Commit Graph

92 Commits

Author SHA1 Message Date
Ivan Enderlin
5db05fd609
Merge branch 'master' into feat-runtime-c-api-instance-context-data 2019-03-12 09:02:05 +01:00
Ivan Enderlin
a390a28384 fix(runtime-c-api) Fix Clippy errors. 2019-03-12 08:58:22 +01:00
Ivan Enderlin
675f6817ba test(runtime-c-api) Free allocations.
Don't forget to free `context_data` :-).
2019-03-11 17:41:17 +01:00
Ivan Enderlin
170de02dd3 test(runtime-c-api) Test the wasmer_instance_context_data_* functions. 2019-03-11 17:34:13 +01:00
Ivan Enderlin
a11d454130 feat(runtime-c-api) Add an API to update vm::Ctx.data.
This patch adds 2 functions for the runtime C API, respectively
`wasmer_instance_context_data_set` and
`wasmer_instance_context_data_get`. The goal is to modify the
`vm::Ctx.data` field in the `runtime-core` library.

This is required to pass dynamic data to imported functions for
instance.
2019-03-11 16:50:18 +01:00
Ivan Enderlin
3fea07dc8a fix(runtime-c-api) Fix the imports length.
`imports` contains `func_import`, `global_import`, `memory_import` and
`table_import`, so 4 items. This patch updates the length of `imports`
when calling the `wasmer_instantiate` function.
2019-03-11 14:35:51 +01:00
Ivan Enderlin
a4454ebae8
doc(readme) Fix a typo.
This patch fixes a typo in the C example.
2019-03-08 13:26:04 +01:00
Brandon Fish
dd3a6ad21b Merge branch 'master' into feat-runtime-c-api-strict-c-cpp 2019-03-07 23:06:01 -06:00
Brandon Fish
628caf0a74 Make import_func_new/destroy not const 2019-03-07 22:59:11 -06:00
Syrus Akbary
6570bd433d
Fixed import func to be mutable 2019-03-07 10:19:03 -08:00
Ivan Enderlin
7a9816ff12 feat(runtime-c-api) Ask rustc to generate a static library.
This is required to correctly link to the embedded runtime.
2019-03-07 10:19:02 +01:00
Ivan Enderlin
1dfae80c65 test(runtime-c-api) Fix compilation errors in test-exports.c. 2019-03-07 10:15:32 +01:00
Ivan Enderlin
725aff6fee test(runtime-c-api) Fix a compilation error in test-instantiate.c. 2019-03-07 10:15:32 +01:00
Ivan Enderlin
603f1fc57d test(runtime-c-api) Fix compilation errors in test-import-function.c. 2019-03-07 10:15:32 +01:00
Ivan Enderlin
2a0e42c1e5 test(runtime-c-api) Fix compilation errors in test-memory.c. 2019-03-07 10:15:32 +01:00
Ivan Enderlin
dcb4032e9d test(runtime-c-api) Fix compilation errors in test-imports.c. 2019-03-07 10:15:32 +01:00
Ivan Enderlin
c658224f0c test(runtime-c-api) Transforms all C/C++ warnings into errors.
This patch ensures that all our examples and tests do not generate
warnings. In C, it can be catastrophic sometimes…

Also, be sure that the `cmake` command doesn't emit any warnings too.
2019-03-07 10:15:32 +01:00
Syrus Akbary
af9c26f4f9
Fixed links of wasmer runtime C api in crates.io and docs.rs 2019-03-06 18:22:16 -08:00
Ivan Enderlin
bedb05738b
Merge branch 'master' into doc-runtime-c-api 2019-03-06 18:50:49 +01:00
Ivan Enderlin
f5ce1e8b60 doc(runtime-c-api) Improve the README.md.
This patch updates the `README.md` by adding badges, a Usage Section,
and a License Section. The Testing Section is slightly revamped.
2019-03-06 14:11:12 +01:00
Ivan Enderlin
d709191be1 doc(runtime-c-api) Declare the example as C, so that they are not tested.
Those examples contain C code. They must not be run by `rustdoc` as
tests.
2019-03-06 12:08:02 +01:00
Ivan Enderlin
76caebebb4 fix(runtime-c-api) Provide a link target.
When compiling `wasmer-runtime-c-api` as a dependency of another
crate, `rustc` emits this warning:

```
warning: The package `wasmer_runtime_c_api` provides no linkable
target. The compiler might raise an error while compiling
`foo`. Consider adding 'dylib' or 'rlib' to key `crate-type` in
`wasmer_runtime_c_api`'s Cargo.toml. This warning might turn into a
hard error in the future.
```

To solve this issue, the `rlib` type has been added to the
`crate-type` list.
2019-03-06 11:02:14 +01:00
Ivan Enderlin
0f74133be3 feat(runtime-c-api) Build: Copy the C header files from OUT_DIR to CARGO_MANIFEST_DIR.
This patch copies the generated C and C++ header files from the
`OUT_DIR` to the root of the crate.
2019-03-06 10:58:40 +01:00
Ivan Enderlin
f2997357fc feat(runtime-c-api) Remove the flag WASM_EMSCRIPTEN_GENERATE_C_API_HEADERS.
This patch removes the `WASM_EMSCRIPTEN_GENERATE_C_API_HEADERS`
flag. Consequently, the C header files will be generated for each
build.

The `generate-c-api-headers` feature is also removed, since it becomes useless.
2019-03-06 10:42:32 +01:00
Ivan Enderlin
7c56d893c2 feat(runtime-c-api) Generate the C header file in OUT_DIR.
This patch changes the directory where the C header files are
generated, from `CARGO_MANIFEST_DIR` to `OUT_DIR`. The goal is: When
`wasm-runtime-c-api` is used as a dependency of another Rust project,
then the C header files are accessible in the `target/` directory
(i.e. the `OUT_DIR`).

Also, since `rustc` has a `--out-dir` directory, it increases the
flexibility of this approach: The user can generate the C header files
where she wants.
2019-03-06 10:42:06 +01:00
Syrus Akbary
28bb264266
Merge pull request #232 from Hywan/fix-runtime-c-api-remove-warnings
fix(runtime-c-api) Fix several warnings
2019-03-05 16:38:14 -08:00
Ivan Enderlin
8ed340b6f1 fix(runtime-c-api) Update cbindgen.
When requiring `wasmer-runtime-c-api`, I get the following conflicts:

```
error: failed to select a version for `serde_derive`.
    ... required by package `cbindgen v0.7.1`
    ... which is depended on by `wasmer-runtime-c-api v0.2.1`
    ... which is depended on by `foo v0.1.0 (/private/tmp/foo)`
versions that meet the requirements `= 1.0.58` are: 1.0.58

all possible versions conflict with previously selected packages.

  previously selected package `serde_derive v1.0.89`
    ... which is depended on by `wasmer-runtime-core v0.2.1`
    ... which is depended on by `wasmer-runtime-c-api v0.2.1`
    ... which is depended on by `foo v0.1.0 (/private/tmp/foo)`

failed to select a version for `serde_derive` which could resolve this conflict
```

This issue resolves by updating `cbindgen` to 0.8.
2019-03-05 14:28:35 +01:00
Ivan Enderlin
25feef7384 chore(runtime-c-api) Regenerate the header files. 2019-03-05 10:07:08 +01:00
Ivan Enderlin
86c41264a3 chore(runtime-c-api) Fix CS. 2019-03-05 10:07:08 +01:00
Ivan Enderlin
59de57e075 fix(runtime-c-api) Fix Clippy notes.
This patch fixes warnings raised by Clippy.
2019-03-05 10:07:08 +01:00
Ivan Enderlin
053e5c40f4 fix(runtime-c-api) Avoid mutable bindings as much as possible.
This patch cleans several warnings where mutable bindings are declared
but used only as immutable bindings.

It's a little bit opinionated patch. I think it's interesting to use
`const` pointers as much as possible.
2019-03-05 10:07:08 +01:00
Ivan Enderlin
5ace3cfa2b fix(runtime-c-api) Remove unsafe blocks inside unsafe function.
This patch removes `unsafe { … }` blocks inside `unsafe` functions.

This patch also removes some warnings about camel case. All structures
with a C representation are automatically not mangle, and allow non
camel case.
2019-03-05 10:07:08 +01:00
Brandon Fish
2077fb448a Fix C API table/global/memory imports 2019-03-02 22:28:00 -06:00
Brandon Fish
adfdf4d85d Merge branch 'master' into feature/add-c-api-module-import-descriptors 2019-03-01 12:50:35 -06:00
Brandon Fish
0792cc7018 Merge branch 'master' into feature/c-api-call-an-exported-func 2019-03-01 12:14:56 -06:00
Brandon Fish
358d653b18
Merge branch 'master' into feature/add-c-api-module-export-descriptors 2019-02-27 23:21:23 -06:00
Brandon Fish
889fc3f432
Merge branch 'master' into feature/add-c-api-module-import-descriptors 2019-02-27 23:21:01 -06:00
Brandon Fish
02eac589f4 Merge branch 'master' into feature/c-api-call-an-exported-func 2019-02-27 23:19:50 -06:00
Syrus
60f8f15db3 Updated version to 0.2.1 2019-02-27 17:20:49 -08:00
Mackenzie Clark
2a7a8c0069
newline in test-module-imports.c 2019-02-27 10:41:22 -08:00
Mackenzie Clark
c4566f0b39
Merge branch 'master' into feature/add-c-api-module-export-descriptors 2019-02-27 10:28:18 -08:00
Syrus
53c8603464 Updated crates version to 0.2.0 2019-02-25 13:33:33 -08:00
Brandon Fish
b008a054de Fix C API to allow calling an exported func 2019-02-24 12:22:24 -06:00
Brandon Fish
1dfa106850 Add C API module import descriptors 2019-02-23 18:25:51 -06:00
Brandon Fish
17fe7bdaea Add C API module export descriptors 2019-02-23 15:41:38 -06:00
Mackenzie Clark
82eef13f41
Create a grow error and refactor grow impl to return result (#191) 2019-02-22 22:18:59 -08:00
Brandon Fish
c9969f269c Use minimum limit as initial table size (#196) 2019-02-22 11:16:15 -08:00
Brandon Fish
ac57a1bc71 Add C API module_instantiate function 2019-02-20 23:08:23 -06:00
Brandon Fish
b073145dbb Clone import in instantiate to prevent import move 2019-02-20 09:52:42 -06:00
Brandon Fish
d2f3023191 Allow specifying optional max value in limits 2019-02-19 00:05:08 -06:00