-
Notifications
You must be signed in to change notification settings - Fork 77
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
cxx_name on methods #828
Comments
Hi, thank you for taking the time to report this issue. Could you provide a small code snippet that shows how you're declaring the We know there are issues with (re-)naming items in CXX-Qt. That's definitely an area of improvement for the next release. |
It is part of a rust override. The C++ API: class UIContextNotification {
...
virtual void OnViewChange(UIContext* context, ViewFrame* frame, const QString& type){}
...
} My rust override: unsafe extern "RustQt" {
#[base = "UIContextNotification"]
type MyUIContextNotification = super::MyUIContextNotificationRust;
}
unsafe extern "RustQt" {
#[cxx_name = "OnViewChange"] // this is ignored and `onViewChange` is used instead
#[cxx_override]
unsafe fn OnViewChange(
self: Pin<&mut MyUIContextNotification>,
context: *mut UIContext,
frame: *mut ViewFrame,
type_: &QString,
);
} which results in the compiler error:
|
I'm just looking through the code. I think this entirely broke during the conversion to our new API for 0.6... Sorry there's no workaround at the moment. |
Right this is an area we need to refactor, hopefully for 0.7. For a workaround maybe you can use an alias in C++ ? Eg create a derived class with a camel case name and then use that in Rust. The changes in #667 were an early attempt at trying to improve the problem, we were also trying to figure out if by default we still want the automatic camel <-> snake conversion (which is useful for things like QML signals as otherwise you potentially end up with I think before when we discussed the options we decided this was a possible route
I am unsure about C++Qt -> no attributes -> Rust case though, maybe only the automatic conversion happens in RustQt. @LeonMatthesKDAB what do you think ? |
Hm, I actually quite like your proposal, including And with the table you provided, it should be easy enough to explain. |
Right that was my though, it's either "language of origin" or if you specify a cxx/rust_name then it follows those or the original. This should allow you to get to all combinations i think 🤔 |
As of #1005, you should now be able to use cxx_name and rust_name on methods again 🥳 . I think we may still be missing the correct case conversions in the |
We've decided to drop the automatic renaming for 0.7. |
The API i work with doesn't follow Qt codestyle. Therefore it contains a function named
OnViewChange
(with a capital first letter, aka. PascalCase). cxx-qt does not supportcxx_name
attributes to rename such functions, they are always formatted to CamelCase.I wrote this as another example for #667
The text was updated successfully, but these errors were encountered: