summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosé Fonseca <jose.r.fonseca@gmail.com>2011-10-15 15:10:06 +0100
committerJosé Fonseca <jose.r.fonseca@gmail.com>2011-10-15 15:10:06 +0100
commit2f2ea48c8f1729bf20936d550b6294bafadb6140 (patch)
treea16936615e1c4b393180bdd0df206be9af6933bc
parent02c2500281c9af1039c272874f38e7802c9acfb9 (diff)
Cleanup Literal class.
-rw-r--r--glstate.py4
-rw-r--r--retrace.py3
-rw-r--r--specs/stdapi.py8
-rw-r--r--specs/winapi.py2
-rw-r--r--trace.py2
5 files changed, 11 insertions, 8 deletions
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: