wasmoon icon indicating copy to clipboard operation
wasmoon copied to clipboard

binary data support

Open fatal10110 opened this issue 9 months ago • 4 comments

This PR addresses two issues

  1. binary data can not properly be returned from lua, as it is "string" type in lua, which is assumed by wasmoon to be a regualr utf8 string

This PR handles it by reading the data directly from C memory to JS memory - Its up to you if u want to handle it this way, as it can affect performance, since it requires extra allocations

  1. Binary data can not be properly passed to lua as lua strings, that behave as lua string

This PR handles it by reading JS memory to C memory - It may be handled differentley by mocking string meta methods

fatal10110 avatar Apr 24 '25 20:04 fatal10110

Tests are failing, can you take a look?

ceifa avatar Apr 30 '25 23:04 ceifa

I guess this fixes #122?

ceifa avatar Apr 30 '25 23:04 ceifa

Tests are failing, can you take a look?

Looks like linter issues, will fix it, thanks

I guess this fixes https://github.com/ceifa/wasmoon/issues/122?

Yeap, as I wrote in the description, this aproach is a bit different than what is implemented now in wasmoon, you prefer not to copy the data to C memory, and only pass a reference to it ( I guess performance reasons), but it has some limitations

The return type here is string, but you added the return as number on the field?

Right I will fix it thanks, the idea here is that it returns a pointer, not sure how it worked like that for me :D

fatal10110 avatar May 01 '25 15:05 fatal10110

Fixed lint issues (not related to the PR, for some reason it failed) Made the code backward compatible, string now is a type extension Removed non used lua function definition

fatal10110 avatar May 01 '25 16:05 fatal10110