Update how types are generated in C#545
Merged
pchickey merged 3 commits intobytecodealliance:mainfrom Mar 28, 2023
Merged
Conversation
Prior to this commit each interface used in C would generate a separate type per import and per export. For example if a `world` both imported and exported an interface then distinct, but defined the same way, types would be generated. Furthermore this same logic was extended to types-in-worlds which ended up not working well and causing bytecodealliance#544. This commit overhauls how types are generated in C. All used interfaces now generate one set of types, regardless of whether the interface is used in an import or an export. Additionally this enables fixing bytecodealliance#544 by generating types for worlds only once at the end instead of incrementally throughout. Along the way this updates many names of generated types to be more appropriate to their scoping constraints. For example types in interfaces are now namespaced by the name of the interface. Functions continue to be namespaced by the name of the import/export and disregard the name of the interface. Ambient types like `record<T, E>` continue to be prefixed by the name of the world that bindings are generated for. Closes bytecodealliance#544
Member
Author
|
cc @Mossaka while I haven't run the Go tests locally (haven't gotten around to installing the right toolchains) this is almost surely going to break Go bindings generation since it's relying on the C bindings generator. |
Member
Ack, I'll take a look at it later today |
Member
|
In the meantime, feel free to disable Go bindgen tests. |
pchickey
approved these changes
Mar 28, 2023
This was referenced May 26, 2023
This file contains hidden or 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
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.
Prior to this commit each interface used in C would generate a separate type per import and per export. For example if a
worldboth imported and exported an interface then distinct, but defined the same way, types would be generated. Furthermore this same logic was extended to types-in-worlds which ended up not working well and causing #544.This commit overhauls how types are generated in C. All used interfaces now generate one set of types, regardless of whether the interface is used in an import or an export. Additionally this enables fixing #544 by generating types for worlds only once at the end instead of incrementally throughout.
Along the way this updates many names of generated types to be more appropriate to their scoping constraints. For example types in interfaces are now namespaced by the name of the interface. Functions continue to be namespaced by the name of the import/export and disregard the name of the interface. Ambient types like
record<T, E>continue to be prefixed by the name of the world that bindings are generated for.Closes #544