summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2011-09-02 01:33:52 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2011-09-02 01:33:52 +0200
commitc0ca65e4dfa1233e452209e624d749709d7502f0 (patch)
tree628066c547e42329ef9600684ca6de02e4d2582d
parent1ad98d67facecc172300a0627ce532f88a7073fc (diff)
downloadffi-efl-c0ca65e4dfa1233e452209e624d749709d7502f0.zip
ffi-efl-c0ca65e4dfa1233e452209e624d749709d7502f0.tar.gz
Efl::Native: wrap #ffi_lib so we can trace all linked libraries, add #find_variable
-rw-r--r--lib/efl/ffi.rb36
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,