mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-05 04:08:20 +00:00
chore(c-api) Formalize API prefixes.
The new rule is the following: * `wasm_` for the standard C API, * `wasmer_` or `wasi_` for the Wasmer non-standard C API. For all symbols inside the `unstable` module, the renaming `wasm_` to `wasmer_` is done without deprecations. It was clear that those API were unstable. For all the other symbols, symbols have been renamed to `wasmer_` but the old symbols have been kept with deprecation warnings. Special note: The `wasm_named_extern_t` type (and associated functions) was in `wasi` by mistake. Its place was in the `unstable` module. This patch also fixes that. The `wasm_declare_vec_*` macros have been updated to support a default prefix, or a user-defined prefix. It's now possible to write `wasm_declare_boxed_vec!(foo);` to get all the API prefixed by `wasm_` (as previously), or `wasm_declare_boxed_vec!(foo, wasmer);` to prefix with `wasmer_`. A user not using symbols from the `unstable` module will continue to get working code, modulo some deprecations, after this patch.
This commit is contained in:
@@ -28,14 +28,14 @@ use std::sync::Arc;
|
||||
/// wasmer_byte_vec_new_from_string(&wat, "(module $moduleName)");
|
||||
/// // ^~~~~~~~~~~ that's the name!
|
||||
/// wasm_byte_vec_t wasm;
|
||||
/// wat2wasm(&wat, &wasm);
|
||||
/// wasmer_wat2wasm(&wat, &wasm);
|
||||
///
|
||||
/// // Create the module.
|
||||
/// wasm_module_t* module = wasm_module_new(store, &wasm);
|
||||
///
|
||||
/// // Read the module's name.
|
||||
/// wasm_name_t name;
|
||||
/// wasm_module_name(module, &name);
|
||||
/// wasmer_module_name(module, &name);
|
||||
///
|
||||
/// // It works!
|
||||
/// wasmer_assert_name(&name, "moduleName");
|
||||
@@ -55,7 +55,7 @@ use std::sync::Arc;
|
||||
/// # }
|
||||
/// ```
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn wasm_module_name(
|
||||
pub unsafe extern "C" fn wasmer_module_name(
|
||||
module: &wasm_module_t,
|
||||
// own
|
||||
out: &mut wasm_name_t,
|
||||
@@ -94,7 +94,7 @@ pub unsafe extern "C" fn wasm_module_name(
|
||||
/// wasm_byte_vec_t wat;
|
||||
/// wasmer_byte_vec_new_from_string(&wat, "(module)");
|
||||
/// wasm_byte_vec_t wasm;
|
||||
/// wat2wasm(&wat, &wasm);
|
||||
/// wasmer_wat2wasm(&wat, &wasm);
|
||||
///
|
||||
/// // Create the module.
|
||||
/// wasm_module_t* module = wasm_module_new(store, &wasm);
|
||||
@@ -102,7 +102,7 @@ pub unsafe extern "C" fn wasm_module_name(
|
||||
/// // Read the module's name. There is none for the moment.
|
||||
/// {
|
||||
/// wasm_name_t name;
|
||||
/// wasm_module_name(module, &name);
|
||||
/// wasmer_module_name(module, &name);
|
||||
///
|
||||
/// assert(name.size == 0);
|
||||
/// }
|
||||
@@ -111,13 +111,13 @@ pub unsafe extern "C" fn wasm_module_name(
|
||||
/// {
|
||||
/// wasm_name_t name;
|
||||
/// wasmer_byte_vec_new_from_string(&name, "hello");
|
||||
/// wasm_module_set_name(module, &name);
|
||||
/// wasmer_module_set_name(module, &name);
|
||||
/// }
|
||||
///
|
||||
/// // And now, let's see the new name.
|
||||
/// {
|
||||
/// wasm_name_t name;
|
||||
/// wasm_module_name(module, &name);
|
||||
/// wasmer_module_name(module, &name);
|
||||
///
|
||||
/// // It works!
|
||||
/// wasmer_assert_name(&name, "hello");
|
||||
@@ -139,7 +139,7 @@ pub unsafe extern "C" fn wasm_module_name(
|
||||
/// # }
|
||||
/// ```
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn wasm_module_set_name(
|
||||
pub unsafe extern "C" fn wasmer_module_set_name(
|
||||
module: &mut wasm_module_t,
|
||||
// own
|
||||
name: &wasm_name_t,
|
||||
|
||||
Reference in New Issue
Block a user