-
Notifications
You must be signed in to change notification settings - Fork 82
Add shorthand for &self in RustQt blocks where the type can be inferred #1249
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 shorthand for &self in RustQt blocks where the type can be inferred #1249
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1249 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 73 74 +1
Lines 12612 12757 +145
==========================================
+ Hits 12612 12757 +145 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
a5f04f7
to
32371fd
Compare
…here the type can be inferred - If exactly one QObject is present in a block with a method, it will infer `Self` to represent that qobject - Updates one of the examples to test this out
32371fd
to
e457080
Compare
267fd77
to
b97d362
Compare
b97d362
to
8d63f02
Compare
Tried to implement in the qml_features example and there is a cxx error about there being multiple types in the block, even though there is only one qobject in the example, which may be because it adds the QObject import? |
84e9300
to
c05d75d
Compare
- QObjects, and invokables are now 2D Vecs, kept in their original block - Adds some helper methods for iterating like they are still flat
539a0a8
to
2b517b4
Compare
- Add function call to cxx-qt-build and cxx-qt-macro - Inlining now happens after parsing and before structuring
128b0f4
to
698c4d7
Compare
for block in 0..data.qobjects.len() { | ||
let methods = &mut data.methods[block]; | ||
let signals = &mut data.signals[block]; | ||
let inherited = &mut data.inherited_methods[block]; | ||
let qobjects = &data.qobjects[block]; |
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.
almost seems like you could use zip
here but seems it'd need to be a nested as it only supports combining two iterators? :-/
it'd probably end up as like
for (((qobject, method), signal), inherit_method) in zip(zip(zip(data.qobjects, data.methods), data.signals), data.inherited_methods)
But then does that end up being less readable 🤣
let inherited = &mut data.inherited_methods[block]; | ||
let qobjects = &data.qobjects[block]; | ||
|
||
let inline_self = qobjects.len() == 1; |
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.
do we only ever need to care about QObjects? eg do we support non-qobject attributed types in extern C++Qt / RustQt blocks ?
and do we need to support normal type
items in C++/Rust blocks if we start avoiding passthrough, this would be a separate change though?
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.
At the minute we don't support any types in C++Qt blocks that don't have a #[qobject] attribute, and I wasn't sure about RustQt blocks, but yeah this may a consideration, that it can be any type defs, not just QObjects, i guess to inline free functions.
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.
Right it's fine for now, but might need to change later depending what we do
Allows
Pin<&mut Self>
and&self
inside the bridge, as shorthand.&self
in bridge #1245