From 4a9c40c5965a1e40c036a0528bb8e389b47201fe Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Mon, 7 Jul 2008 18:04:53 +0900 Subject: [PATCH] Handle pointers correctly. --- base.py | 13 ++++++++++--- d3d8.py | 8 ++++---- d3d8types.py | 2 -- windows.py | 2 +- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/base.py b/base.py index abc0aaa..1da4bce 100644 --- a/base.py +++ b/base.py @@ -62,10 +62,14 @@ class Pointer(Type): return str(self.type) + " *" def dump(self, instance): + print ' if(%s) {' % instance try: - print ' g_pLog->TextF("%%p", %s);' % instance - except NotImplementedError: self.type.dump("*" + instance) + except NotImplementedError: + print ' g_pLog->TextF("%%p", %s);' % instance + print ' }' + print ' else' + print ' g_pLog->Text("NULL");' def wrap_instance(self, instance): self.type.wrap_instance("*" + instance) @@ -213,6 +217,9 @@ class Interface(Type): print ' %s result;' % method.type result = 'result = ' print ' g_pLog->BeginCall("%s");' % (self.name + '::' + method.name) + print ' g_pLog->BeginParam("this", "%s *");' % self.name + print ' g_pLog->TextF("%p", m_pInstance);' + print ' g_pLog->EndParam();' for type, name in method.args: if not type.isoutput(): type.unwrap_instance(name) @@ -228,7 +235,7 @@ class Interface(Type): type.wrap_instance(name) if method.type is not Void: print ' g_pLog->BeginReturn("%s");' % method.type - type.dump("result") + method.type.dump("result") print ' g_pLog->EndReturn();' method.type.wrap_instance('result') print ' g_pLog->EndCall();' diff --git a/d3d8.py b/d3d8.py index 42cd10b..4802149 100755 --- a/d3d8.py +++ b/d3d8.py @@ -190,13 +190,13 @@ IDirect3DCubeTexture8.methods += [ ] IDirect3DVertexBuffer8.methods += [ - Method(HRESULT, "Lock", [(UINT, "OffsetToLock"), (UINT, "SizeToLock"), (Pointer(Pointer(BYTE)), "ppbData"), (DWORD, "Flags")]), + Method(HRESULT, "Lock", [(UINT, "OffsetToLock"), (UINT, "SizeToLock"), (OutPointer(Pointer(BYTE)), "ppbData"), (DWORD, "Flags")]), Method(HRESULT, "Unlock", []), Method(HRESULT, "GetDesc", [(Pointer(D3DVERTEXBUFFER_DESC), "pDesc")]), ] IDirect3DIndexBuffer8.methods += [ - Method(HRESULT, "Lock", [(UINT, "OffsetToLock"), (UINT, "SizeToLock"), (Pointer(Pointer(BYTE)), "ppbData"), (DWORD, "Flags")]), + Method(HRESULT, "Lock", [(UINT, "OffsetToLock"), (UINT, "SizeToLock"), (OutPointer(Pointer(BYTE)), "ppbData"), (DWORD, "Flags")]), Method(HRESULT, "Unlock", []), Method(HRESULT, "GetDesc", [(Pointer(D3DINDEXBUFFER_DESC), "pDesc")]), ] @@ -206,7 +206,7 @@ IDirect3DSurface8.methods += [ Method(HRESULT, "SetPrivateData", [(REFGUID, "refguid"), (Const(Pointer(Void)), "pData"), (DWORD, "SizeOfData"), (DWORD, "Flags")]), Method(HRESULT, "GetPrivateData", [(REFGUID, "refguid"), (Pointer(Void), "pData"), (Pointer(DWORD), "pSizeOfData")]), Method(HRESULT, "FreePrivateData", [(REFGUID, "refguid")]), - Method(HRESULT, "GetContainer", [(REFIID, "riid"), (Pointer(Pointer(Void)), "ppContainer")]), + Method(HRESULT, "GetContainer", [(REFIID, "riid"), (OutPointer(Pointer(Void)), "ppContainer")]), Method(HRESULT, "GetDesc", [(Pointer(D3DSURFACE_DESC), "pDesc")]), Method(HRESULT, "LockRect", [(Pointer(D3DLOCKED_RECT), "pLockedRect"), (Pointer(Const(RECT)), "pRect"), (DWORD, "Flags")]), Method(HRESULT, "UnlockRect", []), @@ -217,7 +217,7 @@ IDirect3DVolume8.methods += [ Method(HRESULT, "SetPrivateData", [(REFGUID, "refguid"), (Const(Pointer(Void)), "pData"), (DWORD, "SizeOfData"), (DWORD, "Flags")]), Method(HRESULT, "GetPrivateData", [(REFGUID, "refguid"), (Pointer(Void), "pData"), (Pointer(DWORD), "pSizeOfData")]), Method(HRESULT, "FreePrivateData", [(REFGUID, "refguid")]), - Method(HRESULT, "GetContainer", [(REFIID, "riid"), (Pointer(Pointer(Void)), "ppContainer")]), + Method(HRESULT, "GetContainer", [(REFIID, "riid"), (OutPointer(Pointer(Void)), "ppContainer")]), Method(HRESULT, "GetDesc", [(Pointer(D3DVOLUME_DESC), "pDesc")]), Method(HRESULT, "LockBox", [(Pointer(D3DLOCKED_BOX), "pLockedVolume"), (Pointer(Const(D3DBOX)), "pBox"), (DWORD, "Flags")]), Method(HRESULT, "UnlockBox", []), diff --git a/d3d8types.py b/d3d8types.py index 8e6d1fa..b49307f 100644 --- a/d3d8types.py +++ b/d3d8types.py @@ -983,8 +983,6 @@ D3DADAPTER_IDENTIFIER8 = Struct("D3DADAPTER_IDENTIFIER8", ( (String, "Driver"), (String, "Description"), (LARGE_INTEGER, "DriverVersion"), - (DWORD, "DriverVersionLowPart"), - (DWORD, "DriverVersionHighPart"), (DWORD, "VendorId"), (DWORD, "DeviceId"), (DWORD, "SubSysId"), diff --git a/windows.py b/windows.py index f0bb792..3b20de8 100644 --- a/windows.py +++ b/windows.py @@ -13,7 +13,7 @@ DWORD = Intrinsic("DWORD", "0x%08lu") BOOL = Intrinsic("BOOL", "%i") -LARGE_INTEGER = Intrinsic("LARGE_INTEGER", "0x%x") +LARGE_INTEGER = Intrinsic("LARGE_INTEGER", "0x%llx") HRESULT = Alias("HRESULT", Int) -- 2.45.2