-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cue/interpreter/wasm: add support for Wasm functions that take and re…
…turn structs Add support for structs in Wasm functions. A function declares that is uses or returns a struct by referring to a CUE struct (defined elsewhere) in its type signature. The CUE struct is a straightforward translation of the native struct type with native scalars replaced by their CUE counterpats (e.g. u32 in Rust becomes uint32 in CUE, int16_t in C becomes int16 in CUE, etc). The order of fields in the CUE struct must match that of the target language. Only structs that contain scalars or other supported structs are currently supported. Struct fields that are pointers in the target language are not currently supported. This may change. In order to support structs CUE needs access to the memory allocator of the guest program. For this, the guest must export two Wasm functions with the following C type signatures: void* allocate(int n); void deallocate(void *ptr, int n); Allocate returns a Wasm pointer to a buffer of size n. Deallocate takes a Wasm pointer and the size of the buffer it points to and frees it. Updates #2035. Updates #2281. Change-Id: Ic509448226b22d2a54b70d565db6c702b801a839 Signed-off-by: Aram Hăvărneanu <aram@mgk.ro>
- Loading branch information
Showing
12 changed files
with
1,041 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.