Add support for structref to the C and C++ APIs#12915
Add support for structref to the C and C++ APIs#12915fitzgen wants to merge 2 commits intobytecodealliance:mainfrom
structref to the C and C++ APIs#12915Conversation
Also requires adding support for struct and field types, as well as `StructRefPre`.
| let storage = match ft.kind { | ||
| WASMTIME_I8 => StorageType::I8, | ||
| WASMTIME_I16 => StorageType::I16, | ||
| crate::WASMTIME_I32 => StorageType::ValType(ValType::I32), | ||
| crate::WASMTIME_I64 => StorageType::ValType(ValType::I64), | ||
| crate::WASMTIME_F32 => StorageType::ValType(ValType::F32), | ||
| crate::WASMTIME_F64 => StorageType::ValType(ValType::F64), | ||
| crate::WASMTIME_V128 => StorageType::ValType(ValType::V128), | ||
| crate::WASMTIME_FUNCREF => StorageType::ValType(ValType::FUNCREF), | ||
| crate::WASMTIME_EXTERNREF => StorageType::ValType(ValType::EXTERNREF), | ||
| crate::WASMTIME_ANYREF => StorageType::ValType(ValType::ANYREF), | ||
| other => panic!("unknown wasmtime_storage_kind_t: {other}"), |
There was a problem hiding this comment.
Ah that didn't exist yet, I can rebase and add that here
| } | ||
|
|
||
| /// Get the underlying C pointer (non-owning). | ||
| const wasmtime_struct_ref_pre_t *c_ptr() const { return ptr.get(); } |
There was a problem hiding this comment.
s/c_ptr/capi/
(I think that's used elsewhere throughout).
Also, can this use the WASMTIME_OWN_WRAPPER helper macro? (and maybe some of the other helper macros in other places if applicable?)
There was a problem hiding this comment.
It may also be worth making a macro for the GC types since they're all going to be quite similar.
There was a problem hiding this comment.
There aren't that many GC types and the casts available is all going to defer, so I think I'll avoid a new macro for GC types
| /// \brief An 8-bit packed integer (only valid inside struct/array fields). | ||
| #define WASMTIME_I8 8 | ||
| /// \brief A 16-bit packed integer (only valid inside struct/array fields). | ||
| #define WASMTIME_I16 9 |
There was a problem hiding this comment.
bikeshed: WASMTIME_STORAGE_KIND_I8?
Subscribe to Label Actioncc @fitzgen DetailsThis issue or pull request has been labeled: "wasmtime:api", "wasmtime:c-api", "wasmtime:ref-types"Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
Also requires adding support for struct and field types, as well as
StructRefPre.Depends on #12914