def visit_array(self, type, *args, **kwargs):
raise NotImplementedError
+ def visit_blob(self, type, *args, **kwargs):
+ raise NotImplementedError
+
def visit_enum(self, type, *args, **kwargs):
raise NotImplementedError
type = self.visit(array.type)
return Array(type, array.length)
+ def visit_blob(self, blob):
+ type = self.visit(blob.type)
+ return Blob(type, blob.size)
+
def visit_enum(self, enum):
return enum
def visit(self, visitor, *args, **kwargs):
raise NotImplementedError
- def isoutput(self):
- return False
+ isoutput = False
def decl(self):
pass
def __init__(self, type):
- if isinstance(type, Pointer):
+ if type.expr.startswith("const "):
expr = type.expr + " const"
else:
expr = "const " + type.expr
return Pointer(Const(type))
-class OutPointer(Pointer):
-
- def isoutput(self):
- return True
+def OutPointer(type):
+ return Out(Pointer(type))
class Enum(Concrete):
class Array(Type):
def __init__(self, type, length):
- Type.__init__(self, type.expr + " *", 'P' + type.id)
+ Type.__init__(self, type.expr + " *")
self.type = type
self.length = length
self.type.wrap_instance("*" + instance)
-class OutArray(Array):
+def OutArray(type, length):
+ return Out(Array(type, length))
+
+
+class Blob(Type):
+
+ def __init__(self, type, size):
+ Type.__init__(self, type.expr + ' *')
+ self.type = type
+ self.size = size
+
+ def visit(self, visitor, *args, **kwargs):
+ return visitor.visit_blob(self, *args, **kwargs)
- def isoutput(self):
- return True
+ def dump(self, instance):
+ print ' Log::LiteralBlob(%s, %s);' % (instance, self.size)
class Struct(Concrete):
self.type.dump(instance)
-class Out(Type):
-
- def __init__(self, type):
- Type.__init__(self, type.expr)
- self.type = type
-
- def isoutput(self):
- return True
-
- def decl(self):
- self.type.decl()
-
- def impl(self):
- self.type.impl()
-
- def dump(self, instance):
- self.type.dump(instance)
-
- def wrap_instance(self, instance):
- self.type.wrap_instance(instance)
-
- def unwrap_instance(self, instance):
- self.type.unwrap_instance(instance)
+def Out(type):
+ type.isoutput = True
+ return type
class Function:
self.get_true_pointer()
print ' Log::BeginCall("%s");' % (self.name)
for type, name in self.args:
- if not type.isoutput():
+ if not type.isoutput:
type.unwrap_instance(name)
print ' Log::BeginArg("%s", "%s");' % (type, name)
type.dump(name)
print ' Log::EndArg();'
print ' %s%s(%s);' % (result, pvalue, ', '.join([str(name) for type, name in self.args]))
for type, name in self.args:
- if type.isoutput():
+ if type.isoutput:
print ' Log::BeginArg("%s", "%s");' % (type, name)
type.dump(name)
print ' Log::EndArg();'
print ' Log::EndPointer();'
print ' Log::EndArg();'
for type, name in method.args:
- if not type.isoutput():
+ if not type.isoutput:
type.unwrap_instance(name)
print ' Log::BeginArg("%s", "%s");' % (type, name)
type.dump(name)
print ' Log::EndArg();'
print ' %sm_pInstance->%s(%s);' % (result, method.name, ', '.join([str(name) for type, name in method.args]))
for type, name in method.args:
- if type.isoutput():
+ if type.isoutput:
print ' Log::BeginArg("%s", "%s");' % (type, name)
type.dump(name)
print ' Log::EndArg();'
String = _String()
-class _Opaque(Type):
+class Opaque(Type):
+ '''Opaque pointer.'''
- def __init__(self):
- Type.__init__(self, "void")
+ def __init__(self, expr):
+ Type.__init__(self, expr)
def visit(self, visitor, *args, **kwargs):
return visitor.visit_opaque(self, *args, **kwargs)
def dump(self, instance):
- print ' Log::LiteralOpaque();'
+ print ' Log::LiteralOpaque((const void *)%s);' % instance
+
-Opaque = Pointer(_Opaque())
+def OpaquePointer(type):
+ return Opaque(type.expr + ' *')
Bool = Literal("bool", "Bool")