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

Pass-by-ref for non-Copy builtins (frontend) #900

Merged
merged 10 commits into from
Sep 18, 2024
Merged

Conversation

Bromeon
Copy link
Member

@Bromeon Bromeon commented Sep 16, 2024

Enables several builtins that don't implement Copy to be passed by reference (borrowed) into engine APIs. Examples are Array, Packed*Array, Dictionary, Variant.

This lays the groundwork for future optimizations which exploit borrowing to avoid unnecessary cloning/ref-count operations, thus further reducing API call overhead.

There are some ergonomic impacts of requiring & in more places, however on the other side .clone() calls can often be avoided now. The current draft uses the Borrow trait in a few manual APIs to enable both by-value and by-ref; I'd probably use something else that uses by-value for Copy types and by-ref otherwise.

@Bromeon Bromeon added feature Adds functionality to the library c: ffi Low-level components and interaction with GDExtension API c: engine Godot classes (nodes, resources, ...) labels Sep 16, 2024
@GodotRust
Copy link

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

@Bromeon Bromeon added the breaking-change Requires SemVer bump label Sep 17, 2024
@Bromeon Bromeon added this to the 0.2 milestone Sep 18, 2024
@Bromeon Bromeon marked this pull request as ready for review September 18, 2024 19:34
@Bromeon Bromeon changed the title Pass-by-ref for non-Copy builtins Pass-by-ref for non-Copy builtins (frontend) Sep 18, 2024
@Bromeon
Copy link
Member Author

Bromeon commented Sep 18, 2024

Merging, as there's a sizeable amount of changes already. The "backend" changes (actual FFI passing) as well as fine-tuning the APIs like impl Borrow<T> can be done in separate PRs.

@Bromeon Bromeon added this pull request to the merge queue Sep 18, 2024
Merged via the queue into master with commit f33fe1f Sep 18, 2024
15 checks passed
@Bromeon Bromeon deleted the qol/engine-pass-by-ref branch September 18, 2024 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change Requires SemVer bump c: engine Godot classes (nodes, resources, ...) c: ffi Low-level components and interaction with GDExtension API feature Adds functionality to the library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants