]> git.cworth.org Git - apitrace/commitdiff
Try to cope with missing functions.
authorJosé Fonseca <jfonseca@vmware.com>
Thu, 23 Apr 2009 14:20:29 +0000 (15:20 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Thu, 23 Apr 2009 14:20:29 +0000 (15:20 +0100)
In particular Direct3DCreate9Ex is only defined on Vista.

base.py
d3d9.py
windows.py

diff --git a/base.py b/base.py
index 1632bc0d1c0c2a480ab6e53fcdeceacd6eeb3c1c..2678ab87614b05221689420e038490d53a67df40 100644 (file)
--- a/base.py
+++ b/base.py
@@ -224,11 +224,12 @@ class Alias(Type):
 
 class Function:
 
-    def __init__(self, type, name, args, call = '__stdcall'):
+    def __init__(self, type, name, args, call = '__stdcall', fail = None):
         self.type = type
         self.name = name
         self.args = args
         self.call = call
+        self.fail = fail
 
     def prototype(self, name=None):
         if name is not None:
diff --git a/d3d9.py b/d3d9.py
index 6e4ce24b8b2cc747b6f393149b88a22379e3bc62..152d48506bf93bbdb54687dc5a09079b218522ff 100644 (file)
--- a/d3d9.py
+++ b/d3d9.py
@@ -383,8 +383,8 @@ IDirect3DSwapChain9Ex.methods += [
 
 d3d9 = Dll("d3d9")
 d3d9.functions += [
-    Function(PDIRECT3D9, "Direct3DCreate9", [(UINT, "SDKVersion")]),
-    Function(HRESULT, "Direct3DCreate9Ex", [(UINT, "SDKVersion"), (OutPointer(PDIRECT3D9EX), "ppD3D")]),
+    Function(PDIRECT3D9, "Direct3DCreate9", [(UINT, "SDKVersion")], fail='NULL'),
+    Function(HRESULT, "Direct3DCreate9Ex", [(UINT, "SDKVersion"), (OutPointer(PDIRECT3D9EX), "ppD3D")], fail='D3DERR_NOTAVAILABLE'),
 ]
 
 if __name__ == '__main__':
index ba6ca5a8c572218149b7fe7e880ac3e0f957b2dd..a149e6a5b6659449172b472f94faf4d41080caf4 100644 (file)
@@ -204,7 +204,11 @@ 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():