Commit Graph

207 Commits

Author SHA1 Message Date
f866ea39fd fixup 2020-10-12 18:02:45 +02:00
fe70330772 fixup 2020-10-12 18:02:32 +02:00
b9f98ce1f6 feat(c-api) Update .h files. 2020-10-12 17:54:21 +02:00
750a1c3645 feat(c-api) Implement wasm_module_name and wasm_module_set_name.
I submited a proposal to the official `wasm.h` by the way,
https://github.com/WebAssembly/wasm-c-api/pull/157. For the moment,
let's keep that as a vendor specific implementation.
2020-10-12 17:52:40 +02:00
bb9149bfe3 Merge #1685
1685: feat(c-api) Implement `wasm_exporttype_delete` r=Hywan a=Hywan

This PR implements the destructor for `wasm_exporttype_t`.

Co-authored-by: Ivan Enderlin <ivan@mnt.io>
2020-10-12 11:16:06 +00:00
1ecb4ca250 feat(c-api) Implement wasm_externtype_copy. 2020-10-12 09:54:05 +02:00
709f1c9f87 Merge branch 'master' into feat-c-api-exporttype-delete 2020-10-09 09:27:12 +02:00
61c88be863 Prepare for 1.0.0-alpha4 release 2020-10-08 16:47:14 -07:00
d687dd5bd6 Add system-libffi feature to wasmer C API crate 2020-10-08 14:59:42 -07:00
02c0df5101 Update to cbindgen 0.15.0
Manually specify that items should be sorted by name in the header
file. We do this because cbindgen 0.15.0 removed sorting by default.
2020-10-08 14:42:00 -07:00
80459f3ae0 feat(c-api) Replace the max limit sentinel value by a constant.
In the `wasm.h` header file, it is defined by `wasm_limits_max_default`.
2020-10-08 17:24:12 +02:00
f6595cdd33 fix(c-api) Fix the sentinel value returned by wasm_memorytype_limits. 2020-10-08 17:23:59 +02:00
5d19813e63 fix(c-api) wasm_limits_t contains Pages, not Bytes.
When building a `wasm_memorytype_t` with `wasm_memorytype_new`, we
pass a `wasm_limits_t`, where `min` and `max` represent `Pages`. This
semantics is set by `wasm_memorytype_new` itself where `min` and `max`
from `wasm_limits_t` are used to compute `Pages`, which are then passed
to `MemoryType`.

Then, in `wasm_memorytype_limits`, we expect to get the same
`wasm_limits_t` given to `wasm_memorytype_new`. But it's not!

The same `MemoryType` is read, good. The `minimum` and `maximum`
fields are `Pages`, good. Then, we compute the `min` and `max` values
for the resulting `wasm_limits_t`, which receive `Page.bytes().0`, not
good! We don't want the number of bytes, but the number of pages.

This patch fixes that.
2020-10-08 17:14:45 +02:00
3ebff74263 doc(c-api) Update inline API documentation. 2020-10-08 13:43:59 +02:00
f24a34b6cf feat(c-api) Implement Drop for wasm_exporttype_t.
`wasm_exporttype_t` has 2 fields: `name` and `extern_type`. Both are
of kind `NonNull`. When `wasm_exporttype_t` is dropped, nor `name` nor
`extern_type` are going to be dropped.

To avoid leaking data, this patch adds a new field: `owns_fields`:

* When `wasm_exporttype_t` is built from `wasm_exportype_new`, this
  field is set to `false` because `name` and `extern_type` are
  received by pointer, and its the responsibility of the caller to
  free them,

* When `wasm_exporttype_t` is built from the `From<&ExportType>`
  implementation, _we_ create `name` and `extern_type` to then leak
  them. In this case, it is safe to reconstruct proper `Box`es to
  finally drop them.
2020-10-08 13:38:01 +02:00
f7d5a11b39 Fix sentinel value in wasm_limits_t for memory in wasm_c_api 2020-10-07 16:38:23 -07:00
ea8bb1ee79 Merge branch 'master' into feature/engine-object-file 2020-10-06 17:50:55 -07:00
e6bc138b10 Remove ability to use object file engine with compiler from C API
Due to the way object file engine works, it only makes sense to use in
headless mode from the C API.
2020-10-06 17:39:51 -07:00
fdb077236a feat(c-api) Implement wasm_exporttype_delete. 2020-10-06 22:22:00 +02:00
aa2e8f7b4d Address more feedback, clean up code 2020-10-06 12:13:59 -07:00
c3efc06e87 test(c-api) Add test case for wat2wasm. 2020-10-06 20:56:36 +02:00
264ed836ac feat(c-api) Use c_try! and From implementations to simplify wat2wasm. 2020-10-06 20:56:21 +02:00
78887c378e chore(c-api) Simplify code. 2020-10-06 11:14:46 +02:00
ded3132b44 feat(c-api) Implement wat2wasm. 2020-10-06 11:09:35 +02:00
ab153fc642 Improve error messages around memory creation 2020-10-05 15:45:52 -07:00
0f8d68652f Finish merge with C API refactor 2020-10-05 12:30:58 -07:00
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
ff4cb6d412 feat(c-api) Implement wasm_module_validate. 2020-10-05 14:49:23 +02:00
f0487763bf Readd functionality from object file engine 2020-10-02 17:31:18 -07:00
1572ae1d5c Merge branch 'master' into feature/engine-object-file 2020-10-02 17:31:06 -07:00
1de0606b4e Merge #1673
1673: Add conversion logic for boxed_vec, simplify vec creation code r=MarkMcCaskey a=MarkMcCaskey

Fixes the issue mentioned in https://github.com/wasmerio/wasmer/issues/1631#issuecomment-702350852 



Co-authored-by: Mark McCaskey <mark@wasmer.io>
2020-10-03 00:01:51 +00:00
e6c61c74ff Update boxed_vec to deal with boxed values 2020-10-02 16:33:03 -07:00
34e6139570 Add conversion logic for boxed_vec, simplify vec creation code 2020-10-02 16:24:46 -07:00
3845e5fd67 Clean up binary files from C API refactor 2020-10-02 15:30:13 -07:00
92ca7899f5 chore(c-api) Use canonical path to wasm*.h headers. 2020-10-02 11:15:37 +02:00
e7d6af01e6 feat(c-api) Remove the deprecated feature.
This feature is no longer necessary. The `build.rs` no longer uses
it. The overhead of including the deprecated symbol inside the dylib
is acceptable. It simplifies the overall build system.
2020-10-02 11:09:20 +02:00
7f4862117f doc(c-api) Write a quick introduction to the crate. 2020-10-02 10:40:26 +02:00
2fdd9ea692 feat(c-api) Simplify the build.rs script. 2020-10-02 10:10:24 +02:00
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
1a45756cad test(c-api) Use the REQUIRED option of find_library. 2020-10-02 09:45:34 +02:00
d5fa525612 test(c-api) Enable the test-early-exit test case. 2020-10-01 23:23:41 +02:00
ddbbd96f1c test(c-api) Run make clean before, in case of. 2020-10-01 23:23:23 +02:00
0095ec9538 fix(c-api) wasm_val_t is not an opaque type, let's use a C representation. 2020-10-01 23:07:43 +02:00
68d6292c35 test(c-api) Restore the test-wasi and disable the test-early-exit. 2020-10-01 21:40:02 +02:00
5d9fc86bb8 test(c-api) Enable the wasi-c-api-trap test case. 2020-10-01 21:27:18 +02:00
a117df1740 chore(c-api) Remove a warning about wasm_frame_t case. 2020-10-01 21:26:45 +02:00
3a81643ff0 chore(c-api) Update header files. 2020-10-01 21:23:06 +02:00
a2854ebfea fix(c-api) Adjust cbindgen metadata for header files. 2020-10-01 21:20:13 +02:00
ecb79e2af0 fix(c-api) Cherry-pick manually from https://github.com/wasmerio/wasmer/pull/1657. 2020-10-01 21:16:29 +02:00
762a6acc85 Add rlib as a crate-type for wasmer-c-api
This is how `wasmer-runtime-c-api` was before and seems to fix a use
case that users relied on
2020-10-01 20:59:40 +02:00