]> git.cworth.org Git - apitrace/blobdiff - wrappers/trace.py
Merge commit '5c298db8fe117e0a445af051335aa0da91c3a31b'
[apitrace] / wrappers / trace.py
index 5f6f52b4d3f446803e41007582d9df5007eaa84a..958c07279a1bf55eab84d44d349ef6a3fded764f 100644 (file)
@@ -396,6 +396,9 @@ class Tracer:
         print '#else'
         print '#  include <alloca.h> // 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;'