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

feat(go-namespaces): Split generated Go files into multiple packages #784

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Mossaka
Copy link
Member

@Mossaka Mossaka commented Dec 4, 2023

This commit overhauls the WorldGenerator file structure in the tinygo bindgen. Key changes include:

  • Splitting generated Go files into different packages for each interface, imported functions, and exported functions.
  • Simplifying function and symbol names by removing namespaces.
  • Adding a package_name option to Go bindgen for prefixed package names. Defaults to main if not specified.

Internally, the C files are placed at a special Go package named "c_files_", and a dummy Go file is generated to expose the C APIs. Each interface generates a Go package that imports this special "c_files_" package to get the C apis. It still has to import the C header file which is also placed at "c_files_" by setting CFLAGS to locate where that is for that Go package.

This restructuring enhances usability by making symbol and function names more readable and less verbose, significantly improving the user experience.

TODO

  • Generate a dummy main file for each codegen test, and that main file needs to import all the generated Go packages.
  • Enable the rest of the runtime tests
  • Figure out how to import Go packages to implement type aliasing
  • More testing with wasi:http

This commit overhauls the `WorldGenerator` file structure in the tinygo bindgen. Key changes include:
- Splitting generated Go files into different packages for each interface, imported functions, and exported functions.
- Simplifying function and symbol names by removing namespaces.
- Adding a `package_name` option to Go bindgen for prefixed package names. Defaults to `main` if not specified.

Internally, the C files are placed at a special Go package named "c_files_", and a dummy Go file is generated to expose the C APIs. Each interface generates a Go package that imports this special "c_files_" package to get the C apis. It still has to import the C header file which is also placed at "c_files_" by setting CFLAGS to locate where that is for that Go package.

This restructuring enhances usability by making symbol and function names more readable and less verbose, significantly improving the user experience.

Signed-off-by: Jiaxiao Zhou (Mossaka) <[email protected]>
@Mossaka Mossaka marked this pull request as draft December 4, 2023 01:43
@Mossaka Mossaka changed the title feat(go-namespaces): Initial draft with working smoke runtime test feat(go-namespaces): Split generated Go files into multiple packages Dec 4, 2023
@Mossaka
Copy link
Member Author

Mossaka commented Apr 30, 2024

This work has been paused for a few months since there is a new pure-Go implementation of the wit-bindgen-go undergoing.

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.

1 participant