1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Add Importable::symbol.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2604 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ttate 2002-06-27 15:09:47 +00:00
parent ad8c8144d4
commit 98007267bc

View file

@ -105,6 +105,29 @@ module DL
@types.typealias(*args)
end
# example:
# symbol "foo_value"
# symbol "foo_func", "IIP"
#
def symbol(name, ty = nil)
sym = nil
@LIBS.each{|lib|
begin
if( ty )
sym = lib[name, ty]
else
sym = lib[name]
end
rescue
next
end
}
if( !sym )
raise(RuntimeError, "can't find the symbol `#{name}'")
end
return sym
end
# example:
# import("get_length", "int", ["void*", "int"])
#
@ -116,12 +139,7 @@ module DL
ty,enc,dec = encode_types(argtypes)
symty = rty + ty
@LIBS.each{|lib|
begin
sym = lib[name, symty]
rescue
next
end
sym = symbol(name, symty)
mname = name.dup
if( ?A <= mname[0] && mname[0] <= ?Z )
@ -154,8 +172,6 @@ module DL
].join("\n")
return sym
}
raise(RuntimeError, "can't find #{name}.")
end
def _args_