Skip to content

Commit

Permalink
Change wasm call method
Browse files Browse the repository at this point in the history
  • Loading branch information
LivInTheLookingGlass committed Aug 23, 2024
1 parent 08d1bbc commit bc0ab16
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion c/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cplusplus/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 2 additions & 6 deletions docs/_static/test-c.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,15 @@
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);
}
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();
Expand Down

0 comments on commit bc0ab16

Please sign in to comment.