File: proxied_function.c

package info (click to toggle)
emscripten 3.1.69%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 121,860 kB
  • sloc: ansic: 636,110; cpp: 425,974; javascript: 78,401; python: 58,404; sh: 49,154; pascal: 5,237; makefile: 3,366; asm: 2,415; lisp: 1,869
file content (35 lines) | stat: -rw-r--r-- 798 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// This test checks whether attempting to call a proxied JS function (one with __proxy signature) will throw
// an exception.

#include <emscripten.h>
#include <emscripten/wasm_worker.h>

void proxied_js_function(void);

void test_finished()
{
  REPORT_RESULT(0);
}

void run_in_worker()
{
  int threw = EM_ASM_INT({
    try {
      _proxied_js_function();
    } catch(e) {
      console.error(e);
      return 1;
    }
    return 0;
  });

  if (!threw) {
    emscripten_wasm_worker_post_function_v(EMSCRIPTEN_WASM_WORKER_ID_PARENT, test_finished);
  }
}

int main()
{
  emscripten_wasm_worker_post_function_v(emscripten_malloc_wasm_worker(1024), run_in_worker);
  proxied_js_function(); // Pin a dependency from C code to the JS function to avoid needing to mess with cmdline export directives
}