-
Notifications
You must be signed in to change notification settings - Fork 210
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
Implement automatic NativeClass
registration via inventory. Implement mix-ins.
#999
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This adds the optional `inventory` feature, which allows `NativeClass` types to be automatically registered on supported platforms (everything that OSS Godot currently supports except WASM). Run-time diagnostic functions are added to help debug missing registration problems that are highly likely to arise when porting `inventory`-enabled projects to WASM. An internal `cfg_ex` attribute macro is added to help manage cfg conditions.
Adds the `#[methods(mixin = "Name")]` syntax for declaring mix-in blocks. Mix-in blocks have a many-to-many relationship with `NativeClass` types. Both `impl Type` and `impl Trait for Type` blocks are accepted. All mix-in blocks have to be manually registered for gdnative v0.11.x. This can be relaxed in the future with a redesign of the `NativeClass` hierarchy of traits.
chitoyuu
added
feature
Adds functionality to the library
c: export
Component: export (mod export, derive)
labels
Dec 10, 2022
chitoyuu
force-pushed
the
feature/inventory
branch
from
December 10, 2022 10:52
96fc6bf
to
e674857
Compare
Some minor unresolved questions:
Ideas for future development:
bors try |
Converting to draft: forgot to update documentation for the macros. Will do this later. |
tryBuild succeeded: |
Left this hanging for a while but it should be good to go. For v0.11 I think we'll keep the feature opt-in and the examples as-is. bors r+ |
bors bot
added a commit
that referenced
this pull request
Jan 4, 2023
999: Implement automatic `NativeClass` registration via inventory. Implement mix-ins. r=chitoyuu a=chitoyuu ## Implement automatic NativeClass registration via inventory This adds the optional `inventory` feature, which allows `NativeClass` types to be automatically registered on supported platforms (everything that OSS Godot currently supports except WASM). Run-time diagnostic functions are added to help debug missing registration problems that are highly likely to arise when porting `inventory`-enabled projects to WASM. An internal `cfg_ex` attribute macro is added to help manage cfg conditions. Close #350. Note that the standalone registration attribute syntax proposed by the original issue isn't implemented, for the limited usefulness -- there are much fewer cases where manual `NativeClass` impls are necessary thanks to all the improvements since the original issue. ## Implement mix-in `#[methods]` blocks Adds the `#[methods(mixin = "Name")]` syntax for declaring mix-in blocks. Mix-in blocks have a many-to-many relationship with `NativeClass` types. Both `impl Type` and `impl Trait for Type` blocks are accepted. The argument name is changed from `as` in the original proposal to `mixin`, because we might still want to keep universal `#[methods]` blocks in the future for ease of use with WASM. `#[methods(mixin)]` makes a lot more sense for a future auto-registered mixin block than `#[methods(as /* as what? */)]`. All mix-in blocks have to be manually registered for gdnative v0.11.x. Some difficulty was encountered when trying to make auto-mixins compatible with existing code. It might still be possible with some tricks like autoref-specialization, but that might be too much effort given that we likely want to re-design much of the hierarchy for 0.12. Close #984. ## Allow `#[register_with]` for `#[monomorphize]` Enables `#[monomorphize]` to take the same standalone `#[register_with]` attribute as `#[derive(NativeClass)]`. This is chosen for short term consistency, but will probably change in a later version w/ #848, which might not still get implemented for a fair bit of time. Co-authored-by: Chitose Yuuzaki <[email protected]>
Build failed: |
bors retry |
bors bot
added a commit
that referenced
this pull request
Jan 4, 2023
999: Implement automatic `NativeClass` registration via inventory. Implement mix-ins. r=chitoyuu a=chitoyuu ## Implement automatic NativeClass registration via inventory This adds the optional `inventory` feature, which allows `NativeClass` types to be automatically registered on supported platforms (everything that OSS Godot currently supports except WASM). Run-time diagnostic functions are added to help debug missing registration problems that are highly likely to arise when porting `inventory`-enabled projects to WASM. An internal `cfg_ex` attribute macro is added to help manage cfg conditions. Close #350. Note that the standalone registration attribute syntax proposed by the original issue isn't implemented, for the limited usefulness -- there are much fewer cases where manual `NativeClass` impls are necessary thanks to all the improvements since the original issue. ## Implement mix-in `#[methods]` blocks Adds the `#[methods(mixin = "Name")]` syntax for declaring mix-in blocks. Mix-in blocks have a many-to-many relationship with `NativeClass` types. Both `impl Type` and `impl Trait for Type` blocks are accepted. The argument name is changed from `as` in the original proposal to `mixin`, because we might still want to keep universal `#[methods]` blocks in the future for ease of use with WASM. `#[methods(mixin)]` makes a lot more sense for a future auto-registered mixin block than `#[methods(as /* as what? */)]`. All mix-in blocks have to be manually registered for gdnative v0.11.x. Some difficulty was encountered when trying to make auto-mixins compatible with existing code. It might still be possible with some tricks like autoref-specialization, but that might be too much effort given that we likely want to re-design much of the hierarchy for 0.12. Close #984. ## Allow `#[register_with]` for `#[monomorphize]` Enables `#[monomorphize]` to take the same standalone `#[register_with]` attribute as `#[derive(NativeClass)]`. This is chosen for short term consistency, but will probably change in a later version w/ #848, which might not still get implemented for a fair bit of time. Co-authored-by: Chitose Yuuzaki <[email protected]>
Build failed: |
chitoyuu
force-pushed
the
feature/inventory
branch
from
January 4, 2023 18:06
b19e19d
to
b984183
Compare
I don't understand why it's $DIR for some of the tests and tests/ui for the others. Perhaps this is something upstream should have considered?
This should finally do it... bors retry |
Build succeeded: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implement automatic NativeClass registration via inventory
This adds the optional
inventory
feature, which allowsNativeClass
types to be automatically registered on supported platforms (everything that OSS Godot currently supports except WASM).Run-time diagnostic functions are added to help debug missing registration problems that are highly likely to arise when porting
inventory
-enabled projects to WASM.An internal
cfg_ex
attribute macro is added to help manage cfg conditions.Close #350. Note that the standalone registration attribute syntax proposed by the original issue isn't implemented, for the limited usefulness -- there are much fewer cases where manual
NativeClass
impls are necessary thanks to all the improvements since the original issue.Implement mix-in
#[methods]
blocksAdds the
#[methods(mixin = "Name")]
syntax for declaring mix-in blocks. Mix-in blocks have a many-to-many relationship withNativeClass
types. Bothimpl Type
andimpl Trait for Type
blocks are accepted.The argument name is changed from
as
in the original proposal tomixin
, because we might still want to keep universal#[methods]
blocks in the future for ease of use with WASM.#[methods(mixin)]
makes a lot more sense for a future auto-registered mixin block than#[methods(as /* as what? */)]
.All mix-in blocks have to be manually registered for gdnative v0.11.x. Some difficulty was encountered when trying to make auto-mixins compatible with existing code. It might still be possible with some tricks like autoref-specialization, but that might be too much effort given that we likely want to re-design much of the hierarchy for 0.12.
Close #984.
Allow
#[register_with]
for#[monomorphize]
Enables
#[monomorphize]
to take the same standalone#[register_with]
attribute as#[derive(NativeClass)]
. This is chosen for short term consistency, but will probably change in a later version w/ #848, which might not still get implemented for a fair bit of time.