Prevent different enums from obtaining the same id.
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Sun, 8 May 2011 23:54:39 +0000 (00:54 +0100)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Sun, 8 May 2011 23:54:39 +0000 (00:54 +0100)
Regression introduced whith the merge of glenum,py and glparams, because
we manipulate enums after creating then,

Thanks to Zack for spotting this

stdapi.py
trace.py

index 38f5db5..586d2d3 100644 (file)
--- a/stdapi.py
+++ b/stdapi.py
@@ -126,12 +126,8 @@ def ConstPointer(type):
 
 class Enum(Type):
 
-    __vid = 0
-
     def __init__(self, name, values):
         Type.__init__(self, name)
-        self.vid = Enum.__vid
-        Enum.__vid += len(values)
         self.values = list(values)
     
     def visit(self, visitor, *args, **kwargs):
index 7076c9f..9f115a3 100644 (file)
--- a/trace.py
+++ b/trace.py
@@ -73,12 +73,15 @@ class DumpDeclarator(stdapi.OnceVisitor):
     def visit_blob(self, array):
         pass
 
+    __enum_id = 0
+
     def visit_enum(self, enum):
         print 'static void __traceEnum%s(const %s value) {' % (enum.id, enum.expr)
         n = len(enum.values)
         for i in range(n):
             value = enum.values[i]
-            print '    static const Trace::EnumSig sig%u = {%u, "%s", %s};' % (i, enum.vid + i, value, value)
+            print '    static const Trace::EnumSig sig%u = {%u, "%s", %s};' % (i, DumpDeclarator.__enum_id, value, value)
+            DumpDeclarator.__enum_id += 1
         print '    const Trace::EnumSig *sig;'
         print '    switch(value) {'
         for i in range(n):