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

doc(c-api) Remove inline documentation in wasmer_wasm.h, clarification about stability… #2083

Merged
merged 8 commits into from
Feb 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- [#2054](https://github.com/wasmerio/wasmer/pull/2054) Add `wasm_config_delete` to the Wasm C API.

### Changed
- [#2083](https://github.com/wasmerio/wasmer/pull/2083) Mark `wasi_env_set_(instance|memory)` as deprecated. You may simply remove them with no side-effect.
- [#2056](https://github.com/wasmerio/wasmer/pull/2056) Change back to depend on the `enumset` crate instead of `wasmer_enumset`

### Fixed
Expand Down
59 changes: 48 additions & 11 deletions lib/c-api/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,41 @@ fn build_wasm_c_api_headers(crate_dir: &str, out_dir: &str) {
out_header_file.push("wasmer_wasm");

let mut pre_header = format!(
r#"// The Wasmer C/C++ header file compatible with the `wasm-c-api` standard API.
// This file is generated by lib/c-api/build.rs.
r#"// The Wasmer C/C++ header file compatible with the [`wasm-c-api`]
// standard API, as `wasm.h` (included here).
//
// This file is automatically generated by `lib/c-api/build.rs` of the
// [`wasmer-c-api`] Rust crate.
//
// # Stability
//
// The [`wasm-c-api`] standard API is a _living_ standard. There is no
// commitment for stability yet. We (Wasmer) will try our best to keep
// backward compatibility as much as possible. Nonetheless, some
// necessary API aren't yet standardized, and as such, we provide a
// custom API, e.g. `wasi_*` types and functions.
//
// The documentation makes it clear whether a function is unstable.
//
// When a type or a function will be deprecated, it will be marked as
// such with the appropriated compiler warning, and will be removed at
// the next release round.
//
// # Documentation
//
// At the time of writing, the [`wasm-c-api`] standard has no
// documentation. This file also does not include inline
// documentation. However, we have made (and we continue to make) an
// important effort to document everything. [See the documentation
// online][documentation]. Please refer to this page for the real
// canonical documentation. It also contains numerous examples.
//
// To generate the documentation locally, run `cargo doc --open` from
// within the [`wasmer-c-api`] Rust crate.
//
// [`wasm-c-api`]: https://github.com/WebAssembly/wasm-c-api
// [`wasmer-c-api`]: https://github.com/wasmerio/wasmer/tree/master/lib/c-api
// [documentation]: https://wasmerio.github.io/wasmer/crates/wasmer_c_api/

#if !defined(WASMER_WASM_H_PRELUDE)

Expand Down Expand Up @@ -184,10 +217,12 @@ fn build_wasmer_c_api_headers(crate_dir: &str, out_dir: &str) {
out_header_file.set_extension("h");

// Build and generate the header file.
exclude_items_from_wasm_c_api(new_builder(Language::C, crate_dir, guard, &pre_header))
.generate()
.expect("Unable to generate C bindings")
.write_to_file(out_header_file.as_path());
exclude_items_from_wasm_c_api(
new_builder(Language::C, crate_dir, guard, &pre_header).with_documentation(true),
)
.generate()
.expect("Unable to generate C bindings")
.write_to_file(out_header_file.as_path());

// Copy the generated bindings from `OUT_DIR` to
// `CARGO_MANIFEST_DIR`.
Expand All @@ -203,10 +238,12 @@ fn build_wasmer_c_api_headers(crate_dir: &str, out_dir: &str) {
out_header_file.set_extension("hh");

// Build and generate the header file.
exclude_items_from_wasm_c_api(new_builder(Language::Cxx, crate_dir, guard, &pre_header))
.generate()
.expect("Unable to generate C++ bindings")
.write_to_file(out_header_file.as_path());
exclude_items_from_wasm_c_api(
new_builder(Language::Cxx, crate_dir, guard, &pre_header).with_documentation(true),
)
.generate()
.expect("Unable to generate C++ bindings")
.write_to_file(out_header_file.as_path());

// Copy the generated bindings from `OUT_DIR` to
// `CARGO_MANIFEST_DIR`.
Expand Down Expand Up @@ -247,7 +284,7 @@ fn new_builder(language: Language, crate_dir: &str, include_guard: &str, header:
.with_crate(crate_dir)
.with_include_guard(include_guard)
.with_header(header)
.with_documentation(true)
.with_documentation(false)
.with_define("target_family", "windows", "_WIN32")
.with_define("target_arch", "x86_64", "ARCH_X86_64")
.with_define("feature", "jit", JIT_FEATURE_AS_C_DEFINE)
Expand Down
26 changes: 9 additions & 17 deletions lib/c-api/src/wasm_c_api/wasi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,30 +199,22 @@ pub extern "C" fn wasi_env_delete(_state: Option<Box<wasi_env_t>>) {}

/// This function is deprecated. You may safely remove all calls to it and everything
/// will continue to work.
// Dead code: deprecate or remove
#[allow(unused_variables)]
///
/// cbindgen:prefix=DEPRECATED("This function is no longer necessary. You may safely remove all calls to it and everything will continue to work.")
#[no_mangle]
pub extern "C" fn wasi_env_set_instance(env: &mut wasi_env_t, instance: &wasm_instance_t) -> bool {
/*
let memory = if let Ok(memory) = instance.inner.exports.get_memory("memory") {
memory
} else {
return false;
};
env.inner.set_memory(memory.clone());
*/

pub extern "C" fn wasi_env_set_instance(
_env: &mut wasi_env_t,
_instance: &wasm_instance_t,
) -> bool {
true
}

/// This function is deprecated. You may safely remove all calls to it and everything
/// will continue to work.
// Dead code: deprecate or remove
#[allow(unused_variables)]
///
/// cbindgen:prefix=DEPRECATED("This function is no longer necessary. You may safely remove all calls to it and everything will continue to work.")
#[no_mangle]
pub extern "C" fn wasi_env_set_memory(env: &mut wasi_env_t, memory: &wasm_memory_t) {
//env.inner.set_memory(memory.inner.clone());
}
pub extern "C" fn wasi_env_set_memory(_env: &mut wasi_env_t, _memory: &wasm_memory_t) {}

#[no_mangle]
pub unsafe extern "C" fn wasi_env_read_stdout(
Expand Down
Loading