-
Notifications
You must be signed in to change notification settings - Fork 79
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
WIP: cxx-qt-gen: use original bridge definition in CXX and remove camel/snake conversion #667
Conversation
14dfe02
to
ba45615
Compare
This works quite well from a generation side, only the However for The syntax could be something like #[qproperty(i32, my_property, cxx_name = "myProperty")]
#[qproperty(i32, myProperty, rust_name = "myProperty")]
#[qproperty(i32, my_property, cxx_name = "myProperty", read = Self::custom_read)] But note that we might have custom getters and setters in there later too 🤔 Another route could be to require to specify the "name" in C++ as the property name and then specify the field it maps to ( #[qproperty(i32, myProperty = Self::my_property)]
#[qproperty(i32, myProperty = Self::my_property, read = Self::custom_read)] Then it could also fallback to if you don't specify the right side it assumes that they are the same #[qproperty(i32, myProperty)] // would look for Self::myProperty Or a further idea could be to make everything key-values, combine the C++ name with the type #[qproperty(myProperty = i32, member = Self::myProperty)]
#[qproperty(myProperty = i32, read = Self::custom_read)] Or if we can use the generic syntax #[qproperty(myProperty<i32>, member = Self::myProperty)]
#[qproperty(myProperty<i32>, read = Self::custom_read)] Which could also drop the Self #[qproperty(myProperty<i32>, member = myProperty)]
#[qproperty(myProperty<i32>, read = custom_read)] |
Hm, I do like the automatic camel-case/snake-case conversion, as snake-case code does look very out of place in QML/C++. I believe we could still make the passthrough work with case conversion, by simply checking whether there's a It's something that we should discuss at the company meeting, whether people think camelCase is important in QML. |
This allows for passing through the original method, invokable, and inherit definition to CXX and then removes camel <-> snake case conversion. Related to KDAB#616
06e9525
to
be2abb9
Compare
Another suggestion for naming of properties: extern "RustQt" {
#[qobject]
#[qproperty(
i32, my_property,
cxx_name="my_prop",
setter=set_my_prop)]
type MyThing = super::MyThingRust;
#[cxx_name="..."]
fn set_my_prop(self: Pin<&mut MyThing>, value: i32);
} It basically boils down to requiring you to declare the actual setter in the bridge yourself, if you don't want to use the auto-generated one. |
This has been done via various changes with @BenFordTytherington 's refactorings. Instead of passing through the original we now rebuild in the generation phase this allows for ensuring we have a supported API etc. |
Closes #616
Closes #532