]> git.cworth.org Git - apitrace/blobdiff - retrace.py
Fix a crash when loading multiple frames at once.
[apitrace] / retrace.py
index edfc07977cf8f94ddac2b8ffb0afac96e2688423..9092f351366a2377231761c962e2c1daec382879 100644 (file)
@@ -28,7 +28,6 @@
 
 import specs.stdapi as stdapi
 import specs.glapi as glapi
-from codegen import *
 
 
 class ConstRemover(stdapi.Rebuilder):
@@ -70,7 +69,7 @@ class ValueExtractor(stdapi.Visitor):
         print '    const Trace::Array *__a%s = dynamic_cast<const Trace::Array *>(&%s);' % (array.id, rvalue)
         print '    if (__a%s) {' % (array.id)
         length = '__a%s->values.size()' % array.id
-        print '        __allocator(%s, %s);' % (lvalue, length)
+        print '        %s = new %s[%s];' % (lvalue, array.type, length)
         index = '__j' + array.id
         print '        for (size_t {i} = 0; {i} < {length}; ++{i}) {{'.format(i = index, length = length)
         try:
@@ -84,7 +83,7 @@ class ValueExtractor(stdapi.Visitor):
     def visit_pointer(self, pointer, lvalue, rvalue):
         print '    const Trace::Array *__a%s = dynamic_cast<const Trace::Array *>(&%s);' % (pointer.id, rvalue)
         print '    if (__a%s) {' % (pointer.id)
-        print '        __allocator(%s);' % (lvalue,)
+        print '        %s = new %s;' % (lvalue, pointer.type)
         try:
             self.visit(pointer.type, '%s[0]' % (lvalue,), '*__a%s->values[0]' % (pointer.id,))
         finally:
@@ -193,8 +192,6 @@ class Retracer:
             print '    (void)call;'
             return
 
-        print '    scoped_allocator __allocator;'
-        print '    (void)__allocator;'
         success = True
         for arg in function.args:
             arg_type = ConstRemover().visit(arg.type)
@@ -252,27 +249,19 @@ class Retracer:
     def filter_function(self, function):
         return True
 
+    table_name = 'retrace::callbacks'
+
     def retrace_functions(self, functions):
         functions = filter(self.filter_function, functions)
 
         for function in functions:
             self.retrace_function(function)
 
-        print 'void retrace::retrace_call(Trace::Call &call) {'
-        print '    const char *name = call.name();'
-        print
-
-        func_dict = dict([(function.name, function) for function in functions])
-
-        def handle_case(function_name):
-            function = func_dict[function_name]
-            print '        retrace_%s(call);' % function.name
-            print '        return;'
-    
-        string_switch('name', func_dict.keys(), handle_case)
-
-        print '    retrace_unknown(call);'
-        print '}'
+        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
 
 
@@ -280,7 +269,6 @@ class Retracer:
 
         print '#include "trace_parser.hpp"'
         print '#include "retrace.hpp"'
-        print '#include "scoped_allocator.hpp"'
         print
 
         types = api.all_types()