summaryrefslogtreecommitdiffstats
path: root/lib/efl/native/eina_hash.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/native/eina_hash.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/native/eina_hash.rb')
-rw-r--r--lib/efl/native/eina_hash.rb28
1 files changed, 4 insertions, 24 deletions
diff --git a/lib/efl/native/eina_hash.rb b/lib/efl/native/eina_hash.rb
index f1df86e..5599da4 100644
--- a/lib/efl/native/eina_hash.rb
+++ b/lib/efl/native/eina_hash.rb
@@ -7,31 +7,11 @@ module Efl
#
module EinaHash
#
+ FCT_PREFIX = 'eina_hash_'
+ #
def self.method_missing m, *args, &block
- 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? 'eina_hash_'+m_s
- 'eina_hash_'+m_s
- elsif Efl::Native.respond_to? m_s
- m_s
- elsif Efl::Native.respond_to? 'eina_hash_'+m_s+'_get'
- 'eina_hash_'+m_s+'_get'
- elsif Efl::Native.respond_to? m_s+'_get'
- m_s+'_get'
- else
- raise NameError.new "#{self.name}.#{m_s} (#{m})"
- end
- )
- self.module_eval "def self.#{m} *args, &block; r=Efl::Native.#{sym}(*args); yield r if block_given?; r; end"
+ sym, args_s = ModuleHelper.find_function m, FCT_PREFIX
+ self.module_eval "def self.#{m} *args, &block; r=Efl::Native.#{sym}(#{args_s}); yield r if block_given?; r; end"
self.send m, *args, &block
end
#