Skip to content
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

fix: Allow generated methods to be reused by other properties #1241

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

BenFordTytherington
Copy link
Collaborator

  • Add list of methods pending generation
  • Perform a lookup in the pending methods if they aren't found in the bridge
  • Use name of pending method if found

Should fix #1232

@BenFordTytherington BenFordTytherington force-pushed the fix-unknown-generated-signals branch from 75b1012 to 08b0ec4 Compare March 28, 2025 13:07
Copy link

codecov bot commented Mar 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (626371a) to head (03e3d57).

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #1241   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           73        73           
  Lines        12612     12658   +46     
=========================================
+ Hits         12612     12658   +46     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@BenFordTytherington BenFordTytherington force-pushed the fix-unknown-generated-signals branch from 08b0ec4 to 12627f2 Compare March 28, 2025 13:51
- Add list of methods pending generation
- Perform a lookup in the pending methods if they aren't found in the bridge
- Use name of pending method if found
@BenFordTytherington BenFordTytherington force-pushed the fix-unknown-generated-signals branch from 12627f2 to 03e3d57 Compare March 28, 2025 13:51
@BenFordTytherington BenFordTytherington marked this pull request as ready for review March 28, 2025 14:18
Copy link
Collaborator

@LeonMatthesKDAB LeonMatthesKDAB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The overall approach is good, but it needs to be split cleanly between signals and methods, and I don't see the need to separate the lookup.

Comment on lines +49 to +59
let lookup = lookup_fn(structured_qobject, ident);
let name = if let Ok(name) = lookup {
name
} else if let Some(name) = structured_qobject.pending_lookup(ident) {
// If a bridge method isn't found, it may be pending generation
name
} else {
// return the not found error if the method wasn't pending either
lookup?
};
Self::Custom(name)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the lookup of auto-generated functions/signals split into the separate pending_lookup function?
These are normal functions, just auto-generated. So why treat them any different in lookup?

IMO method_lookup and signal_lookup should just return them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because at this stage, the actual function signatures don't exist, the pending_lookup is simply searching through a set of names of the functions which are pending generation, whereas the signal and method lookups are finding actual methods which have been associated during structuring, so they have a declaration, and all the associated data already, whereas the pending ones just have a name, and will be generated later.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should note as well, those lookups are reading from vectors of ParsedSignal or ParsedMethod in StructuredQObject, so putting those pending methods in there would require building those structs just from the name.

Comment on lines +243 to +245
if let Some(FlagState::Auto) = &self.flags.notify {
pending.push(notify_name_from_property(&self.name));
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a signal, not a method, so needs to be treated differently during lookup.
We wouldn't want someone to e.g. use:

#[qproperty(i32, number, READ, NOTIFY=number)]

Which cxx-qt-gen would now accept.

Comment on lines +62 to +65
/// Searches for a name in the list of functions pending generation
pub fn pending_lookup(&self, id: &Ident) -> Option<Name> {
lookup(&self.pending_generation, id, |pending| pending)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should be a separate function, the lookup should just work via method_lookup and signal_lookup respectively.
If you want to look up whether a certain function can be named, then I don't think you need to care whether it's a generated function or a manually written one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to reference auto-generated qproperty flags in another flag
2 participants