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__':
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
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: