Commit Graph

811 Commits

Author SHA1 Message Date
830efaac17 fix(c-api) Use the name wasm_config_set_.
See the discussion here
https://github.com/wasmerio/wasmer/pull/2117#discussion_r575303872.
2021-02-18 15:04:21 +01:00
fbe4e07476 test(c-api) Remove no_run for 2 doctests. 2021-02-12 10:44:14 +01:00
bd412ea2e5 chore(c-api) Update headers. 2021-02-12 10:36:49 +01:00
93a427505e doc(c-api) Add documentation. 2021-02-12 10:35:54 +01:00
bdcc95925c test(c-api) Add tests for the wasmer_is_*_available API. 2021-02-12 10:29:58 +01:00
17dbb32e5a feat(c-api) Do not rename wat2wasm for the moment. 2021-02-12 00:26:53 +01:00
359873c1a1 feat(c-api) Add an unstable non-standard API to query available engines and compilers. 2021-02-12 00:20:23 +01:00
fd6689c580 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.
2021-02-11 23:56:36 +01:00
197d0f7a49 Initial commit of C API for metering and middleware. 2021-02-09 01:20:34 -08:00
f85ebe1b21 fix(c-api) Fix how string's length is computed.
Obviously, it's just `feature.size`. Why did I do that…?
2021-02-05 10:09:43 +01:00
fb429e0a6e Update the C API header files. 2021-02-04 19:53:41 -08:00
9e1cec01be Prepare for 1.0.2 release 2021-02-04 19:44:49 -08:00
e5fd42ebaf Merge pull request #2093 from Hywan/feat-c-api-env-instance
feat(api,vm) Improve the `vm::ImportInitializerFuncPtr` type.
2021-02-04 16:05:08 -08:00
f0f1915c86 chore(c-api) Rename or add variables for more clarity. 2021-02-04 14:00:00 +01:00
30095e1600 fix(c-api) Do not run build.rs if the scripts/publish.py script is running. 2021-02-02 14:26:58 +01:00
698a26c7fe fix(c-api) Restore a bug with wasi_get_imports.
We said that `wasi_get_imports` was taking ownership of
`wasi_env_t`. It wasn't. In 9e63ba9a25,
we have fixed this. But it creates another bug when `wasi_env_t` is
used _after_ for example when calling `wasi_env_read_stdout`.

So this patch reverts the bug fix. And we will discuss about how to
fix that later.
2021-02-02 13:42:29 +01:00
e5d5303b50 Merge branch 'master' into feat-c-api-wasi-unordered-imports 2021-02-02 12:17:01 +01:00
995a2d4779 feat(c-api) No longer expand with cbindgen: drop dependency to Rust nightly.
So. Let's explain a dirty hack. `cbindgen` reads the code and collects
symbols. What symbols do we need? None of the one declared in
`wasm.h`, but for non-standard API, we need to collect all of
them. The problem is that `wasm_named_extern_t` is the only
non-standard type where extra symbols are generated by a macro
(`wasm_declare_boxed_vec!`). If we want those macro-generated symbols
to be collected by `cbindgen`, we need to _expand_ the crate
(i.e. running something like `rustc -- -Zunstable-options
--pretty=expanded`). Expanding code is unstable and available only on
nightly compiler. We _don't want_ to use a nightly compiler only for
that. So how can we help `cbindgen` to _see_ those symbols?

First solution: We write the C code directly in a file, which is then
included in the generated header file with the `cbindgen`
API. Problem, it's super easy to get it outdated, and it makes the
build process more complex.

Second solution: We write those symbols in a custom module, that is
just here for `cbindgen`, never used by our Rust code (otherwise it's
duplicated code), with no particular implementation.

And that's why we have the following `cbindgen_hack` module.

But this module must not be compiled by `rustc`. How to force `rustc`
to ignore a module? With conditional compilation. Because `cbindgen`
does not support conditional compilation, it will always _ignore_ the
`#[cfg]` attribute, and will always read the content of the module.

Sorry.
2021-02-02 12:05:47 +01:00
4725a5d623 Merge branch 'master' into feat-c-api-cross-compilation-2 2021-02-02 11:07:21 +01:00
c4c7b2bb9b Merge #2083
2083: doc(c-api) Remove inline documentation in `wasmer_wasm.h`, clarification about stability… r=Hywan a=Hywan

# Description

As suggested in https://github.com/wasmerio/wasmer/pull/2053#discussion_r566692725, this PR removes the automatically generated documentation when building `wasmer_wasm.h`.

It also clarifies our position regarding stability, and add a section about the documentation.

This PR takes also the opportunity to mark `wasi_env_set_(instance|memory)` as deprecated functions.

# Review

- [x] Add a short description of the the change to the CHANGELOG.md file


Co-authored-by: Ivan Enderlin <ivan@mnt.io>
2021-02-02 09:24:37 +00:00
0826d3d722 Merge branch 'master' into feat-c-api-cross-compilation-2 2021-02-02 09:51:01 +01:00
7eb08399f2 fix(c-api) Include feedbacks from @MarkMcCaskey! 2021-02-02 09:49:39 +01:00
b2bc62d43a chore(c-api) Update headers. 2021-02-02 09:23:37 +01:00
98bff43f35 chore(c-api) Remove useless unsafe keywords. 2021-02-01 15:49:53 +01:00
b954429ca6 fix(c-api) Avoid more than one call to the function environment finalizer.
A function environment `WrapperEnv` can be cloned. In case the
original and the cloned environments are being dropped, the
`self.finalizer` function —if any— is called twice. That's a bug. It
must be called only once.

This patch updates the code to apply the finalizer only once by taking
it —if any— the first time it's called.
2021-02-01 15:42:28 +01:00
7c63648eb7 Update lib/c-api/src/wasm_c_api/wasi/mod.rs
Co-authored-by: Julien BIANCHI <contact@jubianchi.Fr>
2021-02-01 15:06:26 +01:00
9a835a4fdc doc(c-api) Remove incorrect link. 2021-02-01 15:00:13 +01:00
d48bc1e67e chore(c-api) Update headers. 2021-02-01 14:58:54 +01:00
8ab82cf589 doc(c-api) Fix documentation. 2021-02-01 14:58:42 +01:00
9e63ba9a25 fix(c-api) Fix memory leak and owernship in WASI.
In `wasi_get_imports` and `wasi_get_unordered_imports`, we said the
ownership of `wasi_env_t` was taken by the function, but it wasn't the
case. This patch changes the type from `&wasi_env_t` to
`Box<wasi_env_t>` to take ownership of it.

The rest of the patch updates the documentation, and improves null
protections with `Option<T>`.
2021-02-01 14:55:45 +01:00
b1dc0416dd chore(c-api) Make type explicit for the sake of simplicity. 2021-02-01 13:42:06 +01:00
bbbbe53602 test(c-api) Move a doctest into a test. 2021-02-01 13:38:51 +01:00
0861b73974 Fix rebase. 2021-02-01 12:04:10 +01:00
37aee2d7ad chore(c-api) Simplify code. 2021-02-01 12:03:38 +01:00
e379fd79fb chore(c-api) Merge _CBINDGEN_IS_RUNNING with DOCS_RS. 2021-02-01 12:03:38 +01:00
83c69a5623 feat(c-api) Implement From<String> for wasm_name_t. 2021-02-01 12:03:38 +01:00
5fc3e9fbca chore(c-api) Update headers. 2021-02-01 12:03:36 +01:00
1042dad5eb chore(c-api) Update headers. 2021-02-01 12:03:08 +01:00
18761cad7d feat(c-api) Implement wasm_extern_copy.
This patch also moves `wasm_extern_delete` into the correct Rust module.
2021-02-01 12:02:39 +01:00
79b5d5c032 chore(c-api) Exclude more functions from Wasm C API for the Wasmer C API. 2021-02-01 12:02:12 +01:00
5abac74618 feat(c-api) Rename wasm_named_extern_extern to wasm_named_extern_unwrap. 2021-02-01 12:02:12 +01:00
5de7d71e84 chore(c-api) Update headers. 2021-02-01 12:02:10 +01:00
8b29156d2d fixup 2021-02-01 12:01:30 +01:00
ffd07bcfd7 feat(c-api) Expand macros of the crate when generating C bindings. 2021-02-01 12:01:27 +01:00
0ad4d319d6 chore(c-api) Update headers. 2021-02-01 12:01:00 +01:00
00bf74c488 chore(c-api) Reorder field for the sake of consistency. 2021-02-01 11:59:23 +01:00
dc0cf7d4a4 feat(c-api) Implement wasi_get_unordered_imports. 2021-02-01 11:59:23 +01:00
a6ce35b824 chore(c-api) Update headers. 2021-02-01 11:55:46 +01:00
277d85c5ae fix(c-api) Mark wasi_env_set_(instance|memory) as deprecated. 2021-02-01 11:55:38 +01:00
cbc8b4a773 chore(c-api) Update headers. 2021-02-01 11:50:11 +01:00