-
-
Notifications
You must be signed in to change notification settings - Fork 139
🐛 xmlgen: avoid generating duplicate receive_*_changed methods
#1684
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?
🐛 xmlgen: avoid generating duplicate receive_*_changed methods
#1684
Conversation
zeenix
left a comment
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.
LGTM otherwise. Thanks!
CodSpeed Performance ReportMerging this PR will not alter performanceComparing Summary
|
ddf72f5 to
b8ea635
Compare
zeenix
left a comment
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.
A few nitpicks resolved and we're good to merge. :)
b8ea635 to
29cb297
Compare
zeenix
left a comment
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.
Very close, I promise :)
29cb297 to
b34e04d
Compare
When given an interface definition with a property named `Foo` and a signal named `FooChanged`, `zbus_xmlgen` would generate duplicate `receive_foo_changed` methods, causing compilation errors. In practice, the colliding `*Changed` signal is used to override the behavior of the property's implicit change signal, so it's preferable to use the overridden one and leave off the implicit rather than keeping it as a compilation error. Resolves `Case 2` of z-galaxy#231
b34e04d to
7c8eee1
Compare
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.
Breaking my promise again by finding more nitpicks. 😆 Sorry! If you don't have the time and motivation anymore, just let me know and I can help out with remaining stuff.
| signals.sort_by(|a, b| a.name().partial_cmp(&b.name()).unwrap()); | ||
|
|
||
| // collect signal method names for collision detection with implicit property change | ||
| // receivers |
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.
Missing . again. Sorry! I just like consistency too much. Although in these files I've allowed changes from contributors that missed . but it's inconsistent with rest of the code and even code here, so let's not add to that. 🙏 I'll add . to existing comments/docs in these files myself later.
| format!(" #[zbus(property, name = \"{}\")]", p.name()) | ||
|
|
||
| let prop_change_receiver_name = format!("{name}_changed"); | ||
| let signal_collision = changed_suffix_signals.get(&prop_change_receiver_name); |
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.
I liked the previous naming better. The variable isn't holding a collision but rather the Signal. The name makes it sound like it's a boolean so makes code slightly harder to follow/read.
| >; | ||
|
|
||
| /// State property | ||
| // Note: change signal is shadowed by `StateChanged` signal. |
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.
change signal->changed signal.- I just realized btw: wouldn't it be better if this was instead:
| // Note: change signal is shadowed by `StateChanged` signal. | |
| // Note: change signal is shadowed by `state_changed` signal method. |
? That would also make the xmlgen part simpler and you can also go back to HashSet but this time w/o the caveat of reallocation. 😉
| @@ -185,6 +186,11 @@ impl GenTrait<'_> { | |||
|
|
|||
| let mut signals = iface.signals().to_vec(); | |||
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.
btw, can't we just switch to be a HashMap instead? Wouldn't it make the code even simpler? 🤔
Resolves
Case 2of #231I ran into this issue when trying to generate
zbusbindings for ModemManager, which has four such naming collisions. This resolves the issue there and should help for others who have commented on #231.