]> git.cworth.org Git - apitrace/commitdiff
Basic support to trace functions obtained via wglGetProcAddress.
authorJosé Fonseca <jfonseca@vmware.com>
Mon, 4 May 2009 11:53:50 +0000 (12:53 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Mon, 4 May 2009 11:53:50 +0000 (12:53 +0100)
base.py
opengl32.py
windows.py

diff --git a/base.py b/base.py
index a901aeb0e0d860365bcf4dd69aa116882469e16f..0dbec4c3ea34cc880e9ec8b30806353efec24f85 100644 (file)
--- a/base.py
+++ b/base.py
@@ -323,11 +323,15 @@ class Function:
             print '    Log::EndReturn();'
             self.type.wrap_instance('result')
         print '    Log::EndCall();'
+        self.post_call_impl()
         if self.type is not Void:
             print '    return result;'
         print '}'
         print
 
+    def post_call_impl(self):
+        pass
+
 
 class Interface(Type):
 
index 539d4661989e2e890c296f93f743673ed8450069..e12ec872856a93f70832ad35b601021a53176f7b 100644 (file)
@@ -533,7 +533,6 @@ opengl32.functions += [
     DllFunction(BOOL, "wglDeleteContext", [(HGLRC, "hglrc")]),
     DllFunction(HGLRC, "wglGetCurrentContext", []),
     DllFunction(HDC, "wglGetCurrentDC", []),
-    DllFunction(PROC, "wglGetProcAddress", [(LPCSTR, "lpszProc")]),
     DllFunction(PROC, "wglGetDefaultProcAddress", [(LPCSTR, "lpszProc")]),
     DllFunction(Int, "wglChoosePixelFormat", [(HDC, "hdc"), (Pointer(Const(PIXELFORMATDESCRIPTOR)), "ppfd")]), 
     DllFunction(Int, "wglDescribePixelFormat", [(HDC, "hdc"), (Int, "iPixelFormat"), (UINT, "nBytes"), (OutPointer(PIXELFORMATDESCRIPTOR), "ppfd")]),
@@ -563,6 +562,48 @@ if False:
         DllFunction(DWORD, "wglSwapMultipleBuffers", [(UINT, "n"), (Pointer(Const(WGLSWAP)), "ps")]),
     ]
 
+
+class WglGetProcAddressFunction(DllFunction):
+
+    def __init__(self, type, name, args):
+        DllFunction.__init__(self, type, name, args)
+        self.functions = []
+
+    def wrap_decl(self):
+        for function in self.functions:
+            function.wrap_decl()
+        DllFunction.wrap_decl(self)
+
+    def wrap_impl(self):
+        for function in self.functions:
+            function.wrap_impl()
+        DllFunction.wrap_impl(self)
+
+    def post_call_impl(self):
+        for function in self.functions:
+            ptype = function.pointer_type()
+            pvalue = function.pointer_value()
+            print '    if(!strcmp("%s", lpszProc)) {' % function.name
+            print '        %s = (%s)result;' % (pvalue, ptype)
+            print '        result = (PROC)&%s;' % function.name;
+            print '    }'
+
+
+wglgetprocaddress = WglGetProcAddressFunction(PROC, "wglGetProcAddress", [(LPCSTR, "lpszProc")])
+opengl32.functions.append(wglgetprocaddress)
+
+class WglFunction(Function):
+
+    def get_true_pointer(self):
+        ptype = self.pointer_type()
+        pvalue = self.pointer_value()
+        print '    if(!%s)' % (pvalue,)
+        self.fail_impl()
+
+wglgetprocaddress.functions += [
+    WglFunction(Const(String), "wglGetExtensionsStringARB", [(HDC, "hdc")]),
+]
+
 if __name__ == '__main__':
     print
     print '#define _GDI32_'
index 4db8616618f31178a42d635f77a76bed44e592b6..59d659180d1c419eb48a45ad164cdeb0881b9bc1 100644 (file)
@@ -148,7 +148,7 @@ class DllFunction(Function):
         self.fail_impl()
         print '    }'
         print '    if(!%s) {' % (pvalue,)
-        print '        %s = (%s)GetProcAddress( g_hDll, "%s");' % (pvalue, ptype, self.name)
+        print '        %s = (%s)GetProcAddress(g_hDll, "%s");' % (pvalue, ptype, self.name)
         print '        if(!%s)' % (pvalue,)
         self.fail_impl()
         print '    }'