X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=retrace.py;fp=retrace.py;h=d6e838755c39a02cd6f517af2866f9d0736c6074;hb=12a22803faa06a0db229b6dfb6130a0e8156ba31;hp=1203a0992e4cebde23706c2fc5a90190d420986d;hpb=5409d1ebd76a55030be01c753722bdf9cb303995;p=apitrace diff --git a/retrace.py b/retrace.py index 1203a09..d6e8387 100644 --- a/retrace.py +++ b/retrace.py @@ -207,11 +207,41 @@ class Retracer: print '}' print + def retraceInterfaceMethod(self, interface, method): + print 'static void retrace_%s__%s(trace::Call &call) {' % (interface.name, method.name) + self.retraceInterfaceMethodBody(interface, method) + print '}' + print + def retraceFunctionBody(self, function): if not function.sideeffects: print ' (void)call;' return + self.deserializeArgs(function) + + self.invokeFunction(function) + + self.swizzleValues(function) + + def retraceInterfaceMethodBody(self, interface, method): + if not method.sideeffects: + print ' (void)call;' + return + + self.deserializeThisPointer(interface) + + self.deserializeArgs(method) + + self.invokeInterfaceMethod(interface, method) + + self.swizzleValues(method) + + def deserializeThisPointer(self, interface): + print ' %s *_this;' % (interface.name,) + # FIXME + + def deserializeArgs(self, function): print ' retrace::ScopedAllocator _allocator;' print ' (void)_allocator;' success = True @@ -224,13 +254,17 @@ class Retracer: try: self.extractArg(function, arg, arg_type, lvalue, rvalue) except NotImplementedError: - success = False + success = False print ' %s = 0; // FIXME' % arg.name + if not success: print ' if (1) {' self.failFunction(function) + if function.name[-1].islower(): + sys.stderr.write('warning: unsupported %s call\n' % function.name) print ' }' - self.invokeFunction(function) + + def swizzleValues(self, function): for arg in function.args: if arg.output: arg_type = ConstRemover().visit(arg.type) @@ -247,9 +281,6 @@ class Retracer: self.regiterSwizzledValue(function.type, lvalue, rvalue) except NotImplementedError: print ' // XXX: result' - if not success: - if function.name[-1].islower(): - sys.stderr.write('warning: unsupported %s call\n' % function.name) def failFunction(self, function): print ' if (retrace::verbosity >= 0) {' @@ -276,25 +307,20 @@ class Retracer: else: print ' %s(%s);' % (function.name, arg_names) + def invokeInterfaceMethod(self, interface, method): + arg_names = ", ".join(method.argNames()) + if method.type is not stdapi.Void: + print ' %s __result;' % (method.type) + print ' __result = _this->%s(%s);' % (method.name, arg_names) + print ' (void)__result;' + else: + print ' _this->%s(%s);' % (method.name, arg_names) + def filterFunction(self, function): return True table_name = 'retrace::callbacks' - def retraceFunctions(self, functions): - functions = filter(self.filterFunction, functions) - - for function in functions: - self.retraceFunction(function) - - print 'const retrace::Entry %s[] = {' % self.table_name - for function in functions: - print ' {"%s", &retrace_%s},' % (function.name, function.name) - print ' {NULL, NULL}' - print '};' - print - - def retraceApi(self, api): print '#include "trace_parser.hpp"' @@ -314,5 +340,21 @@ class Retracer: handle_names.add(handle.name) print - self.retraceFunctions(api.functions) + functions = filter(self.filterFunction, api.functions) + for function in functions: + self.retraceFunction(function) + interfaces = api.getAllInterfaces() + for interface in interfaces: + for method in interface.iterMethods(): + self.retraceInterfaceMethod(interface, method) + + print 'const retrace::Entry %s[] = {' % self.table_name + for function in functions: + print ' {"%s", &retrace_%s},' % (function.name, function.name) + for interface in interfaces: + for method in interface.iterMethods(): + print ' {"%s::%s", &retrace_%s__%s},' % (interface.name, method.name, interface.name, method.name) + print ' {NULL, NULL}' + print '};' + print