Wasmtime
component/val.h
Go to the documentation of this file.
1
2
3#ifndef WASMTIME_COMPONENT_VAL_H
4#define WASMTIME_COMPONENT_VAL_H
5
6#include <wasmtime/conf.h>
7
8#ifdef WASMTIME_FEATURE_COMPONENT_MODEL
9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
16
19#define WASMTIME_COMPONENT_BOOL 0
22#define WASMTIME_COMPONENT_S8 1
25#define WASMTIME_COMPONENT_U8 2
28#define WASMTIME_COMPONENT_S16 3
31#define WASMTIME_COMPONENT_U16 4
34#define WASMTIME_COMPONENT_S32 5
37#define WASMTIME_COMPONENT_U32 6
40#define WASMTIME_COMPONENT_S64 7
43#define WASMTIME_COMPONENT_U64 8
46#define WASMTIME_COMPONENT_F32 9
49#define WASMTIME_COMPONENT_F64 10
52#define WASMTIME_COMPONENT_CHAR 11
55#define WASMTIME_COMPONENT_STRING 12
58#define WASMTIME_COMPONENT_LIST 13
61#define WASMTIME_COMPONENT_RECORD 14
64#define WASMTIME_COMPONENT_TUPLE 15
67#define WASMTIME_COMPONENT_VARIANT 16
70#define WASMTIME_COMPONENT_ENUM 17
73#define WASMTIME_COMPONENT_OPTION 18
76#define WASMTIME_COMPONENT_RESULT 19
79#define WASMTIME_COMPONENT_FLAGS 20
80
83
84#define DECLARE_VEC(name, type) \
85 \
86 typedef struct name { \
87 \
88 size_t size; \
89 \
90 type *data; \
91 } name##_t; \
92 \
93 \
94 WASM_API_EXTERN void name##_new(name##_t *out, size_t size, type *ptr); \
95 \
96 WASM_API_EXTERN void name##_new_empty(name##_t *out); \
97 \
98 WASM_API_EXTERN void name##_new_uninit(name##_t *out, size_t size); \
99 \
100 WASM_API_EXTERN void name##_copy(name##_t *dst, const name##_t *src); \
101 \
102 WASM_API_EXTERN void name##_delete(name##_t *value);
103
109
110#undef DECLARE_VEC
111
113typedef struct {
119
121typedef struct {
123 bool is_ok;
128
131typedef union {
135 int8_t s8;
137 uint8_t u8;
139 int16_t s16;
141 uint16_t u16;
143 int32_t s32;
145 uint32_t u32;
147 int64_t s64;
149 uint64_t u64;
155 uint32_t character;
180
189
198
201
203WASM_API_EXTERN void
205
206#ifdef __cplusplus
207} // extern "C"
208#endif
209
210#endif // WASMTIME_FEATURE_COMPONENT_MODEL
211
212#endif // WASMTIME_COMPONENT_VAL_H
struct wasmtime_component_valrecord_entry wasmtime_component_valrecord_entry_t
A pair of a name and a value that represents one entry in a value with kind WASMTIME_COMPONENT_RECORD...
WASM_API_EXTERN wasmtime_component_val_t * wasmtime_component_val_new()
Allocates a new wasmtime_component_val_t.
uint8_t wasmtime_component_valkind_t
Discriminant used in wasmtime_component_val_t::kind.
Definition: component/val.h:15
struct wasmtime_component_val wasmtime_component_val_t
Represents possible runtime values which a component function can either consume or produce.
WASM_API_EXTERN void wasmtime_component_val_delete(wasmtime_component_val_t *value)
Calls the destructor on value deallocating any owned memory.
Build-time defines for how the C API was built.
A list of bytes.
Definition: wasm.h:102
Represents possible runtime values which a component function can either consume or produce.
Definition: component/val.h:183
wasmtime_component_valunion_t of
Value of type kind.
Definition: component/val.h:187
wasmtime_component_valkind_t kind
The type discriminant.
Definition: component/val.h:185
A vec of a wasm_name_t
Definition: component/val.h:108
A vec of a struct wasmtime_component_val
Definition: component/val.h:104
A pair of a name and a value that represents one entry in a value with kind WASMTIME_COMPONENT_RECORD...
Definition: component/val.h:192
wasmtime_component_val_t val
The value of this entry.
Definition: component/val.h:196
wasm_name_t name
The name of this entry.
Definition: component/val.h:194
A vec of a struct wasmtime_component_valrecord_entry
Definition: component/val.h:106
Represents a result type.
Definition: component/val.h:121
bool is_ok
The discriminant of the result.
Definition: component/val.h:123
struct wasmtime_component_val * val
Definition: component/val.h:126
A vec of a struct wasmtime_component_val
Definition: component/val.h:107
Represents a variant type.
Definition: component/val.h:113
struct wasmtime_component_val * val
The payload of the variant.
Definition: component/val.h:117
wasm_name_t discriminant
The discriminant of the variant.
Definition: component/val.h:115
Represents possible runtime values which a component function can either consume or produce.
Definition: component/val.h:131
uint16_t u16
Field used if wasmtime_component_val_t::kind is WASMTIME_COMPONENT_U16.
Definition: component/val.h:141
wasm_name_t string
Definition: component/val.h:158
int64_t s64
Field used if wasmtime_component_val_t::kind is WASMTIME_COMPONENT_S64.
Definition: component/val.h:147
bool boolean
Field used if wasmtime_component_val_t::kind is WASMTIME_COMPONENT_BOOL.
Definition: component/val.h:133
wasmtime_component_valvariant_t variant
Definition: component/val.h:168
uint32_t u32
Field used if wasmtime_component_val_t::kind is WASMTIME_COMPONENT_U32.
Definition: component/val.h:145
wasmtime_component_vallist_t list
Field used if wasmtime_component_val_t::kind is WASMTIME_COMPONENT_LIST.
Definition: component/val.h:160
int32_t s32
Field used if wasmtime_component_val_t::kind is WASMTIME_COMPONENT_S32.
Definition: component/val.h:143
float32_t f32
Field used if wasmtime_component_val_t::kind is WASMTIME_COMPONENT_F32.
Definition: component/val.h:151
float64_t f64
Field used if wasmtime_component_val_t::kind is WASMTIME_COMPONENT_F64.
Definition: component/val.h:153
struct wasmtime_component_val * option
Definition: component/val.h:173
int16_t s16
Field used if wasmtime_component_val_t::kind is WASMTIME_COMPONENT_S16.
Definition: component/val.h:139
uint8_t u8
Field used if wasmtime_component_val_t::kind is WASMTIME_COMPONENT_U8.
Definition: component/val.h:137
wasmtime_component_valrecord_t record
Definition: component/val.h:163
uint64_t u64
Field used if wasmtime_component_val_t::kind is WASMTIME_COMPONENT_U64.
Definition: component/val.h:149
wasmtime_component_valresult_t result
Definition: component/val.h:176
uint32_t character
Field used if wasmtime_component_val_t::kind is WASMTIME_COMPONENT_CHAR.
Definition: component/val.h:155
wasmtime_component_valflags_t flags
Field used if wasmtime_component_val_t::kind is WASMTIME_COMPONENT_FLAGS.
Definition: component/val.h:178
wasmtime_component_valtuple_t tuple
Field used if wasmtime_component_val_t::kind is WASMTIME_COMPONENT_TUPLE.
Definition: component/val.h:165
int8_t s8
Field used if wasmtime_component_val_t::kind is WASMTIME_COMPONENT_S8.
Definition: component/val.h:135
wasm_name_t enumeration
Field used if wasmtime_component_val_t::kind is WASMTIME_COMPONENT_ENUM.
Definition: component/val.h:170
float float32_t
A type definition for a 32-bit float.
Definition: wasm.h:44
double float64_t
A type definition for a 64-bit float.
Definition: wasm.h:45