Ivan Enderlin
8c8586faaa
test(runtime-c-api) Assert returned value from wasmer_last_error_message
.
2019-05-13 10:52:55 +02:00
Ivan Enderlin
bedd305b06
doc(runtime-c-api) Fix inline comment.
2019-05-13 10:52:43 +02:00
Brandon Fish
2aefa731a6
Add deny for unreachable patterns and unused unsafe
2019-05-12 00:33:02 -05:00
Brandon Fish
85158ac22a
Add some initial deny for unused_imports and unused_variables
...
Additional unused variable fix on unix
Remove unused import on unix
Remove unused windows import
2019-05-11 09:23:25 -05:00
Ivan Enderlin
7d2721ef7a
fix(runtime-c-api) wasmer_last_error_message
returns the length + 1.
...
Returning the error message's length + 1 mimics the
`wasmer_last_error_length` function that counts the trailing null
byte.
2019-05-10 16:00:13 +02:00
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
1c063090c5
doc(runtime-c-api) Add short module descriptions.
2019-03-29 16:35:35 +01: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
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
Brandon Fish
380d766943
Convert from Box into/from raw to pointer ref-deref to fix free issue
2019-02-18 23:30:08 -06:00
Brandon Fish
123d55cb4a
Remove commented out code, cleanup build warnings
2019-02-17 17:10:15 -06:00
Brandon Fish
ee81560e06
Cleanup tests
2019-02-17 16:51:59 -06:00
Brandon Fish
a77d1be983
Remove unused API functions
2019-02-17 14:48:30 -06:00
Brandon Fish
36767e0bd6
Move ctx pointer to first parameter to fix test
2019-02-17 14:39:26 -06:00
Brandon Fish
7bb947aba7
Add func signature lookup functions
2019-02-17 14:12:05 -06:00
Brandon Fish
56079ad589
Add compile Module function
2019-02-15 19:47:00 -06:00
Brandon Fish
3ebb80e50e
Update imports and add func_new
2019-02-15 09:40:28 -06:00
Brandon Fish
bfd5e21605
Add export_name and export_func
2019-02-14 00:00:39 -06:00
Brandon Fish
93979aeae2
Add get exports from instance
2019-02-13 20:02:11 -06:00
Brandon Fish
27cbfc0b0b
Add documentation to API functions
2019-02-11 23:14:32 -06:00
Brandon Fish
34c45aee3d
Update last error for every error result
2019-02-11 20:08:54 -06:00
Brandon Fish
019ef9ea01
Consolidate result type to one enum
2019-02-11 19:07:28 -06:00
Brandon Fish
b70e319f5c
Add initial error messaging
2019-02-10 17:57:23 -06:00
Brandon Fish
66bf13c9dd
Add memory data function
2019-02-10 15:20:35 -06:00
Brandon Fish
a502da58e3
Fix import object destroy
2019-02-10 14:27:08 -06:00
Brandon Fish
7ef472dae2
Add instance context memory
2019-02-10 14:24:36 -06:00
Brandon Fish
0cfe864fe6
Add Memory data length
2019-02-10 14:14:42 -06:00
Brandon Fish
2fa9cec0ed
Add include guard
2019-02-09 18:07:05 -06:00
Brandon Fish
a0288c87ac
Add Memory Grow C API
2019-02-09 17:53:03 -06:00
Brandon Fish
94c5acedbf
Add basic Global API
2019-02-09 17:39:15 -06:00
Brandon Fish
8364c39b4c
Add Table grow function
2019-02-09 13:58:50 -06:00
Brandon Fish
4e5e525626
Add basic Table functions
2019-02-09 13:37:07 -06:00
Brandon Fish
c3707efa08
Update for merge from master
2019-02-09 13:09:54 -06:00
Brandon Fish
309246e0d6
Add validate function and test
2019-02-05 00:01:01 -06:00
Brandon Fish
8d8dea7ec8
Implement basic C API memory functions
2019-02-04 21:46:47 -06:00
Brandon Fish
2defd27fac
Also generate C++ bindings
2019-02-04 19:54:12 -06:00
Brandon Fish
6ed72a50ce
Add instance_destroy back to test
2019-02-04 19:49:28 -06:00
Brandon Fish
fa959fa6ee
Call cargo build during make test to build C API lib
2019-02-03 13:21:59 -06:00
Brandon Fish
358c306cea
Add runtime-c-api as external project to build dependency
2019-02-03 12:33:42 -06:00
Brandon Fish
6185eb73a8
Configure cmake to find dylib/so/dll wasmer library
2019-02-03 12:14:14 -06:00
Brandon Fish
6f7db9062d
Run cmake tests as part of a rust test
2019-02-02 20:16:53 -06:00
Brandon Fish
5d9e05c2f6
Add function signature parameters to set import func
2019-02-02 19:10:08 -06:00
Brandon Fish
d31c1c6068
Fix lints
2019-02-02 18:07:37 -06:00
Brandon Fish
ffb3dc083a
Add test to import function and call it
2019-02-02 17:43:59 -06:00
Brandon Fish
9120a9d1f8
Implement tagged enum for params/results
2019-02-02 14:53:07 -06:00
Brandon Fish
3633ab8ef4
Add parameters and results
2019-02-02 10:44:08 -06:00
Brandon Fish
3c7ad109bc
Fix instance null ptr bug
2019-02-02 08:43:29 -06:00
Brandon Fish
be19e96669
Implementing instantiate and call
2019-02-02 00:26:10 -06:00
Brandon Fish
62f7bb607e
Add first c test to test the C api
2019-02-01 22:10:36 -06:00
Brandon Fish
6f05146737
Use build script to run cbinden behind feature flag
2019-02-01 18:52:22 -06:00
Brandon Fish
5ebea9672c
Initial commit of C API library
2019-01-31 23:51:34 -06:00