diff --git a/crates/cxx-qt-gen/src/generator/cpp/inherit.rs b/crates/cxx-qt-gen/src/generator/cpp/inherit.rs index 41a8c641e..ac599fd3e 100644 --- a/crates/cxx-qt-gen/src/generator/cpp/inherit.rs +++ b/crates/cxx-qt-gen/src/generator/cpp/inherit.rs @@ -35,7 +35,7 @@ pub fn generate( return {base_class}::{func_ident}(args...); }}"#, mutability = if method.mutable { "" } else { " const" }, - func_ident = method.ident.cxx_unqualified(), + func_ident = method.name.cxx_unqualified(), wrapper_ident = method.wrapper_ident(), return_type = return_type.unwrap_or_else(|| "void".to_string()), base_class = base_class diff --git a/crates/cxx-qt-gen/src/generator/rust/inherit.rs b/crates/cxx-qt-gen/src/generator/rust/inherit.rs index cc1a90e09..64ecd1851 100644 --- a/crates/cxx-qt-gen/src/generator/rust/inherit.rs +++ b/crates/cxx-qt-gen/src/generator/rust/inherit.rs @@ -30,6 +30,7 @@ pub fn generate( quote! { #ident: #ty } }) .collect::>(); + let ident = &method.method.sig.ident; let cxx_name_string = &method.wrapper_ident().to_string(); let self_param = if method.mutable { @@ -44,12 +45,16 @@ pub fn generate( if method.safe { std::mem::swap(&mut unsafe_call, &mut unsafe_block); } + let attrs = &method.method.attrs; + let doc_comments = &method.docs; + syn::parse2(quote_spanned! { method.method.span() => #unsafe_block extern "C++" { #(#attrs)* #[cxx_name = #cxx_name_string] + #(#doc_comments)* #unsafe_call fn #ident(#self_param, #(#parameters),*) #return_type; } }) diff --git a/crates/cxx-qt-gen/src/generator/rust/method.rs b/crates/cxx-qt-gen/src/generator/rust/method.rs index 8a8d687c6..a076e519c 100644 --- a/crates/cxx-qt-gen/src/generator/rust/method.rs +++ b/crates/cxx-qt-gen/src/generator/rust/method.rs @@ -37,10 +37,9 @@ pub fn generate_rust_methods( let return_type = &invokable.method.sig.output; - let mut unsafe_block = None; let mut unsafe_call = Some(quote! { unsafe }); if invokable.safe { - std::mem::swap(&mut unsafe_call, &mut unsafe_block); + std::mem::swap(&mut unsafe_call, &mut None); } let fragment = RustFragmentPair { @@ -51,8 +50,8 @@ pub fn generate_rust_methods( // Note that we are exposing a Rust method on the C++ type to C++ // // CXX ends up generating the source, then we generate the matching header. - #[doc(hidden)] #[cxx_name = #wrapper_ident_cpp] + #[doc(hidden)] // TODO: Add #[namespace] of the QObject #unsafe_call fn #invokable_ident_rust(#parameter_signatures) #return_type; } @@ -179,8 +178,8 @@ mod tests { &generated.cxx_mod_contents[0], quote! { extern "Rust" { - #[doc(hidden)] #[cxx_name = "voidInvokableWrapper"] + #[doc(hidden)] fn void_invokable(self: &MyObject); } }, @@ -191,8 +190,8 @@ mod tests { &generated.cxx_mod_contents[1], quote! { extern "Rust" { - #[doc(hidden)] #[cxx_name = "trivialInvokableWrapper"] + #[doc(hidden)] fn trivial_invokable(self: &MyObject, param: i32) -> i32; } }, @@ -203,8 +202,8 @@ mod tests { &generated.cxx_mod_contents[2], quote! { extern "Rust" { - #[doc(hidden)] #[cxx_name = "opaqueInvokableWrapper"] + #[doc(hidden)] fn opaque_invokable(self: Pin<&mut MyObject>, param: &QColor) -> UniquePtr; } }, @@ -215,8 +214,8 @@ mod tests { &generated.cxx_mod_contents[3], quote! { extern "Rust" { - #[doc(hidden)] #[cxx_name = "unsafeInvokableWrapper"] + #[doc(hidden)] unsafe fn unsafe_invokable(self:&MyObject, param: *mut T) -> *mut T; } }, diff --git a/crates/cxx-qt-gen/src/generator/structuring/mod.rs b/crates/cxx-qt-gen/src/generator/structuring/mod.rs index 8f53681a4..1ea39011d 100644 --- a/crates/cxx-qt-gen/src/generator/structuring/mod.rs +++ b/crates/cxx-qt-gen/src/generator/structuring/mod.rs @@ -240,6 +240,31 @@ mod tests { .is_err()); } + #[test] + fn test_inherited_lookup() { + let module = parse_quote! { + #[cxx_qt::bridge] + mod ffi { + extern "RustQt" { + #[qobject] + type MyObject = super::MyObjectRust; + } + + unsafe extern "RustQt" { + #[qinvokable] + #[inherit] + fn test_fn(self: Pin<&mut MyObject>); + } + } + }; + + let parser = Parser::from(module).unwrap(); + let structures = Structures::new(&parser.cxx_qt_data).unwrap(); + + let qobject = structures.qobjects.first().unwrap(); + assert!(qobject.method_lookup(&format_ident!("test_fn")).is_ok()); + } + #[test] fn test_structures() { let module = parse_quote! { diff --git a/crates/cxx-qt-gen/src/generator/structuring/qobject.rs b/crates/cxx-qt-gen/src/generator/structuring/qobject.rs index 791c05187..c4835e7e7 100644 --- a/crates/cxx-qt-gen/src/generator/structuring/qobject.rs +++ b/crates/cxx-qt-gen/src/generator/structuring/qobject.rs @@ -25,6 +25,14 @@ pub struct StructuredQObject<'a> { pub threading: bool, } +fn lookup(invokables: &[T], id: &Ident, name_getter: impl Fn(&T) -> &Name) -> Option { + invokables + .iter() + .map(name_getter) + .find(|name| name.rust_unqualified() == id) + .cloned() +} + impl<'a> StructuredQObject<'a> { pub fn has_qobject_name(&self, ident: &Ident) -> bool { self.declaration.name.rust_unqualified() == ident @@ -44,22 +52,16 @@ impl<'a> StructuredQObject<'a> { } } + /// Returns the name of the method with the provided Rust ident if it exists, or an error pub fn method_lookup(&self, id: &Ident) -> Result { - // TODO account for inherited methods too since those are in a different vector - self.methods - .iter() - .map(|method| &method.name) - .find(|name| name.rust_unqualified() == id) - .cloned() + lookup(&self.methods, id, |method| &method.name) + .or_else(|| lookup(&self.inherited_methods, id, |inherited| &inherited.name)) // fallback to searching inherited methods .ok_or_else(|| Error::new_spanned(id, format!("Method with name '{id}' not found!"))) } + /// Returns the name of the signal with the provided Rust ident if it exists, or an error pub fn signal_lookup(&self, id: &Ident) -> Result { - self.signals - .iter() - .map(|signal| &signal.name) - .find(|name| name.rust_unqualified() == id) - .cloned() + lookup(&self.signals, id, |signal| &signal.name) .ok_or_else(|| Error::new_spanned(id, format!("Signal with name '{id}' not found!"))) } diff --git a/crates/cxx-qt-gen/src/parser/inherit.rs b/crates/cxx-qt-gen/src/parser/inherit.rs index 67e27fdde..989199d07 100644 --- a/crates/cxx-qt-gen/src/parser/inherit.rs +++ b/crates/cxx-qt-gen/src/parser/inherit.rs @@ -3,15 +3,15 @@ // // SPDX-License-Identifier: MIT OR Apache-2.0 +use crate::parser::method::MethodFields; +use crate::parser::{check_safety, separate_docs}; use crate::{ naming::Name, parser::parameter::ParsedFunctionParameter, - syntax::{ - attribute::attribute_take_path, expr::expr_to_string, foreignmod, safety::Safety, types, - }, + syntax::{attribute::attribute_take_path, safety::Safety}, }; use quote::format_ident; -use syn::{spanned::Spanned, Error, ForeignItemFn, Ident, Result}; +use syn::{Attribute, ForeignItemFn, Ident, Result}; /// Describes a method found in an extern "RustQt" with #[inherit] pub struct ParsedInheritedMethod { @@ -26,46 +26,39 @@ pub struct ParsedInheritedMethod { /// the parameters of the method, without the `self` argument pub parameters: Vec, /// the name of the function in Rust, as well as C++ - pub ident: Name, + pub name: Name, + /// All the docs (each line) of the inherited method + pub docs: Vec, } impl ParsedInheritedMethod { pub fn parse(mut method: ForeignItemFn, safety: Safety) -> Result { - if safety == Safety::Unsafe && method.sig.unsafety.is_none() { - return Err(Error::new( - method.span(), - "Inherited methods must be marked as unsafe or wrapped in an `unsafe extern \"RustQt\"` block!", - )); - } - - let self_receiver = foreignmod::self_type_from_foreign_fn(&method.sig)?; - let (qobject_ident, mutability) = types::extract_qobject_ident(&self_receiver.ty)?; - let mutable = mutability.is_some(); - - let parameters = ParsedFunctionParameter::parse_all_ignoring_receiver(&method.sig)?; + check_safety(&method, &safety)?; - let mut ident = - Name::from_rust_ident_and_attrs(&method.sig.ident, &method.attrs, None, None)?; + let docs = separate_docs(&mut method); + let invokable_fields = MethodFields::parse(&method, docs)?; - if let Some(attr) = attribute_take_path(&mut method.attrs, &["cxx_name"]) { - ident = ident.with_cxx_name(expr_to_string(&attr.meta.require_name_value()?.value)?); - } + // This block seems unnecessary but since attrs are passed through on generator/rust/inherit.rs a duplicate attr would occur without it + attribute_take_path(&mut method.attrs, &["cxx_name"]); - let safe = method.sig.unsafety.is_none(); + Ok(Self::from_invokable_fields(invokable_fields, method)) + } - Ok(Self { + fn from_invokable_fields(fields: MethodFields, method: ForeignItemFn) -> Self { + Self { method, - qobject_ident, - mutable, - parameters, - ident, - safe, - }) + qobject_ident: fields.qobject_ident, + mutable: fields.mutable, + safe: fields.safe, + parameters: fields.parameters, + name: fields.name, + docs: fields.docs, + } } /// the name of the wrapper function in C++ pub fn wrapper_ident(&self) -> Ident { - format_ident!("{}CxxQtInherit", self.ident.cxx_unqualified()) + format_ident!("{}CxxQtInherit", self.name.cxx_unqualified()) } } @@ -146,10 +139,10 @@ mod tests { assert_eq!(parsed.qobject_ident, format_ident!("T")); assert_eq!(parsed.parameters.len(), 2); assert_eq!( - parsed.ident.rust_unqualified().to_string(), + parsed.name.rust_unqualified().to_string(), String::from("test") ); - assert_eq!(parsed.ident.cxx_unqualified(), String::from("testFunction")); + assert_eq!(parsed.name.cxx_unqualified(), String::from("testFunction")); assert_eq!( parsed.wrapper_ident(), format_ident!("testFunctionCxxQtInherit") diff --git a/crates/cxx-qt-gen/src/parser/method.rs b/crates/cxx-qt-gen/src/parser/method.rs index a84fe8bfb..29a84adea 100644 --- a/crates/cxx-qt-gen/src/parser/method.rs +++ b/crates/cxx-qt-gen/src/parser/method.rs @@ -6,11 +6,13 @@ use crate::{ naming::Name, parser::parameter::ParsedFunctionParameter, - syntax::{attribute::attribute_take_path, foreignmod, safety::Safety, types}, + syntax::{attribute::attribute_take_path, safety::Safety}, }; use std::collections::HashSet; -use syn::{spanned::Spanned, Error, ForeignItemFn, Ident, Result}; +use syn::{Attribute, Error, ForeignItemFn, Ident, Result}; +use crate::parser::{check_safety, separate_docs}; +use crate::syntax::{foreignmod, types}; #[cfg(test)] use quote::format_ident; @@ -54,10 +56,15 @@ pub struct ParsedMethod { impl ParsedMethod { pub fn parse(mut method: ForeignItemFn, safety: Safety) -> Result { - if safety == Safety::Unsafe && method.sig.unsafety.is_none() { - return Err(Error::new( - method.span(), - "Invokable methods must be marked as unsafe or wrapped in an `unsafe extern \"RustQt\"` block!", + check_safety(&method, &safety)?; + + let docs = separate_docs(&mut method); + let invokable_fields = MethodFields::parse(&method, docs)?; + + if invokable_fields.name.namespace().is_some() { + return Err(Error::new_spanned( + method.sig.ident, + "Methods / QInvokables cannot have a namespace attribute", )); } @@ -72,38 +79,34 @@ impl ParsedMethod { ParsedQInvokableSpecifiers::Virtual, ] { if attribute_take_path(&mut method.attrs, specifier.as_str_slice()).is_some() { - specifiers.insert(specifier); + specifiers.insert(specifier); // Should a fn be able to be Override AND Virtual? } } - // Determine if the invokable is mutable - let self_receiver = foreignmod::self_type_from_foreign_fn(&method.sig)?; - let (qobject_ident, mutability) = types::extract_qobject_ident(&self_receiver.ty)?; - let mutable = mutability.is_some(); - - let parameters = ParsedFunctionParameter::parse_all_ignoring_receiver(&method.sig)?; - - let safe = method.sig.unsafety.is_none(); - - let name = Name::from_rust_ident_and_attrs(&method.sig.ident, &method.attrs, None, None)?; - - if name.namespace().is_some() { - return Err(Error::new_spanned( - method.sig.ident, - "Methods / QInvokables cannot have a namespace attribute", - )); - } + Ok(ParsedMethod::from_invokable_fields( + invokable_fields, + method, + specifiers, + is_qinvokable, + )) + } - Ok(ParsedMethod { + fn from_invokable_fields( + fields: MethodFields, + method: ForeignItemFn, + specifiers: HashSet, + is_qinvokable: bool, + ) -> Self { + Self { method, - qobject_ident, - mutable, - parameters, + qobject_ident: fields.qobject_ident, + mutable: fields.mutable, + safe: fields.safe, + parameters: fields.parameters, specifiers, - safe, is_qinvokable, - name, - }) + name: fields.name, + } } #[cfg(test)] @@ -135,3 +138,35 @@ impl ParsedMethod { } } } + +/// Struct with common fields between Invokable types. +/// These types are ParsedSignal, ParsedMethod and ParsedInheritedMethod +pub struct MethodFields { + pub qobject_ident: Ident, + pub mutable: bool, + pub parameters: Vec, + pub safe: bool, + pub name: Name, + pub docs: Vec, // TODO: Remove this +} + +impl MethodFields { + pub fn parse(method: &ForeignItemFn, docs: Vec) -> Result { + let self_receiver = foreignmod::self_type_from_foreign_fn(&method.sig)?; + let (qobject_ident, mutability) = types::extract_qobject_ident(&self_receiver.ty)?; + let mutable = mutability.is_some(); + + let parameters = ParsedFunctionParameter::parse_all_ignoring_receiver(&method.sig)?; + let safe = method.sig.unsafety.is_none(); + let name = Name::from_rust_ident_and_attrs(&method.sig.ident, &method.attrs, None, None)?; + + Ok(MethodFields { + qobject_ident, + mutable, + parameters, + safe, + name, + docs, + }) + } +} diff --git a/crates/cxx-qt-gen/src/parser/mod.rs b/crates/cxx-qt-gen/src/parser/mod.rs index 815a2b307..46df7135c 100644 --- a/crates/cxx-qt-gen/src/parser/mod.rs +++ b/crates/cxx-qt-gen/src/parser/mod.rs @@ -16,6 +16,7 @@ pub mod qobject; pub mod signals; pub mod trait_impl; +use crate::syntax::safety::Safety; use crate::{ // Used for error handling when resolving the namespace of the qenum. naming::TypeNames, @@ -26,9 +27,31 @@ use syn::{ punctuated::Punctuated, spanned::Spanned, token::{Brace, Semi}, - Error, Ident, Item, ItemMod, Meta, Result, Token, + Attribute, Error, ForeignItemFn, Ident, Item, ItemMod, Meta, Result, Token, }; +fn check_safety(method: &ForeignItemFn, safety: &Safety) -> Result<()> { + if safety == &Safety::Unsafe && method.sig.unsafety.is_none() { + Err(Error::new( + method.span(), + "Invokables must be marked as unsafe or wrapped in an `unsafe extern \"RustQt\"` block!", + )) + } else { + Ok(()) + } +} + +/// Iterate the attributes of the method to extract Doc attributes (doc comments are parsed as this) +/// +/// Note: This modifies the method by removing those doc attributes +pub fn separate_docs(method: &mut ForeignItemFn) -> Vec { + let mut docs = vec![]; + while let Some(doc) = attribute_take_path(&mut method.attrs, &["doc"]) { + docs.push(doc); + } + docs +} + /// A struct representing a module block with CXX-Qt relevant [syn::Item]'s /// parsed into ParsedCxxQtData, to be used later to generate Rust & C++ code. /// diff --git a/crates/cxx-qt-gen/src/parser/signals.rs b/crates/cxx-qt-gen/src/parser/signals.rs index 541996fcc..cd8f300a4 100644 --- a/crates/cxx-qt-gen/src/parser/signals.rs +++ b/crates/cxx-qt-gen/src/parser/signals.rs @@ -6,12 +6,12 @@ use crate::{ naming::Name, parser::parameter::ParsedFunctionParameter, - syntax::{ - attribute::attribute_take_path, foreignmod, path::path_compare_str, safety::Safety, types, - }, + syntax::{attribute::attribute_take_path, path::path_compare_str, safety::Safety}, }; use syn::{spanned::Spanned, Attribute, Error, ForeignItemFn, Ident, Result, Visibility}; +use crate::parser::method::MethodFields; +use crate::parser::{check_safety, separate_docs}; #[cfg(test)] use quote::format_ident; @@ -34,7 +34,7 @@ pub struct ParsedSignal { pub inherit: bool, /// Whether the signal is private pub private: bool, - /// All the doc attributes (each line) of the Signal + /// All the doc attributes (each line) of the signal pub docs: Vec, } @@ -77,58 +77,57 @@ impl ParsedSignal { } pub fn parse(mut method: ForeignItemFn, safety: Safety) -> Result { - if safety == Safety::Unsafe && method.sig.unsafety.is_none() { - return Err(Error::new( - method.span(), - "qsignals methods must be marked as unsafe or wrapped in an `unsafe extern \"RustQt\"` block!", - )); - } - - let self_receiver = foreignmod::self_type_from_foreign_fn(&method.sig)?; - let (qobject_ident, mutability) = types::extract_qobject_ident(&self_receiver.ty)?; - let mutable = mutability.is_some(); - if !mutable { - return Err(Error::new( - method.span(), - "signals must be mutable, use Pin<&mut T> instead of T for the self type", - )); - } - - let parameters = ParsedFunctionParameter::parse_all_ignoring_receiver(&method.sig)?; + check_safety(&method, &safety)?; - let name = Name::from_rust_ident_and_attrs(&method.sig.ident, &method.attrs, None, None)?; + let docs = separate_docs(&mut method); + let invokable_fields = MethodFields::parse(&method, docs)?; - if name.namespace().is_some() { + if invokable_fields.name.namespace().is_some() { return Err(Error::new_spanned( method.sig.ident, "Signals cannot have a namespace attribute", )); } - let mut docs = vec![]; - while let Some(doc) = attribute_take_path(&mut method.attrs, &["doc"]) { - docs.push(doc); + if !invokable_fields.mutable { + return Err(Error::new( + method.span(), + "signals must be mutable, use Pin<&mut T> instead of T for the self type", + )); } let inherit = attribute_take_path(&mut method.attrs, &["inherit"]).is_some(); - let safe = method.sig.unsafety.is_none(); let private = if let Visibility::Restricted(vis_restricted) = &method.vis { path_compare_str(&vis_restricted.path, &["self"]) } else { false }; - Ok(Self { + Ok(Self::from_invokable_fields( + invokable_fields, method, - qobject_ident, - mutable, - parameters, - name, - safe, inherit, private, - docs, - }) + )) + } + + fn from_invokable_fields( + fields: MethodFields, + method: ForeignItemFn, + inherit: bool, + private: bool, + ) -> Self { + Self { + method, + qobject_ident: fields.qobject_ident, + mutable: fields.mutable, + safe: fields.safe, + parameters: fields.parameters, + name: fields.name, + inherit, + private, + docs: fields.docs, + } } } diff --git a/crates/cxx-qt-gen/test_outputs/inheritance.rs b/crates/cxx-qt-gen/test_outputs/inheritance.rs index fbf0daddb..bb0bb61f4 100644 --- a/crates/cxx-qt-gen/test_outputs/inheritance.rs +++ b/crates/cxx-qt-gen/test_outputs/inheritance.rs @@ -34,23 +34,23 @@ mod inheritance { type MyObjectRust; } extern "Rust" { - #[doc(hidden)] #[cxx_name = "dataWrapper"] + #[doc(hidden)] fn data(self: &MyObject, _index: &QModelIndex, _role: i32) -> QVariant; } extern "Rust" { - #[doc(hidden)] #[cxx_name = "hasChildrenWrapper"] + #[doc(hidden)] fn has_children(self: &MyObject, _parent: &QModelIndex) -> bool; } unsafe extern "C++" { - #[doc = " Inherited hasChildren from the base class"] #[cxx_name = "hasChildrenCxxQtInherit"] + #[doc = " Inherited hasChildren from the base class"] fn has_children_super(self: &MyObject, parent: &QModelIndex) -> bool; } extern "C++" { - #[doc = " Inherited fetchMore from the base class"] #[cxx_name = "fetchMoreCxxQtInherit"] + #[doc = " Inherited fetchMore from the base class"] unsafe fn fetch_more(self: Pin<&mut MyObject>, index: &QModelIndex); } extern "Rust" { diff --git a/crates/cxx-qt-gen/test_outputs/invokables.rs b/crates/cxx-qt-gen/test_outputs/invokables.rs index 4d43f4ee4..16a867ff1 100644 --- a/crates/cxx-qt-gen/test_outputs/invokables.rs +++ b/crates/cxx-qt-gen/test_outputs/invokables.rs @@ -41,58 +41,58 @@ mod ffi { type MyObjectRust; } extern "Rust" { - #[doc(hidden)] #[cxx_name = "cppMethodWrapper"] + #[doc(hidden)] fn cpp_method(self: &MyObject); } extern "Rust" { - #[doc(hidden)] #[cxx_name = "invokableWrapper"] + #[doc(hidden)] fn invokable(self: &MyObject); } extern "Rust" { - #[doc(hidden)] #[cxx_name = "invokableMutableWrapper"] + #[doc(hidden)] fn invokable_mutable(self: Pin<&mut MyObject>); } extern "Rust" { - #[doc(hidden)] #[cxx_name = "invokableParametersWrapper"] + #[doc(hidden)] fn invokable_parameters(self: &MyObject, opaque: &QColor, trivial: &QPoint, primitive: i32); } extern "Rust" { - #[doc(hidden)] #[cxx_name = "invokableReturnOpaqueWrapper"] + #[doc(hidden)] fn invokable_return_opaque(self: Pin<&mut MyObject>) -> UniquePtr; } extern "Rust" { - #[doc(hidden)] #[cxx_name = "invokableReturnTrivialWrapper"] + #[doc(hidden)] fn invokable_return_trivial(self: Pin<&mut MyObject>) -> QPoint; } extern "Rust" { - #[doc(hidden)] #[cxx_name = "invokableFinalWrapper"] + #[doc(hidden)] fn invokable_final(self: &MyObject); } extern "Rust" { - #[doc(hidden)] #[cxx_name = "invokableOverrideWrapper"] + #[doc(hidden)] fn invokable_override(self: &MyObject); } extern "Rust" { - #[doc(hidden)] #[cxx_name = "invokableVirtualWrapper"] + #[doc(hidden)] fn invokable_virtual(self: &MyObject); } extern "Rust" { - #[doc(hidden)] #[cxx_name = "invokableResultTupleWrapper"] + #[doc(hidden)] fn invokable_result_tuple(self: &MyObject) -> Result<()>; } extern "Rust" { - #[doc(hidden)] #[cxx_name = "invokableResultTypeWrapper"] + #[doc(hidden)] fn invokable_result_type(self: &MyObject) -> Result; } unsafe extern "C++" { 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 337a073cd..664aa24ab 100644 --- a/crates/cxx-qt-gen/test_outputs/passthrough_and_naming.rs +++ b/crates/cxx-qt-gen/test_outputs/passthrough_and_naming.rs @@ -124,8 +124,8 @@ pub mod ffi { ); } extern "Rust" { - #[doc(hidden)] #[cxx_name = "invokableNameWrapper"] + #[doc(hidden)] fn invokable_name(self: Pin<&mut MyObject>); } unsafe extern "C++" { @@ -226,8 +226,8 @@ pub mod ffi { ); } extern "Rust" { - #[doc(hidden)] #[cxx_name = "invokableNameWrapper"] + #[doc(hidden)] fn invokable_name(self: Pin<&mut SecondObject>); } unsafe extern "C++" { diff --git a/crates/cxx-qt-gen/test_outputs/properties.rs b/crates/cxx-qt-gen/test_outputs/properties.rs index 4e30a6020..c43370cc5 100644 --- a/crates/cxx-qt-gen/test_outputs/properties.rs +++ b/crates/cxx-qt-gen/test_outputs/properties.rs @@ -187,18 +187,18 @@ mod ffi { ); } extern "Rust" { - #[doc(hidden)] #[cxx_name = "myGetterWrapper"] + #[doc(hidden)] fn my_getter(self: &MyObject) -> i32; } extern "Rust" { - #[doc(hidden)] #[cxx_name = "MyCustomSetterWrapper"] + #[doc(hidden)] fn my_setter(self: Pin<&mut MyObject>, value: i32); } extern "Rust" { - #[doc(hidden)] #[cxx_name = "myResetFnWrapper"] + #[doc(hidden)] fn myResetFn(self: Pin<&mut MyObject>); } unsafe extern "C++" { diff --git a/crates/cxx-qt-gen/test_outputs/qenum.rs b/crates/cxx-qt-gen/test_outputs/qenum.rs index 01c49f0e6..da72a117d 100644 --- a/crates/cxx-qt-gen/test_outputs/qenum.rs +++ b/crates/cxx-qt-gen/test_outputs/qenum.rs @@ -78,8 +78,8 @@ mod ffi { type MyObjectRust; } extern "Rust" { - #[doc(hidden)] #[cxx_name = "myInvokableWrapper"] + #[doc(hidden)] fn my_invokable(self: &MyObject, qenum: MyEnum, other_qenum: MyOtherEnum); } extern "Rust" { diff --git a/crates/cxx-qt-gen/test_outputs/signals.rs b/crates/cxx-qt-gen/test_outputs/signals.rs index 263d973b1..44def4728 100644 --- a/crates/cxx-qt-gen/test_outputs/signals.rs +++ b/crates/cxx-qt-gen/test_outputs/signals.rs @@ -35,8 +35,8 @@ mod ffi { type MyObjectRust; } extern "Rust" { - #[doc(hidden)] #[cxx_name = "invokableWrapper"] + #[doc(hidden)] fn invokable(self: Pin<&mut MyObject>); } unsafe extern "C++" {