Add a wasmtime-specific wasmtime_wat2wasm C API (#1206)
* Add a wasmtime-specific `wasmtime_wat2wasm` C API This commit implements a wasmtime-specific C API for converting the text format to the binary format. An upstream spec issue exists for adding this to the C API, but in the meantime we can experiment with our own version of this API and use it in the C# extension, for example! Closes #1000 * Reorder arguments * Use wasm_byte_vec_t for input `*.wat` * Mark wat input as const * Return an error message and use `fixed` * Actually include the error message * Use `fixed` in `Module.cs` as well
This commit is contained in:
@@ -13,7 +13,9 @@ namespace Wasmtime.Tests
|
||||
.WithReferenceTypes(true)
|
||||
.Build();
|
||||
Store = Engine.CreateStore();
|
||||
Module = Store.CreateModule(Path.Combine("Modules", ModuleFileName));
|
||||
var wat = Path.Combine("Modules", ModuleFileName);
|
||||
var wasm = Engine.WatToWasm(File.ReadAllText(wat));
|
||||
Module = Store.CreateModule(wat, wasm);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Wasmtime.Tests
|
||||
{
|
||||
public class FunctionExportsFixture : ModuleFixture
|
||||
{
|
||||
protected override string ModuleFileName => "FunctionExports.wasm";
|
||||
protected override string ModuleFileName => "FunctionExports.wat";
|
||||
}
|
||||
|
||||
public class FunctionExportsTests : IClassFixture<FunctionExportsFixture>
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Wasmtime.Tests
|
||||
{
|
||||
public class FunctionImportsFixture : ModuleFixture
|
||||
{
|
||||
protected override string ModuleFileName => "FunctionImports.wasm";
|
||||
protected override string ModuleFileName => "FunctionImports.wat";
|
||||
}
|
||||
|
||||
public class FunctionImportsTests : IClassFixture<FunctionImportsFixture>
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Wasmtime.Tests
|
||||
{
|
||||
public class FunctionThunkingFixture : ModuleFixture
|
||||
{
|
||||
protected override string ModuleFileName => "FunctionThunking.wasm";
|
||||
protected override string ModuleFileName => "FunctionThunking.wat";
|
||||
}
|
||||
|
||||
public class FunctionThunkingTests : IClassFixture<FunctionThunkingFixture>
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Wasmtime.Tests
|
||||
{
|
||||
public class GlobalExportsFixture : ModuleFixture
|
||||
{
|
||||
protected override string ModuleFileName => "GlobalExports.wasm";
|
||||
protected override string ModuleFileName => "GlobalExports.wat";
|
||||
}
|
||||
|
||||
public class GlobalExportsTests : IClassFixture<GlobalExportsFixture>
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Wasmtime.Tests
|
||||
{
|
||||
public class GlobalImportBindingFixture : ModuleFixture
|
||||
{
|
||||
protected override string ModuleFileName => "GlobalImportBindings.wasm";
|
||||
protected override string ModuleFileName => "GlobalImportBindings.wat";
|
||||
}
|
||||
|
||||
public class GlobalImportBindingTests : IClassFixture<GlobalImportBindingFixture>
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Wasmtime.Tests
|
||||
{
|
||||
public class GlobalImportsFixture : ModuleFixture
|
||||
{
|
||||
protected override string ModuleFileName => "GlobalImports.wasm";
|
||||
protected override string ModuleFileName => "GlobalImports.wat";
|
||||
}
|
||||
|
||||
public class GlobalImportsTests : IClassFixture<GlobalImportsFixture>
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Wasmtime.Tests
|
||||
{
|
||||
public class MemoryExportsFixture : ModuleFixture
|
||||
{
|
||||
protected override string ModuleFileName => "MemoryExports.wasm";
|
||||
protected override string ModuleFileName => "MemoryExports.wat";
|
||||
}
|
||||
|
||||
public class MemoryExportsTests : IClassFixture<MemoryExportsFixture>
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Wasmtime.Tests
|
||||
{
|
||||
public class MemoryImportBindingFixture : ModuleFixture
|
||||
{
|
||||
protected override string ModuleFileName => "MemoryImportBinding.wasm";
|
||||
protected override string ModuleFileName => "MemoryImportBinding.wat";
|
||||
}
|
||||
|
||||
public class MemoryImportBindingTests : IClassFixture<MemoryImportBindingFixture>
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Wasmtime.Tests
|
||||
{
|
||||
public class MemoryImportFromModuleFixture : ModuleFixture
|
||||
{
|
||||
protected override string ModuleFileName => "MemoryImportFromModule.wasm";
|
||||
protected override string ModuleFileName => "MemoryImportFromModule.wat";
|
||||
}
|
||||
|
||||
public class MemoryImportFromModuleTests : IClassFixture<MemoryImportFromModuleFixture>
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Wasmtime.Tests
|
||||
{
|
||||
public class MemoryImportNoUpperBoundFixture : ModuleFixture
|
||||
{
|
||||
protected override string ModuleFileName => "MemoryImportNoUpperBound.wasm";
|
||||
protected override string ModuleFileName => "MemoryImportNoUpperBound.wat";
|
||||
}
|
||||
|
||||
public class MemoryImportNoUpperBoundTests : IClassFixture<MemoryImportNoUpperBoundFixture>
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Wasmtime.Tests
|
||||
{
|
||||
public class MemoryImportWithUpperBoundFixture : ModuleFixture
|
||||
{
|
||||
protected override string ModuleFileName => "MemoryImportWithUpperBound.wasm";
|
||||
protected override string ModuleFileName => "MemoryImportWithUpperBound.wat";
|
||||
}
|
||||
|
||||
public class MemoryImportWithUpperBoundTests : IClassFixture<MemoryImportWithUpperBoundFixture>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -8,7 +8,7 @@ namespace Wasmtime.Tests
|
||||
{
|
||||
public class TableExportsFixture : ModuleFixture
|
||||
{
|
||||
protected override string ModuleFileName => "TableExports.wasm";
|
||||
protected override string ModuleFileName => "TableExports.wat";
|
||||
}
|
||||
|
||||
public class TableExportsTests : IClassFixture<TableExportsFixture>
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Wasmtime.Tests
|
||||
{
|
||||
public class TableImportsFixture : ModuleFixture
|
||||
{
|
||||
protected override string ModuleFileName => "TableImports.wasm";
|
||||
protected override string ModuleFileName => "TableImports.wat";
|
||||
}
|
||||
|
||||
public class TableImportsTests : IClassFixture<TableImportsFixture>
|
||||
|
||||
@@ -21,4 +21,4 @@ namespace Wasmtime.Tests
|
||||
|
||||
public string Path { get; private set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Wasmtime.Tests
|
||||
{
|
||||
public class WasiFixture : ModuleFixture
|
||||
{
|
||||
protected override string ModuleFileName => "Wasi.wasm";
|
||||
protected override string ModuleFileName => "Wasi.wat";
|
||||
}
|
||||
|
||||
public class WasiTests : IClassFixture<WasiFixture>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
</Target>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Modules/*.wasm" CopyToOutputDirectory="PreserveNewest" />
|
||||
<None Update="Modules/*.wat" CopyToOutputDirectory="PreserveNewest" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user