X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=wrappers%2Ftrace.py;h=958c07279a1bf55eab84d44d349ef6a3fded764f;hb=537c507874cdde0b507d306ac058767f506da8e2;hp=c838dc78a83df0e8e61190b1f30ef774b20e5ba8;hpb=ba2f08cfdfbc4e48960ac7b1709928fff1e344ae;p=apitrace diff --git a/wrappers/trace.py b/wrappers/trace.py index c838dc7..958c072 100644 --- a/wrappers/trace.py +++ b/wrappers/trace.py @@ -187,7 +187,7 @@ class ValueSerializer(stdapi.Visitor): length = '_c' + array.type.tag index = '_i' + array.type.tag print ' if (%s) {' % instance - print ' size_t %s = %s;' % (length, array.length) + print ' size_t %s = %s > 0 ? %s : 0;' % (length, array.length, array.length) print ' trace::localWriter.beginArray(%s);' % length print ' for (size_t %s = 0; %s < %s; ++%s) {' % (index, index, length, index) print ' trace::localWriter.beginElement();' @@ -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;'