Ivan Enderlin
90676b5c5b
feat(runtime-c-api) wasmer_instantiate
raises the source error.
...
Instead of returning only “error instanting”, `wasmer_instantiate` can
return the real error message.
2019-05-24 14:24:00 +02:00
Ivan Enderlin
c92230e18e
fix(runtime-c-api) Lengths cannot be negative.
...
This patch prevents receiving negative length in various places.
2019-05-22 16:44:03 +02:00
Brandon Fish
89f3998b49
Merge branch 'master' into feature/fix-default_compiler-compilation
2019-05-14 18:22:44 -05:00
Brandon Fish
bef9f1244a
Return impl Compiler from default_compiler to fix compilation with features
2019-05-14 18:19:58 -05:00
Ivan Enderlin
f04e77323b
fix(runtime-c-api) Update wasmer_export_func_params_arity
signature.
...
The `returns_len` argument type of `wasmer_export_func_returns_params`
must be `uint32_t` to match the `wasmer_export_func_returns_arity` results,
so that casts are not required.
2019-05-14 16:18:41 +02:00
Ivan Enderlin
91006bab53
fix(runtime-c-api) Update wasmer_export_func_params_arity
signature.
...
The `params_len` argument type of `wasmer_export_func_params_arity`
must be `uint32_t` to match the `wasmer_export_func_*_arity` results,
so that casts are not required.
2019-05-14 16:15:36 +02:00
Ivan Enderlin
d3c75a38fa
fix(runtime-c-api) wasmer_instance_call
types matches wasmer_export_func_*_arity
.
...
The `wasmer_export_func_params_arity` and
`wasmer_export_func_returns_arity` functions store the arity in a
`uint32_t`. The `wasmer_instance_call` expects `c_int`. There is a
type mismatch here. It's not annoying in C or C++, but in some other
languages that have bindings to C/C++, it can imply useless casting.
This patch changes `wasmer_instance_call` to expect `uint32_t` for
`params_len` and `results_len` to match the
`wasmer_export_func_*_arity` functions.
2019-05-14 11:46:43 +02:00
Syrus
19eba19603
Merge branch 'master' into doc-runtime-c-api
...
# Conflicts:
# lib/runtime-c-api/src/lib.rs
2019-05-13 15:55:20 -07:00
Ivan Enderlin
b050144898
Merge branch 'master' into fix-runtime-c-api-error-length
2019-05-13 10:59:11 +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
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
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
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
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
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
a390a28384
fix(runtime-c-api) Fix Clippy errors.
2019-03-12 08:58:22 +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
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
dcb4032e9d
test(runtime-c-api) Fix compilation errors in test-imports.c
.
2019-03-07 10:15:32 +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
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
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
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
a77d1be983
Remove unused API functions
2019-02-17 14:48:30 -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
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
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