Commit Graph

15 Commits

Author SHA1 Message Date
Peter Huene
a6ec8f85a6 Loop the array of strings only once.
Remove unnecessary loop when marshaling lists of strings as pointers to UTF-8
bytes.
2020-02-24 18:26:26 -08:00
Peter Huene
78ee043524 Ensure marshaled UTF-8 string arrays are null terminated. 2020-02-24 18:20:27 -08:00
Peter Huene
8dff0fc121 Fix unit tests on Windows.
Close the file descriptors before attempting to reopen the files.
2020-02-24 17:56:55 -08:00
Peter Huene
11dec4d788 Add WASI unit tests for the C# API. 2020-02-24 17:42:49 -08:00
Peter Huene
ae0b4090ce Implement WASI C API.
This commit implements an initial WASI C API that can be used to instantiate
and configure a WASI instance from C.

This also implements a `WasiBuilder` for the C# API enabling .NET hosts to bind
to Wasmtime's WASI implementation.
2020-02-24 17:42:44 -08:00
Alex Crichton
364fa994ed Move the C API to a separate crate (#818)
* Move the C API to a separate crate

This commit moves the C API from `crates/api/src/wasm.rs` to
`crates/capi/src/lib.rs` to be located in a separate crate. There's a
number of reasons for this:

* When a Rust program depends on the `wasmtime` crate, there's no need
  to compile in the C API.
* This should improve compile times of the `wasmtime` crate since it's
  not producing artifacts which aren't always used.
* The development of the C API can be guaranteed to only use the public
  API of the `wasmtime` crate itself.

Some CI pieces are tweaked and this overall shouldn't have much impact
on users, it's intended that it's a cleanup/speedup for developers!

* Disable rustdoc/tests for capi

* Review feedback

* Add back in accidentally deleted comment

* More renamings

* Try to fix dotnet build
2020-01-14 11:36:57 -08:00
Austin Wise
50d0aa939c Add tests calling function imports. 2019-12-13 18:50:57 -08:00
Austin Wise
df0f0e3c44 Remove trailing null bytes from trap messages.
It appears there are two trailing null bytes at the end of the string.
This does not seem right. But it might be a good idea generally to remove
any null bytes that get into error messages.
2019-12-13 18:48:32 -08:00
Austin Wise
e11056345a Add a Visual Studio solution. 2019-12-13 17:25:12 -08:00
Austin Wise
96d6a16ce9 Remove unneed dynamic binding in MemoryBinding.
The Validate function already checks that the field type is Memory.
2019-12-13 17:25:08 -08:00
Austin Wise
7f05a2e6a5 Use DoNotWrapExceptions to avoid exception wrapping. 2019-12-13 17:22:26 -08:00
Austin Wise
1d01779b2e Root bindings so the delegate in FunctionBinding is not GCed. 2019-12-05 18:58:09 -08:00
Peter Huene
cc02214084 Fix .NET interop issue for Windows release builds.
For Windows release builds, the `wasm_valtype_kind` C API return value
is being returned as a single byte.

The .NET interop signature for this function was expecting an
integer-sized return, resulting in three extra bytes being used on
Windows.

The fix is to limit the corresponding C# enum to a byte representation,
which will properly mask the return value from `wasm_valtype_kind`.

CI has also been updated to test both debug and release configurations
(previously it was only testing debug, hence why this was missed).

Also fixed a cast bug in the `declare_vec!` macro in the C API when the
element types were pointers to values.  The `as_slice` implementation
was incorrectly casting away a level of pointer indirection, resulting
in corrupted data when accessing the slice's elements.
2019-12-05 12:44:47 -08:00
Peter Huene
a3bc464e47 Add LLVM exception for Wasmtime for .NET license. 2019-11-26 11:34:44 -08:00
Peter Huene
9fdf5bce8e Move Wasmtime for .NET to the Wasmtime repo.
This moves the Wasmtime for .NET implementation to the Wasmtime repo.

Wasmtime for .NET is a binding of the Wasmtime API for use in .NET.
2019-11-22 18:26:33 -08:00