|
| 1 | +#ifndef WASMTIME_COMPONENT_LINKER_H |
| 2 | +#define WASMTIME_COMPONENT_LINKER_H |
| 3 | + |
| 4 | +#include <wasm.h> |
| 5 | +#include <wasmtime/component/component.h> |
| 6 | +#include <wasmtime/component/instance.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 | +typedef struct wasmtime_component_linker_t wasmtime_component_linker_t; |
| 18 | + |
| 19 | +/** |
| 20 | + * \brief Creates a new #wasmtime_component_linker_t for the specified engine. |
| 21 | + * |
| 22 | + * \param engine the compilation environment and configuration |
| 23 | + * |
| 24 | + * \return a pointer to the newly created #wasmtime_component_linker_t |
| 25 | + */ |
| 26 | +WASM_API_EXTERN wasmtime_component_linker_t * |
| 27 | +wasmtime_component_linker_new(const wasm_engine_t *engine); |
| 28 | + |
| 29 | +/** |
| 30 | + * \brief Instantiates a component instance in a given #wasmtime_context_t |
| 31 | + * |
| 32 | + * \param linker a #wasmtime_component_linker_t that will help provide host |
| 33 | + * functions |
| 34 | + * \param context the #wasmtime_context_t in which the instance should be |
| 35 | + * created |
| 36 | + * \param component the #wasmtime_component_t to instantiate |
| 37 | + * \param instance_out on success, the instantiated |
| 38 | + * #wasmtime_component_instance_t |
| 39 | + * |
| 40 | + * \return wasmtime_error_t* on success `NULL` is returned, otherwise an error |
| 41 | + * is returned which describes why the build failed. |
| 42 | + */ |
| 43 | +WASM_API_EXTERN wasmtime_error_t *wasmtime_component_linker_instantiate( |
| 44 | + const wasmtime_component_linker_t *linker, wasmtime_context_t *context, |
| 45 | + const wasmtime_component_t *component, |
| 46 | + wasmtime_component_instance_t *instance_out); |
| 47 | + |
| 48 | +/** |
| 49 | + * \brief Deletes a #wasmtime_component_linker_t created by |
| 50 | + * #wasmtime_component_linker_new |
| 51 | + * |
| 52 | + * \param linker the #wasmtime_component_linker_t to delete |
| 53 | + */ |
| 54 | +WASM_API_EXTERN void |
| 55 | +wasmtime_component_linker_delete(wasmtime_component_linker_t *linker); |
| 56 | + |
| 57 | +#ifdef __cplusplus |
| 58 | +} // extern "C" |
| 59 | +#endif |
| 60 | + |
| 61 | +#endif // WASMTIME_FEATURE_COMPONENT_MODEL |
| 62 | + |
| 63 | +#endif // WASMTIME_COMPONENT_LINKER_H |
0 commit comments