1
1
// ------------------------------------------------------------------------------
2
2
// <auto-generated>
3
3
// This code was generated by a tool.
4
- // Runtime Version: 16 .0.0.0
4
+ // Runtime Version: 17 .0.0.0
5
5
//
6
6
// Changes to this file may cause incorrect behavior and will be lost if
7
7
// the code is regenerated.
@@ -18,8 +18,8 @@ namespace Codegen
18
18
/// Class to produce the template output
19
19
/// </summary>
20
20
21
- #line 1 "F: \r eact-native-xaml\package\Codegen\TypeCreator.tt"
22
- [ global ::System . CodeDom . Compiler . GeneratedCodeAttribute ( "Microsoft.VisualStudio.TextTemplating" , "16 .0.0.0" ) ]
21
+ #line 1 "C:\Users \a sklar\source \r epos \r eact-native-xaml\package\Codegen\TypeCreator.tt"
22
+ [ global ::System . CodeDom . Compiler . GeneratedCodeAttribute ( "Microsoft.VisualStudio.TextTemplating" , "17 .0.0.0" ) ]
23
23
public partial class TypeCreator : TypeCreatorBase
24
24
{
25
25
#line hidden
@@ -31,80 +31,85 @@ public virtual string TransformText()
31
31
this . Write ( "#include \" pch.h\" \r \n #include \" XamlMetadata.h\" \r \n #include \" Crc32Str.h\" \r \n #include <win" +
32
32
"string.h>\r \n \r \n " ) ;
33
33
34
- #line 11 "F: \r eact-native-xaml\package\Codegen\TypeCreator.tt"
34
+ #line 11 "C:\Users \a sklar\source \r epos \r eact-native-xaml\package\Codegen\TypeCreator.tt"
35
35
foreach ( var ns in Types . Select ( x => x . GetNamespace ( ) ) . Distinct ( ) ) {
36
36
37
37
#line default
38
38
#line hidden
39
39
this . Write ( "#include \" winrt/" ) ;
40
40
41
- #line 12 "F: \r eact-native-xaml\package\Codegen\TypeCreator.tt"
41
+ #line 12 "C:\Users \a sklar\source \r epos \r eact-native-xaml\package\Codegen\TypeCreator.tt"
42
42
this . Write ( this . ToStringHelper . ToStringWithCulture ( ns ) ) ;
43
43
44
44
#line default
45
45
#line hidden
46
46
this . Write ( ".h\" \r \n " ) ;
47
47
48
- #line 13 "F: \r eact-native-xaml\package\Codegen\TypeCreator.tt"
48
+ #line 13 "C:\Users \a sklar\source \r epos \r eact-native-xaml\package\Codegen\TypeCreator.tt"
49
49
}
50
50
51
51
#line default
52
52
#line hidden
53
- this . Write ( @"
54
- /*************************************************************
55
- THIS FILE WAS AUTOMATICALLY GENERATED, DO NOT MODIFY MANUALLY
56
- **************************************************************/
57
-
58
- winrt::Windows::Foundation::IInspectable XamlMetadata::Create(const std::string_view& typeName) const {
59
- wchar_t buf[128]{};
60
- for (auto i = 0u; i < typeName.size() && i < ARRAYSIZE(buf) - 1; i++) {
61
- buf[i] = static_cast<wchar_t>(typeName[i]);
62
- }
63
-
64
- HSTRING clsid = nullptr;
65
- if (SUCCEEDED(WindowsCreateString(buf, static_cast<UINT32>(wcslen(buf)), &clsid))) {
66
- winrt::com_ptr<::IInspectable> insp{ nullptr };
67
- if (SUCCEEDED(RoActivateInstance(clsid, insp.put()))) {
68
- winrt::IUnknown unk{ nullptr };
69
- winrt::copy_from_abi(unk, insp.get());
70
- WindowsDeleteString(clsid);
71
- return unk.as<winrt::IInspectable>();
72
- } else {
73
- // type probably has a custom activation factory, use C++/WinRT to create it
74
- WindowsDeleteString(clsid);
75
- clsid = nullptr;
76
- const auto key = COMPILE_TIME_CRC32_STR(typeName.data());
77
- switch (key) {
78
- " ) ;
53
+ this . Write ( "\r \n /*************************************************************\r \n THIS FILE WAS A" +
54
+ "UTOMATICALLY GENERATED, DO NOT MODIFY MANUALLY\r \n ********************************" +
55
+ "******************************/\r \n \r \n template<typename T, typename K, size_t N>\r \n c" +
56
+ "onst T* binary_search_map(const std::pair<K, T> (& map)[N], size_t low, size_t h" +
57
+ "igh, const K& key) {\r \n while (low != high) {\r \n size_t midpoint = (low " +
58
+ "+ high) / 2;\r \n if (map[midpoint].first == key) return &(map[midpoint].sec" +
59
+ "ond);\r \n else if (((high - low) % 2 == 1) && map[midpoint + 1].first == ke" +
60
+ "y) return &(map[midpoint + 1].second);\r \n else if (key < map[midpoint].fir" +
61
+ "st) high = midpoint;\r \n else /*if (key > map[midpoint].first)*/ low = midp" +
62
+ "oint + 1;\r \n }\r \n if (map[low].first == key) return &(map[low].second);\r \n " +
63
+ " return nullptr;\r \n }\r \n \r \n winrt::Windows::Foundation::IInspectable XamlMetadata::Cr" +
64
+ "eate(const std::string_view& typeName) const {\r \n wchar_t buf[128]{};\r \n for (au" +
65
+ "to i = 0u; i < typeName.size() && i < ARRAYSIZE(buf) - 1; i++) {\r \n buf[i] = s" +
66
+ "tatic_cast<wchar_t>(typeName[i]);\r \n }\r \n \r \n HSTRING clsid = nullptr;\r \n if (SUCC" +
67
+ "EEDED(WindowsCreateString(buf, static_cast<UINT32>(wcslen(buf)), &clsid))) {\r \n " +
68
+ " winrt::com_ptr<::IInspectable> insp{ nullptr };\r \n if (SUCCEEDED(RoActivateI" +
69
+ "nstance(clsid, insp.put()))) {\r \n winrt::IUnknown unk{ nullptr };\r \n win" +
70
+ "rt::copy_from_abi(unk, insp.get());\r \n WindowsDeleteString(clsid);\r \n re" +
71
+ "turn unk.as<winrt::IInspectable>();\r \n } else {\r \n // type probably has a " +
72
+ "custom activation factory, use C++/WinRT to create it\r \n WindowsDeleteString" +
73
+ "(clsid);\r \n clsid = nullptr;\r \n const auto key = COMPILE_TIME_CRC32_STR(" +
74
+ "typeName.data());\r \n const std::pair<uint32_t, winrt::Windows::Foundation::I" +
75
+ "Inspectable(*)()> map[] = {\r \n " ) ;
79
76
80
- #line 39 "F: \r eact-native-xaml\package\Codegen\TypeCreator.tt"
81
- foreach ( var t in Types . Where ( t => Util . GetComposableFactoryType ( t ) != null ) ) {
77
+ #line 52 "C:\Users \a sklar\source \r epos \r eact-native-xaml\package\Codegen\TypeCreator.tt"
78
+ foreach ( var t in Types . Where ( t => Util . GetComposableFactoryType ( t ) != null ) . OrderBy ( t => Util . GetCRC32 ( t . GetFullName ( ) ) ) ) {
82
79
83
80
#line default
84
81
#line hidden
85
- this . Write ( " case COMPILE_TIME_CRC32_STR(\" " ) ;
82
+ this . Write ( " { COMPILE_TIME_CRC32_STR(\" " ) ;
86
83
87
- #line 40 "F: \r eact-native-xaml\package\Codegen\TypeCreator.tt"
84
+ #line 53 "C:\Users \a sklar\source \r epos \r eact-native-xaml\package\Codegen\TypeCreator.tt"
88
85
this . Write ( this . ToStringHelper . ToStringWithCulture ( t . GetFullName ( ) ) ) ;
89
86
90
87
#line default
91
88
#line hidden
92
- this . Write ( "\" ): { return " ) ;
89
+ this . Write ( "\" ), []() -> winrt::Windows::Foundation::IInspectable { return " ) ;
93
90
94
- #line 40 "F: \r eact-native-xaml\package\Codegen\TypeCreator.tt"
91
+ #line 53 "C:\Users \a sklar\source \r epos \r eact-native-xaml\package\Codegen\TypeCreator.tt"
95
92
this . Write ( this . ToStringHelper . ToStringWithCulture ( Util . GetCppWinRTType ( t ) ) ) ;
96
93
97
94
#line default
98
95
#line hidden
99
- this . Write ( "(); }\r \n " ) ;
96
+ this . Write ( "(); } }, // 0x " ) ;
100
97
101
- #line 41 "F:\r eact-native-xaml\package\Codegen\TypeCreator.tt"
98
+ #line 53 "C:\Users\a sklar\source\r epos\r eact-native-xaml\package\Codegen\TypeCreator.tt"
99
+ this . Write ( this . ToStringHelper . ToStringWithCulture ( Util . GetCRC32 ( t . GetFullName ( ) ) . ToString ( "X8" ) ) ) ;
100
+
101
+ #line default
102
+ #line hidden
103
+ this . Write ( "\r \n " ) ;
104
+
105
+ #line 54 "C:\Users\a sklar\source\r epos\r eact-native-xaml\package\Codegen\TypeCreator.tt"
102
106
}
103
107
104
108
#line default
105
109
#line hidden
106
- this . Write ( " }\r \n }\r \n }\r \n assert(false && \" xaml type not found\" );\r \n return nullptr;\r \n " +
107
- "}\r \n \r \n \r \n " ) ;
110
+ this . Write ( " };\r \n \r \n if (const auto it = binary_search_map(map, 0, std::size(map), k" +
111
+ "ey)) {\r \n return (* it)();\r \n }\r \n }\r \n }\r \n assert(false && \" xaml t" +
112
+ "ype not found\" );\r \n return nullptr;\r \n }\r \n \r \n \r \n " ) ;
108
113
return this . GenerationEnvironment . ToString ( ) ;
109
114
}
110
115
}
@@ -115,7 +120,7 @@ public virtual string TransformText()
115
120
/// <summary>
116
121
/// Base class for this transformation
117
122
/// </summary>
118
- [ global ::System . CodeDom . Compiler . GeneratedCodeAttribute ( "Microsoft.VisualStudio.TextTemplating" , "16 .0.0.0" ) ]
123
+ [ global ::System . CodeDom . Compiler . GeneratedCodeAttribute ( "Microsoft.VisualStudio.TextTemplating" , "17 .0.0.0" ) ]
119
124
public class TypeCreatorBase
120
125
{
121
126
#region Fields
0 commit comments