diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2011-05-19 09:47:05 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2011-05-19 09:47:05 +0200 |
commit | 422d2cf48320daed5caf35be2d94838268775a1b (patch) | |
tree | 4ced7dc7a3f24f35ee2f8bb6ec1efc6c1b360490 /lib/efl/native | |
parent | a3fbc22500199376091e37280c0dc336cab2da51 (diff) | |
download | ffi-efl-422d2cf48320daed5caf35be2d94838268775a1b.zip ffi-efl-422d2cf48320daed5caf35be2d94838268775a1b.tar.gz |
extract find_function from Module specific method_missing
Diffstat (limited to 'lib/efl/native')
-rw-r--r-- | lib/efl/native/ecore.rb | 28 | ||||
-rw-r--r-- | lib/efl/native/ecore_evas.rb | 28 | ||||
-rw-r--r-- | lib/efl/native/ecore_getopt.rb | 28 | ||||
-rw-r--r-- | lib/efl/native/ecore_input.rb | 28 | ||||
-rw-r--r-- | lib/efl/native/edje.rb | 28 | ||||
-rw-r--r-- | lib/efl/native/eet.rb | 28 | ||||
-rw-r--r-- | lib/efl/native/eina.rb | 28 | ||||
-rw-r--r-- | lib/efl/native/eina_hash.rb | 28 | ||||
-rw-r--r-- | lib/efl/native/eina_list.rb | 28 | ||||
-rw-r--r-- | lib/efl/native/eina_log.rb | 28 | ||||
-rw-r--r-- | lib/efl/native/eina_types.rb | 28 | ||||
-rw-r--r-- | lib/efl/native/elementary.rb | 28 | ||||
-rw-r--r-- | lib/efl/native/evas.rb | 28 |
13 files changed, 52 insertions, 312 deletions
diff --git a/lib/efl/native/ecore.rb b/lib/efl/native/ecore.rb index 71e7daa..d790bd2 100644 --- a/lib/efl/native/ecore.rb +++ b/lib/efl/native/ecore.rb @@ -7,31 +7,11 @@ module Efl # module Ecore # + FCT_PREFIX = 'ecore_' + # 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? 'ecore_'+m_s - 'ecore_'+m_s - elsif Efl::Native.respond_to? m_s - m_s - elsif Efl::Native.respond_to? 'ecore_'+m_s+'_get' - 'ecore_'+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" + sym, args_s = ModuleHelper.find_function m, FCT_PREFIX + self.module_eval "def self.#{m} *args, █ r=Efl::Native.#{sym}(#{args_s}); yield r if block_given?; r; end" self.send m, *args, &block end # diff --git a/lib/efl/native/ecore_evas.rb b/lib/efl/native/ecore_evas.rb index 4413980..f1f1112 100644 --- a/lib/efl/native/ecore_evas.rb +++ b/lib/efl/native/ecore_evas.rb @@ -7,31 +7,11 @@ module Efl # module EcoreEvas # + FCT_PREFIX = 'ecore_evas_' + # 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? 'ecore_evas_'+m_s - 'ecore_evas_'+m_s - elsif Efl::Native.respond_to? m_s - m_s - elsif Efl::Native.respond_to? 'ecore_evas_'+m_s+'_get' - 'ecore_evas_'+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" + sym, args_s = ModuleHelper.find_function m, FCT_PREFIX + self.module_eval "def self.#{m} *args, █ r=Efl::Native.#{sym}(#{args_s}); yield r if block_given?; r; end" self.send m, *args, &block end # diff --git a/lib/efl/native/ecore_getopt.rb b/lib/efl/native/ecore_getopt.rb index feb74e8..ddce66b 100644 --- a/lib/efl/native/ecore_getopt.rb +++ b/lib/efl/native/ecore_getopt.rb @@ -7,31 +7,11 @@ module Efl # module EcoreGetopt # + FCT_PREFIX = 'ecore_getopt_' + # 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? 'ecore_getopt_'+m_s - 'ecore_getopt_'+m_s - elsif Efl::Native.respond_to? m_s - m_s - elsif Efl::Native.respond_to? 'ecore_getopt_'+m_s+'_get' - 'ecore_getopt_'+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" + sym, args_s = ModuleHelper.find_function m, FCT_PREFIX + self.module_eval "def self.#{m} *args, █ r=Efl::Native.#{sym}(#{args_s}); yield r if block_given?; r; end" self.send m, *args, &block end # diff --git a/lib/efl/native/ecore_input.rb b/lib/efl/native/ecore_input.rb index ba246f2..88df1e1 100644 --- a/lib/efl/native/ecore_input.rb +++ b/lib/efl/native/ecore_input.rb @@ -7,31 +7,11 @@ module Efl # module EcoreInput # + FCT_PREFIX = 'ecore_event_' + # 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? 'ecore_event_'+m_s - 'ecore_event_'+m_s - elsif Efl::Native.respond_to? m_s - m_s - elsif Efl::Native.respond_to? 'ecore_event_'+m_s+'_get' - 'ecore_event_'+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" + sym, args_s = ModuleHelper.find_function m, FCT_PREFIX + self.module_eval "def self.#{m} *args, █ r=Efl::Native.#{sym}(#{args_s}); yield r if block_given?; r; end" self.send m, *args, &block end # diff --git a/lib/efl/native/edje.rb b/lib/efl/native/edje.rb index 8b2d849..af7cf61 100644 --- a/lib/efl/native/edje.rb +++ b/lib/efl/native/edje.rb @@ -7,31 +7,11 @@ module Efl # module Edje # + FCT_PREFIX = 'edje_' + # 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? 'edje_'+m_s - 'edje_'+m_s - elsif Efl::Native.respond_to? m_s - m_s - elsif Efl::Native.respond_to? 'edje_'+m_s+'_get' - 'edje_'+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" + sym, args_s = ModuleHelper.find_function m, FCT_PREFIX + self.module_eval "def self.#{m} *args, █ r=Efl::Native.#{sym}(#{args_s}); yield r if block_given?; r; end" self.send m, *args, &block end # diff --git a/lib/efl/native/eet.rb b/lib/efl/native/eet.rb index e035c85..606a8a3 100644 --- a/lib/efl/native/eet.rb +++ b/lib/efl/native/eet.rb @@ -7,31 +7,11 @@ module Efl # module Eet # + FCT_PREFIX = 'eet_' + # 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? 'eet_'+m_s - 'eet_'+m_s - elsif Efl::Native.respond_to? m_s - m_s - elsif Efl::Native.respond_to? 'eet_'+m_s+'_get' - 'eet_'+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" + sym, args_s = ModuleHelper.find_function m, FCT_PREFIX + self.module_eval "def self.#{m} *args, █ r=Efl::Native.#{sym}(#{args_s}); yield r if block_given?; r; end" self.send m, *args, &block end # diff --git a/lib/efl/native/eina.rb b/lib/efl/native/eina.rb index a910567..9c831f7 100644 --- a/lib/efl/native/eina.rb +++ b/lib/efl/native/eina.rb @@ -7,31 +7,11 @@ module Efl # module Eina # + FCT_PREFIX = 'eina_' + # 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_'+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" + sym, args_s = ModuleHelper.find_function m, FCT_PREFIX + self.module_eval "def self.#{m} *args, █ r=Efl::Native.#{sym}(#{args_s}); yield r if block_given?; r; end" self.send m, *args, &block end # 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, █ 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, █ r=Efl::Native.#{sym}(#{args_s}); yield r if block_given?; r; end" self.send m, *args, &block end # diff --git a/lib/efl/native/eina_list.rb b/lib/efl/native/eina_list.rb index 1d5396a..b24bce9 100644 --- a/lib/efl/native/eina_list.rb +++ b/lib/efl/native/eina_list.rb @@ -7,31 +7,11 @@ module Efl # module EinaList # + FCT_PREFIX = 'eina_list_' + # 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_list_'+m_s - 'eina_list_'+m_s - elsif Efl::Native.respond_to? m_s - m_s - elsif Efl::Native.respond_to? 'eina_list_'+m_s+'_get' - 'eina_list_'+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" + sym, args_s = ModuleHelper.find_function m, FCT_PREFIX + self.module_eval "def self.#{m} *args, █ r=Efl::Native.#{sym}(#{args_s}); yield r if block_given?; r; end" self.send m, *args, &block end # diff --git a/lib/efl/native/eina_log.rb b/lib/efl/native/eina_log.rb index c7b2acb..1aabb3c 100644 --- a/lib/efl/native/eina_log.rb +++ b/lib/efl/native/eina_log.rb @@ -7,31 +7,11 @@ module Efl # module EinaLog # + FCT_PREFIX = 'eina_log_' + # 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_log_'+m_s - 'eina_log_'+m_s - elsif Efl::Native.respond_to? m_s - m_s - elsif Efl::Native.respond_to? 'eina_log_'+m_s+'_get' - 'eina_log_'+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" + sym, args_s = ModuleHelper.find_function m, FCT_PREFIX + self.module_eval "def self.#{m} *args, █ r=Efl::Native.#{sym}(#{args_s}); yield r if block_given?; r; end" self.send m, *args, &block end # diff --git a/lib/efl/native/eina_types.rb b/lib/efl/native/eina_types.rb index fbe7130..e23b0a4 100644 --- a/lib/efl/native/eina_types.rb +++ b/lib/efl/native/eina_types.rb @@ -7,31 +7,11 @@ module Efl # module Eina # + FCT_PREFIX = 'eina_' + # 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_'+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" + sym, args_s = ModuleHelper.find_function m, FCT_PREFIX + self.module_eval "def self.#{m} *args, █ r=Efl::Native.#{sym}(#{args_s}); yield r if block_given?; r; end" self.send m, *args, &block end # diff --git a/lib/efl/native/elementary.rb b/lib/efl/native/elementary.rb index 7e2dc4d..76bc3d0 100644 --- a/lib/efl/native/elementary.rb +++ b/lib/efl/native/elementary.rb @@ -8,31 +8,11 @@ module Efl # module Elm # + FCT_PREFIX = 'elm_' + # 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? 'elm_'+m_s - 'elm_'+m_s - elsif Efl::Native.respond_to? m_s - m_s - elsif Efl::Native.respond_to? 'elm_'+m_s+'_get' - 'elm_'+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" + sym, args_s = ModuleHelper.find_function m, FCT_PREFIX + self.module_eval "def self.#{m} *args, █ r=Efl::Native.#{sym}(#{args_s}); yield r if block_given?; r; end" self.send m, *args, &block end # diff --git a/lib/efl/native/evas.rb b/lib/efl/native/evas.rb index bd316e0..4f258d0 100644 --- a/lib/efl/native/evas.rb +++ b/lib/efl/native/evas.rb @@ -7,31 +7,11 @@ module Efl # module Evas # + FCT_PREFIX = 'evas_' + # 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? 'evas_'+m_s - 'evas_'+m_s - elsif Efl::Native.respond_to? m_s - m_s - elsif Efl::Native.respond_to? 'evas_'+m_s+'_get' - 'evas_'+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" + sym, args_s = ModuleHelper.find_function m, FCT_PREFIX + self.module_eval "def self.#{m} *args, █ r=Efl::Native.#{sym}(#{args_s}); yield r if block_given?; r; end" self.send m, *args, &block end # |