-
Notifications
You must be signed in to change notification settings - Fork 1
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
Implement get_module_property and add JS type #25
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #25 +/- ##
==========================================
- Coverage 70.49% 70.01% -0.48%
==========================================
Files 21 22 +1
Lines 4894 5023 +129
==========================================
+ Hits 3450 3517 +67
- Misses 1062 1114 +52
- Partials 382 392 +10 ☔ View full report in Codecov by Sentry. |
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.
The emval part looks good except for the pointer part. The js adapters need some more modifications. I am looking into it. The emscripten code works in a super roundabout way. I'll keep you posted.
if !ok { | ||
panic(fmt.Errorf("could not create memory view")) | ||
} | ||
stack[0] = api.EncodeI32(engine.emvalEngine.toHandle(js.Int8Array{ |
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.
We need to pass pointers for all the structs. Otherwise it fails with:
error while calling embind function full_default: reflect: Elem of invalid type js.Uint8Array (recovered by wazero)
So this is what eventually worked for me for type float32Array struct {
BackingBuffer []uint8 `embind_arg:"0"`
ByteOffset uint32 `embind_arg:"1"`
Length int32 `embind_arg:"2"`
Constructor *float32Array
Buffer []float32
}
func NewFloat32Array(in []float32) *float32Array {
return &float32Array{
Buffer: in,
Constructor: &float32Array{},
Length: int32(len(in)),
}
}
func (fa *float32Array) Set(in *float32Array) {
reslice := fa.BackingBuffer[fa.ByteOffset : fa.ByteOffset+(uint32(fa.Length)*4)]
conv := unsafe.Slice((*uint8)(unsafe.Pointer(&in.Buffer[0])), len(in.Buffer)*4)
copy(reslice, conv)
fa.Buffer = in.Buffer
fa.Length = in.Length
} I don't really need the And then in the EDIT: I think it's perfectly fine to expect a typed input to the |
Add JS Array types with a basic implementation (buffer and length properties).