From 4391ea6a13e082c0887bafa9ecd4ed35d26efcd0 Mon Sep 17 00:00:00 2001 From: Kenny Kerr Date: Fri, 26 Mar 2021 11:17:52 -0700 Subject: [PATCH] windows --- cppwinrt/code_writers.h | 18 +++++++++--------- cppwinrt/component_writers.h | 4 ++-- cppwinrt/type_writers.h | 2 +- test/test_component/Windows.Class.cpp | 15 +++++++++++++++ test/test_component/Windows.Class.h | 19 +++++++++++++++++++ test/test_component/test_component.idl | 10 ++++++++++ test/test_component/test_component.vcxproj | 2 ++ 7 files changed, 58 insertions(+), 12 deletions(-) create mode 100644 test/test_component/Windows.Class.cpp create mode 100644 test/test_component/Windows.Class.h diff --git a/cppwinrt/code_writers.h b/cppwinrt/code_writers.h index 422be0541..5817abb64 100644 --- a/cppwinrt/code_writers.h +++ b/cppwinrt/code_writers.h @@ -1619,7 +1619,7 @@ namespace cppwinrt else if (optional) { auto format = R"( if (%) *% = nullptr; - Windows::Foundation::IInspectable winrt_impl_%; + winrt::Windows::Foundation::IInspectable winrt_impl_%; )"; w.write(format, param_name, param_name, param_name); @@ -1961,7 +1961,7 @@ struct __declspec(empty_bases) produce_dispatch_to_overridable if (!found) { - w.write(", Windows::Foundation::IInspectable"); + w.write(", winrt::Windows::Foundation::IInspectable"); } } @@ -2314,11 +2314,11 @@ struct __declspec(empty_bases) produce_dispatch_to_overridable if (empty(generics)) { auto format = R"( struct __declspec(empty_bases) % : - Windows::Foundation::IInspectable, + winrt::Windows::Foundation::IInspectable, impl::consume_t<%>% { %(std::nullptr_t = nullptr) noexcept {} - %(void* ptr, take_ownership_from_abi_t) noexcept : Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {} + %(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {} %(% const&) noexcept = default; %(%&&) noexcept = default; %& operator=(% const&) & noexcept = default; @@ -2349,11 +2349,11 @@ struct __declspec(empty_bases) produce_dispatch_to_overridable auto format = R"( template <%> struct __declspec(empty_bases) % : - Windows::Foundation::IInspectable, + winrt::Windows::Foundation::IInspectable, impl::consume_t<%>% {% %(std::nullptr_t = nullptr) noexcept {} - %(void* ptr, take_ownership_from_abi_t) noexcept : Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {} + %(void* ptr, take_ownership_from_abi_t) noexcept : winrt::Windows::Foundation::IInspectable(ptr, take_ownership_from_abi) {} %(% const&) noexcept = default; %(%&&) noexcept = default; %& operator=(% const&) & noexcept = default; @@ -2925,7 +2925,7 @@ struct __declspec(empty_bases) produce_dispatch_to_overridable auto format = R"( inline %::%(%) { - Windows::Foundation::IInspectable %, %; + winrt::Windows::Foundation::IInspectable %, %; *this = % { return f.%(%%%, %); }); } )"; @@ -3056,7 +3056,7 @@ struct __declspec(empty_bases) produce_dispatch_to_overridable if (has_fastabi(type)) { format = R"( inline %::%() : - %(impl::call_factory_cast<%(*)(Windows::Foundation::IActivationFactory const&), %>([](Windows::Foundation::IActivationFactory const& f) { return impl::fast_activate<%>(f); })) + %(impl::call_factory_cast<%(*)(winrt::Windows::Foundation::IActivationFactory const&), %>([](winrt::Windows::Foundation::IActivationFactory const& f) { return impl::fast_activate<%>(f); })) { } )"; @@ -3064,7 +3064,7 @@ struct __declspec(empty_bases) produce_dispatch_to_overridable else { format = R"( inline %::%() : - %(impl::call_factory_cast<%(*)(Windows::Foundation::IActivationFactory const&), %>([](Windows::Foundation::IActivationFactory const& f) { return f.template ActivateInstance<%>(); })) + %(impl::call_factory_cast<%(*)(winrt::Windows::Foundation::IActivationFactory const&), %>([](winrt::Windows::Foundation::IActivationFactory const& f) { return f.template ActivateInstance<%>(); })) { } )"; diff --git a/cppwinrt/component_writers.h b/cppwinrt/component_writers.h index a2e755a48..b8894f8f4 100644 --- a/cppwinrt/component_writers.h +++ b/cppwinrt/component_writers.h @@ -347,7 +347,7 @@ catch (...) { return winrt::to_hresult(); } if (!default_constructor) { - w.write(R"( [[noreturn]] Windows::Foundation::IInspectable ActivateInstance() const + w.write(R"( [[noreturn]] winrt::Windows::Foundation::IInspectable ActivateInstance() const { throw hresult_not_implemented(); } @@ -831,7 +831,7 @@ catch (...) { return winrt::to_hresult(); } auto format = R"(namespace winrt::@::factory_implementation { template - struct __declspec(empty_bases) %T : implements + struct __declspec(empty_bases) %T : implements { using instance_type = @::%; diff --git a/cppwinrt/type_writers.h b/cppwinrt/type_writers.h index c05505db2..0f3ca983e 100644 --- a/cppwinrt/type_writers.h +++ b/cppwinrt/type_writers.h @@ -504,7 +504,7 @@ namespace cppwinrt } else { - write("Windows::Foundation::IInspectable"); + write("winrt::Windows::Foundation::IInspectable"); } } else diff --git a/test/test_component/Windows.Class.cpp b/test/test_component/Windows.Class.cpp new file mode 100644 index 000000000..bbed99356 --- /dev/null +++ b/test/test_component/Windows.Class.cpp @@ -0,0 +1,15 @@ +#include "pch.h" +#include "Windows.Class.h" +#include "Windows.Class.g.cpp" + +namespace winrt::test_component::Windows::implementation +{ + void Class::StaticMethod() + { + throw hresult_not_implemented(); + } + void Class::Method() + { + throw hresult_not_implemented(); + } +} diff --git a/test/test_component/Windows.Class.h b/test/test_component/Windows.Class.h new file mode 100644 index 000000000..f720364f1 --- /dev/null +++ b/test/test_component/Windows.Class.h @@ -0,0 +1,19 @@ +#pragma once +#include "Windows.Class.g.h" + +namespace winrt::test_component::Windows::implementation +{ + struct Class : ClassT + { + Class() = default; + + static void StaticMethod(); + void Method(); + }; +} +namespace winrt::test_component::Windows::factory_implementation +{ + struct Class : ClassT + { + }; +} diff --git a/test/test_component/test_component.idl b/test/test_component/test_component.idl index a7a86a447..b3455f362 100644 --- a/test/test_component/test_component.idl +++ b/test/test_component/test_component.idl @@ -277,4 +277,14 @@ namespace test_component } } } + + namespace Windows + { + runtimeclass Class + { + Class(); + static void StaticMethod(); + void Method(); + } + } } diff --git a/test/test_component/test_component.vcxproj b/test/test_component/test_component.vcxproj index ef66896e9..171c859e9 100644 --- a/test/test_component/test_component.vcxproj +++ b/test/test_component/test_component.vcxproj @@ -620,6 +620,7 @@ + @@ -628,6 +629,7 @@ +