@@ -85,7 +85,7 @@ namespace cppwinrt
8585 }
8686 }
8787
88- static void write_component_activation (writer& w, TypeDef const & type)
88+ static void write_component_make_definition (writer& w, TypeDef const & type)
8989 {
9090 if (!has_factory_members (w, type) || is_always_disabled (type))
9191 {
@@ -96,25 +96,38 @@ namespace cppwinrt
9696 auto type_namespace = type.TypeNamespace ();
9797 auto impl_name = get_impl_name (type_namespace, type_name);
9898
99+ auto format = R"( void* winrt_make_%()
100+ {
101+ return winrt::detach_abi(winrt::make<winrt::@::factory_implementation::%>());
102+ }
103+ )" ;
104+
105+ w.write (format,
106+ impl_name,
107+ type_namespace,
108+ type_name);
109+ }
110+
111+ static void write_component_activation (writer& w, TypeDef const & type)
112+ {
113+ if (!has_factory_members (w, type) || is_always_disabled (type))
114+ {
115+ return ;
116+ }
117+
118+ auto impl_name = get_impl_name (type.TypeNamespace (), type.TypeName ());
119+
99120 if (settings.component_opt )
100121 {
101122 auto format = R"( void* winrt_make_%();
102123)" ;
103124
104125 w.write (format, impl_name);
126+ return ;
105127 }
106128 else
107129 {
108- auto format = R"( void* winrt_make_%()
109- {
110- return winrt::detach_abi(winrt::make<winrt::@::factory_implementation::%>());
111- }
112- )" ;
113-
114- w.write (format,
115- impl_name,
116- type_namespace,
117- type_name);
130+ write_component_make_definition (w, type);
118131 }
119132 }
120133
@@ -428,7 +441,7 @@ catch (...) { return winrt::to_hresult(); }
428441 auto type_name = type.TypeName ();
429442 auto type_namespace = type.TypeNamespace ();
430443
431- write_component_activation (w, type);
444+ write_component_make_definition (w, type);
432445
433446 if (!settings.component_opt )
434447 {
0 commit comments