1233: Improved Wasmer C API release artifacts r=syrusakbary a=syrusakbary
<!--
Prior to submitting a PR, review the CONTRIBUTING.md document for recommendations on how to test:
https://github.com/wasmerio/wasmer/blob/master/CONTRIBUTING.md#pull-requests
-->
# Description
This PR updates the artifacts generated for Wasmer C API, in a way that is much more consumable, including a quick README and License.
So, after running `make capi && make build-capi` We will have a `wasmer-c-api.tar.gz` file with the following structure
```
/
lib/
libwasmer.a
libwasmer.so
include/
wasmer.h
wasmer.hh
README.md
LICENSE
```
See example generated artifact here:
[wasmer-c-api.tar.gz](https://github.com/wasmerio/wasmer/files/4228560/wasmer-c-api.tar.gz)
<!--
Provide details regarding the change including motivation,
links to related issues, and the context of the PR.
-->
# Review
- [x] Add a short description of the the change to the CHANGELOG.md file
Co-authored-by: Syrus <me@syrusakbary.com>
Co-authored-by: Syrus Akbary <me@syrusakbary.com>
1223: feat(runtime-core) Implement `TryFrom<native_type>` for `Value` r=Hywan a=Hywan
Extracted from #1018.
This PR implements `TryFrom` for `Value`. It is required to support dynamically-typed values for polymorphic host functions.
This PR also refactors the code by using a macro (`value_conversions!`) to implement `From` and `TryFrom` in one shot.
Co-authored-by: Ivan Enderlin <ivan.enderlin@hoa-project.net>
Co-authored-by: Ivan Enderlin <ivan.enderlin@wanadoo.fr>
1216: feat(interface-types) Add the binary encoder r=Hywan a=Hywan
This PR adds the `encoders::binary` module, which exposes the `ToBytes` trait. It is used to encode the AST into the WIT binary representation.
Check the tests to get examples, but quickly, the roundtrip works:
```rust
fn test_binary_encoding_decoding_roundtrip() {
// Let `original_ast` be an AST representing a set of WIT interfaces
let original_ast = Interfaces {
exports: vec![Export {
name: "ab",
input_types: vec![InterfaceType::I32],
output_types: vec![InterfaceType::I32],
}],
types: vec![Type::new(
"ab",
vec!["cd", "e"],
vec![InterfaceType::I32, InterfaceType::I32],
)],
imports: vec![Import {
namespace: "a",
name: "b",
input_types: vec![InterfaceType::I32],
output_types: vec![InterfaceType::I64],
}],
adapters: vec![Adapter::Import {
namespace: "a",
name: "b",
input_types: vec![InterfaceType::I32],
output_types: vec![InterfaceType::I32],
instructions: vec![Instruction::ArgumentGet { index: 1 }],
}],
forwards: vec![Forward { name: "a" }],
};
// Let's encode the AST into the WIT binary representation.
let mut binary = vec![];
original_ast
.to_bytes(&mut binary)
.expect("Failed to encode the AST.");
// And let's go back to the AST land.
let (remainder, ast) = parse::<()>(binary.as_slice()).expect("Failed to decode the AST.");
assert!(remainder.is_empty());
// They must equal.
assert_eq!(original_ast, ast);
}
```
The implementation with the `ToBytes` trait and the `io::Write` trait is —I hope— Rust idiomatic. I reckon the code is easy to read and understand.
Co-authored-by: Ivan Enderlin <ivan.enderlin@hoa-project.net>
Co-authored-by: Ivan Enderlin <ivan.enderlin@wanadoo.fr>
1229: Add clippy::missing_safety_doc lint to wasi, misc clean up r=MarkMcCaskey a=MarkMcCaskey
Part of #1219
# Review
- [ ] Add a short description of the the change to the CHANGELOG.md file
Co-authored-by: Mark McCaskey <mark@wasmer.io>
1222: feat(runtime-core) Simplify `WasmExternType` implementations with macros r=Hywan a=Hywan
Extracted from #1018.
This PR simplifies the code (understand, remove code duplication) of `WasmExternType` by using a macro.
Co-authored-by: Ivan Enderlin <ivan.enderlin@hoa-project.net>
Co-authored-by: Ivan Enderlin <ivan.enderlin@wanadoo.fr>
1224: fix(runtime-core) Remove warnings r=Hywan a=Hywan
Because we can use the `impl_traits!` macro with only one identifier,
a warning is emitted saying the parenthesis are useless for this
specific usecase. They are required for all the other usecases
though. We can safely ignore this warning.
Co-authored-by: Ivan Enderlin <ivan.enderlin@hoa-project.net>
Co-authored-by: Ivan Enderlin <ivan.enderlin@wanadoo.fr>
1221: doc(interface-types) Add a `README.md` file r=MarkMcCaskey a=Hywan
Just a small `README.md`, so that users aren't totally loss.
Co-authored-by: Ivan Enderlin <ivan.enderlin@hoa-project.net>
Those are not necessary for the user. It's only internal
implementation, that must be public because it ends up in public
types, but the compiler infers everything automatically.
Because we can use the `impl_traits!` macro with only one identifier,
a warning is emitted saying the parenthesis are useless for this
specific usecase. They are required for all the other usecases
though. We can safely ignore this warning.
1218: Enable clif verifier in debug mode, fix issue with verifier r=MarkMcCaskey a=MarkMcCaskey
Ensures we're using I32s to index into things that are indexed by I32s
# Review
- [x] Add a short description of the the change to the CHANGELOG.md file
Co-authored-by: Mark McCaskey <mark@wasmer.io>