From 8bec8a0c309cffea31148ccbf0d5cf76e3e93619 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Mon, 9 May 2011 00:54:39 +0100 Subject: [PATCH] Prevent different enums from obtaining the same id. 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 | 4 ---- trace.py | 5 ++++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/stdapi.py b/stdapi.py index 38f5db5..586d2d3 100644 --- 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): diff --git a/trace.py b/trace.py index 7076c9f..9f115a3 100644 --- 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): -- 2.7.4