@@ -515,8 +515,7 @@ typedef own wasm_trap_t* (*wasmtime_func_callback_t)(const wasmtime_caller_t* ca
515
515
*
516
516
* This function is the same as #wasm_func_callback_with_env_t except that its
517
517
* first argument is a #wasmtime_caller_t which allows learning information
518
- * about the
519
- * caller.
518
+ * about the caller.
520
519
*/
521
520
typedef own wasm_trap_t * (* wasmtime_func_callback_with_env_t )(const wasmtime_caller_t * caller , void * env , const wasm_val_t args [], wasm_val_t results []);
522
521
@@ -544,6 +543,28 @@ WASM_API_EXTERN own wasm_func_t* wasmtime_func_new_with_env(
544
543
void (* finalizer )(void * )
545
544
);
546
545
546
+ /**
547
+ * \brief Creates a new `funcref` value referencing `func`.
548
+ *
549
+ * Create a `funcref` value that references `func` and writes it to `funcrefp`.
550
+ *
551
+ * Gives ownership fo the `funcref` value written to `funcrefp`.
552
+ *
553
+ * Both `func` and `funcrefp` must not be NULL.
554
+ */
555
+ WASM_API_EXTERN void wasmtime_func_as_funcref (const wasm_func_t * func , wasm_val_t * funcrefp );
556
+
557
+ /**
558
+ * \brief Get the `wasm_func_t*` referenced by the given `funcref` value.
559
+ *
560
+ * Gets an owning handle to the `wasm_func_t*` that the given `funcref` value is
561
+ * referencing. Returns NULL if the value is not a `funcref`, or if the value is
562
+ * a null function reference.
563
+ *
564
+ * The `val` pointer must not be NULL.
565
+ */
566
+ WASM_API_EXTERN own wasm_func_t * wasmtime_funcref_as_func (const wasm_val_t * val );
567
+
547
568
/**
548
569
* \brief Loads a #wasm_extern_t from the caller's context
549
570
*
@@ -845,8 +866,10 @@ WASM_API_EXTERN wasmtime_error_t *wasmtime_funcref_table_grow(
845
866
* This function does not take an associated finalizer to clean up the data when
846
867
* the reference is reclaimed. If you need a finalizer to clean up the data,
847
868
* then use #wasmtime_externref_new_with_finalizer.
869
+ *
870
+ * Gives ownership of the newly created `externref` value.
848
871
*/
849
- WASM_API_EXTERN void wasmtime_externref_new (void * data , wasm_val_t * valp );
872
+ WASM_API_EXTERN void wasmtime_externref_new (own void * data , wasm_val_t * valp );
850
873
851
874
/**
852
875
* \brief A finalizer for an `externref`'s wrapped data.
@@ -866,9 +889,11 @@ typedef void (*wasmtime_externref_finalizer_t)(void*);
866
889
* When the reference is reclaimed, the wrapped data is cleaned up with the
867
890
* provided finalizer. If you do not need to clean up the wrapped data, then use
868
891
* #wasmtime_externref_new.
892
+ *
893
+ * Gives ownership of the newly created `externref` value.
869
894
*/
870
895
WASM_API_EXTERN void wasmtime_externref_new_with_finalizer (
871
- void * data ,
896
+ own void * data ,
872
897
wasmtime_externref_finalizer_t finalizer ,
873
898
wasm_val_t * valp
874
899
);
@@ -887,7 +912,8 @@ WASM_API_EXTERN void wasmtime_externref_new_with_finalizer(
887
912
* If the given value is not an `externref`, returns `false` and leaves `datap`
888
913
* unmodified.
889
914
*
890
- * Does not take ownership of `val`.
915
+ * Does not take ownership of `val`. Does not give up ownership of the `void*`
916
+ * data written to `datap`.
891
917
*
892
918
* Both `val` and `datap` must not be `NULL`.
893
919
*/
0 commit comments