From c0ca65e4dfa1233e452209e624d749709d7502f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 2 Sep 2011 01:33:52 +0200 Subject: Efl::Native: wrap #ffi_lib so we can trace all linked libraries, add #find_variable --- lib/efl/ffi.rb | 36 ++++++++++++++++++++++++++---------- 1 file 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, -- cgit v1.1-2-g2b99