-
Notifications
You must be signed in to change notification settings - Fork 12
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
Generate Go code from WIT representation #12
Closed
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
ydnar
force-pushed
the
ydnar/gen
branch
3 times, most recently
from
November 2, 2023 17:47
d901ee3
to
0d72040
Compare
ydnar
force-pushed
the
ydnar/gen
branch
5 times, most recently
from
January 28, 2024 02:43
1fcf13f
to
603259f
Compare
ydnar
force-pushed
the
ydnar/gen
branch
5 times, most recently
from
February 9, 2024 00:58
e82d774
to
51ee738
Compare
wit: ID type This will be removed in a future commit. wit/gen: add Package.Decls internal/go/gen, bindgen, wit: refactor bindgen: Option types bindgen: initial commit of func Go() cmd/wit-bindgen-go: syntax -> wit cmd/wit-bindgen-go: add basic generate command internal/go/gen: Ident type bindgen, internal/go, wit: WIP Generating valid Go names from WIT names: 1. Scan for an explicit mapping, e.g. wasi:clocks/wall-clock -> wasi/clocks/wallclock 2. Perform string conversion, e.g. : -> /, strip - 3. (optional) validate short package name as valid Go identifier 4. Check against list of Go reserved words 5. For decl names, convert to Go-style names (TitleCase), check against existing decl bindgen, internal/go: WIP cmd/wit-bindgen-go: add --map wit=go ... flag bindgen, cmd/wit-bindgen-go: implement generated by for DO NOT EDIT comment internal/design: stab at what a generated interface for wasi:clocks/wall-clock could look like _design: multiple Go modules _design: WIP for imported and exported type _design/import-and-export: add README _design/import-and-export: fix typo bindgen, wit: WIP remove go.work and secondary go.mod file _design -> design, with go:build tags wasm/cm: importable Component Model primitive types design/wasi/io/poll: hand-rolled example for wasi:io/poll design/wasi/io/poll: right ABI? design/import-and-export: remove build tags where not necessary design/wasi/io: update WIP design/wasi/io/poll: improve comments design/wasi/io/poll: wasmexport methods should call the real methods on the type design/wasi/io: add world.wit source design: reorganized design/{export,import}: further explorations design/export/wasi/io/poll: exploring own/borrow semantics wasm/cm: Resource, Handle, Own, Borrow types wasm/cm: Resource, Handle, Own, Borrow types design: further experimentation cabi, design: post-return function to free allocated memory wasm/cabi: combine cabi and wasm/cm packages wasm/cabi: update README links cmd/wit-bindgen-go/cmd/generate: update to github.com/urfave/cli/v3 API changes cabi, design: move cabi back out of wasm directory cabi: add some TODOs wit: rename PackageName to ID; add extension (world, interface) bindgen, wit: update use of ID wit, testdata: ID -> Ident internal/go/gen: fix test wit: move Ident to ident.go and add tests bidngen, internal/go/gen: start generating Go names bindgen, internal/go/gen: more Go code generation; WIP cmd/wit-bindgen-go/cmd/generate, internal/go/gen: PackagePath function to load go.mod file cmd/wit-bindgen-go/cmd/generate: add -o flag internal/go/gen: Unique name generator internal/go/gen: add package, file, import manipulation bindgen, cmd/wit-bindgen-go/cmd/generate: PackageRoot option bindgen, wit: generate multiple Go packages design/wasi/io/streams: try version directories bindgen: WIP on package path and name generation bindgen: update comments bindgen: WIP bindgen, cmd/wit-bindgen-go/cmd/generate: remove - from Go package paths wit: fix typo bindgen: WIP emitting Go names for types in correct packages bindgen: emit functions; WIP bindgen: remove packageForWorld method bindgen: fake wasmimport lines bindgen: add TODO about mapping WIT functions and typedefs to Go decls internal/go/gen: replace Imports type with Imports func bindgen: export Go name helpers bindgen: rename isSep to notLetterDigit internal/go/gen: rename AddImport to Import bindgen, internal/go/gen: update Unique function internal/go/gen: NewFile -> File bindgen, internal/go/gen: update AddDecl bindgen, internal/go/gen: Decl returns Decl{} bindgen: map wit.TypeDef and wit.Function to gen.Decl bindgen: update comments cmd/wit-bindgen-go/cmd/generate: note generated package list internal/go/gen: remove File.ImportDecls internal/go/gen: FormatDocComments bindgen, cmd/wit-bindgen-go/cmd/generate, internal/go/gen: generate Go code into individual files in packages Write doc comments from WIT into files; set type aliases to any // TODO bindgen: serialize WIT docs into Go doc comments for types and functions bindgen: start breaking out type generation bindgen: rearrange deck chairs bindgen: stub out option<T> internal/go/gen: use golang.org/x/mod/modfile internal/go/gen: require IsGo for HasPackageDocs internal/go/gen: reorganize wit: omit doc comments when ctx == nil bindgen: print WIT definition in doc comments for each type wit: use tab indentation instead of 4 spaces This is necessary for Go doc comments that embed original WIT definition. testdata: regenerate with tab indentation bindgen: declare types before defining them wit: test that all TypeDef roots have named owners Anonymous interfaces can use types, but should point to a type owned by a named interface. design/wasi/io/poll/exports: update design for exported interfaces cabi: tweak
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.
This PR is a WIP for generating Go code from the JSON representation of fully-resolved WIT file(s).