Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bytecodealliance
GitHub Repository: bytecodealliance/wasmtime
Path: blob/main/crates/c-api/include/doc-wasm.h
1692 views
1
/* clang-format off */
2
3
/**
4
* \file wasm.h
5
*
6
* Upstream Embedding API for WebAssembly.
7
*
8
* This API is defined by the upstream wasm-c-api proposal at
9
* https://github.com/WebAssembly/wasm-c-api. That proposal is in flux but
10
* Wasmtime intends to be active in its development.
11
*
12
* The documentation for this header file is currently defined in the Wasmtime
13
* project, not in the upstream header file. Some behavior here may be
14
* Wasmtime-specific and may not be portable to other engines implementing the
15
* same C API. Also note that not all functionality from the upstream C API is
16
* implemented in Wasmtime. We strive to provide all symbols as to not generate
17
* link errors but some functions are unimplemented and will abort the process
18
* if called.
19
*
20
* ### Memory Management
21
*
22
* Memory management in the wasm C API is intended to be relatively simple. Each
23
* individual object is reference counted unless otherwise noted. You can delete
24
* any object at any time after you no longer need it. Deletion of an object
25
* does not imply that the memory will be deallocated at that time. If another
26
* object still internally references the original object then the memory will
27
* still be alive.
28
*
29
* For example you can delete a #wasm_engine_t after you create a #wasm_store_t
30
* with #wasm_store_new. The engine, however, is still referenced by the
31
* #wasm_store_t so it will not be deallocated. In essence by calling
32
* #wasm_engine_delete you're release your own strong reference on the
33
* #wasm_engine_t, but that's it.
34
*
35
* Additionally APIs like #wasm_memory_copy do not actually copy the underlying
36
* data. Instead they only increment the reference count and return a new
37
* object. You'll need to still call #wasm_memory_delete (or the corresponding
38
* `*_delete` function) for each copy of an object you acquire.
39
*
40
* ### Vectors
41
*
42
* This API provides a number of `wasm_*_vec_t` type definitions and functions
43
* to work with them. Each vector is defined by a pointer and a length.
44
* "Ownership" of a vector refers to the data pointer, not the memory holding
45
* the data pointer and the length. It is safe, for example to create a
46
* #wasm_name_t on the stack and pass it to #wasm_importtype_new. The memory
47
* pointed to by #wasm_name_t must be properly initialized, however, and cannot
48
* reside on the stack.
49
*/
50
51
/**
52
* \typedef byte_t
53
* \brief A type definition for a number that occupies a single byte of data.
54
*
55
* \typedef wasm_byte_t
56
* \brief A type definition for a number that occupies a single byte of data.
57
*
58
* \typedef float32_t
59
* \brief A type definition for a 32-bit float.
60
*
61
* \typedef float64_t
62
* \brief A type definition for a 64-bit float.
63
*
64
* \typedef wasm_name_t
65
* \brief Convenience for hinting that an argument only accepts utf-8 input.
66
*/
67
68
/**
69
* \typedef wasm_config_t
70
* \brief Convenience alias for #wasm_config_t
71
*
72
* \struct wasm_config_t
73
* \brief Global engine configuration
74
*
75
* This structure represents global configuration used when constructing a
76
* #wasm_engine_t. There are now functions to modify this from wasm.h but the
77
* wasmtime/config.h header provides a number of Wasmtime-specific functions to
78
* tweak configuration options.
79
*
80
* This object is created with #wasm_config_new.
81
*
82
* Configuration is safe to share between threads. Typically you'll create a
83
* config object and immediately pass it into #wasm_engine_new_with_config,
84
* however.
85
*
86
* For more information about configuration see the Rust documentation as well
87
* at
88
* https://bytecodealliance.github.io/wasmtime/api/wasmtime/struct.Config.html.
89
*
90
* \fn wasm_config_t *wasm_config_new(void);
91
* \brief Creates a new empty configuration object.
92
*
93
* The object returned is owned by the caller and will need to be deleted with
94
* #wasm_config_delete. May return `NULL` if a configuration object could not be
95
* allocated.
96
*
97
* \fn void wasm_config_delete(wasm_config_t*);
98
* \brief Deletes a configuration object.
99
*/
100
101
/**
102
* \typedef wasm_engine_t
103
* \brief Convenience alias for #wasm_engine_t
104
*
105
* \struct wasm_engine_t
106
* \brief Compilation environment and configuration.
107
*
108
* An engine is typically global in a program and contains all the configuration
109
* necessary for compiling wasm code. From an engine you'll typically create a
110
* #wasmtime_store_t. Engines are created with #wasm_engine_new or
111
* #wasm_engine_new_with_config.
112
*
113
* An engine is safe to share between threads. Multiple stores can be created
114
* within the same engine with each store living on a separate thread. Typically
115
* you'll create one #wasm_engine_t for the lifetime of your program.
116
*
117
* Engines are reference counted internally so #wasm_engine_delete can be called
118
* at any time after a #wasmtime_store_t has been created from one.
119
*
120
* \fn wasm_engine_t *wasm_engine_new(void);
121
* \brief Creates a new engine with the default configuration.
122
*
123
* The object returned is owned by the caller and will need to be deleted with
124
* #wasm_engine_delete. This may return `NULL` if the engine could not be
125
* allocated.
126
*
127
* \fn wasm_engine_t *wasm_engine_new_with_config(wasm_config_t *);
128
* \brief Creates a new engine with the specified configuration.
129
*
130
* This function will take ownership of the configuration specified regardless
131
* of the outcome of this function. You do not need to call #wasm_config_delete
132
* on the argument. The object returned is owned by the caller and will need to
133
* be deleted with #wasm_engine_delete. This may return `NULL` if the engine
134
* could not be allocated.
135
*
136
* \fn void wasm_engine_delete(wasm_engine_t*);
137
* \brief Deletes an engine.
138
*/
139
140
/**
141
* \typedef wasm_store_t
142
* \brief Convenience alias for #wasm_store_t
143
*
144
* \struct wasm_store_t
145
* \brief A collection of instances and wasm global items.
146
*
147
* A #wasm_store_t corresponds to the concept of an [embedding
148
* store](https://webassembly.github.io/spec/core/exec/runtime.html#store)
149
*
150
* \fn wasm_store_t *wasm_store_new(wasm_engine_t *);
151
* \brief Creates a new store within the specified engine.
152
*
153
* The object returned is owned by the caller and will need to be deleted with
154
* #wasm_store_delete. This may return `NULL` if the store could not be
155
* allocated.
156
*
157
* \fn void wasm_store_delete(wasm_store_t *);
158
* \brief Deletes the specified store.
159
*/
160
161
/**
162
* \struct wasm_byte_vec_t
163
* \brief A list of bytes
164
*
165
* Used to pass data in or pass data out of various functions. The meaning and
166
* ownership of the bytes is defined by each API that operates on this
167
* datatype.
168
*
169
* \var wasm_byte_vec_t::size
170
* \brief Length of this vector.
171
*
172
* \var wasm_byte_vec_t::data
173
* \brief Pointer to the base of this vector
174
*
175
* \typedef wasm_byte_vec_t
176
* \brief Convenience alias for #wasm_byte_vec_t
177
*
178
* \typedef wasm_message_t
179
* \brief Alias of #wasm_byte_vec_t which always has a trailing 0-byte.
180
*
181
* \fn wasm_name
182
* \brief Unused by Wasmtime
183
*
184
* \fn wasm_name_new
185
* \brief Convenience alias
186
*
187
* \fn wasm_name_new_empty
188
* \brief Convenience alias
189
*
190
* \fn wasm_name_new_new_uninitialized
191
* \brief Convenience alias
192
*
193
* \fn wasm_name_new_from_string
194
* \brief Create a new name from a C string.
195
*
196
* \fn wasm_name_new_from_string_nt
197
* \brief Create a new name from a C string with null terminator.
198
*
199
* \fn wasm_name_copy
200
* \brief Convenience alias
201
*
202
* \fn wasm_name_delete
203
* \brief Convenience alias
204
*
205
* \fn void wasm_byte_vec_new_empty(wasm_byte_vec_t *out);
206
* \brief Initializes an empty byte vector.
207
*
208
* \fn void wasm_byte_vec_new_uninitialized(wasm_byte_vec_t *out, size_t);
209
* \brief Initializes an byte vector with the specified capacity.
210
*
211
* This function will initialize the provided vector with capacity to hold the
212
* specified number of bytes. The `out` parameter must previously not already be
213
* initialized and after this function is called you are then responsible for
214
* ensuring #wasm_byte_vec_delete is called.
215
*
216
* \fn void wasm_byte_vec_new(wasm_byte_vec_t *out, size_t, wasm_byte_t const[]);
217
* \brief Copies the specified data into a new byte vector.
218
*
219
* This function will copy the provided data into this byte vector. The byte
220
* vector should not be previously initialized and the caller is responsible for
221
* calling #wasm_byte_vec_delete after this function returns.
222
*
223
* Note that memory of the initialization vector provided to this function
224
* must be managed externally. This function will copy the contents to the
225
* output vector, but it's up to the caller to properly deallocate the memory.
226
*
227
* \fn void wasm_byte_vec_copy(wasm_byte_vec_t *out, const wasm_byte_vec_t *);
228
* \brief Copies one vector into a new vector.
229
*
230
* Copies the second argument's data into the first argument. The `out` vector
231
* should not be previously initialized and after this function returns you're
232
* responsible for calling #wasm_byte_vec_delete.
233
*
234
* \fn void wasm_byte_vec_delete(wasm_byte_vec_t *);
235
* \brief Deletes a byte vector.
236
*
237
* This function will deallocate the data referenced by the argument provided.
238
* This does not deallocate the memory holding the #wasm_byte_vec_t itself, it's
239
* expected that memory is owned by the caller.
240
*/
241
242
/**
243
* \struct wasm_valtype_t
244
* \brief An object representing the type of a value.
245
*
246
* \typedef wasm_valtype_t
247
* \brief Convenience alias for #wasm_valtype_t
248
*
249
* \struct wasm_valtype_vec_t
250
* \brief A list of #wasm_valtype_t values.
251
*
252
* \var wasm_valtype_vec_t::size
253
* \brief Length of this vector.
254
*
255
* \var wasm_valtype_vec_t::data
256
* \brief Pointer to the base of this vector
257
*
258
* \typedef wasm_valtype_vec_t
259
* \brief Convenience alias for #wasm_valtype_vec_t
260
*
261
* \fn void wasm_valtype_delete(wasm_valtype_t *);
262
* \brief Deletes a type.
263
*
264
* \fn void wasm_valtype_vec_new_empty(wasm_valtype_vec_t *out);
265
* \brief Creates an empty vector.
266
*
267
* See #wasm_byte_vec_new_empty for more information.
268
*
269
* \fn void wasm_valtype_vec_new_uninitialized(wasm_valtype_vec_t *out, size_t);
270
* \brief Creates a vector with the given capacity.
271
*
272
* See #wasm_byte_vec_new_uninitialized for more information.
273
*
274
* \fn void wasm_valtype_vec_new(wasm_valtype_vec_t *out, size_t, wasm_valtype_t *const[]);
275
* \brief Creates a vector with the provided contents.
276
*
277
* See #wasm_byte_vec_new for more information.
278
*
279
* \fn void wasm_valtype_vec_copy(wasm_valtype_vec_t *out, const wasm_valtype_vec_t *)
280
* \brief Copies one vector to another
281
*
282
* See #wasm_byte_vec_copy for more information.
283
*
284
* \fn void wasm_valtype_vec_delete(wasm_valtype_vec_t *out)
285
* \brief Deallocates memory for a vector.
286
*
287
* See #wasm_byte_vec_delete for more information.
288
*
289
* \fn wasm_valtype_t* wasm_valtype_copy(const wasm_valtype_t *)
290
* \brief Creates a new value which matches the provided one.
291
*
292
* The caller is responsible for deleting the returned value.
293
*
294
* \fn wasm_valtype_t* wasm_valtype_new(wasm_valkind_t);
295
* \brief Creates a new value type from the specified kind.
296
*
297
* The caller is responsible for deleting the returned value.
298
*
299
* \fn wasm_valkind_t wasm_valtype_kind(const wasm_valtype_t *);
300
* \brief Returns the associated kind for this value type.
301
*/
302
303
/**
304
* \typedef wasm_valkind_t
305
* \brief Different kinds of types supported in wasm.
306
*/
307
308
/**
309
* \struct wasm_functype_t
310
* \brief An opaque object representing the type of a function.
311
*
312
* \typedef wasm_functype_t
313
* \brief Convenience alias for #wasm_functype_t
314
*
315
* \struct wasm_functype_vec_t
316
* \brief A list of #wasm_functype_t values.
317
*
318
* \var wasm_functype_vec_t::size
319
* \brief Length of this vector.
320
*
321
* \var wasm_functype_vec_t::data
322
* \brief Pointer to the base of this vector
323
*
324
* \typedef wasm_functype_vec_t
325
* \brief Convenience alias for #wasm_functype_vec_t
326
*
327
* \fn void wasm_functype_delete(wasm_functype_t *);
328
* \brief Deletes a type.
329
*
330
* \fn void wasm_functype_vec_new_empty(wasm_functype_vec_t *out);
331
* \brief Creates an empty vector.
332
*
333
* See #wasm_byte_vec_new_empty for more information.
334
*
335
* \fn void wasm_functype_vec_new_uninitialized(wasm_functype_vec_t *out, size_t);
336
* \brief Creates a vector with the given capacity.
337
*
338
* See #wasm_byte_vec_new_uninitialized for more information.
339
*
340
* \fn void wasm_functype_vec_new(wasm_functype_vec_t *out, size_t, wasm_functype_t *const[]);
341
* \brief Creates a vector with the provided contents.
342
*
343
* See #wasm_byte_vec_new for more information.
344
*
345
* \fn void wasm_functype_vec_copy(wasm_functype_vec_t *out, const wasm_functype_vec_t *)
346
* \brief Copies one vector to another
347
*
348
* See #wasm_byte_vec_copy for more information.
349
*
350
* \fn void wasm_functype_vec_delete(wasm_functype_vec_t *out)
351
* \brief Deallocates memory for a vector.
352
*
353
* See #wasm_byte_vec_delete for more information.
354
*
355
* \fn wasm_functype_t* wasm_functype_copy(const wasm_functype_t *)
356
* \brief Creates a new value which matches the provided one.
357
*
358
* The caller is responsible for deleting the returned value.
359
*
360
* \fn wasm_functype_t* wasm_functype_new(wasm_valtype_vec_t *params, wasm_valtype_vec_t *results);
361
* \brief Creates a new function type with the provided parameter and result
362
* types.
363
*
364
* This function takes ownership of the `params` and `results` arguments.
365
*
366
* The caller is responsible for deleting the returned value.
367
*
368
* \fn const wasm_valtype_vec_t* wasm_functype_params(const wasm_functype_t *);
369
* \brief Returns the list of parameters of this function type.
370
*
371
* The returned memory is owned by the #wasm_functype_t argument, the caller
372
* should not deallocate it.
373
*
374
* \fn const wasm_valtype_vec_t* wasm_functype_results(const wasm_functype_t *);
375
* \brief Returns the list of results of this function type.
376
*
377
* The returned memory is owned by the #wasm_functype_t argument, the caller
378
* should not deallocate it.
379
*/
380
381
/**
382
* \struct wasm_globaltype_t
383
* \brief An opaque object representing the type of a global.
384
*
385
* \typedef wasm_globaltype_t
386
* \brief Convenience alias for #wasm_globaltype_t
387
*
388
* \struct wasm_globaltype_vec_t
389
* \brief A list of #wasm_globaltype_t values.
390
*
391
* \var wasm_globaltype_vec_t::size
392
* \brief Length of this vector.
393
*
394
* \var wasm_globaltype_vec_t::data
395
* \brief Pointer to the base of this vector
396
*
397
* \typedef wasm_globaltype_vec_t
398
* \brief Convenience alias for #wasm_globaltype_vec_t
399
*
400
* \fn void wasm_globaltype_delete(wasm_globaltype_t *);
401
* \brief Deletes a type.
402
*
403
* \fn void wasm_globaltype_vec_new_empty(wasm_globaltype_vec_t *out);
404
* \brief Creates an empty vector.
405
*
406
* See #wasm_byte_vec_new_empty for more information.
407
*
408
* \fn void wasm_globaltype_vec_new_uninitialized(wasm_globaltype_vec_t *out, size_t);
409
* \brief Creates a vector with the given capacity.
410
*
411
* See #wasm_byte_vec_new_uninitialized for more information.
412
*
413
* \fn void wasm_globaltype_vec_new(wasm_globaltype_vec_t *out, size_t, wasm_globaltype_t *const[]);
414
* \brief Creates a vector with the provided contents.
415
*
416
* See #wasm_byte_vec_new for more information.
417
*
418
* \fn void wasm_globaltype_vec_copy(wasm_globaltype_vec_t *out, const wasm_globaltype_vec_t *)
419
* \brief Copies one vector to another
420
*
421
* See #wasm_byte_vec_copy for more information.
422
*
423
* \fn void wasm_globaltype_vec_delete(wasm_globaltype_vec_t *out)
424
* \brief Deallocates memory for a vector.
425
*
426
* See #wasm_byte_vec_delete for more information.
427
*
428
* \fn wasm_globaltype_t* wasm_globaltype_copy(const wasm_globaltype_t *)
429
* \brief Creates a new value which matches the provided one.
430
*
431
* The caller is responsible for deleting the returned value.
432
*
433
* \fn wasm_globaltype_t* wasm_globaltype_new(wasm_valtype_t *, wasm_mutability_t)
434
* \brief Creates a new global type.
435
*
436
* This function takes ownership of the #wasm_valtype_t argument.
437
*
438
* The caller is responsible for deleting the returned value.
439
*
440
* \fn const wasm_valtype_t* wasm_globaltype_content(const wasm_globaltype_t *);
441
* \brief Returns the type of value contained in a global.
442
*
443
* The returned memory is owned by the provided #wasm_globaltype_t, the caller
444
* should not deallocate it.
445
*
446
* \fn wasm_mutability_t wasm_globaltype_mutability(const wasm_globaltype_t *);
447
* \brief Returns whether or not a global is mutable.
448
*/
449
450
/**
451
* \typedef wasm_mutability_t
452
* \brief Boolean flag for whether a global is mutable or not.
453
*/
454
455
/**
456
* \struct wasm_tabletype_t
457
* \brief An opaque object representing the type of a table.
458
*
459
* \typedef wasm_tabletype_t
460
* \brief Convenience alias for #wasm_tabletype_t
461
*
462
* \struct wasm_tabletype_vec_t
463
* \brief A list of #wasm_tabletype_t values.
464
*
465
* \var wasm_tabletype_vec_t::size
466
* \brief Length of this vector.
467
*
468
* \var wasm_tabletype_vec_t::data
469
* \brief Pointer to the base of this vector
470
*
471
* \typedef wasm_tabletype_vec_t
472
* \brief Convenience alias for #wasm_tabletype_vec_t
473
*
474
* \fn void wasm_tabletype_delete(wasm_tabletype_t *);
475
* \brief Deletes a type.
476
*
477
* \fn void wasm_tabletype_vec_new_empty(wasm_tabletype_vec_t *out);
478
* \brief Creates an empty vector.
479
*
480
* See #wasm_byte_vec_new_empty for more information.
481
*
482
* \fn void wasm_tabletype_vec_new_uninitialized(wasm_tabletype_vec_t *out, size_t);
483
* \brief Creates a vector with the given capacity.
484
*
485
* See #wasm_byte_vec_new_uninitialized for more information.
486
*
487
* \fn void wasm_tabletype_vec_new(wasm_tabletype_vec_t *out, size_t, wasm_tabletype_t *const[]);
488
* \brief Creates a vector with the provided contents.
489
*
490
* See #wasm_byte_vec_new for more information.
491
*
492
* \fn void wasm_tabletype_vec_copy(wasm_tabletype_vec_t *out, const wasm_tabletype_vec_t *)
493
* \brief Copies one vector to another
494
*
495
* See #wasm_byte_vec_copy for more information.
496
*
497
* \fn void wasm_tabletype_vec_delete(wasm_tabletype_vec_t *out)
498
* \brief Deallocates memory for a vector.
499
*
500
* See #wasm_byte_vec_delete for more information.
501
*
502
* \fn wasm_tabletype_t* wasm_tabletype_copy(const wasm_tabletype_t *)
503
* \brief Creates a new value which matches the provided one.
504
*
505
* The caller is responsible for deleting the returned value.
506
*
507
* \fn wasm_tabletype_t* wasm_tabletype_new(wasm_valtype_t *, const wasm_limits_t *)h
508
* \brief Creates a new table type.
509
*
510
* This function takes ownership of the #wasm_valtype_t argument, but does not
511
* take ownership of the #wasm_limits_t.
512
*
513
* The caller is responsible for deallocating the returned type.
514
*
515
* \fn const wasm_valtype_t* wasm_tabletype_element(const wasm_tabletype_t *);
516
* \brief Returns the element type of this table.
517
*
518
* The returned #wasm_valtype_t is owned by the #wasm_tabletype_t parameter, the
519
* caller should not deallocate it.
520
*
521
* \fn const wasm_limits_t* wasm_tabletype_limits(const wasm_tabletype_t *);
522
* \brief Returns the limits of this table.
523
*
524
* The returned #wasm_limits_t is owned by the #wasm_tabletype_t parameter, the
525
* caller should not deallocate it.
526
*/
527
528
/**
529
* \struct wasm_limits_t
530
* \brief Limits for tables/memories in wasm modules
531
* \var wasm_limits_t::min
532
* The minimum value required.
533
* \var wasm_limits_t::max
534
* The maximum value required, or `wasm_limits_max_default` if no maximum is
535
* specified.
536
*
537
* \typedef wasm_limits_t
538
* \brief A convenience typedef to #wasm_limits_t
539
*/
540
541
/**
542
* \struct wasm_memorytype_t
543
* \brief An opaque object representing the type of a memory.
544
*
545
* \typedef wasm_memorytype_t
546
* \brief Convenience alias for #wasm_memorytype_t
547
*
548
* \struct wasm_memorytype_vec_t
549
* \brief A list of #wasm_memorytype_t values.
550
*
551
* \var wasm_memorytype_vec_t::size
552
* \brief Length of this vector.
553
*
554
* \var wasm_memorytype_vec_t::data
555
* \brief Pointer to the base of this vector
556
*
557
* \typedef wasm_memorytype_vec_t
558
* \brief Convenience alias for #wasm_memorytype_vec_t
559
*
560
* \fn void wasm_memorytype_delete(wasm_memorytype_t *);
561
* \brief Deletes a type.
562
*
563
* \fn void wasm_memorytype_vec_new_empty(wasm_memorytype_vec_t *out);
564
* \brief Creates an empty vector.
565
*
566
* See #wasm_byte_vec_new_empty for more information.
567
*
568
* \fn void wasm_memorytype_vec_new_uninitialized(wasm_memorytype_vec_t *out, size_t);
569
* \brief Creates a vector with the given capacity.
570
*
571
* See #wasm_byte_vec_new_uninitialized for more information.
572
*
573
* \fn void wasm_memorytype_vec_new(wasm_memorytype_vec_t *out, size_t, wasm_memorytype_t *const[]);
574
* \brief Creates a vector with the provided contents.
575
*
576
* See #wasm_byte_vec_new for more information.
577
*
578
* \fn void wasm_memorytype_vec_copy(wasm_memorytype_vec_t *out, const wasm_memorytype_vec_t *)
579
* \brief Copies one vector to another
580
*
581
* See #wasm_byte_vec_copy for more information.
582
*
583
* \fn void wasm_memorytype_vec_delete(wasm_memorytype_vec_t *out)
584
* \brief Deallocates memory for a vector.
585
*
586
* See #wasm_byte_vec_delete for more information.
587
*
588
* \fn wasm_memorytype_t* wasm_memorytype_copy(const wasm_memorytype_t *)
589
* \brief Creates a new value which matches the provided one.
590
*
591
* The caller is responsible for deleting the returned value.
592
*
593
* \fn wasm_memorytype_t* wasm_memorytype_new(const wasm_limits_t *)h
594
* \brief Creates a new memory type.
595
*
596
* This function takes ownership of the #wasm_valtype_t argument, but does not
597
* take ownership of the #wasm_limits_t.
598
*
599
* The caller is responsible for deallocating the returned type.
600
*
601
* For compatibility with memory64 it's recommended to use
602
* #wasmtime_memorytype_new instead.
603
*
604
* \fn const wasm_limits_t* wasm_memorytype_limits(const wasm_memorytype_t *);
605
* \brief Returns the limits of this memory.
606
*
607
* The returned #wasm_limits_t is owned by the #wasm_memorytype_t parameter, the
608
* caller should not deallocate it.
609
*
610
* For compatibility with memory64 it's recommended to use
611
* #wasmtime_memorytype_maximum or #wasmtime_memorytype_minimum instead.
612
*/
613
614
/**
615
* \struct wasm_externtype_t
616
* \brief An opaque object representing the type of a external value. Can be
617
* seen as a superclass of #wasm_functype_t, #wasm_tabletype_t,
618
* #wasm_globaltype_t, and #wasm_memorytype_t.
619
*
620
* \typedef wasm_externtype_t
621
* \brief Convenience alias for #wasm_externtype_t
622
*
623
* \struct wasm_externtype_vec_t
624
* \brief A list of #wasm_externtype_t values.
625
*
626
* \var wasm_externtype_vec_t::size
627
* \brief Length of this vector.
628
*
629
* \var wasm_externtype_vec_t::data
630
* \brief Pointer to the base of this vector
631
*
632
* \typedef wasm_externtype_vec_t
633
* \brief Convenience alias for #wasm_externtype_vec_t
634
*
635
* \fn void wasm_externtype_delete(wasm_externtype_t *);
636
* \brief Deletes a type.
637
*
638
* \fn void wasm_externtype_vec_new_empty(wasm_externtype_vec_t *out);
639
* \brief Creates an empty vector.
640
*
641
* See #wasm_byte_vec_new_empty for more information.
642
*
643
* \fn void wasm_externtype_vec_new_uninitialized(wasm_externtype_vec_t *out, size_t);
644
* \brief Creates a vector with the given capacity.
645
*
646
* See #wasm_byte_vec_new_uninitialized for more information.
647
*
648
* \fn void wasm_externtype_vec_new(wasm_externtype_vec_t *out, size_t, wasm_externtype_t *const[]);
649
* \brief Creates a vector with the provided contents.
650
*
651
* See #wasm_byte_vec_new for more information.
652
*
653
* \fn void wasm_externtype_vec_copy(wasm_externtype_vec_t *out, const wasm_externtype_vec_t *)
654
* \brief Copies one vector to another
655
*
656
* See #wasm_byte_vec_copy for more information.
657
*
658
* \fn void wasm_externtype_vec_delete(wasm_externtype_vec_t *out)
659
* \brief Deallocates extern for a vector.
660
*
661
* See #wasm_byte_vec_delete for more information.
662
*
663
* \fn wasm_externtype_t* wasm_externtype_copy(const wasm_externtype_t *)
664
* \brief Creates a new value which matches the provided one.
665
*
666
* The caller is responsible for deleting the returned value.
667
*
668
* \fn wasm_externkind_t wasm_externtype_kind(const wasm_externtype_t *)
669
* \brief Returns the kind of external item this type represents.
670
*/
671
672
/**
673
* \typedef wasm_externkind_t
674
* \brief Classifier for #wasm_externtype_t
675
*
676
* This is returned from #wasm_extern_kind and #wasm_externtype_kind to
677
* determine what kind of type is wrapped.
678
*/
679
680
/**
681
* \fn wasm_externtype_t* wasm_functype_as_externtype(wasm_functype_t *)
682
* \brief Converts a #wasm_functype_t to a #wasm_externtype_t
683
*
684
* The returned value is owned by the #wasm_functype_t argument and should not
685
* be deleted.
686
*
687
* \fn wasm_externtype_t* wasm_tabletype_as_externtype(wasm_tabletype_t *)
688
* \brief Converts a #wasm_tabletype_t to a #wasm_externtype_t
689
*
690
* The returned value is owned by the #wasm_tabletype_t argument and should not
691
* be deleted.
692
*
693
* \fn wasm_externtype_t* wasm_globaltype_as_externtype(wasm_globaltype_t *)
694
* \brief Converts a #wasm_globaltype_t to a #wasm_externtype_t
695
*
696
* The returned value is owned by the #wasm_globaltype_t argument and should not
697
* be deleted.
698
*
699
* \fn wasm_externtype_t* wasm_memorytype_as_externtype(wasm_memorytype_t *)
700
* \brief Converts a #wasm_memorytype_t to a #wasm_externtype_t
701
*
702
* The returned value is owned by the #wasm_memorytype_t argument and should not
703
* be deleted.
704
*
705
* \fn const wasm_externtype_t* wasm_functype_as_externtype_const(const wasm_functype_t *)
706
* \brief Converts a #wasm_functype_t to a #wasm_externtype_t
707
*
708
* The returned value is owned by the #wasm_functype_t argument and should not
709
* be deleted.
710
*
711
* \fn const wasm_externtype_t* wasm_tabletype_as_externtype_const(const wasm_tabletype_t *)
712
* \brief Converts a #wasm_tabletype_t to a #wasm_externtype_t
713
*
714
* The returned value is owned by the #wasm_tabletype_t argument and should not
715
* be deleted.
716
*
717
* \fn const wasm_externtype_t* wasm_globaltype_as_externtype_const(const wasm_globaltype_t *)
718
* \brief Converts a #wasm_globaltype_t to a #wasm_externtype_t
719
*
720
* The returned value is owned by the #wasm_globaltype_t argument and should not
721
* be deleted.
722
*
723
* \fn const wasm_externtype_t* wasm_memorytype_as_externtype_const(const wasm_memorytype_t *)
724
* \brief Converts a #wasm_memorytype_t to a #wasm_externtype_t
725
*
726
* The returned value is owned by the #wasm_memorytype_t argument and should not
727
* be deleted.
728
*
729
* \fn wasm_functype_t* wasm_externtype_as_functype(wasm_externtype_t *)
730
* \brief Attempts to convert a #wasm_externtype_t to a #wasm_functype_t
731
*
732
* The returned value is owned by the #wasm_functype_t argument and should not
733
* be deleted. Returns `NULL` if the provided argument is not a
734
* #wasm_functype_t.
735
*
736
* \fn wasm_tabletype_t* wasm_externtype_as_tabletype(wasm_externtype_t *)
737
* \brief Attempts to convert a #wasm_externtype_t to a #wasm_tabletype_t
738
*
739
* The returned value is owned by the #wasm_tabletype_t argument and should not
740
* be deleted. Returns `NULL` if the provided argument is not a
741
* #wasm_tabletype_t.
742
*
743
* \fn wasm_memorytype_t* wasm_externtype_as_memorytype(wasm_externtype_t *)
744
* \brief Attempts to convert a #wasm_externtype_t to a #wasm_memorytype_t
745
*
746
* The returned value is owned by the #wasm_memorytype_t argument and should not
747
* be deleted. Returns `NULL` if the provided argument is not a
748
* #wasm_memorytype_t.
749
*
750
* \fn wasm_globaltype_t* wasm_externtype_as_globaltype(wasm_externtype_t *)
751
* \brief Attempts to convert a #wasm_externtype_t to a #wasm_globaltype_t
752
*
753
* The returned value is owned by the #wasm_globaltype_t argument and should not
754
* be deleted. Returns `NULL` if the provided argument is not a
755
* #wasm_globaltype_t.
756
*
757
* \fn const wasm_functype_t* wasm_externtype_as_functype_const(const wasm_externtype_t *)
758
* \brief Attempts to convert a #wasm_externtype_t to a #wasm_functype_t
759
*
760
* The returned value is owned by the #wasm_functype_t argument and should not
761
* be deleted. Returns `NULL` if the provided argument is not a
762
* #wasm_functype_t.
763
*
764
* \fn const wasm_tabletype_t* wasm_externtype_as_tabletype_const(const wasm_externtype_t *)
765
* \brief Attempts to convert a #wasm_externtype_t to a #wasm_tabletype_t
766
*
767
* The returned value is owned by the #wasm_tabletype_t argument and should not
768
* be deleted. Returns `NULL` if the provided argument is not a
769
* #wasm_tabletype_t.
770
*
771
* \fn const wasm_memorytype_t* wasm_externtype_as_memorytype_const(const wasm_externtype_t *)
772
* \brief Attempts to convert a #wasm_externtype_t to a #wasm_memorytype_t
773
*
774
* The returned value is owned by the #wasm_memorytype_t argument and should not
775
* be deleted. Returns `NULL` if the provided argument is not a
776
* #wasm_memorytype_t.
777
*
778
* \fn const wasm_globaltype_t* wasm_externtype_as_globaltype_const(const wasm_externtype_t *)
779
* \brief Attempts to convert a #wasm_externtype_t to a #wasm_globaltype_t
780
*
781
* The returned value is owned by the #wasm_globaltype_t argument and should not
782
* be deleted. Returns `NULL` if the provided argument is not a
783
* #wasm_globaltype_t.
784
*/
785
786
/**
787
* \struct wasm_importtype_t
788
* \brief An opaque object representing the type of an import.
789
*
790
* \typedef wasm_importtype_t
791
* \brief Convenience alias for #wasm_importtype_t
792
*
793
* \struct wasm_importtype_vec_t
794
* \brief A list of #wasm_importtype_t values.
795
*
796
* \var wasm_importtype_vec_t::size
797
* \brief Length of this vector.
798
*
799
* \var wasm_importtype_vec_t::data
800
* \brief Pointer to the base of this vector
801
*
802
* \typedef wasm_importtype_vec_t
803
* \brief Convenience alias for #wasm_importtype_vec_t
804
*
805
* \fn void wasm_importtype_delete(wasm_importtype_t *);
806
* \brief Deletes a type.
807
*
808
* \fn void wasm_importtype_vec_new_empty(wasm_importtype_vec_t *out);
809
* \brief Creates an empty vector.
810
*
811
* See #wasm_byte_vec_new_empty for more information.
812
*
813
* \fn void wasm_importtype_vec_new_uninitialized(wasm_importtype_vec_t *out, size_t);
814
* \brief Creates a vector with the given capacity.
815
*
816
* See #wasm_byte_vec_new_uninitialized for more information.
817
*
818
* \fn void wasm_importtype_vec_new(wasm_importtype_vec_t *out, size_t, wasm_importtype_t *const[]);
819
* \brief Creates a vector with the provided contents.
820
*
821
* See #wasm_byte_vec_new for more information.
822
*
823
* \fn void wasm_importtype_vec_copy(wasm_importtype_vec_t *out, const wasm_importtype_vec_t *)
824
* \brief Copies one vector to another
825
*
826
* See #wasm_byte_vec_copy for more information.
827
*
828
* \fn void wasm_importtype_vec_delete(wasm_importtype_vec_t *out)
829
* \brief Deallocates import for a vector.
830
*
831
* See #wasm_byte_vec_delete for more information.
832
*
833
* \fn wasm_importtype_t* wasm_importtype_copy(const wasm_importtype_t *)
834
* \brief Creates a new value which matches the provided one.
835
*
836
* The caller is responsible for deleting the returned value.
837
*
838
* \fn wasm_importtype_t* wasm_importtype_new(wasm_name_t *module, wasm_name_t *name, wasm_externtype_t *)
839
* \brief Creates a new import type.
840
*
841
* This function takes ownership of the `module`, `name`, and
842
* #wasm_externtype_t arguments. The caller is responsible for deleting the
843
* returned value. Note that `name` can be `NULL` where in the module linking
844
* proposal the import name can be omitted.
845
*
846
* \fn const wasm_name_t* wasm_importtype_module(const wasm_importtype_t *);
847
* \brief Returns the module this import is importing from.
848
*
849
* The returned memory is owned by the #wasm_importtype_t argument, the caller
850
* should not deallocate it.
851
*
852
* \fn const wasm_name_t* wasm_importtype_name(const wasm_importtype_t *);
853
* \brief Returns the name this import is importing from.
854
*
855
* The returned memory is owned by the #wasm_importtype_t argument, the caller
856
* should not deallocate it. Note that `NULL` can be returned which means
857
* that the import name is not provided. This is for imports with the module
858
* linking proposal that only have the module specified.
859
*
860
* \fn const wasm_externtype_t* wasm_importtype_type(const wasm_importtype_t *);
861
* \brief Returns the type of item this import is importing.
862
*
863
* The returned memory is owned by the #wasm_importtype_t argument, the caller
864
* should not deallocate it.
865
*/
866
867
/**
868
* \struct wasm_exporttype_t
869
* \brief An opaque object representing the type of an export.
870
*
871
* \typedef wasm_exporttype_t
872
* \brief Convenience alias for #wasm_exporttype_t
873
*
874
* \struct wasm_exporttype_vec_t
875
* \brief A list of #wasm_exporttype_t values.
876
*
877
* \var wasm_exporttype_vec_t::size
878
* \brief Length of this vector.
879
*
880
* \var wasm_exporttype_vec_t::data
881
* \brief Pointer to the base of this vector
882
*
883
* \typedef wasm_exporttype_vec_t
884
* \brief Convenience alias for #wasm_exporttype_vec_t
885
*
886
* \fn void wasm_exporttype_delete(wasm_exporttype_t *);
887
* \brief Deletes a type.
888
*
889
* \fn void wasm_exporttype_vec_new_empty(wasm_exporttype_vec_t *out);
890
* \brief Creates an empty vector.
891
*
892
* See #wasm_byte_vec_new_empty for more information.
893
*
894
* \fn void wasm_exporttype_vec_new_uninitialized(wasm_exporttype_vec_t *out, size_t);
895
* \brief Creates a vector with the given capacity.
896
*
897
* See #wasm_byte_vec_new_uninitialized for more information.
898
*
899
* \fn void wasm_exporttype_vec_new(wasm_exporttype_vec_t *out, size_t, wasm_exporttype_t *const[]);
900
* \brief Creates a vector with the provided contents.
901
*
902
* See #wasm_byte_vec_new for more information.
903
*
904
* \fn void wasm_exporttype_vec_copy(wasm_exporttype_vec_t *out, const wasm_exporttype_vec_t *)
905
* \brief Copies one vector to another
906
*
907
* See #wasm_byte_vec_copy for more information.
908
*
909
* \fn void wasm_exporttype_vec_delete(wasm_exporttype_vec_t *out)
910
* \brief Deallocates export for a vector.
911
*
912
* See #wasm_byte_vec_delete for more information.
913
*
914
* \fn wasm_exporttype_t* wasm_exporttype_copy(const wasm_exporttype_t *)
915
* \brief Creates a new value which matches the provided one.
916
*
917
* The caller is responsible for deleting the returned value.
918
*
919
* \fn wasm_exporttype_t* wasm_exporttype_new(wasm_name_t *name, wasm_externtype_t *)
920
* \brief Creates a new export type.
921
*
922
* This function takes ownership of the `name` and
923
* #wasm_externtype_t arguments. The caller is responsible for deleting the
924
* returned value.
925
*
926
* \fn const wasm_name_t* wasm_exporttype_name(const wasm_exporttype_t *);
927
* \brief Returns the name of this export.
928
*
929
* The returned memory is owned by the #wasm_exporttype_t argument, the caller
930
* should not deallocate it.
931
*
932
* \fn const wasm_externtype_t* wasm_exporttype_type(const wasm_exporttype_t *);
933
* \brief Returns the type of this export.
934
*
935
* The returned memory is owned by the #wasm_exporttype_t argument, the caller
936
* should not deallocate it.
937
*/
938
939
/**
940
* \struct wasm_val_t
941
* \brief Representation of a WebAssembly value.
942
*
943
* Note that this structure is intended to represent the way to communicate
944
* values from the embedder to the engine. This type is not actually the
945
* internal representation in JIT code, for example.
946
*
947
* Also note that this is an owned value, notably the `ref` field. The
948
* #wasm_val_delete function does not delete the memory holding the #wasm_val_t
949
* itself, but only the memory pointed to by #wasm_val_t.
950
*
951
* \var wasm_val_t::kind
952
* \brief The kind of this value, or which of the fields in the `of` payload
953
* contains the actual value.
954
*
955
* \var wasm_val_t::of
956
* \brief The actual value of this #wasm_val_t. Only one field of this
957
* anonymous union is valid, and which field is valid is defined by the `kind`
958
* field.
959
*
960
* \var wasm_val_t::@0::i32
961
* \brief value for the `WASM_I32` type
962
*
963
* \var wasm_val_t::@0::i64
964
* \brief value for the `WASM_I64` type
965
*
966
* \var wasm_val_t::@0::f32
967
* \brief value for the `WASM_F32` type
968
*
969
* \var wasm_val_t::@0::f64
970
* \brief value for the `WASM_F64` type
971
*
972
* \var wasm_val_t::@0::ref
973
* \brief Unused by Wasmtime.
974
*
975
* \typedef wasm_val_t
976
* \brief Convenience alias for #wasm_val_t
977
*
978
* \struct wasm_val_vec_t
979
* \brief A list of #wasm_val_t values.
980
*
981
* \var wasm_val_vec_t::size
982
* \brief Length of this vector.
983
*
984
* \var wasm_val_vec_t::data
985
* \brief Pointer to the base of this vector
986
*
987
* \typedef wasm_val_vec_t
988
* \brief Convenience alias for #wasm_val_vec_t
989
*
990
* \fn void wasm_val_delete(wasm_val_t *v);
991
* \brief Deletes a type.
992
*
993
* This does not delete the memory pointed to by `v`, so it's safe for `v` to
994
* reside on the stack. Instead this only deletes the memory referenced by `v`,
995
* such as the `ref` variant of #wasm_val_t.
996
*
997
* \fn void wasm_val_vec_new_empty(wasm_val_vec_t *out);
998
* \brief Creates an empty vector.
999
*
1000
* See #wasm_byte_vec_new_empty for more information.
1001
*
1002
* \fn void wasm_val_vec_new_uninitialized(wasm_val_vec_t *out, size_t);
1003
* \brief Creates a vector with the given capacity.
1004
*
1005
* See #wasm_byte_vec_new_uninitialized for more information.
1006
*
1007
* \fn void wasm_val_vec_new(wasm_val_vec_t *out, size_t, wasm_val_t const[]);
1008
* \brief Creates a vector with the provided contents.
1009
*
1010
* See #wasm_byte_vec_new for more information.
1011
*
1012
* \fn void wasm_val_vec_copy(wasm_val_vec_t *out, const wasm_val_vec_t *)
1013
* \brief Copies one vector to another
1014
*
1015
* See #wasm_byte_vec_copy for more information.
1016
*
1017
* \fn void wasm_val_vec_delete(wasm_val_vec_t *out)
1018
* \brief Deallocates export for a vector.
1019
*
1020
* See #wasm_byte_vec_delete for more information.
1021
*
1022
* \fn void wasm_val_copy(wasm_val_t *out, const wasm_val_t *)
1023
* \brief Copies a #wasm_val_t to a new one.
1024
*
1025
* The second argument to this function is copied to the first. The caller is
1026
* responsible for calling #wasm_val_delete on the first argument after this
1027
* function. The `out` parameter is assumed uninitialized by this function and
1028
* the previous contents will not be deallocated.
1029
*/
1030
1031
/**
1032
* \struct wasm_ref_t
1033
* \brief A reference type: either a funcref or an externref.
1034
*
1035
* \typedef wasm_ref_t
1036
* \brief Convenience alias for #wasm_ref_t
1037
*
1038
* \fn void wasm_ref_delete(wasm_ref_t *v);
1039
* \brief Delete a reference.
1040
*
1041
* \fn wasm_ref_t *wasm_ref_copy(const wasm_ref_t *)
1042
* \brief Copy a reference.
1043
*
1044
* \fn bool wasm_ref_same(const wasm_ref_t *, const wasm_ref_t *)
1045
* \brief Are the given references pointing to the same externref?
1046
*
1047
* > Note: Wasmtime does not support checking funcrefs for equality, and this
1048
* > function will always return false for funcrefs.
1049
*
1050
* \fn void* wasm_ref_get_host_info(const wasm_ref_t *);
1051
* \brief Unimplemented in Wasmtime, always returns `NULL`.
1052
*
1053
* \fn void wasm_ref_set_host_info(wasm_ref_t *, void *);
1054
* \brief Unimplemented in Wasmtime, aborts the process if called.
1055
*
1056
* \fn void wasm_ref_set_host_info_with_finalizer(wasm_ref_t *, void *, void(*)(void*));
1057
* \brief Unimplemented in Wasmtime, aborts the process if called.
1058
*/
1059
1060
/**
1061
* \struct wasm_frame_t
1062
* \brief Opaque struct representing a frame of a wasm stack trace.
1063
*
1064
* \typedef wasm_frame_t
1065
* \brief Convenience alias for #wasm_frame_t
1066
*
1067
* \struct wasm_frame_vec_t
1068
* \brief A list of #wasm_frame_t frameues.
1069
*
1070
* \var wasm_frame_vec_t::size
1071
* \brief Length of this vector.
1072
*
1073
* \var wasm_frame_vec_t::data
1074
* \brief Pointer to the base of this vector
1075
*
1076
* \typedef wasm_frame_vec_t
1077
* \brief Convenience alias for #wasm_frame_vec_t
1078
*
1079
* \fn void wasm_frame_delete(wasm_frame_t *v);
1080
* \brief Deletes a frame.
1081
*
1082
* \fn void wasm_frame_vec_new_empty(wasm_frame_vec_t *out);
1083
* \brief Creates an empty vector.
1084
*
1085
* See #wasm_byte_vec_new_empty for more information.
1086
*
1087
* \fn void wasm_frame_vec_new_uninitialized(wasm_frame_vec_t *out, size_t);
1088
* \brief Creates a vector with the given capacity.
1089
*
1090
* See #wasm_byte_vec_new_uninitialized for more information.
1091
*
1092
* \fn void wasm_frame_vec_new(wasm_frame_vec_t *out, size_t, wasm_frame_t *const[]);
1093
* \brief Creates a vector with the provided contents.
1094
*
1095
* See #wasm_byte_vec_new for more information.
1096
*
1097
* \fn void wasm_frame_vec_copy(wasm_frame_vec_t *out, const wasm_frame_vec_t *)
1098
* \brief Copies one vector to another
1099
*
1100
* See #wasm_byte_vec_copy for more information.
1101
*
1102
* \fn void wasm_frame_vec_delete(wasm_frame_vec_t *out)
1103
* \brief Deallocates export for a vector.
1104
*
1105
* See #wasm_byte_vec_delete for more information.
1106
*
1107
* \fn wasm_frame_t *wasm_frame_copy(const wasm_frame_t *)
1108
* \brief Returns a copy of the provided frame.
1109
*
1110
* The caller is expected to call #wasm_frame_delete on the returned frame.
1111
*
1112
* \fn wasm_instance_t *wasm_frame_instance(const wasm_frame_t *);
1113
* \brief Unimplemented in Wasmtime, aborts the process if called.
1114
*
1115
* \fn uint32_t wasm_frame_func_index(const wasm_frame_t *);
1116
* \brief Returns the function index in the original wasm module that this frame
1117
* corresponds to.
1118
*
1119
* \fn uint32_t wasm_frame_func_offset(const wasm_frame_t *);
1120
* \brief Returns the byte offset from the beginning of the function in the
1121
* original wasm file to the instruction this frame points to.
1122
*
1123
* \fn uint32_t wasm_frame_module_offset(const wasm_frame_t *);
1124
* \brief Returns the byte offset from the beginning of the original wasm file
1125
* to the instruction this frame points to.
1126
*/
1127
1128
/**
1129
* \struct wasm_trap_t
1130
* \brief Opaque struct representing a wasm trap.
1131
*
1132
* \typedef wasm_trap_t
1133
* \brief Convenience alias for #wasm_trap_t
1134
*
1135
* \fn void wasm_trap_delete(wasm_trap_t *v);
1136
* \brief Deletes a trap.
1137
*
1138
* \fn wasm_trap_t *wasm_trap_copy(const wasm_trap_t *)
1139
* \brief Copies a #wasm_trap_t to a new one.
1140
*
1141
* The caller is responsible for deleting the returned #wasm_trap_t.
1142
*
1143
* \fn void wasm_trap_same(const wasm_trap_t *, const wasm_trap_t *)
1144
* \brief Unimplemented in Wasmtime, aborts the process if called.
1145
*
1146
* \fn void* wasm_trap_get_host_info(const wasm_trap_t *);
1147
* \brief Unimplemented in Wasmtime, always returns `NULL`.
1148
*
1149
* \fn void wasm_trap_set_host_info(wasm_trap_t *, void *);
1150
* \brief Unimplemented in Wasmtime, aborts the process if called.
1151
*
1152
* \fn void wasm_trap_set_host_info_with_finalizer(wasm_trap_t *, void *, void(*)(void*));
1153
* \brief Unimplemented in Wasmtime, aborts the process if called.
1154
*
1155
* \fn wasm_ref_t *wasm_trap_as_ref(wasm_trap_t *);
1156
* \brief Unimplemented in Wasmtime, aborts the process if called.
1157
*
1158
* \fn wasm_trap_t *wasm_ref_as_trap(wasm_ref_t *);
1159
* \brief Unimplemented in Wasmtime, aborts the process if called.
1160
*
1161
* \fn const wasm_ref_t *wasm_trap_as_ref_const(const wasm_trap_t *);
1162
* \brief Unimplemented in Wasmtime, aborts the process if called.
1163
*
1164
* \fn const wasm_trap_t *wasm_ref_as_trap_const(const wasm_ref_t *);
1165
* \brief Unimplemented in Wasmtime, aborts the process if called.
1166
*
1167
* \fn wasm_trap_t *wasm_trap_new(wasm_store_t *store, const wasm_message_t *);
1168
* \brief Creates a new #wasm_trap_t with the provided message.
1169
*
1170
* This function will create a new trap within the given #wasm_store_t with the
1171
* provided message. This will also capture the backtrace, if any, of wasm
1172
* frames on the stack.
1173
*
1174
* Note that the #wasm_message_t argument is expected to have a 0-byte at the
1175
* end of the message, and the length should include the trailing 0-byte.
1176
*
1177
* This function does not take ownership of either argument.
1178
*
1179
* The caller is responsible for deallocating the trap returned.
1180
*
1181
* \fn void wasm_trap_message(const wasm_trap_t *, wasm_message_t *out);
1182
* \brief Retrieves the message associated with this trap.
1183
*
1184
* The caller takes ownership of the returned `out` value and is responsible for
1185
* calling #wasm_byte_vec_delete on it.
1186
*
1187
* \fn wasm_frame_t* wasm_trap_origin(const wasm_trap_t *);
1188
* \brief Returns the top frame of the wasm stack responsible for this trap.
1189
*
1190
* The caller is responsible for deallocating the returned frame. This function
1191
* may return `NULL`, for example, for traps created when there wasn't anything
1192
* on the wasm stack.
1193
*
1194
* \fn void wasm_trap_trace(const wasm_trap_t *, wasm_frame_vec_t *out);
1195
* \brief Returns the trace of wasm frames for this trap.
1196
*
1197
* The caller is responsible for deallocating the returned list of frames.
1198
* Frames are listed in order of increasing depth, with the most recently called
1199
* function at the front of the list and the base function on the stack at the
1200
* end.
1201
*/
1202
1203
/**
1204
* \struct wasm_foreign_t
1205
* \brief Unimplemented in Wasmtime
1206
*
1207
* \typedef wasm_foreign_t
1208
* \brief Convenience alias for #wasm_foreign_t
1209
*
1210
* \fn void wasm_foreign_delete(wasm_foreign_t *v);
1211
* \brief Unimplemented in Wasmtime, aborts the process if called
1212
*
1213
* \fn wasm_foreign_t *wasm_foreign_copy(const wasm_foreign_t *)
1214
* \brief Unimplemented in Wasmtime, aborts the process if called
1215
*
1216
* \fn void wasm_foreign_same(const wasm_foreign_t *, const wasm_foreign_t *)
1217
* \brief Unimplemented in Wasmtime, aborts the process if called.
1218
*
1219
* \fn void* wasm_foreign_get_host_info(const wasm_foreign_t *);
1220
* \brief Unimplemented in Wasmtime, always returns `NULL`.
1221
*
1222
* \fn void wasm_foreign_set_host_info(wasm_foreign_t *, void *);
1223
* \brief Unimplemented in Wasmtime, aborts the process if called.
1224
*
1225
* \fn void wasm_foreign_set_host_info_with_finalizer(wasm_foreign_t *, void *, void(*)(void*));
1226
* \brief Unimplemented in Wasmtime, aborts the process if called.
1227
*
1228
* \fn wasm_ref_t *wasm_foreign_as_ref(wasm_foreign_t *);
1229
* \brief Unimplemented in Wasmtime, aborts the process if called.
1230
*
1231
* \fn wasm_foreign_t *wasm_ref_as_foreign(wasm_ref_t *);
1232
* \brief Unimplemented in Wasmtime, aborts the process if called.
1233
*
1234
* \fn const wasm_ref_t *wasm_foreign_as_ref_const(const wasm_foreign_t *);
1235
* \brief Unimplemented in Wasmtime, aborts the process if called.
1236
*
1237
* \fn const wasm_foreign_t *wasm_ref_as_foreign_const(const wasm_ref_t *);
1238
* \brief Unimplemented in Wasmtime, aborts the process if called.
1239
*
1240
* \fn wasm_foreign_t *wasm_foreign_new(wasm_store_t *store);
1241
* \brief Unimplemented in Wasmtime, aborts the process if called.
1242
*/
1243
1244
/**
1245
* \struct wasm_module_t
1246
* \brief Opaque struct representing a compiled wasm module.
1247
*
1248
* This structure is safe to send across threads in Wasmtime.
1249
*
1250
* \typedef wasm_module_t
1251
* \brief Convenience alias for #wasm_module_t
1252
*
1253
* \struct wasm_shared_module_t
1254
* \brief Opaque struct representing module that can be sent between threads.
1255
*
1256
* This structure is safe to send across threads in Wasmtime. Note that in
1257
* Wasmtime #wasm_module_t is also safe to share across threads.
1258
*
1259
* \typedef wasm_shared_module_t
1260
* \brief Convenience alias for #wasm_shared_module_t
1261
*
1262
* \fn void wasm_module_delete(wasm_module_t *v);
1263
* \brief Deletes a module.
1264
*
1265
* \fn wasm_module_t *wasm_module_copy(const wasm_module_t *)
1266
* \brief Copies a #wasm_module_t to a new one.
1267
*
1268
* The caller is responsible for deleting the returned #wasm_module_t.
1269
*
1270
* \fn void wasm_module_same(const wasm_module_t *, const wasm_module_t *)
1271
* \brief Unimplemented in Wasmtime, aborts the process if called.
1272
*
1273
* \fn void* wasm_module_get_host_info(const wasm_module_t *);
1274
* \brief Unimplemented in Wasmtime, always returns `NULL`.
1275
*
1276
* \fn void wasm_module_set_host_info(wasm_module_t *, void *);
1277
* \brief Unimplemented in Wasmtime, aborts the process if called.
1278
*
1279
* \fn void wasm_module_set_host_info_with_finalizer(wasm_module_t *, void *, void(*)(void*));
1280
* \brief Unimplemented in Wasmtime, aborts the process if called.
1281
*
1282
* \fn wasm_ref_t *wasm_module_as_ref(wasm_module_t *);
1283
* \brief Unimplemented in Wasmtime, aborts the process if called.
1284
*
1285
* \fn wasm_module_t *wasm_ref_as_module(wasm_ref_t *);
1286
* \brief Unimplemented in Wasmtime, aborts the process if called.
1287
*
1288
* \fn const wasm_ref_t *wasm_module_as_ref_const(const wasm_module_t *);
1289
* \brief Unimplemented in Wasmtime, aborts the process if called.
1290
*
1291
* \fn const wasm_module_t *wasm_ref_as_module_const(const wasm_ref_t *);
1292
* \brief Unimplemented in Wasmtime, aborts the process if called.
1293
*
1294
* \fn wasm_ref_as_module_const(const wasm_ref_t *);
1295
* \brief Unimplemented in Wasmtime, aborts the process if called.
1296
*
1297
* \fn void wasm_shared_module_delete(wasm_shared_module_t *);
1298
* \brief Deletes the provided module.
1299
*
1300
* \fn wasm_shared_module_t *wasm_module_share(const wasm_module_t *);
1301
* \brief Creates a shareable module from the provided module.
1302
*
1303
* > Note that this API is not necessary in Wasmtime because #wasm_module_t can
1304
* > be shared across threads. This is implemented for compatibility, however.
1305
*
1306
* This function does not take ownership of the argument, but the caller is
1307
* expected to deallocate the returned #wasm_shared_module_t.
1308
*
1309
* \fn wasm_module_t *wasm_module_obtain(wasm_store_t *, const wasm_shared_module_t *);
1310
* \brief Attempts to create a #wasm_module_t from the shareable module.
1311
*
1312
* > Note that this API is not necessary in Wasmtime because #wasm_module_t can
1313
* > be shared across threads. This is implemented for compatibility, however.
1314
*
1315
* This function does not take ownership of its arguments, but the caller is
1316
* expected to deallocate the returned #wasm_module_t.
1317
*
1318
* This function may fail if the engines associated with the #wasm_store_t or
1319
* #wasm_shared_module_t are different.
1320
*
1321
* \fn wasm_module_t *wasm_module_new(wasm_store_t *, const wasm_byte_vec_t *binary)
1322
* \brief Compiles a raw WebAssembly binary to a #wasm_module_t.
1323
*
1324
* This function will validate and compile the provided binary. The returned
1325
* #wasm_module_t is ready for instantiation after this call returns.
1326
*
1327
* This function does not take ownership of its arguments, but the caller is
1328
* expected to deallocate the returned #wasm_module_t.
1329
*
1330
* This function may fail if the provided binary is not a WebAssembly binary or
1331
* if it does not pass validation. In these cases this function returns `NULL`.
1332
*
1333
* \fn bool wasm_module_validate(wasm_store_t *, const wasm_byte_vec_t *binary);
1334
* \brief Validates whether a provided byte sequence is a valid wasm binary.
1335
*
1336
* This function will perform any internal validation necessary to determine if
1337
* `binary` is a valid WebAssembly binary according to the configuration of the
1338
* #wasm_store_t provided.
1339
*
1340
* \fn void wasm_module_imports(const wasm_module_t *, wasm_importtype_vec_t *out);
1341
* \brief Returns the list of imports that this module expects.
1342
*
1343
* The list of imports returned are the types of items expected to be passed to
1344
* #wasm_instance_new. You can use #wasm_importtype_type to learn about the
1345
* expected type of each import.
1346
*
1347
* This function does not take ownership of the provided module but ownership of
1348
* `out` is passed to the caller. Note that `out` is treated as uninitialized
1349
* when passed to this function.
1350
*
1351
* \fn void wasm_module_exports(const wasm_module_t *, wasm_exporttype_vec_t *out);
1352
* \brief Returns the list of exports that this module provides.
1353
*
1354
* The list of exports returned are in the same order as the items returned by
1355
* #wasm_instance_exports.
1356
*
1357
* This function does not take ownership of the provided module but ownership
1358
* of `out` is passed to the caller. Note that `out` is treated as
1359
* uninitialized when passed to this function.
1360
*
1361
* \fn void wasm_module_serialize(const wasm_module_t *, wasm_byte_vec_t *out);
1362
* \brief Serializes the provided module to a byte vector.
1363
*
1364
* Does not take ownership of the input module but expects the caller will
1365
* deallocate the `out` vector. The byte vector can later be deserialized
1366
* through #wasm_module_deserialize.
1367
*
1368
* \fn wasm_module_t *wasm_module_deserialize(wasm_store_t *, const wasm_byte_vec_t *);
1369
* \brief Deserializes a previously-serialized module.
1370
*
1371
* The input bytes must have been created from a previous call to
1372
* #wasm_module_serialize.
1373
*/
1374
1375
/**
1376
* \struct wasm_func_t
1377
* \brief Opaque struct representing a compiled wasm function.
1378
*
1379
* \typedef wasm_func_t
1380
* \brief Convenience alias for #wasm_func_t
1381
*
1382
* \typedef wasm_func_callback_t
1383
* \brief Type definition for functions passed to #wasm_func_new.
1384
*
1385
* This is the type signature of a host function created with #wasm_func_new.
1386
* This function takes two parameters, the first of which is the list of
1387
* parameters to the function and the second of which is where to write the
1388
* results. This function can optionally return a #wasm_trap_t and does not have
1389
* to fill in the results in that case.
1390
*
1391
* It is guaranteed that this function will be called with the appropriate
1392
* number and types of arguments according to the function type passed to
1393
* #wasm_func_new. It is required that this function produces the correct number
1394
* and types of results as the original type signature. It is undefined behavior
1395
* to return other types or different numbers of values.
1396
*
1397
* Ownership of the results and the trap returned, if any, is passed to the
1398
* caller of this function.
1399
*
1400
* \typedef wasm_func_callback_with_env_t
1401
* \brief Type definition for functions passed to #wasm_func_new_with_env
1402
*
1403
* The semantics of this function are the same as those of
1404
* #wasm_func_callback_t, except the first argument is the same `void*` argument
1405
* passed to #wasm_func_new_with_env.
1406
*
1407
* \fn void wasm_func_delete(wasm_func_t *v);
1408
* \brief Deletes a func.
1409
*
1410
* \fn wasm_func_t *wasm_func_copy(const wasm_func_t *)
1411
* \brief Copies a #wasm_func_t to a new one.
1412
*
1413
* The caller is responsible for deleting the returned #wasm_func_t.
1414
*
1415
* \fn void wasm_func_same(const wasm_func_t *, const wasm_func_t *)
1416
* \brief Unimplemented in Wasmtime, aborts the process if called.
1417
*
1418
* \fn void* wasm_func_get_host_info(const wasm_func_t *);
1419
* \brief Unimplemented in Wasmtime, always returns `NULL`.
1420
*
1421
* \fn void wasm_func_set_host_info(wasm_func_t *, void *);
1422
* \brief Unimplemented in Wasmtime, aborts the process if called.
1423
*
1424
* \fn void wasm_func_set_host_info_with_finalizer(wasm_func_t *, void *, void(*)(void*));
1425
* \brief Unimplemented in Wasmtime, aborts the process if called.
1426
*
1427
* \fn wasm_ref_t *wasm_func_as_ref(wasm_func_t *);
1428
* \brief Unimplemented in Wasmtime, aborts the process if called.
1429
*
1430
* \fn wasm_func_t *wasm_ref_as_func(wasm_ref_t *);
1431
* \brief Unimplemented in Wasmtime, aborts the process if called.
1432
*
1433
* \fn const wasm_ref_t *wasm_func_as_ref_const(const wasm_func_t *);
1434
* \brief Unimplemented in Wasmtime, aborts the process if called.
1435
*
1436
* \fn const wasm_func_t *wasm_ref_as_func_const(const wasm_ref_t *);
1437
* \brief Unimplemented in Wasmtime, aborts the process if called.
1438
*
1439
* \fn wasm_ref_as_func_const(const wasm_ref_t *);
1440
* \brief Unimplemented in Wasmtime, aborts the process if called.
1441
*
1442
* \fn wasm_func_t *wasm_func_new(wasm_store_t *, const wasm_functype_t *, wasm_func_callback_t);
1443
* \brief Creates a new WebAssembly function with host functionality.
1444
*
1445
* This function creates a new #wasm_func_t from a host-provided function. The
1446
* host provided function must implement the type signature matching the
1447
* #wasm_functype_t provided here.
1448
*
1449
* The returned #wasm_func_t is expected to be deleted by the caller. This
1450
* function does not take ownership of its arguments.
1451
*
1452
* \fn wasm_func_t *wasm_func_new_with_env(
1453
* wasm_store_t *,
1454
* const wasm_functype_t *type,
1455
* wasm_func_callback_with_env_t,
1456
* void *env,
1457
* void (*finalizer)(void *));
1458
* \brief Creates a new WebAssembly function with host functionality.
1459
*
1460
* This function is the same as #wasm_func_new except that it the host-provided
1461
* `env` argument is passed to each invocation of the callback provided. This
1462
* provides a means of attaching host information to this #wasm_func_t.
1463
*
1464
* The `finalizer` argument will be invoked to deallocate `env` when the
1465
* #wasm_func_t is deallocated. If this argument is `NULL` then the data
1466
* provided will not be finalized.
1467
*
1468
* This function only takes ownership of the `env` argument (which is later
1469
* deallocated automatically by calling `finalizer`). This function yields
1470
* ownership of the returned #wasm_func_t to the caller.
1471
*
1472
* \fn wasm_functype_t *wasm_func_type(const wasm_func_t *);
1473
* \brief Returns the type of this function.
1474
*
1475
* The returned #wasm_functype_t is expected to be deallocated by the caller.
1476
*
1477
* \fn size_t wasm_func_param_arity(const wasm_func_t *);
1478
* \brief Returns the number of arguments expected by this function.
1479
*
1480
* \fn size_t wasm_func_result_arity(const wasm_func_t *);
1481
* \brief Returns the number of results returned by this function.
1482
*
1483
* \fn wasm_trap_t *wasm_func_call(const wasm_func_t *, const wasm_val_vec_t *args, wasm_val_vec_t *results);
1484
* \brief Calls the provided function with the arguments given.
1485
*
1486
* This function is used to call WebAssembly from the host. The parameter array
1487
* provided must be valid for #wasm_func_param_arity number of arguments, and
1488
* the result array must be valid for #wasm_func_result_arity number of results.
1489
* Providing not enough space is undefined behavior.
1490
*
1491
* If any of the arguments do not have the correct type then a trap is returned.
1492
* Additionally if any of the arguments come from a different store than
1493
* the #wasm_func_t provided a trap is returned.
1494
*
1495
* When no trap happens and no errors are detected then `NULL` is returned. The
1496
* `results` array is guaranteed to be filled in with values appropriate for
1497
* this function's type signature.
1498
*
1499
* If a trap happens during execution or some other error then a non-`NULL` trap
1500
* is returned. In this situation the `results` are is unmodified.
1501
*
1502
* Does not take ownership of `wasm_val_t` arguments. Gives ownership of
1503
* `wasm_val_t` results.
1504
*/
1505
1506
/**
1507
* \struct wasm_global_t
1508
* \brief Opaque struct representing a wasm global.
1509
*
1510
* \typedef wasm_global_t
1511
* \brief Convenience alias for #wasm_global_t
1512
*
1513
* \fn void wasm_global_delete(wasm_global_t *v);
1514
* \brief Deletes a global.
1515
*
1516
* \fn wasm_global_t *wasm_global_copy(const wasm_global_t *)
1517
* \brief Copies a #wasm_global_t to a new one.
1518
*
1519
* The caller is responsible for deleting the returned #wasm_global_t.
1520
*
1521
* \fn void wasm_global_same(const wasm_global_t *, const wasm_global_t *)
1522
* \brief Unimplemented in Wasmtime, aborts the process if called.
1523
*
1524
* \fn void* wasm_global_get_host_info(const wasm_global_t *);
1525
* \brief Unimplemented in Wasmtime, always returns `NULL`.
1526
*
1527
* \fn void wasm_global_set_host_info(wasm_global_t *, void *);
1528
* \brief Unimplemented in Wasmtime, aborts the process if called.
1529
*
1530
* \fn void wasm_global_set_host_info_with_finalizer(wasm_global_t *, void *, void(*)(void*));
1531
* \brief Unimplemented in Wasmtime, aborts the process if called.
1532
*
1533
* \fn wasm_ref_t *wasm_global_as_ref(wasm_global_t *);
1534
* \brief Unimplemented in Wasmtime, aborts the process if called.
1535
*
1536
* \fn wasm_global_t *wasm_ref_as_global(wasm_ref_t *);
1537
* \brief Unimplemented in Wasmtime, aborts the process if called.
1538
*
1539
* \fn const wasm_ref_t *wasm_global_as_ref_const(const wasm_global_t *);
1540
* \brief Unimplemented in Wasmtime, aborts the process if called.
1541
*
1542
* \fn const wasm_global_t *wasm_ref_as_global_const(const wasm_ref_t *);
1543
* \brief Unimplemented in Wasmtime, aborts the process if called.
1544
*
1545
* \fn wasm_ref_as_global_const(const wasm_ref_t *);
1546
* \brief Unimplemented in Wasmtime, aborts the process if called.
1547
*
1548
* \fn wasm_global_t *wasm_global_new(wasm_store_t *, const wasm_globaltype_t *, const wasm_val_t *);
1549
* \brief Creates a new WebAssembly global.
1550
*
1551
* This function is used to create a wasm global from the host, typically to
1552
* provide as the import of a module. The type of the global is specified along
1553
* with the initial value.
1554
*
1555
* This function will return `NULL` on errors. Errors include:
1556
*
1557
* * The type of the global doesn't match the type of the value specified.
1558
* * The initialization value does not come from the provided #wasm_store_t.
1559
*
1560
* This function does not take ownership of any of its arguments. The caller is
1561
* expected to deallocate the returned value.
1562
*
1563
* \fn wasm_globaltype_t *wasm_global_type(const wasm_global_t *);
1564
* \brief Returns the type of this global.
1565
*
1566
* The caller is expected to deallocate the returned #wasm_globaltype_t.
1567
*
1568
* \fn void wasm_global_get(const wasm_global_t *, wasm_val_t *out);
1569
* \brief Gets the value of this global.
1570
*
1571
* The caller is expected to deallocate the returned #wasm_val_t. The provided
1572
* `out` argument is treated as uninitialized on input.
1573
*
1574
* \fn void wasm_global_set(wasm_global_t *, const wasm_val_t *);
1575
* \brief Sets the value of this global.
1576
*
1577
* This function will set the value of a global to a new value. This function
1578
* does nothing if the global is not mutable, if the #wasm_val_t argument has
1579
* the wrong type, or if the provided value comes from a different store as the
1580
* #wasm_global_t.
1581
*
1582
* This function does not take ownership of its arguments.
1583
*/
1584
1585
/**
1586
* \struct wasm_table_t
1587
* \brief Opaque struct representing a wasm table.
1588
*
1589
* \typedef wasm_table_t
1590
* \brief Convenience alias for #wasm_table_t
1591
*
1592
* \typedef wasm_table_size_t
1593
* \brief Typedef for indices and sizes of wasm tables.
1594
*
1595
* \fn void wasm_table_delete(wasm_table_t *v);
1596
* \brief Deletes a table.
1597
*
1598
* \fn wasm_table_t *wasm_table_copy(const wasm_table_t *)
1599
* \brief Copies a #wasm_table_t to a new one.
1600
*
1601
* The caller is responsible for deleting the returned #wasm_table_t.
1602
*
1603
* \fn void wasm_table_same(const wasm_table_t *, const wasm_table_t *)
1604
* \brief Unimplemented in Wasmtime, aborts the process if called.
1605
*
1606
* \fn void* wasm_table_get_host_info(const wasm_table_t *);
1607
* \brief Unimplemented in Wasmtime, always returns `NULL`.
1608
*
1609
* \fn void wasm_table_set_host_info(wasm_table_t *, void *);
1610
* \brief Unimplemented in Wasmtime, aborts the process if called.
1611
*
1612
* \fn void wasm_table_set_host_info_with_finalizer(wasm_table_t *, void *, void(*)(void*));
1613
* \brief Unimplemented in Wasmtime, aborts the process if called.
1614
*
1615
* \fn wasm_ref_t *wasm_table_as_ref(wasm_table_t *);
1616
* \brief Unimplemented in Wasmtime, aborts the process if called.
1617
*
1618
* \fn wasm_table_t *wasm_ref_as_table(wasm_ref_t *);
1619
* \brief Unimplemented in Wasmtime, aborts the process if called.
1620
*
1621
* \fn const wasm_ref_t *wasm_table_as_ref_const(const wasm_table_t *);
1622
* \brief Unimplemented in Wasmtime, aborts the process if called.
1623
*
1624
* \fn const wasm_table_t *wasm_ref_as_table_const(const wasm_ref_t *);
1625
* \brief Unimplemented in Wasmtime, aborts the process if called.
1626
*
1627
* \fn wasm_ref_as_table_const(const wasm_ref_t *);
1628
* \brief Unimplemented in Wasmtime, aborts the process if called.
1629
*
1630
* \fn wasm_table_t *wasm_table_new(wasm_store_t *, const wasm_tabletype_t *, wasm_ref_t *init);
1631
* \brief Creates a new WebAssembly table.
1632
*
1633
* Creates a new host-defined table of values. This table has the type provided
1634
* and is filled with the provided initial value (which can be `NULL`).
1635
*
1636
* Returns an error if the #wasm_ref_t does not match the element type of the
1637
* table provided or if it comes from a different store than the one provided.
1638
*
1639
* Does not take ownship of the `init` value.
1640
*
1641
* \fn wasm_tabletype_t *wasm_table_type(const wasm_table_t *);
1642
* \brief Returns the type of this table.
1643
*
1644
* The caller is expected to deallocate the returned #wasm_tabletype_t.
1645
*
1646
* \fn wasm_ref_t *wasm_table_get(const wasm_table_t *, wasm_table_size_t index);
1647
* \brief Gets an element from this table.
1648
*
1649
* Attempts to get a value at an index in this table. This function returns
1650
* `NULL` if the index is out of bounds.
1651
*
1652
* Gives ownership of the resulting `wasm_ref_t*`.
1653
*
1654
* \fn void wasm_table_set(wasm_table_t *, wasm_table_size_t index, wasm_ref_t *);
1655
* \brief Sets an element in this table.
1656
*
1657
* Attempts to set a value at an index in this table. This function does nothing
1658
* in erroneous situations such as:
1659
*
1660
* * The index is out of bounds.
1661
* * The #wasm_ref_t comes from a different store than the table provided.
1662
* * The #wasm_ref_t does not have an appropriate type to store in this table.
1663
*
1664
* Does not take ownership of the given `wasm_ref_t*`.
1665
*
1666
* \fn wasm_table_size_t wasm_table_size(const wasm_table_t *);
1667
* \brief Gets the current size, in elements, of this table.
1668
*
1669
* \fn bool wasm_table_grow(wasm_table_t *, wasm_table_size_t delta, wasm_ref_t *init);
1670
* \brief Attempts to grow this table by `delta` elements.
1671
*
1672
* This function will grow the table by `delta` elements, initializing all new
1673
* elements to the `init` value provided.
1674
*
1675
* If growth happens successfully, then `true` is returned. Otherwise `false` is
1676
* returned and indicates one possible form of failure:
1677
*
1678
* * The table's limits do not allow growth by `delta`.
1679
* * The #wasm_ref_t comes from a different store than the table provided.
1680
* * The #wasm_ref_t does not have an appropriate type to store in this table.
1681
*
1682
* Does not take ownership of the given `init` value.
1683
*/
1684
1685
/**
1686
* \struct wasm_memory_t
1687
* \brief Opaque struct representing a wasm memory.
1688
*
1689
* \typedef wasm_memory_t
1690
* \brief Convenience alias for #wasm_memory_t
1691
*
1692
* \typedef wasm_memory_pages_t
1693
* \brief Unsigned integer to hold the number of pages a memory has.
1694
*
1695
* \fn void wasm_memory_delete(wasm_memory_t *v);
1696
* \brief Deletes a memory.
1697
*
1698
* \fn wasm_memory_t *wasm_memory_copy(const wasm_memory_t *)
1699
* \brief Copies a #wasm_memory_t to a new one.
1700
*
1701
* The caller is responsible for deleting the returned #wasm_memory_t.
1702
*
1703
* \fn void wasm_memory_same(const wasm_memory_t *, const wasm_memory_t *)
1704
* \brief Unimplemented in Wasmtime, aborts the process if called.
1705
*
1706
* \fn void* wasm_memory_get_host_info(const wasm_memory_t *);
1707
* \brief Unimplemented in Wasmtime, always returns `NULL`.
1708
*
1709
* \fn void wasm_memory_set_host_info(wasm_memory_t *, void *);
1710
* \brief Unimplemented in Wasmtime, aborts the process if called.
1711
*
1712
* \fn void wasm_memory_set_host_info_with_finalizer(wasm_memory_t *, void *, void(*)(void*));
1713
* \brief Unimplemented in Wasmtime, aborts the process if called.
1714
*
1715
* \fn wasm_ref_t *wasm_memory_as_ref(wasm_memory_t *);
1716
* \brief Unimplemented in Wasmtime, aborts the process if called.
1717
*
1718
* \fn wasm_memory_t *wasm_ref_as_memory(wasm_ref_t *);
1719
* \brief Unimplemented in Wasmtime, aborts the process if called.
1720
*
1721
* \fn const wasm_ref_t *wasm_memory_as_ref_const(const wasm_memory_t *);
1722
* \brief Unimplemented in Wasmtime, aborts the process if called.
1723
*
1724
* \fn const wasm_memory_t *wasm_ref_as_memory_const(const wasm_ref_t *);
1725
* \brief Unimplemented in Wasmtime, aborts the process if called.
1726
*
1727
* \fn wasm_ref_as_memory_const(const wasm_ref_t *);
1728
* \brief Unimplemented in Wasmtime, aborts the process if called.
1729
*
1730
* \fn wasm_memory_t *wasm_memory_new(wasm_store_t *, const wasm_memorytype_t *);
1731
* \brief Creates a new WebAssembly memory.
1732
*
1733
* \fn wasm_memorytype_t *wasm_memory_type(const wasm_memory_t *);
1734
* \brief Returns the type of this memory.
1735
*
1736
* The caller is expected to deallocate the returned #wasm_memorytype_t.
1737
*
1738
* \fn byte_t *wasm_memory_data(wasm_memory_t *);
1739
* \brief Returns the base address, in memory, where this memory is located.
1740
*
1741
* Note that the returned address may change over time when growth happens. The
1742
* returned pointer is only valid until the memory is next grown (which could
1743
* happen in wasm itself).
1744
*
1745
* \fn size_t wasm_memory_data_size(const wasm_memory_t *);
1746
* \brief Returns the size, in bytes, of this memory.
1747
*
1748
* \fn wasm_memory_pages_t wasm_memory_size(const wasm_memory_t *);
1749
* \brief Returns the size, in wasm pages, of this memory.
1750
*
1751
* \fn bool wasm_memory_grow(wasm_memory_t *, wasm_memory_pages_t delta);
1752
* \brief Attempts to grow this memory by `delta` wasm pages.
1753
*
1754
* This function is similar to the `memory.grow` instruction in wasm itself. It
1755
* will attempt to grow the memory by `delta` wasm pages. If growth fails then
1756
* `false` is returned, otherwise `true` is returned.
1757
*/
1758
1759
/**
1760
* \struct wasm_extern_t
1761
* \brief Opaque struct representing a wasm external value.
1762
*
1763
* \typedef wasm_extern_t
1764
* \brief Convenience alias for #wasm_extern_t
1765
*
1766
* \struct wasm_extern_vec_t
1767
* \brief A list of #wasm_extern_t values.
1768
*
1769
* \var wasm_extern_vec_t::size
1770
* \brief Length of this vector.
1771
*
1772
* \var wasm_extern_vec_t::data
1773
* \brief Pointer to the base of this vector
1774
*
1775
* \typedef wasm_extern_vec_t
1776
* \brief Convenience alias for #wasm_extern_vec_t
1777
*
1778
* \fn void wasm_extern_delete(wasm_extern_t *v);
1779
* \brief Deletes a extern.
1780
*
1781
* \fn void wasm_extern_vec_new_empty(wasm_extern_vec_t *out);
1782
* \brief Creates an empty vector.
1783
*
1784
* See #wasm_byte_vec_new_empty for more information.
1785
*
1786
* \fn void wasm_extern_vec_new_uninitialized(wasm_extern_vec_t *out, size_t);
1787
* \brief Creates a vector with the given capacity.
1788
*
1789
* See #wasm_byte_vec_new_uninitialized for more information.
1790
*
1791
* \fn void wasm_extern_vec_new(wasm_extern_vec_t *out, size_t, wasm_extern_t *const[]);
1792
* \brief Creates a vector with the provided contents.
1793
*
1794
* See #wasm_byte_vec_new for more information.
1795
*
1796
* \fn void wasm_extern_vec_copy(wasm_extern_vec_t *out, const wasm_extern_vec_t *)
1797
* \brief Copies one vector to another
1798
*
1799
* See #wasm_byte_vec_copy for more information.
1800
*
1801
* \fn void wasm_extern_vec_delete(wasm_extern_vec_t *out)
1802
* \brief Deallocates import for a vector.
1803
*
1804
* See #wasm_byte_vec_delete for more information.
1805
*
1806
* \fn wasm_extern_t *wasm_extern_copy(const wasm_extern_t *)
1807
* \brief Copies a #wasm_extern_t to a new one.
1808
*
1809
* The caller is responsible for deleting the returned #wasm_extern_t.
1810
*
1811
* \fn void wasm_extern_same(const wasm_extern_t *, const wasm_extern_t *)
1812
* \brief Unimplemented in Wasmtime, aborts the process if called.
1813
*
1814
* \fn void* wasm_extern_get_host_info(const wasm_extern_t *);
1815
* \brief Unimplemented in Wasmtime, always returns `NULL`.
1816
*
1817
* \fn void wasm_extern_set_host_info(wasm_extern_t *, void *);
1818
* \brief Unimplemented in Wasmtime, aborts the process if called.
1819
*
1820
* \fn void wasm_extern_set_host_info_with_finalizer(wasm_extern_t *, void *, void(*)(void*));
1821
* \brief Unimplemented in Wasmtime, aborts the process if called.
1822
*
1823
* \fn wasm_ref_t *wasm_extern_as_ref(wasm_extern_t *);
1824
* \brief Unimplemented in Wasmtime, aborts the process if called.
1825
*
1826
* \fn wasm_extern_t *wasm_ref_as_extern(wasm_ref_t *);
1827
* \brief Unimplemented in Wasmtime, aborts the process if called.
1828
*
1829
* \fn const wasm_ref_t *wasm_extern_as_ref_const(const wasm_extern_t *);
1830
* \brief Unimplemented in Wasmtime, aborts the process if called.
1831
*
1832
* \fn const wasm_extern_t *wasm_ref_as_extern_const(const wasm_ref_t *);
1833
* \brief Unimplemented in Wasmtime, aborts the process if called.
1834
*
1835
* \fn wasm_ref_as_extern_const(const wasm_ref_t *);
1836
* \brief Unimplemented in Wasmtime, aborts the process if called.
1837
*
1838
* \fn wasm_externkind_t *wasm_extern_kind(const wasm_extern_t *);
1839
* \brief Returns the kind of this extern, indicating what it will downcast as.
1840
*
1841
* \fn wasm_externtype_t *wasm_extern_type(const wasm_extern_t *);
1842
* \brief Returns the type of this extern.
1843
*
1844
* The caller is expected to deallocate the returned #wasm_externtype_t.
1845
*/
1846
1847
/**
1848
* \fn wasm_extern_t *wasm_func_as_extern(wasm_func_t *f);
1849
* \brief Converts a #wasm_func_t to #wasm_extern_t.
1850
*
1851
* The returned #wasm_extern_t is owned by the #wasm_func_t argument. Callers
1852
* should not delete the returned value, and it only lives as long as the
1853
* #wasm_func_t argument.
1854
*
1855
* \fn wasm_extern_t *wasm_global_as_extern(wasm_global_t *f);
1856
* \brief Converts a #wasm_global_t to #wasm_extern_t.
1857
*
1858
* The returned #wasm_extern_t is owned by the #wasm_global_t argument. Callers
1859
* should not delete the returned value, and it only lives as long as the
1860
* #wasm_global_t argument.
1861
*
1862
* \fn wasm_extern_t *wasm_memory_as_extern(wasm_memory_t *f);
1863
* \brief Converts a #wasm_memory_t to #wasm_extern_t.
1864
*
1865
* The returned #wasm_extern_t is owned by the #wasm_memory_t argument. Callers
1866
* should not delete the returned value, and it only lives as long as the
1867
* #wasm_memory_t argument.
1868
*
1869
* \fn wasm_extern_t *wasm_table_as_extern(wasm_table_t *f);
1870
* \brief Converts a #wasm_table_t to #wasm_extern_t.
1871
*
1872
* The returned #wasm_extern_t is owned by the #wasm_table_t argument. Callers
1873
* should not delete the returned value, and it only lives as long as the
1874
* #wasm_table_t argument.
1875
*
1876
* \fn const wasm_extern_t *wasm_func_as_extern_const(const wasm_func_t *f);
1877
* \brief Converts a #wasm_func_t to #wasm_extern_t.
1878
*
1879
* The returned #wasm_extern_t is owned by the #wasm_func_t argument. Callers
1880
* should not delete the returned value, and it only lives as long as the
1881
* #wasm_func_t argument.
1882
*
1883
* \fn const wasm_extern_t *wasm_global_as_extern_const(const wasm_global_t *f);
1884
* \brief Converts a #wasm_global_t to #wasm_extern_t.
1885
*
1886
* The returned #wasm_extern_t is owned by the #wasm_global_t argument. Callers
1887
* should not delete the returned value, and it only lives as long as the
1888
* #wasm_global_t argument.
1889
*
1890
* \fn const wasm_extern_t *wasm_memory_as_extern_const(const wasm_memory_t *f);
1891
* \brief Converts a #wasm_memory_t to #wasm_extern_t.
1892
*
1893
* The returned #wasm_extern_t is owned by the #wasm_memory_t argument. Callers
1894
* should not delete the returned value, and it only lives as long as the
1895
* #wasm_memory_t argument.
1896
*
1897
* \fn const wasm_extern_t *wasm_table_as_extern_const(const wasm_table_t *f);
1898
* \brief Converts a #wasm_table_t to #wasm_extern_t.
1899
*
1900
* The returned #wasm_extern_t is owned by the #wasm_table_t argument. Callers
1901
* should not delete the returned value, and it only lives as long as the
1902
* #wasm_table_t argument.
1903
*
1904
* \fn wasm_func_t *wasm_extern_as_func(wasm_extern_t *);
1905
* \brief Converts a #wasm_extern_t to #wasm_func_t.
1906
*
1907
* The returned #wasm_func_t is owned by the #wasm_extern_t argument. Callers
1908
* should not delete the returned value, and it only lives as long as the
1909
* #wasm_extern_t argument.
1910
*
1911
* If the #wasm_extern_t argument isn't a #wasm_func_t then `NULL` is returned.
1912
*
1913
* \fn wasm_table_t *wasm_extern_as_table(wasm_extern_t *);
1914
* \brief Converts a #wasm_extern_t to #wasm_table_t.
1915
*
1916
* The returned #wasm_table_t is owned by the #wasm_extern_t argument. Callers
1917
* should not delete the returned value, and it only lives as long as the
1918
* #wasm_extern_t argument.
1919
*
1920
* If the #wasm_extern_t argument isn't a #wasm_table_t then `NULL` is returned.
1921
*
1922
* \fn wasm_memory_t *wasm_extern_as_memory(wasm_extern_t *);
1923
* \brief Converts a #wasm_extern_t to #wasm_memory_t.
1924
*
1925
* The returned #wasm_memory_t is owned by the #wasm_extern_t argument. Callers
1926
* should not delete the returned value, and it only lives as long as the
1927
* #wasm_extern_t argument.
1928
*
1929
* If the #wasm_extern_t argument isn't a #wasm_memory_t then `NULL` is returned.
1930
*
1931
* \fn wasm_global_t *wasm_extern_as_global(wasm_extern_t *);
1932
* \brief Converts a #wasm_extern_t to #wasm_global_t.
1933
*
1934
* The returned #wasm_global_t is owned by the #wasm_extern_t argument. Callers
1935
* should not delete the returned value, and it only lives as long as the
1936
* #wasm_extern_t argument.
1937
*
1938
* If the #wasm_extern_t argument isn't a #wasm_global_t then `NULL` is returned.
1939
*
1940
* \fn const wasm_func_t *wasm_extern_as_func_const(const wasm_extern_t *);
1941
* \brief Converts a #wasm_extern_t to #wasm_func_t.
1942
*
1943
* The returned #wasm_func_t is owned by the #wasm_extern_t argument. Callers
1944
* should not delete the returned value, and it only lives as long as the
1945
* #wasm_extern_t argument.
1946
*
1947
* If the #wasm_extern_t argument isn't a #wasm_func_t then `NULL` is returned.
1948
*
1949
* \fn const wasm_table_t *wasm_extern_as_table_const(const wasm_extern_t *);
1950
* \brief Converts a #wasm_extern_t to #wasm_table_t.
1951
*
1952
* The returned #wasm_table_t is owned by the #wasm_extern_t argument. Callers
1953
* should not delete the returned value, and it only lives as long as the
1954
* #wasm_extern_t argument.
1955
*
1956
* If the #wasm_extern_t argument isn't a #wasm_table_t then `NULL` is returned.
1957
*
1958
* \fn const wasm_memory_t *wasm_extern_as_memory_const(const wasm_extern_t *);
1959
* \brief Converts a #wasm_extern_t to #wasm_memory_t.
1960
*
1961
* The returned #wasm_memory_t is owned by the #wasm_extern_t argument. Callers
1962
* should not delete the returned value, and it only lives as long as the
1963
* #wasm_extern_t argument.
1964
*
1965
* If the #wasm_extern_t argument isn't a #wasm_memory_t then `NULL` is returned.
1966
*
1967
* \fn const wasm_global_t *wasm_extern_as_global_const(const wasm_extern_t *);
1968
* \brief Converts a #wasm_extern_t to #wasm_global_t.
1969
*
1970
* The returned #wasm_global_t is owned by the #wasm_extern_t argument. Callers
1971
* should not delete the returned value, and it only lives as long as the
1972
* #wasm_extern_t argument.
1973
*
1974
* If the #wasm_extern_t argument isn't a #wasm_global_t then `NULL` is returned.
1975
*/
1976
1977
/**
1978
* \struct wasm_instance_t
1979
* \brief Opaque struct representing a wasm instance.
1980
*
1981
* \typedef wasm_instance_t
1982
* \brief Convenience alias for #wasm_instance_t
1983
*
1984
* \fn void wasm_instance_delete(wasm_instance_t *v);
1985
* \brief Deletes a instance.
1986
*
1987
* \fn wasm_instance_t *wasm_instance_copy(const wasm_instance_t *)
1988
* \brief Copies a #wasm_instance_t to a new one.
1989
*
1990
* The caller is responsible for deleting the returned #wasm_instance_t.
1991
*
1992
* \fn void wasm_instance_same(const wasm_instance_t *, const wasm_instance_t *)
1993
* \brief Unimplemented in Wasmtime, aborts the process if called.
1994
*
1995
* \fn void* wasm_instance_get_host_info(const wasm_instance_t *);
1996
* \brief Unimplemented in Wasmtime, always returns `NULL`.
1997
*
1998
* \fn void wasm_instance_set_host_info(wasm_instance_t *, void *);
1999
* \brief Unimplemented in Wasmtime, aborts the process if called.
2000
*
2001
* \fn void wasm_instance_set_host_info_with_finalizer(wasm_instance_t *, void *, void(*)(void*));
2002
* \brief Unimplemented in Wasmtime, aborts the process if called.
2003
*
2004
* \fn wasm_ref_t *wasm_instance_as_ref(wasm_instance_t *);
2005
* \brief Unimplemented in Wasmtime, aborts the process if called.
2006
*
2007
* \fn wasm_instance_t *wasm_ref_as_instance(wasm_ref_t *);
2008
* \brief Unimplemented in Wasmtime, aborts the process if called.
2009
*
2010
* \fn const wasm_ref_t *wasm_instance_as_ref_const(const wasm_instance_t *);
2011
* \brief Unimplemented in Wasmtime, aborts the process if called.
2012
*
2013
* \fn const wasm_instance_t *wasm_ref_as_instance_const(const wasm_ref_t *);
2014
* \brief Unimplemented in Wasmtime, aborts the process if called.
2015
*
2016
* \fn wasm_ref_as_instance_const(const wasm_ref_t *);
2017
* \brief Unimplemented in Wasmtime, aborts the process if called.
2018
*
2019
* \fn wasm_instance_t *wasm_instance_new(wasm_store_t *, const wasm_module_t *, const wasm_extern_vec_t *, wasm_trap_t **);
2020
* \brief Instantiates a module with the provided imports.
2021
*
2022
* This function will instantiate the provided #wasm_module_t into the provided
2023
* #wasm_store_t. The `imports` specified are used to satisfy the imports of the
2024
* #wasm_module_t.
2025
*
2026
* This function must provide exactly the same number of imports as returned by
2027
* #wasm_module_imports or this results in undefined behavior.
2028
*
2029
* Imports provided are expected to be 1:1 matches against the list returned by
2030
* #wasm_module_imports.
2031
*
2032
* Instantiation includes invoking the `start` function of a wasm module. If
2033
* that function traps then a trap is returned through the #wasm_trap_t type.
2034
*
2035
* This function does not take ownership of any of its arguments, and the
2036
* returned #wasm_instance_t and #wasm_trap_t are owned by the caller.
2037
*
2038
* \fn void wasm_instance_exports(const wasm_instance_t *, wasm_extern_vec_t *out);
2039
* \brief Returns the exports of an instance.
2040
*
2041
* This function returns a list of #wasm_extern_t values, which will be owned by
2042
* the caller, which are exported from the instance. The `out` list will have
2043
* the same length as #wasm_module_exports called on the original module. Each
2044
* element is 1:1 matched with the elements in the list of #wasm_module_exports.
2045
*/
2046
2047
/**
2048
* \def WASM_EMPTY_VEC
2049
* \brief Used to initialize an empty vector type.
2050
*
2051
* \def WASM_ARRAY_VEC
2052
* \brief Used to initialize a vector type from a C array.
2053
*
2054
* \def WASM_I32_VAL
2055
* \brief Used to initialize a 32-bit integer wasm_val_t value.
2056
*
2057
* \def WASM_I64_VAL
2058
* \brief Used to initialize a 64-bit integer wasm_val_t value.
2059
*
2060
* \def WASM_F32_VAL
2061
* \brief Used to initialize a 32-bit floating point wasm_val_t value.
2062
*
2063
* \def WASM_F64_VAL
2064
* \brief Used to initialize a 64-bit floating point wasm_val_t value.
2065
*
2066
* \def WASM_REF_VAL
2067
* \brief Used to initialize an externref wasm_val_t value.
2068
*
2069
* \def WASM_INIT_VAL
2070
* \brief Used to initialize a null externref wasm_val_t value.
2071
*/
2072
2073