From: José Fonseca Date: Sun, 11 Nov 2012 00:10:20 +0000 (+0000) Subject: specs: Allow an API to spread across multiple modules. X-Git-Url: https://git.cworth.org/git?p=apitrace;a=commitdiff_plain;h=81301939f025407ceb284a9dcd5d5a1f05d27b8f specs: Allow an API to spread across multiple modules. --- diff --git a/dispatch/dispatch.py b/dispatch/dispatch.py index 4580166..60f9507 100644 --- a/dispatch/dispatch.py +++ b/dispatch/dispatch.py @@ -58,20 +58,20 @@ class Dispatcher: # raise NotImplementedError - def dispatchApi(self, api): - for function in api.functions: - self.dispatchFunction(api, function) + def dispatchModule(self, module): + for function in module.functions: + self.dispatchFunction(module, function) # define standard name aliases for convenience, but only when not # tracing, as that would cause symbol clashing with the tracing # functions print '#ifdef RETRACE' - for function in api.functions: + for function in module.functions: print '#define %s _%s' % (function.name, function.name) print '#endif /* RETRACE */' print - def dispatchFunction(self, api, function): + def dispatchFunction(self, module, function): ptype = function_pointer_type(function) pvalue = function_pointer_value(function) print 'typedef ' + function.prototype('* %s' % ptype) + ';' @@ -83,24 +83,24 @@ class Dispatcher: ret = '' else: ret = 'return ' - self.invokeGetProcAddress(api, function) + self.invokeGetProcAddress(module, function) print ' %s%s(%s);' % (ret, pvalue, ', '.join([str(arg.name) for arg in function.args])) print '}' print - def isFunctionPublic(self, api, function): + def isFunctionPublic(self, module, function): return True - def getProcAddressName(self, api, function): - if self.isFunctionPublic(api, function): + def getProcAddressName(self, module, function): + if self.isFunctionPublic(module, function): return '_getPublicProcAddress' else: return '_getPrivateProcAddress' - def invokeGetProcAddress(self, api, function): + def invokeGetProcAddress(self, module, function): ptype = function_pointer_type(function) pvalue = function_pointer_value(function) - getProcAddressName = self.getProcAddressName(api, function) + getProcAddressName = self.getProcAddressName(module, function) print ' if (!%s) {' % (pvalue,) print ' %s = (%s)%s(_name);' % (pvalue, ptype, getProcAddressName) print ' if (!%s) {' % (pvalue,) diff --git a/dispatch/glproc.py b/dispatch/glproc.py index abf4f00..488f912 100644 --- a/dispatch/glproc.py +++ b/dispatch/glproc.py @@ -503,7 +503,7 @@ void * _getPublicProcAddress(const char *procName); void * _getPrivateProcAddress(const char *procName); ''' - def isFunctionPublic(self, api, function): + def isFunctionPublic(self, module, function): return function.name in public_symbols or function.name.startswith('CGL') @@ -519,25 +519,25 @@ if __name__ == '__main__': print dispatcher.header() print - dispatcher.dispatchApi(eglapi) + dispatcher.dispatchModule(eglapi) print print '#if defined(_WIN32)' print - dispatcher.dispatchApi(wglapi) + dispatcher.dispatchModule(wglapi) print print '#elif defined(__APPLE__)' print - dispatcher.dispatchApi(cglapi) + dispatcher.dispatchModule(cglapi) print print '#elif defined(HAVE_X11)' print - dispatcher.dispatchApi(glxapi) + dispatcher.dispatchModule(glxapi) print print '#endif' print - dispatcher.dispatchApi(glapi) + dispatcher.dispatchModule(glapi) print - dispatcher.dispatchApi(glesapi) + dispatcher.dispatchModule(glesapi) print print '#endif /* !_GLPROC_HPP_ */' diff --git a/retrace/d3d10_1retrace.py b/retrace/d3d10_1retrace.py index bb45b82..3599a9e 100644 --- a/retrace/d3d10_1retrace.py +++ b/retrace/d3d10_1retrace.py @@ -45,4 +45,4 @@ if __name__ == '__main__': ''' retracer = D3DRetracer() - retracer.retraceApi(d3d10_1) + retracer.retraceModule(d3d10_1) diff --git a/retrace/d3d10retrace.py b/retrace/d3d10retrace.py index 877b1e4..ccfd87e 100644 --- a/retrace/d3d10retrace.py +++ b/retrace/d3d10retrace.py @@ -45,4 +45,4 @@ if __name__ == '__main__': ''' retracer = D3DRetracer() - retracer.retraceApi(d3d10) + retracer.retraceModule(d3d10) diff --git a/retrace/d3d11retrace.py b/retrace/d3d11retrace.py index 8831024..1f349a2 100644 --- a/retrace/d3d11retrace.py +++ b/retrace/d3d11retrace.py @@ -45,4 +45,4 @@ if __name__ == '__main__': ''' retracer = D3DRetracer() - retracer.retraceApi(d3d11) + retracer.retraceModule(d3d11) diff --git a/retrace/d3d9retrace.py b/retrace/d3d9retrace.py index 7030f86..c175705 100644 --- a/retrace/d3d9retrace.py +++ b/retrace/d3d9retrace.py @@ -34,14 +34,14 @@ from specs.d3d9 import * class D3DRetracer(Retracer): - def retraceApi(self, api): + def retraceModule(self, api): print '// Swizzling mapping for lock addresses' print 'static std::map _locks;' print self.table_name = 'd3dretrace::d3d_callbacks' - Retracer.retraceApi(self, api) + Retracer.retraceModule(self, api) def invokeFunction(self, function): if function.name in ('Direct3DCreate9', 'Direct3DCreate9Ex'): @@ -124,4 +124,4 @@ if __name__ == '__main__': ''' retracer = D3DRetracer() - retracer.retraceApi(d3d9) + retracer.retraceModule(d3d9) diff --git a/retrace/d3dcommonretrace.py b/retrace/d3dcommonretrace.py index ea09eb0..75262c2 100644 --- a/retrace/d3dcommonretrace.py +++ b/retrace/d3dcommonretrace.py @@ -33,14 +33,14 @@ import specs.stdapi as stdapi class D3DRetracer(Retracer): - def retraceApi(self, api): + def retraceModule(self, api): print '// Swizzling mapping for lock addresses' print 'static std::map _maps;' print self.table_name = 'd3dretrace::d3d_callbacks' - Retracer.retraceApi(self, api) + Retracer.retraceModule(self, api) def invokeFunction(self, function): # create windows as neccessary diff --git a/retrace/dllretrace.py b/retrace/dllretrace.py index 4fd481c..926bacd 100644 --- a/retrace/dllretrace.py +++ b/retrace/dllretrace.py @@ -26,12 +26,13 @@ from retrace import Retracer from dispatch import Dispatcher +from specs.stdapi import API class DllDispatcher(Dispatcher): - def dispatchApi(self, api): - tag = api.name.upper() + def dispatchModule(self, module): + tag = module.name.upper() print r'const char *g_sz%sDllName = NULL;' % (tag,) print r'HMODULE g_h%sModule = NULL;' % (tag,) print r'' @@ -45,10 +46,10 @@ class DllDispatcher(Dispatcher): print r' }' print r' }' print r' if (!g_h%sModule) {' % tag - print r' g_h%sModule = LoadLibraryA("%s.dll");' % (tag, api.name) + print r' g_h%sModule = LoadLibraryA("%s.dll");' % (tag, module.name) print r' }' print r' if (!g_h%sModule) {' % tag - print r' os::log("error: failed to load %s.dll\n");' % api.name + print r' os::log("error: failed to load %s.dll\n");' % module.name print r' exit(1);' print r' }' print r' }' @@ -56,14 +57,19 @@ class DllDispatcher(Dispatcher): print r'}' print r'' - Dispatcher.dispatchApi(self, api) + Dispatcher.dispatchModule(self, module) class DllRetracer(Retracer): def retraceApi(self, api): - dispatcher = DllDispatcher() - dispatcher.dispatchApi(api) + for module in api.modules: + dispatcher = DllDispatcher() + dispatcher.dispatchModule(module) Retracer.retraceApi(self, api) + def retraceModule(self, module): + api = API() + api.addModule(module) + self.retraceApi(api) diff --git a/retrace/glretrace.py b/retrace/glretrace.py index e2ea320..6fdeffe 100644 --- a/retrace/glretrace.py +++ b/retrace/glretrace.py @@ -528,7 +528,8 @@ if __name__ == '__main__': static bool _pipelineHasBeenBound = false; ''' - api = glapi.glapi - api.addApi(glesapi.glesapi) + api = stdapi.API() + api.addModule(glapi.glapi) + api.addModule(glesapi.glesapi) retracer = GlRetracer() retracer.retraceApi(api) diff --git a/retrace/retrace.py b/retrace/retrace.py index 2dd8e2f..ecad9f4 100644 --- a/retrace/retrace.py +++ b/retrace/retrace.py @@ -479,7 +479,7 @@ class Retracer: handle_names.add(handle.name) print - functions = filter(self.filterFunction, api.functions) + functions = filter(self.filterFunction, api.getAllFunctions()) for function in functions: if function.sideeffects and not function.internal: self.retraceFunction(function) diff --git a/specs/cglapi.py b/specs/cglapi.py index fbae1b1..6cea028 100644 --- a/specs/cglapi.py +++ b/specs/cglapi.py @@ -180,7 +180,7 @@ CGLError = Enum("CGLError", [ CGLContextObj = Opaque("CGLContextObj") -cglapi = API("CGL") +cglapi = Module("CGL") cglapi.addFunctions([ # CGLCurrent.h, libGL.dylib diff --git a/specs/d2d1.py b/specs/d2d1.py index 7fe9b65..20c657e 100644 --- a/specs/d2d1.py +++ b/specs/d2d1.py @@ -622,8 +622,10 @@ ID2D1Factory.methods += [ StdMethod(HRESULT, "CreateDCRenderTarget", [(Pointer(Const(D2D1_RENDER_TARGET_PROPERTIES)), "renderTargetProperties"), Out(Pointer(ObjPointer(ID2D1DCRenderTarget)), "dcRenderTarget")]), ] -d2d1 = API("d2d1") -d2d1.addInterface(ID2D1Factory) +d2d1 = Module("d2d1") +d2d1.addInterfaces([ + ID2D1Factory +]) d2d1.addFunctions([ StdFunction(HRESULT, "D2D1CreateFactory", [(D2D1_FACTORY_TYPE, "factoryType"), (REFIID, "riid"), (Pointer(Const(D2D1_FACTORY_OPTIONS)), "pFactoryOptions"), Out(Pointer(OpaquePointer(Void)), "ppIFactory")]), StdFunction(Void, "D2D1MakeRotateMatrix", [(FLOAT, "angle"), (D2D1_POINT_2F, "center"), Out(Pointer(D2D1_MATRIX_3X2_F), "matrix")]), diff --git a/specs/d3d10.py b/specs/d3d10.py index 48dc2e1..0552575 100644 --- a/specs/d3d10.py +++ b/specs/d3d10.py @@ -898,7 +898,7 @@ ID3D10Multithread.methods += [ ] -d3d10 = API("d3d10") +d3d10 = Module("d3d10") from d3d10sdklayers import * diff --git a/specs/d3d10_1.py b/specs/d3d10_1.py index 60a7656..73d798e 100644 --- a/specs/d3d10_1.py +++ b/specs/d3d10_1.py @@ -100,7 +100,7 @@ ID3D10Device1.methods += [ StdMethod(D3D10_FEATURE_LEVEL1, "GetFeatureLevel", [], sideeffects=False), ] -d3d10_1 = API("d3d10_1") +d3d10_1 = Module("d3d10_1") d3d10_1.addFunctions([ StdFunction(HRESULT, "D3D10CreateDevice1", [(ObjPointer(IDXGIAdapter), "pAdapter"), (D3D10_DRIVER_TYPE, "DriverType"), (HMODULE, "Software"), (D3D10_CREATE_DEVICE_FLAG, "Flags"), (D3D10_FEATURE_LEVEL1, "HardwareLevel"), (UINT, "SDKVersion"), Out(Pointer(ObjPointer(ID3D10Device1)), "ppDevice")]), StdFunction(HRESULT, "D3D10CreateDeviceAndSwapChain1", [(ObjPointer(IDXGIAdapter), "pAdapter"), (D3D10_DRIVER_TYPE, "DriverType"), (HMODULE, "Software"), (D3D10_CREATE_DEVICE_FLAG, "Flags"), (D3D10_FEATURE_LEVEL1, "HardwareLevel"), (UINT, "SDKVersion"), (Pointer(DXGI_SWAP_CHAIN_DESC), "pSwapChainDesc"), Out(Pointer(ObjPointer(IDXGISwapChain)), "ppSwapChain"), Out(Pointer(ObjPointer(ID3D10Device1)), "ppDevice")]), diff --git a/specs/d3d11.py b/specs/d3d11.py index 4566ea1..578d214 100644 --- a/specs/d3d11.py +++ b/specs/d3d11.py @@ -1213,7 +1213,7 @@ ID3D11Device.methods += [ StdMethod(UINT, "GetExceptionMode", [], sideeffects=False), ] -d3d11 = API("d3d11") +d3d11 = Module("d3d11") d3d11.addFunctions([ StdFunction(HRESULT, "D3D11CreateDevice", [(ObjPointer(IDXGIAdapter), "pAdapter"), (D3D_DRIVER_TYPE, "DriverType"), (HMODULE, "Software"), (D3D11_CREATE_DEVICE_FLAG, "Flags"), (Array(Const(D3D_FEATURE_LEVEL), "FeatureLevels"), "pFeatureLevels"), (UINT, "FeatureLevels"), (UINT, "SDKVersion"), Out(Pointer(ObjPointer(ID3D11Device)), "ppDevice"), Out(Pointer(D3D_FEATURE_LEVEL), "pFeatureLevel"), Out(Pointer(ObjPointer(ID3D11DeviceContext)), "ppImmediateContext")]), diff --git a/specs/d3d8.py b/specs/d3d8.py index 9a11ec5..c835fc5 100644 --- a/specs/d3d8.py +++ b/specs/d3d8.py @@ -289,7 +289,7 @@ IDirect3DVolume8.methods += [ StdMethod(HRESULT, "UnlockBox", []), ] -d3d8 = API("d3d8") +d3d8 = Module("d3d8") d3d8.addFunctions([ StdFunction(PDIRECT3D8, "Direct3DCreate8", [(UINT, "SDKVersion")]), ]) diff --git a/specs/d3d9.py b/specs/d3d9.py index 3443fee..c3f2800 100644 --- a/specs/d3d9.py +++ b/specs/d3d9.py @@ -418,7 +418,7 @@ IDirect3DSwapChain9Ex.methods += [ StdMethod(HRESULT, "GetDisplayModeEx", [Out(Pointer(D3DDISPLAYMODEEX), "pMode"), Out(Pointer(D3DDISPLAYROTATION), "pRotation")], sideeffects=False), ] -d3d9 = API("d3d9") +d3d9 = Module("d3d9") d3d9.addFunctions([ StdFunction(PDIRECT3D9, "Direct3DCreate9", [(UINT, "SDKVersion")], fail='NULL'), StdFunction(HRESULT, "Direct3DCreate9Ex", [(UINT, "SDKVersion"), Out(Pointer(PDIRECT3D9EX), "ppD3D")], fail='D3DERR_NOTAVAILABLE'), diff --git a/specs/ddraw.py b/specs/ddraw.py index cccbbe5..ca540f0 100644 --- a/specs/ddraw.py +++ b/specs/ddraw.py @@ -1632,7 +1632,7 @@ DDCREATE = Flags(DWORD, [ "DDCREATE_EMULATIONONLY", ]) -ddraw = API("ddraw") +ddraw = Module("ddraw") ddraw.addFunctions([ StdFunction(HRESULT, "DirectDrawEnumerateW", [(LPDDENUMCALLBACKW, "lpCallback"), (LPVOID, "lpContext")]), StdFunction(HRESULT, "DirectDrawEnumerateA", [(LPDDENUMCALLBACKA, "lpCallback"), (LPVOID, "lpContext")]), diff --git a/specs/dwrite.py b/specs/dwrite.py index 001d041..916cae3 100644 --- a/specs/dwrite.py +++ b/specs/dwrite.py @@ -769,8 +769,10 @@ IDWriteFactory.methods += [ StdMethod(HRESULT, "CreateGlyphRunAnalysis", [(Pointer(Const(DWRITE_GLYPH_RUN)), "glyphRun"), (FLOAT, "pixelsPerDip"), (Pointer(Const(DWRITE_MATRIX)), "transform"), (DWRITE_RENDERING_MODE, "renderingMode"), (DWRITE_MEASURING_MODE, "measuringMode"), (FLOAT, "baselineOriginX"), (FLOAT, "baselineOriginY"), Out(Pointer(ObjPointer(IDWriteGlyphRunAnalysis)), "glyphRunAnalysis")]), ] -dwrite = API("dwrite") -dwrite.addInterface(IDWriteFactory) +dwrite = Module("dwrite") +dwrite.addInterfaces([ + IDWriteFactory +]) dwrite.addFunctions([ StdFunction(HRESULT, "DWriteCreateFactory", [(DWRITE_FACTORY_TYPE, "factoryType"), (REFIID, "iid"), Out(Pointer(ObjPointer(IUnknown)), "factory")]), ]) diff --git a/specs/dxgi.py b/specs/dxgi.py index 45af484..97aa5dd 100644 --- a/specs/dxgi.py +++ b/specs/dxgi.py @@ -282,7 +282,7 @@ IDXGIDevice1.methods += [ StdMethod(HRESULT, "GetMaximumFrameLatency", [Out(Pointer(UINT), "pMaxLatency")], sideeffects=False), ] -dxgi = API('dxgi') +dxgi = Module('dxgi') dxgi.addFunctions([ StdFunction(HRESULT, "CreateDXGIFactory", [(REFIID, "riid"), Out(Pointer(ObjPointer(Void)), "ppFactory")]), StdFunction(HRESULT, "CreateDXGIFactory1", [(REFIID, "riid"), Out(Pointer(ObjPointer(Void)), "ppFactory")]), diff --git a/specs/eglapi.py b/specs/eglapi.py index 7458478..510e0fa 100644 --- a/specs/eglapi.py +++ b/specs/eglapi.py @@ -289,7 +289,7 @@ EGLClientPixmapHI = Struct("struct EGLClientPixmapHI", [ # EGL_NV_system_time EGLuint64NV = Alias("EGLuint64NV", UInt64) -eglapi = API("EGL") +eglapi = Module("EGL") EGLAttribList = Array(Const(EGLattrib), "_AttribPairList_size(attrib_list, EGL_NONE)") diff --git a/specs/glapi.py b/specs/glapi.py index 3db0739..9378721 100644 --- a/specs/glapi.py +++ b/specs/glapi.py @@ -44,7 +44,7 @@ def GlFunction(*args, **kwargs): return Function(*args, **kwargs) -glapi = API('GL') +glapi = Module('GL') glapi.addFunctions([ diff --git a/specs/glesapi.py b/specs/glesapi.py index 46c6ef0..6d51fe0 100644 --- a/specs/glesapi.py +++ b/specs/glesapi.py @@ -40,7 +40,7 @@ def GlFunction(*args, **kwargs): return Function(*args, **kwargs) -glesapi = API('GLES') +glesapi = Module('GLES') # OpenGL ES specific functions diff --git a/specs/glxapi.py b/specs/glxapi.py index 1577527..f4e544c 100644 --- a/specs/glxapi.py +++ b/specs/glxapi.py @@ -242,7 +242,7 @@ GLXbuffer = Flags(Int, [ "GLX_PBUFFER_CLOBBER_MASK", ]) -glxapi = API("GLX") +glxapi = Module("GLX") PROC = Opaque("__GLXextFuncPtr") diff --git a/specs/stdapi.py b/specs/stdapi.py index 846227e..1097347 100644 --- a/specs/stdapi.py +++ b/specs/stdapi.py @@ -837,11 +837,8 @@ class Collector(Traverser): -class API: - '''API abstraction. - - Essentially, a collection of types, functions, and interfaces. - ''' +class Module: + '''A collection of functions.''' def __init__(self, name = None): self.name = name @@ -849,50 +846,73 @@ class API: self.functions = [] self.interfaces = [] + def addFunctions(self, functions): + self.functions.extend(functions) + + def addInterfaces(self, interfaces): + self.interfaces.extend(interfaces) + + def mergeModule(self, module): + self.headers.extend(module.headers) + self.functions.extend(module.functions) + self.interfaces.extend(module.interfaces) + + def getFunctionByName(self, name): + for function in self.functions: + if function.name == name: + return function + return None + + +class API: + '''API abstraction. + + Essentially, a collection of types, functions, and interfaces. + ''' + + def __init__(self, modules = None): + self.modules = [] + if modules is not None: + self.modules.extend(modules) + def getAllTypes(self): collector = Collector() - for function in self.functions: - for arg in function.args: - collector.visit(arg.type) - collector.visit(function.type) - for interface in self.interfaces: - collector.visit(interface) - for method in interface.iterMethods(): - for arg in method.args: + for module in self.modules: + for function in module.functions: + for arg in function.args: collector.visit(arg.type) - collector.visit(method.type) + collector.visit(function.type) + for interface in module.interfaces: + collector.visit(interface) + for method in interface.iterMethods(): + for arg in method.args: + collector.visit(arg.type) + collector.visit(method.type) return collector.types + def getAllFunctions(self): + functions = [] + for module in self.modules: + functions.extend(module.functions) + return functions + def getAllInterfaces(self): types = self.getAllTypes() interfaces = [type for type in types if isinstance(type, Interface)] - for interface in self.interfaces: - if interface not in interfaces: - interfaces.append(interface) + for module in self.modules: + for interface in module.interfaces: + if interface not in interfaces: + interfaces.append(interface) return interfaces - def addFunction(self, function): - self.functions.append(function) - - def addFunctions(self, functions): - for function in functions: - self.addFunction(function) - - def addInterface(self, interface): - self.interfaces.append(interface) - - def addInterfaces(self, interfaces): - self.interfaces.extend(interfaces) - - def addApi(self, api): - self.headers.extend(api.headers) - self.addFunctions(api.functions) - self.addInterfaces(api.interfaces) + def addModule(self, module): + self.modules.append(module) def getFunctionByName(self, name): - for function in self.functions: - if function.name == name: - return function + for module in self.modules: + for function in module.functions: + if function.name == name: + return function return None diff --git a/specs/wglapi.py b/specs/wglapi.py index e3d8b23..f4b625a 100644 --- a/specs/wglapi.py +++ b/specs/wglapi.py @@ -32,7 +32,7 @@ from winapi import * from wglenum import * -wglapi = API("WGL") +wglapi = Module("WGL") HGLRC = Alias("HGLRC", HANDLE) diff --git a/wrappers/cgltrace.py b/wrappers/cgltrace.py index e7cbd7b..c56edf2 100644 --- a/wrappers/cgltrace.py +++ b/wrappers/cgltrace.py @@ -28,7 +28,7 @@ from gltrace import GlTracer -from specs.stdapi import API +from specs.stdapi import Module, API from specs.glapi import glapi from specs.cglapi import cglapi @@ -93,9 +93,11 @@ if __name__ == '__main__': print '#include "glsize.hpp"' print + module = Module() + module.mergeModule(cglapi) + module.mergeModule(glapi) api = API() - api.addApi(cglapi) - api.addApi(glapi) + api.addModule(module) tracer = CglTracer() tracer.traceApi(api) diff --git a/wrappers/d2d1trace.py b/wrappers/d2d1trace.py index a614285..d6d4864 100644 --- a/wrappers/d2d1trace.py +++ b/wrappers/d2d1trace.py @@ -52,4 +52,4 @@ if __name__ == '__main__': print tracer = D2D1Tracer('d2d1.dll') - tracer.traceApi(d2d1) + tracer.traceModule(d2d1) diff --git a/wrappers/d3d10_1trace.py b/wrappers/d3d10_1trace.py index 6fa3efc..3b744e4 100644 --- a/wrappers/d3d10_1trace.py +++ b/wrappers/d3d10_1trace.py @@ -39,4 +39,4 @@ if __name__ == '__main__': print '#include "d3d10size.hpp"' print tracer = D3DCommonTracer('d3d10_1.dll') - tracer.traceApi(d3d10_1) + tracer.traceModule(d3d10_1) diff --git a/wrappers/d3d10trace.py b/wrappers/d3d10trace.py index 42f6058..9bbaa94 100644 --- a/wrappers/d3d10trace.py +++ b/wrappers/d3d10trace.py @@ -39,4 +39,4 @@ if __name__ == '__main__': print '#include "d3d10size.hpp"' print tracer = D3DCommonTracer('d3d10.dll') - tracer.traceApi(d3d10) + tracer.traceModule(d3d10) diff --git a/wrappers/d3d11trace.py b/wrappers/d3d11trace.py index c504f5e..aa076a0 100644 --- a/wrappers/d3d11trace.py +++ b/wrappers/d3d11trace.py @@ -48,4 +48,4 @@ if __name__ == '__main__': print '#include "d3d11size.hpp"' print tracer = D3DCommonTracer('d3d11.dll') - tracer.traceApi(d3d11) + tracer.traceModule(d3d11) diff --git a/wrappers/d3d8trace.py b/wrappers/d3d8trace.py index 0bf4bb8..cba3ace 100644 --- a/wrappers/d3d8trace.py +++ b/wrappers/d3d8trace.py @@ -50,5 +50,5 @@ if __name__ == '__main__': print '#include "os.hpp"' print tracer = D3D8Tracer('d3d8.dll') - tracer.traceApi(d3d8) + tracer.traceModule(d3d8) diff --git a/wrappers/d3d9trace.py b/wrappers/d3d9trace.py index fc6e65e..cec045e 100644 --- a/wrappers/d3d9trace.py +++ b/wrappers/d3d9trace.py @@ -95,5 +95,5 @@ _declCount(const D3DVERTEXELEMENT9 *pVertexElements) { } ''' tracer = D3D9Tracer('d3d9.dll') - tracer.traceApi(d3d9) + tracer.traceModule(d3d9) diff --git a/wrappers/ddrawtrace.py b/wrappers/ddrawtrace.py index b575c77..ca33a3e 100644 --- a/wrappers/ddrawtrace.py +++ b/wrappers/ddrawtrace.py @@ -67,4 +67,4 @@ if __name__ == '__main__': print '#include "os.hpp"' print tracer = DDrawTracer('ddraw.dll') - tracer.traceApi(ddraw) + tracer.traceModule(ddraw) diff --git a/wrappers/dlltrace.py b/wrappers/dlltrace.py index 8456d5f..cea7dc7 100644 --- a/wrappers/dlltrace.py +++ b/wrappers/dlltrace.py @@ -28,6 +28,7 @@ from trace import Tracer from dispatch import Dispatcher +from specs.stdapi import API class DllTracer(Tracer): @@ -62,8 +63,13 @@ _getPublicProcAddress(LPCSTR lpProcName) ''' % self.dllname - dispatcher = Dispatcher() - dispatcher.dispatchApi(api) + for module in api.modules: + dispatcher = Dispatcher() + dispatcher.dispatchModule(module) Tracer.header(self, api) + def traceModule(self, module): + api = API() + api.addModule(module) + self.traceApi(api) diff --git a/wrappers/dwritetrace.py b/wrappers/dwritetrace.py index 7fb77e2..cbb2148 100644 --- a/wrappers/dwritetrace.py +++ b/wrappers/dwritetrace.py @@ -55,4 +55,4 @@ if __name__ == '__main__': print tracer = DWriteTracer('dwrite.dll') - tracer.traceApi(dwrite) + tracer.traceModule(dwrite) diff --git a/wrappers/egltrace.py b/wrappers/egltrace.py index a6ff17f..0c7ebb6 100644 --- a/wrappers/egltrace.py +++ b/wrappers/egltrace.py @@ -33,7 +33,7 @@ from gltrace import GlTracer -from specs.stdapi import API +from specs.stdapi import Module, API from specs.glapi import glapi from specs.eglapi import eglapi from specs.glesapi import glesapi @@ -125,10 +125,12 @@ if __name__ == '__main__': print '#include "eglsize.hpp"' print + module = Module() + module.mergeModule(eglapi) + module.mergeModule(glapi) + module.mergeModule(glesapi) api = API() - api.addApi(eglapi) - api.addApi(glapi) - api.addApi(glesapi) + api.addModule(module) tracer = EglTracer() tracer.traceApi(api) diff --git a/wrappers/gltrace.py b/wrappers/gltrace.py index feb96e4..3e01e40 100644 --- a/wrappers/gltrace.py +++ b/wrappers/gltrace.py @@ -337,7 +337,7 @@ class GlTracer(Tracer): print ' if (!procPtr) {' print ' return procPtr;' print ' }' - for function in api.functions: + for function in api.getAllFunctions(): ptype = function_pointer_type(function) pvalue = function_pointer_value(function) print ' if (strcmp("%s", (const char *)procName) == 0) {' % function.name diff --git a/wrappers/glxtrace.py b/wrappers/glxtrace.py index 670f8f3..9c0f87d 100644 --- a/wrappers/glxtrace.py +++ b/wrappers/glxtrace.py @@ -29,7 +29,7 @@ from gltrace import GlTracer -from specs.stdapi import API +from specs.stdapi import Module, API from specs.glapi import glapi from specs.glxapi import glxapi @@ -101,9 +101,11 @@ if __name__ == '__main__': print '#include "glsize.hpp"' print + module = Module() + module.mergeModule(glxapi) + module.mergeModule(glapi) api = API() - api.addApi(glxapi) - api.addApi(glapi) + api.addModule(module) tracer = GlxTracer() tracer.traceApi(api) diff --git a/wrappers/trace.py b/wrappers/trace.py index cbdc0c0..79156ac 100644 --- a/wrappers/trace.py +++ b/wrappers/trace.py @@ -426,8 +426,9 @@ class Tracer: self.header(api) # Includes - for header in api.headers: - print header + for module in api.modules: + for header in module.headers: + print header print # Generate the serializer functions @@ -442,8 +443,10 @@ class Tracer: # Function wrappers self.interface = None self.base = None - map(self.traceFunctionDecl, api.functions) - map(self.traceFunctionImpl, api.functions) + for function in api.getAllFunctions(): + self.traceFunctionDecl(function) + for function in api.getAllFunctions(): + self.traceFunctionImpl(function) print self.footer(api) diff --git a/wrappers/wgltrace.py b/wrappers/wgltrace.py index 317c542..c001cb1 100644 --- a/wrappers/wgltrace.py +++ b/wrappers/wgltrace.py @@ -28,7 +28,7 @@ from gltrace import GlTracer -from specs.stdapi import API +from specs.stdapi import Module, API from specs.glapi import glapi from specs.wglapi import wglapi @@ -96,8 +96,10 @@ if __name__ == '__main__': print '#include "glproc.hpp"' print '#include "glsize.hpp"' print + module = Module() + module.mergeModule(glapi) + module.mergeModule(wglapi) api = API() - api.addApi(glapi) - api.addApi(wglapi) + api.addModule(module) tracer = WglTracer() tracer.traceApi(api)