-
Notifications
You must be signed in to change notification settings - Fork 92
Add attribute which generates wrappers for a function #1278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add attribute which generates wrappers for a function #1278
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1278 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 75 75
Lines 12784 12846 +62
=========================================
+ Hits 12784 12846 +62 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
15fa262
to
c6de2c6
Compare
3620686
to
6bba256
Compare
6bba256
to
a6b282c
Compare
a6b282c
to
4619a1b
Compare
@@ -43,3 +43,8 @@ For [`#[qproperty]`](./extern_rustqt.md#properties), a CXX or Rust name can be p | |||
The `#[auto_cxx_name]` and `#[auto_rust_name]` attributes can be used to automatically rename cxx and rust names. | |||
These are placed at a block level on `extern "RustQt"` or `extern "C++Qt"` blocks, and will automatically case convert the items inside, unless they specify either a `rust_name` or `cxx_name`. | |||
By default `#[auto_cxx_name]` will generate a camelCase conversion for`cxx_name` and `#[auto_rust_name]` will generate a snake_case conversion for `rust_name`. | |||
|
|||
### Automatic wrapping |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
an example that is compiled would be good too. I think the load_color here could be changed to use it https://github.com/KDAB/cxx-qt/blob/main/examples/qml_features/rust/src/invokables.rs#L99
So that you have load_color auto_wrapped to read the inner as_qcolor on the Rust type (which could be renamed)
bf40f52
to
b30fe57
Compare
#unsafe_call fn #invokable_ident_rust(#parameter_signatures) #return_type; | ||
} | ||
impl #qualified_impl { | ||
#method_safety fn #invokable_ident_rust(#parameter_signatures) #return_type { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
think you need to consider the visibility here too? eg pass through the pub
or pub(super)
etc
b30fe57
to
4ed0a1f
Compare
} | ||
impl #qualified_impl { | ||
pub #method_safety fn #invokable_ident_rust(#parameter_signatures) #return_type { | ||
self.#inner_fn.#invokable_ident_rust(#call_parameters) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking at other generators they have use cxx_qt::CxxQtType;
within the function so that they can reach the trait implementation of rust() / rust_mut(). Wonder if we need the same here?
eg here https://github.com/KDAB/cxx-qt/blob/main/crates/cxx-qt-gen/src/generator/rust/property/setter.rs#L71
@@ -780,6 +780,11 @@ cxx_qt::static_assertions::assert_eq_size!( | |||
cxx_qt::signalhandler::CxxQtSignalHandler<SecondObjectCxxQtSignalClosurepropertyNameChanged>, | |||
[usize; 2] | |||
); | |||
impl ffi::SecondObject { | |||
fn my_function(self: &SecondObject, param: i32) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aha this type should be ffi::SecondObject
that's why it's failing :-)
4ed0a1f
to
ad60cb0
Compare
Closes #1235
Adds the
auto_wrap
attribute which will generate the wrapper function for methods defined in the bridge.