From: José Fonseca Date: Sat, 15 Oct 2011 14:10:06 +0000 (+0100) Subject: Cleanup Literal class. X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=2f2ea48c8f1729bf20936d550b6294bafadb6140;p=apitrace Cleanup Literal class. --- diff --git a/glstate.py b/glstate.py index acd43d0..79cf2de 100644 --- a/glstate.py +++ b/glstate.py @@ -189,9 +189,9 @@ class JsonWriter(Visitor): It expects a previously declared JSONWriter instance named "json".''' def visit_literal(self, literal, instance): - if literal.format == 'Bool': + if literal.kind == 'Bool': print ' json.writeBool(%s);' % instance - elif literal.format in ('SInt', 'Uint', 'Float', 'Double'): + elif literal.kind in ('SInt', 'Uint', 'Float', 'Double'): print ' json.writeNumber(%s);' % instance else: raise NotImplementedError diff --git a/retrace.py b/retrace.py index 22ce5ed..3f55df1 100644 --- a/retrace.py +++ b/retrace.py @@ -53,8 +53,7 @@ def handle_entry(handle, value): class ValueExtractor(stdapi.Visitor): def visit_literal(self, literal, lvalue, rvalue): - #if literal.format in ('Bool', 'UInt'): - print ' %s = (%s).to%s();' % (lvalue, rvalue, literal.format) + print ' %s = (%s).to%s();' % (lvalue, rvalue, literal.kind) def visit_const(self, const, lvalue, rvalue): self.visit(const.type, lvalue, rvalue) diff --git a/specs/stdapi.py b/specs/stdapi.py index 7044c38..0b2fe82 100644 --- a/specs/stdapi.py +++ b/specs/stdapi.py @@ -80,10 +80,14 @@ Void = _Void() class Literal(Type): + """Class to describe literal types. - def __init__(self, expr, format): + Types which are not defined in terms of other types, such as integers and + floats.""" + + def __init__(self, expr, kind): Type.__init__(self, expr) - self.format = format + self.kind = kind def visit(self, visitor, *args, **kwargs): return visitor.visit_literal(self, *args, **kwargs) diff --git a/specs/winapi.py b/specs/winapi.py index 8f96799..6e3c609 100644 --- a/specs/winapi.py +++ b/specs/winapi.py @@ -49,7 +49,7 @@ BYTE = Alias("BYTE", UInt8) WORD = Alias("WORD", UInt16) DWORD = Alias("DWORD", UInt32) -WCHAR = Literal("WCHAR", "SInt") +WCHAR = Alias("WCHAR", Short) BOOL = Alias("BOOL", Bool) diff --git a/trace.py b/trace.py index 5b8f7ec..2cb11e5 100644 --- a/trace.py +++ b/trace.py @@ -152,7 +152,7 @@ class DumpImplementer(stdapi.Visitor): '''Dump an instance.''' def visit_literal(self, literal, instance): - print ' Trace::localWriter.write%s(%s);' % (literal.format, instance) + print ' Trace::localWriter.write%s(%s);' % (literal.kind, instance) def visit_string(self, string, instance): if string.length is not None: