]> git.cworth.org Git - apitrace/blobdiff - wgltrace.py
Update to-do list.
[apitrace] / wgltrace.py
index f75ae80f972802ac27fd0d96572156665dfc949c..7dcb85055491c2d16d07f295490ffa86df809efd 100644 (file)
 ##########################################################################/
 
 
+"""WGL tracing code generator."""
+
+
 from wglapi import wglapi
 from trace import Tracer
+from codegen import *
 
 
 public_symbols = set([
@@ -410,18 +414,20 @@ class WglTracer(Tracer):
     def wrap_ret(self, function, instance):
         if function.name == "wglGetProcAddress":
             print '    if (%s) {' % instance
-            else_ = ''
-            for f in wglapi.functions:
+        
+            func_dict = dict([(f.name, f) for f in wglapi.functions])
+
+            def handle_case(function_name):
+                f = func_dict[function_name]
                 ptype = self.function_pointer_type(f)
                 pvalue = self.function_pointer_value(f)
-                print '        %sif (!strcmp("%s", lpszProc)) {' % (else_, f.name)
-                print '            %s = (%s)%s;' % (pvalue, ptype, instance)
-                print '            %s = (%s)&%s;' % (instance, function.type, f.name);
-                print '        }'
-                else_ = 'else '
-            print '        %s{' % (else_,)
-            print '            OS::DebugMessage("apitrace: unknown function \\"%s\\"\\n", lpszProc);'
-            print '        }'
+                print '    %s = (%s)%s;' % (pvalue, ptype, instance)
+                print '    %s = (%s)&%s;' % (instance, function.type, f.name);
+        
+            def handle_default():
+                print '    OS::DebugMessage("apitrace: unknown function \\"%s\\"\\n", lpszProc);'
+
+            string_switch('lpszProc', func_dict.keys(), handle_case, handle_default)
             print '    }'
 
 
@@ -435,27 +441,6 @@ if __name__ == '__main__':
     print '#include "os.hpp"'
     print '#include "glsize.hpp"'
     print
-    print '#ifndef PFD_SUPPORT_DIRECTDRAW'
-    print '#define PFD_SUPPORT_DIRECTDRAW 0x00002000'
-    print '#endif'
-    print '#ifndef PFD_SUPPORT_COMPOSITION'
-    print '#define PFD_SUPPORT_COMPOSITION 0x00008000'
-    print '#endif'
-
-    print '#define GLAPIENTRY __stdcall'
-    print
-    print '#ifdef __MINGW32__'
-    print ''
-    print 'typedef struct _WGLSWAP'
-    print '{'
-    print '    HDC hdc;'
-    print '    UINT uiFlags;'
-    print '} WGLSWAP, *PWGLSWAP, FAR *LPWGLSWAP;'
-    print ''
-    print '#define WGL_SWAPMULTIPLE_MAX 16'
-    print ''
-    print '#endif'
-    print
     print 'extern "C" {'
     print '''
 static HINSTANCE g_hDll = NULL;