From dacd8dd5910b1e32e4a8c378fe9ac01b2bce695b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Thu, 25 Nov 2010 17:50:26 +0000 Subject: [PATCH] Handle glXxxPointer --- glretrace.py | 33 +++++++++++++++++++++++++++------ retrace.py | 4 +++- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/glretrace.py b/glretrace.py index 0724cff..3e2e922 100644 --- a/glretrace.py +++ b/glretrace.py @@ -26,12 +26,33 @@ 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(&%s)) {' % rvalue + print ' %s = 0;' % (lvalue) + print ' } else {' + print ' %s = (%s)(uintptr_t)(%s);' % (lvalue, arg_type, rvalue) + print ' }' if __name__ == '__main__': diff --git a/retrace.py b/retrace.py index a2d30a4..7525185 100644 --- a/retrace.py +++ b/retrace.py @@ -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: -- 2.43.0