]> git.cworth.org Git - apitrace/commitdiff
specs: Allow an API to spread across multiple modules.
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Sun, 11 Nov 2012 00:10:20 +0000 (00:10 +0000)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Sun, 11 Nov 2012 00:10:20 +0000 (00:10 +0000)
41 files changed:
dispatch/dispatch.py
dispatch/glproc.py
retrace/d3d10_1retrace.py
retrace/d3d10retrace.py
retrace/d3d11retrace.py
retrace/d3d9retrace.py
retrace/d3dcommonretrace.py
retrace/dllretrace.py
retrace/glretrace.py
retrace/retrace.py
specs/cglapi.py
specs/d2d1.py
specs/d3d10.py
specs/d3d10_1.py
specs/d3d11.py
specs/d3d8.py
specs/d3d9.py
specs/ddraw.py
specs/dwrite.py
specs/dxgi.py
specs/eglapi.py
specs/glapi.py
specs/glesapi.py
specs/glxapi.py
specs/stdapi.py
specs/wglapi.py
wrappers/cgltrace.py
wrappers/d2d1trace.py
wrappers/d3d10_1trace.py
wrappers/d3d10trace.py
wrappers/d3d11trace.py
wrappers/d3d8trace.py
wrappers/d3d9trace.py
wrappers/ddrawtrace.py
wrappers/dlltrace.py
wrappers/dwritetrace.py
wrappers/egltrace.py
wrappers/gltrace.py
wrappers/glxtrace.py
wrappers/trace.py
wrappers/wgltrace.py

index 4580166b18a25cff806a2dbaea61bda02bfa283a..60f95073b76d829c773b3dc653e6fadde895cfb0 100644 (file)
@@ -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,)
index abf4f00e20063a824373083f9de4c363694694b7..488f91279da853bd3b4ce3ad45efbcf5733180bc 100644 (file)
@@ -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_ */'
index bb45b82c0bc99f9acd17d388150ce0512e2660cb..3599a9ea3aa7b1a6a5e7020644e641a5d4c3488c 100644 (file)
@@ -45,4 +45,4 @@ if __name__ == '__main__':
 '''
 
     retracer = D3DRetracer()
-    retracer.retraceApi(d3d10_1)
+    retracer.retraceModule(d3d10_1)
index 877b1e4ecfaa117fde5bac638f1300c38f2e1a48..ccfd87e2d1fbab198de1995ee2fbaa919e65bbc4 100644 (file)
@@ -45,4 +45,4 @@ if __name__ == '__main__':
 '''
 
     retracer = D3DRetracer()
-    retracer.retraceApi(d3d10)
+    retracer.retraceModule(d3d10)
index 8831024bc2679d0aeaca4a57653fef18a41f5c46..1f349a203653c6938d195a2282a0f1ca535a5918 100644 (file)
@@ -45,4 +45,4 @@ if __name__ == '__main__':
 '''
 
     retracer = D3DRetracer()
-    retracer.retraceApi(d3d11)
+    retracer.retraceModule(d3d11)
index 7030f868f17b3a98a27d0e3048f7077f412f640c..c175705e2dd036f21b4903cb672856dca29e5945 100644 (file)
@@ -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<void *, void *> _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)
index ea09eb01bab5e475411fde8b76757223d8246e5e..75262c2c62a1457db7dbb677d82a8cf7be640c6a 100644 (file)
@@ -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<void *, void *> _maps;'
         print
 
         self.table_name = 'd3dretrace::d3d_callbacks'
 
-        Retracer.retraceApi(self, api)
+        Retracer.retraceModule(self, api)
 
     def invokeFunction(self, function):
         # create windows as neccessary
index 4fd481ca967560d2226a4b15d5c2571e1cf749fb..926bacd250ec7017a97929aa86311e16a4a6d53a 100644 (file)
 
 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)
index e2ea3201bf183bd63597a964b11f95bcc101424f..6fdeffe49eaa8c14ed2cedcb820344679d271216 100644 (file)
@@ -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)
index 2dd8e2f12a2ae0d825c9c61f079946a91b1b4699..ecad9f45615497c6657e419f2ef2cd813ab79326 100644 (file)
@@ -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)
index fbae1b149eecd539d171845a9aac963f868940b6..6cea02887f3f3945bf9b99099a6a2a2b09d21d86 100644 (file)
@@ -180,7 +180,7 @@ CGLError = Enum("CGLError", [
 
 CGLContextObj = Opaque("CGLContextObj")
 
-cglapi = API("CGL")
+cglapi = Module("CGL")
 
 cglapi.addFunctions([
     # CGLCurrent.h, libGL.dylib
index 7fe9b65912fa3c571b4fc6862c184dea4a892868..20c657e51cf9bf1edf9d25445d0947bdd34c65f2 100644 (file)
@@ -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")]),
index 48dc2e1816632fddf2ff0bac7b8f4cb6a87a1402..0552575d64e67ac9c370f985936020bc191b3f3f 100644 (file)
@@ -898,7 +898,7 @@ ID3D10Multithread.methods += [
 ]
 
 
-d3d10 = API("d3d10")
+d3d10 = Module("d3d10")
 
 
 from d3d10sdklayers import *
index 60a7656c45c1071295ce4feb94de6c7934a866b1..73d798ec4405cb3e98288035bcbc6952eb2f5611 100644 (file)
@@ -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")]),
index 4566ea15218b539e10ff9e332a7b394a9b6a8cc8..578d2144f855057eccc58247e2aa0156ae7cb31f 100644 (file)
@@ -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")]),
index 9a11ec5244f668c2754af451f5a682bac29d31d0..c835fc5036ee8213b1e0179c17164ef260750327 100644 (file)
@@ -289,7 +289,7 @@ IDirect3DVolume8.methods += [
     StdMethod(HRESULT, "UnlockBox", []),
 ]
 
-d3d8 = API("d3d8")
+d3d8 = Module("d3d8")
 d3d8.addFunctions([
     StdFunction(PDIRECT3D8, "Direct3DCreate8", [(UINT, "SDKVersion")]),
 ])
index 3443feeb971f354e0eb1b882c40e3ef99df54c56..c3f28008502a6e2ccaa0a5f3ee3fce9a01eea960 100644 (file)
@@ -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'),
index cccbbe57fd73540eee7dfa37291f911469546763..ca540f0202c0559e64630c49e9364a89111adfdc 100644 (file)
@@ -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")]),
index 001d041573e131e2d3e634325533d647c5e9933e..916cae3e068949ed3ed3a9ca0fbadcef84720c74 100644 (file)
@@ -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")]),
 ])
index 45af484d138637763ed89d967991666cad32adf3..97aa5dd46b59831e026dfa21a1baa3db7fc010c6 100644 (file)
@@ -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")]),
index 74584784fac766cd5c3770e1d3326d304564a63a..510e0fab4b2eabbe032ced568598628fd287899c 100644 (file)
@@ -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)")
 
index 3db0739dc3767b5608e350ac00007affcbea6dc9..9378721a0c6e0f89bdeb33ea8364cd035b2fb31c 100644 (file)
@@ -44,7 +44,7 @@ def GlFunction(*args, **kwargs):
     return Function(*args, **kwargs)
 
 
-glapi = API('GL')
+glapi = Module('GL')
 
 
 glapi.addFunctions([
index 46c6ef02888e363f5b93aa4633e26c9ed1be9cb8..6d51fe07e4ff8f2294943cdd52cc177ae27875a0 100644 (file)
@@ -40,7 +40,7 @@ def GlFunction(*args, **kwargs):
     return Function(*args, **kwargs)
 
 
-glesapi = API('GLES')
+glesapi = Module('GLES')
 
 
 # OpenGL ES specific functions
index 157752719c87c5692e2f98c5dcd44e268dd67278..f4e544c060cf7f7f9f2f68fd10c810e8d7157462 100644 (file)
@@ -242,7 +242,7 @@ GLXbuffer = Flags(Int, [
     "GLX_PBUFFER_CLOBBER_MASK",
 ])
 
-glxapi = API("GLX")
+glxapi = Module("GLX")
 
 PROC = Opaque("__GLXextFuncPtr")
 
index 846227ef3468fd2f06956476dc29d10bfd27c2b2..1097347f38ce3a97a26b9312c7de183c469e8c0f 100644 (file)
@@ -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
 
 
index e3d8b2366f593fd53f4f72cd6902280af92489b7..f4b625ac60fae45a4b56b539a7912c2a83fe436c 100644 (file)
@@ -32,7 +32,7 @@ from winapi import *
 from wglenum import *
 
 
-wglapi = API("WGL")
+wglapi = Module("WGL")
 
 
 HGLRC = Alias("HGLRC", HANDLE)
index e7cbd7b123fa6c834e2180f04bcd769071ac2237..c56edf24443911611050747fa9cc0a7fbec2688b 100644 (file)
@@ -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)
 
index a6142852d094881a9a37ee51f3276a7fb3cdc599..d6d48646d6cdcbdd812247ecc598b639d63d7b1b 100644 (file)
@@ -52,4 +52,4 @@ if __name__ == '__main__':
     print
 
     tracer = D2D1Tracer('d2d1.dll')
-    tracer.traceApi(d2d1)
+    tracer.traceModule(d2d1)
index 6fa3efc27cf7199b4a99954cccca29e030d11b5d..3b744e426c4933c3aaf2937f964166bd6ff9ee26 100644 (file)
@@ -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)
index 42f6058a9b3a8e14c5ae67ecb4d19a056aa2e469..9bbaa9434af5785e46d36dbe117865a857f99d40 100644 (file)
@@ -39,4 +39,4 @@ if __name__ == '__main__':
     print '#include "d3d10size.hpp"'
     print
     tracer = D3DCommonTracer('d3d10.dll')
-    tracer.traceApi(d3d10)
+    tracer.traceModule(d3d10)
index c504f5e35326fab498f8ed0c86c7a1e14305af7d..aa076a07ca095d5e4fcc78d1e969cf597f58ecd4 100644 (file)
@@ -48,4 +48,4 @@ if __name__ == '__main__':
     print '#include "d3d11size.hpp"'
     print
     tracer = D3DCommonTracer('d3d11.dll')
-    tracer.traceApi(d3d11)
+    tracer.traceModule(d3d11)
index 0bf4bb80fdd81c70a91d34eb878bc92a7fe02e23..cba3ace27e1dbbde67a037caab2107f39e6c20c6 100644 (file)
@@ -50,5 +50,5 @@ if __name__ == '__main__':
     print '#include "os.hpp"'
     print
     tracer = D3D8Tracer('d3d8.dll')
-    tracer.traceApi(d3d8)
+    tracer.traceModule(d3d8)
 
index fc6e65ef2ae86982df2f74f340aea5dfda51e799..cec045e4c5d6876fcc378e84f7950bb92dbaffcc 100644 (file)
@@ -95,5 +95,5 @@ _declCount(const D3DVERTEXELEMENT9 *pVertexElements) {
 }
 '''
     tracer = D3D9Tracer('d3d9.dll')
-    tracer.traceApi(d3d9)
+    tracer.traceModule(d3d9)
 
index b575c77092eda1c2af80ad9ede0b18da56fdfd4a..ca33a3e899b44216ec3f85886d7c5ddcedf02ffb 100644 (file)
@@ -67,4 +67,4 @@ if __name__ == '__main__':
     print '#include "os.hpp"'
     print
     tracer = DDrawTracer('ddraw.dll')
-    tracer.traceApi(ddraw)
+    tracer.traceModule(ddraw)
index 8456d5f7a63a4052129e69aef305582ceeb240ad..cea7dc7464c4717efe44828a917f65a6a4c2d3d9 100644 (file)
@@ -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)
index 7fb77e22f51662f8b36b7f2d975324f6b1473a5e..cbb214822b2a6af9c4415c7eb23b807cae297abf 100644 (file)
@@ -55,4 +55,4 @@ if __name__ == '__main__':
     print
 
     tracer = DWriteTracer('dwrite.dll')
-    tracer.traceApi(dwrite)
+    tracer.traceModule(dwrite)
index a6ff17f8eaa1f37509b6ad094f07e8e2306f02d4..0c7ebb6b1937acedfd657d0bdabdc29e857b5947 100644 (file)
@@ -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)
 
index feb96e44276842d515efd79b254946708ad74c6f..3e01e40eb72010e9fae5887509514d3762e0a91e 100644 (file)
@@ -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
index 670f8f39a1785254d3b9d8bc497777e22b846a38..9c0f87dbcb443fba7fd520317368877062550c33 100644 (file)
@@ -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)
 
index cbdc0c07122e2a9ee4390263f83746a68decb107..79156acafbd328086f6ea021c41bf5c64a8ce2d7 100644 (file)
@@ -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)
index 317c5422a7d5400e17c9d791c084c630b1ee9d7f..c001cb1a988ffcd54f0b1ad8e8bd2242480d87f1 100644 (file)
@@ -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)