Skip to content

Commit

Permalink
Hotfix: rust_name on #[inherit]
Browse files Browse the repository at this point in the history
This used ident directly, instead of rust_unqualified()

Also, add a corresponding regression test
  • Loading branch information
LeonMatthesKDAB committed Sep 26, 2024
1 parent 8ac1f79 commit 7e52b94
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion crates/cxx-qt-gen/src/generator/rust/inherit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub fn generate(
})
.collect::<Vec<TokenStream>>();

let ident = &method.method.sig.ident;
let ident = &method.method_fields.name.rust_unqualified();
let cxx_name_string = &method.wrapper_ident().to_string();
let self_param = if method.mutable {
quote! { self: Pin<&mut #qobject_name> }
Expand Down
4 changes: 4 additions & 0 deletions crates/cxx-qt-gen/test_inputs/inheritance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ mod inheritance {
#[cxx_name = "hasChildren"]
#[inherit]
fn has_children_super(self: &MyObject, parent: &QModelIndex) -> bool;

#[rust_name = "hello_world"]
#[inherit]
fn helloWorld(self: &MyObject, parent: &QModelIndex) -> bool;
}

extern "RustQt" {
Expand Down
5 changes: 5 additions & 0 deletions crates/cxx-qt-gen/test_outputs/inheritance.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ class MyObject
return QAbstractItemModel::hasChildren(args...);
}
template<class... Args>
bool helloWorldCxxQtInherit(Args... args) const
{
return QAbstractItemModel::helloWorld(args...);
}
template<class... Args>
void fetchMoreCxxQtInherit(Args... args)
{
return QAbstractItemModel::fetchMore(args...);
Expand Down
4 changes: 4 additions & 0 deletions crates/cxx-qt-gen/test_outputs/inheritance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ mod inheritance {
#[doc = " Inherited hasChildren from the base class"]
fn has_children_super(self: &MyObject, parent: &QModelIndex) -> bool;
}
unsafe extern "C++" {
#[cxx_name = "helloWorldCxxQtInherit"]
fn hello_world(self: &MyObject, parent: &QModelIndex) -> bool;
}
extern "C++" {
#[cxx_name = "fetchMoreCxxQtInherit"]
#[doc = " Inherited fetchMore from the base class"]
Expand Down

0 comments on commit 7e52b94

Please sign in to comment.