diff --git a/.build/debug.yaml b/.build/debug.yaml deleted file mode 100644 index a9699e6..0000000 --- a/.build/debug.yaml +++ /dev/null @@ -1,54 +0,0 @@ -client: - name: basic - file-system: device-agnostic -tools: {} -targets: - "CWinRT-debug.dylib": [""] - "CWinRT-debug.module": [""] - "PackageStructure": [""] - "main": ["",""] - "test": ["",""] -default: "main" -nodes: - "C:\\dev\\browser\\swift-cwinrt\\Sources\\CWinRT/": - is-directory-structure: true - content-exclusion-patterns: [".git",".build"] -commands: - "": - tool: phony - inputs: ["C:\\dev\\browser\\swift-cwinrt\\.build\\x86_64-unknown-windows-msvc\\debug\\CWinRT.dll"] - outputs: [""] - - "": - tool: phony - inputs: ["C:\\dev\\browser\\swift-cwinrt\\.build\\x86_64-unknown-windows-msvc\\debug\\CWinRT.build\\shim.c.o"] - outputs: [""] - - "C.CWinRT-debug.dylib": - tool: shell - inputs: ["C:\\dev\\browser\\swift-cwinrt\\.build\\x86_64-unknown-windows-msvc\\debug\\CWinRT.build\\shim.c.o","C:\\dev\\browser\\swift-cwinrt\\.build\\x86_64-unknown-windows-msvc\\debug\\CWinRT.product\\Objects.LinkFileList"] - outputs: ["C:\\dev\\browser\\swift-cwinrt\\.build\\x86_64-unknown-windows-msvc\\debug\\CWinRT.dll"] - description: "Linking C:\\dev\\browser\\swift-cwinrt\\.build\\x86_64-unknown-windows-msvc\\debug\\CWinRT.dll" - args: ["C:\\Users\\skirb\\AppData\\Local\\Programs\\Swift\\Toolchains\\0.0.0+Asserts\\usr\\bin\\swiftc.exe","-L","C:\\dev\\browser\\swift-cwinrt\\.build\\x86_64-unknown-windows-msvc\\debug","-o","C:\\dev\\browser\\swift-cwinrt\\.build\\x86_64-unknown-windows-msvc\\debug\\CWinRT.dll","-module-name","CWinRT","-emit-library","@C:\\dev\\browser\\swift-cwinrt\\.build\\x86_64-unknown-windows-msvc\\debug\\CWinRT.product\\Objects.LinkFileList","-runtime-compatibility-version","none","-target","x86_64-unknown-windows-msvc","-nostartfiles","-sdk","C:\\Users\\skirb\\AppData\\Local\\Programs\\Swift\\Platforms\\0.0.0\\Windows.platform\\Developer\\SDKs\\Windows.sdk","-libc","MD","-I","C:\\Users\\skirb\\AppData\\Local\\Programs\\Swift\\Platforms\\0.0.0\\Windows.platform\\Developer\\Library\\XCTest-development\\usr\\lib\\swift\\windows","-I","C:\\Users\\skirb\\AppData\\Local\\Programs\\Swift\\Platforms\\0.0.0\\Windows.platform\\Developer\\Library\\XCTest-development\\usr\\lib\\swift\\windows\\x86_64","-L","C:\\Users\\skirb\\AppData\\Local\\Programs\\Swift\\Platforms\\0.0.0\\Windows.platform\\Developer\\Library\\XCTest-development\\usr\\lib\\swift\\windows\\x86_64","-use-ld=lld","-g","-use-ld=lld","-Xlinker","-debug:dwarf","-Xlinker","-debug:dwarf"] - - "C:\\dev\\browser\\swift-cwinrt\\.build\\x86_64-unknown-windows-msvc\\debug\\CWinRT.build\\shim.c.o": - tool: clang - inputs: ["C:\\dev\\browser\\swift-cwinrt\\Sources\\CWinRT\\shim.c"] - outputs: ["C:\\dev\\browser\\swift-cwinrt\\.build\\x86_64-unknown-windows-msvc\\debug\\CWinRT.build\\shim.c.o"] - description: "Compiling CWinRT shim.c" - args: ["C:\\Users\\skirb\\AppData\\Local\\Programs\\Swift\\Toolchains\\0.0.0+Asserts\\usr\\bin\\clang.exe","-target","x86_64-unknown-windows-msvc","-O0","-DSWIFT_PACKAGE=1","-DDEBUG=1","-fblocks","-I","C:\\dev\\browser\\swift-cwinrt\\Sources\\CWinRT\\include","-D_MT","-D_DLL","-Xclang","--dependent-lib=msvcrt","-gdwarf","-MD","-MT","dependencies","-MF","C:\\dev\\browser\\swift-cwinrt\\.build\\x86_64-unknown-windows-msvc\\debug\\CWinRT.build\\shim.c.d","-c","C:\\dev\\browser\\swift-cwinrt\\Sources\\CWinRT\\shim.c","-o","C:\\dev\\browser\\swift-cwinrt\\.build\\x86_64-unknown-windows-msvc\\debug\\CWinRT.build\\shim.c.o"] - deps: "C:\\dev\\browser\\swift-cwinrt\\.build\\x86_64-unknown-windows-msvc\\debug\\CWinRT.build\\shim.c.d" - - "C:\\dev\\browser\\swift-cwinrt\\.build\\x86_64-unknown-windows-msvc\\debug\\CWinRT.product\\Objects.LinkFileList": - tool: write-auxiliary-file - inputs: ["","C:\\dev\\browser\\swift-cwinrt\\.build\\x86_64-unknown-windows-msvc\\debug\\CWinRT.build\\shim.c.o"] - outputs: ["C:\\dev\\browser\\swift-cwinrt\\.build\\x86_64-unknown-windows-msvc\\debug\\CWinRT.product\\Objects.LinkFileList"] - description: "Write auxiliary file C:\\dev\\browser\\swift-cwinrt\\.build\\x86_64-unknown-windows-msvc\\debug\\CWinRT.product\\Objects.LinkFileList" - - "PackageStructure": - tool: package-structure-tool - inputs: ["C:\\dev\\browser\\swift-cwinrt\\Sources\\CWinRT/","C:\\dev\\browser\\swift-cwinrt\\Package.swift","C:\\dev\\browser\\swift-cwinrt\\Package.resolved"] - outputs: [""] - description: "Planning build" - allow-missing-inputs: true - diff --git a/.build/workspace-state.json b/.build/workspace-state.json deleted file mode 100644 index 71deae9..0000000 --- a/.build/workspace-state.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "object" : { - "artifacts" : [ - - ], - "dependencies" : [ - - ] - }, - "version" : 6 -} \ No newline at end of file diff --git a/.build/x86_64-unknown-windows-msvc/build.db b/.build/x86_64-unknown-windows-msvc/build.db deleted file mode 100644 index c09880b..0000000 Binary files a/.build/x86_64-unknown-windows-msvc/build.db and /dev/null differ diff --git a/.build/x86_64-unknown-windows-msvc/debug/description.json b/.build/x86_64-unknown-windows-msvc/debug/description.json deleted file mode 100644 index bc48968..0000000 --- a/.build/x86_64-unknown-windows-msvc/debug/description.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "builtTestProducts" : [ - - ], - "copyCommands" : { - - }, - "explicitTargetDependencyImportCheckingMode" : { - "none" : { - - } - }, - "generatedSourceTargetSet" : [ - - ], - "pluginDescriptions" : [ - - ], - "swiftCommands" : { - - }, - "swiftFrontendCommands" : { - - }, - "swiftTargetScanArgs" : { - - }, - "targetDependencyMap" : { - "CWinRT" : [ - - ] - }, - "testDiscoveryCommands" : { - - }, - "testEntryPointCommands" : { - - }, - "writeCommands" : { - "C:\\dev\\browser\\swift-cwinrt\\.build\\x86_64-unknown-windows-msvc\\debug\\CWinRT.product\\Objects.LinkFileList" : { - "alwaysOutOfDate" : false, - "inputs" : [ - { - "kind" : "virtual", - "name" : "" - }, - { - "kind" : "file", - "name" : "C:\\dev\\browser\\swift-cwinrt\\.build\\x86_64-unknown-windows-msvc\\debug\\CWinRT.build\\shim.c.o" - } - ], - "outputFilePath" : "C:\\dev\\browser\\swift-cwinrt\\.build\\x86_64-unknown-windows-msvc\\debug\\CWinRT.product\\Objects.LinkFileList" - } - } -} \ No newline at end of file diff --git a/.gitignore b/.gitignore index eb59970..4df8d0f 100644 --- a/.gitignore +++ b/.gitignore @@ -55,3 +55,6 @@ dkms.conf .generated swift-winrt.rsp Package.resolved + +# Swift +/.build \ No newline at end of file diff --git a/README.md b/README.md index 33f46c7..1125c34 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # swift-cwinrt -> [!WARNING] -> This project contains an outdated snapshot of a subset of WinRT projections generated with [swift-winrt](https://github.com/thebrowsercompany/swift-winrt), provided for illustration purposes. To use WinRT APIs in your Swift project, we recommend using [swift-winrt](https://github.com/thebrowsercompany/swift-winrt) directly to generate your own projections. +This is based on [thebrowsercompany/swift-cwinrt](https://github.com/thebrowsercompany/swift-cwinrt). C API definition used by Swift Language bindings. diff --git a/Sources/CWinRT/include/CppInteropWorkaround.h b/Sources/CWinRT/include/CppInteropWorkaround.h index ad751d6..b1559fb 100644 --- a/Sources/CWinRT/include/CppInteropWorkaround.h +++ b/Sources/CWinRT/include/CppInteropWorkaround.h @@ -1,237 +1,237 @@ -// Works around limitations of Swift's C++ Interop when exposing the Windows.h GUID type to Swift. -#pragma once - -typedef struct GUID_Workaround { - unsigned long Data1; - unsigned short Data2; - unsigned short Data3; - unsigned char Data4[8]; -} GUID_Workaround; - -typedef GUID_Workaround CLSID_Workaround; -typedef GUID_Workaround IID_Workaround; -typedef GUID_Workaround UUID_Workaround; - -// Functions depending on workaround types -typedef struct IUnknown_Workaround IUnknown_Workaround; -typedef struct IInspectable_Workaround IInspectable_Workaround; -typedef struct IMarshal_Workaround IMarshal_Workaround; - -#include -inline HRESULT CoCreateInstance_Workaround( - const CLSID_Workaround* rclsid, - LPUNKNOWN pUnkOuter, - DWORD dwClsContext, - const IID_Workaround* riid, - LPVOID* ppv) { -#ifdef __cplusplus - return CoCreateInstance(*(CLSID*)rclsid, pUnkOuter, dwClsContext, *(IID*)riid, ppv); -#else - return CoCreateInstance((REFCLSID)rclsid, pUnkOuter, dwClsContext, (REFIID)riid, ppv); -#endif -} - -inline HRESULT CoCreateFreeThreadedMarshaler_Workaround(IUnknown_Workaround* pUnkOuter, IUnknown_Workaround** ppunkMarshal) { - return CoCreateFreeThreadedMarshaler((IUnknown*)pUnkOuter, (IUnknown**)ppunkMarshal); -} - -inline int StringFromGUID2_Workaround(const GUID_Workaround* rguid, LPOLESTR lpsz, int cchMax) { -#ifdef __cplusplus - return StringFromGUID2(*(GUID*)rguid, lpsz, cchMax); -#else - return StringFromGUID2((REFGUID)rguid, lpsz, cchMax); -#endif -} - -#include -inline RPC_STATUS UuidFromStringA_Workaround(RPC_CSTR StringUuid, UUID_Workaround* Uuid) { - return UuidFromStringA(StringUuid, (UUID*)Uuid); -} - -#include -inline HRESULT RoActivateInstance_Workaround( - HSTRING activatableClassId, - IInspectable_Workaround** instance) { - return RoActivateInstance(activatableClassId, (IInspectable**)instance); -} - -inline HRESULT RoGetActivationFactory_Workaround( - HSTRING activatableClassId, - const IID_Workaround* iid, - void** factory) { -#ifdef __cplusplus - return RoGetActivationFactory(activatableClassId, *(IID*)iid, factory); -#else - return RoGetActivationFactory(activatableClassId, (REFIID)iid, factory); -#endif -} - -//------------------------------------------------------------------------------------------------- -// Begin the great lie -// Everything below will unknowingly use Xxx_Workaround. -// For example, uses of GUID will be redirected to GUID_Workaround. -//------------------------------------------------------------------------------------------------- -// Preemptively include headers before swapping out the IID type -// This no-op the #includes in generated code, so that it instead relies of our workaround types -#include -#include -#include - -#define GUID GUID_Workaround -#undef REFGUID // REFGUID is a #define, not a typedef -#define REFGUID const GUID* __MIDL_CONST -#define IID IID_Workaround -#undef REFIID // REFIID is a #define, not a typedef -#define REFIID const IID* __MIDL_CONST -#define CLSID GUID - -#define IUnknown IUnknown_Workaround -#define IUnknownVtbl IUnknownVtbl_Workaround -#define IInspectable IInspectable_Workaround -#define IInspectableVtbl IInspectableVtbl_Workaround -#define IMarshal IMarshal_Workaround -#define IMarshalVtbl IMarshalVtbl_Workaround - -// iunknown.h -typedef struct IUnknownVtbl -{ - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - __RPC__in IUnknown * This, - /* [in] */ __RPC__in REFIID riid, - /* [annotation][iid_is][out] */ - _COM_Outptr_ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - __RPC__in IUnknown * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - __RPC__in IUnknown * This); -} IUnknownVtbl; - -interface IUnknown -{ - CONST_VTBL struct IUnknownVtbl *lpVtbl; -}; - -// IInspectable.h -typedef struct IInspectableVtbl -{ - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - __RPC__in IInspectable * This, - /* [in] */ __RPC__in REFIID riid, - /* [annotation][iid_is][out] */ - _COM_Outptr_ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - __RPC__in IInspectable * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - __RPC__in IInspectable * This); - - HRESULT ( STDMETHODCALLTYPE *GetIids )( - __RPC__in IInspectable * This, - /* [out] */ __RPC__out ULONG *iidCount, - /* [size_is][size_is][out] */ __RPC__deref_out_ecount_full_opt(*iidCount) IID **iids); - - HRESULT ( STDMETHODCALLTYPE *GetRuntimeClassName )( - __RPC__in IInspectable * This, - /* [out] */ __RPC__deref_out_opt HSTRING *className); - - HRESULT ( STDMETHODCALLTYPE *GetTrustLevel )( - __RPC__in IInspectable * This, - /* [out] */ __RPC__out TrustLevel *trustLevel); - - END_INTERFACE -} IInspectableVtbl; - -interface IInspectable -{ - CONST_VTBL struct IInspectableVtbl *lpVtbl; -}; - -typedef struct IMarshalVtbl -{ - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IMarshal * This, - /* [in] */ REFIID riid, - /* [annotation][iid_is][out] */ - _COM_Outptr_ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IMarshal * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IMarshal * This); - - HRESULT ( STDMETHODCALLTYPE *GetUnmarshalClass )( - IMarshal * This, - /* [annotation][in] */ - _In_ REFIID riid, - /* [annotation][unique][in] */ - _In_opt_ void *pv, - /* [annotation][in] */ - _In_ DWORD dwDestContext, - /* [annotation][unique][in] */ - _Reserved_ void *pvDestContext, - /* [annotation][in] */ - _In_ DWORD mshlflags, - /* [annotation][out] */ - _Out_ CLSID *pCid); - - HRESULT ( STDMETHODCALLTYPE *GetMarshalSizeMax )( - IMarshal * This, - /* [annotation][in] */ - _In_ REFIID riid, - /* [annotation][unique][in] */ - _In_opt_ void *pv, - /* [annotation][in] */ - _In_ DWORD dwDestContext, - /* [annotation][unique][in] */ - _Reserved_ void *pvDestContext, - /* [annotation][in] */ - _In_ DWORD mshlflags, - /* [annotation][out] */ - _Out_ DWORD *pSize); - - HRESULT ( STDMETHODCALLTYPE *MarshalInterface )( - IMarshal * This, - /* [annotation][unique][in] */ - _In_ IStream *pStm, - /* [annotation][in] */ - _In_ REFIID riid, - /* [annotation][unique][in] */ - _In_opt_ void *pv, - /* [annotation][in] */ - _In_ DWORD dwDestContext, - /* [annotation][unique][in] */ - _Reserved_ void *pvDestContext, - /* [annotation][in] */ - _In_ DWORD mshlflags); - - HRESULT ( STDMETHODCALLTYPE *UnmarshalInterface )( - IMarshal * This, - /* [annotation][unique][in] */ - _In_ IStream *pStm, - /* [annotation][in] */ - _In_ REFIID riid, - /* [annotation][out] */ - _Outptr_ void **ppv); - - HRESULT ( STDMETHODCALLTYPE *ReleaseMarshalData )( - IMarshal * This, - /* [annotation][unique][in] */ - _In_ IStream *pStm); - - HRESULT ( STDMETHODCALLTYPE *DisconnectObject )( - IMarshal * This, - /* [annotation][in] */ - _In_ DWORD dwReserved); - -} IMarshalVtbl; - -interface IMarshal -{ - CONST_VTBL struct IMarshalVtbl *lpVtbl; +// Works around limitations of Swift's C++ Interop when exposing the Windows.h GUID type to Swift. +#pragma once + +typedef struct GUID_Workaround { + unsigned long Data1; + unsigned short Data2; + unsigned short Data3; + unsigned char Data4[8]; +} GUID_Workaround; + +typedef GUID_Workaround CLSID_Workaround; +typedef GUID_Workaround IID_Workaround; +typedef GUID_Workaround UUID_Workaround; + +// Functions depending on workaround types +typedef struct IUnknown_Workaround IUnknown_Workaround; +typedef struct IInspectable_Workaround IInspectable_Workaround; +typedef struct IMarshal_Workaround IMarshal_Workaround; + +#include +inline HRESULT CoCreateInstance_Workaround( + const CLSID_Workaround* rclsid, + LPUNKNOWN pUnkOuter, + DWORD dwClsContext, + const IID_Workaround* riid, + LPVOID* ppv) { +#ifdef __cplusplus + return CoCreateInstance(*(CLSID*)rclsid, pUnkOuter, dwClsContext, *(IID*)riid, ppv); +#else + return CoCreateInstance((REFCLSID)rclsid, pUnkOuter, dwClsContext, (REFIID)riid, ppv); +#endif +} + +inline HRESULT CoCreateFreeThreadedMarshaler_Workaround(IUnknown_Workaround* pUnkOuter, IUnknown_Workaround** ppunkMarshal) { + return CoCreateFreeThreadedMarshaler((IUnknown*)pUnkOuter, (IUnknown**)ppunkMarshal); +} + +inline int StringFromGUID2_Workaround(const GUID_Workaround* rguid, LPOLESTR lpsz, int cchMax) { +#ifdef __cplusplus + return StringFromGUID2(*(GUID*)rguid, lpsz, cchMax); +#else + return StringFromGUID2((REFGUID)rguid, lpsz, cchMax); +#endif +} + +#include +inline RPC_STATUS UuidFromStringA_Workaround(RPC_CSTR StringUuid, UUID_Workaround* Uuid) { + return UuidFromStringA(StringUuid, (UUID*)Uuid); +} + +#include +inline HRESULT RoActivateInstance_Workaround( + HSTRING activatableClassId, + IInspectable_Workaround** instance) { + return RoActivateInstance(activatableClassId, (IInspectable**)instance); +} + +inline HRESULT RoGetActivationFactory_Workaround( + HSTRING activatableClassId, + const IID_Workaround* iid, + void** factory) { +#ifdef __cplusplus + return RoGetActivationFactory(activatableClassId, *(IID*)iid, factory); +#else + return RoGetActivationFactory(activatableClassId, (REFIID)iid, factory); +#endif +} + +//------------------------------------------------------------------------------------------------- +// Begin the great lie +// Everything below will unknowingly use Xxx_Workaround. +// For example, uses of GUID will be redirected to GUID_Workaround. +//------------------------------------------------------------------------------------------------- +// Preemptively include headers before swapping out the IID type +// This no-op the #includes in generated code, so that it instead relies of our workaround types +#include +#include +#include + +#define GUID GUID_Workaround +#undef REFGUID // REFGUID is a #define, not a typedef +#define REFGUID const GUID* __MIDL_CONST +#define IID IID_Workaround +#undef REFIID // REFIID is a #define, not a typedef +#define REFIID const IID* __MIDL_CONST +#define CLSID GUID + +#define IUnknown IUnknown_Workaround +#define IUnknownVtbl IUnknownVtbl_Workaround +#define IInspectable IInspectable_Workaround +#define IInspectableVtbl IInspectableVtbl_Workaround +#define IMarshal IMarshal_Workaround +#define IMarshalVtbl IMarshalVtbl_Workaround + +// iunknown.h +typedef struct IUnknownVtbl +{ + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + __RPC__in IUnknown * This, + /* [in] */ __RPC__in REFIID riid, + /* [annotation][iid_is][out] */ + _COM_Outptr_ void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + __RPC__in IUnknown * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + __RPC__in IUnknown * This); +} IUnknownVtbl; + +interface IUnknown +{ + CONST_VTBL struct IUnknownVtbl *lpVtbl; +}; + +// IInspectable.h +typedef struct IInspectableVtbl +{ + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + __RPC__in IInspectable * This, + /* [in] */ __RPC__in REFIID riid, + /* [annotation][iid_is][out] */ + _COM_Outptr_ void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + __RPC__in IInspectable * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + __RPC__in IInspectable * This); + + HRESULT ( STDMETHODCALLTYPE *GetIids )( + __RPC__in IInspectable * This, + /* [out] */ __RPC__out ULONG *iidCount, + /* [size_is][size_is][out] */ __RPC__deref_out_ecount_full_opt(*iidCount) IID **iids); + + HRESULT ( STDMETHODCALLTYPE *GetRuntimeClassName )( + __RPC__in IInspectable * This, + /* [out] */ __RPC__deref_out_opt HSTRING *className); + + HRESULT ( STDMETHODCALLTYPE *GetTrustLevel )( + __RPC__in IInspectable * This, + /* [out] */ __RPC__out TrustLevel *trustLevel); + + END_INTERFACE +} IInspectableVtbl; + +interface IInspectable +{ + CONST_VTBL struct IInspectableVtbl *lpVtbl; +}; + +typedef struct IMarshalVtbl +{ + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IMarshal * This, + /* [in] */ REFIID riid, + /* [annotation][iid_is][out] */ + _COM_Outptr_ void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + IMarshal * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + IMarshal * This); + + HRESULT ( STDMETHODCALLTYPE *GetUnmarshalClass )( + IMarshal * This, + /* [annotation][in] */ + _In_ REFIID riid, + /* [annotation][unique][in] */ + _In_opt_ void *pv, + /* [annotation][in] */ + _In_ DWORD dwDestContext, + /* [annotation][unique][in] */ + _Reserved_ void *pvDestContext, + /* [annotation][in] */ + _In_ DWORD mshlflags, + /* [annotation][out] */ + _Out_ CLSID *pCid); + + HRESULT ( STDMETHODCALLTYPE *GetMarshalSizeMax )( + IMarshal * This, + /* [annotation][in] */ + _In_ REFIID riid, + /* [annotation][unique][in] */ + _In_opt_ void *pv, + /* [annotation][in] */ + _In_ DWORD dwDestContext, + /* [annotation][unique][in] */ + _Reserved_ void *pvDestContext, + /* [annotation][in] */ + _In_ DWORD mshlflags, + /* [annotation][out] */ + _Out_ DWORD *pSize); + + HRESULT ( STDMETHODCALLTYPE *MarshalInterface )( + IMarshal * This, + /* [annotation][unique][in] */ + _In_ IStream *pStm, + /* [annotation][in] */ + _In_ REFIID riid, + /* [annotation][unique][in] */ + _In_opt_ void *pv, + /* [annotation][in] */ + _In_ DWORD dwDestContext, + /* [annotation][unique][in] */ + _Reserved_ void *pvDestContext, + /* [annotation][in] */ + _In_ DWORD mshlflags); + + HRESULT ( STDMETHODCALLTYPE *UnmarshalInterface )( + IMarshal * This, + /* [annotation][unique][in] */ + _In_ IStream *pStm, + /* [annotation][in] */ + _In_ REFIID riid, + /* [annotation][out] */ + _Outptr_ void **ppv); + + HRESULT ( STDMETHODCALLTYPE *ReleaseMarshalData )( + IMarshal * This, + /* [annotation][unique][in] */ + _In_ IStream *pStm); + + HRESULT ( STDMETHODCALLTYPE *DisconnectObject )( + IMarshal * This, + /* [annotation][in] */ + _In_ DWORD dwReserved); + +} IMarshalVtbl; + +interface IMarshal +{ + CONST_VTBL struct IMarshalVtbl *lpVtbl; }; \ No newline at end of file diff --git a/Sources/CWinRT/include/IVectorChangedEventArgs.h b/Sources/CWinRT/include/IVectorChangedEventArgs.h index 26c8b2e..13cc0c5 100644 --- a/Sources/CWinRT/include/IVectorChangedEventArgs.h +++ b/Sources/CWinRT/include/IVectorChangedEventArgs.h @@ -1,74 +1,74 @@ -// The real ivectorchangedeventargs.h will provide different definitions in C vs C++ compilation mode. -// Override it with ours so we ensure we get the C definitions. -#pragma once - -#include -#include - -#if !defined(____x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs_INTERFACE_DEFINED__) -#define ____x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs_INTERFACE_DEFINED__ -typedef interface __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs; - -typedef /* [v1_enum] */ -enum __x_ABI_CWindows_CFoundation_CCollections_CCollectionChange -{ - CollectionChange_Reset, - CollectionChange_ItemInserted, - CollectionChange_ItemRemoved, - CollectionChange_ItemChanged, -} __x_ABI_CWindows_CFoundation_CCollections_CCollectionChange; - -/* [contract, version, pointer_default(unique), uuid("575933df-34fe-4480-af15-07691f3d5d9b"), object] */ -typedef struct __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgsVtbl -{ - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface)( - __RPC__in __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs * This, - /* [in] */ __RPC__in REFIID riid, - /* [annotation][iid_is][out] */ - _COM_Outptr_ void **ppvObject - ); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - __RPC__in __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs * This - ); - - ULONG ( STDMETHODCALLTYPE *Release )( - __RPC__in __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs * This - ); - - HRESULT ( STDMETHODCALLTYPE *GetIids )( - __RPC__in __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs * This, - /* [out] */ __RPC__out ULONG *iidCount, - /* [size_is][size_is][out] */ __RPC__deref_out_ecount_full_opt(*iidCount) IID **iids - ); - - HRESULT ( STDMETHODCALLTYPE *GetRuntimeClassName )( - __RPC__in __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs * This, - /* [out] */ __RPC__deref_out_opt HSTRING *className - ); - - HRESULT ( STDMETHODCALLTYPE *GetTrustLevel )( - __RPC__in __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs * This, - /* [OUT ] */ __RPC__out TrustLevel *trustLevel - ); - - /* [propget] */HRESULT ( STDMETHODCALLTYPE *get_CollectionChange )( - __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs * This, - /* [retval, out] */__RPC__out __x_ABI_CWindows_CFoundation_CCollections_CCollectionChange * value - ); - - /* [propget] */HRESULT ( STDMETHODCALLTYPE *get_Index )( - __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs * This, - /* [retval, out] */__RPC__out unsigned int * value - ); - - END_INTERFACE -} __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgsVtbl; - -interface __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs -{ - CONST_VTBL struct __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgsVtbl *lpVtbl; -}; +// The real ivectorchangedeventargs.h will provide different definitions in C vs C++ compilation mode. +// Override it with ours so we ensure we get the C definitions. +#pragma once + +#include +#include + +#if !defined(____x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs_INTERFACE_DEFINED__) +#define ____x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs_INTERFACE_DEFINED__ +typedef interface __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs; + +typedef /* [v1_enum] */ +enum __x_ABI_CWindows_CFoundation_CCollections_CCollectionChange +{ + CollectionChange_Reset, + CollectionChange_ItemInserted, + CollectionChange_ItemRemoved, + CollectionChange_ItemChanged, +} __x_ABI_CWindows_CFoundation_CCollections_CCollectionChange; + +/* [contract, version, pointer_default(unique), uuid("575933df-34fe-4480-af15-07691f3d5d9b"), object] */ +typedef struct __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgsVtbl +{ + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface)( + __RPC__in __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs * This, + /* [in] */ __RPC__in REFIID riid, + /* [annotation][iid_is][out] */ + _COM_Outptr_ void **ppvObject + ); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + __RPC__in __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs * This + ); + + ULONG ( STDMETHODCALLTYPE *Release )( + __RPC__in __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs * This + ); + + HRESULT ( STDMETHODCALLTYPE *GetIids )( + __RPC__in __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs * This, + /* [out] */ __RPC__out ULONG *iidCount, + /* [size_is][size_is][out] */ __RPC__deref_out_ecount_full_opt(*iidCount) IID **iids + ); + + HRESULT ( STDMETHODCALLTYPE *GetRuntimeClassName )( + __RPC__in __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs * This, + /* [out] */ __RPC__deref_out_opt HSTRING *className + ); + + HRESULT ( STDMETHODCALLTYPE *GetTrustLevel )( + __RPC__in __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs * This, + /* [OUT ] */ __RPC__out TrustLevel *trustLevel + ); + + /* [propget] */HRESULT ( STDMETHODCALLTYPE *get_CollectionChange )( + __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs * This, + /* [retval, out] */__RPC__out __x_ABI_CWindows_CFoundation_CCollections_CCollectionChange * value + ); + + /* [propget] */HRESULT ( STDMETHODCALLTYPE *get_Index )( + __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs * This, + /* [retval, out] */__RPC__out unsigned int * value + ); + + END_INTERFACE +} __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgsVtbl; + +interface __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgs +{ + CONST_VTBL struct __x_ABI_CWindows_CFoundation_CCollections_CIVectorChangedEventArgsVtbl *lpVtbl; +}; #endif \ No newline at end of file diff --git a/Sources/CWinRT/include/MemoryBuffer.h b/Sources/CWinRT/include/MemoryBuffer.h index cdefd86..7d2c963 100644 --- a/Sources/CWinRT/include/MemoryBuffer.h +++ b/Sources/CWinRT/include/MemoryBuffer.h @@ -1,30 +1,30 @@ -// The real MemoryBuffer.h doesn't provide C definitions, so we need to provide those here -// No pragma once, we might include this twice (once for the regular definitions, once for the workaround) - -#include - -#ifndef _IMEMORYBUFFERBYTEACCESS_DEFINED -#define _IMEMORYBUFFERBYTEACCESS_DEFINED -typedef interface IMemoryBufferByteAccess IMemoryBufferByteAccess; -#endif - -typedef struct IMemoryBufferByteAccessVtbl -{ - BEGIN_INTERFACE - - HRESULT (STDMETHODCALLTYPE* QueryInterface)(__RPC__in IMemoryBufferByteAccess* This, - REFIID riid, - _COM_Outptr_ void** ppvObject); - ULONG (STDMETHODCALLTYPE* AddRef)(__RPC__in IMemoryBufferByteAccess* This); - ULONG (STDMETHODCALLTYPE* Release)(__RPC__in IMemoryBufferByteAccess* This); - HRESULT (STDMETHODCALLTYPE* GetBuffer)(__RPC__in IMemoryBufferByteAccess* This, - BYTE** value, - _Out_ UINT32* capacity); - - END_INTERFACE -} IMemoryBufferByteAccessVtbl; - -interface IMemoryBufferByteAccess -{ - CONST_VTBL struct IMemoryBufferByteAccessVtbl* lpVtbl; +// The real MemoryBuffer.h doesn't provide C definitions, so we need to provide those here +// No pragma once, we might include this twice (once for the regular definitions, once for the workaround) + +#include + +#ifndef _IMEMORYBUFFERBYTEACCESS_DEFINED +#define _IMEMORYBUFFERBYTEACCESS_DEFINED +typedef interface IMemoryBufferByteAccess IMemoryBufferByteAccess; +#endif + +typedef struct IMemoryBufferByteAccessVtbl +{ + BEGIN_INTERFACE + + HRESULT (STDMETHODCALLTYPE* QueryInterface)(__RPC__in IMemoryBufferByteAccess* This, + REFIID riid, + _COM_Outptr_ void** ppvObject); + ULONG (STDMETHODCALLTYPE* AddRef)(__RPC__in IMemoryBufferByteAccess* This); + ULONG (STDMETHODCALLTYPE* Release)(__RPC__in IMemoryBufferByteAccess* This); + HRESULT (STDMETHODCALLTYPE* GetBuffer)(__RPC__in IMemoryBufferByteAccess* This, + BYTE** value, + _Out_ UINT32* capacity); + + END_INTERFACE +} IMemoryBufferByteAccessVtbl; + +interface IMemoryBufferByteAccess +{ + CONST_VTBL struct IMemoryBufferByteAccessVtbl* lpVtbl; }; \ No newline at end of file diff --git a/Sources/CWinRT/include/RestrictedErrorInfo.h b/Sources/CWinRT/include/RestrictedErrorInfo.h index 58236c3..a075838 100644 --- a/Sources/CWinRT/include/RestrictedErrorInfo.h +++ b/Sources/CWinRT/include/RestrictedErrorInfo.h @@ -1,57 +1,57 @@ -// The real restrictederrorinfo.h will provide different definitions in C vs C++ compilation mode. -// Override it with ours so we ensure we get the C definitions. - -// No pragma once, we might include this twice (once for the regular definitions, once for the workaround) - -#include - -#ifndef __IRestrictedErrorInfo_FWD_DEFINED__ -#define __IRestrictedErrorInfo_FWD_DEFINED__ -typedef interface IRestrictedErrorInfo IRestrictedErrorInfo; -#endif - -#ifndef __IRestrictedErrorInfo_INTERFACE_DEFINED__ -#define __IRestrictedErrorInfo_INTERFACE_DEFINED__ -EXTERN_C const IID IID_IRestrictedErrorInfo; - -typedef struct IRestrictedErrorInfoVtbl -{ - BEGIN_INTERFACE - - DECLSPEC_XFGVIRT(IUnknown, QueryInterface) - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - __RPC__in IRestrictedErrorInfo * This, - /* [in] */ __RPC__in REFIID riid, - /* [annotation][iid_is][out] */ - _COM_Outptr_ void **ppvObject); - - DECLSPEC_XFGVIRT(IUnknown, AddRef) - ULONG ( STDMETHODCALLTYPE *AddRef )( - __RPC__in IRestrictedErrorInfo * This); - - DECLSPEC_XFGVIRT(IUnknown, Release) - ULONG ( STDMETHODCALLTYPE *Release )( - __RPC__in IRestrictedErrorInfo * This); - - DECLSPEC_XFGVIRT(IRestrictedErrorInfo, GetErrorDetails) - HRESULT ( STDMETHODCALLTYPE *GetErrorDetails )( - __RPC__in IRestrictedErrorInfo * This, - /* [out] */ __RPC__deref_out_opt BSTR *description, - /* [out] */ __RPC__out HRESULT *error, - /* [out] */ __RPC__deref_out_opt BSTR *restrictedDescription, - /* [out] */ __RPC__deref_out_opt BSTR *capabilitySid); - - DECLSPEC_XFGVIRT(IRestrictedErrorInfo, GetReference) - HRESULT ( STDMETHODCALLTYPE *GetReference )( - __RPC__in IRestrictedErrorInfo * This, - /* [out] */ __RPC__deref_out_opt BSTR *reference); - - END_INTERFACE -} IRestrictedErrorInfoVtbl; - -interface IRestrictedErrorInfo -{ - CONST_VTBL struct IRestrictedErrorInfoVtbl *lpVtbl; -}; - -#endif +// The real restrictederrorinfo.h will provide different definitions in C vs C++ compilation mode. +// Override it with ours so we ensure we get the C definitions. + +// No pragma once, we might include this twice (once for the regular definitions, once for the workaround) + +#include + +#ifndef __IRestrictedErrorInfo_FWD_DEFINED__ +#define __IRestrictedErrorInfo_FWD_DEFINED__ +typedef interface IRestrictedErrorInfo IRestrictedErrorInfo; +#endif + +#ifndef __IRestrictedErrorInfo_INTERFACE_DEFINED__ +#define __IRestrictedErrorInfo_INTERFACE_DEFINED__ +EXTERN_C const IID IID_IRestrictedErrorInfo; + +typedef struct IRestrictedErrorInfoVtbl +{ + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + __RPC__in IRestrictedErrorInfo * This, + /* [in] */ __RPC__in REFIID riid, + /* [annotation][iid_is][out] */ + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + __RPC__in IRestrictedErrorInfo * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + __RPC__in IRestrictedErrorInfo * This); + + DECLSPEC_XFGVIRT(IRestrictedErrorInfo, GetErrorDetails) + HRESULT ( STDMETHODCALLTYPE *GetErrorDetails )( + __RPC__in IRestrictedErrorInfo * This, + /* [out] */ __RPC__deref_out_opt BSTR *description, + /* [out] */ __RPC__out HRESULT *error, + /* [out] */ __RPC__deref_out_opt BSTR *restrictedDescription, + /* [out] */ __RPC__deref_out_opt BSTR *capabilitySid); + + DECLSPEC_XFGVIRT(IRestrictedErrorInfo, GetReference) + HRESULT ( STDMETHODCALLTYPE *GetReference )( + __RPC__in IRestrictedErrorInfo * This, + /* [out] */ __RPC__deref_out_opt BSTR *reference); + + END_INTERFACE +} IRestrictedErrorInfoVtbl; + +interface IRestrictedErrorInfo +{ + CONST_VTBL struct IRestrictedErrorInfoVtbl *lpVtbl; +}; + +#endif diff --git a/Sources/CWinRT/include/robuffer.h b/Sources/CWinRT/include/robuffer.h index ca62b07..8ae005f 100644 --- a/Sources/CWinRT/include/robuffer.h +++ b/Sources/CWinRT/include/robuffer.h @@ -1,32 +1,32 @@ -// The real robuffer.h doesn't provide C definitions, so we need to provide those here - -// No pragma once, we might include this twice (once for the regular definitions, once for the workaround) - -#include -#include -#include - -#ifndef _IBufferByteAccess_DEFINED -#define _IBufferByteAccess_DEFINED -typedef interface C_IBufferByteAccess C_IBufferByteAccess; -#endif /* _IBufferByteAccess_DEFINED */ - -typedef struct C_IBufferByteAccessVtbl -{ - BEGIN_INTERFACE - - HRESULT (STDMETHODCALLTYPE* QueryInterface)(__RPC__in C_IBufferByteAccess* This, - REFIID riid, - _COM_Outptr_ void** ppvObject); - ULONG (STDMETHODCALLTYPE* AddRef)(__RPC__in C_IBufferByteAccess* This); - ULONG (STDMETHODCALLTYPE* Release)(__RPC__in C_IBufferByteAccess* This); - HRESULT (STDMETHODCALLTYPE* Buffer)(__RPC__in C_IBufferByteAccess* This, - BYTE** value); - - END_INTERFACE -} C_IBufferByteAccessVtbl; - -interface C_IBufferByteAccess -{ - CONST_VTBL struct C_IBufferByteAccessVtbl* lpVtbl; -}; +// The real robuffer.h doesn't provide C definitions, so we need to provide those here + +// No pragma once, we might include this twice (once for the regular definitions, once for the workaround) + +#include +#include +#include + +#ifndef _IBufferByteAccess_DEFINED +#define _IBufferByteAccess_DEFINED +typedef interface C_IBufferByteAccess C_IBufferByteAccess; +#endif /* _IBufferByteAccess_DEFINED */ + +typedef struct C_IBufferByteAccessVtbl +{ + BEGIN_INTERFACE + + HRESULT (STDMETHODCALLTYPE* QueryInterface)(__RPC__in C_IBufferByteAccess* This, + REFIID riid, + _COM_Outptr_ void** ppvObject); + ULONG (STDMETHODCALLTYPE* AddRef)(__RPC__in C_IBufferByteAccess* This); + ULONG (STDMETHODCALLTYPE* Release)(__RPC__in C_IBufferByteAccess* This); + HRESULT (STDMETHODCALLTYPE* Buffer)(__RPC__in C_IBufferByteAccess* This, + BYTE** value); + + END_INTERFACE +} C_IBufferByteAccessVtbl; + +interface C_IBufferByteAccess +{ + CONST_VTBL struct C_IBufferByteAccessVtbl* lpVtbl; +}; diff --git a/Sources/CWinRT/shim.c b/Sources/CWinRT/shim.c index fc6430c..e84438d 100644 --- a/Sources/CWinRT/shim.c +++ b/Sources/CWinRT/shim.c @@ -1,11 +1,11 @@ -// ISO C requires a translation unit to contain at least one declaration. -extern unsigned _; - -// To force the linker to produce a .lib file, currently required for dynamic -// linking, at least the way our CMakeLists.txt are currently structured, we -// also need to export a symbol. -#if defined(CWinRT_EXPORTS) - int __declspec(dllexport) force_lib_generation(void) { - return 1; -} -#endif +// ISO C requires a translation unit to contain at least one declaration. +extern unsigned _; + +// To force the linker to produce a .lib file, currently required for dynamic +// linking, at least the way our CMakeLists.txt are currently structured, we +// also need to export a symbol. +#if defined(CWinRT_EXPORTS) + int __declspec(dllexport) force_lib_generation(void) { + return 1; +} +#endif