Wasmtime
component/linker.h
Go to the documentation of this file.
1
2
3#ifndef WASMTIME_COMPONENT_LINKER_H
4#define WASMTIME_COMPONENT_LINKER_H
5
6#include <wasm.h>
9#include <wasmtime/conf.h>
10#include <wasmtime/error.h>
11#include <wasmtime/module.h>
12#include <wasmtime/store.h>
13
14#ifdef WASMTIME_FEATURE_COMPONENT_MODEL
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
22
26
34WASM_API_EXTERN wasmtime_component_linker_t *
36
43WASM_API_EXTERN void
45 bool allow);
46
58
74 const wasmtime_component_linker_t *linker, wasmtime_context_t *context,
75 const wasmtime_component_t *component,
76 wasmtime_component_instance_t *instance_out);
77
84WASM_API_EXTERN void
86
105WASM_API_EXTERN wasmtime_error_t *
107 wasmtime_component_linker_instance_t *linker_instance, const char *name,
108 size_t name_len,
109 wasmtime_component_linker_instance_t **linker_instance_out);
110
125 wasmtime_component_linker_instance_t *linker_instance, const char *name,
126 size_t name_len, const wasmtime_module_t *module);
127
129typedef wasmtime_error_t *(*wasmtime_component_func_callback_t)(
130 void *, wasmtime_context_t *, const wasmtime_component_val_t *, size_t,
131 wasmtime_component_val_t *, size_t);
132
146 wasmtime_component_linker_instance_t *linker_instance, const char *name,
147 size_t name_len, wasmtime_component_func_callback_t callback, void *data,
148 void (*finalizer)(void *));
149
150#ifdef WASMTIME_FEATURE_WASI
151
155WASM_API_EXTERN wasmtime_error_t *
157
158#endif // WASMTIME_FEATURE_WASI
159
162typedef wasmtime_error_t *(*wasmtime_component_resource_destructor_t)(
163 void *, wasmtime_context_t *, uint32_t);
164
176WASM_API_EXTERN wasmtime_error_t *
178 wasmtime_component_linker_instance_t *linker_instance, const char *name,
179 size_t name_len, const wasmtime_component_resource_type_t *resource,
180 wasmtime_component_resource_destructor_t destructor, void *data,
181 void (*finalizer)(void *));
182
189 wasmtime_component_linker_instance_t *linker_instance);
190
191#ifdef __cplusplus
192} // extern "C"
193#endif
194
195#endif // WASMTIME_FEATURE_COMPONENT_MODEL
196
197#endif // WASMTIME_COMPONENT_LINKER_H
struct wasmtime_component_t wasmtime_component_t
Representation of a component in the component model.
Definition: component/component.h:17
wasmtime_error_t * wasmtime_component_linker_instance_add_module(wasmtime_component_linker_instance_t *linker_instance, const char *name, size_t name_len, const wasmtime_module_t *module)
Defines a wasmtime_module_t within this instance.
wasmtime_component_linker_t * wasmtime_component_linker_new(const wasm_engine_t *engine)
Creates a new wasmtime_component_linker_t for the specified engine.
struct wasmtime_component_linker_instance_t wasmtime_component_linker_instance_t
Structure representing an "instance" being defined within a linker.
Definition: component/linker.h:24
wasmtime_error_t * wasmtime_component_linker_instantiate(const wasmtime_component_linker_t *linker, wasmtime_context_t *context, const wasmtime_component_t *component, wasmtime_component_instance_t *instance_out)
Instantiates a component instance in a given wasmtime_context_t.
wasmtime_error_t *(* wasmtime_component_resource_destructor_t)(void *, wasmtime_context_t *, uint32_t)
Definition: component/linker.h:162
void wasmtime_component_linker_allow_shadowing(wasmtime_component_linker_t *linker, bool allow)
Configures whether this linker allows later definitions to shadow previous definitions.
void wasmtime_component_linker_instance_delete(wasmtime_component_linker_instance_t *linker_instance)
Deletes a wasmtime_component_linker_instance_t.
wasmtime_component_linker_instance_t * wasmtime_component_linker_root(wasmtime_component_linker_t *linker)
Returns the "root instance" of this linker, used to define names into the root namespace.
struct wasmtime_component_linker_t wasmtime_component_linker_t
A type used to instantiate a wasmtime_component_t.
Definition: component/linker.h:21
wasmtime_error_t * wasmtime_component_linker_instance_add_func(wasmtime_component_linker_instance_t *linker_instance, const char *name, size_t name_len, wasmtime_component_func_callback_t callback, void *data, void(*finalizer)(void *))
Define a function within this instance.
wasmtime_error_t * wasmtime_component_linker_instance_add_instance(wasmtime_component_linker_instance_t *linker_instance, const char *name, size_t name_len, wasmtime_component_linker_instance_t **linker_instance_out)
Defines a nested instance within this instance.
wasmtime_error_t * wasmtime_component_linker_instance_add_resource(wasmtime_component_linker_instance_t *linker_instance, const char *name, size_t name_len, const wasmtime_component_resource_type_t *resource, wasmtime_component_resource_destructor_t destructor, void *data, void(*finalizer)(void *))
Defines a new resource type within this instance.
wasmtime_error_t * wasmtime_component_linker_add_wasip2(wasmtime_component_linker_t *linker)
Add all WASI interfaces into the linker provided.
void wasmtime_component_linker_delete(wasmtime_component_linker_t *linker)
Deletes a wasmtime_component_linker_t created by wasmtime_component_linker_new.
wasmtime_error_t *(* wasmtime_component_func_callback_t)(void *, wasmtime_context_t *, const wasmtime_component_val_t *, size_t, wasmtime_component_val_t *, size_t)
Type of the callback used in wasmtime_component_linker_instance_add_func.
Definition: component/linker.h:129
struct wasmtime_component_resource_type wasmtime_component_resource_type_t
Represents the type of a component resource.
Definition: component/val.h:23
Build-time defines for how the C API was built.
Definition and accessors of wasmtime_error_t.
Compilation environment and configuration.
Representation of a instance in Wasmtime.
Definition: component/instance.h:24
Represents possible runtime values which a component function can either consume or produce.
Definition: component/val.h:425
An interior pointer into a wasmtime_store_t which is used as "context" for many functions.
Errors generated by Wasmtime.
A compiled Wasmtime module.