From c0c5fb1b8ce0bcc6975b1933ae7c069a80de9971 Mon Sep 17 00:00:00 2001 From: Christoph Wille Date: Tue, 30 Aug 2022 06:56:03 +0200 Subject: [PATCH] Wasmtime 0.40.0-preview1 --- .../Opa.Wasm.Benchmarks.csproj | 2 +- .../Opa.Wasm.ConsoleSample.csproj | 2 +- src/Opa.Wasm/Opa.Wasm.csproj | 4 +-- src/Opa.Wasm/OpaPolicy.Functions.cs | 36 +++++++++---------- src/Opa.Wasm/OpaPolicy.cs | 10 +++--- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/Opa.Wasm.Benchmarks/Opa.Wasm.Benchmarks.csproj b/src/Opa.Wasm.Benchmarks/Opa.Wasm.Benchmarks.csproj index d28d124..b6a0063 100644 --- a/src/Opa.Wasm.Benchmarks/Opa.Wasm.Benchmarks.csproj +++ b/src/Opa.Wasm.Benchmarks/Opa.Wasm.Benchmarks.csproj @@ -12,7 +12,7 @@ - + diff --git a/src/Opa.Wasm.ConsoleSample/Opa.Wasm.ConsoleSample.csproj b/src/Opa.Wasm.ConsoleSample/Opa.Wasm.ConsoleSample.csproj index 7c79b68..73ba2ef 100644 --- a/src/Opa.Wasm.ConsoleSample/Opa.Wasm.ConsoleSample.csproj +++ b/src/Opa.Wasm.ConsoleSample/Opa.Wasm.ConsoleSample.csproj @@ -24,7 +24,7 @@ - + diff --git a/src/Opa.Wasm/Opa.Wasm.csproj b/src/Opa.Wasm/Opa.Wasm.csproj index 1138c6d..cf7812b 100644 --- a/src/Opa.Wasm/Opa.Wasm.csproj +++ b/src/Opa.Wasm/Opa.Wasm.csproj @@ -1,7 +1,7 @@  net6.0 - 0.32.0 + 0.33.0 MIT https://github.com/christophwille/dotnet-opa-wasm https://github.com/christophwille/dotnet-opa-wasm.git @@ -37,7 +37,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/src/Opa.Wasm/OpaPolicy.Functions.cs b/src/Opa.Wasm/OpaPolicy.Functions.cs index 61f7bc0..d3b5309 100644 --- a/src/Opa.Wasm/OpaPolicy.Functions.cs +++ b/src/Opa.Wasm/OpaPolicy.Functions.cs @@ -6,99 +6,99 @@ public partial class OpaPolicy { private int? Policy_opa_wasm_abi_version() { - var global = _instance.GetGlobal(_store, "opa_wasm_abi_version"); - return (int?)global?.GetValue(_store); + var global = _instance.GetGlobal("opa_wasm_abi_version"); + return (int?)global?.GetValue(); } private int? Policy_opa_wasm_abi_minor_version() { - var global = _instance.GetGlobal(_store, "opa_wasm_abi_minor_version"); - return (int?)global?.GetValue(_store); + var global = _instance.GetGlobal("opa_wasm_abi_minor_version"); + return (int?)global?.GetValue(); } private int Policy_Builtins() { - var run = _instance.GetFunction(_store, "builtins"); + var run = _instance.GetFunction("builtins"); return run(); } private int Policy_Entrypoints() { - var run = _instance.GetFunction(_store, "entrypoints"); + var run = _instance.GetFunction("entrypoints"); return run(); } private int Policy_opa_heap_ptr_get() { - var run = _instance.GetFunction(_store, "opa_heap_ptr_get"); + var run = _instance.GetFunction("opa_heap_ptr_get"); return run(); } private void Policy_opa_heap_ptr_set(int ptr) { - var run = _instance.GetAction(_store, "opa_heap_ptr_set"); + var run = _instance.GetAction("opa_heap_ptr_set"); run(ptr); } private int Policy_opa_eval_ctx_new() { - var run = _instance.GetFunction(_store, "opa_eval_ctx_new"); + var run = _instance.GetFunction("opa_eval_ctx_new"); return run(); } private void Policy_opa_eval_ctx_set_input(int ctxAddr, int inputAddr) { - var run = _instance.GetAction(_store, "opa_eval_ctx_set_input"); + var run = _instance.GetAction("opa_eval_ctx_set_input"); run(ctxAddr, inputAddr); } private void Policy_opa_eval_ctx_set_data(int ctxAddr, int dataAddr) { - var run = _instance.GetAction(_store, "opa_eval_ctx_set_data"); + var run = _instance.GetAction("opa_eval_ctx_set_data"); run(ctxAddr, dataAddr); } private void Policy_opa_eval_ctx_set_entrypoint(int ctxAddr, int entrypoint) { - var run = _instance.GetAction(_store, "opa_eval_ctx_set_entrypoint"); + var run = _instance.GetAction("opa_eval_ctx_set_entrypoint"); run(ctxAddr, entrypoint); } private void Policy_eval(int ctxAddr) { - var run = _instance.GetFunction(_store, "eval"); + var run = _instance.GetFunction("eval"); _ = run(ctxAddr); } private int Policy_opa_eval(/*int addr, */ int entrypoint_id, int dataaddr, int jsonaddr, int jsonlength, int heapaddr/*, int format*/) { - var run = _instance.GetFunction(_store, "opa_eval"); + var run = _instance.GetFunction("opa_eval"); return run(0 /* always 0 */, entrypoint_id, dataaddr, jsonaddr, jsonlength, heapaddr, 0 /* json format */); } private int Policy_opa_eval_ctx_get_result(int ctxAddr) { - var run = _instance.GetFunction(_store, "opa_eval_ctx_get_result"); + var run = _instance.GetFunction("opa_eval_ctx_get_result"); return run(ctxAddr); } private int Policy_opa_malloc(int length) { - var run = _instance.GetFunction(_store, "opa_malloc"); + var run = _instance.GetFunction("opa_malloc"); return run(length); } private int Policy_opa_json_parse(int addr, int length) { - var run = _instance.GetFunction(_store, "opa_json_parse"); + var run = _instance.GetFunction("opa_json_parse"); return run(addr, length); } private int Policy_opa_json_dump(int addrResult) { - var run = _instance.GetFunction(_store, "opa_json_dump"); + var run = _instance.GetFunction("opa_json_dump"); return run(addrResult); } } diff --git a/src/Opa.Wasm/OpaPolicy.cs b/src/Opa.Wasm/OpaPolicy.cs index 1314e80..9d744b8 100644 --- a/src/Opa.Wasm/OpaPolicy.cs +++ b/src/Opa.Wasm/OpaPolicy.cs @@ -70,7 +70,7 @@ private void LinkImports() _linker.Define(OpaConstants.Module, OpaConstants.Abort, Function.FromCallback(_store, (Caller caller, int addr) => { - string info = _envMemory.ReadNullTerminatedString(_store, addr); + string info = _envMemory.ReadNullTerminatedString(addr); // NOTE: the generic class will do, as it is unwrapped again by Policy_eval/run?.Invoke throw new Exception(info); @@ -303,11 +303,11 @@ private string FastEvaluate(string json, int? entrypoint) { if (!entrypoint.HasValue) entrypoint = 0; // use default entry point - _envMemory.WriteString(_store, _dataHeapPtr, json); + _envMemory.WriteString(_dataHeapPtr, json); int resultaddr = Policy_opa_eval(entrypoint.Value, _dataAddr, _dataHeapPtr, json.Length, _dataHeapPtr + json.Length); - return _envMemory.ReadNullTerminatedString(_store, resultaddr); + return _envMemory.ReadNullTerminatedString(resultaddr); } public void SetDataJson(string json) @@ -326,7 +326,7 @@ public void SetData(object data) private int LoadJson(string json) { int addr = Policy_opa_malloc(json.Length); - _envMemory.WriteString(_store, addr, json); + _envMemory.WriteString(addr, json); int parseAddr = Policy_opa_json_parse(addr, json.Length); @@ -341,7 +341,7 @@ private int LoadJson(string json) private string DumpJson(int addrResult) { int addr = Policy_opa_json_dump(addrResult); - return _envMemory.ReadNullTerminatedString(_store, addr); + return _envMemory.ReadNullTerminatedString(addr); } public void Dispose()