Commit Graph

127 Commits

Author SHA1 Message Date
Ivan Enderlin
1d555301f7 feat(runtime-c-api) Check buffer size before creating the slice.
It's safer to check the buffer size is large enough to hold the error
message before creating the slice from raw parts.

Also, this patch remove the need for `last_error`, simplifying the
code a little bit. The `length` variable is casted to `usize` once.
2019-05-10 15:55:02 +02:00
Mark McCaskey
e5dc94c7d6 update version number to 0.4.1 2019-05-06 18:02:39 -07:00
Mark McCaskey
d020ffd759 update version to 0.4.0 2019-04-29 13:26:51 -07:00
Mark McCaskey
d507253372 update crate version numbers to 0.3.0 2019-04-12 12:19:46 -07:00
Ivan Enderlin
8ee0f16c8a fix(runtime-c-api) Remove last warnings. 2019-03-29 15:56:08 +01:00
Ivan Enderlin
849af62911 feat(runtime-c-api) Finish to extract last pieces of code. 2019-03-29 15:52:41 +01:00
Ivan Enderlin
361ff81db7 feat(runtime-c-api) Extract the import module. 2019-03-29 15:50:16 +01:00
Ivan Enderlin
9c4696eb5b feat(runtime-c-api) Extract the export module. 2019-03-29 15:38:12 +01:00
Ivan Enderlin
f46be814da feat(runtime-c-api) Extract the instance module. 2019-03-29 15:14:05 +01:00
Ivan Enderlin
d06d6b7ac8 feat(runtime-c-api) Extract the global module. 2019-03-29 15:05:17 +01:00
Ivan Enderlin
8bdb458ea7 feat(runtime-c-api) Extract the table module. 2019-03-29 15:02:50 +01:00
Ivan Enderlin
4239975240 feat(runtime-c-api) Move wasmer_validate into the module module. 2019-03-29 14:59:02 +01:00
Ivan Enderlin
55c010688c feat(runtime-c-api) Extract the memory module. 2019-03-29 14:57:08 +01:00
Ivan Enderlin
168aa8031f feat(runtime-c-api) Extract the module module. 2019-03-29 14:51:35 +01:00
Ivan Enderlin
96324977b5 feat(runtime-c-api) Extract the error module. 2019-03-29 14:41:39 +01:00
Ivan Enderlin
49c01f6093 feat(runtime-c-api) Extract the value module. 2019-03-29 14:40:26 +01:00
Ivan Enderlin
a59ce13810 chore(runtime-c-api) Build the C and C++ headers. 2019-03-27 10:50:40 +01:00
Ivan Enderlin
4d0312f0ed test(runtime-c-api) New test suite for wasmer_export_to_memory. 2019-03-27 10:49:28 +01:00
Ivan Enderlin
6fca475564 feat(runtime-c-api) Implement the wasmer_export_to_memory function.
This new function returns a `wasmer_memory_t` from a
`wasmer_export_t`.
2019-03-27 10:44:47 +01:00
Ivan Enderlin
5661540097 chore(runtime-c-api) Move .wasm files into the assets directory. 2019-03-27 09:42:56 +01:00
Ivan Enderlin
c0f4b6a87c
Merge branch 'master' into feat-runtime-c-api-cache 2019-03-19 16:35:32 +01:00
Ivan Enderlin
57a82fa5cf fix(runtime-c-api) wasmer_serialized_module_from_bytes accepts bytes + length instead of wasmer_byte_array. 2019-03-19 16:24:59 +01:00
Ivan Enderlin
44373aae94 feat(runtime-c-api) Mirrors the debug and llvm features.
`wasmer-runtime` has a `debug` and a `llvm` features. Let's mirror
them in `wasmer-runtime-c-api` so that the user can, for instance,
compile with the LLVM backend.
2019-03-19 11:12:19 +01:00
Ivan Enderlin
46edd20725 feat(runtime-c-api) Add the wasmer_serialized_module_from_bytes function.
This function is required to transform a `wasmer_byte_array` into a
`wasmer_serialized_module_t`. This is the complementary function of
`wasmer_serialized_module_bytes`.
2019-03-19 10:51:43 +01:00
Ivan Enderlin
5e31a1b6d1 feat(runtime-c-api) Introduce the wasmer_serialized_module_t struct type.
The `wasmer_module_serialize` function now computes a
`wasmer_serialized_module_t` value. The `wasmer_module_deserialize`
function takes this value as an input. Same for
`wasmer_serialized_module_destroy`.

The new function `wasmer_serialized_module_bytes` allows to read the
bytes inside the `wasmer_serialized_mdule_t` structure.
2019-03-19 10:04:31 +01:00
Ivan Enderlin
f049e9b0b3 fix(runtime-c-api) Remove explicity drop.
When the value goes out-of-scope, `drop` is called utomatically.
2019-03-18 16:09:02 +01:00
Ivan Enderlin
6605a02316 feat(runtime-c-api) Add the wasmer_module_serialization_destroy function. 2019-03-18 16:05:04 +01:00
Ivan Enderlin
aac5c88b58 doc(runtime-c-api) Update the documentation of wasmer_module_deserialize. 2019-03-15 12:18:52 +01:00
Ivan Enderlin
082c93ceba chore(runtime-c-api) Fix a merging error. 2019-03-15 12:04:23 +01:00
Ivan Enderlin
2368ce3a20 chore(runtime-c-api) Regenerate the wasmer.hh? files. 2019-03-15 12:04:23 +01:00
Ivan Enderlin
c8872f1a6f test(runtime-c-api) Test the new wasmer_module_(de)?serialize functions.
This test suite compiles a module, then serializes it, deserializes
it, and continues by creating an instance and calling a function on
it. It allows to test the entire roundtrip.
2019-03-15 12:04:23 +01:00
Ivan Enderlin
f2760249b6 fix(runtime-c-api) Reorganize the tests by alphabetic order. 2019-03-15 12:04:23 +01:00
Ivan Enderlin
c142e16d12 feat(runtime-c-api) Implement the wasmer_module_(de)?serialize functions.
This patch implements 2 functions:

  1. `wasmer_module_serialize`, and
  2. `wasmer_module_deserialize`.
2019-03-15 12:04:23 +01:00
Ivan Enderlin
f57f8bc0cb fix(runtime-c-api) Use imported symbols.
`std::slice` is already imported. This patch then rewrites `::std::slice::` into `slice::`.
2019-03-15 12:04:23 +01:00
Ivan Enderlin
5b98ee732c feat(runtime-c-api) wasmer_validate expects a *const uint8_t.
This patch updates the first argument of `wasmer_validate` from `*mut
uint8_t` to `*const uint8_t`. Indeed, the
`wasmer-runtime-core::validate` function doesn't expect a mutable
slice, so it's not required to expect a mutable array from C.

Also, it's likely for the Wasm bytes to be stored in the
`wasmer_byte_array` structure. The first field `bytes` is defined as
`*const uint8_t`. So this patch avoids a cast when writing a C++
program.
2019-03-14 12:33:40 +01:00
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