diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2012-02-24 17:37:48 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2012-02-24 17:37:48 +0100 |
commit | 5c2f92768fc4c2949a60bd2849989295ac9f986d (patch) | |
tree | 211bd90571e641a3d28b3025033164c2f930b3eb /tools | |
parent | 9aa92b05eeb263a3c14529291ebc8311ba7760f7 (diff) | |
download | ffi-efl-5c2f92768fc4c2949a60bd2849989295ac9f986d.zip ffi-efl-5c2f92768fc4c2949a60bd2849989295ac9f986d.tar.gz |
tools/genruby.rb: rewrite set_type and get_type to allow usage of efl defined types as function parameter types
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/genruby.rb | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/tools/genruby.rb b/tools/genruby.rb index e1b891a..2265ed1 100755 --- a/tools/genruby.rb +++ b/tools/genruby.rb @@ -85,20 +85,21 @@ TYPES = { 'struct tm *' => ':pointer', 'struct timeval *' => ':pointer', 'struct sockaddr *' => ':pointer', - 'Eina_Bool' => ':eina_bool' } -# -TYPES_USAGE = {} +ETYPES = { + 'Eina_Bool' => ':bool' +} # def set_type t, sym - if TYPES[t].nil? + return ETYPES['Eina_Bool'] if t=='Eina_Bool' + if ETYPES[t].nil? +# v = ( ETYPES[sym].nil? ? ( TYPES[sym].nil? ? ':'+sym.downcase : TYPES[sym] ) : ETYPES[sym] ) v = ( TYPES[sym].nil? ? ':'+sym.downcase : TYPES[sym] ) - TYPES[t] = v - puts " define type : #{t} => #{v}" + ETYPES[t] = v + printf "\033[0;35m%40s\033[0m => \033[0;36m%s\033[0m\n",t,v return v else - return TYPES['Eina_Bool'] if t=='Eina_Bool' - puts "ERROR type #{t} => #{sym} alredy exists!" + printf "\033[0;31mERROR type #{t} => #{sym} alredy exists!\033[0m\n" exit 1 end end @@ -106,12 +107,17 @@ end def get_type t k = t.gsub(/(const|enum|union)/, '').strip r = TYPES[k] - if r.nil? - return ':pointer' if k=~ /\*/ - puts "unknown type >#{k}< #{t}" + return r unless r.nil? + r = ETYPES[k] + return r unless r.nil? + if not k=~ /\*/ + printf "\033[0;31munknown type >#{k}< #{t}\033[0m\n" exit 1 end - r + k = k.gsub(/[ \*]*/, '').strip + r = ETYPES[k] + return ':'+k.downcase if r==':pointer' + ':pointer' end # def get_type_from_arg arg, l |