Skip to content

Commit 507d3f4

Browse files
committed
fix addEmJs when parameter is indirect pointer
1 parent a8c9373 commit 507d3f4

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

src/lib/libdylink.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ var LibraryDylink = {
880880
cSig = cSig.split(',');
881881
for (var arg of cSig) {
882882
var jsArg = arg.split(' ').pop();
883-
jsArgs.push(jsArg.replace('*', ''));
883+
jsArgs.push(jsArg.replaceAll('*', ''));
884884
}
885885
}
886886
var func = `(${jsArgs}) => ${body};`;

test/other/test_em_js_main.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ in main
22
hello from side module 42 + hello
33
hello again
44
hello from void func
5+
hello

test/other/test_em_js_side.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,15 @@ EM_JS(void, js_side_func_void, (), {
1414
out(`hello from void func`);
1515
});
1616

17+
EM_JS(void, js_side_func_indirect_ptr, (const char **pptr), {
18+
out(UTF8ToString(getValue(pptr, '*')));
19+
});
20+
1721
int test_side() {
22+
const char *hello = "hello";
1823
js_side_func(42, "hello");
1924
js_side_func2("hello again");
2025
js_side_func_void();
26+
js_side_func_indirect_ptr(&hello);
2127
return 0;
2228
}

0 commit comments

Comments
 (0)