-
Notifications
You must be signed in to change notification settings - Fork 246
/
Copy pathbase_xaml_typename.h
150 lines (146 loc) · 4.62 KB
/
base_xaml_typename.h
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
namespace winrt::impl
{
template <typename T>
struct xaml_typename_name
{
static constexpr std::wstring_view value() noexcept
{
return name_of<T>();
}
};
template <>
struct xaml_typename_name<Windows::Foundation::Point>
{
static constexpr std::wstring_view value() noexcept
{
return L"Point"sv;
}
};
template <>
struct xaml_typename_name<Windows::Foundation::Size>
{
static constexpr std::wstring_view value() noexcept
{
return L"Size"sv;
}
};
template <>
struct xaml_typename_name<Windows::Foundation::Rect>
{
static constexpr std::wstring_view value() noexcept
{
return L"Rect"sv;
}
};
template <>
struct xaml_typename_name<Windows::Foundation::DateTime>
{
static constexpr std::wstring_view value() noexcept
{
return L"DateTime"sv;
}
};
template <>
struct xaml_typename_name<Windows::Foundation::TimeSpan>
{
static constexpr std::wstring_view value() noexcept
{
return L"TimeSpan"sv;
}
};
template <typename T>
struct xaml_typename_kind
{
static constexpr Windows::UI::Xaml::Interop::TypeKind value = Windows::UI::Xaml::Interop::TypeKind::Metadata;
};
template<>
struct xaml_typename_kind<bool>
{
static constexpr Windows::UI::Xaml::Interop::TypeKind value = Windows::UI::Xaml::Interop::TypeKind::Primitive;
};
template<>
struct xaml_typename_kind<char16_t>
{
static constexpr Windows::UI::Xaml::Interop::TypeKind value = Windows::UI::Xaml::Interop::TypeKind::Primitive;
};
template<>
struct xaml_typename_kind<uint8_t>
{
static constexpr Windows::UI::Xaml::Interop::TypeKind value = Windows::UI::Xaml::Interop::TypeKind::Primitive;
};
template<>
struct xaml_typename_kind<int8_t>
{
static constexpr Windows::UI::Xaml::Interop::TypeKind value = Windows::UI::Xaml::Interop::TypeKind::Primitive;
};
template<>
struct xaml_typename_kind<uint16_t>
{
static constexpr Windows::UI::Xaml::Interop::TypeKind value = Windows::UI::Xaml::Interop::TypeKind::Primitive;
};
template<>
struct xaml_typename_kind<int16_t>
{
static constexpr Windows::UI::Xaml::Interop::TypeKind value = Windows::UI::Xaml::Interop::TypeKind::Primitive;
};
template<>
struct xaml_typename_kind<uint32_t>
{
static constexpr Windows::UI::Xaml::Interop::TypeKind value = Windows::UI::Xaml::Interop::TypeKind::Primitive;
};
template<>
struct xaml_typename_kind<int32_t>
{
static constexpr Windows::UI::Xaml::Interop::TypeKind value = Windows::UI::Xaml::Interop::TypeKind::Primitive;
};
template<>
struct xaml_typename_kind<uint64_t>
{
static constexpr Windows::UI::Xaml::Interop::TypeKind value = Windows::UI::Xaml::Interop::TypeKind::Primitive;
};
template<>
struct xaml_typename_kind<int64_t>
{
static constexpr Windows::UI::Xaml::Interop::TypeKind value = Windows::UI::Xaml::Interop::TypeKind::Primitive;
};
template<>
struct xaml_typename_kind<float>
{
static constexpr Windows::UI::Xaml::Interop::TypeKind value = Windows::UI::Xaml::Interop::TypeKind::Primitive;
};
template<>
struct xaml_typename_kind<double>
{
static constexpr Windows::UI::Xaml::Interop::TypeKind value = Windows::UI::Xaml::Interop::TypeKind::Primitive;
};
template<>
struct xaml_typename_kind<hstring>
{
static constexpr Windows::UI::Xaml::Interop::TypeKind value = Windows::UI::Xaml::Interop::TypeKind::Primitive;
};
template<>
struct xaml_typename_kind<guid>
{
static constexpr Windows::UI::Xaml::Interop::TypeKind value = Windows::UI::Xaml::Interop::TypeKind::Primitive;
};
template <typename D>
auto consume_Windows_UI_Xaml_Interop_IBindableIterable<D>::begin() const
{
return get_begin_iterator(static_cast<D const&>(*this));
}
template <typename D>
auto consume_Windows_UI_Xaml_Interop_IBindableIterable<D>::end() const
{
return get_end_iterator(static_cast<D const&>(*this));
}
}
WINRT_EXPORT namespace winrt
{
template <typename T>
inline Windows::UI::Xaml::Interop::TypeName xaml_typename()
{
static_assert(impl::has_category_v<T>, "T must be WinRT type.");
static const Windows::UI::Xaml::Interop::TypeName name{ hstring{ impl::xaml_typename_name<T>::value() }, impl::xaml_typename_kind<T>::value };
return name;
}
}