X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=wrappers%2Ftrace.py;h=30668365ee3fc27eded75d3f4111f64d0951b0e7;hb=b2533e55f00bc9c086eb31573d391ba26bf40fe4;hp=5f6f52b4d3f446803e41007582d9df5007eaa84a;hpb=614174444ce27a22f25e08a50cca3af5d3d07bae;p=apitrace diff --git a/wrappers/trace.py b/wrappers/trace.py index 5f6f52b..3066836 100644 --- a/wrappers/trace.py +++ b/wrappers/trace.py @@ -162,12 +162,12 @@ class ValueSerializer(stdapi.Visitor): print ' trace::localWriter.write%s(%s);' % (literal.kind, instance) def visitString(self, string, instance): - if string.kind == 'String': + if not string.wide: cast = 'const char *' - elif string.kind == 'WString': - cast = 'const wchar_t *' + suffix = 'String' else: - assert False + cast = 'const wchar_t *' + suffix = 'WString' if cast != string.expr: # reinterpret_cast is necessary for GLubyte * <=> char * instance = 'reinterpret_cast<%s>(%s)' % (cast, instance) @@ -175,7 +175,7 @@ class ValueSerializer(stdapi.Visitor): length = ', %s' % string.length else: length = '' - print ' trace::localWriter.write%s(%s%s);' % (string.kind, instance, length) + print ' trace::localWriter.write%s(%s%s);' % (suffix, instance, length) def visitConst(self, const, instance): self.visit(const.type, instance) @@ -396,6 +396,9 @@ class Tracer: print '#else' print '# include // alloca' print '#endif' + print + print '#include "trace.hpp"' + print def footer(self, api): pass @@ -422,6 +425,16 @@ class Tracer: print function.prototype() + ' {' if function.type is not stdapi.Void: print ' %s _result;' % function.type + + # No-op if tracing is disabled + print ' if (!trace::isTracingEnabled()) {' + Tracer.invokeFunction(self, function) + if function.type is not stdapi.Void: + print ' return _result;' + else: + print ' return;' + print ' }' + self.traceFunctionImplBody(function) if function.type is not stdapi.Void: print ' return _result;' @@ -682,4 +695,15 @@ class Tracer: print ' trace::localWriter.endEnter();' print ' trace::localWriter.beginLeave(_call);' print ' trace::localWriter.endLeave();' + + def fake_call(self, function, args): + print ' unsigned _fake_call = trace::localWriter.beginEnter(&_%s_sig);' % (function.name,) + for arg, instance in zip(function.args, args): + assert not arg.output + print ' trace::localWriter.beginArg(%u);' % (arg.index,) + self.serializeValue(arg.type, instance) + print ' trace::localWriter.endArg();' + print ' trace::localWriter.endEnter();' + print ' trace::localWriter.beginLeave(_fake_call);' + print ' trace::localWriter.endLeave();'