summaryrefslogtreecommitdiff
path: root/src/inc/winrt/windowsruntime.h
blob: 766b94ab9c5be7f632f2791919c20a6533df1072 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more 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