Skip to content

Update how types are generated in C#545

Merged
pchickey merged 3 commits intobytecodealliance:mainfrom
alexcrichton:update-c-name
Mar 28, 2023
Merged

Update how types are generated in C#545
pchickey merged 3 commits intobytecodealliance:mainfrom
alexcrichton:update-c-name

Conversation

@alexcrichton
Copy link
Member

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 #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

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
@alexcrichton
Copy link
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.

@Mossaka
Copy link
Member

Mossaka commented Mar 27, 2023

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.

Ack, I'll take a look at it later today

@Mossaka
Copy link
Member

Mossaka commented Mar 27, 2023

In the meantime, feel free to disable Go bindgen tests.

@alexcrichton alexcrichton requested a review from pchickey March 28, 2023 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

type/function redefinition when same tuple/list type appear in both typedef and funcdef

3 participants