[PATCH 4/4] include: Use cpp_quote for ID3DInclude.

Stefan Dösinger stefan at codeweavers.com
Thu Mar 26 13:02:42 CDT 2015


The current code does not compile with midl because midl expects
interfaces to inherit from IUnknown and have a GUID. Microsoft's
d3dcommon.idl solves this problem in a similar way. If we don't care
about being able to compile our headers with midl please ignore this
patch.

Microsoft's header does not define ID3DInclude_* macros. The code in our
d3dcompiler implementation uses them though. I made sure both versions
(macros and inline functions) work.
---
 include/d3dcommon.idl | 48 ++++++++++++++++++++++++++++++++++--------------
 1 file changed, 34 insertions(+), 14 deletions(-)

diff --git a/include/d3dcommon.idl b/include/d3dcommon.idl
index f8fe203..b4ab6a2 100644
--- a/include/d3dcommon.idl
+++ b/include/d3dcommon.idl
@@ -52,21 +52,41 @@ typedef enum _D3D_INCLUDE_TYPE
     D3D_INCLUDE_FORCE_DWORD = 0x7fffffff
 } D3D_INCLUDE_TYPE;
 
-[
-    object,
-    local,
-]
-interface ID3DInclude
-{
-    HRESULT Open(D3D_INCLUDE_TYPE include_type,
-                 const char *filename,
-                 const void *parent_data,
-                 const void **data,
-                 UINT *bytes);
-    HRESULT Close(const void *data);
-}
+cpp_quote("#ifndef __ID3DInclude_INTERFACE_DEFINED__")
+cpp_quote("#define __ID3DInclude_INTERFACE_DEFINED__")
+
+/* ID3DInclude does not inherit from IUnknown and does not have a GUID. */
+cpp_quote("#undef INTERFACE")
+cpp_quote("#define INTERFACE ID3DInclude")
+cpp_quote("DECLARE_INTERFACE(ID3DInclude)")
+cpp_quote("{")
+cpp_quote("    STDMETHOD(Open)(THIS_ D3D_INCLUDE_TYPE include_type, const char *filename, const void *parent_data,")
+cpp_quote("        const void **data, UINT *bytes);")
+cpp_quote("    STDMETHOD(Close)(THIS_ const void *data);")
+cpp_quote("};")
+cpp_quote("#undef INTERFACE")
+
+cpp_quote("#ifdef COBJMACROS")
+cpp_quote("#ifndef WIDL_C_INLINE_WRAPPERS")
+cpp_quote("/*** ID3DInclude methods ***/")
+cpp_quote("#define ID3DInclude_Open(This,include_type,filename,parent_data,data,bytes)\\")
+cpp_quote("        (This)->lpVtbl->Open(This,include_type,filename,parent_data,data,bytes)")
+cpp_quote("#define ID3DInclude_Close(This,data) (This)->lpVtbl->Close(This,data)")
+cpp_quote("#else")
+cpp_quote("/*** ID3DInclude methods ***/")
+cpp_quote("static FORCEINLINE HRESULT ID3DInclude_Open(ID3DInclude* This,D3D_INCLUDE_TYPE include_type,")
+cpp_quote("        const char *filename,const void *parent_data,const void **data,UINT *bytes) {")
+cpp_quote("    return This->lpVtbl->Open(This,include_type,filename,parent_data,data,bytes);")
+cpp_quote("}")
+cpp_quote("static FORCEINLINE HRESULT ID3DInclude_Close(ID3DInclude* This,const void *data) {")
+cpp_quote("    return This->lpVtbl->Close(This,data);")
+cpp_quote("}")
+cpp_quote("#endif")
+cpp_quote("#endif")
+
+cpp_quote("#endif  /* __ID3DInclude_INTERFACE_DEFINED__ */")
 
-typedef ID3DInclude* LPD3DINCLUDE;
+cpp_quote("typedef ID3DInclude* LPD3DINCLUDE;")
 
 typedef enum D3D_DRIVER_TYPE
 {
-- 
2.3.4




More information about the wine-patches mailing list