wit-bindgen icon indicating copy to clipboard operation
wit-bindgen copied to clipboard

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

Open Mossaka opened this issue 2 years ago • 1 comments

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

Mossaka avatar Dec 04 '23 01:12 Mossaka

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

Mossaka avatar Apr 30 '24 18:04 Mossaka