]> git.cworth.org Git - apitrace/commitdiff
Portability fixes.
authorJosé Fonseca <jfonseca@vmware.com>
Mon, 29 Nov 2010 14:43:06 +0000 (14:43 +0000)
committerJosé Fonseca <jfonseca@vmware.com>
Mon, 29 Nov 2010 14:43:06 +0000 (14:43 +0000)
CMakeLists.txt
trace.py
wgltrace.py

index 914c12a7caa9cf0d9b77f00d3539cfe53af48b42..78a6f2d6b34650b9bf436ce5a216e9e02eb5d294 100644 (file)
@@ -49,6 +49,9 @@ if (MSVC)
                        string (REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
                endif (${flag_var} MATCHES "/MD")
        endforeach (flag_var)
+    
+    # C99 headers
+    include_directories (c99)
 else ()
        # Adjust warnings
        add_definitions (-Wall)
index 8c4eb75b10c00efc0652a341d118bb07d3dda5ff..65b03b683603aba3d81b8d4de1d628ee870f8890 100644 (file)
--- a/trace.py
+++ b/trace.py
@@ -322,7 +322,10 @@ class Tracer:
     def trace_function_impl(self, function):
         pvalue = self.function_pointer_value(function)
         print function.prototype() + ' {'
-        print '    static const char * __args[%u] = {%s};' % (len(function.args), ', '.join(['"%s"' % arg.name for arg in function.args]))
+        if function.args:
+            print '    static const char * __args[%u] = {%s};' % (len(function.args), ', '.join(['"%s"' % arg.name for arg in function.args]))
+        else:
+            print '    static const char ** __args = NULL;'
         print '    static const Trace::FunctionSig __sig = {%u, "%s", %u, __args};' % (int(function.id), function.name, len(function.args))
         if function.type is stdapi.Void:
             result = ''
index 11da692dda9c3a9f6e11e1e678f4c47a0e55b4e0..6474755ea1898cc1a7a52402b5dffb59079e81e2 100644 (file)
@@ -26,6 +26,7 @@
 
 from wglapi import wglapi
 from trace import Tracer
+from codegen import *
 
 
 public_symbols = set([
@@ -410,18 +411,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 '    }'