diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2011-05-19 08:53:13 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2011-05-19 08:53:13 +0200 |
commit | 055aea9c81c370af51ff6331f626ca470f41c2dd (patch) | |
tree | adf2b5588ab21206961b2641db597af93acd0782 /lib/efl/native/eina.rb | |
parent | b79c8a5851d1d9a5523230158f2d6d5a8b16cdc3 (diff) | |
download | ffi-efl-055aea9c81c370af51ff6331f626ca470f41c2dd.zip ffi-efl-055aea9c81c370af51ff6331f626ca470f41c2dd.tar.gz |
increase Efl::ModuleX::method_missing capabilities
Diffstat (limited to 'lib/efl/native/eina.rb')
-rw-r--r-- | lib/efl/native/eina.rb | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/lib/efl/native/eina.rb b/lib/efl/native/eina.rb index 6f7ea11..a910567 100644 --- a/lib/efl/native/eina.rb +++ b/lib/efl/native/eina.rb @@ -8,8 +8,29 @@ module Efl module Eina # def self.method_missing m, *args, &block - sym = 'eina_'+m.to_s - raise NameError.new "#{self.name}.#{sym} (#{m})" if not Efl::Native.respond_to? sym + 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_'+m_s + 'eina_'+m_s + elsif Efl::Native.respond_to? m_s + m_s + elsif Efl::Native.respond_to? 'eina_'+m_s+'_get' + 'eina_'+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, █ r=Efl::Native.#{sym}(*args); yield r if block_given?; r; end" self.send m, *args, &block end |