From 90dd97e5eda2b8f74ac26c0cee9548b13bcf7a69 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Tue, 23 Nov 2010 21:35:55 +0000 Subject: [PATCH] More cleanups. --- CMakeLists.txt | 22 ++------------ d3d10_1.py | 6 ++-- d3d10misc.py | 6 ++-- d3d8.py | 2 +- d3d9.py | 18 +++++------ d3dcaps.py | 4 +-- ddraw.py | 14 ++++----- dl.py | 81 -------------------------------------------------- 8 files changed, 27 insertions(+), 126 deletions(-) delete mode 100644 dl.py diff --git a/CMakeLists.txt b/CMakeLists.txt index b7f98f5..a7ac9f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,26 +21,8 @@ find_path (GLEW_INCLUDE_DIR GL/glew.h ) if (WIN32) - # Nobody likes to include windows.h: - # - Microsoft's GL/gl.h header depends on windows.h but doesn't include it; - # - GLEW temporarily defines the necessary defines but undefines them later - # - certain GLUT distributions don't include it; - # - most of our programs are meant to be portable so don't include it. - # - # We could try to replicate the windows.h definitions required by - # GL/gl.h, but the build time savings don't compensate the constant - # headaches that brings, so instead we force windows.h to be included - # on every file. - if (MSVC) - add_definitions (-FIwindows.h) - else (MSVC) - add_definitions (--include windows.h) - endif (MSVC) - # MSVC & MinGW only define & use APIENTRY add_definitions (-DGLAPIENTRY=__stdcall) - - link_libraries (winmm) endif (WIN32) if (MSVC) @@ -155,7 +137,7 @@ else () add_custom_command ( OUTPUT glxtrace.cpp COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glxtrace.py > ${CMAKE_CURRENT_BINARY_DIR}/glxtrace.cpp - DEPENDS glxtrace.py trace.py glapi.py dl.py base.py + DEPENDS glxtrace.py trace.py glapi.py base.py ) add_library (glxtrace SHARED glxtrace.cpp log.cpp os_posix.cpp) @@ -170,7 +152,7 @@ if (GLEW_INCLUDE_DIR) add_custom_command ( OUTPUT glretrace.cpp COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glretrace.py > ${CMAKE_CURRENT_BINARY_DIR}/glretrace.cpp - DEPENDS glretrace.py glapi.py dl.py base.py + DEPENDS glretrace.py glapi.py base.py ) include_directories ( diff --git a/d3d10_1.py b/d3d10_1.py index 932e6cd..b9fa9f9 100644 --- a/d3d10_1.py +++ b/d3d10_1.py @@ -59,9 +59,9 @@ DXGI_SWAP_CHAIN_DESC = Alias("DXGI_SWAP_CHAIN_DESC", Void) d3d10_1 = Dll("d3d10") d3d10_1.functions += [ - DllFunction(HRESULT, "D3D10CreateDevice1", [(Pointer(IDXGIAdapter), "pAdapter"), (D3D10_DRIVER_TYPE, "DriverType"), (HMODULE, "Software"), (UINT, "Flags"), (D3D10_FEATURE_LEVEL1, "HardwareLevel"), (UINT, "SDKVersion"), (OutPointer(Pointer(ID3D10Device1)), "ppDevice")]), - DllFunction(HRESULT, "D3D10CreateDeviceAndSwapChain1", [(Pointer(IDXGIAdapter), "pAdapter"), (D3D10_DRIVER_TYPE, "DriverType"), (HMODULE, "Software"), (UINT, "Flags"), (D3D10_FEATURE_LEVEL1, "HardwareLevel"), (UINT, "SDKVersion"), (Pointer(DXGI_SWAP_CHAIN_DESC), "pSwapChainDesc"), (OutPointer(Pointer(IDXGISwapChain)), "ppSwapChain"), (OutPointer(Pointer(ID3D10Device1)), "ppDevice")]), - DllFunction(HRESULT, "D3D10CreateBlob", [(SIZE_T, "NumBytes"), (OutPointer(LPD3D10BLOB), "ppBuffer")]), + StdFunction(HRESULT, "D3D10CreateDevice1", [(Pointer(IDXGIAdapter), "pAdapter"), (D3D10_DRIVER_TYPE, "DriverType"), (HMODULE, "Software"), (UINT, "Flags"), (D3D10_FEATURE_LEVEL1, "HardwareLevel"), (UINT, "SDKVersion"), (OutPointer(Pointer(ID3D10Device1)), "ppDevice")]), + StdFunction(HRESULT, "D3D10CreateDeviceAndSwapChain1", [(Pointer(IDXGIAdapter), "pAdapter"), (D3D10_DRIVER_TYPE, "DriverType"), (HMODULE, "Software"), (UINT, "Flags"), (D3D10_FEATURE_LEVEL1, "HardwareLevel"), (UINT, "SDKVersion"), (Pointer(DXGI_SWAP_CHAIN_DESC), "pSwapChainDesc"), (OutPointer(Pointer(IDXGISwapChain)), "ppSwapChain"), (OutPointer(Pointer(ID3D10Device1)), "ppDevice")]), + StdFunction(HRESULT, "D3D10CreateBlob", [(SIZE_T, "NumBytes"), (OutPointer(LPD3D10BLOB), "ppBuffer")]), ] if __name__ == '__main__': diff --git a/d3d10misc.py b/d3d10misc.py index a75efb0..9e81b51 100644 --- a/d3d10misc.py +++ b/d3d10misc.py @@ -51,9 +51,9 @@ DXGI_SWAP_CHAIN_DESC = Alias("DXGI_SWAP_CHAIN_DESC", Void) d3d10 = Dll("d3d10") d3d10.functions += [ - DllFunction(HRESULT, "D3D10CreateDevice", [(Pointer(IDXGIAdapter), "pAdapter"), (D3D10_DRIVER_TYPE, "DriverType"), (HMODULE, "Software"), (UINT, "Flags"), (UINT, "SDKVersion"), Out(Pointer(Pointer(ID3D10Device)), "ppDevice")]), - DllFunction(HRESULT, "D3D10CreateDeviceAndSwapChain", [(Pointer(IDXGIAdapter), "pAdapter"), (D3D10_DRIVER_TYPE, "DriverType"), (HMODULE, "Software"), (UINT, "Flags"), (UINT, "SDKVersion"), (Pointer(DXGI_SWAP_CHAIN_DESC), "pSwapChainDesc"), Out(Pointer(Pointer(IDXGISwapChain)), "ppSwapChain"), Out(Pointer(Pointer(ID3D10Device)), "ppDevice")]), - DllFunction(HRESULT, "D3D10CreateBlob", [(SIZE_T, "NumBytes"), Out(Pointer(LPD3D10BLOB), "ppBuffer")]), + StdFunction(HRESULT, "D3D10CreateDevice", [(Pointer(IDXGIAdapter), "pAdapter"), (D3D10_DRIVER_TYPE, "DriverType"), (HMODULE, "Software"), (UINT, "Flags"), (UINT, "SDKVersion"), Out(Pointer(Pointer(ID3D10Device)), "ppDevice")]), + StdFunction(HRESULT, "D3D10CreateDeviceAndSwapChain", [(Pointer(IDXGIAdapter), "pAdapter"), (D3D10_DRIVER_TYPE, "DriverType"), (HMODULE, "Software"), (UINT, "Flags"), (UINT, "SDKVersion"), (Pointer(DXGI_SWAP_CHAIN_DESC), "pSwapChainDesc"), Out(Pointer(Pointer(IDXGISwapChain)), "ppSwapChain"), Out(Pointer(Pointer(ID3D10Device)), "ppDevice")]), + StdFunction(HRESULT, "D3D10CreateBlob", [(SIZE_T, "NumBytes"), Out(Pointer(LPD3D10BLOB), "ppBuffer")]), ] if __name__ == '__main__': diff --git a/d3d8.py b/d3d8.py index aaa0285..a4f1f34 100644 --- a/d3d8.py +++ b/d3d8.py @@ -275,7 +275,7 @@ IDirect3DVolume8.methods += [ d3d8 = Dll("d3d8") d3d8.functions += [ - DllFunction(PDIRECT3D8, "Direct3DCreate8", [(UINT, "SDKVersion")]), + StdFunction(PDIRECT3D8, "Direct3DCreate8", [(UINT, "SDKVersion")]), ] if __name__ == '__main__': diff --git a/d3d9.py b/d3d9.py index 7049d1d..55f3dcd 100644 --- a/d3d9.py +++ b/d3d9.py @@ -392,15 +392,15 @@ IDirect3DSwapChain9Ex.methods += [ d3d9 = Dll("d3d9") d3d9.functions += [ - DllFunction(PDIRECT3D9, "Direct3DCreate9", [(UINT, "SDKVersion")], fail='NULL'), - DllFunction(HRESULT, "Direct3DCreate9Ex", [(UINT, "SDKVersion"), Out(Pointer(PDIRECT3D9EX), "ppD3D")], fail='D3DERR_NOTAVAILABLE'), - DllFunction(Int, "D3DPERF_BeginEvent", [(D3DCOLOR, "col"), (LPCWSTR, "wszName")], fail='-1'), - DllFunction(Int, "D3DPERF_EndEvent", [], fail='-1'), - DllFunction(Void, "D3DPERF_SetMarker", [(D3DCOLOR, "col"), (LPCWSTR, "wszName")], fail=''), - DllFunction(Void, "D3DPERF_SetRegion", [(D3DCOLOR, "col"), (LPCWSTR, "wszName")], fail=''), - DllFunction(BOOL, "D3DPERF_QueryRepeatFrame", [], fail='FALSE'), - DllFunction(Void, "D3DPERF_SetOptions", [(DWORD, "dwOptions")], fail=''), - DllFunction(DWORD, "D3DPERF_GetStatus", [], fail='0'), + StdFunction(PDIRECT3D9, "Direct3DCreate9", [(UINT, "SDKVersion")], fail='NULL'), + StdFunction(HRESULT, "Direct3DCreate9Ex", [(UINT, "SDKVersion"), Out(Pointer(PDIRECT3D9EX), "ppD3D")], fail='D3DERR_NOTAVAILABLE'), + StdFunction(Int, "D3DPERF_BeginEvent", [(D3DCOLOR, "col"), (LPCWSTR, "wszName")], fail='-1'), + StdFunction(Int, "D3DPERF_EndEvent", [], fail='-1'), + StdFunction(Void, "D3DPERF_SetMarker", [(D3DCOLOR, "col"), (LPCWSTR, "wszName")], fail=''), + StdFunction(Void, "D3DPERF_SetRegion", [(D3DCOLOR, "col"), (LPCWSTR, "wszName")], fail=''), + StdFunction(BOOL, "D3DPERF_QueryRepeatFrame", [], fail='FALSE'), + StdFunction(Void, "D3DPERF_SetOptions", [(DWORD, "dwOptions")], fail=''), + StdFunction(DWORD, "D3DPERF_GetStatus", [], fail='0'), ] if __name__ == '__main__': diff --git a/d3dcaps.py b/d3dcaps.py index 515c3c4..50ca351 100644 --- a/d3dcaps.py +++ b/d3dcaps.py @@ -461,6 +461,6 @@ D3DFINDDEVICERESULT = Struct("D3DFINDDEVICERESULT", [ ]) LPD3DFINDDEVICERESULT = Pointer(D3DFINDDEVICERESULT) -LPD3DENUMDEVICESCALLBACK = DllFunction(HRESULT, "LPD3DENUMDEVICESCALLBACK", [(Pointer(GUID), "lpGuid"), (LPSTR, "lpDeviceDescription"), (LPSTR, "lpDeviceName"), LPD3DDEVICEDESC, LPD3DDEVICEDESC, LPVOID]) -LPD3DENUMDEVICESCALLBACK7 = DllFunction(HRESULT, "LPD3DENUMDEVICESCALLBACK7", [(LPSTR, "lpDeviceDescription"), (LPSTR, "lpDeviceName"), LPD3DDEVICEDESC7, LPVOID]) +LPD3DENUMDEVICESCALLBACK = StdFunction(HRESULT, "LPD3DENUMDEVICESCALLBACK", [(Pointer(GUID), "lpGuid"), (LPSTR, "lpDeviceDescription"), (LPSTR, "lpDeviceName"), LPD3DDEVICEDESC, LPD3DDEVICEDESC, LPVOID]) +LPD3DENUMDEVICESCALLBACK7 = StdFunction(HRESULT, "LPD3DENUMDEVICESCALLBACK7", [(LPSTR, "lpDeviceDescription"), (LPSTR, "lpDeviceName"), LPD3DDEVICEDESC7, LPVOID]) diff --git a/ddraw.py b/ddraw.py index 8f3f241..bc2065b 100644 --- a/ddraw.py +++ b/ddraw.py @@ -1605,13 +1605,13 @@ DDCREATE = Flags(DWORD, [ ddraw = Dll("ddraw") ddraw.functions += [ - DllFunction(HRESULT, "DirectDrawEnumerateW", [(LPDDENUMCALLBACKW, "lpCallback"), (LPVOID, "lpContext")]), - DllFunction(HRESULT, "DirectDrawEnumerateA", [(LPDDENUMCALLBACKA, "lpCallback"), (LPVOID, "lpContext")]), - DllFunction(HRESULT, "DirectDrawEnumerateExW", [(LPDDENUMCALLBACKEXW, "lpCallback"), (LPVOID, "lpContext"), (DDENUM, "dwFlags")]), - DllFunction(HRESULT, "DirectDrawEnumerateExA", [(LPDDENUMCALLBACKEXA, "lpCallback"), (LPVOID, "lpContext"), (DDENUM, "dwFlags")]), - DllFunction(HRESULT, "DirectDrawCreate", [(Pointer(GUID), "lpGUID"), Out(Pointer(LPDIRECTDRAW), "lplpDD"), (Pointer(IUnknown), "pUnkOuter")]), - DllFunction(HRESULT, "DirectDrawCreateEx", [(Pointer(GUID), "lpGuid"), Out(Pointer(LPVOID), "lplpDD"), (REFIID, "iid"), (Pointer(IUnknown), "pUnkOuter")]), - DllFunction(HRESULT, "DirectDrawCreateClipper", [(DWORD, "dwFlags"), Out(Pointer(LPDIRECTDRAWCLIPPER), "lplpDDClipper"), (Pointer(IUnknown), "pUnkOuter")]), + StdFunction(HRESULT, "DirectDrawEnumerateW", [(LPDDENUMCALLBACKW, "lpCallback"), (LPVOID, "lpContext")]), + StdFunction(HRESULT, "DirectDrawEnumerateA", [(LPDDENUMCALLBACKA, "lpCallback"), (LPVOID, "lpContext")]), + StdFunction(HRESULT, "DirectDrawEnumerateExW", [(LPDDENUMCALLBACKEXW, "lpCallback"), (LPVOID, "lpContext"), (DDENUM, "dwFlags")]), + StdFunction(HRESULT, "DirectDrawEnumerateExA", [(LPDDENUMCALLBACKEXA, "lpCallback"), (LPVOID, "lpContext"), (DDENUM, "dwFlags")]), + StdFunction(HRESULT, "DirectDrawCreate", [(Pointer(GUID), "lpGUID"), Out(Pointer(LPDIRECTDRAW), "lplpDD"), (Pointer(IUnknown), "pUnkOuter")]), + StdFunction(HRESULT, "DirectDrawCreateEx", [(Pointer(GUID), "lpGuid"), Out(Pointer(LPVOID), "lplpDD"), (REFIID, "iid"), (Pointer(IUnknown), "pUnkOuter")]), + StdFunction(HRESULT, "DirectDrawCreateClipper", [(DWORD, "dwFlags"), Out(Pointer(LPDIRECTDRAWCLIPPER), "lplpDDClipper"), (Pointer(IUnknown), "pUnkOuter")]), ] if __name__ == '__main__': diff --git a/dl.py b/dl.py deleted file mode 100644 index 1edcec7..0000000 --- a/dl.py +++ /dev/null @@ -1,81 +0,0 @@ -########################################################################## -# -# Copyright 2008-2010 VMware, Inc. -# All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# -##########################################################################/ - -"""dl""" - - -from base import * - - -class DllFunction(Function): - - def __init__(self, type, name, args, call = '', **kwargs): - Function.__init__(self, type, name, args, call=call, **kwargs) - - def get_true_pointer(self): - ptype = self.pointer_type() - pvalue = self.pointer_value() - print ' if(!%s) {' % (pvalue,) - print ' %s = (%s)dlsym(RTLD_NEXT, "%s");' % (pvalue, ptype, self.name) - print ' if(!%s)' % (pvalue,) - self.fail_impl() - print ' }' - - -class Dll: - - def __init__(self, name): - self.name = name - self.functions = [] - if self not in towrap: - towrap.append(self) - - def wrap_name(self): - return "Wrap" + self.name - - def wrap_pre_decl(self): - pass - - def wrap_decl(self): - for function in self.functions: - function.wrap_decl() - print - - def wrap_impl(self): - for function in self.functions: - function.wrap_impl() - print - print ''' -static void _init(void) __attribute__((constructor)); -static void _init(void) {''' - print r' Log::Open("%s");' % self.name - print '''} - -static void _uninit(void) __attribute__((destructor)); -static void _uninit(void) { - Log::Close(); -} -''' - -- 2.45.2