summaryrefslogtreecommitdiffstats
path: root/lib/efl/ffi.rb
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2011-05-19 09:47:05 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2011-05-19 09:47:05 +0200
commit422d2cf48320daed5caf35be2d94838268775a1b (patch)
tree4ced7dc7a3f24f35ee2f8bb6ec1efc6c1b360490 /lib/efl/ffi.rb
parenta3fbc22500199376091e37280c0dc336cab2da51 (diff)
downloadffi-efl-422d2cf48320daed5caf35be2d94838268775a1b.zip
ffi-efl-422d2cf48320daed5caf35be2d94838268775a1b.tar.gz
extract find_function from Module specific method_missing
Diffstat (limited to 'lib/efl/ffi.rb')
-rw-r--r--lib/efl/ffi.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/efl/ffi.rb b/lib/efl/ffi.rb
index f66905f..9d206d4 100644
--- a/lib/efl/ffi.rb
+++ b/lib/efl/ffi.rb
@@ -80,6 +80,36 @@ module Efl
#
end
#
+ module ModuleHelper
+ def find_function m, prefix
+ m_s = m.to_s
+ if m_s =~/^(.*)=$/
+ m_s = $1+'_set'
+ args_s = '*args[0]'
+ elsif m_s =~/^(.*)\?$/
+ m_s = $1+'_get'
+ args_s = '*args'
+ else
+ args_s = '*args'
+ end
+ sym = (
+ if Efl::Native.respond_to? prefix+m_s
+ prefix+m_s
+ elsif Efl::Native.respond_to? m_s
+ m_s
+ elsif Efl::Native.respond_to? prefix+m_s+'_get'
+ prefix+m_s+'_get'
+ elsif Efl::Native.respond_to? m_s+'_get'
+ m_s+'_get'
+ else
+ raise NameError.new "#{self.name}.#{m_s} (#{m})"
+ end
+ )
+ [sym, args_s]
+ end
+ module_function :find_function
+ end
+ #
module ClassHelper
def to_a; [self] end
def to_ary; [self] end