def isoutput(self):
return False
+ def dump(self, instance):
+ raise NotImplementedError
+
def wrap_instance(self, instance):
pass
Type.__init__(self, name)
self.format = format
+ def dump(self, instance):
+ print ' g_pLog->TextF("%s", %s);' % (self.format, instance)
+
class Const(Type):
Type.__init__(self, 'C' + type.name)
self.type = type
+ def dump(self, instance):
+ self.type.dump(instance)
+
def __str__(self):
return "const " + str(self.type)
def __str__(self):
return str(self.type) + " *"
+
+ def dump(self, instance):
+ try:
+ print ' g_pLog->TextF("%%p", %s);' % instance
+ except NotImplementedError:
+ self.type.dump("*" + instance)
def wrap_instance(self, instance):
self.type.wrap_instance("*" + instance)
self.type.wrap_instance("*" + instance)
-class Output(Type):
-
- def __init__(self, type):
- Type.__init__(self, type.name)
- self.type = type
-
- def __str__(self):
- return str(self.type)
+class OutPointer(Pointer):
def isoutput(self):
return True
- def wrap_instance(self, instance):
- self.type.wrap_instance(instance)
-
- def unwrap_instance(self, instance):
- self.type.wrap_instance(instance)
-
-def OutPointer(type):
- return Output(Pointer(type))
-
class Enum(Type):
def __init__(self, name, values):
Type.__init__(self, name)
self.values = values
+
+ def dump(self, instance):
+ print ' switch(%s) {' % instance
+ for value in self.values:
+ print ' case %s:' % value
+ print ' g_pLog->Text("%s");' % value
+ print ' break;'
+ print ' default:'
+ print ' g_pLog->TextF("%%i", %s);' % instance
+ print ' break;'
+ print ' }'
class Flags(Type):
Type.__init__(self, name)
self.members = members
+ def dump(self, instance):
+ print ' g_pLog->Text("{");'
+ first = True
+ for type, name in self.members:
+ if first:
+ first = False
+ else:
+ print ' g_pLog->Text(", ");'
+ type.dump('(%s).%s' % (instance, name))
+ print ' g_pLog->Text("}");'
+
class Alias(Type):
Type.__init__(self, name)
self.type = type
+ def dump(self, instance):
+ self.type.dump(instance)
+
class Function:
for type, name in method.args:
if not type.isoutput():
type.unwrap_instance(name)
+ print ' g_pLog->BeginParam("%s", "%s");' % (name, type)
+ type.dump(name)
+ print ' g_pLog->EndParam();'
print ' %sm_pInstance->%s(%s);' % (result, method.name, ', '.join([str(name) for type, name in method.args]))
print ' g_pLog->EndCall();'
for type, name in method.args:
Method(HRESULT, "TestCooperativeLevel", []),
Method(UINT, "GetAvailableTextureMem", []),
Method(HRESULT, "ResourceManagerDiscardBytes", [(DWORD, "Bytes")]),
- Method(HRESULT, "GetDirect3D", [(Pointer(PDIRECT3D8), "ppD3D8")]),
+ Method(HRESULT, "GetDirect3D", [(OutPointer(PDIRECT3D8), "ppD3D8")]),
Method(HRESULT, "GetDeviceCaps", [(Pointer(D3DCAPS8), "pCaps")]),
Method(HRESULT, "GetDisplayMode", [(Pointer(D3DDISPLAYMODE), "pMode")]),
Method(HRESULT, "GetCreationParameters", [(Pointer(D3DDEVICE_CREATION_PARAMETERS), "pParameters")]),
def wrap_decl(self):
print 'static HINSTANCE g_hDll = NULL;'
- print 'static Log * g_pLog = NULL;'
+ print 'Log * g_pLog = NULL;'
print 'static TCHAR g_szDll[MAX_PATH] = {0};'
print
print 'BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);'
else:
print ' %s result;' % function.type
result = 'result = '
- print ' if(!g_hDll) {'
- print ' g_hDll = LoadLibrary(g_szDll);'
- print ' if(!g_hDll)'
- print ' ExitProcess(0);'
- print ' }'
+ print ' if(!g_hDll) {'
+ print ' g_hDll = LoadLibrary(g_szDll);'
+ print ' if(!g_hDll)'
+ print ' ExitProcess(0);'
+ print ' }'
print ' pFunction = (%s)GetProcAddress( g_hDll, "%s");' % (type, function.name)
print ' if(!pFunction)'
print ' ExitProcess(0);'