You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This compliments `MAIN_THREAD_EM_ASM_INT` in the same way that `EM_ASM_PTR`
was added to compliment `EM_ASM_INT`.
This is needed to fix the wasm64 SDL2 build. See
libsdl-org/SDL#8241.
// Asynchronously dispatches the given JavaScript code to be run on the main browser thread.
247
-
// If the calling thread is the main browser thread, then the specified JavaScript code is executed
248
-
// synchronously. Otherwise an event will be queued on the main browser thread to execute the call
249
-
// later (think postMessage()), and this call will immediately return without waiting. Be sure to guard any accesses to shared memory on the heap inside the JavaScript code with appropriate locking.
270
+
// Asynchronously dispatches the given JavaScript code to be run on the main
271
+
// browser thread.
272
+
// If the calling thread is the main browser thread, then the specified
273
+
// JavaScript code is executed synchronously. Otherwise an event will be queued
274
+
// on the main browser thread to execute the call later (think postMessage()),
275
+
// and this call will immediately return without waiting. Be sure to guard any
276
+
// accesses to shared memory on the heap inside the JavaScript code with
Copy file name to clipboardExpand all lines: test/core/test_em_asm_2.cpp
+9Lines changed: 9 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -111,6 +111,15 @@ int main()
111
111
// Note that expressions do not evaluate to return values, but the "return" keyword is needed. That is, the following line would return undefined and store i <- 0.
112
112
// i = EM_ASM_INT(HEAP8.length); printf("returned statement %d\n", i);
113
113
114
+
void* p;
115
+
116
+
printf("\nEM_ASM_PTR: Return a pointer back.\n");
117
+
p = EM_ASM_PTR(out('1. got arg ' + $0); return3;, 42); printf("1. returned ptr %p\n", p);
118
+
p = EM_ASM_PTR("out('2. got arg ' + $0); return 4;", 42); printf("2. returned ptr %p\n", p);
119
+
p = EM_ASM_PTR({"out('3. got arg ' + $0); return 5;"}, 42); printf("3. returned ptr %p\n", p);
120
+
p = EM_ASM_PTR({out('4. got arg ' + $0); return6;}, 42); printf("4. returned ptr %p\n", p);
121
+
p = EM_ASM_PTR("{out('5. got arg ' + $0); return 7;}", 42); printf("5. returned ptr %p\n", p);
122
+
114
123
double d;
115
124
116
125
printf("\nEM_ASM_DOUBLE: Pass no parameters, return a double.\n");
0 commit comments