From b1770039f4d483cdab2d4d136cd7ffbf12f165b7 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Wed, 28 May 2025 14:32:38 +0200 Subject: Enable WASM64 --- web/callback.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'web/callback.js') diff --git a/web/callback.js b/web/callback.js index 178b8e9..e277cf5 100644 --- a/web/callback.js +++ b/web/callback.js @@ -31,8 +31,15 @@ addCallbackFunction: function(f) { callFunction__deps: [ 'cbfl', 'validateCallbackId' ], callFunction: function(id, arg) { + // This is a workaround related to usign WASM64 + // JavaScript's UTF8ToString expects a pointer argument, which for JS is + // of type "number", but WASM64 is passing a BigInt. See also: + // https://github.com/emscripten-core/emscripten/issues/21541 + // (but I could not make the suggested solution work in this case). + // TODO: check if there is a better workaround. + const non64_arg = Number(arg); if (_validateCallbackId(id)) - _cbfl[id](UTF8ToString(arg)); + _cbfl[id](UTF8ToString(non64_arg)); }, callFunctionInt__deps: [ 'cbfl', 'validateCallbackId' ], -- cgit v1.3