diff --git a/Include/activation.h b/Include/activation.h new file mode 100644 index 0000000..fa0a130 --- /dev/null +++ b/Include/activation.h @@ -0,0 +1,151 @@ +/*** Autogenerated by WIDL 7.7 from include/activation.idl - Do not edit ***/ + +#ifdef _WIN32 +#ifndef __REQUIRED_RPCNDR_H_VERSION__ +#define __REQUIRED_RPCNDR_H_VERSION__ 475 +#endif +#include +#include +#endif + +#ifndef COM_NO_WINDOWS_H +#include +#include +#endif + +#ifndef __activation_h__ +#define __activation_h__ + +/* Forward declarations */ + +#ifndef __IActivationFactory_FWD_DEFINED__ +#define __IActivationFactory_FWD_DEFINED__ +typedef interface IActivationFactory IActivationFactory; +#ifdef __cplusplus +interface IActivationFactory; +#endif /* __cplusplus */ +#endif + +/* Headers for imported files */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/***************************************************************************** + * IActivationFactory interface + */ +#ifndef __IActivationFactory_INTERFACE_DEFINED__ +#define __IActivationFactory_INTERFACE_DEFINED__ + +DEFINE_GUID(IID_IActivationFactory, 0x00000035, 0x0000, 0x0000, 0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46); +#if defined(__cplusplus) && !defined(CINTERFACE) +MIDL_INTERFACE("00000035-0000-0000-c000-000000000046") +IActivationFactory : public IInspectable +{ + virtual HRESULT STDMETHODCALLTYPE ActivateInstance( + IInspectable **instance) = 0; + +}; +#ifdef __CRT_UUID_DECL +__CRT_UUID_DECL(IActivationFactory, 0x00000035, 0x0000, 0x0000, 0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46) +#endif +#else +typedef struct IActivationFactoryVtbl { + BEGIN_INTERFACE + + /*** IUnknown methods ***/ + HRESULT (STDMETHODCALLTYPE *QueryInterface)( + IActivationFactory *This, + REFIID riid, + void **ppvObject); + + ULONG (STDMETHODCALLTYPE *AddRef)( + IActivationFactory *This); + + ULONG (STDMETHODCALLTYPE *Release)( + IActivationFactory *This); + + /*** IInspectable methods ***/ + HRESULT (STDMETHODCALLTYPE *GetIids)( + IActivationFactory *This, + ULONG *iidCount, + IID **iids); + + HRESULT (STDMETHODCALLTYPE *GetRuntimeClassName)( + IActivationFactory *This, + HSTRING *className); + + HRESULT (STDMETHODCALLTYPE *GetTrustLevel)( + IActivationFactory *This, + TrustLevel *trustLevel); + + /*** IActivationFactory methods ***/ + HRESULT (STDMETHODCALLTYPE *ActivateInstance)( + IActivationFactory *This, + IInspectable **instance); + + END_INTERFACE +} IActivationFactoryVtbl; + +interface IActivationFactory { + CONST_VTBL IActivationFactoryVtbl* lpVtbl; +}; + +#ifdef COBJMACROS +#ifndef WIDL_C_INLINE_WRAPPERS +/*** IUnknown methods ***/ +#define IActivationFactory_QueryInterface(This,riid,ppvObject) (This)->lpVtbl->QueryInterface(This,riid,ppvObject) +#define IActivationFactory_AddRef(This) (This)->lpVtbl->AddRef(This) +#define IActivationFactory_Release(This) (This)->lpVtbl->Release(This) +/*** IInspectable methods ***/ +#define IActivationFactory_GetIids(This,iidCount,iids) (This)->lpVtbl->GetIids(This,iidCount,iids) +#define IActivationFactory_GetRuntimeClassName(This,className) (This)->lpVtbl->GetRuntimeClassName(This,className) +#define IActivationFactory_GetTrustLevel(This,trustLevel) (This)->lpVtbl->GetTrustLevel(This,trustLevel) +/*** IActivationFactory methods ***/ +#define IActivationFactory_ActivateInstance(This,instance) (This)->lpVtbl->ActivateInstance(This,instance) +#else +/*** IUnknown methods ***/ +static FORCEINLINE HRESULT IActivationFactory_QueryInterface(IActivationFactory* This,REFIID riid,void **ppvObject) { + return This->lpVtbl->QueryInterface(This,riid,ppvObject); +} +static FORCEINLINE ULONG IActivationFactory_AddRef(IActivationFactory* This) { + return This->lpVtbl->AddRef(This); +} +static FORCEINLINE ULONG IActivationFactory_Release(IActivationFactory* This) { + return This->lpVtbl->Release(This); +} +/*** IInspectable methods ***/ +static FORCEINLINE HRESULT IActivationFactory_GetIids(IActivationFactory* This,ULONG *iidCount,IID **iids) { + return This->lpVtbl->GetIids(This,iidCount,iids); +} +static FORCEINLINE HRESULT IActivationFactory_GetRuntimeClassName(IActivationFactory* This,HSTRING *className) { + return This->lpVtbl->GetRuntimeClassName(This,className); +} +static FORCEINLINE HRESULT IActivationFactory_GetTrustLevel(IActivationFactory* This,TrustLevel *trustLevel) { + return This->lpVtbl->GetTrustLevel(This,trustLevel); +} +/*** IActivationFactory methods ***/ +static FORCEINLINE HRESULT IActivationFactory_ActivateInstance(IActivationFactory* This,IInspectable **instance) { + return This->lpVtbl->ActivateInstance(This,instance); +} +#endif +#endif + +#endif + + +#endif /* __IActivationFactory_INTERFACE_DEFINED__ */ + +/* Begin additional prototypes for all interfaces */ + + +/* End additional prototypes */ + +#ifdef __cplusplus +} +#endif + +#endif /* __activation_h__ */ diff --git a/Include/hstring.h b/Include/hstring.h new file mode 100644 index 0000000..fba9836 --- /dev/null +++ b/Include/hstring.h @@ -0,0 +1,55 @@ +/*** Autogenerated by WIDL 7.7 from include/hstring.idl - Do not edit ***/ + +#ifdef _WIN32 +#ifndef __REQUIRED_RPCNDR_H_VERSION__ +#define __REQUIRED_RPCNDR_H_VERSION__ 475 +#endif +#include +#include +#endif + +#ifndef COM_NO_WINDOWS_H +#include +#include +#endif + +#ifndef __hstring_h__ +#define __hstring_h__ + +/* Forward declarations */ + +/* Headers for imported files */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct HSTRING__ { + int unused; +} HSTRING__; +typedef HSTRING__ *HSTRING; + + typedef struct HSTRING_HEADER { + union { + PVOID Reserved1; +#ifdef _WIN64 + char Reserved2[24]; +#else + char Reserved2[20]; +#endif + } Reserved; + } HSTRING_HEADER; + +DECLARE_HANDLE(HSTRING_BUFFER); +/* Begin additional prototypes for all interfaces */ + + +/* End additional prototypes */ + +#ifdef __cplusplus +} +#endif + +#endif /* __hstring_h__ */ diff --git a/Include/inspectable.h b/Include/inspectable.h new file mode 100644 index 0000000..a4cd82b --- /dev/null +++ b/Include/inspectable.h @@ -0,0 +1,169 @@ +/*** Autogenerated by WIDL 7.7 from include/inspectable.idl - Do not edit ***/ + +#ifdef _WIN32 +#ifndef __REQUIRED_RPCNDR_H_VERSION__ +#define __REQUIRED_RPCNDR_H_VERSION__ 475 +#endif +#include +#include +#endif + +#ifndef COM_NO_WINDOWS_H +#include +#include +#endif + +#ifndef __inspectable_h__ +#define __inspectable_h__ + +/* Forward declarations */ + +#ifndef __IInspectable_FWD_DEFINED__ +#define __IInspectable_FWD_DEFINED__ +typedef interface IInspectable IInspectable; +#ifdef __cplusplus +interface IInspectable; +#endif /* __cplusplus */ +#endif + +/* Headers for imported files */ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum TrustLevel { + BaseTrust = 0, + PartialTrust = 1, + FullTrust = 2 +} TrustLevel; +/***************************************************************************** + * IInspectable interface + */ +#ifndef __IInspectable_INTERFACE_DEFINED__ +#define __IInspectable_INTERFACE_DEFINED__ + +DEFINE_GUID(IID_IInspectable, 0xaf86e2e0, 0xb12d, 0x4c6a, 0x9c,0x5a, 0xd7,0xaa,0x65,0x10,0x1e,0x90); +#if defined(__cplusplus) && !defined(CINTERFACE) +MIDL_INTERFACE("af86e2e0-b12d-4c6a-9c5a-d7aa65101e90") +IInspectable : public IUnknown +{ + virtual HRESULT STDMETHODCALLTYPE GetIids( + ULONG *iidCount, + IID **iids) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetRuntimeClassName( + HSTRING *className) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetTrustLevel( + TrustLevel *trustLevel) = 0; + +}; +#ifdef __CRT_UUID_DECL +__CRT_UUID_DECL(IInspectable, 0xaf86e2e0, 0xb12d, 0x4c6a, 0x9c,0x5a, 0xd7,0xaa,0x65,0x10,0x1e,0x90) +#endif +#else +typedef struct IInspectableVtbl { + BEGIN_INTERFACE + + /*** IUnknown methods ***/ + HRESULT (STDMETHODCALLTYPE *QueryInterface)( + IInspectable *This, + REFIID riid, + void **ppvObject); + + ULONG (STDMETHODCALLTYPE *AddRef)( + IInspectable *This); + + ULONG (STDMETHODCALLTYPE *Release)( + IInspectable *This); + + /*** IInspectable methods ***/ + HRESULT (STDMETHODCALLTYPE *GetIids)( + IInspectable *This, + ULONG *iidCount, + IID **iids); + + HRESULT (STDMETHODCALLTYPE *GetRuntimeClassName)( + IInspectable *This, + HSTRING *className); + + HRESULT (STDMETHODCALLTYPE *GetTrustLevel)( + IInspectable *This, + TrustLevel *trustLevel); + + END_INTERFACE +} IInspectableVtbl; + +interface IInspectable { + CONST_VTBL IInspectableVtbl* lpVtbl; +}; + +#ifdef COBJMACROS +#ifndef WIDL_C_INLINE_WRAPPERS +/*** IUnknown methods ***/ +#define IInspectable_QueryInterface(This,riid,ppvObject) (This)->lpVtbl->QueryInterface(This,riid,ppvObject) +#define IInspectable_AddRef(This) (This)->lpVtbl->AddRef(This) +#define IInspectable_Release(This) (This)->lpVtbl->Release(This) +/*** IInspectable methods ***/ +#define IInspectable_GetIids(This,iidCount,iids) (This)->lpVtbl->GetIids(This,iidCount,iids) +#define IInspectable_GetRuntimeClassName(This,className) (This)->lpVtbl->GetRuntimeClassName(This,className) +#define IInspectable_GetTrustLevel(This,trustLevel) (This)->lpVtbl->GetTrustLevel(This,trustLevel) +#else +/*** IUnknown methods ***/ +static FORCEINLINE HRESULT IInspectable_QueryInterface(IInspectable* This,REFIID riid,void **ppvObject) { + return This->lpVtbl->QueryInterface(This,riid,ppvObject); +} +static FORCEINLINE ULONG IInspectable_AddRef(IInspectable* This) { + return This->lpVtbl->AddRef(This); +} +static FORCEINLINE ULONG IInspectable_Release(IInspectable* This) { + return This->lpVtbl->Release(This); +} +/*** IInspectable methods ***/ +static FORCEINLINE HRESULT IInspectable_GetIids(IInspectable* This,ULONG *iidCount,IID **iids) { + return This->lpVtbl->GetIids(This,iidCount,iids); +} +static FORCEINLINE HRESULT IInspectable_GetRuntimeClassName(IInspectable* This,HSTRING *className) { + return This->lpVtbl->GetRuntimeClassName(This,className); +} +static FORCEINLINE HRESULT IInspectable_GetTrustLevel(IInspectable* This,TrustLevel *trustLevel) { + return This->lpVtbl->GetTrustLevel(This,trustLevel); +} +#endif +#endif + +#endif + + +#endif /* __IInspectable_INTERFACE_DEFINED__ */ + + +#if !defined (CINTERFACE) && defined (__cplusplus) +extern "C++" { + template void **IID_INS_ARGS_internal (T **p) { + static_cast (*p); + return reinterpret_cast (p); + } +} + +#define IID_INS_ARGS(P) __uuidof(**(P)), IID_INS_ARGS_internal(P) +#endif +/* Begin additional prototypes for all interfaces */ + +ULONG __RPC_USER HSTRING_UserSize (ULONG *, ULONG, HSTRING *); +unsigned char * __RPC_USER HSTRING_UserMarshal (ULONG *, unsigned char *, HSTRING *); +unsigned char * __RPC_USER HSTRING_UserUnmarshal(ULONG *, unsigned char *, HSTRING *); +void __RPC_USER HSTRING_UserFree (ULONG *, HSTRING *); + +/* End additional prototypes */ + +#ifdef __cplusplus +} +#endif + +#endif /* __inspectable_h__ */ diff --git a/Include/roapi.h b/Include/roapi.h new file mode 100644 index 0000000..14d94c3 --- /dev/null +++ b/Include/roapi.h @@ -0,0 +1,93 @@ +/** + * This file has no copyright assigned and is placed in the Public Domain. + * This file is part of the mingw-w64 runtime package. + * No warranty is given; refer to the file DISCLAIMER.PD within this package. + */ +#ifndef __ROAPI_H__ +#define __ROAPI_H__ + +#include +#include +#include +#include +#include +#include + +typedef enum RO_INIT_TYPE { +#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP) + RO_INIT_SINGLETHREADED = 0, +#endif + RO_INIT_MULTITHREADED = 1 +} RO_INIT_TYPE; + +typedef struct { } *RO_REGISTRATION_COOKIE; + +typedef HRESULT (WINAPI *PFNGETACTIVATIONFACTORY)(HSTRING, IActivationFactory **); + +#ifdef __cplusplus +extern "C" { +#endif + +HRESULT WINAPI RoActivateInstance(HSTRING activatableClassId, IInspectable **instance); + +HRESULT WINAPI RoGetActivationFactory(HSTRING activatableClassId, REFIID iid, void **factory); + +HRESULT WINAPI RoGetApartmentIdentifier(UINT64 *apartmentIdentifier); + +HRESULT WINAPI RoInitialize(RO_INIT_TYPE initType); + +HRESULT WINAPI RoRegisterActivationFactories(HSTRING *activatableClassIds, PFNGETACTIVATIONFACTORY *activationFactoryCallbacks, UINT32 count, RO_REGISTRATION_COOKIE *cookie); + +void WINAPI RoRevokeActivationFactories(RO_REGISTRATION_COOKIE cookie); + +void WINAPI RoUninitialize(void); + +typedef interface IApartmentShutdown IApartmentShutdown; +DECLARE_HANDLE (APARTMENT_SHUTDOWN_REGISTRATION_COOKIE); + +HRESULT WINAPI RoRegisterForApartmentShutdown (IApartmentShutdown *callbackObj, UINT64 *apartmentId, APARTMENT_SHUTDOWN_REGISTRATION_COOKIE *regCookie); + +HRESULT WINAPI RoUnregisterForApartmentShutdown (APARTMENT_SHUTDOWN_REGISTRATION_COOKIE regCookie); + +HRESULT WINAPI RoGetApartmentIdentifier (UINT64 *apartmentId); + +#ifdef __cplusplus +} /* extern "C" */ + +namespace Windows { + namespace Foundation { + __inline HRESULT Initialize (RO_INIT_TYPE it +#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP) + = RO_INIT_SINGLETHREADED +#endif + ) { return RoInitialize (it); } + __inline void Uninitialize () + { RoUninitialize (); } + + template __inline HRESULT GetActivationFactory(HSTRING classid, T **factory) { + return RoGetActivationFactory(classid, IID_INS_ARGS(factory)); + } + } +} + +namespace ABI { + namespace Windows { + namespace Foundation { + __inline HRESULT Initialze (RO_INIT_TYPE it +#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP) + = RO_INIT_SINGLETHREADED +#endif + ) { return RoInitialize (it); } + __inline void Uninitialize () + { RoUninitialize (); } + } + + template __inline HRESULT GetActivationFactory(HSTRING classid, T **factory) { + return RoGetActivationFactory(classid, IID_INS_ARGS(factory)); + } + } +} + +#endif + +#endif diff --git a/Include/wrl/client.h b/Include/wrl/client.h new file mode 100644 index 0000000..12239e1 --- /dev/null +++ b/Include/wrl/client.h @@ -0,0 +1,306 @@ +/** + * This file has no copyright assigned and is placed in the Public Domain. + * This file is part of the mingw-w64 runtime package. + * No warranty is given; refer to the file DISCLAIMER.PD within this package. + */ + +#ifndef _WRL_CLIENT_H_ +#define _WRL_CLIENT_H_ + +#include +#include +/* #include */ +#include + +/* #include */ +#include + +namespace Microsoft { + namespace WRL { + namespace Details { + template class ComPtrRefBase { + protected: + T* ptr_; + + public: + typedef typename T::InterfaceType InterfaceType; + +#ifndef __WRL_CLASSIC_COM__ + operator IInspectable**() const throw() { + static_assert(__is_base_of(IInspectable, InterfaceType), "Invalid cast"); + return reinterpret_cast(ptr_->ReleaseAndGetAddressOf()); + } +#endif + + operator IUnknown**() const throw() { + static_assert(__is_base_of(IUnknown, InterfaceType), "Invalid cast"); + return reinterpret_cast(ptr_->ReleaseAndGetAddressOf()); + } + }; + + template class ComPtrRef : public Details::ComPtrRefBase { + public: + ComPtrRef(T *ptr) throw() { + ComPtrRefBase::ptr_ = ptr; + } + + operator void**() const throw() { + return reinterpret_cast(ComPtrRefBase::ptr_->ReleaseAndGetAddressOf()); + } + + operator T*() throw() { + *ComPtrRefBase::ptr_ = nullptr; + return ComPtrRefBase::ptr_; + } + + operator typename ComPtrRefBase::InterfaceType**() throw() { + return ComPtrRefBase::ptr_->ReleaseAndGetAddressOf(); + } + + typename ComPtrRefBase::InterfaceType *operator*() throw() { + return ComPtrRefBase::ptr_->Get(); + } + + typename ComPtrRefBase::InterfaceType *const *GetAddressOf() const throw() { + return ComPtrRefBase::ptr_->GetAddressOf(); + } + + typename ComPtrRefBase::InterfaceType **ReleaseAndGetAddressOf() throw() { + return ComPtrRefBase::ptr_->ReleaseAndGetAddressOf(); + } + }; + + } + + template class ComPtr { + public: + typedef T InterfaceType; + + ComPtr() throw() : ptr_(nullptr) {} + ComPtr(decltype(nullptr)) throw() : ptr_(nullptr) {} + + template ComPtr(U *other) throw() : ptr_(other) { + InternalAddRef(); + } + + ComPtr(const ComPtr &other) throw() : ptr_(other.ptr_) { + InternalAddRef(); + } + + template + ComPtr(const ComPtr &other) throw() : ptr_(other.Get()) { + InternalAddRef(); + } + + ComPtr(ComPtr &&other) throw() : ptr_(nullptr) { + if(this != reinterpret_cast(&reinterpret_cast(other))) + Swap(other); + } + + template + ComPtr(ComPtr&& other) throw() : ptr_(other.Detach()) {} + + ~ComPtr() throw() { + InternalRelease(); + } + + ComPtr &operator=(decltype(nullptr)) throw() { + InternalRelease(); + return *this; + } + + ComPtr &operator=(InterfaceType *other) throw() { + if (ptr_ != other) { + InternalRelease(); + ptr_ = other; + InternalAddRef(); + } + return *this; + } + + template + ComPtr &operator=(U *other) throw() { + if (ptr_ != other) { + InternalRelease(); + ptr_ = other; + InternalAddRef(); + } + return *this; + } + + ComPtr& operator=(const ComPtr &other) throw() { + if (ptr_ != other.ptr_) + ComPtr(other).Swap(*this); + return *this; + } + + template + ComPtr &operator=(const ComPtr &other) throw() { + ComPtr(other).Swap(*this); + return *this; + } + + ComPtr& operator=(ComPtr &&other) throw() { + ComPtr(other).Swap(*this); + return *this; + } + + template + ComPtr& operator=(ComPtr &&other) throw() { + ComPtr(other).Swap(*this); + return *this; + } + + void Swap(ComPtr &&r) throw() { + InterfaceType *tmp = ptr_; + ptr_ = r.ptr_; + r.ptr_ = tmp; + } + + void Swap(ComPtr &r) throw() { + InterfaceType *tmp = ptr_; + ptr_ = r.ptr_; + r.ptr_ = tmp; + } + + operator Details::BoolType() const throw() { + return Get() != nullptr ? &Details::BoolStruct::Member : nullptr; + } + + InterfaceType *Get() const throw() { + return ptr_; + } + + InterfaceType *operator->() const throw() { + return ptr_; + } + + Details::ComPtrRef> operator&() throw() { + return Details::ComPtrRef>(this); + } + + const Details::ComPtrRef> operator&() const throw() { + return Details::ComPtrRef>(this); + } + + InterfaceType *const *GetAddressOf() const throw() { + return &ptr_; + } + + InterfaceType **GetAddressOf() throw() { + return &ptr_; + } + + InterfaceType **ReleaseAndGetAddressOf() throw() { + InternalRelease(); + return &ptr_; + } + + InterfaceType *Detach() throw() { + T* ptr = ptr_; + ptr_ = nullptr; + return ptr; + } + + void Attach(InterfaceType *other) throw() { + if (ptr_ != other) { + InternalRelease(); + ptr_ = other; + InternalAddRef(); + } + } + + unsigned long Reset() { + return InternalRelease(); + } + + HRESULT CopyTo(InterfaceType **ptr) const throw() { + InternalAddRef(); + *ptr = ptr_; + return S_OK; + } + + HRESULT CopyTo(REFIID riid, void **ptr) const throw() { + return ptr_->QueryInterface(riid, ptr); + } + + template + HRESULT CopyTo(U **ptr) const throw() { + return ptr_->QueryInterface(__uuidof(U), reinterpret_cast(ptr)); + } + + template + HRESULT As(Details::ComPtrRef> p) const throw() { + return ptr_->QueryInterface(__uuidof(U), p); + } + + template + HRESULT As(ComPtr *p) const throw() { + return ptr_->QueryInterface(__uuidof(U), reinterpret_cast(p->ReleaseAndGetAddressOf())); + } + + HRESULT AsIID(REFIID riid, ComPtr *p) const throw() { + return ptr_->QueryInterface(riid, reinterpret_cast(p->ReleaseAndGetAddressOf())); + } + + /* + HRESULT AsWeak(WeakRef *pWeakRef) const throw() { + return ::Microsoft::WRL::AsWeak(ptr_, pWeakRef); + } + */ + protected: + InterfaceType *ptr_; + + void InternalAddRef() const throw() { + if(ptr_) + ptr_->AddRef(); + } + + unsigned long InternalRelease() throw() { + InterfaceType *tmp = ptr_; + if(!tmp) + return 0; + ptr_ = nullptr; + return tmp->Release(); + } + }; + } +} + +template +void **IID_PPV_ARGS_Helper(::Microsoft::WRL::Details::ComPtrRef pp) throw() { + static_assert(__is_base_of(IUnknown, typename T::InterfaceType), "Expected COM interface"); + return pp; +} + +namespace Windows { + namespace Foundation { + template + inline HRESULT ActivateInstance(HSTRING classid, ::Microsoft::WRL::Details::ComPtrRef instance) throw() { + return ActivateInstance(classid, instance.ReleaseAndGetAddressOf()); + } + + template + inline HRESULT GetActivationFactory(HSTRING classid, ::Microsoft::WRL::Details::ComPtrRef factory) throw() { + return RoGetActivationFactory(classid, IID_INS_ARGS(factory.ReleaseAndGetAddressOf())); + } + } +} + +namespace ABI { + namespace Windows { + namespace Foundation { + template + inline HRESULT ActivateInstance(HSTRING classid, ::Microsoft::WRL::Details::ComPtrRef instance) throw() { + return ActivateInstance(classid, instance.ReleaseAndGetAddressOf()); + } + + template + inline HRESULT GetActivationFactory(HSTRING classid, ::Microsoft::WRL::Details::ComPtrRef factory) throw() { + return RoGetActivationFactory(classid, IID_INS_ARGS(factory.ReleaseAndGetAddressOf())); + } + } + } +} + +#endif diff --git a/Include/wrl/internal.h b/Include/wrl/internal.h new file mode 100644 index 0000000..715ef74 --- /dev/null +++ b/Include/wrl/internal.h @@ -0,0 +1,36 @@ +/** + * This file has no copyright assigned and is placed in the Public Domain. + * This file is part of the mingw-w64 runtime package. + * No warranty is given; refer to the file DISCLAIMER.PD within this package. + */ + +#ifndef _WRL_INTERNAL_H_ +#define _WRL_INTERNAL_H_ + +#include + +namespace Microsoft { + namespace WRL { + namespace Details { + struct BoolStruct { + int Member; + }; + + typedef int BoolStruct::* BoolType; + + inline void DECLSPEC_NORETURN RaiseException(HRESULT hr, DWORD flags = EXCEPTION_NONCONTINUABLE) throw() { + ::RaiseException(static_cast(hr), flags, 0, NULL); + } + + template + struct EnableIf {}; + + template + struct EnableIf { + typedef T type; + }; + } + } +} + +#endif diff --git a/Include/wrl/module.h b/Include/wrl/module.h new file mode 100644 index 0000000..4ac93ca --- /dev/null +++ b/Include/wrl/module.h @@ -0,0 +1,23 @@ +/** + * This file has no copyright assigned and is placed in the Public Domain. + * This file is part of the mingw-w64 runtime package. + * No warranty is given; refer to the file DISCLAIMER.PD within this package. + */ + +#ifndef _WRL_MODULE_H_ +#define _WRL_MODULE_H_ + +#include +#include +#include +#include +#include + +/* #include */ +#include +#include +/* #include */ +/* #include */ +#include + +#endif diff --git a/Include/wrl/wrappers/corewrappers.h b/Include/wrl/wrappers/corewrappers.h new file mode 100644 index 0000000..221d9cc --- /dev/null +++ b/Include/wrl/wrappers/corewrappers.h @@ -0,0 +1,117 @@ +/** + * This file has no copyright assigned and is placed in the Public Domain. + * This file is part of the mingw-w64 runtime package. + * No warranty is given; refer to the file DISCLAIMER.PD within this package. + */ + +#ifndef _WRL_COREWRAPPERS_H_ +#define _WRL_COREWRAPPERS_H_ + +#include +#include +#include +#include + +/* #include */ +#include + +namespace Microsoft { + namespace WRL { + namespace Details { + struct Dummy {}; + } + + namespace Wrappers { + class HStringReference { + private: + void Init(const wchar_t* str, unsigned int len) { + HRESULT hres = ::WindowsCreateStringReference(str, len, &header_, &hstr_); + if (FAILED(hres)) + ::Microsoft::WRL::Details::RaiseException(hres); + } + + HStringReference() : hstr_(nullptr) {} + + public: + HStringReference(const wchar_t* str, unsigned int len) throw() : hstr_(nullptr) { + Init(str, len); + } + + template + explicit HStringReference(wchar_t const (&str)[sizeDest]) throw() : hstr_(nullptr) { + Init(str, sizeDest - 1); + } + + template + explicit HStringReference(wchar_t (&strRef)[sizeDest]) throw() { + const wchar_t *str = static_cast(strRef); + Init(str, ::wcslen(str)); + } + + template + explicit HStringReference(const T &strRef) throw() : hstr_(nullptr) { + const wchar_t* str = static_cast(strRef); + size_t len = ::wcslen(str); + if(static_cast(static_cast(len)) != len) + ::Microsoft::WRL::Details::RaiseException(INTSAFE_E_ARITHMETIC_OVERFLOW); + Init(str, len); + } + + HStringReference(const HStringReference &other) throw() : hstr_(nullptr) { + unsigned int len = 0; + const wchar_t* value = other.GetRawBuffer(&len); + Init(value, len); + } + + ~HStringReference() throw() { + hstr_ = nullptr; + } + + HStringReference& operator=(const HStringReference &other) throw() { + unsigned int len = 0; + const wchar_t* value = other.GetRawBuffer(&len); + Init(value, len); + return *this; + } + + HSTRING Get() const throw() { + return hstr_; + } + + const wchar_t *GetRawBuffer(unsigned int *len) const { + return ::WindowsGetStringRawBuffer(hstr_, len); + } + + HRESULT CopyTo(HSTRING *str) const throw() { + return ::WindowsDuplicateString(hstr_, str); + } + + friend class HString; + + protected: + HSTRING_HEADER header_; + HSTRING hstr_; + }; + + class RoInitializeWrapper { + public: + RoInitializeWrapper(RO_INIT_TYPE flags) { + hres = ::Windows::Foundation::Initialize(flags); + } + + ~RoInitializeWrapper() { + if(SUCCEEDED(hres)) + ::Windows::Foundation::Uninitialize(); + } + + operator HRESULT() { + return hres; + } + private: + HRESULT hres; + }; + } + } +} + +#endif