-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Open
Description
EM_JS
is a very useful feature for including JS-library-like code in object files (which can later be put into archives and linked fully transparently). However, it suffers from a usability issue: it is by default formatted as one large line:
; input
EM_JS(int, JSAdd2, (int x, int y), {
console.log(`In JSAdd2(${x}, ${y})`);
return x + y;
});
; output
function JSAdd2(x,y) { console.log(`In JSAdd2(${x}, ${y})`); return x + y; }
Which makes larger functions very hard to debug / read in generated code.
I was thinking the situation could be improved; some possibilities:
- Run an auto-formatter on these functions after the fact. This could be complex.
- Add a new macro variation that accepts string literals instead of a token list.
I am not sure 1
is viable. 2
though seems like a simple enough change; it can be hacked together today by using the implementation macro _EM_JS
(and indeed works as one would expect):
EM_JS_STR(int, JSAdd, (int x, int y), R"({
console.log(`In JSAdd(${x}, ${y})`);
return x + y;
})");
Metadata
Metadata
Assignees
Labels
No labels