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