From 74beaa713486135a2aa4589f8fe662257d75dce2 Mon Sep 17 00:00:00 2001 From: Leon Matthes Date: Fri, 23 Feb 2024 14:20:08 +0100 Subject: [PATCH] Remove the full qualification prefix `::` This is conflicting with Qt5s Meta Object system. E.g.: In Qt5 only `QPoint` is a valid type for a Q_PROPERTY, `::QPoint` is not! --- crates/cxx-qt-gen/src/generator/cpp/method.rs | 11 +- crates/cxx-qt-gen/src/generator/cpp/signal.rs | 26 +-- .../src/generator/naming/signals.rs | 20 ++- crates/cxx-qt-gen/src/naming/cpp.rs | 4 +- crates/cxx-qt-gen/src/naming/type_names.rs | 31 ++-- .../cxx-qt-gen/test_outputs/inheritance.cpp | 6 +- crates/cxx-qt-gen/test_outputs/inheritance.h | 12 +- crates/cxx-qt-gen/test_outputs/invokables.cpp | 6 +- crates/cxx-qt-gen/test_outputs/invokables.h | 12 +- .../test_outputs/passthrough_and_naming.cpp | 166 +++++++++--------- .../test_outputs/passthrough_and_naming.h | 74 ++++---- .../test_outputs/passthrough_and_naming.rs | 48 ++--- crates/cxx-qt-gen/test_outputs/properties.cpp | 52 +++--- crates/cxx-qt-gen/test_outputs/properties.h | 34 ++-- crates/cxx-qt-gen/test_outputs/properties.rs | 16 +- crates/cxx-qt-gen/test_outputs/qenum.cpp | 4 +- crates/cxx-qt-gen/test_outputs/qenum.h | 8 +- crates/cxx-qt-gen/test_outputs/signals.cpp | 152 ++++++++-------- crates/cxx-qt-gen/test_outputs/signals.h | 52 +++--- crates/cxx-qt-gen/test_outputs/signals.rs | 32 ++-- 20 files changed, 391 insertions(+), 375 deletions(-) diff --git a/crates/cxx-qt-gen/src/generator/cpp/method.rs b/crates/cxx-qt-gen/src/generator/cpp/method.rs index 5df9f1a89..b869d703e 100644 --- a/crates/cxx-qt-gen/src/generator/cpp/method.rs +++ b/crates/cxx-qt-gen/src/generator/cpp/method.rs @@ -411,15 +411,12 @@ mod tests { } else { panic!("Expected pair") }; - assert_str_eq!( - header, - "Q_INVOKABLE ::B2 trivialInvokable(::A1 param) const;" - ); + assert_str_eq!(header, "Q_INVOKABLE B2 trivialInvokable(A1 param) const;"); assert_str_eq!( source, indoc! {r#" - ::B2 - MyObject::trivialInvokable(::A1 param) const + B2 + MyObject::trivialInvokable(A1 param) const { const ::rust::cxxqt1::MaybeLockGuard guard(*this); return trivialInvokableWrapper(param); @@ -437,7 +434,7 @@ mod tests { }; assert_str_eq!( header, - "::B2 trivialInvokableWrapper(::A1 param) const noexcept;" + "B2 trivialInvokableWrapper(A1 param) const noexcept;" ); } } diff --git a/crates/cxx-qt-gen/src/generator/cpp/signal.rs b/crates/cxx-qt-gen/src/generator/cpp/signal.rs index 52e71b0e6..03abb57ce 100644 --- a/crates/cxx-qt-gen/src/generator/cpp/signal.rs +++ b/crates/cxx-qt-gen/src/generator/cpp/signal.rs @@ -639,10 +639,10 @@ mod tests { header, indoc! { r#" - namespace rust::cxxqtgen1::mynamespace { + namespace mynamespace::rust::cxxqtgen1 { ::QMetaObject::Connection - ObjRust_signalCxxNameConnect(::mynamespace::ObjCpp& self, ::rust::cxxqtgen1::mynamespace::ObjRustCxxQtSignalHandlersignalCxxName closure, ::Qt::ConnectionType type); - } // namespace rust::cxxqtgen1::mynamespace + ObjRust_signalCxxNameConnect(mynamespace::ObjCpp& self, ::mynamespace::rust::cxxqtgen1::ObjRustCxxQtSignalHandlersignalCxxName closure, ::Qt::ConnectionType type); + } // namespace mynamespace::rust::cxxqtgen1 "#} ); assert_str_eq!( @@ -652,7 +652,7 @@ mod tests { // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480 namespace rust::cxxqt1 { template <> - SignalHandler<::rust::cxxqtgen1::mynamespace::ObjRustCxxQtSignalParamssignalCxxName *>::~SignalHandler() noexcept + SignalHandler<::mynamespace::rust::cxxqtgen1::ObjRustCxxQtSignalParamssignalCxxName *>::~SignalHandler() noexcept { if (data[0] == nullptr && data[1] == nullptr) { @@ -664,30 +664,30 @@ mod tests { template <> template <> - void SignalHandler<::rust::cxxqtgen1::mynamespace::ObjRustCxxQtSignalParamssignalCxxName *>::operator()<::mynamespace::ObjCpp&>(::mynamespace::ObjCpp& self) + void SignalHandler<::mynamespace::rust::cxxqtgen1::ObjRustCxxQtSignalParamssignalCxxName *>::operator()(mynamespace::ObjCpp& self) { call_ObjRust_signal_handler_signalCxxName(*this, self); } - static_assert(alignof(SignalHandler<::rust::cxxqtgen1::mynamespace::ObjRustCxxQtSignalParamssignalCxxName *>) <= alignof(::std::size_t), "unexpected aligment"); - static_assert(sizeof(SignalHandler<::rust::cxxqtgen1::mynamespace::ObjRustCxxQtSignalParamssignalCxxName *>) == sizeof(::std::size_t[2]), "unexpected size"); + static_assert(alignof(SignalHandler<::mynamespace::rust::cxxqtgen1::ObjRustCxxQtSignalParamssignalCxxName *>) <= alignof(::std::size_t), "unexpected aligment"); + static_assert(sizeof(SignalHandler<::mynamespace::rust::cxxqtgen1::ObjRustCxxQtSignalParamssignalCxxName *>) == sizeof(::std::size_t[2]), "unexpected size"); } // namespace rust::cxxqt1 - namespace rust::cxxqtgen1::mynamespace { + namespace mynamespace::rust::cxxqtgen1 { ::QMetaObject::Connection - ObjRust_signalCxxNameConnect(::mynamespace::ObjCpp& self, ::rust::cxxqtgen1::mynamespace::ObjRustCxxQtSignalHandlersignalCxxName closure, ::Qt::ConnectionType type) + ObjRust_signalCxxNameConnect(mynamespace::ObjCpp& self, ::mynamespace::rust::cxxqtgen1::ObjRustCxxQtSignalHandlersignalCxxName closure, ::Qt::ConnectionType type) { return ::QObject::connect( &self, - &::mynamespace::ObjCpp::signalCxxName, + &mynamespace::ObjCpp::signalCxxName, &self, [&, closure = ::std::move(closure)]() mutable { - const ::rust::cxxqt1::MaybeLockGuard<::mynamespace::ObjCpp> guard(self); - closure.template operator()<::mynamespace::ObjCpp&>(self); + const ::rust::cxxqt1::MaybeLockGuard guard(self); + closure.template operator()(self); }, type); } - } // namespace rust::cxxqtgen1::mynamespace + } // namespace mynamespace::rust::cxxqtgen1 "#} ); } diff --git a/crates/cxx-qt-gen/src/generator/naming/signals.rs b/crates/cxx-qt-gen/src/generator/naming/signals.rs index 95f3b24ce..4b9890dc1 100644 --- a/crates/cxx-qt-gen/src/generator/naming/signals.rs +++ b/crates/cxx-qt-gen/src/generator/naming/signals.rs @@ -56,10 +56,22 @@ impl QSignalHelperName { let signal_ident = &idents.name.cpp; let handler_alias = format_ident!("{qobject_ident}CxxQtSignalHandler{signal_ident}"); let namespace = { - let mut namespace = vec!["rust::cxxqtgen1".to_owned()]; - if let Some(qobject_namespace) = type_names.namespace(qobject_ident) { - namespace.push(qobject_namespace); - } + // This namespace will take the form of: + // qobject_namespace::rust::cxxqtgen1 + // + // We experimented with using rust::cxxqtgen1::qobject_namespace. + // However, this currently doesn't work, as we can't fully-qualify all C++ access. + // Therefore when refering to the QObject type (e.g. qobject_namespace::QObject), + // It would fail, as it would look up in this helper namespace, instead of the actual + // qobject_namespace. + // + // See the comment on TypeNames::cxx_qualified for why fully qualifying is + // unfortunately not possible. + let qobject_namespace = type_names.namespace(qobject_ident); + let namespace: Vec<_> = qobject_namespace + .into_iter() + .chain(vec!["rust::cxxqtgen1".to_owned()]) + .collect(); namespace.join("::") }; diff --git a/crates/cxx-qt-gen/src/naming/cpp.rs b/crates/cxx-qt-gen/src/naming/cpp.rs index b98d59d84..65f172878 100644 --- a/crates/cxx-qt-gen/src/naming/cpp.rs +++ b/crates/cxx-qt-gen/src/naming/cpp.rs @@ -373,7 +373,7 @@ mod tests { let ty = parse_quote! { A }; let mut type_names = TypeNames::default(); type_names.insert("A", None, Some("A1"), None); - assert_eq!(syn_type_to_cpp_type(&ty, &type_names).unwrap(), "::A1"); + assert_eq!(syn_type_to_cpp_type(&ty, &type_names).unwrap(), "A1"); } #[test] @@ -381,7 +381,7 @@ mod tests { let ty = parse_quote! { A }; let mut type_names = TypeNames::default(); type_names.insert("A", None, Some("A1"), Some("N1")); - assert_eq!(syn_type_to_cpp_type(&ty, &type_names).unwrap(), "::N1::A1"); + assert_eq!(syn_type_to_cpp_type(&ty, &type_names).unwrap(), "N1::A1"); } #[test] diff --git a/crates/cxx-qt-gen/src/naming/type_names.rs b/crates/cxx-qt-gen/src/naming/type_names.rs index 1031b8c12..08679390b 100644 --- a/crates/cxx-qt-gen/src/naming/type_names.rs +++ b/crates/cxx-qt-gen/src/naming/type_names.rs @@ -178,6 +178,15 @@ impl TypeNames { } /// For a given rust ident return the CXX name with its namespace + /// + /// Ideally we'd want this type name to always be **fully** qualified, staring with `::`. + /// Unfortunately, this isn't always possible, as the Qt5 meta object system doesn't register + /// types with the fully qualified path :( + /// E.g. it will recognize `QString`, but not `::QString` from QML. + /// + /// This needs to be considered in many places (properties, signals, invokables, etc.) + /// Therefore, for now we'll use the qualified, but not fully qualified version of `namespace::type`. + /// This should work in most cases, but it's not perfect. pub fn cxx_qualified(&self, ident: &Ident) -> String { // Check if there is a cxx_name or namespace to handle let name = self.names.get(ident); @@ -190,9 +199,9 @@ impl TypeNames { let cxx_name = name.cxx.clone().unwrap_or_else(|| name.rust.to_string()); if let Some(namespace) = &name.namespace { - format!("::{namespace}::{cxx_name}") + format!("{namespace}::{cxx_name}") } else { - format!("::{cxx_name}") + cxx_name } } @@ -284,7 +293,7 @@ mod tests { assert_eq!(types.num_types(), 1); assert_eq!(types.rust_qualified(&ident), parse_quote! { ffi::A }); - assert_eq!(types.cxx_qualified(&ident), "::A"); + assert_eq!(types.cxx_qualified(&ident), "A"); assert!(types.namespace(&ident).is_none()); } @@ -302,7 +311,7 @@ mod tests { .is_ok()); assert_eq!(types.num_types(), 1); - assert_eq!(types.cxx_qualified(&ident), "::B"); + assert_eq!(types.cxx_qualified(&ident), "B"); assert!(types.namespace(&ident).is_none()); assert_eq!(types.rust_qualified(&ident), parse_quote! { ffi::A }); } @@ -354,7 +363,7 @@ mod tests { .populate(&ident, &[], Some("bridge_namespace"), &format_ident!("ffi")) .is_ok()); - assert_eq!(types.cxx_qualified(&ident), "::bridge_namespace::A"); + assert_eq!(types.cxx_qualified(&ident), "bridge_namespace::A"); assert_eq!(types.namespace(&ident).unwrap(), "bridge_namespace"); assert_eq!(types.num_types(), 1); assert_eq!( @@ -397,7 +406,7 @@ mod tests { let type_names = parse_cxx_item(item); let ident = format_ident!("A"); assert_eq!(type_names.num_types(), 1); - assert_eq!(type_names.cxx_qualified(&ident), "::B"); + assert_eq!(type_names.cxx_qualified(&ident), "B"); assert_eq!(type_names.rust_qualified(&ident), parse_quote! { ffi::A }); } @@ -431,15 +440,15 @@ mod tests { assert_eq!( &types.cxx_qualified(&format_ident!("A")), - "::type_namespace::B" + "type_namespace::B" ); assert_eq!( &types.cxx_qualified(&format_ident!("C")), - "::extern_namespace::D" + "extern_namespace::D" ); assert_eq!( &types.cxx_qualified(&format_ident!("E")), - "::bridge_namespace::E" + "bridge_namespace::E" ); assert_eq!( @@ -485,7 +494,7 @@ mod tests { assert_eq!(type_names.num_types(), 1); assert_eq!(type_names.cxx_unqualified(&ident).unwrap(), "EnumB"); assert_eq!(type_names.namespace(&ident).unwrap(), "enum_namespace"); - assert_eq!(type_names.cxx_qualified(&ident), "::enum_namespace::EnumB"); + assert_eq!(type_names.cxx_qualified(&ident), "enum_namespace::EnumB"); assert_eq!( type_names.rust_qualified(&ident), parse_quote! { ffi::EnumA } @@ -507,7 +516,7 @@ mod tests { assert_eq!(types.num_types(), 1); assert_eq!(types.cxx_unqualified(&ident).unwrap(), "StructB"); - assert_eq!(types.cxx_qualified(&ident), "::struct_namespace::StructB"); + assert_eq!(types.cxx_qualified(&ident), "struct_namespace::StructB"); assert_eq!(types.namespace(&ident).unwrap(), "struct_namespace"); assert_eq!(types.rust_qualified(&ident), parse_quote! { ffi::StructA }); } diff --git a/crates/cxx-qt-gen/test_outputs/inheritance.cpp b/crates/cxx-qt-gen/test_outputs/inheritance.cpp index 6be23243c..f015da4fc 100644 --- a/crates/cxx-qt-gen/test_outputs/inheritance.cpp +++ b/crates/cxx-qt-gen/test_outputs/inheritance.cpp @@ -1,14 +1,14 @@ #include "cxx-qt-gen/inheritance.cxxqt.h" -::QVariant -MyObject::data(::QModelIndex const& _index, ::std::int32_t _role) const +QVariant +MyObject::data(QModelIndex const& _index, ::std::int32_t _role) const { const ::rust::cxxqt1::MaybeLockGuard guard(*this); return dataWrapper(_index, _role); } bool -MyObject::hasChildren(::QModelIndex const& _parent) const +MyObject::hasChildren(QModelIndex const& _parent) const { const ::rust::cxxqt1::MaybeLockGuard guard(*this); return hasChildrenWrapper(_parent); diff --git a/crates/cxx-qt-gen/test_outputs/inheritance.h b/crates/cxx-qt-gen/test_outputs/inheritance.h index 5403b5167..5574858ff 100644 --- a/crates/cxx-qt-gen/test_outputs/inheritance.h +++ b/crates/cxx-qt-gen/test_outputs/inheritance.h @@ -18,9 +18,9 @@ class MyObject virtual ~MyObject() = default; public: - Q_INVOKABLE ::QVariant data(::QModelIndex const& _index, - ::std::int32_t _role) const override; - Q_INVOKABLE bool hasChildren(::QModelIndex const& _parent) const override; + Q_INVOKABLE QVariant data(QModelIndex const& _index, + ::std::int32_t _role) const override; + Q_INVOKABLE bool hasChildren(QModelIndex const& _parent) const override; template bool hasChildrenCxxQtInherit(Args... args) const { @@ -34,9 +34,9 @@ class MyObject explicit MyObject(QObject* parent = nullptr); private: - ::QVariant dataWrapper(::QModelIndex const& _index, - ::std::int32_t _role) const noexcept; - bool hasChildrenWrapper(::QModelIndex const& _parent) const noexcept; + QVariant dataWrapper(QModelIndex const& _index, + ::std::int32_t _role) const noexcept; + bool hasChildrenWrapper(QModelIndex const& _parent) const noexcept; }; static_assert(::std::is_base_of::value, diff --git a/crates/cxx-qt-gen/test_outputs/invokables.cpp b/crates/cxx-qt-gen/test_outputs/invokables.cpp index 7812bcbf7..c3f79859e 100644 --- a/crates/cxx-qt-gen/test_outputs/invokables.cpp +++ b/crates/cxx-qt-gen/test_outputs/invokables.cpp @@ -23,8 +23,8 @@ MyObject::invokableMutable() } void -MyObject::invokableParameters(::QColor const& opaque, - ::QPoint const& trivial, +MyObject::invokableParameters(QColor const& opaque, + QPoint const& trivial, ::std::int32_t primitive) const { const ::rust::cxxqt1::MaybeLockGuard guard(*this); @@ -38,7 +38,7 @@ MyObject::invokableReturnOpaque() return invokableReturnOpaqueWrapper(); } -::QPoint +QPoint MyObject::invokableReturnTrivial() { const ::rust::cxxqt1::MaybeLockGuard guard(*this); diff --git a/crates/cxx-qt-gen/test_outputs/invokables.h b/crates/cxx-qt-gen/test_outputs/invokables.h index 77b19671d..e2c0bff26 100644 --- a/crates/cxx-qt-gen/test_outputs/invokables.h +++ b/crates/cxx-qt-gen/test_outputs/invokables.h @@ -26,11 +26,11 @@ class MyObject void cppMethod() const; Q_INVOKABLE void invokable() const; Q_INVOKABLE void invokableMutable(); - Q_INVOKABLE void invokableParameters(::QColor const& opaque, - ::QPoint const& trivial, + Q_INVOKABLE void invokableParameters(QColor const& opaque, + QPoint const& trivial, ::std::int32_t primitive) const; Q_INVOKABLE ::std::unique_ptr invokableReturnOpaque(); - Q_INVOKABLE ::QPoint invokableReturnTrivial(); + Q_INVOKABLE QPoint invokableReturnTrivial(); Q_INVOKABLE void invokableFinal() const final; Q_INVOKABLE void invokableOverride() const override; Q_INVOKABLE virtual void invokableVirtual() const; @@ -43,11 +43,11 @@ class MyObject void cppMethodWrapper() const noexcept; void invokableWrapper() const noexcept; void invokableMutableWrapper() noexcept; - void invokableParametersWrapper(::QColor const& opaque, - ::QPoint const& trivial, + void invokableParametersWrapper(QColor const& opaque, + QPoint const& trivial, ::std::int32_t primitive) const noexcept; ::std::unique_ptr invokableReturnOpaqueWrapper() noexcept; - ::QPoint invokableReturnTrivialWrapper() noexcept; + QPoint invokableReturnTrivialWrapper() noexcept; void invokableFinalWrapper() const noexcept; void invokableOverrideWrapper() const noexcept; void invokableVirtualWrapper() const noexcept; diff --git a/crates/cxx-qt-gen/test_outputs/passthrough_and_naming.cpp b/crates/cxx-qt-gen/test_outputs/passthrough_and_naming.cpp index 716d0fbaf..09573c364 100644 --- a/crates/cxx-qt-gen/test_outputs/passthrough_and_naming.cpp +++ b/crates/cxx-qt-gen/test_outputs/passthrough_and_naming.cpp @@ -18,7 +18,7 @@ template<> template<> void SignalHandler<::rust::cxxqtgen1::QPushButtonCxxQtSignalParamsclicked*>:: -operator()<::QPushButton&, bool>(::QPushButton& self, bool checked) +operator()(QPushButton& self, bool checked) { call_QPushButton_signal_handler_clicked(*this, self, ::std::move(checked)); } @@ -38,18 +38,18 @@ static_assert( namespace rust::cxxqtgen1 { ::QMetaObject::Connection QPushButton_clickedConnect( - ::QPushButton& self, + QPushButton& self, ::rust::cxxqtgen1::QPushButtonCxxQtSignalHandlerclicked closure, ::Qt::ConnectionType type) { return ::QObject::connect( &self, - &::QPushButton::clicked, + &QPushButton::clicked, &self, [&, closure = ::std::move(closure)](bool checked) mutable { - const ::rust::cxxqt1::MaybeLockGuard<::QPushButton> guard(self); - closure.template operator()<::QPushButton&, bool>(self, - ::std::move(checked)); + const ::rust::cxxqt1::MaybeLockGuard guard(self); + closure.template operator()(self, + ::std::move(checked)); }, type); } @@ -60,7 +60,7 @@ QPushButton_clickedConnect( namespace rust::cxxqt1 { template<> SignalHandler< - ::rust::cxxqtgen1::mynamespace::ExternObjectCxxQtSignalParamsdataReady*>:: + ::mynamespace::rust::cxxqtgen1::ExternObjectCxxQtSignalParamsdataReady*>:: ~SignalHandler() noexcept { if (data[0] == nullptr && data[1] == nullptr) { @@ -74,52 +74,51 @@ template<> template<> void SignalHandler< - ::rust::cxxqtgen1::mynamespace::ExternObjectCxxQtSignalParamsdataReady*>:: -operator()<::mynamespace::ExternObjectCpp&>( - ::mynamespace::ExternObjectCpp& self) + ::mynamespace::rust::cxxqtgen1::ExternObjectCxxQtSignalParamsdataReady*>:: +operator()(mynamespace::ExternObjectCpp& self) { call_ExternObject_signal_handler_dataReady(*this, self); } static_assert( - alignof(SignalHandler<::rust::cxxqtgen1::mynamespace:: + alignof(SignalHandler<::mynamespace::rust::cxxqtgen1:: ExternObjectCxxQtSignalParamsdataReady*>) <= alignof(::std::size_t), "unexpected aligment"); static_assert( - sizeof(SignalHandler<::rust::cxxqtgen1::mynamespace:: + sizeof(SignalHandler<::mynamespace::rust::cxxqtgen1:: ExternObjectCxxQtSignalParamsdataReady*>) == sizeof(::std::size_t[2]), "unexpected size"); } // namespace rust::cxxqt1 -namespace rust::cxxqtgen1::mynamespace { +namespace mynamespace::rust::cxxqtgen1 { ::QMetaObject::Connection ExternObject_dataReadyConnect( - ::mynamespace::ExternObjectCpp& self, - ::rust::cxxqtgen1::mynamespace::ExternObjectCxxQtSignalHandlerdataReady + mynamespace::ExternObjectCpp& self, + ::mynamespace::rust::cxxqtgen1::ExternObjectCxxQtSignalHandlerdataReady closure, ::Qt::ConnectionType type) { return ::QObject::connect( &self, - &::mynamespace::ExternObjectCpp::dataReady, + &mynamespace::ExternObjectCpp::dataReady, &self, [&, closure = ::std::move(closure)]() mutable { - const ::rust::cxxqt1::MaybeLockGuard<::mynamespace::ExternObjectCpp> - guard(self); - closure.template operator()<::mynamespace::ExternObjectCpp&>(self); + const ::rust::cxxqt1::MaybeLockGuard guard( + self); + closure.template operator()(self); }, type); } -} // namespace rust::cxxqtgen1::mynamespace +} // namespace mynamespace::rust::cxxqtgen1 // Define namespace otherwise we hit a GCC bug // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480 namespace rust::cxxqt1 { template<> SignalHandler< - ::rust::cxxqtgen1::mynamespace::ExternObjectCxxQtSignalParamserrorOccurred*>:: + ::mynamespace::rust::cxxqtgen1::ExternObjectCxxQtSignalParamserrorOccurred*>:: ~SignalHandler() noexcept { if (data[0] == nullptr && data[1] == nullptr) { @@ -133,52 +132,51 @@ template<> template<> void SignalHandler< - ::rust::cxxqtgen1::mynamespace::ExternObjectCxxQtSignalParamserrorOccurred*>:: -operator()<::mynamespace::ExternObjectCpp&>( - ::mynamespace::ExternObjectCpp& self) + ::mynamespace::rust::cxxqtgen1::ExternObjectCxxQtSignalParamserrorOccurred*>:: +operator()(mynamespace::ExternObjectCpp& self) { call_ExternObject_signal_handler_errorOccurred(*this, self); } static_assert( - alignof(SignalHandler<::rust::cxxqtgen1::mynamespace:: + alignof(SignalHandler<::mynamespace::rust::cxxqtgen1:: ExternObjectCxxQtSignalParamserrorOccurred*>) <= alignof(::std::size_t), "unexpected aligment"); static_assert( - sizeof(SignalHandler<::rust::cxxqtgen1::mynamespace:: + sizeof(SignalHandler<::mynamespace::rust::cxxqtgen1:: ExternObjectCxxQtSignalParamserrorOccurred*>) == sizeof(::std::size_t[2]), "unexpected size"); } // namespace rust::cxxqt1 -namespace rust::cxxqtgen1::mynamespace { +namespace mynamespace::rust::cxxqtgen1 { ::QMetaObject::Connection ExternObject_errorOccurredConnect( - ::mynamespace::ExternObjectCpp& self, - ::rust::cxxqtgen1::mynamespace::ExternObjectCxxQtSignalHandlererrorOccurred + mynamespace::ExternObjectCpp& self, + ::mynamespace::rust::cxxqtgen1::ExternObjectCxxQtSignalHandlererrorOccurred closure, ::Qt::ConnectionType type) { return ::QObject::connect( &self, - &::mynamespace::ExternObjectCpp::errorOccurred, + &mynamespace::ExternObjectCpp::errorOccurred, &self, [&, closure = ::std::move(closure)]() mutable { - const ::rust::cxxqt1::MaybeLockGuard<::mynamespace::ExternObjectCpp> - guard(self); - closure.template operator()<::mynamespace::ExternObjectCpp&>(self); + const ::rust::cxxqt1::MaybeLockGuard guard( + self); + closure.template operator()(self); }, type); } -} // namespace rust::cxxqtgen1::mynamespace +} // namespace mynamespace::rust::cxxqtgen1 // Define namespace otherwise we hit a GCC bug // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480 namespace rust::cxxqt1 { template<> SignalHandler< - ::rust::cxxqtgen1::cxx_qt::multi_object:: + ::cxx_qt::multi_object::rust::cxxqtgen1:: MyObjectCxxQtSignalParamspropertyNameChanged*>::~SignalHandler() noexcept { if (data[0] == nullptr && data[1] == nullptr) { @@ -191,52 +189,52 @@ SignalHandler< template<> template<> void -SignalHandler<::rust::cxxqtgen1::cxx_qt::multi_object:: +SignalHandler<::cxx_qt::multi_object::rust::cxxqtgen1:: MyObjectCxxQtSignalParamspropertyNameChanged*>:: -operator()<::cxx_qt::multi_object::MyObject&>( - ::cxx_qt::multi_object::MyObject& self) +operator()( + cxx_qt::multi_object::MyObject& self) { call_MyObject_signal_handler_propertyNameChanged(*this, self); } static_assert( - alignof(SignalHandler<::rust::cxxqtgen1::cxx_qt::multi_object:: + alignof(SignalHandler<::cxx_qt::multi_object::rust::cxxqtgen1:: MyObjectCxxQtSignalParamspropertyNameChanged*>) <= alignof(::std::size_t), "unexpected aligment"); static_assert( - sizeof(SignalHandler<::rust::cxxqtgen1::cxx_qt::multi_object:: + sizeof(SignalHandler<::cxx_qt::multi_object::rust::cxxqtgen1:: MyObjectCxxQtSignalParamspropertyNameChanged*>) == sizeof(::std::size_t[2]), "unexpected size"); } // namespace rust::cxxqt1 -namespace rust::cxxqtgen1::cxx_qt::multi_object { +namespace cxx_qt::multi_object::rust::cxxqtgen1 { ::QMetaObject::Connection MyObject_propertyNameChangedConnect( - ::cxx_qt::multi_object::MyObject& self, - ::rust::cxxqtgen1::cxx_qt::multi_object:: + cxx_qt::multi_object::MyObject& self, + ::cxx_qt::multi_object::rust::cxxqtgen1:: MyObjectCxxQtSignalHandlerpropertyNameChanged closure, ::Qt::ConnectionType type) { return ::QObject::connect( &self, - &::cxx_qt::multi_object::MyObject::propertyNameChanged, + &cxx_qt::multi_object::MyObject::propertyNameChanged, &self, [&, closure = ::std::move(closure)]() mutable { - const ::rust::cxxqt1::MaybeLockGuard<::cxx_qt::multi_object::MyObject> + const ::rust::cxxqt1::MaybeLockGuard guard(self); - closure.template operator()<::cxx_qt::multi_object::MyObject&>(self); + closure.template operator()(self); }, type); } -} // namespace rust::cxxqtgen1::cxx_qt::multi_object +} // namespace cxx_qt::multi_object::rust::cxxqtgen1 // Define namespace otherwise we hit a GCC bug // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480 namespace rust::cxxqt1 { template<> -SignalHandler<::rust::cxxqtgen1::cxx_qt::multi_object:: +SignalHandler<::cxx_qt::multi_object::rust::cxxqtgen1:: MyObjectCxxQtSignalParamsready*>::~SignalHandler() noexcept { if (data[0] == nullptr && data[1] == nullptr) { @@ -250,43 +248,43 @@ template<> template<> void SignalHandler< - ::rust::cxxqtgen1::cxx_qt::multi_object::MyObjectCxxQtSignalParamsready*>:: -operator()<::cxx_qt::multi_object::MyObject&>( - ::cxx_qt::multi_object::MyObject& self) + ::cxx_qt::multi_object::rust::cxxqtgen1::MyObjectCxxQtSignalParamsready*>:: +operator()( + cxx_qt::multi_object::MyObject& self) { call_MyObject_signal_handler_ready(*this, self); } -static_assert(alignof(SignalHandler<::rust::cxxqtgen1::cxx_qt::multi_object:: +static_assert(alignof(SignalHandler<::cxx_qt::multi_object::rust::cxxqtgen1:: MyObjectCxxQtSignalParamsready*>) <= alignof(::std::size_t), "unexpected aligment"); -static_assert(sizeof(SignalHandler<::rust::cxxqtgen1::cxx_qt::multi_object:: +static_assert(sizeof(SignalHandler<::cxx_qt::multi_object::rust::cxxqtgen1:: MyObjectCxxQtSignalParamsready*>) == sizeof(::std::size_t[2]), "unexpected size"); } // namespace rust::cxxqt1 -namespace rust::cxxqtgen1::cxx_qt::multi_object { +namespace cxx_qt::multi_object::rust::cxxqtgen1 { ::QMetaObject::Connection MyObject_readyConnect( - ::cxx_qt::multi_object::MyObject& self, - ::rust::cxxqtgen1::cxx_qt::multi_object::MyObjectCxxQtSignalHandlerready + cxx_qt::multi_object::MyObject& self, + ::cxx_qt::multi_object::rust::cxxqtgen1::MyObjectCxxQtSignalHandlerready closure, ::Qt::ConnectionType type) { return ::QObject::connect( &self, - &::cxx_qt::multi_object::MyObject::ready, + &cxx_qt::multi_object::MyObject::ready, &self, [&, closure = ::std::move(closure)]() mutable { - const ::rust::cxxqt1::MaybeLockGuard<::cxx_qt::multi_object::MyObject> + const ::rust::cxxqt1::MaybeLockGuard guard(self); - closure.template operator()<::cxx_qt::multi_object::MyObject&>(self); + closure.template operator()(self); }, type); } -} // namespace rust::cxxqtgen1::cxx_qt::multi_object +} // namespace cxx_qt::multi_object::rust::cxxqtgen1 namespace cxx_qt::multi_object { ::std::int32_t const& @@ -324,7 +322,7 @@ MyObject::MyObject(QObject* parent) // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480 namespace rust::cxxqt1 { template<> -SignalHandler<::rust::cxxqtgen1::second_object:: +SignalHandler<::second_object::rust::cxxqtgen1:: SecondObjectCxxQtSignalParamspropertyNameChanged*>:: ~SignalHandler() noexcept { @@ -338,51 +336,51 @@ SignalHandler<::rust::cxxqtgen1::second_object:: template<> template<> void -SignalHandler<::rust::cxxqtgen1::second_object:: +SignalHandler<::second_object::rust::cxxqtgen1:: SecondObjectCxxQtSignalParamspropertyNameChanged*>:: -operator()<::second_object::SecondObject&>(::second_object::SecondObject& self) +operator()(second_object::SecondObject& self) { call_SecondObject_signal_handler_propertyNameChanged(*this, self); } static_assert( - alignof(SignalHandler<::rust::cxxqtgen1::second_object:: + alignof(SignalHandler<::second_object::rust::cxxqtgen1:: SecondObjectCxxQtSignalParamspropertyNameChanged*>) <= alignof(::std::size_t), "unexpected aligment"); static_assert( - sizeof(SignalHandler<::rust::cxxqtgen1::second_object:: + sizeof(SignalHandler<::second_object::rust::cxxqtgen1:: SecondObjectCxxQtSignalParamspropertyNameChanged*>) == sizeof(::std::size_t[2]), "unexpected size"); } // namespace rust::cxxqt1 -namespace rust::cxxqtgen1::second_object { +namespace second_object::rust::cxxqtgen1 { ::QMetaObject::Connection SecondObject_propertyNameChangedConnect( - ::second_object::SecondObject& self, - ::rust::cxxqtgen1::second_object:: + second_object::SecondObject& self, + ::second_object::rust::cxxqtgen1:: SecondObjectCxxQtSignalHandlerpropertyNameChanged closure, ::Qt::ConnectionType type) { return ::QObject::connect( &self, - &::second_object::SecondObject::propertyNameChanged, + &second_object::SecondObject::propertyNameChanged, &self, [&, closure = ::std::move(closure)]() mutable { - const ::rust::cxxqt1::MaybeLockGuard<::second_object::SecondObject> guard( + const ::rust::cxxqt1::MaybeLockGuard guard( self); - closure.template operator()<::second_object::SecondObject&>(self); + closure.template operator()(self); }, type); } -} // namespace rust::cxxqtgen1::second_object +} // namespace second_object::rust::cxxqtgen1 // Define namespace otherwise we hit a GCC bug // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480 namespace rust::cxxqt1 { template<> -SignalHandler<::rust::cxxqtgen1::second_object:: +SignalHandler<::second_object::rust::cxxqtgen1:: SecondObjectCxxQtSignalParamsready*>::~SignalHandler() noexcept { if (data[0] == nullptr && data[1] == nullptr) { @@ -396,8 +394,8 @@ template<> template<> void SignalHandler< - ::rust::cxxqtgen1::second_object::SecondObjectCxxQtSignalParamsready*>:: -operator()<::second_object::SecondObject&>(::second_object::SecondObject& self) + ::second_object::rust::cxxqtgen1::SecondObjectCxxQtSignalParamsready*>:: +operator()(second_object::SecondObject& self) { call_SecondObject_signal_handler_ready(*this, self); } @@ -405,36 +403,36 @@ operator()<::second_object::SecondObject&>(::second_object::SecondObject& self) static_assert( alignof( SignalHandler< - ::rust::cxxqtgen1::second_object::SecondObjectCxxQtSignalParamsready*>) <= + ::second_object::rust::cxxqtgen1::SecondObjectCxxQtSignalParamsready*>) <= alignof(::std::size_t), "unexpected aligment"); static_assert( sizeof( SignalHandler< - ::rust::cxxqtgen1::second_object::SecondObjectCxxQtSignalParamsready*>) == + ::second_object::rust::cxxqtgen1::SecondObjectCxxQtSignalParamsready*>) == sizeof(::std::size_t[2]), "unexpected size"); } // namespace rust::cxxqt1 -namespace rust::cxxqtgen1::second_object { +namespace second_object::rust::cxxqtgen1 { ::QMetaObject::Connection SecondObject_readyConnect( - ::second_object::SecondObject& self, - ::rust::cxxqtgen1::second_object::SecondObjectCxxQtSignalHandlerready closure, + second_object::SecondObject& self, + ::second_object::rust::cxxqtgen1::SecondObjectCxxQtSignalHandlerready closure, ::Qt::ConnectionType type) { return ::QObject::connect( &self, - &::second_object::SecondObject::ready, + &second_object::SecondObject::ready, &self, [&, closure = ::std::move(closure)]() mutable { - const ::rust::cxxqt1::MaybeLockGuard<::second_object::SecondObject> guard( + const ::rust::cxxqt1::MaybeLockGuard guard( self); - closure.template operator()<::second_object::SecondObject&>(self); + closure.template operator()(self); }, type); } -} // namespace rust::cxxqtgen1::second_object +} // namespace second_object::rust::cxxqtgen1 namespace second_object { ::std::int32_t const& diff --git a/crates/cxx-qt-gen/test_outputs/passthrough_and_naming.h b/crates/cxx-qt-gen/test_outputs/passthrough_and_naming.h index 0c1791f96..14bd6c82b 100644 --- a/crates/cxx-qt-gen/test_outputs/passthrough_and_naming.h +++ b/crates/cxx-qt-gen/test_outputs/passthrough_and_naming.h @@ -10,94 +10,94 @@ class MyObject; } // namespace cxx_qt::multi_object -namespace rust::cxxqtgen1::cxx_qt::multi_object { +namespace cxx_qt::multi_object::rust::cxxqtgen1 { using MyObjectCxxQtSignalHandlerpropertyNameChanged = ::rust::cxxqt1::SignalHandler< struct MyObjectCxxQtSignalParamspropertyNameChanged*>; -} // namespace rust::cxxqtgen1::cxx_qt::multi_object +} // namespace cxx_qt::multi_object::rust::cxxqtgen1 -namespace rust::cxxqtgen1::cxx_qt::multi_object { +namespace cxx_qt::multi_object::rust::cxxqtgen1 { using MyObjectCxxQtSignalHandlerready = ::rust::cxxqt1::SignalHandler; -} // namespace rust::cxxqtgen1::cxx_qt::multi_object +} // namespace cxx_qt::multi_object::rust::cxxqtgen1 namespace second_object { class SecondObject; } // namespace second_object -namespace rust::cxxqtgen1::second_object { +namespace second_object::rust::cxxqtgen1 { using SecondObjectCxxQtSignalHandlerpropertyNameChanged = ::rust::cxxqt1::SignalHandler< struct SecondObjectCxxQtSignalParamspropertyNameChanged*>; -} // namespace rust::cxxqtgen1::second_object +} // namespace second_object::rust::cxxqtgen1 -namespace rust::cxxqtgen1::second_object { +namespace second_object::rust::cxxqtgen1 { using SecondObjectCxxQtSignalHandlerready = ::rust::cxxqt1::SignalHandler; -} // namespace rust::cxxqtgen1::second_object +} // namespace second_object::rust::cxxqtgen1 namespace rust::cxxqtgen1 { using QPushButtonCxxQtSignalHandlerclicked = ::rust::cxxqt1::SignalHandler; } // namespace rust::cxxqtgen1 -namespace rust::cxxqtgen1::mynamespace { +namespace mynamespace::rust::cxxqtgen1 { using ExternObjectCxxQtSignalHandlerdataReady = ::rust::cxxqt1::SignalHandler; -} // namespace rust::cxxqtgen1::mynamespace +} // namespace mynamespace::rust::cxxqtgen1 -namespace rust::cxxqtgen1::mynamespace { +namespace mynamespace::rust::cxxqtgen1 { using ExternObjectCxxQtSignalHandlererrorOccurred = ::rust::cxxqt1::SignalHandler< struct ExternObjectCxxQtSignalParamserrorOccurred*>; -} // namespace rust::cxxqtgen1::mynamespace +} // namespace mynamespace::rust::cxxqtgen1 #include "cxx-qt-gen/multi_object.cxx.h" namespace rust::cxxqtgen1 { ::QMetaObject::Connection QPushButton_clickedConnect( - ::QPushButton& self, + QPushButton& self, ::rust::cxxqtgen1::QPushButtonCxxQtSignalHandlerclicked closure, ::Qt::ConnectionType type); } // namespace rust::cxxqtgen1 -namespace rust::cxxqtgen1::mynamespace { +namespace mynamespace::rust::cxxqtgen1 { ::QMetaObject::Connection ExternObject_dataReadyConnect( - ::mynamespace::ExternObjectCpp& self, - ::rust::cxxqtgen1::mynamespace::ExternObjectCxxQtSignalHandlerdataReady + mynamespace::ExternObjectCpp& self, + ::mynamespace::rust::cxxqtgen1::ExternObjectCxxQtSignalHandlerdataReady closure, ::Qt::ConnectionType type); -} // namespace rust::cxxqtgen1::mynamespace +} // namespace mynamespace::rust::cxxqtgen1 -namespace rust::cxxqtgen1::mynamespace { +namespace mynamespace::rust::cxxqtgen1 { ::QMetaObject::Connection ExternObject_errorOccurredConnect( - ::mynamespace::ExternObjectCpp& self, - ::rust::cxxqtgen1::mynamespace::ExternObjectCxxQtSignalHandlererrorOccurred + mynamespace::ExternObjectCpp& self, + ::mynamespace::rust::cxxqtgen1::ExternObjectCxxQtSignalHandlererrorOccurred closure, ::Qt::ConnectionType type); -} // namespace rust::cxxqtgen1::mynamespace +} // namespace mynamespace::rust::cxxqtgen1 -namespace rust::cxxqtgen1::cxx_qt::multi_object { +namespace cxx_qt::multi_object::rust::cxxqtgen1 { ::QMetaObject::Connection MyObject_propertyNameChangedConnect( - ::cxx_qt::multi_object::MyObject& self, - ::rust::cxxqtgen1::cxx_qt::multi_object:: + cxx_qt::multi_object::MyObject& self, + ::cxx_qt::multi_object::rust::cxxqtgen1:: MyObjectCxxQtSignalHandlerpropertyNameChanged closure, ::Qt::ConnectionType type); -} // namespace rust::cxxqtgen1::cxx_qt::multi_object +} // namespace cxx_qt::multi_object::rust::cxxqtgen1 -namespace rust::cxxqtgen1::cxx_qt::multi_object { +namespace cxx_qt::multi_object::rust::cxxqtgen1 { ::QMetaObject::Connection MyObject_readyConnect( - ::cxx_qt::multi_object::MyObject& self, - ::rust::cxxqtgen1::cxx_qt::multi_object::MyObjectCxxQtSignalHandlerready + cxx_qt::multi_object::MyObject& self, + ::cxx_qt::multi_object::rust::cxxqtgen1::MyObjectCxxQtSignalHandlerready closure, ::Qt::ConnectionType type); -} // namespace rust::cxxqtgen1::cxx_qt::multi_object +} // namespace cxx_qt::multi_object::rust::cxxqtgen1 namespace cxx_qt::multi_object { class MyObject @@ -132,22 +132,22 @@ static_assert(::std::is_base_of::value, Q_DECLARE_METATYPE(cxx_qt::multi_object::MyObject*) -namespace rust::cxxqtgen1::second_object { +namespace second_object::rust::cxxqtgen1 { ::QMetaObject::Connection SecondObject_propertyNameChangedConnect( - ::second_object::SecondObject& self, - ::rust::cxxqtgen1::second_object:: + second_object::SecondObject& self, + ::second_object::rust::cxxqtgen1:: SecondObjectCxxQtSignalHandlerpropertyNameChanged closure, ::Qt::ConnectionType type); -} // namespace rust::cxxqtgen1::second_object +} // namespace second_object::rust::cxxqtgen1 -namespace rust::cxxqtgen1::second_object { +namespace second_object::rust::cxxqtgen1 { ::QMetaObject::Connection SecondObject_readyConnect( - ::second_object::SecondObject& self, - ::rust::cxxqtgen1::second_object::SecondObjectCxxQtSignalHandlerready closure, + second_object::SecondObject& self, + ::second_object::rust::cxxqtgen1::SecondObjectCxxQtSignalHandlerready closure, ::Qt::ConnectionType type); -} // namespace rust::cxxqtgen1::second_object +} // namespace second_object::rust::cxxqtgen1 namespace second_object { class SecondObject diff --git a/crates/cxx-qt-gen/test_outputs/passthrough_and_naming.rs b/crates/cxx-qt-gen/test_outputs/passthrough_and_naming.rs index 065b33527..99a948c86 100644 --- a/crates/cxx-qt-gen/test_outputs/passthrough_and_naming.rs +++ b/crates/cxx-qt-gen/test_outputs/passthrough_and_naming.rs @@ -88,13 +88,13 @@ pub mod ffi { } unsafe extern "C++" { #[doc(hidden)] - #[namespace = "rust::cxxqtgen1::cxx_qt::multi_object"] + #[namespace = "cxx_qt::multi_object::rust::cxxqtgen1"] type MyObjectCxxQtSignalHandlerpropertyNameChanged = cxx_qt::signalhandler::CxxQtSignalHandler< super::MyObjectCxxQtSignalClosurepropertyNameChanged, >; #[doc(hidden)] - #[namespace = "rust::cxxqtgen1::cxx_qt::multi_object"] + #[namespace = "cxx_qt::multi_object::rust::cxxqtgen1"] #[must_use] #[rust_name = "MyObject_connect_property_name_changed"] fn MyObject_propertyNameChangedConnect( @@ -103,7 +103,7 @@ pub mod ffi { conn_type: CxxQtConnectionType, ) -> CxxQtQMetaObjectConnection; } - #[namespace = "rust::cxxqtgen1::cxx_qt::multi_object"] + #[namespace = "cxx_qt::multi_object::rust::cxxqtgen1"] extern "Rust" { #[doc(hidden)] fn drop_MyObject_signal_handler_propertyNameChanged( @@ -126,11 +126,11 @@ pub mod ffi { } unsafe extern "C++" { #[doc(hidden)] - #[namespace = "rust::cxxqtgen1::cxx_qt::multi_object"] + #[namespace = "cxx_qt::multi_object::rust::cxxqtgen1"] type MyObjectCxxQtSignalHandlerready = cxx_qt::signalhandler::CxxQtSignalHandler; #[doc(hidden)] - #[namespace = "rust::cxxqtgen1::cxx_qt::multi_object"] + #[namespace = "cxx_qt::multi_object::rust::cxxqtgen1"] #[must_use] #[rust_name = "MyObject_connect_ready"] fn MyObject_readyConnect( @@ -139,7 +139,7 @@ pub mod ffi { conn_type: CxxQtConnectionType, ) -> CxxQtQMetaObjectConnection; } - #[namespace = "rust::cxxqtgen1::cxx_qt::multi_object"] + #[namespace = "cxx_qt::multi_object::rust::cxxqtgen1"] extern "Rust" { #[doc(hidden)] fn drop_MyObject_signal_handler_ready(handler: MyObjectCxxQtSignalHandlerready); @@ -192,13 +192,13 @@ pub mod ffi { } unsafe extern "C++" { #[doc(hidden)] - #[namespace = "rust::cxxqtgen1::second_object"] + #[namespace = "second_object::rust::cxxqtgen1"] type SecondObjectCxxQtSignalHandlerpropertyNameChanged = cxx_qt::signalhandler::CxxQtSignalHandler< super::SecondObjectCxxQtSignalClosurepropertyNameChanged, >; #[doc(hidden)] - #[namespace = "rust::cxxqtgen1::second_object"] + #[namespace = "second_object::rust::cxxqtgen1"] #[must_use] #[rust_name = "SecondObject_connect_property_name_changed"] fn SecondObject_propertyNameChangedConnect( @@ -207,7 +207,7 @@ pub mod ffi { conn_type: CxxQtConnectionType, ) -> CxxQtQMetaObjectConnection; } - #[namespace = "rust::cxxqtgen1::second_object"] + #[namespace = "second_object::rust::cxxqtgen1"] extern "Rust" { #[doc(hidden)] fn drop_SecondObject_signal_handler_propertyNameChanged( @@ -231,11 +231,11 @@ pub mod ffi { } unsafe extern "C++" { #[doc(hidden)] - #[namespace = "rust::cxxqtgen1::second_object"] + #[namespace = "second_object::rust::cxxqtgen1"] type SecondObjectCxxQtSignalHandlerready = cxx_qt::signalhandler::CxxQtSignalHandler; #[doc(hidden)] - #[namespace = "rust::cxxqtgen1::second_object"] + #[namespace = "second_object::rust::cxxqtgen1"] #[must_use] #[rust_name = "SecondObject_connect_ready"] fn SecondObject_readyConnect( @@ -244,7 +244,7 @@ pub mod ffi { conn_type: CxxQtConnectionType, ) -> CxxQtQMetaObjectConnection; } - #[namespace = "rust::cxxqtgen1::second_object"] + #[namespace = "second_object::rust::cxxqtgen1"] extern "Rust" { #[doc(hidden)] fn drop_SecondObject_signal_handler_ready(handler: SecondObjectCxxQtSignalHandlerready); @@ -311,12 +311,12 @@ pub mod ffi { } unsafe extern "C++" { #[doc(hidden)] - #[namespace = "rust::cxxqtgen1::mynamespace"] + #[namespace = "mynamespace::rust::cxxqtgen1"] type ExternObjectCxxQtSignalHandlerdataReady = cxx_qt::signalhandler::CxxQtSignalHandler< super::ExternObjectCxxQtSignalClosuredataReady, >; #[doc(hidden)] - #[namespace = "rust::cxxqtgen1::mynamespace"] + #[namespace = "mynamespace::rust::cxxqtgen1"] #[must_use] #[rust_name = "ExternObject_connect_data_ready"] fn ExternObject_dataReadyConnect( @@ -325,7 +325,7 @@ pub mod ffi { conn_type: CxxQtConnectionType, ) -> CxxQtQMetaObjectConnection; } - #[namespace = "rust::cxxqtgen1::mynamespace"] + #[namespace = "mynamespace::rust::cxxqtgen1"] extern "Rust" { #[doc(hidden)] fn drop_ExternObject_signal_handler_dataReady( @@ -343,13 +343,13 @@ pub mod ffi { } unsafe extern "C++" { #[doc(hidden)] - #[namespace = "rust::cxxqtgen1::mynamespace"] + #[namespace = "mynamespace::rust::cxxqtgen1"] type ExternObjectCxxQtSignalHandlererrorOccurred = cxx_qt::signalhandler::CxxQtSignalHandler< super::ExternObjectCxxQtSignalClosureerrorOccurred, >; #[doc(hidden)] - #[namespace = "rust::cxxqtgen1::mynamespace"] + #[namespace = "mynamespace::rust::cxxqtgen1"] #[must_use] #[rust_name = "ExternObject_connect_error_occurred"] fn ExternObject_errorOccurredConnect( @@ -358,7 +358,7 @@ pub mod ffi { conn_type: CxxQtConnectionType, ) -> CxxQtQMetaObjectConnection; } - #[namespace = "rust::cxxqtgen1::mynamespace"] + #[namespace = "mynamespace::rust::cxxqtgen1"] extern "Rust" { #[doc(hidden)] fn drop_ExternObject_signal_handler_errorOccurred( @@ -433,7 +433,7 @@ impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure for MyObjectCxxQtSignalClosurepropertyNameChanged { type Id = cxx::type_id!( - "::rust::cxxqtgen1::cxx_qt::multi_object::MyObjectCxxQtSignalHandlerpropertyNameChanged" + "::cxx_qt::multi_object::rust::cxxqtgen1::MyObjectCxxQtSignalHandlerpropertyNameChanged" ); type FnType = dyn FnMut(core::pin::Pin<&mut ffi::MyObject>); } @@ -495,7 +495,7 @@ impl ffi::MyObject { pub struct MyObjectCxxQtSignalClosureready {} impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure for MyObjectCxxQtSignalClosureready { type Id = - cxx::type_id!("::rust::cxxqtgen1::cxx_qt::multi_object::MyObjectCxxQtSignalHandlerready"); + cxx::type_id!("::cxx_qt::multi_object::rust::cxxqtgen1::MyObjectCxxQtSignalHandlerready"); type FnType = dyn FnMut(core::pin::Pin<&mut ffi::MyObject>); } use core::mem::drop as drop_MyObject_signal_handler_ready; @@ -597,7 +597,7 @@ impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure for SecondObjectCxxQtSignalClosurepropertyNameChanged { type Id = cxx::type_id!( - "::rust::cxxqtgen1::second_object::SecondObjectCxxQtSignalHandlerpropertyNameChanged" + "::second_object::rust::cxxqtgen1::SecondObjectCxxQtSignalHandlerpropertyNameChanged" ); type FnType = dyn FnMut(core::pin::Pin<&mut ffi::SecondObject>); } @@ -659,7 +659,7 @@ impl ffi::SecondObject { pub struct SecondObjectCxxQtSignalClosureready {} impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure for SecondObjectCxxQtSignalClosureready { type Id = - cxx::type_id!("::rust::cxxqtgen1::second_object::SecondObjectCxxQtSignalHandlerready"); + cxx::type_id!("::second_object::rust::cxxqtgen1::SecondObjectCxxQtSignalHandlerready"); type FnType = dyn FnMut(core::pin::Pin<&mut ffi::SecondObject>); } use core::mem::drop as drop_SecondObject_signal_handler_ready; @@ -784,7 +784,7 @@ impl ffi::ExternObject { pub struct ExternObjectCxxQtSignalClosuredataReady {} impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure for ExternObjectCxxQtSignalClosuredataReady { type Id = - cxx::type_id!("::rust::cxxqtgen1::mynamespace::ExternObjectCxxQtSignalHandlerdataReady"); + cxx::type_id!("::mynamespace::rust::cxxqtgen1::ExternObjectCxxQtSignalHandlerdataReady"); type FnType = dyn FnMut(core::pin::Pin<&mut ffi::ExternObject>); } use core::mem::drop as drop_ExternObject_signal_handler_dataReady; @@ -851,7 +851,7 @@ impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure for ExternObjectCxxQtSignalClosureerrorOccurred { type Id = cxx::type_id!( - "::rust::cxxqtgen1::mynamespace::ExternObjectCxxQtSignalHandlererrorOccurred" + "::mynamespace::rust::cxxqtgen1::ExternObjectCxxQtSignalHandlererrorOccurred" ); type FnType = dyn FnMut(core::pin::Pin<&mut ffi::ExternObject>); } diff --git a/crates/cxx-qt-gen/test_outputs/properties.cpp b/crates/cxx-qt-gen/test_outputs/properties.cpp index 06bcb523c..578a0a3c9 100644 --- a/crates/cxx-qt-gen/test_outputs/properties.cpp +++ b/crates/cxx-qt-gen/test_outputs/properties.cpp @@ -5,7 +5,7 @@ namespace rust::cxxqt1 { template<> SignalHandler< - ::rust::cxxqtgen1::cxx_qt::my_object:: + ::cxx_qt::my_object::rust::cxxqtgen1:: MyObjectCxxQtSignalParamsprimitiveChanged*>::~SignalHandler() noexcept { if (data[0] == nullptr && data[1] == nullptr) { @@ -18,52 +18,52 @@ SignalHandler< template<> template<> void -SignalHandler<::rust::cxxqtgen1::cxx_qt::my_object:: +SignalHandler<::cxx_qt::my_object::rust::cxxqtgen1:: MyObjectCxxQtSignalParamsprimitiveChanged*>:: -operator()<::cxx_qt::my_object::MyObject&>(::cxx_qt::my_object::MyObject& self) +operator()(cxx_qt::my_object::MyObject& self) { call_MyObject_signal_handler_primitiveChanged(*this, self); } static_assert( - alignof(SignalHandler<::rust::cxxqtgen1::cxx_qt::my_object:: + alignof(SignalHandler<::cxx_qt::my_object::rust::cxxqtgen1:: MyObjectCxxQtSignalParamsprimitiveChanged*>) <= alignof(::std::size_t), "unexpected aligment"); static_assert( - sizeof(SignalHandler<::rust::cxxqtgen1::cxx_qt::my_object:: + sizeof(SignalHandler<::cxx_qt::my_object::rust::cxxqtgen1:: MyObjectCxxQtSignalParamsprimitiveChanged*>) == sizeof(::std::size_t[2]), "unexpected size"); } // namespace rust::cxxqt1 -namespace rust::cxxqtgen1::cxx_qt::my_object { +namespace cxx_qt::my_object::rust::cxxqtgen1 { ::QMetaObject::Connection MyObject_primitiveChangedConnect( - ::cxx_qt::my_object::MyObject& self, - ::rust::cxxqtgen1::cxx_qt::my_object:: + cxx_qt::my_object::MyObject& self, + ::cxx_qt::my_object::rust::cxxqtgen1:: MyObjectCxxQtSignalHandlerprimitiveChanged closure, ::Qt::ConnectionType type) { return ::QObject::connect( &self, - &::cxx_qt::my_object::MyObject::primitiveChanged, + &cxx_qt::my_object::MyObject::primitiveChanged, &self, [&, closure = ::std::move(closure)]() mutable { - const ::rust::cxxqt1::MaybeLockGuard<::cxx_qt::my_object::MyObject> guard( + const ::rust::cxxqt1::MaybeLockGuard guard( self); - closure.template operator()<::cxx_qt::my_object::MyObject&>(self); + closure.template operator()(self); }, type); } -} // namespace rust::cxxqtgen1::cxx_qt::my_object +} // namespace cxx_qt::my_object::rust::cxxqtgen1 // Define namespace otherwise we hit a GCC bug // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480 namespace rust::cxxqt1 { template<> SignalHandler< - ::rust::cxxqtgen1::cxx_qt::my_object:: + ::cxx_qt::my_object::rust::cxxqtgen1:: MyObjectCxxQtSignalParamstrivialChanged*>::~SignalHandler() noexcept { if (data[0] == nullptr && data[1] == nullptr) { @@ -76,45 +76,45 @@ SignalHandler< template<> template<> void -SignalHandler<::rust::cxxqtgen1::cxx_qt::my_object:: +SignalHandler<::cxx_qt::my_object::rust::cxxqtgen1:: MyObjectCxxQtSignalParamstrivialChanged*>:: -operator()<::cxx_qt::my_object::MyObject&>(::cxx_qt::my_object::MyObject& self) +operator()(cxx_qt::my_object::MyObject& self) { call_MyObject_signal_handler_trivialChanged(*this, self); } static_assert( - alignof(SignalHandler<::rust::cxxqtgen1::cxx_qt::my_object:: + alignof(SignalHandler<::cxx_qt::my_object::rust::cxxqtgen1:: MyObjectCxxQtSignalParamstrivialChanged*>) <= alignof(::std::size_t), "unexpected aligment"); static_assert( - sizeof(SignalHandler<::rust::cxxqtgen1::cxx_qt::my_object:: + sizeof(SignalHandler<::cxx_qt::my_object::rust::cxxqtgen1:: MyObjectCxxQtSignalParamstrivialChanged*>) == sizeof(::std::size_t[2]), "unexpected size"); } // namespace rust::cxxqt1 -namespace rust::cxxqtgen1::cxx_qt::my_object { +namespace cxx_qt::my_object::rust::cxxqtgen1 { ::QMetaObject::Connection MyObject_trivialChangedConnect( - ::cxx_qt::my_object::MyObject& self, - ::rust::cxxqtgen1::cxx_qt::my_object::MyObjectCxxQtSignalHandlertrivialChanged + cxx_qt::my_object::MyObject& self, + ::cxx_qt::my_object::rust::cxxqtgen1::MyObjectCxxQtSignalHandlertrivialChanged closure, ::Qt::ConnectionType type) { return ::QObject::connect( &self, - &::cxx_qt::my_object::MyObject::trivialChanged, + &cxx_qt::my_object::MyObject::trivialChanged, &self, [&, closure = ::std::move(closure)]() mutable { - const ::rust::cxxqt1::MaybeLockGuard<::cxx_qt::my_object::MyObject> guard( + const ::rust::cxxqt1::MaybeLockGuard guard( self); - closure.template operator()<::cxx_qt::my_object::MyObject&>(self); + closure.template operator()(self); }, type); } -} // namespace rust::cxxqtgen1::cxx_qt::my_object +} // namespace cxx_qt::my_object::rust::cxxqtgen1 namespace cxx_qt::my_object { ::std::int32_t const& @@ -131,7 +131,7 @@ MyObject::setPrimitive(::std::int32_t const& value) setPrimitiveWrapper(value); } -::QPoint const& +QPoint const& MyObject::getTrivial() const { const ::rust::cxxqt1::MaybeLockGuard guard(*this); @@ -139,7 +139,7 @@ MyObject::getTrivial() const } void -MyObject::setTrivial(::QPoint const& value) +MyObject::setTrivial(QPoint const& value) { const ::rust::cxxqt1::MaybeLockGuard guard(*this); setTrivialWrapper(value); diff --git a/crates/cxx-qt-gen/test_outputs/properties.h b/crates/cxx-qt-gen/test_outputs/properties.h index a63022976..7efa9d489 100644 --- a/crates/cxx-qt-gen/test_outputs/properties.h +++ b/crates/cxx-qt-gen/test_outputs/properties.h @@ -10,36 +10,36 @@ class MyObject; } // namespace cxx_qt::my_object -namespace rust::cxxqtgen1::cxx_qt::my_object { +namespace cxx_qt::my_object::rust::cxxqtgen1 { using MyObjectCxxQtSignalHandlerprimitiveChanged = ::rust::cxxqt1::SignalHandler< struct MyObjectCxxQtSignalParamsprimitiveChanged*>; -} // namespace rust::cxxqtgen1::cxx_qt::my_object +} // namespace cxx_qt::my_object::rust::cxxqtgen1 -namespace rust::cxxqtgen1::cxx_qt::my_object { +namespace cxx_qt::my_object::rust::cxxqtgen1 { using MyObjectCxxQtSignalHandlertrivialChanged = ::rust::cxxqt1::SignalHandler< struct MyObjectCxxQtSignalParamstrivialChanged*>; -} // namespace rust::cxxqtgen1::cxx_qt::my_object +} // namespace cxx_qt::my_object::rust::cxxqtgen1 #include "cxx-qt-gen/ffi.cxx.h" -namespace rust::cxxqtgen1::cxx_qt::my_object { +namespace cxx_qt::my_object::rust::cxxqtgen1 { ::QMetaObject::Connection MyObject_primitiveChangedConnect( - ::cxx_qt::my_object::MyObject& self, - ::rust::cxxqtgen1::cxx_qt::my_object:: + cxx_qt::my_object::MyObject& self, + ::cxx_qt::my_object::rust::cxxqtgen1:: MyObjectCxxQtSignalHandlerprimitiveChanged closure, ::Qt::ConnectionType type); -} // namespace rust::cxxqtgen1::cxx_qt::my_object +} // namespace cxx_qt::my_object::rust::cxxqtgen1 -namespace rust::cxxqtgen1::cxx_qt::my_object { +namespace cxx_qt::my_object::rust::cxxqtgen1 { ::QMetaObject::Connection MyObject_trivialChangedConnect( - ::cxx_qt::my_object::MyObject& self, - ::rust::cxxqtgen1::cxx_qt::my_object::MyObjectCxxQtSignalHandlertrivialChanged + cxx_qt::my_object::MyObject& self, + ::cxx_qt::my_object::rust::cxxqtgen1::MyObjectCxxQtSignalHandlertrivialChanged closure, ::Qt::ConnectionType type); -} // namespace rust::cxxqtgen1::cxx_qt::my_object +} // namespace cxx_qt::my_object::rust::cxxqtgen1 namespace cxx_qt::my_object { class MyObject @@ -52,15 +52,15 @@ class MyObject Q_PROPERTY(::std::int32_t primitive READ getPrimitive WRITE setPrimitive NOTIFY primitiveChanged) Q_PROPERTY( - ::QPoint trivial READ getTrivial WRITE setTrivial NOTIFY trivialChanged) + QPoint trivial READ getTrivial WRITE setTrivial NOTIFY trivialChanged) virtual ~MyObject() = default; public: ::std::int32_t const& getPrimitive() const; Q_SLOT void setPrimitive(::std::int32_t const& value); - ::QPoint const& getTrivial() const; - Q_SLOT void setTrivial(::QPoint const& value); + QPoint const& getTrivial() const; + Q_SLOT void setTrivial(QPoint const& value); Q_SIGNAL void primitiveChanged(); Q_SIGNAL void trivialChanged(); explicit MyObject(QObject* parent = nullptr); @@ -68,8 +68,8 @@ class MyObject private: ::std::int32_t const& getPrimitiveWrapper() const noexcept; void setPrimitiveWrapper(::std::int32_t value) noexcept; - ::QPoint const& getTrivialWrapper() const noexcept; - void setTrivialWrapper(::QPoint value) noexcept; + QPoint const& getTrivialWrapper() const noexcept; + void setTrivialWrapper(QPoint value) noexcept; }; static_assert(::std::is_base_of::value, diff --git a/crates/cxx-qt-gen/test_outputs/properties.rs b/crates/cxx-qt-gen/test_outputs/properties.rs index 147401b96..3be6bc00e 100644 --- a/crates/cxx-qt-gen/test_outputs/properties.rs +++ b/crates/cxx-qt-gen/test_outputs/properties.rs @@ -56,12 +56,12 @@ mod ffi { } unsafe extern "C++" { #[doc(hidden)] - #[namespace = "rust::cxxqtgen1::cxx_qt::my_object"] + #[namespace = "cxx_qt::my_object::rust::cxxqtgen1"] type MyObjectCxxQtSignalHandlerprimitiveChanged = cxx_qt::signalhandler::CxxQtSignalHandler< super::MyObjectCxxQtSignalClosureprimitiveChanged, >; #[doc(hidden)] - #[namespace = "rust::cxxqtgen1::cxx_qt::my_object"] + #[namespace = "cxx_qt::my_object::rust::cxxqtgen1"] #[must_use] #[rust_name = "MyObject_connect_primitive_changed"] fn MyObject_primitiveChangedConnect( @@ -70,7 +70,7 @@ mod ffi { conn_type: CxxQtConnectionType, ) -> CxxQtQMetaObjectConnection; } - #[namespace = "rust::cxxqtgen1::cxx_qt::my_object"] + #[namespace = "cxx_qt::my_object::rust::cxxqtgen1"] extern "Rust" { #[doc(hidden)] fn drop_MyObject_signal_handler_primitiveChanged( @@ -89,12 +89,12 @@ mod ffi { } unsafe extern "C++" { #[doc(hidden)] - #[namespace = "rust::cxxqtgen1::cxx_qt::my_object"] + #[namespace = "cxx_qt::my_object::rust::cxxqtgen1"] type MyObjectCxxQtSignalHandlertrivialChanged = cxx_qt::signalhandler::CxxQtSignalHandler< super::MyObjectCxxQtSignalClosuretrivialChanged, >; #[doc(hidden)] - #[namespace = "rust::cxxqtgen1::cxx_qt::my_object"] + #[namespace = "cxx_qt::my_object::rust::cxxqtgen1"] #[must_use] #[rust_name = "MyObject_connect_trivial_changed"] fn MyObject_trivialChangedConnect( @@ -103,7 +103,7 @@ mod ffi { conn_type: CxxQtConnectionType, ) -> CxxQtQMetaObjectConnection; } - #[namespace = "rust::cxxqtgen1::cxx_qt::my_object"] + #[namespace = "cxx_qt::my_object::rust::cxxqtgen1"] extern "Rust" { #[doc(hidden)] fn drop_MyObject_signal_handler_trivialChanged( @@ -216,7 +216,7 @@ impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure for MyObjectCxxQtSignalClosureprimitiveChanged { type Id = cxx::type_id!( - "::rust::cxxqtgen1::cxx_qt::my_object::MyObjectCxxQtSignalHandlerprimitiveChanged" + "::cxx_qt::my_object::rust::cxxqtgen1::MyObjectCxxQtSignalHandlerprimitiveChanged" ); type FnType = dyn FnMut(core::pin::Pin<&mut ffi::MyObject>); } @@ -266,7 +266,7 @@ impl ffi::MyObject { pub struct MyObjectCxxQtSignalClosuretrivialChanged {} impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure for MyObjectCxxQtSignalClosuretrivialChanged { type Id = cxx::type_id!( - "::rust::cxxqtgen1::cxx_qt::my_object::MyObjectCxxQtSignalHandlertrivialChanged" + "::cxx_qt::my_object::rust::cxxqtgen1::MyObjectCxxQtSignalHandlertrivialChanged" ); type FnType = dyn FnMut(core::pin::Pin<&mut ffi::MyObject>); } diff --git a/crates/cxx-qt-gen/test_outputs/qenum.cpp b/crates/cxx-qt-gen/test_outputs/qenum.cpp index a7daf6ea0..8fd4a4ddf 100644 --- a/crates/cxx-qt-gen/test_outputs/qenum.cpp +++ b/crates/cxx-qt-gen/test_outputs/qenum.cpp @@ -2,8 +2,8 @@ namespace cxx_qt::my_object { void -MyObject::myInvokable(::cxx_qt::my_object::MyEnum qenum, - ::cxx_qt::my_object::MyOtherEnum other_qenum) const +MyObject::myInvokable(cxx_qt::my_object::MyEnum qenum, + cxx_qt::my_object::MyOtherEnum other_qenum) const { const ::rust::cxxqt1::MaybeLockGuard guard(*this); myInvokableWrapper(qenum, other_qenum); diff --git a/crates/cxx-qt-gen/test_outputs/qenum.h b/crates/cxx-qt-gen/test_outputs/qenum.h index ae9b78b43..7ec5b1da7 100644 --- a/crates/cxx-qt-gen/test_outputs/qenum.h +++ b/crates/cxx-qt-gen/test_outputs/qenum.h @@ -83,14 +83,14 @@ class MyObject public: Q_INVOKABLE void myInvokable( - ::cxx_qt::my_object::MyEnum qenum, - ::cxx_qt::my_object::MyOtherEnum other_qenum) const; + cxx_qt::my_object::MyEnum qenum, + cxx_qt::my_object::MyOtherEnum other_qenum) const; explicit MyObject(QObject* parent = nullptr); private: void myInvokableWrapper( - ::cxx_qt::my_object::MyEnum qenum, - ::cxx_qt::my_object::MyOtherEnum other_qenum) const noexcept; + cxx_qt::my_object::MyEnum qenum, + cxx_qt::my_object::MyOtherEnum other_qenum) const noexcept; }; static_assert(::std::is_base_of::value, diff --git a/crates/cxx-qt-gen/test_outputs/signals.cpp b/crates/cxx-qt-gen/test_outputs/signals.cpp index bec6791e8..6930eaf89 100644 --- a/crates/cxx-qt-gen/test_outputs/signals.cpp +++ b/crates/cxx-qt-gen/test_outputs/signals.cpp @@ -4,7 +4,7 @@ // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480 namespace rust::cxxqt1 { template<> -SignalHandler<::rust::cxxqtgen1::cxx_qt::my_object:: +SignalHandler<::cxx_qt::my_object::rust::cxxqtgen1:: QTimerCxxQtSignalParamstimeout*>::~SignalHandler() noexcept { if (data[0] == nullptr && data[1] == nullptr) { @@ -18,8 +18,8 @@ template<> template<> void SignalHandler< - ::rust::cxxqtgen1::cxx_qt::my_object::QTimerCxxQtSignalParamstimeout*>:: -operator()<::cxx_qt::my_object::QTimer&>(::cxx_qt::my_object::QTimer& self) + ::cxx_qt::my_object::rust::cxxqtgen1::QTimerCxxQtSignalParamstimeout*>:: +operator()(cxx_qt::my_object::QTimer& self) { call_QTimer_signal_handler_timeout(*this, self); } @@ -27,42 +27,42 @@ operator()<::cxx_qt::my_object::QTimer&>(::cxx_qt::my_object::QTimer& self) static_assert( alignof( SignalHandler< - ::rust::cxxqtgen1::cxx_qt::my_object::QTimerCxxQtSignalParamstimeout*>) <= + ::cxx_qt::my_object::rust::cxxqtgen1::QTimerCxxQtSignalParamstimeout*>) <= alignof(::std::size_t), "unexpected aligment"); static_assert( sizeof( SignalHandler< - ::rust::cxxqtgen1::cxx_qt::my_object::QTimerCxxQtSignalParamstimeout*>) == + ::cxx_qt::my_object::rust::cxxqtgen1::QTimerCxxQtSignalParamstimeout*>) == sizeof(::std::size_t[2]), "unexpected size"); } // namespace rust::cxxqt1 -namespace rust::cxxqtgen1::cxx_qt::my_object { +namespace cxx_qt::my_object::rust::cxxqtgen1 { ::QMetaObject::Connection QTimer_timeoutConnect( - ::cxx_qt::my_object::QTimer& self, - ::rust::cxxqtgen1::cxx_qt::my_object::QTimerCxxQtSignalHandlertimeout closure, + cxx_qt::my_object::QTimer& self, + ::cxx_qt::my_object::rust::cxxqtgen1::QTimerCxxQtSignalHandlertimeout closure, ::Qt::ConnectionType type) { return ::QObject::connect( &self, - &::cxx_qt::my_object::QTimer::timeout, + &cxx_qt::my_object::QTimer::timeout, &self, [&, closure = ::std::move(closure)]() mutable { - const ::rust::cxxqt1::MaybeLockGuard<::cxx_qt::my_object::QTimer> guard( + const ::rust::cxxqt1::MaybeLockGuard guard( self); - closure.template operator()<::cxx_qt::my_object::QTimer&>(self); + closure.template operator()(self); }, type); } -} // namespace rust::cxxqtgen1::cxx_qt::my_object +} // namespace cxx_qt::my_object::rust::cxxqtgen1 // Define namespace otherwise we hit a GCC bug // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480 namespace rust::cxxqt1 { template<> -SignalHandler<::rust::cxxqtgen1::cxx_qt::my_object:: +SignalHandler<::cxx_qt::my_object::rust::cxxqtgen1:: MyObjectCxxQtSignalParamsready*>::~SignalHandler() noexcept { if (data[0] == nullptr && data[1] == nullptr) { @@ -76,8 +76,8 @@ template<> template<> void SignalHandler< - ::rust::cxxqtgen1::cxx_qt::my_object::MyObjectCxxQtSignalParamsready*>:: -operator()<::cxx_qt::my_object::MyObject&>(::cxx_qt::my_object::MyObject& self) + ::cxx_qt::my_object::rust::cxxqtgen1::MyObjectCxxQtSignalParamsready*>:: +operator()(cxx_qt::my_object::MyObject& self) { call_MyObject_signal_handler_ready(*this, self); } @@ -85,43 +85,43 @@ operator()<::cxx_qt::my_object::MyObject&>(::cxx_qt::my_object::MyObject& self) static_assert( alignof( SignalHandler< - ::rust::cxxqtgen1::cxx_qt::my_object::MyObjectCxxQtSignalParamsready*>) <= + ::cxx_qt::my_object::rust::cxxqtgen1::MyObjectCxxQtSignalParamsready*>) <= alignof(::std::size_t), "unexpected aligment"); static_assert( sizeof( SignalHandler< - ::rust::cxxqtgen1::cxx_qt::my_object::MyObjectCxxQtSignalParamsready*>) == + ::cxx_qt::my_object::rust::cxxqtgen1::MyObjectCxxQtSignalParamsready*>) == sizeof(::std::size_t[2]), "unexpected size"); } // namespace rust::cxxqt1 -namespace rust::cxxqtgen1::cxx_qt::my_object { +namespace cxx_qt::my_object::rust::cxxqtgen1 { ::QMetaObject::Connection MyObject_readyConnect( - ::cxx_qt::my_object::MyObject& self, - ::rust::cxxqtgen1::cxx_qt::my_object::MyObjectCxxQtSignalHandlerready closure, + cxx_qt::my_object::MyObject& self, + ::cxx_qt::my_object::rust::cxxqtgen1::MyObjectCxxQtSignalHandlerready closure, ::Qt::ConnectionType type) { return ::QObject::connect( &self, - &::cxx_qt::my_object::MyObject::ready, + &cxx_qt::my_object::MyObject::ready, &self, [&, closure = ::std::move(closure)]() mutable { - const ::rust::cxxqt1::MaybeLockGuard<::cxx_qt::my_object::MyObject> guard( + const ::rust::cxxqt1::MaybeLockGuard guard( self); - closure.template operator()<::cxx_qt::my_object::MyObject&>(self); + closure.template operator()(self); }, type); } -} // namespace rust::cxxqtgen1::cxx_qt::my_object +} // namespace cxx_qt::my_object::rust::cxxqtgen1 // Define namespace otherwise we hit a GCC bug // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480 namespace rust::cxxqt1 { template<> SignalHandler< - ::rust::cxxqtgen1::cxx_qt::my_object::MyObjectCxxQtSignalParamsdataChanged*>:: + ::cxx_qt::my_object::rust::cxxqtgen1::MyObjectCxxQtSignalParamsdataChanged*>:: ~SignalHandler() noexcept { if (data[0] == nullptr && data[1] == nullptr) { @@ -135,16 +135,16 @@ template<> template<> void SignalHandler< - ::rust::cxxqtgen1::cxx_qt::my_object::MyObjectCxxQtSignalParamsdataChanged*>:: -operator()<::cxx_qt::my_object::MyObject&, + ::cxx_qt::my_object::rust::cxxqtgen1::MyObjectCxxQtSignalParamsdataChanged*>:: +operator(), - ::QPoint, - ::QPoint const&>(::cxx_qt::my_object::MyObject& self, - ::std::int32_t first, - ::std::unique_ptr second, - ::QPoint third, - ::QPoint const& fourth) + QPoint, + QPoint const&>(cxx_qt::my_object::MyObject& self, + ::std::int32_t first, + ::std::unique_ptr second, + QPoint third, + QPoint const& fourth) { call_MyObject_signal_handler_dataChanged(*this, self, @@ -154,53 +154,53 @@ operator()<::cxx_qt::my_object::MyObject&, ::std::move(fourth)); } -static_assert(alignof(SignalHandler<::rust::cxxqtgen1::cxx_qt::my_object:: +static_assert(alignof(SignalHandler<::cxx_qt::my_object::rust::cxxqtgen1:: MyObjectCxxQtSignalParamsdataChanged*>) <= alignof(::std::size_t), "unexpected aligment"); -static_assert(sizeof(SignalHandler<::rust::cxxqtgen1::cxx_qt::my_object:: +static_assert(sizeof(SignalHandler<::cxx_qt::my_object::rust::cxxqtgen1:: MyObjectCxxQtSignalParamsdataChanged*>) == sizeof(::std::size_t[2]), "unexpected size"); } // namespace rust::cxxqt1 -namespace rust::cxxqtgen1::cxx_qt::my_object { +namespace cxx_qt::my_object::rust::cxxqtgen1 { ::QMetaObject::Connection MyObject_dataChangedConnect( - ::cxx_qt::my_object::MyObject& self, - ::rust::cxxqtgen1::cxx_qt::my_object::MyObjectCxxQtSignalHandlerdataChanged + cxx_qt::my_object::MyObject& self, + ::cxx_qt::my_object::rust::cxxqtgen1::MyObjectCxxQtSignalHandlerdataChanged closure, ::Qt::ConnectionType type) { return ::QObject::connect( &self, - &::cxx_qt::my_object::MyObject::dataChanged, + &cxx_qt::my_object::MyObject::dataChanged, &self, [&, closure = ::std::move(closure)](::std::int32_t first, ::std::unique_ptr second, - ::QPoint third, - ::QPoint const& fourth) mutable { - const ::rust::cxxqt1::MaybeLockGuard<::cxx_qt::my_object::MyObject> guard( + QPoint third, + QPoint const& fourth) mutable { + const ::rust::cxxqt1::MaybeLockGuard guard( self); - closure.template operator()<::cxx_qt::my_object::MyObject&, + closure.template operator(), - ::QPoint, - ::QPoint const&>(self, - ::std::move(first), - ::std::move(second), - ::std::move(third), - ::std::move(fourth)); + QPoint, + QPoint const&>(self, + ::std::move(first), + ::std::move(second), + ::std::move(third), + ::std::move(fourth)); }, type); } -} // namespace rust::cxxqtgen1::cxx_qt::my_object +} // namespace cxx_qt::my_object::rust::cxxqtgen1 // Define namespace otherwise we hit a GCC bug // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480 namespace rust::cxxqt1 { template<> -SignalHandler<::rust::cxxqtgen1::cxx_qt::my_object:: +SignalHandler<::cxx_qt::my_object::rust::cxxqtgen1:: MyObjectCxxQtSignalParamsnewData*>::~SignalHandler() noexcept { if (data[0] == nullptr && data[1] == nullptr) { @@ -214,16 +214,16 @@ template<> template<> void SignalHandler< - ::rust::cxxqtgen1::cxx_qt::my_object::MyObjectCxxQtSignalParamsnewData*>:: -operator()<::cxx_qt::my_object::MyObject&, + ::cxx_qt::my_object::rust::cxxqtgen1::MyObjectCxxQtSignalParamsnewData*>:: +operator(), - ::QPoint, - ::QPoint const&>(::cxx_qt::my_object::MyObject& self, - ::std::int32_t first, - ::std::unique_ptr second, - ::QPoint third, - ::QPoint const& fourth) + QPoint, + QPoint const&>(cxx_qt::my_object::MyObject& self, + ::std::int32_t first, + ::std::unique_ptr second, + QPoint third, + QPoint const& fourth) { call_MyObject_signal_handler_newData(*this, self, @@ -233,47 +233,47 @@ operator()<::cxx_qt::my_object::MyObject&, ::std::move(fourth)); } -static_assert(alignof(SignalHandler<::rust::cxxqtgen1::cxx_qt::my_object:: +static_assert(alignof(SignalHandler<::cxx_qt::my_object::rust::cxxqtgen1:: MyObjectCxxQtSignalParamsnewData*>) <= alignof(::std::size_t), "unexpected aligment"); -static_assert(sizeof(SignalHandler<::rust::cxxqtgen1::cxx_qt::my_object:: +static_assert(sizeof(SignalHandler<::cxx_qt::my_object::rust::cxxqtgen1:: MyObjectCxxQtSignalParamsnewData*>) == sizeof(::std::size_t[2]), "unexpected size"); } // namespace rust::cxxqt1 -namespace rust::cxxqtgen1::cxx_qt::my_object { +namespace cxx_qt::my_object::rust::cxxqtgen1 { ::QMetaObject::Connection MyObject_newDataConnect( - ::cxx_qt::my_object::MyObject& self, - ::rust::cxxqtgen1::cxx_qt::my_object::MyObjectCxxQtSignalHandlernewData + cxx_qt::my_object::MyObject& self, + ::cxx_qt::my_object::rust::cxxqtgen1::MyObjectCxxQtSignalHandlernewData closure, ::Qt::ConnectionType type) { return ::QObject::connect( &self, - &::cxx_qt::my_object::MyObject::newData, + &cxx_qt::my_object::MyObject::newData, &self, [&, closure = ::std::move(closure)](::std::int32_t first, ::std::unique_ptr second, - ::QPoint third, - ::QPoint const& fourth) mutable { - const ::rust::cxxqt1::MaybeLockGuard<::cxx_qt::my_object::MyObject> guard( + QPoint third, + QPoint const& fourth) mutable { + const ::rust::cxxqt1::MaybeLockGuard guard( self); - closure.template operator()<::cxx_qt::my_object::MyObject&, + closure.template operator(), - ::QPoint, - ::QPoint const&>(self, - ::std::move(first), - ::std::move(second), - ::std::move(third), - ::std::move(fourth)); + QPoint, + QPoint const&>(self, + ::std::move(first), + ::std::move(second), + ::std::move(third), + ::std::move(fourth)); }, type); } -} // namespace rust::cxxqtgen1::cxx_qt::my_object +} // namespace cxx_qt::my_object::rust::cxxqtgen1 namespace cxx_qt::my_object { void diff --git a/crates/cxx-qt-gen/test_outputs/signals.h b/crates/cxx-qt-gen/test_outputs/signals.h index 65385906a..0c9eb7e4e 100644 --- a/crates/cxx-qt-gen/test_outputs/signals.h +++ b/crates/cxx-qt-gen/test_outputs/signals.h @@ -10,61 +10,61 @@ class MyObject; } // namespace cxx_qt::my_object -namespace rust::cxxqtgen1::cxx_qt::my_object { +namespace cxx_qt::my_object::rust::cxxqtgen1 { using MyObjectCxxQtSignalHandlerready = ::rust::cxxqt1::SignalHandler; -} // namespace rust::cxxqtgen1::cxx_qt::my_object +} // namespace cxx_qt::my_object::rust::cxxqtgen1 -namespace rust::cxxqtgen1::cxx_qt::my_object { +namespace cxx_qt::my_object::rust::cxxqtgen1 { using MyObjectCxxQtSignalHandlerdataChanged = ::rust::cxxqt1::SignalHandler; -} // namespace rust::cxxqtgen1::cxx_qt::my_object +} // namespace cxx_qt::my_object::rust::cxxqtgen1 -namespace rust::cxxqtgen1::cxx_qt::my_object { +namespace cxx_qt::my_object::rust::cxxqtgen1 { using MyObjectCxxQtSignalHandlernewData = ::rust::cxxqt1::SignalHandler; -} // namespace rust::cxxqtgen1::cxx_qt::my_object +} // namespace cxx_qt::my_object::rust::cxxqtgen1 -namespace rust::cxxqtgen1::cxx_qt::my_object { +namespace cxx_qt::my_object::rust::cxxqtgen1 { using QTimerCxxQtSignalHandlertimeout = ::rust::cxxqt1::SignalHandler; -} // namespace rust::cxxqtgen1::cxx_qt::my_object +} // namespace cxx_qt::my_object::rust::cxxqtgen1 #include "cxx-qt-gen/ffi.cxx.h" -namespace rust::cxxqtgen1::cxx_qt::my_object { +namespace cxx_qt::my_object::rust::cxxqtgen1 { ::QMetaObject::Connection QTimer_timeoutConnect( - ::cxx_qt::my_object::QTimer& self, - ::rust::cxxqtgen1::cxx_qt::my_object::QTimerCxxQtSignalHandlertimeout closure, + cxx_qt::my_object::QTimer& self, + ::cxx_qt::my_object::rust::cxxqtgen1::QTimerCxxQtSignalHandlertimeout closure, ::Qt::ConnectionType type); -} // namespace rust::cxxqtgen1::cxx_qt::my_object +} // namespace cxx_qt::my_object::rust::cxxqtgen1 -namespace rust::cxxqtgen1::cxx_qt::my_object { +namespace cxx_qt::my_object::rust::cxxqtgen1 { ::QMetaObject::Connection MyObject_readyConnect( - ::cxx_qt::my_object::MyObject& self, - ::rust::cxxqtgen1::cxx_qt::my_object::MyObjectCxxQtSignalHandlerready closure, + cxx_qt::my_object::MyObject& self, + ::cxx_qt::my_object::rust::cxxqtgen1::MyObjectCxxQtSignalHandlerready closure, ::Qt::ConnectionType type); -} // namespace rust::cxxqtgen1::cxx_qt::my_object +} // namespace cxx_qt::my_object::rust::cxxqtgen1 -namespace rust::cxxqtgen1::cxx_qt::my_object { +namespace cxx_qt::my_object::rust::cxxqtgen1 { ::QMetaObject::Connection MyObject_dataChangedConnect( - ::cxx_qt::my_object::MyObject& self, - ::rust::cxxqtgen1::cxx_qt::my_object::MyObjectCxxQtSignalHandlerdataChanged + cxx_qt::my_object::MyObject& self, + ::cxx_qt::my_object::rust::cxxqtgen1::MyObjectCxxQtSignalHandlerdataChanged closure, ::Qt::ConnectionType type); -} // namespace rust::cxxqtgen1::cxx_qt::my_object +} // namespace cxx_qt::my_object::rust::cxxqtgen1 -namespace rust::cxxqtgen1::cxx_qt::my_object { +namespace cxx_qt::my_object::rust::cxxqtgen1 { ::QMetaObject::Connection MyObject_newDataConnect( - ::cxx_qt::my_object::MyObject& self, - ::rust::cxxqtgen1::cxx_qt::my_object::MyObjectCxxQtSignalHandlernewData + cxx_qt::my_object::MyObject& self, + ::cxx_qt::my_object::rust::cxxqtgen1::MyObjectCxxQtSignalHandlernewData closure, ::Qt::ConnectionType type); -} // namespace rust::cxxqtgen1::cxx_qt::my_object +} // namespace cxx_qt::my_object::rust::cxxqtgen1 namespace cxx_qt::my_object { class MyObject @@ -81,8 +81,8 @@ class MyObject Q_SIGNAL void ready(); Q_SIGNAL void dataChanged(::std::int32_t first, ::std::unique_ptr second, - ::QPoint third, - ::QPoint const& fourth); + QPoint third, + QPoint const& fourth); explicit MyObject(QObject* parent = nullptr); private: diff --git a/crates/cxx-qt-gen/test_outputs/signals.rs b/crates/cxx-qt-gen/test_outputs/signals.rs index 0f774baf3..338345a92 100644 --- a/crates/cxx-qt-gen/test_outputs/signals.rs +++ b/crates/cxx-qt-gen/test_outputs/signals.rs @@ -44,11 +44,11 @@ mod ffi { } unsafe extern "C++" { #[doc(hidden)] - #[namespace = "rust::cxxqtgen1::cxx_qt::my_object"] + #[namespace = "cxx_qt::my_object::rust::cxxqtgen1"] type MyObjectCxxQtSignalHandlerready = cxx_qt::signalhandler::CxxQtSignalHandler; #[doc(hidden)] - #[namespace = "rust::cxxqtgen1::cxx_qt::my_object"] + #[namespace = "cxx_qt::my_object::rust::cxxqtgen1"] #[must_use] #[rust_name = "MyObject_connect_ready"] fn MyObject_readyConnect( @@ -57,7 +57,7 @@ mod ffi { conn_type: CxxQtConnectionType, ) -> CxxQtQMetaObjectConnection; } - #[namespace = "rust::cxxqtgen1::cxx_qt::my_object"] + #[namespace = "cxx_qt::my_object::rust::cxxqtgen1"] extern "Rust" { #[doc(hidden)] fn drop_MyObject_signal_handler_ready(handler: MyObjectCxxQtSignalHandlerready); @@ -79,11 +79,11 @@ mod ffi { } unsafe extern "C++" { #[doc(hidden)] - #[namespace = "rust::cxxqtgen1::cxx_qt::my_object"] + #[namespace = "cxx_qt::my_object::rust::cxxqtgen1"] type MyObjectCxxQtSignalHandlerdataChanged = cxx_qt::signalhandler::CxxQtSignalHandler; #[doc(hidden)] - #[namespace = "rust::cxxqtgen1::cxx_qt::my_object"] + #[namespace = "cxx_qt::my_object::rust::cxxqtgen1"] #[must_use] #[rust_name = "MyObject_connect_data_changed"] fn MyObject_dataChangedConnect( @@ -92,7 +92,7 @@ mod ffi { conn_type: CxxQtConnectionType, ) -> CxxQtQMetaObjectConnection; } - #[namespace = "rust::cxxqtgen1::cxx_qt::my_object"] + #[namespace = "cxx_qt::my_object::rust::cxxqtgen1"] extern "Rust" { #[doc(hidden)] fn drop_MyObject_signal_handler_dataChanged(handler: MyObjectCxxQtSignalHandlerdataChanged); @@ -118,11 +118,11 @@ mod ffi { } unsafe extern "C++" { #[doc(hidden)] - #[namespace = "rust::cxxqtgen1::cxx_qt::my_object"] + #[namespace = "cxx_qt::my_object::rust::cxxqtgen1"] type MyObjectCxxQtSignalHandlernewData = cxx_qt::signalhandler::CxxQtSignalHandler; #[doc(hidden)] - #[namespace = "rust::cxxqtgen1::cxx_qt::my_object"] + #[namespace = "cxx_qt::my_object::rust::cxxqtgen1"] #[must_use] #[rust_name = "MyObject_connect_base_class_new_data"] fn MyObject_newDataConnect( @@ -131,7 +131,7 @@ mod ffi { conn_type: CxxQtConnectionType, ) -> CxxQtQMetaObjectConnection; } - #[namespace = "rust::cxxqtgen1::cxx_qt::my_object"] + #[namespace = "cxx_qt::my_object::rust::cxxqtgen1"] extern "Rust" { #[doc(hidden)] fn drop_MyObject_signal_handler_newData(handler: MyObjectCxxQtSignalHandlernewData); @@ -167,11 +167,11 @@ mod ffi { } unsafe extern "C++" { #[doc(hidden)] - #[namespace = "rust::cxxqtgen1::cxx_qt::my_object"] + #[namespace = "cxx_qt::my_object::rust::cxxqtgen1"] type QTimerCxxQtSignalHandlertimeout = cxx_qt::signalhandler::CxxQtSignalHandler; #[doc(hidden)] - #[namespace = "rust::cxxqtgen1::cxx_qt::my_object"] + #[namespace = "cxx_qt::my_object::rust::cxxqtgen1"] #[must_use] #[rust_name = "QTimer_connect_timeout"] fn QTimer_timeoutConnect( @@ -180,7 +180,7 @@ mod ffi { conn_type: CxxQtConnectionType, ) -> CxxQtQMetaObjectConnection; } - #[namespace = "rust::cxxqtgen1::cxx_qt::my_object"] + #[namespace = "cxx_qt::my_object::rust::cxxqtgen1"] extern "Rust" { #[doc(hidden)] fn drop_QTimer_signal_handler_timeout(handler: QTimerCxxQtSignalHandlertimeout); @@ -232,7 +232,7 @@ impl ffi::MyObject { pub struct MyObjectCxxQtSignalClosureready {} impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure for MyObjectCxxQtSignalClosureready { type Id = - cxx::type_id!("::rust::cxxqtgen1::cxx_qt::my_object::MyObjectCxxQtSignalHandlerready"); + cxx::type_id!("::cxx_qt::my_object::rust::cxxqtgen1::MyObjectCxxQtSignalHandlerready"); type FnType = dyn FnMut(core::pin::Pin<&mut ffi::MyObject>); } use core::mem::drop as drop_MyObject_signal_handler_ready; @@ -307,7 +307,7 @@ impl ffi::MyObject { pub struct MyObjectCxxQtSignalClosuredataChanged {} impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure for MyObjectCxxQtSignalClosuredataChanged { type Id = cxx::type_id!( - "::rust::cxxqtgen1::cxx_qt::my_object::MyObjectCxxQtSignalHandlerdataChanged" + "::cxx_qt::my_object::rust::cxxqtgen1::MyObjectCxxQtSignalHandlerdataChanged" ); type FnType = dyn FnMut( core::pin::Pin<&mut ffi::MyObject>, @@ -393,7 +393,7 @@ impl ffi::MyObject { pub struct MyObjectCxxQtSignalClosurenewData {} impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure for MyObjectCxxQtSignalClosurenewData { type Id = - cxx::type_id!("::rust::cxxqtgen1::cxx_qt::my_object::MyObjectCxxQtSignalHandlernewData"); + cxx::type_id!("::cxx_qt::my_object::rust::cxxqtgen1::MyObjectCxxQtSignalHandlernewData"); type FnType = dyn FnMut( core::pin::Pin<&mut ffi::MyObject>, i32, @@ -482,7 +482,7 @@ impl ffi::QTimer { pub struct QTimerCxxQtSignalClosuretimeout {} impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure for QTimerCxxQtSignalClosuretimeout { type Id = - cxx::type_id!("::rust::cxxqtgen1::cxx_qt::my_object::QTimerCxxQtSignalHandlertimeout"); + cxx::type_id!("::cxx_qt::my_object::rust::cxxqtgen1::QTimerCxxQtSignalHandlertimeout"); type FnType = dyn FnMut(core::pin::Pin<&mut ffi::QTimer>); } use core::mem::drop as drop_QTimer_signal_handler_timeout;