summaryrefslogtreecommitdiff
path: root/src/inc/winrt/windowsruntime.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/inc/winrt/windowsruntime.h')
-rw-r--r--src/inc/winrt/windowsruntime.h66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/inc/winrt/windowsruntime.h b/src/inc/winrt/windowsruntime.h
new file mode 100644
index 0000000000..42f3b37e2d
--- /dev/null
+++ b/src/inc/winrt/windowsruntime.h
@@ -0,0 +1,66 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+#ifndef WindowsRuntime_h
+#define WindowsRuntime_h
+
+#include <roapi.h>
+#include <windowsstring.h>
+#include "holder.h"
+
+#ifdef FEATURE_LEAVE_RUNTIME_HOLDER
+ #define HR_LEAVE_RUNTIME_HOLDER(X) \
+ GCX_PREEMP(); \
+ LeaveRuntimeHolderNoThrow lrh(X); \
+ if (FAILED(lrh.GetHR())) \
+ { \
+ return lrh.GetHR(); \
+ }
+#else
+ #define HR_LEAVE_RUNTIME_HOLDER(X) (void *)0;
+#endif
+
+#ifndef IID_INS_ARGS
+ #define IID_INS_ARGS(ppType) __uuidof(**(ppType)), IID_INS_ARGS_Helper(ppType)
+#endif
+
+HRESULT StringCchLength(
+ __in LPCWSTR wz,
+ __out UINT32 *pcch);
+
+#ifndef CROSSGEN_COMPILE
+namespace clr
+{
+ namespace winrt
+ {
+ using ABI::Windows::Foundation::GetActivationFactory;
+
+ template <typename ItfT> inline
+ HRESULT GetActivationFactory(
+ __in WinRtStringRef const & wzActivatableClassId,
+ __deref_out ItfT** ppItf)
+ {
+ LIMITED_METHOD_CONTRACT;
+ HR_LEAVE_RUNTIME_HOLDER(::RoGetActivationFactory);
+ return GetActivationFactory(wzActivatableClassId.Get(), ppItf);
+ }
+
+ template <typename ItfT>
+ HRESULT GetActivationFactory(
+ __in WinRtStringRef const & wzActivatableClassId,
+ __in typename ReleaseHolder<ItfT>& hItf)
+ {
+ LIMITED_METHOD_CONTRACT;
+ HR_LEAVE_RUNTIME_HOLDER(::RoGetActivationFactory);
+ return GetActivationFactory(wzActivatableClassId.Get(), (ItfT**)&hItf);
+ }
+ } // namespace winrt
+} // namespace clr
+#endif //CROSSGEN_COMPILE
+#undef HR_LEAVE_RUNTIME_HOLDER
+
+#endif // WindowsRuntime_h
+
+