Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib/libdylink.js
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ var LibraryDylink = {
cSig = cSig.split(',');
for (var arg of cSig) {
var jsArg = arg.split(' ').pop();
jsArgs.push(jsArg.replace('*', ''));
jsArgs.push(jsArg.replaceAll('*', ''));
}
}
var func = `(${jsArgs}) => ${body};`;
Expand Down
1 change: 1 addition & 0 deletions test/other/test_em_js_main.out
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ in main
hello from side module 42 + hello
hello again
hello from void func
indirect ptr value: 0
5 changes: 5 additions & 0 deletions test/other/test_em_js_side.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@ EM_JS(void, js_side_func_void, (), {
out(`hello from void func`);
});

EM_JS(void, js_side_func_indirect_ptr, (char **pptr), {
out(`indirect ptr value: ${pptr}`);
});

int test_side() {
js_side_func(42, "hello");
js_side_func2("hello again");
js_side_func_void();
js_side_func_indirect_ptr(NULL);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you pass &"hello" and then print the string js_side_func_indirect_ptr?

otherwise lgtm

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code inside EM_JS is JavaScript function so I cannot dereference pointer in the C way. Is there a way to do it with JS?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you can use the makeGetValue macro. See the libraries in src/lib for examples

return 0;
}
Loading