]> git.cworth.org Git - apitrace/blobdiff - windows.py
Try to cope with missing functions.
[apitrace] / windows.py
index d9b915b8a72d9f82a9f74137d37113350a8fa636..a149e6a5b6659449172b472f94faf4d41080caf4 100644 (file)
@@ -45,6 +45,7 @@ LPBOOL = Pointer(BOOL)
 LPSIZE = LPDWORD
 
 LPSTR = String
+LPCSTR = Const(String)
 LPWSTR = String
 
 LARGE_INTEGER = Intrinsic("LARGE_INTEGER", "0x%llx")
@@ -164,6 +165,7 @@ class Dll:
         print r'        if(!GetSystemDirectory(g_szDll, MAX_PATH))'
         print r'            return FALSE;'
         print r'        _tcscat(g_szDll, TEXT("\\%s.dll"));' % self.name
+        print r'        Log::Open("%s");' % self.name
         print r'    case DLL_THREAD_ATTACH:'
         print r'        return TRUE;'
         print r'    case DLL_THREAD_DETACH:'
@@ -184,7 +186,7 @@ class Dll:
         for function in self.functions:
             type = 'P' + function.name
             print function.prototype() + ' {'
-            if 1:
+            if 0:
                 print '    Log::Close();'
                 print '    Log::Open("%s");' % self.name
             #print '    Log::ReOpen();'
@@ -202,15 +204,31 @@ class Dll:
             print '    }'
             print '    pFunction = (%s)GetProcAddress( g_hDll, "%s");' % (type, function.name)
             print '    if(!pFunction)'
-            print '        ExitProcess(0);'
+            if function.fail is not None:
+                assert function.type is not Void
+                print '        return %s;' % function.fail
+            else:
+                print '        ExitProcess(0);'
             print '    Log::BeginCall("%s");' % (function.name)
+            for type, name in function.args:
+                if not type.isoutput():
+                    type.unwrap_instance(name)
+                    print '    Log::BeginArg("%s", "%s");' % (type, name)
+                    type.dump(name)
+                    print '    Log::EndArg();'
             print '    %spFunction(%s);' % (result, ', '.join([str(name) for type, name in function.args]))
-            print '    Log::EndCall();'
             for type, name in function.args:
                 if type.isoutput():
+                    print '    Log::BeginArg("%s", "%s");' % (type, name)
+                    type.dump(name)
+                    print '    Log::EndArg();'
                     type.wrap_instance(name)
             if function.type is not Void:
+                print '    Log::BeginReturn("%s");' % function.type
+                function.type.dump("result")
+                print '    Log::EndReturn();'
                 function.type.wrap_instance('result')
+            print '    Log::EndCall();'
             if function.type is not Void:
                 print '    return result;'
             print '}'