1 /// \file wasmtime/component/func.h 2 3 #ifndef WASMTIME_COMPONENT_FUNC_H 4 #define WASMTIME_COMPONENT_FUNC_H 5 6 #include <wasmtime/component/val.h> 7 #include <wasmtime/conf.h> 8 #include <wasmtime/error.h> 9 #include <wasmtime/store.h> 10 11 #ifdef WASMTIME_FEATURE_COMPONENT_MODEL 12 13 #ifdef __cplusplus 14 extern "C" { 15 #endif 16 17 /// \brief Representation of a function in Wasmtime. 18 /// 19 /// Functions in Wasmtime are represented as an index into a store and don't 20 /// have any data or destructor associated with the value. Functions cannot 21 /// interoperate between #wasmtime_store_t instances and if the wrong function 22 /// is passed to the wrong store then it may trigger an assertion to abort the 23 /// process. 24 typedef struct wasmtime_component_func { 25 /// Internal identifier of what store this belongs to, never zero. 26 uint64_t store_id; 27 /// Internal index within the store. 28 size_t index; 29 } wasmtime_component_func_t; 30 31 /// \brief Invokes \p func with the \p args given and returns the result. 32 /// 33 /// The \p args provided must match the parameters that this function takes in 34 /// terms of their types and the number of parameters. Results will be written 35 /// to the \p results provided if the call completes successfully. The initial 36 /// types of the values in \p results are ignored and values are overwritten to 37 /// write the result. It's required that the \p results_size exactly matches the 38 /// number of results that this function produces. 39 WASM_API_EXTERN wasmtime_error_t *wasmtime_component_func_call( 40 const wasmtime_component_func_t *func, wasmtime_context_t *context, 41 const wasmtime_component_val_t *args, size_t args_size, 42 wasmtime_component_val_t *results, size_t results_size); 43 44 #ifdef __cplusplus 45 } // extern "C" 46 #endif 47 48 #endif // WASMTIME_FEATURE_COMPONENT_MODEL 49 50 #endif // WASMTIME_COMPONENT_FUNC_H 51