From 048a2ba5bb90a48142ef5cba0682c6bd0fad6bea Mon Sep 17 00:00:00 2001 From: Andrew Hayzen Date: Fri, 21 Jul 2023 13:47:14 +0100 Subject: [PATCH] cxx-qt-gen: use qualified mappings in impl T as well Related to #404 --- .../src/generator/rust/cxxqttype.rs | 22 +++++++++---- .../src/generator/rust/property/getter.rs | 6 ++-- .../src/generator/rust/property/setter.rs | 9 ++++-- .../cxx-qt-gen/src/generator/rust/qobject.rs | 16 +++++++--- .../cxx-qt-gen/src/generator/rust/signals.rs | 6 ++-- .../src/generator/rust/threading.rs | 23 ++++++++++---- crates/cxx-qt-gen/src/generator/utils/rust.rs | 31 +++++++++++++++++-- crates/cxx-qt-gen/test_outputs/inheritance.rs | 6 ++-- crates/cxx-qt-gen/test_outputs/invokables.rs | 14 ++++----- .../test_outputs/passthrough_and_naming.rs | 26 ++++++++-------- crates/cxx-qt-gen/test_outputs/properties.rs | 18 +++++------ crates/cxx-qt-gen/test_outputs/signals.rs | 12 +++---- 12 files changed, 125 insertions(+), 64 deletions(-) diff --git a/crates/cxx-qt-gen/src/generator/rust/cxxqttype.rs b/crates/cxx-qt-gen/src/generator/rust/cxxqttype.rs index ea96b3d90..3da02005f 100644 --- a/crates/cxx-qt-gen/src/generator/rust/cxxqttype.rs +++ b/crates/cxx-qt-gen/src/generator/rust/cxxqttype.rs @@ -3,17 +3,27 @@ // // SPDX-License-Identifier: MIT OR Apache-2.0 -use crate::generator::{naming::qobject::QObjectName, rust::qobject::GeneratedRustQObjectBlocks}; +use std::collections::BTreeMap; + +use crate::generator::{ + naming::qobject::QObjectName, rust::qobject::GeneratedRustQObjectBlocks, + utils::rust::syn_ident_cxx_bridge_to_qualified_impl, +}; use quote::quote; -use syn::Result; +use syn::{Ident, Path, Result}; use super::fragment::RustFragmentPair; -pub fn generate(qobject_ident: &QObjectName) -> Result { +pub fn generate( + qobject_ident: &QObjectName, + qualified_mappings: &BTreeMap, +) -> Result { let mut blocks = GeneratedRustQObjectBlocks::default(); let cpp_struct_ident = &qobject_ident.cpp_class.rust; let rust_struct_ident = &qobject_ident.rust_struct.rust; + let qualified_impl = + syn_ident_cxx_bridge_to_qualified_impl(cpp_struct_ident, qualified_mappings); let fragment = RustFragmentPair { cxx_bridge: vec![ @@ -34,7 +44,7 @@ pub fn generate(qobject_ident: &QObjectName) -> Result &Self::Target { @@ -43,7 +53,7 @@ pub fn generate(qobject_ident: &QObjectName) -> Result &Self::Rust { @@ -81,7 +91,7 @@ mod tests { let qobject = create_parsed_qobject(); let qobject_idents = QObjectName::from(&qobject); - let generated = generate(&qobject_idents).unwrap(); + let generated = generate(&qobject_idents, &BTreeMap::::default()).unwrap(); assert_eq!(generated.cxx_mod_contents.len(), 2); assert_eq!(generated.cxx_qt_mod_contents.len(), 2); diff --git a/crates/cxx-qt-gen/src/generator/rust/property/getter.rs b/crates/cxx-qt-gen/src/generator/rust/property/getter.rs index f8a2dcbf1..6c995feca 100644 --- a/crates/cxx-qt-gen/src/generator/rust/property/getter.rs +++ b/crates/cxx-qt-gen/src/generator/rust/property/getter.rs @@ -6,7 +6,7 @@ use crate::generator::{ naming::{property::QPropertyName, qobject::QObjectName}, rust::fragment::RustFragmentPair, - utils::rust::syn_type_cxx_bridge_to_qualified, + utils::rust::{syn_ident_cxx_bridge_to_qualified_impl, syn_type_cxx_bridge_to_qualified}, }; use quote::quote; use std::collections::BTreeMap; @@ -24,6 +24,8 @@ pub fn generate( let ident = &idents.name.rust; let ident_str = ident.to_string(); let qualified_ty = syn_type_cxx_bridge_to_qualified(cxx_ty, qualified_mappings); + let qualified_impl = + syn_ident_cxx_bridge_to_qualified_impl(cpp_class_name_rust, qualified_mappings); RustFragmentPair { cxx_bridge: vec![quote! { @@ -33,7 +35,7 @@ pub fn generate( } }], implementation: vec![quote! { - impl #cpp_class_name_rust { + impl #qualified_impl { #[doc = "Getter for the Q_PROPERTY "] #[doc = #ident_str] pub fn #getter_rust(&self) -> &#qualified_ty { diff --git a/crates/cxx-qt-gen/src/generator/rust/property/setter.rs b/crates/cxx-qt-gen/src/generator/rust/property/setter.rs index 8b40983b8..5be0b8851 100644 --- a/crates/cxx-qt-gen/src/generator/rust/property/setter.rs +++ b/crates/cxx-qt-gen/src/generator/rust/property/setter.rs @@ -6,7 +6,10 @@ use crate::generator::{ naming::{property::QPropertyName, qobject::QObjectName}, rust::fragment::RustFragmentPair, - utils::rust::{syn_type_cxx_bridge_to_qualified, syn_type_is_cxx_bridge_unsafe}, + utils::rust::{ + syn_ident_cxx_bridge_to_qualified_impl, syn_type_cxx_bridge_to_qualified, + syn_type_is_cxx_bridge_unsafe, + }, }; use quote::quote; use std::collections::BTreeMap; @@ -25,6 +28,8 @@ pub fn generate( let ident_str = ident.to_string(); let notify_ident = &idents.notify.rust; let qualified_ty = syn_type_cxx_bridge_to_qualified(cxx_ty, qualified_mappings); + let qualified_impl = + syn_ident_cxx_bridge_to_qualified_impl(cpp_class_name_rust, qualified_mappings); // Determine if unsafe is required due to an unsafe type let has_unsafe = if syn_type_is_cxx_bridge_unsafe(cxx_ty) { @@ -41,7 +46,7 @@ pub fn generate( } }], implementation: vec![quote! { - impl #cpp_class_name_rust { + impl #qualified_impl { #[doc = "Setter for the Q_PROPERTY "] #[doc = #ident_str] pub fn #setter_rust(mut self: core::pin::Pin<&mut Self>, value: #qualified_ty) { diff --git a/crates/cxx-qt-gen/src/generator/rust/qobject.rs b/crates/cxx-qt-gen/src/generator/rust/qobject.rs index b11fd40ca..313f58dae 100644 --- a/crates/cxx-qt-gen/src/generator/rust/qobject.rs +++ b/crates/cxx-qt-gen/src/generator/rust/qobject.rs @@ -13,6 +13,7 @@ use crate::{ invokable::generate_rust_invokables, property::generate_rust_properties, signals::generate_rust_signals, threading, }, + utils::rust::syn_ident_cxx_bridge_to_qualified_impl, }, parser::qobject::ParsedQObject, }; @@ -125,6 +126,7 @@ impl GeneratedRustQObject { generated.blocks.append(&mut threading::generate( &qobject_idents, &namespace_idents, + qualified_mappings, )?); } @@ -133,12 +135,15 @@ impl GeneratedRustQObject { // This could be implemented using an auto trait in the future once stable // https://doc.rust-lang.org/beta/unstable-book/language-features/auto-traits.html if qobject.locking { - let cpp_class_name_rust = &qobject_idents.cpp_class.rust; + let qualified_impl = syn_ident_cxx_bridge_to_qualified_impl( + &qobject_idents.cpp_class.rust, + qualified_mappings, + ); generated .blocks .cxx_qt_mod_contents .push(syn::parse_quote! { - impl cxx_qt::Locking for #cpp_class_name_rust {} + impl cxx_qt::Locking for #qualified_impl {} }); } @@ -148,9 +153,10 @@ impl GeneratedRustQObject { &namespace_idents, )?); - generated - .blocks - .append(&mut cxxqttype::generate(&qobject_idents)?); + generated.blocks.append(&mut cxxqttype::generate( + &qobject_idents, + qualified_mappings, + )?); Ok(generated) } diff --git a/crates/cxx-qt-gen/src/generator/rust/signals.rs b/crates/cxx-qt-gen/src/generator/rust/signals.rs index 8d0acedac..3406e5251 100644 --- a/crates/cxx-qt-gen/src/generator/rust/signals.rs +++ b/crates/cxx-qt-gen/src/generator/rust/signals.rs @@ -9,7 +9,7 @@ use crate::{ generator::{ naming::{qobject::QObjectName, signals::QSignalName}, rust::{fragment::RustFragmentPair, qobject::GeneratedRustQObjectBlocks}, - utils::rust::syn_type_cxx_bridge_to_qualified, + utils::rust::{syn_ident_cxx_bridge_to_qualified_impl, syn_type_cxx_bridge_to_qualified}, }, parser::signals::ParsedSignal, }; @@ -64,6 +64,8 @@ pub fn generate_rust_signals( }; let self_type_qualified = syn_type_cxx_bridge_to_qualified(&self_type_cxx, qualified_mappings); + let qualified_impl = + syn_ident_cxx_bridge_to_qualified_impl(qobject_name, qualified_mappings); let mut unsafe_block = None; let mut unsafe_call = Some(quote! { unsafe }); @@ -94,7 +96,7 @@ pub fn generate_rust_signals( }, ], implementation: vec![quote! { - impl #qobject_name { + impl #qualified_impl { #[doc = "Connect the given function pointer to the signal "] #[doc = #signal_name_cpp_str] #[doc = ", so that when the signal is emitted the function pointer is executed."] diff --git a/crates/cxx-qt-gen/src/generator/rust/threading.rs b/crates/cxx-qt-gen/src/generator/rust/threading.rs index 1f897dc3e..1bedea450 100644 --- a/crates/cxx-qt-gen/src/generator/rust/threading.rs +++ b/crates/cxx-qt-gen/src/generator/rust/threading.rs @@ -3,21 +3,25 @@ // // SPDX-License-Identifier: MIT OR Apache-2.0 +use std::collections::BTreeMap; + use crate::generator::{ naming::{ namespace::{namespace_combine_ident, NamespaceName}, qobject::QObjectName, }, rust::qobject::GeneratedRustQObjectBlocks, + utils::rust::syn_ident_cxx_bridge_to_qualified_impl, }; use quote::quote; -use syn::Result; +use syn::{Ident, Path, Result}; use super::fragment::RustFragmentPair; pub fn generate( qobject_ident: &QObjectName, namespace_ident: &NamespaceName, + qualified_mappings: &BTreeMap, ) -> Result { let mut blocks = GeneratedRustQObjectBlocks::default(); @@ -30,6 +34,8 @@ pub fn generate( let namespace_internals = &namespace_ident.internal; let cxx_qt_thread_ident_type_id_str = namespace_combine_ident(&namespace_ident.namespace, cxx_qt_thread_ident); + let qualified_impl = + syn_ident_cxx_bridge_to_qualified_impl(cpp_struct_ident, qualified_mappings); let fragment = RustFragmentPair { cxx_bridge: vec![ @@ -81,7 +87,7 @@ pub fn generate( ], implementation: vec![ quote! { - impl cxx_qt::Threading for #cpp_struct_ident { + impl cxx_qt::Threading for #qualified_impl { type BoxedQueuedFn = #cxx_qt_thread_queued_fn_ident; type ThreadingTypeId = cxx::type_id!(#cxx_qt_thread_ident_type_id_str); @@ -93,7 +99,7 @@ pub fn generate( #[doc(hidden)] fn queue(cxx_qt_thread: &#cxx_qt_thread_ident, f: F) -> std::result::Result<(), cxx::Exception> where - F: FnOnce(core::pin::Pin<&mut #cpp_struct_ident>), + F: FnOnce(core::pin::Pin<&mut #qualified_impl>), F: Send + 'static, { // Wrap the given closure and pass in to C++ function as an opaque type @@ -102,7 +108,7 @@ pub fn generate( #[allow(clippy::boxed_local)] #[doc(hidden)] fn func( - obj: core::pin::Pin<&mut #cpp_struct_ident>, + obj: core::pin::Pin<&mut #qualified_impl>, arg: std::boxed::Box<#cxx_qt_thread_queued_fn_ident>, ) { (arg.inner)(obj) @@ -129,7 +135,7 @@ pub fn generate( pub struct #cxx_qt_thread_queued_fn_ident { // An opaque Rust type is required to be Sized. // https://github.com/dtolnay/cxx/issues/665 - inner: std::boxed::Box) + Send>, + inner: std::boxed::Box) + Send>, } }, ], @@ -159,7 +165,12 @@ mod tests { let qobject_idents = QObjectName::from(&qobject); let namespace_ident = NamespaceName::from(&qobject); - let generated = generate(&qobject_idents, &namespace_ident).unwrap(); + let generated = generate( + &qobject_idents, + &namespace_ident, + &BTreeMap::::default(), + ) + .unwrap(); assert_eq!(generated.cxx_mod_contents.len(), 2); assert_eq!(generated.cxx_qt_mod_contents.len(), 2); diff --git a/crates/cxx-qt-gen/src/generator/utils/rust.rs b/crates/cxx-qt-gen/src/generator/utils/rust.rs index 93ec9df64..93787f403 100644 --- a/crates/cxx-qt-gen/src/generator/utils/rust.rs +++ b/crates/cxx-qt-gen/src/generator/utils/rust.rs @@ -9,6 +9,23 @@ use syn::{ GenericArgument, Ident, Path, PathArguments, PathSegment, ReturnType, Type, TypeReference, }; +/// Return a qualified version of the ident that can by used for impl T outside of a CXX bridge +/// +/// Eg MyObject -> ffi::MyObject +/// +/// Note that this does not handle CXX types such as UniquePtr -> cxx::UniquePtr. +/// This is just for resolving impl T {} -> impl module::T {} +pub(crate) fn syn_ident_cxx_bridge_to_qualified_impl( + ident: &syn::Ident, + qualified_mappings: &BTreeMap, +) -> syn::Path { + if let Some(qualified_path) = qualified_mappings.get(ident) { + qualified_path.clone() + } else { + Path::from(ident.clone()) + } +} + /// Return a qualified version of the type that can by used outside of a CXX bridge /// /// Eg Pin -> core::pin::Pin or UniquePtr -> cxx::UniquePtr @@ -78,9 +95,7 @@ pub(crate) fn syn_type_cxx_bridge_to_qualified( // If the path matches a known ident then used the qualified mapping if let Some(ident) = ty_path.path.get_ident() { - if let Some(qualified_path) = qualified_mappings.get(ident) { - ty_path.path = qualified_path.clone(); - } + ty_path.path = syn_ident_cxx_bridge_to_qualified_impl(ident, qualified_mappings); } return Type::Path(ty_path); @@ -271,6 +286,16 @@ mod tests { ); } + #[test] + fn test_syn_ident_cxx_bridge_to_qualified_impl_mapped() { + let mut mappings = BTreeMap::::default(); + mappings.insert(format_ident!("A"), parse_quote! { ffi::B }); + assert_eq!( + syn_ident_cxx_bridge_to_qualified_impl(&parse_quote! { A }, &mappings), + parse_quote! { ffi::B } + ); + } + #[test] fn test_syn_type_is_cxx_bridge_unsafe_path() { assert!(!syn_type_is_cxx_bridge_unsafe(&parse_quote! { i32 })); diff --git a/crates/cxx-qt-gen/test_outputs/inheritance.rs b/crates/cxx-qt-gen/test_outputs/inheritance.rs index 0fe654d26..eedfbdfb6 100644 --- a/crates/cxx-qt-gen/test_outputs/inheritance.rs +++ b/crates/cxx-qt-gen/test_outputs/inheritance.rs @@ -79,18 +79,18 @@ pub mod cxx_qt_inheritance { #[doc(hidden)] type UniquePtr = cxx::UniquePtr; type MyObjectRust = super::MyObjectRust; - impl cxx_qt::Locking for MyObject {} + impl cxx_qt::Locking for inheritance::MyObject {} #[doc(hidden)] pub fn create_rs_my_object_rust() -> std::boxed::Box { std::boxed::Box::new(core::default::Default::default()) } - impl core::ops::Deref for MyObject { + impl core::ops::Deref for inheritance::MyObject { type Target = MyObjectRust; fn deref(&self) -> &Self::Target { self.cxx_qt_ffi_rust() } } - impl cxx_qt::CxxQtType for MyObject { + impl cxx_qt::CxxQtType for inheritance::MyObject { type Rust = MyObjectRust; fn rust(&self) -> &Self::Rust { self.cxx_qt_ffi_rust() diff --git a/crates/cxx-qt-gen/test_outputs/invokables.rs b/crates/cxx-qt-gen/test_outputs/invokables.rs index a77a0284c..306ca4a13 100644 --- a/crates/cxx-qt-gen/test_outputs/invokables.rs +++ b/crates/cxx-qt-gen/test_outputs/invokables.rs @@ -179,7 +179,7 @@ pub mod cxx_qt_ffi { #[doc(hidden)] type UniquePtr = cxx::UniquePtr; type MyObjectRust = super::MyObjectRust; - impl cxx_qt::Threading for MyObject { + impl cxx_qt::Threading for ffi::MyObject { type BoxedQueuedFn = MyObjectCxxQtThreadQueuedFn; type ThreadingTypeId = cxx::type_id!("cxx_qt::my_object::MyObjectCxxQtThread"); fn qt_thread(&self) -> MyObjectCxxQtThread { @@ -191,13 +191,13 @@ pub mod cxx_qt_ffi { f: F, ) -> std::result::Result<(), cxx::Exception> where - F: FnOnce(core::pin::Pin<&mut MyObject>), + F: FnOnce(core::pin::Pin<&mut ffi::MyObject>), F: Send + 'static, { #[allow(clippy::boxed_local)] #[doc(hidden)] fn func( - obj: core::pin::Pin<&mut MyObject>, + obj: core::pin::Pin<&mut ffi::MyObject>, arg: std::boxed::Box, ) { (arg.inner)(obj) @@ -218,9 +218,9 @@ pub mod cxx_qt_ffi { } #[doc(hidden)] pub struct MyObjectCxxQtThreadQueuedFn { - inner: std::boxed::Box) + Send>, + inner: std::boxed::Box) + Send>, } - impl cxx_qt::Locking for MyObject {} + impl cxx_qt::Locking for ffi::MyObject {} #[doc(hidden)] pub fn route_arguments_my_object_0( arg0: i32, @@ -257,13 +257,13 @@ pub mod cxx_qt_ffi { ) { >::initialize(qobject, ()); } - impl core::ops::Deref for MyObject { + impl core::ops::Deref for ffi::MyObject { type Target = MyObjectRust; fn deref(&self) -> &Self::Target { self.cxx_qt_ffi_rust() } } - impl cxx_qt::CxxQtType for MyObject { + impl cxx_qt::CxxQtType for ffi::MyObject { type Rust = MyObjectRust; fn rust(&self) -> &Self::Rust { self.cxx_qt_ffi_rust() 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 f7f087d8a..a41b8899a 100644 --- a/crates/cxx-qt-gen/test_outputs/passthrough_and_naming.rs +++ b/crates/cxx-qt-gen/test_outputs/passthrough_and_naming.rs @@ -218,14 +218,14 @@ pub mod cxx_qt_ffi { type UniquePtr = cxx::UniquePtr; use super::MyTrait; type MyObjectRust = super::MyObjectRust; - impl MyObject { + impl ffi::MyObject { #[doc = "Getter for the Q_PROPERTY "] #[doc = "property_name"] pub fn property_name(&self) -> &i32 { &self.property_name } } - impl MyObject { + impl ffi::MyObject { #[doc = "Setter for the Q_PROPERTY "] #[doc = "property_name"] pub fn set_property_name(mut self: core::pin::Pin<&mut Self>, value: i32) { @@ -236,7 +236,7 @@ pub mod cxx_qt_ffi { self.as_mut().property_name_changed(); } } - impl MyObject { + impl ffi::MyObject { #[doc = "Connect the given function pointer to the signal "] #[doc = "propertyNameChanged"] #[doc = ", so that when the signal is emitted the function pointer is executed."] @@ -250,7 +250,7 @@ pub mod cxx_qt_ffi { self.connect_property_name_changed(func, cxx_qt_lib::ConnectionType::AutoConnection) } } - impl MyObject { + impl ffi::MyObject { #[doc = "Connect the given function pointer to the signal "] #[doc = "ready"] #[doc = ", so that when the signal is emitted the function pointer is executed."] @@ -264,18 +264,18 @@ pub mod cxx_qt_ffi { self.connect_ready(func, cxx_qt_lib::ConnectionType::AutoConnection) } } - impl cxx_qt::Locking for MyObject {} + impl cxx_qt::Locking for ffi::MyObject {} #[doc(hidden)] pub fn create_rs_my_object_rust() -> std::boxed::Box { std::boxed::Box::new(core::default::Default::default()) } - impl core::ops::Deref for MyObject { + impl core::ops::Deref for ffi::MyObject { type Target = MyObjectRust; fn deref(&self) -> &Self::Target { self.cxx_qt_ffi_rust() } } - impl cxx_qt::CxxQtType for MyObject { + impl cxx_qt::CxxQtType for ffi::MyObject { type Rust = MyObjectRust; fn rust(&self) -> &Self::Rust { self.cxx_qt_ffi_rust() @@ -285,14 +285,14 @@ pub mod cxx_qt_ffi { } } type SecondObjectRust = super::SecondObjectRust; - impl SecondObject { + impl ffi::SecondObject { #[doc = "Getter for the Q_PROPERTY "] #[doc = "property_name"] pub fn property_name(&self) -> &i32 { &self.property_name } } - impl SecondObject { + impl ffi::SecondObject { #[doc = "Setter for the Q_PROPERTY "] #[doc = "property_name"] pub fn set_property_name(mut self: core::pin::Pin<&mut Self>, value: i32) { @@ -303,7 +303,7 @@ pub mod cxx_qt_ffi { self.as_mut().property_name_changed(); } } - impl SecondObject { + impl ffi::SecondObject { #[doc = "Connect the given function pointer to the signal "] #[doc = "propertyNameChanged"] #[doc = ", so that when the signal is emitted the function pointer is executed."] @@ -317,7 +317,7 @@ pub mod cxx_qt_ffi { self.connect_property_name_changed(func, cxx_qt_lib::ConnectionType::AutoConnection) } } - impl SecondObject { + impl ffi::SecondObject { #[doc = "Connect the given function pointer to the signal "] #[doc = "ready"] #[doc = ", so that when the signal is emitted the function pointer is executed."] @@ -335,13 +335,13 @@ pub mod cxx_qt_ffi { pub fn create_rs_second_object_rust() -> std::boxed::Box { std::boxed::Box::new(core::default::Default::default()) } - impl core::ops::Deref for SecondObject { + impl core::ops::Deref for ffi::SecondObject { type Target = SecondObjectRust; fn deref(&self) -> &Self::Target { self.cxx_qt_ffi_rust() } } - impl cxx_qt::CxxQtType for SecondObject { + impl cxx_qt::CxxQtType for ffi::SecondObject { type Rust = SecondObjectRust; fn rust(&self) -> &Self::Rust { self.cxx_qt_ffi_rust() diff --git a/crates/cxx-qt-gen/test_outputs/properties.rs b/crates/cxx-qt-gen/test_outputs/properties.rs index 24d13c5ca..3ddb0ba4f 100644 --- a/crates/cxx-qt-gen/test_outputs/properties.rs +++ b/crates/cxx-qt-gen/test_outputs/properties.rs @@ -108,14 +108,14 @@ pub mod cxx_qt_ffi { #[doc(hidden)] type UniquePtr = cxx::UniquePtr; type MyObjectRust = super::MyObjectRust; - impl MyObject { + impl ffi::MyObject { #[doc = "Getter for the Q_PROPERTY "] #[doc = "primitive"] pub fn primitive(&self) -> &i32 { &self.primitive } } - impl MyObject { + impl ffi::MyObject { #[doc = "Setter for the Q_PROPERTY "] #[doc = "primitive"] pub fn set_primitive(mut self: core::pin::Pin<&mut Self>, value: i32) { @@ -126,14 +126,14 @@ pub mod cxx_qt_ffi { self.as_mut().primitive_changed(); } } - impl MyObject { + impl ffi::MyObject { #[doc = "Getter for the Q_PROPERTY "] #[doc = "trivial"] pub fn trivial(&self) -> &ffi::QPoint { &self.trivial } } - impl MyObject { + impl ffi::MyObject { #[doc = "Setter for the Q_PROPERTY "] #[doc = "trivial"] pub fn set_trivial(mut self: core::pin::Pin<&mut Self>, value: ffi::QPoint) { @@ -144,7 +144,7 @@ pub mod cxx_qt_ffi { self.as_mut().trivial_changed(); } } - impl MyObject { + impl ffi::MyObject { #[doc = "Connect the given function pointer to the signal "] #[doc = "primitiveChanged"] #[doc = ", so that when the signal is emitted the function pointer is executed."] @@ -158,7 +158,7 @@ pub mod cxx_qt_ffi { self.connect_primitive_changed(func, cxx_qt_lib::ConnectionType::AutoConnection) } } - impl MyObject { + impl ffi::MyObject { #[doc = "Connect the given function pointer to the signal "] #[doc = "trivialChanged"] #[doc = ", so that when the signal is emitted the function pointer is executed."] @@ -172,18 +172,18 @@ pub mod cxx_qt_ffi { self.connect_trivial_changed(func, cxx_qt_lib::ConnectionType::AutoConnection) } } - impl cxx_qt::Locking for MyObject {} + impl cxx_qt::Locking for ffi::MyObject {} #[doc(hidden)] pub fn create_rs_my_object_rust() -> std::boxed::Box { std::boxed::Box::new(core::default::Default::default()) } - impl core::ops::Deref for MyObject { + impl core::ops::Deref for ffi::MyObject { type Target = MyObjectRust; fn deref(&self) -> &Self::Target { self.cxx_qt_ffi_rust() } } - impl cxx_qt::CxxQtType for MyObject { + impl cxx_qt::CxxQtType for ffi::MyObject { type Rust = MyObjectRust; fn rust(&self) -> &Self::Rust { self.cxx_qt_ffi_rust() diff --git a/crates/cxx-qt-gen/test_outputs/signals.rs b/crates/cxx-qt-gen/test_outputs/signals.rs index b01871d21..11ee9d874 100644 --- a/crates/cxx-qt-gen/test_outputs/signals.rs +++ b/crates/cxx-qt-gen/test_outputs/signals.rs @@ -135,7 +135,7 @@ pub mod cxx_qt_ffi { #[doc(hidden)] type UniquePtr = cxx::UniquePtr; type MyObjectRust = super::MyObjectRust; - impl MyObject { + impl ffi::MyObject { #[doc = "Connect the given function pointer to the signal "] #[doc = "ready"] #[doc = ", so that when the signal is emitted the function pointer is executed."] @@ -149,7 +149,7 @@ pub mod cxx_qt_ffi { self.connect_ready(func, cxx_qt_lib::ConnectionType::AutoConnection) } } - impl MyObject { + impl ffi::MyObject { #[doc = "Connect the given function pointer to the signal "] #[doc = "dataChanged"] #[doc = ", so that when the signal is emitted the function pointer is executed."] @@ -169,7 +169,7 @@ pub mod cxx_qt_ffi { self.connect_data_changed(func, cxx_qt_lib::ConnectionType::AutoConnection) } } - impl MyObject { + impl ffi::MyObject { #[doc = "Connect the given function pointer to the signal "] #[doc = "newData"] #[doc = ", so that when the signal is emitted the function pointer is executed."] @@ -189,18 +189,18 @@ pub mod cxx_qt_ffi { self.connect_base_class_new_data(func, cxx_qt_lib::ConnectionType::AutoConnection) } } - impl cxx_qt::Locking for MyObject {} + impl cxx_qt::Locking for ffi::MyObject {} #[doc(hidden)] pub fn create_rs_my_object_rust() -> std::boxed::Box { std::boxed::Box::new(core::default::Default::default()) } - impl core::ops::Deref for MyObject { + impl core::ops::Deref for ffi::MyObject { type Target = MyObjectRust; fn deref(&self) -> &Self::Target { self.cxx_qt_ffi_rust() } } - impl cxx_qt::CxxQtType for MyObject { + impl cxx_qt::CxxQtType for ffi::MyObject { type Rust = MyObjectRust; fn rust(&self) -> &Self::Rust { self.cxx_qt_ffi_rust()