]> git.cworth.org Git - apitrace/commitdiff
d2d1,dwrite: Trace both APIs together.
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Tue, 13 Nov 2012 08:21:15 +0000 (08:21 +0000)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Tue, 13 Nov 2012 08:21:55 +0000 (08:21 +0000)
12 files changed:
wrappers/.gitignore
wrappers/CMakeLists.txt
wrappers/d2d1.def
wrappers/d2d1trace.py
wrappers/d3d10_1trace.py
wrappers/d3d10trace.py
wrappers/d3d11trace.py
wrappers/d3d8trace.py
wrappers/d3d9trace.py
wrappers/ddrawtrace.py
wrappers/dlltrace.py
wrappers/dwritetrace.py [deleted file]

index cc5f074b65f5017f7ec6a52e5d9304c5d3c128a6..e124b5d0740d03dcba90e348d8db2afffb0d8765 100644 (file)
@@ -8,7 +8,6 @@ d3d8trace.cpp
 d3d9trace.cpp
 ddrawtrace.cpp
 dlltrace.cpp
-dwritetrace.cpp
 egltrace.cpp
 gltrace.cpp
 glxtrace.cpp
index 9cb4504e4ce251244fbafd32d369caf636d1ca0f..69d65869f5725e6002abe3c4f44b77a6c07b03bf 100644 (file)
@@ -268,7 +268,7 @@ if (WIN32)
                 ${CMAKE_SOURCE_DIR}/specs/winapi.py
                 ${CMAKE_SOURCE_DIR}/specs/stdapi.py
         )
-        add_library (d2d1 MODULE d2d1.def d2d1trace.cpp)
+        add_library (d2d1 SHARED d2d1.def d2d1trace.cpp)
         target_link_libraries (d2d1
             common_trace
             common
@@ -279,33 +279,15 @@ if (WIN32)
             PROPERTIES PREFIX ""
             OUTPUT_NAME d2d1
         )
-        install (TARGETS d2d1 LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
-
-        add_custom_command (
-            OUTPUT dwritetrace.cpp
-            COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/dwritetrace.py > ${CMAKE_CURRENT_BINARY_DIR}/dwritetrace.cpp
-            DEPENDS
-                dwritetrace.py
-                trace.py
-                ${CMAKE_SOURCE_DIR}/specs/d2d1.py
-                ${CMAKE_SOURCE_DIR}/specs/d2d1.py
-                ${CMAKE_SOURCE_DIR}/specs/d2dbasetypes.py
-                ${CMAKE_SOURCE_DIR}/specs/d2derr.py
-                ${CMAKE_SOURCE_DIR}/specs/dwrite.py
-                ${CMAKE_SOURCE_DIR}/specs/dcommon.py
-                ${CMAKE_SOURCE_DIR}/specs/dxgi.py
-                ${CMAKE_SOURCE_DIR}/specs/dxgitype.py
-                ${CMAKE_SOURCE_DIR}/specs/dxgiformat.py
-                ${CMAKE_SOURCE_DIR}/specs/winapi.py
-                ${CMAKE_SOURCE_DIR}/specs/stdapi.py
-        )
-        add_library (dwrite MODULE dwrite.def dwritetrace.cpp)
-        target_link_libraries (dwrite
-            common_trace
-            common
-            ${ZLIB_LIBRARIES}
-            ${SNAPPY_LIBRARIES}
+        # http://www.cmake.org/pipermail/cmake/2009-March/028221.html
+        install (TARGETS d2d1
+            RUNTIME DESTINATION ${WRAPPER_INSTALL_DIR} COMPONENT RUNTIME
+            LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR} COMPONENT RUNTIME
         )
+
+        # dwrite.dll is just an empty stub for d2d1.dll
+        add_library (dwrite MODULE dwrite.def)
+        target_link_libraries (dwrite d2d1)
         set_target_properties (dwrite
             PROPERTIES PREFIX ""
             OUTPUT_NAME dwrite
index 58c897b708168d7ceb7f73ace48802f491faea48..da9a8137b1a5599af7462a396513d522cf556f7d 100644 (file)
@@ -6,3 +6,5 @@ EXPORTS
        D2D1IsMatrixInvertible
        D2D1MakeRotateMatrix
        D2D1MakeSkewMatrix
+
+       DWriteCreateFactory
index 8883bd578b82f5821de1dec547168cc8fe9dd9f4..10e14a441b5044c0472da769733e09dfec791908 100644 (file)
@@ -25,6 +25,8 @@
 
 
 from dlltrace import DllTracer
+from specs.stdapi import API
+from specs.dwrite import dwrite
 from specs.d2d1 import d2d1
 
 
@@ -34,8 +36,13 @@ if __name__ == '__main__':
     print '#include "trace_writer_local.hpp"'
     print '#include "os.hpp"'
     print
+    print '#define DWRITE_EXPORT WINAPI'
+    print
     print '#include "d2dimports.hpp"'
     print
 
-    tracer = DllTracer('d2d1.dll')
-    tracer.traceModule(d2d1)
+    api = API()
+    api.addModule(d2d1)
+    api.addModule(dwrite)
+    tracer = DllTracer()
+    tracer.traceApi(api)
index 3b744e426c4933c3aaf2937f964166bd6ff9ee26..94bd743cd6fa567fb44b21882497812a8edb55ec 100644 (file)
@@ -25,6 +25,7 @@
 
 
 from d3dcommontrace import D3DCommonTracer
+from specs.stdapi import API
 from specs.d3d10_1 import d3d10_1
 
 
@@ -38,5 +39,8 @@ if __name__ == '__main__':
     print '#include "d3dcommonshader.hpp"'
     print '#include "d3d10size.hpp"'
     print
-    tracer = D3DCommonTracer('d3d10_1.dll')
-    tracer.traceModule(d3d10_1)
+
+    api = API()
+    api.addModule(d3d10_1)
+    tracer = D3DCommonTracer()
+    tracer.traceApi(api)
index 9bbaa9434af5785e46d36dbe117865a857f99d40..7a9f3ff0af92e9e270c1e20aa3ba9c0fdac42e54 100644 (file)
@@ -25,6 +25,7 @@
 
 
 from d3dcommontrace import D3DCommonTracer
+from specs.stdapi import API
 from specs.d3d10misc import d3d10
 
 
@@ -38,5 +39,8 @@ if __name__ == '__main__':
     print '#include "d3dcommonshader.hpp"'
     print '#include "d3d10size.hpp"'
     print
-    tracer = D3DCommonTracer('d3d10.dll')
-    tracer.traceModule(d3d10)
+
+    api = API()
+    api.addModule(d3d10)
+    tracer = D3DCommonTracer()
+    tracer.traceApi(api)
index aa076a07ca095d5e4fcc78d1e969cf597f58ecd4..6e2627717dca96b84ffb32b5fad394d95a333f61 100644 (file)
@@ -27,6 +27,7 @@
 import sys
 
 from d3dcommontrace import D3DCommonTracer
+from specs.stdapi import API
 from specs.d3d11 import d3d11
 
 
@@ -47,5 +48,8 @@ if __name__ == '__main__':
     print '#include "d3dcommonshader.hpp"'
     print '#include "d3d11size.hpp"'
     print
-    tracer = D3DCommonTracer('d3d11.dll')
-    tracer.traceModule(d3d11)
+
+    api = API()
+    api.addModule(d3d11)
+    tracer = D3DCommonTracer()
+    tracer.traceApi(api)
index cba3ace27e1dbbde67a037caab2107f39e6c20c6..2abaf4e54f27923f45bfa66964ebacfe6a53c624 100644 (file)
@@ -25,6 +25,7 @@
 
 
 from dlltrace import DllTracer
+from specs.stdapi import API
 from specs.d3d8 import d3d8
 
 
@@ -49,6 +50,9 @@ if __name__ == '__main__':
     print '#include "trace_writer_local.hpp"'
     print '#include "os.hpp"'
     print
-    tracer = D3D8Tracer('d3d8.dll')
-    tracer.traceModule(d3d8)
 
+
+    api = API()
+    api.addModule(d3d8)
+    tracer = D3D8Tracer()
+    tracer.traceApi(api)
index c1cadb67e49b10d39d6619992d6fb6acceb73977..2a4c1a93d824503164d15e36b0796a7c105cec59 100644 (file)
@@ -25,6 +25,7 @@
 
 
 from dlltrace import DllTracer
+from specs.stdapi import API
 from specs.d3d9 import d3d9, D3DSHADER9
 
 import specs.d3d9dxva2
@@ -94,6 +95,8 @@ _declCount(const D3DVERTEXELEMENT9 *pVertexElements) {
     return count;
 }
 '''
-    tracer = D3D9Tracer('d3d9.dll')
-    tracer.traceModule(d3d9)
 
+    api = API()
+    api.addModule(d3d9)
+    tracer = D3D9Tracer()
+    tracer.traceApi(api)
index 7a60d4621304fd46771af307a206996d7101e5db..94e39e2d126e3c2d18db984af49a7f946d6c4a58 100644 (file)
@@ -25,6 +25,7 @@
 
 
 from dlltrace import DllTracer
+from specs.stdapi import API
 from specs.d3d import ddraw, interfaces
 
 
@@ -56,5 +57,8 @@ if __name__ == '__main__':
     print '#include "trace_writer_local.hpp"'
     print '#include "os.hpp"'
     print
-    tracer = DllTracer('ddraw.dll')
-    tracer.traceModule(ddraw)
+
+    api = API()
+    api.addModule(ddraw)
+    tracer = DllTracer()
+    tracer.traceApi(api)
index cea7dc7464c4717efe44828a917f65a6a4c2d3d9..f7ad20fe8c4a399337fe61313c48d8681a3c5741 100644 (file)
 """Trace code generation for Windows DLLs."""
 
 
+import ntpath
+
 from trace import Tracer
 from dispatch import Dispatcher
 from specs.stdapi import API
 
 
-class DllTracer(Tracer):
+class DllDispatcher(Dispatcher):
 
-    def __init__(self, dllname):
-        self.dllname = dllname
-    
-    def header(self, api):
-        print '''
-static HMODULE g_hDll = NULL;
+    def dispatchModule(self, module):
+        tag = module.name.upper()
+        print r'HMODULE g_h%sModule = NULL;' % (tag,)
+        print r''
+        print r'static PROC'
+        print r'_get%sProcAddress(LPCSTR lpProcName) {' % tag
+        print r'    if (!g_h%sModule) {' % tag
+        print r'        char szDll[MAX_PATH] = {0};'
+        print r'        if (!GetSystemDirectoryA(szDll, MAX_PATH)) {'
+        print r'            return NULL;'
+        print r'        }'
+        print r'        strcat(szDll, "\\\\%s.dll");' % module.name
+        print r'        g_h%sModule = LoadLibraryA(szDll);' % tag
+        print r'        if (!g_h%sModule) {' % tag
+        print r'            return NULL;'
+        print r'        }'
+        print r'    }'
+        print r'    return GetProcAddress(g_h%sModule, lpProcName);' % tag
+        print r'}'
+        print r''
 
-static PROC
-_getPublicProcAddress(LPCSTR lpProcName)
-{
-    if (!g_hDll) {
-        char szDll[MAX_PATH] = {0};
-        
-        if (!GetSystemDirectoryA(szDll, MAX_PATH)) {
-            return NULL;
-        }
-        
-        strcat(szDll, "\\\\%s");
-        
-        g_hDll = LoadLibraryA(szDll);
-        if (!g_hDll) {
-            return NULL;
-        }
-    }
-        
-    return GetProcAddress(g_hDll, lpProcName);
-}
+        Dispatcher.dispatchModule(self, module)
 
-''' % self.dllname
+    def getProcAddressName(self, module, function):
+        assert self.isFunctionPublic(module, function)
+        return '_get%sProcAddress' % (module.name.upper())
+
+
+class DllTracer(Tracer):
+
+    def header(self, api):
 
         for module in api.modules:
-            dispatcher = Dispatcher()
+            dispatcher = DllDispatcher()
             dispatcher.dispatchModule(module)
 
         Tracer.header(self, api)
-
-    def traceModule(self, module):
-        api = API()
-        api.addModule(module)
-        self.traceApi(api)
diff --git a/wrappers/dwritetrace.py b/wrappers/dwritetrace.py
deleted file mode 100644 (file)
index 2b42e43..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-##########################################################################
-#
-# Copyright 2008-2009 VMware, Inc.
-# All Rights Reserved.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-# THE SOFTWARE.
-#
-##########################################################################/
-
-
-from dlltrace import DllTracer
-from specs.dwrite import dwrite
-from specs.d2d1 import d2d1 # cyclic dependency
-
-
-if __name__ == '__main__':
-    print '#define INITGUID'
-    print
-    print '#include "trace_writer_local.hpp"'
-    print '#include "os.hpp"'
-    print
-    print '#define DWRITE_EXPORT WINAPI'
-    print
-    print '#include "d2dimports.hpp"'
-    print
-
-    tracer = DllTracer('dwrite.dll')
-    tracer.traceModule(dwrite)