From 68a87a54aad033b0c2a7ea65a53d0dd90a1d2c56 Mon Sep 17 00:00:00 2001 From: Alexander Sklar Date: Tue, 9 Mar 2021 18:00:04 -0800 Subject: [PATCH 1/2] Reduce size of compiled base.h due to get_runtime_activation_factory --- strings/base_activation.h | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/strings/base_activation.h b/strings/base_activation.h index c9ec543d0..16e57d22c 100644 --- a/strings/base_activation.h +++ b/strings/base_activation.h @@ -24,17 +24,18 @@ namespace winrt::impl return error_class_not_available; } - template - hresult get_runtime_activation_factory(param::hstring const& name, void** result) noexcept + + template + __declspec(noinline) hresult get_runtime_activation_factory_impl(param::hstring const& name, winrt::guid const& guid, void** result) noexcept { if (winrt_activation_handler) { - return winrt_activation_handler(*(void**)(&name), guid_of(), result); + return winrt_activation_handler(*(void**)(&name), guid, result); } - static int32_t(__stdcall * handler)(void* classId, guid const& iid, void** factory) noexcept; + static int32_t(__stdcall * handler)(void* classId, winrt::guid const& iid, void** factory) noexcept; impl::load_runtime_function("RoGetActivationFactory", handler, fallback_RoGetActivationFactory); - hresult hr = handler(*(void**)(&name), guid_of(), result); + hresult hr = handler(*(void**)(&name), guid, result); if (hr == impl::error_not_initialized) { @@ -47,7 +48,7 @@ namespace winrt::impl void* cookie; usage(&cookie); - hr = handler(*(void**)(&name), guid_of(), result); + hr = handler(*(void**)(&name), guid, result); } if (hr == 0) @@ -87,13 +88,13 @@ namespace winrt::impl continue; } - if constexpr (std::is_same_v< Interface, Windows::Foundation::IActivationFactory>) + if constexpr (isSameInterfaceAsIActivationFactory) { *result = library_factory.detach(); library.detach(); return 0; } - else if (0 == library_factory.as(guid_of(), result)) + else if (0 == library_factory.as(guid, result)) { library.detach(); return 0; @@ -103,6 +104,12 @@ namespace winrt::impl WINRT_IMPL_SetErrorInfo(0, error_info.get()); return hr; } + + template + hresult get_runtime_activation_factory(param::hstring const& name, void** result) noexcept + { + return get_runtime_activation_factory_impl>(name, guid_of(), result); + } } WINRT_EXPORT namespace winrt From 3177c9a685b3bdf07cb5e9426188ba6e73ff6bcc Mon Sep 17 00:00:00 2001 From: Alexander Sklar Date: Tue, 9 Mar 2021 18:05:27 -0800 Subject: [PATCH 2/2] format --- strings/base_activation.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/strings/base_activation.h b/strings/base_activation.h index 16e57d22c..704caf805 100644 --- a/strings/base_activation.h +++ b/strings/base_activation.h @@ -108,7 +108,7 @@ namespace winrt::impl template hresult get_runtime_activation_factory(param::hstring const& name, void** result) noexcept { - return get_runtime_activation_factory_impl>(name, guid_of(), result); + return get_runtime_activation_factory_impl>(name, guid_of(), result); } }