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 /tools/genruby.rb | |
parent | a3fbc22500199376091e37280c0dc336cab2da51 (diff) | |
download | ffi-efl-422d2cf48320daed5caf35be2d94838268775a1b.zip ffi-efl-422d2cf48320daed5caf35be2d94838268775a1b.tar.gz |
extract find_function from Module specific method_missing
Diffstat (limited to 'tools/genruby.rb')
-rwxr-xr-x | tools/genruby.rb | 30 |
1 files changed, 5 insertions, 25 deletions
diff --git a/tools/genruby.rb b/tools/genruby.rb index 84f96d4..008837e 100755 --- a/tools/genruby.rb +++ b/tools/genruby.rb @@ -38,31 +38,11 @@ module Efl # module MNAME # + FCT_PREFIX = 'MY_FCT_PREFIX_' + # 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? 'FCT_PREFIX_'+m_s - 'FCT_PREFIX_'+m_s - elsif Efl::Native.respond_to? m_s - m_s - elsif Efl::Native.respond_to? 'FCT_PREFIX_'+m_s+'_get' - 'FCT_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 - ) - 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 # @@ -303,7 +283,7 @@ libraries.collect do |header,module_name,fct_prefix,lib, output| end.each do |lib, output, module_name, fct_prefix, enums, typedefs, callbacks, variables, functions| printf "%-60s", "generate #{output}" open(output,'w:utf-8') do |f| - f << HEADER.gsub(/MNAME/,module_name).gsub(/FCT_PREFIX/,fct_prefix) + f << HEADER.gsub(/MNAME/,module_name).sub(/MY_FCT_PREFIX/,fct_prefix) f << "#{INDENT}#\n#{INDENT}ffi_lib '#{lib}'" f << "\n#{INDENT}#\n#{INDENT}# ENUMS" print "enums, " |