Commit Graph

934 Commits

Author SHA1 Message Date
Ivan Enderlin
d48bc1e67e chore(c-api) Update headers. 2021-02-01 14:58:54 +01:00
Ivan Enderlin
8ab82cf589 doc(c-api) Fix documentation. 2021-02-01 14:58:42 +01:00
Ivan Enderlin
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
Ivan Enderlin
b1dc0416dd chore(c-api) Make type explicit for the sake of simplicity. 2021-02-01 13:42:06 +01:00
Ivan Enderlin
bbbbe53602 test(c-api) Move a doctest into a test. 2021-02-01 13:38:51 +01:00
Ivan Enderlin
0861b73974 Fix rebase. 2021-02-01 12:04:10 +01:00
Ivan Enderlin
37aee2d7ad chore(c-api) Simplify code. 2021-02-01 12:03:38 +01:00
Ivan Enderlin
e379fd79fb chore(c-api) Merge _CBINDGEN_IS_RUNNING with DOCS_RS. 2021-02-01 12:03:38 +01:00
Ivan Enderlin
83c69a5623 feat(c-api) Implement From<String> for wasm_name_t. 2021-02-01 12:03:38 +01:00
Ivan Enderlin
5fc3e9fbca chore(c-api) Update headers. 2021-02-01 12:03:36 +01:00
Ivan Enderlin
1042dad5eb chore(c-api) Update headers. 2021-02-01 12:03:08 +01:00
Ivan Enderlin
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
Ivan Enderlin
79b5d5c032 chore(c-api) Exclude more functions from Wasm C API for the Wasmer C API. 2021-02-01 12:02:12 +01:00
Ivan Enderlin
5abac74618 feat(c-api) Rename wasm_named_extern_extern to wasm_named_extern_unwrap. 2021-02-01 12:02:12 +01:00
Ivan Enderlin
5de7d71e84 chore(c-api) Update headers. 2021-02-01 12:02:10 +01:00
Ivan Enderlin
8b29156d2d fixup 2021-02-01 12:01:30 +01:00
Ivan Enderlin
ffd07bcfd7 feat(c-api) Expand macros of the crate when generating C bindings. 2021-02-01 12:01:27 +01:00
Ivan Enderlin
0ad4d319d6 chore(c-api) Update headers. 2021-02-01 12:01:00 +01:00
Ivan Enderlin
00bf74c488 chore(c-api) Reorder field for the sake of consistency. 2021-02-01 11:59:23 +01:00
Ivan Enderlin
dc0cf7d4a4 feat(c-api) Implement wasi_get_unordered_imports. 2021-02-01 11:59:23 +01:00
Ivan Enderlin
a6ce35b824 chore(c-api) Update headers. 2021-02-01 11:55:46 +01:00
Ivan Enderlin
277d85c5ae fix(c-api) Mark wasi_env_set_(instance|memory) as deprecated. 2021-02-01 11:55:38 +01:00
Ivan Enderlin
cbc8b4a773 chore(c-api) Update headers. 2021-02-01 11:50:11 +01:00
Ivan Enderlin
c1092864e1 doc(c-api) Improve wasmer_wasm.h intro to explain stability and documentation. 2021-02-01 11:49:03 +01:00
Ivan Enderlin
3ecd71940f doc(c-api) Remove auto-doc from wasmer_wasm.h. 2021-02-01 11:48:55 +01:00
Ivan Enderlin
7e757ded6b test(c-api) Simplify test by using wasm_name_new_from_string. 2021-01-29 15:04:40 +01:00
Ivan Enderlin
9fb174e961 doc(c-api) Add more documentation. 2021-01-29 14:41:41 +01:00
Ivan Enderlin
3c5692ca2f doc(c-api) Mark some types as unstable. 2021-01-29 14:39:59 +01:00
Ivan Enderlin
dc9f8fc82c chore(c-api) Update headers. 2021-01-29 14:34:59 +01:00
Ivan Enderlin
e4057469bc chore(c-api) get_default_compiler_config can stay private. 2021-01-29 14:29:50 +01:00
Ivan Enderlin
9fda912f31 feat(c-api) wasm_config_t and wasm_engine_new_with_config handle the target. 2021-01-29 14:27:07 +01:00
Ivan Enderlin
14b8fb0a9a feat(c-api) Implement wasm_config_set_target. 2021-01-29 14:26:52 +01:00
Ivan Enderlin
bc5bbfdeef feat(c-api) Implement Debug for wasm_target_t. 2021-01-29 14:26:38 +01:00
Ivan Enderlin
1eec258550 chore(c-api) Remove warning. 2021-01-29 14:25:47 +01:00
Ivan Enderlin
169fe16f31 doc+test(c-api) Add more tests and more documentation. 2021-01-29 12:34:14 +01:00
Ivan Enderlin
8f42485a49 Merge branch 'master' into feat-c-api-cross-compilation-2 2021-01-29 11:55:14 +01:00
bors[bot]
a0cadcf361 Merge #2071
2071: feat(c-api) Rename the `wasmer` module to `unstable` r=Hywan a=Hywan

# Description

This patch is the first step to prepare more unstable API (like cross-compilation etc.). Nothing changes for the moment from the user perspective, it's not a breaking change. It's just a reorganisation of the code, and better documentation. Basically the `wasmer_c_api::wasm_c_api::wasmer` module has been renamed `unstable`, so that it's super clear :-).

# Review

- [ ] ~Add a short description of the the change to the CHANGELOG.md file~ not necessary


Co-authored-by: Ivan Enderlin <ivan@mnt.io>
2021-01-28 17:54:24 +00:00
Ivan Enderlin
b201f12494 feat(c-api) Start implementing wasm_target_t, wasm_triple_t and wasm_cpu_features_t. 2021-01-28 17:26:15 +01:00
Ivan Enderlin
2f82d5536f feat(c-api) Rename the wasmer module to unstable. 2021-01-28 15:35:51 +01:00
Ivan Enderlin
2df343dc70 test(c-api) Test WASI captured stdout API. 2021-01-28 11:25:42 +01:00
Ivan Enderlin
7f79fcc373 Merge branch 'master' into fix-c-api-wasi-read-captured-stream 2021-01-28 10:45:16 +01:00
Ivan Enderlin
ef1328e1d7 fix(c-api) Don't drain the entire captured stream when reading a small range.
We use `VecDeque::drain` to read the captured stream, zipped with the
given buffer. We could expect that only the yielded items from the
`drain` will be removed, but actually no. Reading [the
documentation](https://doc.rust-lang.org/std/collections/struct.VecDeque.html#method.drain):

> Note 1: The element `range` is removed even if the iterator is not
> consumed until the end.

So by using a range like `..` will drain the entire captured stream,
whatever we read from it. Said differently, if the given buffer length
is smaller than the captured stream, the first read will drain the
entire captured stream.

This patch fixes the problem by specifying a better range:
`..min(inner_buffer.len(), oc.buffer.len())`.

With this new range, it's actually useless to increment
`num_bytes_written`, we already know ahead of time the amount of bytes
we are going to read. Consequently, the patch simplifies this code a
little bit more.
2021-01-28 10:28:49 +01:00
Ivan Enderlin
ca7fc908b5 chore(c-api) Update headers. 2021-01-28 09:23:56 +01:00
Ivan Enderlin
1828d8ecff Merge branch 'master' into fix-c-api-wasi-version 2021-01-28 09:18:30 +01:00
Ivan Enderlin
af5052598a chore(c-api) Update headers. 2021-01-28 09:15:25 +01:00
Ivan Enderlin
7a435ef740 feat(c-api) wasi_version_t has a C representation now.
On Windows, using a `u32` representation for `wasi_version_t` fails if
a C++ compiler is used to treat a C program. So we change our strategy
here. We use a C representation to be FFI-safe, and the
`INVALID_VERSION` variant is now set to -1 instead of `u32::MAX`.

This patch also adds unit tests for `wasi_get_wasi_version` so that we
are sure of the behavior of this `type` on all platforms.
2021-01-28 09:12:10 +01:00
Ivan Enderlin
c03d61b78a test(c-api) Simplify wat2wasm test cases. 2021-01-28 09:11:50 +01:00
Nick Lewycky
95887af4da Include 'extern "C"' in our C header files when included in a C++ build. 2021-01-27 11:41:31 -08:00
bors[bot]
2d57f31037 Merge #2054
2054: Add `wasm_config_delete` to the Wasm C API r=MarkMcCaskey a=MarkMcCaskey

Fixes 1 missing import reported in #2052 

This function is relatively new to the Wasm C API and its implementation is trivial

Co-authored-by: Mark McCaskey <mark@wasmer.io>
2021-01-26 16:38:47 +00:00
Ivan Enderlin
4688d9b369 chore(c-api) Disable wasi_config_capture_stdin for the moment`. 2021-01-26 16:21:55 +01:00