summaryrefslogtreecommitdiff
path: root/ext/dl/lib
diff options
context:
space:
mode:
authorttate <ttate@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-02-07 09:45:02 +0000
committerttate <ttate@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-02-07 09:45:02 +0000
commit7bcc13550437e1c4198fbf6212abc8e7672e1adb (patch)
treecf1236e58aba577543c8788adbca32293d2d4ad4 /ext/dl/lib
parent48a86f5ffafb2744fac609714fee74f1872df84b (diff)
Improved DL::Handle#sym.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7911 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/dl/lib')
-rw-r--r--ext/dl/lib/dl/cparser.rb2
-rw-r--r--ext/dl/lib/dl/func.rb4
-rw-r--r--ext/dl/lib/dl/import.rb5
-rw-r--r--ext/dl/lib/dl/value.rb7
4 files changed, 13 insertions, 5 deletions
diff --git a/ext/dl/lib/dl/cparser.rb b/ext/dl/lib/dl/cparser.rb
index 5b5dd5f478..c897d1b69f 100644
--- a/ext/dl/lib/dl/cparser.rb
+++ b/ext/dl/lib/dl/cparser.rb
@@ -39,7 +39,7 @@ module DL
tymap ||= {}
signature = signature.gsub(/\s+/, " ").strip
case signature
- when /^([\d\w\*_\s]+)\(([\d\w\*_\s\,\[\]]*)\)$/
+ when /^([\d\w@\*_\s]+)\(([\d\w\*_\s\,\[\]]*)\)$/
ret = $1
args = $2
ret = ret.split(/\s+/)
diff --git a/ext/dl/lib/dl/func.rb b/ext/dl/lib/dl/func.rb
index 121f2efcc0..b29aebcc8b 100644
--- a/ext/dl/lib/dl/func.rb
+++ b/ext/dl/lib/dl/func.rb
@@ -27,7 +27,7 @@ module DL
def call(*args, &block)
funcs = []
- args = wrap_args(args, nil, funcs, &block)
+ args = wrap_args(args, @stack.types, funcs, &block)
r = @cfunc.call(@stack.pack(args))
funcs.each{|f| f.unbind_at_call()}
return wrap_result(r)
@@ -59,7 +59,7 @@ module DL
end
}
r = block.call(*ary)
- wrap_arg(r, nil, [])
+ wrap_arg(r, @cfunc.ctype, [])
}
case @cfunc.calltype
when :cdecl
diff --git a/ext/dl/lib/dl/import.rb b/ext/dl/lib/dl/import.rb
index 2ad805598a..ebd84eb471 100644
--- a/ext/dl/lib/dl/import.rb
+++ b/ext/dl/lib/dl/import.rb
@@ -113,9 +113,10 @@ module DL
private :parse_bind_options
def extern(signature, *opts)
- name, ctype, argtype = parse_signature(signature, @type_alias)
+ symname, ctype, argtype = parse_signature(signature, @type_alias)
opt = parse_bind_options(opts)
- f = import_function(name, ctype, argtype, opt[:call_type])
+ f = import_function(symname, ctype, argtype, opt[:call_type])
+ name = symname.gsub(/@.+/,'')
@func_map[name] = f
#define_method(name){|*args,&block| f.call(*args,&block)}
module_eval(<<-EOS)
diff --git a/ext/dl/lib/dl/value.rb b/ext/dl/lib/dl/value.rb
index 1357106a42..aa7e0dd325 100644
--- a/ext/dl/lib/dl/value.rb
+++ b/ext/dl/lib/dl/value.rb
@@ -50,6 +50,13 @@ module DL
case arg
when CPtr
return arg.to_i
+ when IO
+ case ty
+ when TYPE_VOIDP
+ return CPtr[arg].to_i
+ else
+ return arg.to_i
+ end
when Function
if( block )
arg.bind_at_call(&block)