-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Labels
wasm-proposal:component-modelIssues related to the WebAssembly Component Model proposalIssues related to the WebAssembly Component Model proposalwasmtime:c-apiIssues pertaining to the C API.Issues pertaining to the C API.
Description
(Part of the outstanding items of the component model: #8036 (comment))
There is currently no way to get the type of a function, i.e. the parameters and the return type.
See this implementation in the #9812 PR:
wasmtime/crates/c-api/include/wasmtime/component.h
Lines 312 to 400 in f14d457
| /// Representation of a field in a record type or a case in a variant type | |
| typedef struct wasmtime_component_type_field_t { | |
| /// Name of the record field or variant case | |
| wasm_name_t name; | |
| /// Type of the record field or variant case (may be null for variant case) | |
| wasmtime_component_type_t *ty; | |
| } wasmtime_component_type_field_t; | |
| WASMTIME_COMPONENT_DECLARE_VEC_NEW(type_field_vec, | |
| wasmtime_component_type_field_t); | |
| /// Representation of a result type | |
| typedef struct wasmtime_component_type_result_t { | |
| /// Type of the ok value (if there is one) | |
| wasmtime_component_type_t *ok_ty; | |
| /// Type of the error value (if there is one) | |
| wasmtime_component_type_t *err_ty; | |
| } wasmtime_component_type_result_t; | |
| /// Container for different kind of component model type data | |
| typedef union wasmtime_component_type_payload_t { | |
| /// Field used if #wasmtime_component_type_t::kind is | |
| /// #WASMTIME_COMPONENT_KIND_LIST | |
| wasmtime_component_type_t *list; | |
| /// Field used if #wasmtime_component_type_t::kind is | |
| /// #WASMTIME_COMPONENT_KIND_RECORD | |
| wasmtime_component_type_field_vec_t record; | |
| /// Field used if #wasmtime_component_type_t::kind is | |
| /// #WASMTIME_COMPONENT_KIND_TUPLE | |
| wasmtime_component_type_vec_t tuple; | |
| /// Field used if #wasmtime_component_type_t::kind is | |
| /// #WASMTIME_COMPONENT_KIND_VARIANT | |
| wasmtime_component_type_field_vec_t variant; | |
| /// Field used if #wasmtime_component_type_t::kind is | |
| /// #WASMTIME_COMPONENT_KIND_ENUM | |
| wasmtime_component_string_vec_t enumeration; | |
| /// Field used if #wasmtime_component_type_t::kind is | |
| /// #WASMTIME_COMPONENT_KIND_OPTION | |
| wasmtime_component_type_t *option; | |
| /// Field used if #wasmtime_component_type_t::kind is | |
| /// #WASMTIME_COMPONENT_KIND_RESULT | |
| wasmtime_component_type_result_t result; | |
| /// Field used if #wasmtime_component_type_t::kind is | |
| /// #WASMTIME_COMPONENT_KIND_FLAGS | |
| wasmtime_component_string_vec_t flags; | |
| } wasmtime_component_type_payload_t; | |
| /** | |
| * \brief Representation of a component model type | |
| * | |
| * Many kind of types own data, so those need to be properly dropped in | |
| * wasmtime, and therefore should not live on the stack. | |
| */ | |
| typedef struct wasmtime_component_type_t { | |
| /// Discriminant indicating what kind of type it is, and which field of | |
| /// #payload is valid, if any | |
| wasmtime_component_kind_t kind; | |
| /// Container for the type data, if any | |
| wasmtime_component_type_payload_t payload; | |
| } wasmtime_component_type_t; | |
| WASMTIME_COMPONENT_DECLARE_VEC_NEW(type_vec, wasmtime_component_type_t); | |
| #undef WASMTIME_COMPONENT_DECLARE_VEC_NEW | |
| /** | |
| * \brief Creates a new #wasmtime_component_type_t | |
| * | |
| * This is usually used to create inner types, typically as part of an option or | |
| * result. In this case, ownership is given out to the outer value. | |
| * | |
| * In case where a top level #wasmtime_component_type_t is created (for example | |
| * to be passed directly to #wasmtime_component_linker_define_func), then it | |
| * should be deleted with #wasmtime_component_type_delete | |
| * | |
| * \return a pointer to the newly created #wasmtime_component_type_t | |
| */ | |
| wasmtime_component_type_t *wasmtime_component_type_new(); | |
| /** | |
| * \brief Deletes a #wasmtime_component_type_t previously created by | |
| * #wasmtime_component_type_new | |
| * | |
| * This should not be called if the type has been given out as part of an outer | |
| * #wasmtime_component_type_t | |
| * | |
| * \param val the #wasmtime_component_type_t to delete | |
| */ | |
| void wasmtime_component_type_delete(wasmtime_component_type_t *ty); |
UserMist
Metadata
Metadata
Assignees
Labels
wasm-proposal:component-modelIssues related to the WebAssembly Component Model proposalIssues related to the WebAssembly Component Model proposalwasmtime:c-apiIssues pertaining to the C API.Issues pertaining to the C API.