summaryrefslogtreecommitdiff
path: root/ext/dl/lib/dl/import.rb
diff options
context:
space:
mode:
Diffstat (limited to 'ext/dl/lib/dl/import.rb')
-rw-r--r--ext/dl/lib/dl/import.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/ext/dl/lib/dl/import.rb b/ext/dl/lib/dl/import.rb
index a318430b73..9005153624 100644
--- a/ext/dl/lib/dl/import.rb
+++ b/ext/dl/lib/dl/import.rb
@@ -79,6 +79,7 @@ module DL
end
def sizeof(ty)
+ @type_alias ||= nil
case ty
when String
ty = parse_ctype(ty, @type_alias).abs()
@@ -128,6 +129,7 @@ module DL
private :parse_bind_options
def extern(signature, *opts)
+ @type_alias ||= nil
symname, ctype, argtype = parse_signature(signature, @type_alias)
opt = parse_bind_options(opts)
f = import_function(symname, ctype, argtype, opt[:call_type])
@@ -150,6 +152,7 @@ module DL
end
def bind(signature, *opts, &blk)
+ @type_alias ||= nil
name, ctype, argtype = parse_signature(signature, @type_alias)
h = parse_bind_options(opts)
case h[:callback_type]
@@ -183,6 +186,7 @@ module DL
#
# MyStruct = struct ['int i', 'char c']
def struct(signature)
+ @type_alias ||= nil
tys, mems = parse_struct_signature(signature, @type_alias)
DL::CStructBuilder.create(CStruct, tys, mems)
end
@@ -191,6 +195,7 @@ module DL
#
# MyUnion = union ['int i', 'char c']
def union(signature)
+ @type_alias ||= nil
tys, mems = parse_struct_signature(signature, @type_alias)
DL::CStructBuilder.create(CUnion, tys, mems)
end
@@ -216,7 +221,8 @@ module DL
end
def handler
- @handler or raise "call dlload before importing symbols and functions"
+ defined?(@handler) or raise "call dlload before importing symbols and functions"
+ @handler
end
def import_symbol(name)