From 522c36146d6187d469b914085c770ee45152126e Mon Sep 17 00:00:00 2001 From: Kenny Kerr Date: Fri, 26 Mar 2021 12:11:47 -0700 Subject: [PATCH 1/3] test --- test/test_component/Windows.Class.cpp | 2 +- test/test_component/Windows.Class.h | 2 +- test/test_component/test_component.idl | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/test_component/Windows.Class.cpp b/test/test_component/Windows.Class.cpp index bbed99356..c4d3d432c 100644 --- a/test/test_component/Windows.Class.cpp +++ b/test/test_component/Windows.Class.cpp @@ -8,7 +8,7 @@ namespace winrt::test_component::Windows::implementation { throw hresult_not_implemented(); } - void Class::Method() + void Class::Method(winrt::Windows::Foundation::Uri const&) { throw hresult_not_implemented(); } diff --git a/test/test_component/Windows.Class.h b/test/test_component/Windows.Class.h index f720364f1..4387d3f3f 100644 --- a/test/test_component/Windows.Class.h +++ b/test/test_component/Windows.Class.h @@ -8,7 +8,7 @@ namespace winrt::test_component::Windows::implementation Class() = default; static void StaticMethod(); - void Method(); + void Method(winrt::Windows::Foundation::Uri const& param); }; } namespace winrt::test_component::Windows::factory_implementation diff --git a/test/test_component/test_component.idl b/test/test_component/test_component.idl index b3455f362..9749ee4a8 100644 --- a/test/test_component/test_component.idl +++ b/test/test_component/test_component.idl @@ -284,7 +284,7 @@ namespace test_component { Class(); static void StaticMethod(); - void Method(); + void Method(Windows.Foundation.Uri param); } } } From 8bf34f3cff4b73c7a48922d9e2ddc7e535511488 Mon Sep 17 00:00:00 2001 From: Kenny Kerr Date: Fri, 26 Mar 2021 12:30:15 -0700 Subject: [PATCH 2/3] struct --- cppwinrt/type_writers.h | 4 ++-- test/test_component/test_component.idl | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cppwinrt/type_writers.h b/cppwinrt/type_writers.h index 0f3ca983e..27b206a25 100644 --- a/cppwinrt/type_writers.h +++ b/cppwinrt/type_writers.h @@ -343,11 +343,11 @@ namespace cppwinrt else if (name == "Vector3") { name = "float3"; } else if (name == "Vector4") { name = "float4"; } - write("@::%", ns, name); + write("winrt::@::%", ns, name); } else { - write("@::%", ns, name); + write("winrt::@::%", ns, name); } } } diff --git a/test/test_component/test_component.idl b/test/test_component/test_component.idl index 9749ee4a8..147346ad9 100644 --- a/test/test_component/test_component.idl +++ b/test/test_component/test_component.idl @@ -286,5 +286,11 @@ namespace test_component static void StaticMethod(); void Method(Windows.Foundation.Uri param); } + + struct Struct + { + Windows.Foundation.Rect rect; + Windows.Foundation.Numerics.Matrix3x2 matrix; + }; } } From 7c6d4347892f1494c54737092be266da287d8dd4 Mon Sep 17 00:00:00 2001 From: Kenny Kerr Date: Fri, 26 Mar 2021 13:16:42 -0700 Subject: [PATCH 3/3] test --- cppwinrt/code_writers.h | 4 ++-- cppwinrt/type_writers.h | 20 ++++++++++---------- test/test_component/Windows.Class.cpp | 2 +- test/test_component/Windows.Class.h | 2 +- test/test_component/test_component.idl | 15 ++++++++------- 5 files changed, 22 insertions(+), 21 deletions(-) diff --git a/cppwinrt/code_writers.h b/cppwinrt/code_writers.h index 5817abb64..37f5f4327 100644 --- a/cppwinrt/code_writers.h +++ b/cppwinrt/code_writers.h @@ -2111,7 +2111,7 @@ struct __declspec(empty_bases) produce_dispatch_to_overridable D& shim() noexcept { return *static_cast(this); } D const& shim() const noexcept { return *static_cast(this); } public: - using % = winrt::%; + using % = %; % }; )"; @@ -3207,7 +3207,7 @@ struct __declspec(empty_bases) produce_dispatch_to_overridable { auto generics = type.GenericParam(); - w.write(" template<%> struct hash : winrt::impl::hash_base {};\n", + w.write(" template<%> struct hash<%> : winrt::impl::hash_base {};\n", bind(generics), type); } diff --git a/cppwinrt/type_writers.h b/cppwinrt/type_writers.h index 27b206a25..a41b3086c 100644 --- a/cppwinrt/type_writers.h +++ b/cppwinrt/type_writers.h @@ -273,7 +273,7 @@ namespace cppwinrt if (!empty(generics)) { - write("@::%<%>", ns, remove_tick(name), bind_list(", ", generics)); + write("winrt::@::%<%>", ns, remove_tick(name), bind_list(", ", generics)); return; } @@ -301,7 +301,7 @@ namespace cppwinrt else if (name == "Vector3") { name = "float3"; } else if (name == "Vector4") { name = "float4"; } - write("@::%", ns, name); + write("winrt::@::%", ns, name); } else if (category == category::struct_type) { @@ -311,7 +311,7 @@ namespace cppwinrt } else if ((name == "Point" || name == "Size" || name == "Rect") && ns == "Windows.Foundation") { - write("@::%", ns, name); + write("winrt::@::%", ns, name); } else if (delegate_types) { @@ -400,14 +400,14 @@ namespace cppwinrt if (consume_types) { - static constexpr std::string_view iterable("Windows::Foundation::Collections::IIterable<"sv); - static constexpr std::string_view vector_view("Windows::Foundation::Collections::IVectorView<"sv); - static constexpr std::string_view map_view("Windows::Foundation::Collections::IMapView<"sv); - static constexpr std::string_view vector("Windows::Foundation::Collections::IVector<"sv); - static constexpr std::string_view map("Windows::Foundation::Collections::IMap<"sv); + static constexpr std::string_view iterable("winrt::Windows::Foundation::Collections::IIterable<"sv); + static constexpr std::string_view vector_view("winrt::Windows::Foundation::Collections::IVectorView<"sv); + static constexpr std::string_view map_view("winrt::Windows::Foundation::Collections::IMapView<"sv); + static constexpr std::string_view vector("winrt::Windows::Foundation::Collections::IVector<"sv); + static constexpr std::string_view map("winrt::Windows::Foundation::Collections::IMap<"sv); consume_types = false; - auto full_name = write_temp("@::%<%>", ns, name, bind_list(", ", type.GenericArgs())); + auto full_name = write_temp("winrt::@::%<%>", ns, name, bind_list(", ", type.GenericArgs())); consume_types = true; if (starts_with(full_name, iterable)) @@ -459,7 +459,7 @@ namespace cppwinrt } else { - write("@::%<%>", ns, name, bind_list(", ", type.GenericArgs())); + write("winrt::@::%<%>", ns, name, bind_list(", ", type.GenericArgs())); } } } diff --git a/test/test_component/Windows.Class.cpp b/test/test_component/Windows.Class.cpp index c4d3d432c..483ebaa50 100644 --- a/test/test_component/Windows.Class.cpp +++ b/test/test_component/Windows.Class.cpp @@ -4,7 +4,7 @@ namespace winrt::test_component::Windows::implementation { - void Class::StaticMethod() + void Class::StaticMethod(winrt::test_component::Windows::Struct const&) { throw hresult_not_implemented(); } diff --git a/test/test_component/Windows.Class.h b/test/test_component/Windows.Class.h index 4387d3f3f..b1ddc72d8 100644 --- a/test/test_component/Windows.Class.h +++ b/test/test_component/Windows.Class.h @@ -7,7 +7,7 @@ namespace winrt::test_component::Windows::implementation { Class() = default; - static void StaticMethod(); + static void StaticMethod(winrt::test_component::Windows::Struct const& param); void Method(winrt::Windows::Foundation::Uri const& param); }; } diff --git a/test/test_component/test_component.idl b/test/test_component/test_component.idl index 147346ad9..a3274e4c3 100644 --- a/test/test_component/test_component.idl +++ b/test/test_component/test_component.idl @@ -280,17 +280,18 @@ namespace test_component namespace Windows { - runtimeclass Class - { - Class(); - static void StaticMethod(); - void Method(Windows.Foundation.Uri param); - } - struct Struct { Windows.Foundation.Rect rect; Windows.Foundation.Numerics.Matrix3x2 matrix; + Windows.Foundation.IReference ref_rect; }; + + runtimeclass Class + { + Class(); + static void StaticMethod(Struct param); + void Method(Windows.Foundation.Uri param); + } } }