]> git.cworth.org Git - apitrace/blobdiff - wrappers/trace.py
Factor out the lock rect size computation.
[apitrace] / wrappers / trace.py
index 782e739d4839f850117b25da83e1c02d05ff230c..eea2fdc22d6f21a57cb928407ead4cebfcf310e6 100644 (file)
@@ -462,10 +462,9 @@ class Tracer:
         for other_arg in function.args:
             if not other_arg.output and other_arg.type is REFIID:
                 riid = other_arg
-        if riid is not None and isinstance(arg.type, stdapi.Pointer):
-            assert isinstance(arg.type.type, stdapi.ObjPointer)
-            obj_type = arg.type.type.type
-            assert obj_type is stdapi.Void
+        if riid is not None \
+           and isinstance(arg.type, stdapi.Pointer) \
+           and isinstance(arg.type.type, stdapi.ObjPointer):
             self.wrapIid(function, riid, arg)
             return
 
@@ -565,6 +564,9 @@ class Tracer:
     def implementWrapperInterfaceMethodBody(self, interface, base, method):
         print '    static const char * _args[%u] = {%s};' % (len(method.args) + 1, ', '.join(['"this"'] + ['"%s"' % arg.name for arg in method.args]))
         print '    static const trace::FunctionSig _sig = {%u, "%s", %u, _args};' % (method.id, interface.name + '::' + method.name, len(method.args) + 1)
+
+        print '    %s *_this = static_cast<%s *>(m_pInstance);' % (base, base)
+
         print '    unsigned _call = trace::localWriter.beginEnter(&_sig);'
         print '    trace::localWriter.beginArg(0);'
         print '    trace::localWriter.writePointer((uintptr_t)m_pInstance);'
@@ -621,18 +623,25 @@ class Tracer:
         print
 
     def wrapIid(self, function, riid, out):
+        # Cast output arg to `void **` if necessary
+        out_name = out.name
+        obj_type = out.type.type.type
+        if not obj_type is stdapi.Void:
+            assert isinstance(obj_type, stdapi.Interface)
+            out_name = 'reinterpret_cast<void * *>(%s)' % out_name
+
         print r'    if (%s && *%s) {' % (out.name, out.name)
         functionName = function.name
         else_ = ''
         if self.interface is not None:
             functionName = self.interface.name + '::' + functionName
-            print r'        if (*%s == m_pInstance &&' % (out.name,)
+            print r'        if (*%s == m_pInstance &&' % (out_name,)
             print r'            (%s)) {' % ' || '.join('%s == IID_%s' % (riid.name, iface.name) for iface in self.interface.iterBases())
-            print r'            *%s = this;' % (out.name,)
+            print r'            *%s = this;' % (out_name,)
             print r'        }'
             else_ = 'else '
         print r'        %s{' % else_
-        print r'             wrapIID("%s", %s, %s);' % (functionName, riid.name, out.name) 
+        print r'             wrapIID("%s", %s, %s);' % (functionName, riid.name, out_name)
         print r'        }'
         print r'    }'
 
@@ -641,7 +650,7 @@ class Tracer:
             result = ''
         else:
             result = '_result = '
-        print '    %sstatic_cast<%s *>(m_pInstance)->%s(%s);' % (result, base, method.name, ', '.join([str(arg.name) for arg in method.args]))
+        print '    %s_this->%s(%s);' % (result, method.name, ', '.join([str(arg.name) for arg in method.args]))
     
     def emit_memcpy(self, dest, src, length):
         print '        unsigned _call = trace::localWriter.beginEnter(&trace::memcpy_sig);'