Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 0.19.0 API methods where appropriate #75

Open
3 of 5 tasks
plicease opened this issue Jul 17, 2020 · 1 comment
Open
3 of 5 tasks

Add 0.19.0 API methods where appropriate #75

plicease opened this issue Jul 17, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@plicease
Copy link
Member

plicease commented Jul 17, 2020

The new header file changes are mostly comments, but:

  • funcref functions
+/**
+ * \brief Creates a new `funcref` value referencing `func`.
+ *
+ * Create a `funcref` value that references `func` and writes it to `funcrefp`.
+ *
+ * Gives ownership fo the `funcref` value written to `funcrefp`.
+ *
+ * Both `func` and `funcrefp` must not be NULL.
+ */
+WASM_API_EXTERN void wasmtime_func_as_funcref(const wasm_func_t* func, wasm_val_t* funcrefp);
+
+/**
+ * \brief Get the `wasm_func_t*` referenced by the given `funcref` value.
+ *
+ * Gets an owning handle to the `wasm_func_t*` that the given `funcref` value is
+ * referencing. Returns NULL if the value is not a `funcref`, or if the value is
+ * a null function reference.
+ *
+ * The `val` pointer must not be NULL.
+ */
+WASM_API_EXTERN own wasm_func_t* wasmtime_funcref_as_func(const wasm_val_t* val);
  • exit_status method
+/**
+ * \brief Attempts to extract a WASI-specific exit status from this trap.
+ *
+ * Returns `true` if the trap is a WASI "exit" trap and has a return status. If
+ * `true` is returned then the exit status is returned through the `status`
+ * pointer. If `false` is returned then this is not a wasi exit trap.
+ */
+WASM_API_EXTERN bool wasmtime_trap_exit_status(const wasm_trap_t*, int *status);
  • update module constructor
 WASM_API_EXTERN own wasmtime_error_t *wasmtime_module_new(
-    wasm_store_t *store,
+    wasm_engine_t *engine,
     const wasm_byte_vec_t *binary,
     own wasm_module_t **ret
 );
  • externref functions
+/**
+ * \brief Create a new `externref` value.
+ *
+ * Creates a new `externref` value wrapping the provided data, and writes it to
+ * `valp`.
+ *
+ * This function does not take an associated finalizer to clean up the data when
+ * the reference is reclaimed. If you need a finalizer to clean up the data,
+ * then use #wasmtime_externref_new_with_finalizer.
+ *
+ * Gives ownership of the newly created `externref` value.
+ */
+WASM_API_EXTERN void wasmtime_externref_new(own void *data, wasm_val_t *valp);
+
+/**
+ * \brief A finalizer for an `externref`'s wrapped data.
+ *
+ * A finalizer callback to clean up an `externref`'s wrapped data after the
+ * `externref` has been reclaimed. This is an opportunity to run destructors,
+ * free dynamically allocated memory, close file handles, etc.
+ */
+typedef void (*wasmtime_externref_finalizer_t)(void*);
+
+/**
+ * \brief Create a new `externref` value with a finalizer.
+ *
+ * Creates a new `externref` value wrapping the provided data, and writes it to
+ * `valp`.
+ *
+ * When the reference is reclaimed, the wrapped data is cleaned up with the
+ * provided finalizer. If you do not need to clean up the wrapped data, then use
+ * #wasmtime_externref_new.
+ *
+ * Gives ownership of the newly created `externref` value.
+ */
+WASM_API_EXTERN void wasmtime_externref_new_with_finalizer(
+    own void *data,
+    wasmtime_externref_finalizer_t finalizer,
+    wasm_val_t *valp
+);
+
+/**
+ * \brief Get an `externref`'s wrapped data
+ *
+ * If the given value is a reference to a non-null `externref`, writes the
+ * wrapped data that was passed into #wasmtime_externref_new or
+ * #wasmtime_externref_new_with_finalizer when creating the given `externref` to
+ * `datap`, and returns `true`.
+ *
+ * If the value is a reference to a null `externref`, writes `NULL` to `datap`
+ * and returns `true`.
+ *
+ * If the given value is not an `externref`, returns `false` and leaves `datap`
+ * unmodified.
+ *
+ * Does not take ownership of `val`. Does not give up ownership of the `void*`
+ * data written to `datap`.
+ *
+ * Both `val` and `datap` must not be `NULL`.
+ */
+WASM_API_EXTERN bool wasmtime_externref_data(wasm_val_t* val, void** datap);
+
  • get_one_by_name method.
@plicease
Copy link
Member Author

plicease commented Jul 18, 2020

Missed this one:

+/**
+ * \brief Loads an item by name from this linker.
+ *
+ * \param linker the linker to load from
+ * \param module the name of the module to get
+ * \param name the name of the field to get
+ * \param item where to store the extracted item
+ *
+ * \return An error is returned if the item isn't defined or has more than one
+ * definition, or `NULL` is returned and `item` is filled in otherwise.
+ */
+WASM_API_EXTERN own wasmtime_error_t* wasmtime_linker_get_one_by_name(
+    const wasmtime_linker_t *linker,
+    const wasm_name_t *module,
+    const wasm_name_t *name,
+    own wasm_extern_t **item
+);

🎉

This was referenced Jul 18, 2020
@plicease plicease added the enhancement New feature or request label Jul 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

1 participant