]> git.cworth.org Git - apitrace/commitdiff
Handle glXxxPointer
authorJosé Fonseca <jfonseca@vmware.com>
Thu, 25 Nov 2010 17:50:26 +0000 (17:50 +0000)
committerJosé Fonseca <jfonseca@vmware.com>
Thu, 25 Nov 2010 17:50:26 +0000 (17:50 +0000)
glretrace.py
retrace.py

index 0724cff5aeb9078c543921228e0a9a29bd0b0c6d..3e2e9220780a44ad7434f4ac71987bc3c6bcb3d9 100644 (file)
 
 import stdapi
 import glapi
-import retrace
-
-
-class GlRetracer(retrace.Retracer):
-
-    pass
+from retrace import Retracer
+
+
+class GlRetracer(Retracer):
+
+    def extract_arg(self, function, arg, arg_type, lvalue, rvalue):
+        if function.name in [
+            "glColorPointer"
+            "glEdgeFlagPointer"
+            "glIndexPointer",
+            "glNormalPointer",
+            "glTexCoordPointer",
+            "glVertexPointer",
+            "glFogCoordPointer",
+            "glSecondaryColorPointer",
+            "glVertexAttribPointer",
+        ] and arg.name == 'pointer':
+            self.extract_pointer(function, arg, arg_type, lvalue, rvalue)
+        else:
+            Retracer.extract_arg(self, function, arg, arg_type, lvalue, rvalue)
+
+    def extract_pointer(self, function, arg, arg_type, lvalue, rvalue):
+        print '    if (dynamic_cast<Trace::Null *>(&%s)) {' % rvalue
+        print '        %s = 0;' % (lvalue)
+        print '    } else {'
+        print '        %s = (%s)(uintptr_t)(%s);' % (lvalue, arg_type, rvalue)
+        print '    }'
 
 
 if __name__ == '__main__':
index a2d30a4065283c7ebc7fb23a33d9080dd4f6823c..7525185d911c609d2782afbb55a52953ca71e8b1 100644 (file)
@@ -168,7 +168,7 @@ class Retracer:
             rvalue = 'call.arg(%u)' % (arg.index,)
             lvalue = arg.name
             try:
-                ValueExtractor().visit(arg_type, lvalue, rvalue)
+                self.extract_arg(function, arg, arg_type, lvalue, rvalue)
             except NotImplementedError:
                 success = False
                 print '    %s = 0; // FIXME' % arg.name
@@ -200,6 +200,8 @@ class Retracer:
         print '}'
         print
 
+    def extract_arg(self, function, arg, arg_type, lvalue, rvalue):
+        ValueExtractor().visit(arg_type, lvalue, rvalue)
 
     def retrace_functions(self, functions):
         for function in functions: