]> thyrsus.com Git - ctopy.git/commitdiff
Enumeration processing is working,
authorEric S. Raymond <esr@thyrsus.com>
Mon, 2 Oct 2006 14:07:07 +0000 (14:07 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Mon, 2 Oct 2006 14:07:07 +0000 (14:07 +0000)
ctopy

diff --git a/ctopy b/ctopy
index 02f6744b17bc058ff5d79ba43b47572d630b20f7..1457df1e7a437b78206595c914a305f5b00458f2 100755 (executable)
--- a/ctopy
+++ b/ctopy
@@ -18,6 +18,7 @@ Limitations:
     * C comma expressions will spuriously turn into Python tuuple constructors,
     * We don't translate frexp and modf because their call conventions differ
       between Python and C, so we want them to throw an error.
+    * Enumerations with only some values specified are not yet handled
 """
 import sys, re
 
@@ -334,6 +335,15 @@ def ctopy(input):
                     regions[i] = '# From anonymous typedefed enum (?!)\n'
             else:
                 regions[i] = re.sub(",\s*", "\n", regions[i])
+                val = 0
+                txt = regions[i].split("\n")
+                for j in range(len(txt)):
+                    if txt[j] == '' or txt[j].startswith("{"):
+                        pass
+                    elif '=' not in txt[j]:
+                        txt[j] += " = %d" % val
+                        val += 1
+                regions[i] = "\n".join(txt)
     if debug:
         "Final transformations begin"
     regions = map(lambda r: single_apply(final_transformations, r),regions)