]> git.cworth.org Git - apitrace/commitdiff
Trace dwrite.dll too.
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Mon, 10 Oct 2011 23:16:47 +0000 (00:16 +0100)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Mon, 10 Oct 2011 23:16:47 +0000 (00:16 +0100)
.gitignore
CMakeLists.txt
dwritetrace.py [new file with mode: 0644]
specs/dwrite.def [new file with mode: 0644]
specs/dwrite.py
specs/stdapi.py
trace.py

index bd855dbdf05b7bf20d9238bbbff1ad62923f7d2f..455b6aff1e3271968b40f899a53919a2b73a866e 100644 (file)
@@ -30,11 +30,12 @@ CMakeFiles
 Makefile
 build
 cgltrace.cpp
-d3d1trace.cpp
+d2d1trace.cpp
 d3d10trace.cpp
 d3d8trace.cpp
 d3d9trace.cpp
 ddrawtrace.cpp
+dwritetrace.cpp
 dxsdk
 glproc.hpp
 glretrace
index d520fb6132e6f708932b10e9bbb82f44083678c7..0cb0acec21e69952a6ef4b8e61fb488936af8b2f 100755 (executable)
@@ -307,9 +307,10 @@ if (WIN32)
         install (TARGETS d3d10 LIBRARY DESTINATION wrappers)
     endif (DirectX_D3D10_INCLUDE_DIR)
 
-    # d2d1.dll
+    # d2d1.dll, dwrite.dll
     if (DirectX_D2D1_INCLUDE_DIR)
         include_directories (SYSTEM ${DirectX_D2D1_INCLUDE_DIR})
+
         add_custom_command (
             OUTPUT d2d1trace.cpp
             COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d2d1trace.py > ${CMAKE_CURRENT_BINARY_DIR}/d2d1trace.cpp
@@ -322,6 +323,19 @@ if (WIN32)
             LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
         )
         install (TARGETS d2d1 LIBRARY DESTINATION wrappers)
+
+        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 specs/d2d1.py specs/d2d1.py specs/d2dbasetypes.py specs/d2derr.py specs/dwrite.py specs/dcommon.py specs/dxgi.py specs/dxgitype.py specs/dxgiformat.py specs/winapi.py specs/stdapi.py
+        )
+        add_library (dwrite MODULE specs/dwrite.def dwritetrace.cpp)
+        set_target_properties (dwrite
+            PROPERTIES PREFIX ""
+            RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
+            LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
+        )
+        install (TARGETS dwrite LIBRARY DESTINATION wrappers)
     endif (DirectX_D2D1_INCLUDE_DIR)
 
     # opengl32.dll
diff --git a/dwritetrace.py b/dwritetrace.py
new file mode 100644 (file)
index 0000000..94f1fbf
--- /dev/null
@@ -0,0 +1,65 @@
+##########################################################################
+#
+# 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 trace import DllTracer
+from specs.dwrite import dwrite
+from specs.d2d1 import d2d1 # cyclic dependency
+
+
+class D2D1Tracer(DllTracer):
+
+    def wrap_arg(self, function, arg):
+        if function.name == 'D2D1CreateFactory' and arg.output:
+            print '    if (*%s) {' % arg.name
+            for iface in d2d1.interfaces:
+                print '        if (riid == IID_%s) {' % iface.name
+                print '            *%s = (%s) new Wrap%s((%s *)*%s);' % (arg.name, arg.type, iface.name, iface.name, arg.name)
+                print '        }'
+            print '    }'
+
+        DllTracer.wrap_arg(self, function, arg)
+
+
+if __name__ == '__main__':
+    print '#define INITGUID'
+    print
+    print '#include "trace_writer.hpp"'
+    print '#include "os.hpp"'
+    print
+    print '#include <windows.h>'
+    print
+    print '#include "compat.h"'
+    print
+    print '#define DWRITE_EXPORT WINAPI'
+    print
+    print '#include <d2d1.h>'
+    print '#include <dwrite.h>'
+    print
+    print 'DEFINE_GUID(IID_IDWriteFactory,0xb859ee5a,0xd838,0x4b5b,0xa2,0xe8,0x1a,0xdc,0x7d,0x93,0xdb,0x48);'
+    print
+
+    tracer = D2D1Tracer('dwrite.dll')
+    tracer.trace_api(dwrite)
diff --git a/specs/dwrite.def b/specs/dwrite.def
new file mode 100644 (file)
index 0000000..4cc6785
--- /dev/null
@@ -0,0 +1,4 @@
+LIBRARY "d2d1"
+
+EXPORTS
+       DWriteCreateFactory
index 38fbe21746fa93acd9e831ead69b129625009cac..04c874358bc2ec53e9803e0b719e9342f2fc7118 100644 (file)
@@ -462,15 +462,15 @@ IDWriteTextFormat.methods += [
     Method(FLOAT, "GetIncrementalTabStop", []),
     Method(HRESULT, "GetTrimming", [Out(Pointer(DWRITE_TRIMMING), "trimmingOptions"), Out(Pointer(Pointer(IDWriteInlineObject)), "trimmingSign")]),
     Method(HRESULT, "GetLineSpacing", [Out(Pointer(DWRITE_LINE_SPACING_METHOD), "lineSpacingMethod"), Out(Pointer(FLOAT), "lineSpacing"), Out(Pointer(FLOAT), "baseline")]),
-    #Method(HRESULT, "GetFontCollection", [Out(Pointer(Pointer(IDWriteFontCollection)), "fontCollection")]),
-    #Method(UINT32, "GetFontFamilyNameLength", []),
-    #Method(HRESULT, "GetFontFamilyName", [Out(Pointer(WCHAR), "fontFamilyName"), (UINT32, "nameSize")]),
-    #Method(DWRITE_FONT_WEIGHT, "GetFontWeight", []),
-    #Method(DWRITE_FONT_STYLE, "GetFontStyle", []),
-    #Method(DWRITE_FONT_STRETCH, "GetFontStretch", []),
-    #Method(FLOAT, "GetFontSize", []),
-    #Method(UINT32, "GetLocaleNameLength", []),
-    #Method(HRESULT, "GetLocaleName", [Out(Pointer(WCHAR), "localeName"), (UINT32, "nameSize")]),
+    Method(HRESULT, "GetFontCollection", [Out(Pointer(Pointer(IDWriteFontCollection)), "fontCollection")]),
+    Method(UINT32, "GetFontFamilyNameLength", []),
+    Method(HRESULT, "GetFontFamilyName", [Out(Pointer(WCHAR), "fontFamilyName"), (UINT32, "nameSize")]),
+    Method(DWRITE_FONT_WEIGHT, "GetFontWeight", []),
+    Method(DWRITE_FONT_STYLE, "GetFontStyle", []),
+    Method(DWRITE_FONT_STRETCH, "GetFontStretch", []),
+    Method(FLOAT, "GetFontSize", []),
+    Method(UINT32, "GetLocaleNameLength", []),
+    Method(HRESULT, "GetLocaleName", [Out(Pointer(WCHAR), "localeName"), (UINT32, "nameSize")]),
 ]
 
 IDWriteTypography.methods += [
@@ -767,6 +767,7 @@ IDWriteFactory.methods += [
 ]
 
 dwrite = API("dwrite")
+dwrite.add_interface(IDWriteFactory)
 dwrite.add_functions([
     StdFunction(HRESULT, "DWriteCreateFactory", [(DWRITE_FACTORY_TYPE, "factoryType"), (REFIID, "iid"), Out(Pointer(Pointer(IUnknown)), "factory")]),
 ])
index 573743c5b39883ef6b4f8570ce6450546fc2a24a..c4fc14af7ee2ffd7f3b68d535103605abbe8066c 100644 (file)
@@ -295,6 +295,14 @@ class Interface(Type):
         for method in self.methods:
             yield method
         raise StopIteration
+    
+    def itermethods2(self):
+        if self.base is not None:
+            for iface, method in self.base.itermethods2():
+                yield iface, method
+        for method in self.methods:
+            yield self, method
+        raise StopIteration
 
 
 class Method(Function):
index 59e1a831e8cb084fad5f3a794676b22f462a6ba4..53045f260f892c9d17e624bd4f23b9e73fbcd493 100644 (file)
--- a/trace.py
+++ b/trace.py
@@ -400,11 +400,11 @@ class Tracer:
         print '%s::~%s() {' % (interface_wrap_name(interface), interface_wrap_name(interface))
         print '}'
         print
-        for method in interface.itermethods():
-            self.trace_method(interface, method)
+        for base, method in interface.itermethods2():
+            self.trace_method(interface, base, method)
         print
 
-    def trace_method(self, interface, method):
+    def trace_method(self, interface, base, method):
         print method.prototype(interface_wrap_name(interface) + '::' + method.name) + ' {'
         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};' % (int(method.id), interface.name + '::' + method.name, len(method.args) + 1)
@@ -422,7 +422,7 @@ class Tracer:
             print '    %s __result;' % method.type
             result = '__result = '
         print '    Trace::localWriter.endEnter();'
-        print '    %sm_pInstance->%s(%s);' % (result, method.name, ', '.join([str(arg.name) for arg in method.args]))
+        print '    %sstatic_cast<%s *>(m_pInstance)->%s(%s);' % (result, base, method.name, ', '.join([str(arg.name) for arg in method.args]))
         print '    Trace::localWriter.beginLeave(__call);'
         for arg in method.args:
             if arg.output: