From 825b5961b6bc2329f958de4610918fa3c1d30aa4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Tue, 11 Oct 2011 00:16:47 +0100 Subject: [PATCH] Trace dwrite.dll too. --- .gitignore | 3 ++- CMakeLists.txt | 16 +++++++++++- dwritetrace.py | 65 ++++++++++++++++++++++++++++++++++++++++++++++++ specs/dwrite.def | 4 +++ specs/dwrite.py | 19 +++++++------- specs/stdapi.py | 8 ++++++ trace.py | 8 +++--- 7 files changed, 108 insertions(+), 15 deletions(-) create mode 100644 dwritetrace.py create mode 100644 specs/dwrite.def diff --git a/.gitignore b/.gitignore index bd855db..455b6af 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index d520fb6..0cb0ace 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 index 0000000..94f1fbf --- /dev/null +++ b/dwritetrace.py @@ -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 ' + print + print '#include "compat.h"' + print + print '#define DWRITE_EXPORT WINAPI' + print + print '#include ' + print '#include ' + 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 index 0000000..4cc6785 --- /dev/null +++ b/specs/dwrite.def @@ -0,0 +1,4 @@ +LIBRARY "d2d1" + +EXPORTS + DWriteCreateFactory diff --git a/specs/dwrite.py b/specs/dwrite.py index 38fbe21..04c8743 100644 --- a/specs/dwrite.py +++ b/specs/dwrite.py @@ -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")]), ]) diff --git a/specs/stdapi.py b/specs/stdapi.py index 573743c..c4fc14a 100644 --- a/specs/stdapi.py +++ b/specs/stdapi.py @@ -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): diff --git a/trace.py b/trace.py index 59e1a83..53045f2 100644 --- 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: -- 2.43.0