Method: Fiddle::Importer#extern
- Defined in:
- lib/fiddle/import.rb
#extern(signature, *opts) ⇒ Object
Creates a global method from the given C signature.
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/fiddle/import.rb', line 169 def extern(signature, *opts) symname, ctype, argtype = parse_signature(signature, type_alias) opt = (opts) 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)} begin /^(.+?):(\d+)/ =~ caller.first file, line = $1, $2.to_i rescue file, line = __FILE__, __LINE__+3 end module_eval(" def \#{name}(*args, &block)\n @func_map['\#{name}'].call(*args,&block)\n end\n EOS\n module_function(name)\n f\nend\n", file, line) |