diff --git a/lib/c-api/wasmer.h b/lib/c-api/wasmer.h index 7c77122932f..f5b0dcb4fd4 100644 --- a/lib/c-api/wasmer.h +++ b/lib/c-api/wasmer.h @@ -418,6 +418,10 @@ typedef struct { } wasmer_wasi_map_dir_entry_t; #endif +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + /** * Creates a new Module from the given wasm bytes. * diff --git a/lib/c-api/wasmer_wasm.h b/lib/c-api/wasmer_wasm.h index 83ad74f3f1c..b4a6dd4a19a 100644 --- a/lib/c-api/wasmer_wasm.h +++ b/lib/c-api/wasmer_wasm.h @@ -138,6 +138,13 @@ typedef struct wasi_env_t wasi_env_t; typedef struct wasm_named_extern_t wasm_named_extern_t; #endif +#if defined(WASMER_WASI_ENABLED) +typedef struct { + uintptr_t size; + wasm_named_extern_t **data; +} wasm_named_extern_vec_t; +#endif + #ifdef __cplusplus extern "C" { #endif // __cplusplus @@ -154,20 +161,6 @@ void wasi_config_capture_stderr(wasi_config_t *config); void wasi_config_capture_stdout(wasi_config_t *config); #endif -/** - *Represents a vector of `wasm_named_extern_t`. - * - *Read the documentation of [`wasm_named_extern_t`] to see more concrete examples. - */ -typedef struct { - uintptr_t size; - wasm_named_extern_t **data; -} wasm_named_extern_vec_t; - -#if defined(WASMER_WASI_ENABLED) -void wasi_config_arg(wasi_config_t *config, const char *arg); -#endif - #if defined(WASMER_WASI_ENABLED) void wasi_config_env(wasi_config_t *config, const char *key, const char *value); #endif @@ -257,97 +250,40 @@ void wasm_module_name(const wasm_module_t *module, wasm_name_t *out); bool wasm_module_set_name(wasm_module_t *module, const wasm_name_t *name); #if defined(WASMER_WASI_ENABLED) -/** - * Non-standard function to get the module name of a - * `wasm_named_extern_t`. - */ const wasm_name_t *wasm_named_extern_module(const wasm_named_extern_t *named_extern); #endif #if defined(WASMER_WASI_ENABLED) -/** - * Non-standard function to get the name of a `wasm_named_extern_t`. - */ const wasm_name_t *wasm_named_extern_name(const wasm_named_extern_t *named_extern); #endif #if defined(WASMER_WASI_ENABLED) -/** - * Non-standard function to get the wrapped extern of a - * `wasm_named_extern_t`. - */ const wasm_extern_t *wasm_named_extern_unwrap(const wasm_named_extern_t *named_extern); #endif #if defined(WASMER_WASI_ENABLED) -/** - *Performs a deep copy of a vector of [`wasm_named_extern_t`]. - */ void wasm_named_extern_vec_copy(wasm_named_extern_vec_t *out_ptr, const wasm_named_extern_vec_t *in_ptr); #endif #if defined(WASMER_WASI_ENABLED) -/** - *Deletes a vector of [`wasm_named_extern_t`]. - * - *# Example - * - *See the [`wasm_named_extern_vec_t`] type to get an example. - */ void wasm_named_extern_vec_delete(wasm_named_extern_vec_t *ptr); #endif #if defined(WASMER_WASI_ENABLED) -/** - *Creates a new vector of [`wasm_named_extern_t`]. - */ void wasm_named_extern_vec_new(wasm_named_extern_vec_t *out, uintptr_t length, wasm_named_extern_t *const *init); #endif #if defined(WASMER_WASI_ENABLED) -/** - *Creates an empty vector of [`wasm_named_extern_t`]. - * - *# Example - * - *```rust # use inline_c::assert_c; # fn main() { # (assert_c! { # #include "tests/wasmer_wasm.h" # int main() { // Creates an empty vector of `wasm_named_extern_t`. wasm_named_extern_vec_t vector; wasm_named_extern_vec_new_empty(&vector); - * - * // Check that it is empty. assert(vector.size == 0); - * - * // Free it. wasm_named_extern_vec_delete(&vector); } # }) # .success(); # } ``` - */ void wasm_named_extern_vec_new_empty(wasm_named_extern_vec_t *out); #endif #if defined(WASMER_WASI_ENABLED) -/** - *Creates a new uninitialized vector of [`wasm_named_extern_t`]. - * - *# Example - * - *```rust # use inline_c::assert_c; # fn main() { # (assert_c! { # #include "tests/wasmer_wasm.h" # int main() { // Creates an empty vector of `wasm_named_extern_t`. wasm_named_extern_vec_t vector; wasm_named_extern_vec_new_uninitialized(&vector, 3); - * - * // Check that it contains 3 items. assert(vector.size == 3); - * - * // Free it. wasm_named_extern_vec_delete(&vector); } # }) # .success(); # } ``` - */ -void wasm_named_extern_vec_new_uninitialized(wasm_named_extern_vec_t *out, - uintptr_t length); -#endif - -/** - * Gets the length in bytes of the last error if any, zero otherwise. - * - * This can be used to dynamically allocate a buffer with the correct number of - * bytes needed to store a message. - * - * # Example - * - * See this module's documentation to get a complete example. - */ +void wasm_named_extern_vec_new_uninitialized(wasm_named_extern_vec_t *out, uintptr_t length); +#endif + int wasmer_last_error_length(void); int wasmer_last_error_message(char *buffer, int length);