-
Notifications
You must be signed in to change notification settings - Fork 199
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): add resources support #759
Conversation
2be24e8
to
646044d
Compare
fc922ee
to
d8cb5d1
Compare
I think this PR is ready to review. I will write more in detail what this PR has changed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I'm not reviewing the Go bits too too closely but all the other bits look good to me. There's some comments of mine from #757 that are applicable here as well, but otherwise this looks good to go
Yea, I will resolve the comments in #757 and rebase onto it. |
One more commit in - now all the resource tests including codegen and runtime are passing 🎉 |
b35bea1
to
98e2974
Compare
@Mossaka want to rebase this and I'll do a final pass? |
Signed-off-by: Jiaxiao Zhou (Mossaka) <[email protected]>
Signed-off-by: Jiaxiao Zhou (Mossaka) <[email protected]> feat(go): add resources support Signed-off-by: Jiaxiao Zhou (Mossaka) <[email protected]> test(c): add a runtime test for resource_borrow_simple Signed-off-by: Jiaxiao Zhou (Mossaka) <[email protected]> temp Signed-off-by: Jiaxiao Zhou (Mossaka) <[email protected]>
Signed-off-by: Jiaxiao Zhou (Mossaka) <[email protected]>
Signed-off-by: Jiaxiao Zhou (Mossaka) <[email protected]>
Signed-off-by: Jiaxiao Zhou (Mossaka) <[email protected]>
Signed-off-by: Jiaxiao Zhou (Mossaka) <[email protected]>
Signed-off-by: Jiaxiao Zhou (Mossaka) <[email protected]>
Signed-off-by: Jiaxiao Zhou (Mossaka) <[email protected]>
Signed-off-by: Jiaxiao Zhou (Mossaka) <[email protected]>
Signed-off-by: Jiaxiao Zhou (Mossaka) <[email protected]>
…exported_interfaces Signed-off-by: Jiaxiao Zhou (Mossaka) <[email protected]>
Signed-off-by: Jiaxiao Zhou (Mossaka) <[email protected]>
Signed-off-by: Jiaxiao Zhou (Mossaka) <[email protected]>
98e2974
to
9bdaea8
Compare
Rebased |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to merge as-is, I can follow-up with the cleanup I mentioned
Signed-off-by: Jiaxiao Zhou (Mossaka) <[email protected]>
I will merge once the CI passes. Thanks for reviewing @alexcrichton |
And thank you again for your work on this! |
sorry wrong button |
[Moved from PR #737]
Introduction
This PR refactors the wit-bindgen-go to mainly support WIT Resources.
Should close #696 and #615
Resources
This PR has enabled WIT resources in the Go binding generator. The user interface for dealing with imported and exported resources look something like this
Exported Resources
Then the generated Go code contains an interface
ExportsX
waiting to be implemented. This interface has all the methodsGetA
andSetA
in it except constructor and static functions, which belong to the WIT interface's generated Go interface. The Go code looks like:Note that if there are no methods in the exported resource, than the generated Go interface is just an empty interface. Any struct implementation would work.
Imported Resources
Now moving on to the imported resources. Imported resources have a better Go semantics than exported ones. For example, given the following WIT resource
You can use the Go APIs to interact with resource Y in the following way:
Note that if the resource is empty (meaning it doesn't have any methods), then that resource's representation is just a
int32
.More Improvement
lib.rs
file into smaller files, each dealing with their own responsibility. For instance, there is abindgen.rs
file dealing with function generator, andinterface.rs
dealing with interface generator.gofmt
flag that runsgofmt
to generated Go files.Breaking Changes
Export
to fix some minor bugs. More on this later with the package refactoring work.