diff options
-rwxr-xr-x | tools/genruby.rb | 4 | ||||
-rw-r--r-- | 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 |