summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2011-05-19 08:53:13 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2011-05-19 08:53:13 +0200
commit055aea9c81c370af51ff6331f626ca470f41c2dd (patch)
treeadf2b5588ab21206961b2641db597af93acd0782 /tools
parentb79c8a5851d1d9a5523230158f2d6d5a8b16cdc3 (diff)
downloadffi-efl-055aea9c81c370af51ff6331f626ca470f41c2dd.zip
ffi-efl-055aea9c81c370af51ff6331f626ca470f41c2dd.tar.gz
increase Efl::ModuleX::method_missing capabilities
Diffstat (limited to 'tools')
-rwxr-xr-xtools/genruby.rb27
1 files changed, 24 insertions, 3 deletions
diff --git a/tools/genruby.rb b/tools/genruby.rb
index c7fa66c..84f96d4 100755
--- a/tools/genruby.rb
+++ b/tools/genruby.rb
@@ -39,8 +39,29 @@ module Efl
module MNAME
#
def self.method_missing m, *args, &block
- sym = 'FCT_PREFIX_'+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? '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, &block; r=Efl::Native.\#{sym}(*args); yield r if block_given?; r; end"
self.send m, *args, &block
end
@@ -282,7 +303,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).sub(/FCT_PREFIX/,fct_prefix)
+ f << HEADER.gsub(/MNAME/,module_name).gsub(/FCT_PREFIX/,fct_prefix)
f << "#{INDENT}#\n#{INDENT}ffi_lib '#{lib}'"
f << "\n#{INDENT}#\n#{INDENT}# ENUMS"
print "enums, "