From bc0ab1690163568243c932c6fd82585f5cb3cdf7 Mon Sep 17 00:00:00 2001 From: Olivia Appleton Date: Fri, 23 Aug 2024 18:31:42 -0500 Subject: [PATCH] Change wasm call method --- c/Makefile | 2 +- cplusplus/Makefile | 2 +- docs/_static/test-c.html | 8 ++------ 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/c/Makefile b/c/Makefile index f2cff94f..6767a6bf 100644 --- a/c/Makefile +++ b/c/Makefile @@ -70,7 +70,7 @@ clean: dist/c-lib.wasm: build/lib.c @mkdir -p dist - @emcc build/lib.c -Wl,--whole-archive -DUNITY_END -O$(O) -s EXPORTED_RUNTIME_METHODS="['UTF8ToString']" -o dist/c-lib.mjs + @emcc build/lib.c -Wl,--whole-archive -DUNITY_END -O$(O) -s EXPORTED_RUNTIME_METHODS="['ccall']" -o dist/c-lib.mjs build/lib.c: ../LICENSE @mkdir -p build diff --git a/cplusplus/Makefile b/cplusplus/Makefile index 7296e63c..eb6b7862 100644 --- a/cplusplus/Makefile +++ b/cplusplus/Makefile @@ -62,7 +62,7 @@ clean: dist/cp-lib.wasm: build/lib.cpp @mkdir -p dist - @emcc build/lib.cpp -Wl,--whole-archive -DUNITY_END -O$(O) -s EXPORTED_RUNTIME_METHODS="['UTF8ToString']" -o dist/cp-lib.mjs + @emcc build/lib.cpp -Wl,--whole-archive -DUNITY_END -O$(O) -s EXPORTED_RUNTIME_METHODS="['ccall']" -o dist/cp-lib.mjs build/lib.cpp: ../LICENSE @mkdir -p build diff --git a/docs/_static/test-c.html b/docs/_static/test-c.html index ba12787e..b1521a3b 100644 --- a/docs/_static/test-c.html +++ b/docs/_static/test-c.html @@ -20,8 +20,7 @@ for (let p = 1; p < 10000; p++) { if ([12, ].includes(p)) continue; const formattedQuestion = `${p}`.padStart(4, '0'); - const func = wasm[`_p${formattedQuestion}`]; - if (func === undefined) continue; + if (wasm[`_p${formattedQuestion}`] === undefined) continue; let expected = get_js_answer(p); if (typeof expected === 'bigint') { expected = Number(expected); @@ -29,10 +28,7 @@ describe(`run test ${p}`, function() { this.timeout(Infinity); it(`should return ${expected}`, () => { - let answer = func(); - if (typeof expected === 'string') { - answer = wasm.UTF8ToString(answer); - } + let answer = wasm.ccall(`p${formattedQuestion}`, typeof expected, [], []); console.log(p, answer, expected); if (answer !== expected) { throw new Error();