Skip to content

Commit 04e0541

Browse files
committed
Add forgotten file
1 parent 0ffb76b commit 04e0541

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

Python/emscripten_trampoline_inner.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
typedef void PyObject;
2+
3+
typedef PyObject* (*zero_arg)(void);
4+
typedef PyObject* (*one_arg)(PyObject*);
5+
typedef PyObject* (*two_arg)(PyObject*, PyObject*);
6+
typedef PyObject* (*three_arg)(PyObject*, PyObject*, PyObject*);
7+
8+
#define TRY_RETURN_CALL(ty, args...) \
9+
if (__builtin_wasm_test_function_pointer_signature((ty)func)) { \
10+
return ((ty)func)(args); \
11+
}
12+
13+
__attribute__((export_name("trampoline_call"))) PyObject*
14+
trampoline_call(int* success,
15+
void* func,
16+
PyObject* self,
17+
PyObject* args,
18+
PyObject* kw)
19+
{
20+
*success = 1;
21+
TRY_RETURN_CALL(three_arg, self, args, kw);
22+
TRY_RETURN_CALL(two_arg, self, args);
23+
TRY_RETURN_CALL(one_arg, self);
24+
TRY_RETURN_CALL(zero_arg);
25+
*success = 0;
26+
return 0;
27+
}

0 commit comments

Comments
 (0)