]> git.cworth.org Git - apitrace/blobdiff - trace.py
Split glxapi.
[apitrace] / trace.py
index 8e2e2af3e061cc41e6d9145d1b12d754947eadaf..677faf33d4d3823287ad24f296394af15fc0bfcf 100644 (file)
--- a/trace.py
+++ b/trace.py
 """C basic types"""
 
 
-import base
+import stdapi
 
 
 all_types = {}
 
 
-class DumpDeclarator(base.OnceVisitor):
+class DumpDeclarator(stdapi.OnceVisitor):
     '''Declare helper functions to dump complex types.'''
 
     def visit_void(self, literal):
@@ -51,7 +51,7 @@ class DumpDeclarator(base.OnceVisitor):
         for type, name in struct.members:
             self.visit(type)
         print 'static void __traceStruct%s(const %s &value) {' % (struct.id, struct.expr)
-        print '    Log::BeginStruct("%s");' % struct.name
+        print '    Log::BeginStruct(%u);' % len(struct.members)
         for type, name in struct.members:
             print '    Log::BeginMember("%s");' % (name,)
             dump_instance(type, 'value.%s' % (name,))
@@ -111,7 +111,7 @@ class DumpDeclarator(base.OnceVisitor):
         pass
 
 
-class DumpImplementer(base.Visitor):
+class DumpImplementer(stdapi.Visitor):
     '''Dump an instance.'''
 
     def visit_literal(self, literal, instance):
@@ -180,7 +180,7 @@ dump_instance = DumpImplementer().visit
 
 
 
-class Wrapper(base.Visitor):
+class Wrapper(stdapi.Visitor):
     '''Wrap an instance.'''
 
     def visit_void(self, type, instance):
@@ -290,7 +290,7 @@ class Tracer:
 
     def trace_function_fail(self, function):
         if function.fail is not None:
-            if function.type is base.Void:
+            if function.type is stdapi.Void:
                 assert function.fail == ''
                 print '            return;' 
             else:
@@ -314,33 +314,35 @@ class Tracer:
     def trace_function_impl(self, function):
         pvalue = self.function_pointer_value(function)
         print function.prototype() + ' {'
-        if function.type is base.Void:
+        if function.type is stdapi.Void:
             result = ''
         else:
             print '    %s __result;' % function.type
             result = '__result = '
         self._get_true_pointer(function)
-        print '    Log::BeginCall("%s");' % (function.name)
+        print '    unsigned __call = Log::BeginEnter("%s");' % (function.name)
         for arg in function.args:
             if not arg.output:
                 self.unwrap_arg(function, arg)
                 self.dump_arg(function, arg)
+        print '    Log::EndEnter();'
         print '    %s%s(%s);' % (result, pvalue, ', '.join([str(arg.name) for arg in function.args]))
+        print '    Log::BeginLeave(__call);'
         for arg in function.args:
             if arg.output:
                 self.dump_arg(function, arg)
                 self.wrap_arg(function, arg)
-        if function.type is not base.Void:
+        if function.type is not stdapi.Void:
             self.dump_ret(function, "__result")
-        print '    Log::EndCall();'
-        if function.type is not base.Void:
+        print '    Log::EndLeave();'
+        if function.type is not stdapi.Void:
             self.wrap_ret(function, "__result")
             print '    return __result;'
         print '}'
         print
 
     def dump_arg(self, function, arg):
-        print '    Log::BeginArg("%s");' % (arg.name,)
+        print '    Log::BeginArg(%u, "%s");' % (arg.index, arg.name,)
         dump_instance(arg.type, arg.name)
         print '    Log::EndArg();'
 
@@ -402,7 +404,7 @@ class Tracer:
             print '    %s __result;' % method.type
             result = '__result = '
         print '    Log::BeginCall("%s");' % (interface.name + '::' + method.name)
-        print '    Log::BeginArg("this");'
+        print '    Log::BeginArg(0, "this");'
         print '    Log::LiteralOpaque((const void *)m_pInstance);'
         print '    Log::EndArg();'
         for arg in method.args: