11// ------------------------------------------------------------------------------
22// <auto-generated>
33// This code was generated by a tool.
4- // Runtime Version: 16 .0.0.0
4+ // Runtime Version: 17 .0.0.0
55//
66// Changes to this file may cause incorrect behavior and will be lost if
77// the code is regenerated.
@@ -18,8 +18,8 @@ namespace Codegen
1818 /// Class to produce the template output
1919 /// </summary>
2020
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" ) ]
2323 public partial class TypeCreator : TypeCreatorBase
2424 {
2525#line hidden
@@ -31,80 +31,85 @@ public virtual string TransformText()
3131 this . Write ( "#include \" pch.h\" \r \n #include \" XamlMetadata.h\" \r \n #include \" Crc32Str.h\" \r \n #include <win" +
3232 "string.h>\r \n \r \n " ) ;
3333
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"
3535 foreach ( var ns in Types . Select ( x => x . GetNamespace ( ) ) . Distinct ( ) ) {
3636
3737 #line default
3838 #line hidden
3939 this . Write ( "#include \" winrt/" ) ;
4040
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"
4242 this . Write ( this . ToStringHelper . ToStringWithCulture ( ns ) ) ;
4343
4444 #line default
4545 #line hidden
4646 this . Write ( ".h\" \r \n " ) ;
4747
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"
4949 }
5050
5151 #line default
5252 #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 " ) ;
7976
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 ( ) ) ) ) {
8279
8380 #line default
8481 #line hidden
85- this . Write ( " case COMPILE_TIME_CRC32_STR(\" " ) ;
82+ this . Write ( " { COMPILE_TIME_CRC32_STR(\" " ) ;
8683
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"
8885 this . Write ( this . ToStringHelper . ToStringWithCulture ( t . GetFullName ( ) ) ) ;
8986
9087 #line default
9188 #line hidden
92- this . Write ( "\" ): { return " ) ;
89+ this . Write ( "\" ), []() -> winrt::Windows::Foundation::IInspectable { return " ) ;
9390
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"
9592 this . Write ( this . ToStringHelper . ToStringWithCulture ( Util . GetCppWinRTType ( t ) ) ) ;
9693
9794 #line default
9895 #line hidden
99- this . Write ( "(); }\r \n " ) ;
96+ this . Write ( "(); } }, // 0x " ) ;
10097
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"
102106 }
103107
104108 #line default
105109 #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 " ) ;
108113 return this . GenerationEnvironment . ToString ( ) ;
109114 }
110115 }
@@ -115,7 +120,7 @@ public virtual string TransformText()
115120 /// <summary>
116121 /// Base class for this transformation
117122 /// </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" ) ]
119124 public class TypeCreatorBase
120125 {
121126 #region Fields
0 commit comments