diff options
-rw-r--r-- | lib/efl/ffi.rb | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/lib/efl/ffi.rb b/lib/efl/ffi.rb index 422f173..f1c1d7d 100644 --- a/lib/efl/ffi.rb +++ b/lib/efl/ffi.rb @@ -9,6 +9,32 @@ module Efl # extend FFI::Library # + def self.attach_fcts fcts + fcts.each do |func| + begin + attach_function(*func) + rescue Object => e + puts "Could not attach #{func} #{e.message}" + end + end + end + # + class << self + alias :ffi_lib_orig :ffi_lib + def ffi_lib *names + @all_ffi_libs||=[] + @all_ffi_libs += ffi_lib_orig(names) + @all_ffi_libs.uniq! + end + def find_variable name + @all_ffi_libs.each do |lib| + address = lib.find_variable name + return address if not address.nil? + end + return nil + end + end + # typedef :pointer, :char_p typedef :pointer, :short_p typedef :pointer, :int_p @@ -44,16 +70,6 @@ module Efl callback :eina_each_cb, [ :void_p, :void_p, :void_p ], :eina_bool callback :eina_free_cb, [ :void_p ], :void # - def self.attach_fcts fcts - fcts.each do |func| - begin - attach_function(*func) - rescue Object => e - puts "Could not attach #{func} #{e.message}" - end - end - end - # class VersionStruct < FFI::Struct layout :major, :int, :minor, :int, |