From ede482ecb7e7d8199adc9ccb2e3ba9ed46aa33f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Tue, 19 Apr 2011 10:16:41 +0200 Subject: handle enum constants values --- tools/genruby.rb | 4 ++-- tools/sed-enums | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/genruby.rb b/tools/genruby.rb index 442c59b..7432ffd 100755 --- a/tools/genruby.rb +++ b/tools/genruby.rb @@ -140,7 +140,7 @@ def gen_enums path, indent r = '' open(path+'-enums','r').readlines.each do |l| l.strip! - if not l=~/(typedef enum(?: \w+)?) {([A-Z0-9_ ,]+)} (\w+);/ + if not l=~/(typedef enum(?: \w+)?) {([A-Z0-9_ (\s*=\s*-?[\d+]),]+)} (\w+);/ r << indent+"# #{l}\n#{indent}# FIXME\n" next end @@ -149,7 +149,7 @@ def gen_enums path, indent typename = $3 set_type typename, typename # args = values.split(',').collect { |cst| ':'+cst.strip.downcase }.join ', ' - args = values.split(',').collect { |cst| ':'+cst.strip.downcase.sub(typename.downcase+'_','') }.join ', ' + args = values.split(',').collect { |cst| ':'+cst.strip.downcase.sub(typename.downcase+'_','') }.join(', ').gsub(/=/,',') r << indent+"# #{typedef} {...} #{typename};\n" r << wrap_text( indent+"enum :#{typename.downcase}, [ #{args} ]", 150, indent+' '*4 )+"\n" end diff --git a/tools/sed-enums b/tools/sed-enums index 488d6e1..3c30476 100644 --- a/tools/sed-enums +++ b/tools/sed-enums @@ -1,7 +1,7 @@ s/^\s*typedef\s+(enum(\s+\w+)?).*$/typedef \1 { / T;h :attrs;n -s/^\s*([A-Z0-9_]+).*$/\1, / +s/^\s*([A-Z0-9_]+)(\s*=\s*-?[0-9])?.*$/\1\2, / T next;H;b attrs :next /^\s*\}/ ! b attrs -- cgit v1.1-2-g2b99