]> git.cworth.org Git - apitrace/commitdiff
Cleanup Literal class.
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Sat, 15 Oct 2011 14:10:06 +0000 (15:10 +0100)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Sat, 15 Oct 2011 14:10:06 +0000 (15:10 +0100)
glstate.py
retrace.py
specs/stdapi.py
specs/winapi.py
trace.py

index acd43d07ff32d37f4efaff3dc6c17cc7f6c6a3ea..79cf2de12dc0bab07a7466833e00ff507f4ed008 100644 (file)
@@ -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
index 22ce5eda3066ff321b578bbf09659e2ea0e8bd46..3f55df1da423e7809b37c842038a17775ca563f1 100644 (file)
@@ -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)
index 7044c3818d94ef88f3bc217becc485b0867076f1..0b2fe828babdf11cd1cab3b5db6143b1aae9cc5c 100644 (file)
@@ -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)
index 8f96799e7c9a4aaeb32b3713d3d462d14851ffc1..6e3c60932123ab070213d888ae690f478057148d 100644 (file)
@@ -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)
 
index 5b8f7ecd833d8ab2608640a4ef5fbaff5eb4c57c..2cb11e5b5d98e8f0fe0ba679ef8b9a761d746cd6 100644 (file)
--- 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: