We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hello, I haven't been able to figure out how to parse the message argument from c# for the built-in abort method.
I currently have this:
var abortImport = new Import("env", nameof(abort), new ImportFunction((WasmAbortCallbackDelegate)abort) ); // ... _wasmInstance = new Instance(wasm, memoryImport, globalMemory, abortImport, funcImport); // ... public void abort(InstanceContext context, int messageLen, int fileName, int line, int column) { IntPtr memoryBase = context.GetMemory(0).Data; byte[] messageBytes = new byte[messageLen]; Marshal.Copy(memoryBase, messageBytes, 0, messageLen); string messageStr = System.Text.Encoding.UTF8.GetString(messageBytes); Log($"Wasm Abort: {messageStr}, {fileName}, {line}, {column}"); }
and I have also tried this:
var memoryBase = ctx.GetMemory (0).Data; unsafe { var str = Encoding.UTF8.GetString ((byte*)memoryBase + ptr, len); Console.WriteLine ("Received this utf string: [{0}]", str); }
But both don't work (aka print an invalid string). When I write the contents of the byte array to the console log, it's just all 0's.
0's
Caling Instance.LastError doesn't return anything either
Instance.LastError
Any guidance on how to implement this?
The text was updated successfully, but these errors were encountered:
assuming you're using assemblyscript to generate the WASM - you'll need to use their custom string format - https://www.assemblyscript.org/runtime.html#memory-layout - the length is 4 bytes before the address given.
Sorry, something went wrong.
No branches or pull requests
Hello, I haven't been able to figure out how to parse the message argument from c# for the built-in abort method.
I currently have this:
and I have also tried this:
But both don't work (aka print an invalid string). When I write the contents of the byte array to the console log, it's just all
0's
.Caling
Instance.LastError
doesn't return anything eitherAny guidance on how to implement this?
The text was updated successfully, but these errors were encountered: