Skip to content

Conversation

@Bromeon
Copy link
Member

@Bromeon Bromeon commented Apr 28, 2025

Previously, you needed at least one #[signal] to make your GodotClass eligible for the WithUserSignals trait, meaning otherwise you couldn't access self.signals() or Gd::signals() methods. This made sense while at the time, but with implicit access to base signals, this can now be relaxed.

The new rule is: typed signals are enabled if your class has a Base<T> field. This still allows to use lightweight data classes without base fields.

This PR also provides a blanked opt-out for typed signals:

#[godot_api(no_typed_signals)]
impl MyClass {
    ...
}

This should be rarely needed, but can be helpful in situations where proc-macro API causes problems (e.g. impl nested::MyClass) or excessive code generation. If enabled, #[signal] can still be used and will register the signal, but not generate any typed APIs -- just like in v0.2.

Bromeon added 3 commits April 28, 2025 13:46
…declared

Necessary due to `&mut self` forwarding, which base collections with Gd<T> can't do.
See comments for details.
@Bromeon Bromeon added quality-of-life No new functionality, but improves ergonomics/internals c: core Core components labels Apr 28, 2025
#[hint] should really be hints: injecting information that the proc-macro cannot infer, like with
#[hint(no_base)] fields. We could use #[hint(has_base_field = true, class_visibility = pub)] or so
in the future.

For now, disabling entire typed-signal API (including traits) can be done on #[godot_api] itself.
@Bromeon Bromeon force-pushed the qol/withsignals-everywhere branch from 2f97138 to 99b76e6 Compare April 28, 2025 12:06
@GodotRust
Copy link

API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-1146

@Bromeon Bromeon added this to the 0.3 milestone Apr 28, 2025
@Bromeon Bromeon added this pull request to the merge queue Apr 28, 2025
Merged via the queue into master with commit dc9ba89 Apr 28, 2025
17 checks passed
@Bromeon Bromeon deleted the qol/withsignals-everywhere branch April 28, 2025 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: core Core components quality-of-life No new functionality, but improves ergonomics/internals

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants