])
DXGI_OUTPUT_DESC = Struct("DXGI_OUTPUT_DESC", [
- (Array(WCHAR, 32), "DeviceName"),
+ (WString, "DeviceName"),
(RECT, "DesktopCoordinates"),
(BOOL, "AttachedToDesktop"),
(DXGI_MODE_ROTATION, "Rotation"),
])
DXGI_ADAPTER_DESC = Struct("DXGI_ADAPTER_DESC", [
- (Array(WCHAR, 128), "Description"),
+ (WString, "Description"),
(UINT, "VendorId"),
(UINT, "DeviceId"),
(UINT, "SubSysId"),
class String(Type):
- def __init__(self, expr = "char *", length = None):
+ def __init__(self, expr = "char *", length = None, kind = 'String'):
Type.__init__(self, expr)
self.length = length
+ self.kind = kind
def visit(self, visitor, *args, **kwargs):
return visitor.visitString(self, *args, **kwargs)
-# C string (i.e., zero terminated)
-CString = String()
-
class Opaque(Type):
'''Opaque pointer.'''
Float = Literal("float", "Float")
Double = Literal("double", "Double")
SizeT = Literal("size_t", "UInt")
-WString = Literal("wchar_t *", "WString")
+
+# C string (i.e., zero terminated)
+CString = String()
+WString = String("wchar_t *", kind="WString")
Int8 = Literal("int8_t", "SInt")
UInt8 = Literal("uint8_t", "UInt")
print ' trace::localWriter.write%s(%s);' % (literal.kind, instance)
def visitString(self, string, instance):
+ if string.kind == 'String':
+ cast = 'const char *'
+ elif string.kind == 'WString':
+ cast = 'const wchar_t *'
+ else:
+ assert False
+ if cast != string.expr:
+ # reinterpret_cast is necessary for GLubyte * <=> char *
+ instance = 'reinterpret_cast<%s>(%s)' % (cast, instance)
if string.length is not None:
- print ' trace::localWriter.writeString((const char *)%s, %s);' % (instance, string.length)
+ length = ', %s' % string.length
else:
- print ' trace::localWriter.writeString((const char *)%s);' % instance
+ length = ''
+ print ' trace::localWriter.write%s(%s%s);' % (string.kind, instance, length)
def visitConst(self, const, instance):
self.visit(const.type, instance)