diff options
Diffstat (limited to 'src/gallium/tools/trace/model.py')
-rwxr-xr-x | src/gallium/tools/trace/model.py | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/src/gallium/tools/trace/model.py b/src/gallium/tools/trace/model.py index 8276a8f9c61..82aca6935bf 100755 --- a/src/gallium/tools/trace/model.py +++ b/src/gallium/tools/trace/model.py @@ -32,13 +32,15 @@ import sys import string -import format +import binascii try: from cStringIO import StringIO except ImportError: from StringIO import StringIO +import format + class Node: @@ -62,6 +64,22 @@ class Literal(Node): visitor.visit_literal(self) +class Blob(Node): + + def __init__(self, value): + self._rawValue = None + self._hexValue = value + + def getValue(self): + if self._rawValue is None: + self._rawValue = binascii.a2b_hex(self._hexValue) + self._hexValue = None + return self._rawValue + + def visit(self, visitor): + visitor.visit_blob(self) + + class NamedConstant(Node): def __init__(self, name): @@ -127,6 +145,9 @@ class Visitor: def visit_literal(self, node): raise NotImplementedError + def visit_blob(self, node): + raise NotImplementedError + def visit_named_constant(self, node): raise NotImplementedError @@ -157,16 +178,14 @@ class PrettyPrinter: return if isinstance(node.value, basestring): - if len(node.value) >= 4096 or node.value.strip(string.printable): - self.formatter.address('blob(%u)' % len(node.value)) - #self.formatter.text('...') - return - self.formatter.literal('"' + node.value + '"') return self.formatter.literal(repr(node.value)) + def visit_blob(self, node): + self.formatter.address('blob()') + def visit_named_constant(self, node): self.formatter.literal(node.name) |