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: implement without C dependency #15

Merged
merged 1 commit into from
Oct 6, 2023
Merged

Conversation

egonelbre
Copy link
Contributor

Go 1.21 introduced go:wasmimport, which means there's no need for using C for imports.

@@ -281,18 +270,18 @@ func (m *Memory) Store(data []byte) {
}

func (m *Memory) Free() {
C.extism_free(m.offset)
extism_free(m.offset)
}

func (m *Memory) Length() uint64 {
return m.length
}

func (m *Memory) Offset() uint64 {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also wondered whether this should return ExtismPointer and then FindMemory also use it... to avoid some potential errors. However, that would be a backwards incompatible change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're nearing a 1.0 release, so let's break things if needed in order to improve the code & APIs!

For reference if interested:
extism/extism#420

Copy link
Contributor Author

@egonelbre egonelbre Oct 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, also -- is it even necessary to expose Offset and FindMemory? If it's not necessary, then the decision can be pushed further down the line until it's necessary.

@wikiwong
Copy link

wikiwong commented Oct 6, 2023

@egonelbre this is a great change, thank you! will give it a more thorough pass tomorrow but so far looks good

@nilslice
Copy link
Member

nilslice commented Oct 6, 2023

@bhelx & @zshipko,

I don't see anything blocking this - but would be great to have one more of us take a quick look!

@nilslice nilslice requested review from zshipko and bhelx October 6, 2023 19:32
@bhelx
Copy link
Contributor

bhelx commented Oct 6, 2023

Go 1.21 introduced go:wasmimport, which means there's no need for using C for imports.

Perhaps a naive question, I'm less familiar with this repo than @nilslice and @zshipko . Does this work in both Go and tinygo? Also, do we support host functions yet in this repo? Not seeing anything in the docs about it.

@bhelx
Copy link
Contributor

bhelx commented Oct 6, 2023

Overall though, yes I endorse this. Love seeing the advancements in Wasm support in the Go ecosystem and not relying on C stuff. I'm also okay with any breaking changes. We can bump this to a 1.0 pre-release version if we want to break the API

@egonelbre
Copy link
Contributor Author

@bhelx yes, both tinygo and regular go should work. It probably would make sense to add tests for both compilers, currently it seems only tinygo is tested.

Copy link
Contributor

@zshipko zshipko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! Merging.

@zshipko zshipko merged commit 75096db into extism:main Oct 6, 2023
2 checks passed
@egonelbre egonelbre deleted the noc branch October 9, 2023 15:33
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.

None yet

5 participants