JanProvaznik / MSBuildWasm

MIT License
1 stars 0 forks source link

easy passing of data between Host and Guest #6

Open JanProvaznik opened 2 weeks ago

JanProvaznik commented 2 weeks ago

We need to pass complex data types, The most complex data type is list<dict<string,string>>. JSON seems appropriate as all languages have libraries for it.

This would not be needed if instead of modules as tasks we used components with WIT which support complex data types. However wasmtime-dotnet does not support components as of now.

WebAssembly supports only ints as return and parameter types without WIT. Likely solution: We have a shared memory. For each data transfer:

  1. serialize to json using library
  2. write the json to shared memory
  3. create a struct in shared memory which holds 2 numbers: ptr to json and len how many bytes it is.
  4. in the transferring function return pointer to this struct struct_ptr
  5. host or guest reads ptr and len from shared memory using struct_ptr
  6. host or guest reads json from shared memory using ptr and len
  7. parse using libraries

ACTION: Refactor to use stdin for input parameters and stdout for output parameters and taskinfo