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:
Ivan Enderlin
2021-02-11 23:30:27 +01:00
parent f21556f85f
commit fd6689c580
17 changed files with 536 additions and 453 deletions

View File

@@ -2,7 +2,7 @@
//! `wasm_engine_t` and siblings.
use super::super::engine::wasm_config_t;
use super::target_lexicon::wasm_target_t;
use super::target_lexicon::wasmer_target_t;
/// Unstable non-standard Wasmer-specific API to update the
/// configuration to specify a particular target for the engine.
@@ -21,11 +21,11 @@ use super::target_lexicon::wasm_target_t;
///
/// // Set the target.
/// {
/// wasm_triple_t* triple = wasm_triple_new_from_host();
/// wasm_cpu_features_t* cpu_features = wasm_cpu_features_new();
/// wasm_target_t* target = wasm_target_new(triple, cpu_features);
/// wasmer_triple_t* triple = wasmer_triple_new_from_host();
/// wasmer_cpu_features_t* cpu_features = wasmer_cpu_features_new();
/// wasmer_target_t* target = wasmer_target_new(triple, cpu_features);
///
/// wasm_config_set_target(config, target);
/// wasmer_config_set_target(config, target);
/// }
///
/// // Create the engine.
@@ -44,6 +44,9 @@ use super::target_lexicon::wasm_target_t;
/// # }
/// ```
#[no_mangle]
pub extern "C" fn wasm_config_set_target(config: &mut wasm_config_t, target: Box<wasm_target_t>) {
pub extern "C" fn wasmer_config_set_target(
config: &mut wasm_config_t,
target: Box<wasmer_target_t>,
) {
config.target = Some(target);
}