Commit Graph

25 Commits

Author SHA1 Message Date
Ivan Enderlin
17dbb32e5a feat(c-api) Do not rename wat2wasm for the moment. 2021-02-12 00:26:53 +01:00
Ivan Enderlin
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
Ivan Enderlin
fb7ce4ad9a doc(c-api) Specify where examples are for wasm_instance_new. 2020-12-15 16:07:13 +01:00
Ivan Enderlin
7a30c31a6f test+doc(c-api) Add test for wasm_instance_exports. 2020-12-15 15:59:57 +01:00
Ivan Enderlin
6d74163462 doc(c-api) Specify that the code does not panic. 2020-12-10 16:18:32 +01:00
Ivan Enderlin
4740202e90 test(c-api) Fix tests. 2020-12-10 16:14:13 +01:00
Ivan Enderlin
f2a2cf4265 Merge branch 'master' into test-c-api 2020-12-01 11:37:41 +01:00
Ivan Enderlin
37240bdc10 test(c-api) Start testing the instance module. 2020-11-30 16:56:56 +01:00
Ivan Enderlin
eb01733839 doc(c-api) Document the instance module. 2020-11-30 16:56:45 +01:00
Mark McCaskey
a19705ae11 Remove free method, call finalizers in C API 2020-11-16 16:36:58 -08:00
Ivan Enderlin
69c23fd78f doc(c-api) Add the own annotation when necessary. 2020-11-16 10:49:37 +01:00
Ivan Enderlin
ce10285be2 fix(c-api) Remove done TODO. 2020-11-16 10:49:37 +01:00
Ivan Enderlin
152f1d980c feat(c-api) wasm_instance_new handles null pointers. 2020-11-16 10:49:37 +01:00
Ivan Enderlin
9583a91678 fix(c-api) wasm_trap_t** in wasm_instance_new does not represent an array.
The `wasm_trap_t**` argument of `wasm_instance_new` represents an
output pointer to a `wasm_trap_t*`, not an array of
`wasm_trap_t*`. This patch updates the code accordingly.
2020-10-30 09:37:05 +01:00
Ivan Enderlin
4102dcb9ac feat(c-api) Shrink vector of traps.
Ensure that the size of the vector of the instance's traps equals its
capacity by shrinking it.
2020-10-27 11:49:01 +01:00
Ivan Enderlin
452181326a fix(c-api) Remove a debug_assert macro. 2020-10-27 11:44:38 +01:00
Ivan Enderlin
a2d96d9ba7 feat(c-api) Implement the traps argument of wasm_instance_new.
When running `Instance::new`, it can error with an
`InstantiationError`. There is 2 scenarii:

1. Either it's a `InstantiationError::Link`. In this case, the
   `wasm_instance_new` function must return `NULL` and register the
   error in the Wasmer error registry.

2. Either it's a `InstantiationError::Start`. In this case, the
   `wasm_instance_new` function must return `NULL` and the error must be
   converted into a `wasm_trap_t`, which is stored in the `wasm_trap_t**`
   array. This array is initialized by `wasm_instance_new` itself.
2020-10-26 15:27:20 +01:00
Ivan Enderlin
fa7fe83bc0 feat(c-api) Update wasm_instance_new.
The `CArrayIter` type is no longer needed. This patch removes it.
2020-10-12 11:45:31 +02:00
Ivan Enderlin
3edcc89698 feat(c-api) Redefine wasm_store_t.
`wasm_store_t` is now a proper struct (rather than an opaque type) of
kind:

```rs
struct wasm_store_t {
    inner: Store
}
```

The rest of the patch updates the code accordingly.
2020-10-05 21:16:43 +02:00
Ivan Enderlin
ae1a50b5d7 chore(c-api) Move cbindgen:ignore from functions/types to modules.
This patch removes the amount of `cbindgen:ignore` instructions by
moving this instruction onto the parent module.
2020-10-02 09:51:48 +02:00
Ivan Enderlin
8f627d9834 feat(c-api) Instruct cbindgen to ignore all functions and types defined in wasm.h. 2020-09-28 14:49:44 +02:00
Ivan Enderlin
174b03f4e9 feat(c-api) Use our fork of cbindgen.
Our fork contains incoming PR. It helps for example to skip struct
fields.
2020-09-24 16:15:04 +02:00
Ivan Enderlin
1a0527af78 feat(c-api) Move all types into their own modules. 2020-09-24 11:41:04 +02:00
Ivan Enderlin
44559a9f04 feat(c-api) Move as_extern APIs into the externals module. 2020-09-24 09:48:56 +02:00
Ivan Enderlin
50fbb9766d feat(c-api) Move instance into its own module. 2020-09-24 09:19:53 +02:00