]> git.cworth.org Git - apitrace/blobdiff - retrace.py
gles: fix GLES version string matching
[apitrace] / retrace.py
index 96a09abc1fcd623048453a578d202d612c6e10e3..5913f56c8550a23dc162054d2a1765e8ec2add26 100644 (file)
@@ -63,7 +63,7 @@ class ValueDeserializer(stdapi.Visitor):
         self.visit(alias.type, lvalue, rvalue)
     
     def visitEnum(self, enum, lvalue, rvalue):
-        print '    %s = (%s).toSInt();' % (lvalue, rvalue)
+        print '    %s = static_cast<%s>((%s).toSInt());' % (lvalue, enum, rvalue)
 
     def visitBitmask(self, bitmask, lvalue, rvalue):
         self.visit(bitmask.type, lvalue, rvalue)
@@ -72,7 +72,7 @@ class ValueDeserializer(stdapi.Visitor):
         print '    const trace::Array *__a%s = dynamic_cast<const trace::Array *>(&%s);' % (array.tag, rvalue)
         print '    if (__a%s) {' % (array.tag)
         length = '__a%s->values.size()' % array.tag
-        print '        %s = new %s[%s];' % (lvalue, array.type, length)
+        print '        %s = _allocator.alloc<%s>(%s);' % (lvalue, array.type, length)
         index = '__j' + array.tag
         print '        for (size_t {i} = 0; {i} < {length}; ++{i}) {{'.format(i = index, length = length)
         try:
@@ -86,7 +86,7 @@ class ValueDeserializer(stdapi.Visitor):
     def visitPointer(self, pointer, lvalue, rvalue):
         print '    const trace::Array *__a%s = dynamic_cast<const trace::Array *>(&%s);' % (pointer.tag, rvalue)
         print '    if (__a%s) {' % (pointer.tag)
-        print '        %s = new %s;' % (lvalue, pointer.type)
+        print '        %s = _allocator.alloc<%s>();' % (lvalue, pointer.type)
         try:
             self.visit(pointer.type, '%s[0]' % (lvalue,), '*__a%s->values[0]' % (pointer.tag,))
         finally:
@@ -94,8 +94,15 @@ class ValueDeserializer(stdapi.Visitor):
             print '        %s = NULL;' % lvalue
             print '    }'
 
+    def visitIntPointer(self, pointer, lvalue, rvalue):
+        print '    %s = static_cast<%s>((%s).toPointer());' % (lvalue, pointer, rvalue)
+
+    def visitLinearPointer(self, pointer, lvalue, rvalue):
+        print '    %s = static_cast<%s>(retrace::toPointer(%s));' % (lvalue, pointer, rvalue)
+
     def visitHandle(self, handle, lvalue, rvalue):
-        OpaqueValueDeserializer().visit(handle.type, lvalue, rvalue);
+        #OpaqueValueDeserializer().visit(handle.type, lvalue, rvalue);
+        self.visit(handle.type, lvalue, rvalue);
         new_lvalue = lookupHandle(handle, lvalue)
         print '    if (retrace::verbosity >= 2) {'
         print '        std::cout << "%s " << size_t(%s) << " <- " << size_t(%s) << "\\n";' % (handle.name, lvalue, new_lvalue)
@@ -155,6 +162,14 @@ class SwizzledValueRegistrator(stdapi.Visitor):
         finally:
             print '    }'
     
+    def visitIntPointer(self, pointer, lvalue, rvalue):
+        pass
+    
+    def visitLinearPointer(self, pointer, lvalue, rvalue):
+        assert pointer.size is not None
+        if pointer.size is not None:
+            print r'    retrace::addRegion((%s).toUIntPtr(), %s, %s);' % (rvalue, lvalue, pointer.size)
+
     def visitHandle(self, handle, lvalue, rvalue):
         print '    %s __orig_result;' % handle.type
         OpaqueValueDeserializer().visit(handle.type, '__orig_result', rvalue);
@@ -197,6 +212,8 @@ class Retracer:
             print '    (void)call;'
             return
 
+        print '    retrace::ScopedAllocator _allocator;'
+        print '    (void)_allocator;'
         success = True
         for arg in function.args:
             arg_type = ConstRemover().visit(arg.type)
@@ -251,7 +268,7 @@ class Retracer:
         visitor.visit(type, lvalue, rvalue)
 
     def invokeFunction(self, function):
-        arg_names = ", ".join([arg.name for arg in function.args])
+        arg_names = ", ".join(function.argNames())
         if function.type is not stdapi.Void:
             print '    %s __result;' % (function.type)
             print '    __result = %s(%s);' % (function.name, arg_names)
@@ -280,11 +297,12 @@ class Retracer:
 
     def retraceApi(self, api):
 
+        print '#include "os_time.hpp"'
         print '#include "trace_parser.hpp"'
         print '#include "retrace.hpp"'
         print
 
-        types = api.all_types()
+        types = api.getAllTypes()
         handles = [type for type in types if isinstance(type, stdapi.Handle)]
         handle_names = set()
         for handle in handles: