From: José Fonseca Date: Sun, 8 May 2011 23:54:39 +0000 (+0100) Subject: Prevent different enums from obtaining the same id. X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=8bec8a0c309cffea31148ccbf0d5cf76e3e93619;p=apitrace 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 --- 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):