diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2011-04-29 12:38:17 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2011-04-29 12:38:17 +0200 |
commit | b720587b2eb1e3e6b5fe6b6cfcca422fe3a215c8 (patch) | |
tree | 03f86122e5eca239dd4c7bfd3bddae501615a98d /tools | |
parent | 54e381957675a7395785be67cac48c34b66d62c8 (diff) | |
download | ffi-efl-b720587b2eb1e3e6b5fe6b6cfcca422fe3a215c8.zip ffi-efl-b720587b2eb1e3e6b5fe6b6cfcca422fe3a215c8.tar.gz |
get rid of Efl::FFI, flatten lib/efl/ffi, module #method_missing uses module_eval, use @search_paths[] instead of @func_prefix for object #method_missing
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/genruby.rb | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/tools/genruby.rb b/tools/genruby.rb index 2b00004..fafa6a9 100755 --- a/tools/genruby.rb +++ b/tools/genruby.rb @@ -7,19 +7,19 @@ lib_path = File.join path, '..', 'lib', 'efl', 'ffi' # header, module name, fct prefix, lib libraries = [ # HEADER MODUE NAME FCT PREFIX LIB OUTPUT - [ 'eina_types.h', 'Eina', 'eina', 'eina', 'eina/eina_types.rb' ], + [ 'eina_types.h', 'Eina', 'eina', 'eina', 'eina_types.rb' ], [ 'eina_main.h', 'Eina', 'eina', 'eina', 'eina.rb' ], - [ 'eina_list.h', 'EinaList', 'eina_list', 'eina', 'eina/eina_list.rb' ], - [ 'eina_hash.h', 'EinaHash', 'eina_hash', 'eina', 'eina/eina_hash.rb' ], + [ 'eina_list.h', 'EinaList', 'eina_list', 'eina', 'eina_list.rb' ], + [ 'eina_hash.h', 'EinaHash', 'eina_hash', 'eina', 'eina_hash.rb' ], [ 'Eet.h', 'Eet', 'eet', 'eet', 'eet.rb' ], [ 'Evas.h', 'Evas', 'evas', 'evas', 'evas.rb' ], # [ 'Evas_GL.h', 'EvasGl', 'evas_gl', 'evas', 'evas/evas_gl.rb' ], [ 'Edje.h', 'Edje', 'edje', 'edje', 'edje.rb' ], [ 'Ecore.h', 'Ecore', 'ecore', 'ecore', 'ecore.rb' ], # [ 'Ecore_Con.h', 'EcoreCon', 'ecore_con', 'ecore', 'ecore/ecore_con.rb' ], - [ 'Ecore_Input.h', 'EcoreInput', 'ecore_event', 'ecore_input', 'ecore/ecore_input.rb' ], - [ 'Ecore_Getopt.h', 'EcoreGetopt', 'ecore_getopt', 'ecore', 'ecore/ecore_getopt.rb' ], - [ 'Ecore_Evas.h', 'EcoreEvas', 'ecore_evas', 'ecore_evas', 'ecore/ecore_evas.rb' ], + [ 'Ecore_Input.h', 'EcoreInput', 'ecore_event', 'ecore_input', 'ecore_input.rb' ], + [ 'Ecore_Getopt.h', 'EcoreGetopt', 'ecore_getopt', 'ecore', 'ecore_getopt.rb' ], + [ 'Ecore_Evas.h', 'EcoreEvas', 'ecore_evas', 'ecore_evas', 'ecore_evas.rb' ], # [ 'Ecore_Fb.h', 'EcoreFb', 'ecore', 'ecore', 'ecore/ecore_fb.rb' ], # [ 'Ecore_File.h', 'EcoreFile', 'ecore', 'ecore', 'ecore/ecore_file.rb' ], [ 'Elementary.h', 'Elm', 'elm', 'libelementary-ver-pre-svn-09.so.0', 'elementary.rb' ], @@ -36,13 +36,15 @@ require 'efl/ffi' module Efl # module MNAME + # + extend Efl::FFIHelper + # def self.method_missing m, *args, &block - return Efl::FFI.send 'PREFIX_'+m.to_s, *args, &block + sym = 'FCT_PREFIX_'+m.to_s + raise NameError.new "\#{self.name}.\#{sym} (\#{m})" if not self.respond_to? sym + self.module_eval "def self.\#{m} *args, █ r=self.\#{sym}(*args); yield r if block_given?; r; end" + self.send sym, *args, &block end - end - # - module FFI - # EOF FOOTER =<<-EOF end @@ -257,7 +259,7 @@ libraries.collect do |header,module_name,fct_prefix,lib, output| end.each do |lib, output, module_name, fct_prefix, enums, typedefs, callbacks, functions| printf "%-60s", "generate #{output}" open(output,'w:utf-8') do |f| - f << HEADER.sub(/MNAME/,module_name).sub(/PREFIX/,fct_prefix) + f << HEADER.gsub(/MNAME/,module_name).sub(/FCT_PREFIX/,fct_prefix) f << "#{INDENT}#\n#{INDENT}ffi_lib '#{lib}'" f << "\n#{INDENT}#\n#{INDENT}# ENUMS" print "enums, " @@ -271,7 +273,7 @@ end.each do |lib, output, module_name, fct_prefix, enums, typedefs, callbacks, f f << "\n#{INDENT}#\n#{INDENT}# FUNCTIONS" puts "functions." f << "\n"+functions.join("\n") unless functions.empty? - f << "\n#{INDENT}#\n#{INDENT}attach_fcts fcts\n" + f << "\n#{INDENT}#\n#{INDENT}attach_fcts fcts\n#{INDENT}#\n" f << FOOTER end end |