File indexing completed on 2025-11-19 09:50:45
0001 #ifndef Py_EMSCRIPTEN_TRAMPOLINE_H
0002 #define Py_EMSCRIPTEN_TRAMPOLINE_H
0003
0004 #include "pycore_runtime.h" // _PyRuntimeState
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028 #if defined(__EMSCRIPTEN__) && defined(PY_CALL_TRAMPOLINE)
0029
0030 void _Py_EmscriptenTrampoline_Init(_PyRuntimeState *runtime);
0031
0032 PyObject*
0033 _PyEM_TrampolineCall_JavaScript(PyCFunctionWithKeywords func,
0034 PyObject* self,
0035 PyObject* args,
0036 PyObject* kw);
0037
0038 PyObject*
0039 _PyEM_TrampolineCall_Reflection(PyCFunctionWithKeywords func,
0040 PyObject* self,
0041 PyObject* args,
0042 PyObject* kw);
0043
0044 #define _PyEM_TrampolineCall(meth, self, args, kw) \
0045 ((_PyRuntime.wasm_type_reflection_available) ? \
0046 (_PyEM_TrampolineCall_Reflection((PyCFunctionWithKeywords)(meth), (self), (args), (kw))) : \
0047 (_PyEM_TrampolineCall_JavaScript((PyCFunctionWithKeywords)(meth), (self), (args), (kw))))
0048
0049 #define _PyCFunction_TrampolineCall(meth, self, args) \
0050 _PyEM_TrampolineCall( \
0051 (*(PyCFunctionWithKeywords)(void(*)(void))(meth)), (self), (args), NULL)
0052
0053 #define _PyCFunctionWithKeywords_TrampolineCall(meth, self, args, kw) \
0054 _PyEM_TrampolineCall((meth), (self), (args), (kw))
0055
0056 #define descr_set_trampoline_call(set, obj, value, closure) \
0057 ((int)_PyEM_TrampolineCall((PyCFunctionWithKeywords)(set), (obj), (value), (PyObject*)(closure)))
0058
0059 #define descr_get_trampoline_call(get, obj, closure) \
0060 _PyEM_TrampolineCall((PyCFunctionWithKeywords)(get), (obj), (PyObject*)(closure), NULL)
0061
0062
0063 #else
0064
0065 #define _Py_EmscriptenTrampoline_Init(runtime)
0066
0067 #define _PyCFunction_TrampolineCall(meth, self, args) \
0068 (meth)((self), (args))
0069
0070 #define _PyCFunctionWithKeywords_TrampolineCall(meth, self, args, kw) \
0071 (meth)((self), (args), (kw))
0072
0073 #define descr_set_trampoline_call(set, obj, value, closure) \
0074 (set)((obj), (value), (closure))
0075
0076 #define descr_get_trampoline_call(get, obj, closure) \
0077 (get)((obj), (closure))
0078
0079 #endif
0080
0081 #endif