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

Separate static name from NativeClass into new trait #847

Merged
merged 2 commits into from
Jan 10, 2022

Conversation

chitoyuu
Copy link
Contributor

@chitoyuu chitoyuu commented Jan 9, 2022

This allows NativeScript types to be registered under names only determined
at run time, enabling better ergonomics for libraries.

Ref #601, #603

Unresolved questions

This does not implement the #[name = "MyCustomName"] static renaming syntax as suggested in #601 (comment), because it's very uncommon (if at all possible) for a key-value pair to be the top-level meta in an attribute. It should also be noted that at this moment, the NativeClass macro already utilizes a large number of type-level attributes:

  • inherit
  • user_data
  • register_with
  • no_constructor

...so it might not be wise to add another into the mix, especially under such a non-specific identifier as name. We might want to consider bundling (some of) these into a single top-level attribute (like variant for the From/ToVariant macros) instead. See #848.

This allows NativeScript types to be registered under names only determined
at run time, enabling better ergonomics for libraries.

Ref godot-rust#601, godot-rust#603
@Bromeon Bromeon added c: export Component: export (mod export, derive) quality-of-life No new functionality, but improves ergonomics/internals labels Jan 9, 2022
@Bromeon Bromeon added this to the v0.10.0 milestone Jan 9, 2022
Copy link
Member

@Bromeon Bromeon left a comment

Choose a reason for hiding this comment

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

Thanks a lot for this great PR!

You bring up a good point with too many attributes. I agree it might be better to scope them appropriately.

bors try

gdnative-core/src/export/class_registry.rs Outdated Show resolved Hide resolved
bors bot added a commit that referenced this pull request Jan 9, 2022
@bors
Copy link
Contributor

bors bot commented Jan 9, 2022

try

Build succeeded:

@Bromeon
Copy link
Member

Bromeon commented Jan 9, 2022

I tried the changes with a local project, all seems good.

If there is no more feedback/addendum, I can merge this tomorrow.

@chitoyuu
Copy link
Contributor Author

chitoyuu commented Jan 9, 2022

I don't have further feedback myself at the moment. #848 should be best done as a separate PR, I believe.

@Bromeon
Copy link
Member

Bromeon commented Jan 10, 2022

bors r+

@bors
Copy link
Contributor

bors bot commented Jan 10, 2022

Build succeeded:

@bors bors bot merged commit 25603b0 into godot-rust:master Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: export Component: export (mod export, derive) 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