bind(signature, *opts, &blk)
public
Creates a global method from the given C signature using the given
opts as bind parameters
with the given block.
# File ext/fiddle/lib/fiddle/import.rb, line 193
def bind(signature, *opts, &blk)
name, ctype, argtype = parse_signature(signature, type_alias)
h = parse_bind_options(opts)
case h[:callback_type]
when :bind, nil
f = bind_function(name, ctype, argtype, h[:call_type], &blk)
else
raise(RuntimeError, "unknown callback type: #{h[:callback_type]}")
end
@func_map[name] = f
#define_method(name){|*args,&block| f.call(*args,&block)}
begin
/^(.+?):(\d+)/ =~ caller.first
file, line = $1, $2.to_i
rescue
file, line = __FILE__, __LINE__+3
end
module_eval( def #{name}(*args,&block) @func_map['#{name}'].call(*args,&block) end, file, line)
module_function(name)
f
end