There was an error while loading. Please reload this page.
1 parent 0a26aa5 commit f81bf2bCopy full SHA for f81bf2b
1 file changed
Python/emscripten_trampoline.c
@@ -10,7 +10,17 @@
10
* https://github.com/GoogleChromeLabs/wasm-feature-detect/blob/main/src/detectors/type-reflection/index.js
11
*/
12
EM_JS(int, _PyEM_detect_type_reflection, (), {
13
- return "Function" in WebAssembly;
+ if (!("Function" in WebAssembly)) {
14
+ return false;
15
+ }
16
+ if (WebAssembly.Function.type) {
17
+ // Node v20
18
+ Module.PyEM_CountArgs = (func) => WebAssembly.Function.type(wasmTable.get(func)).parameters.length;
19
+ } else {
20
+ // Node >= 22, v8-based browsers
21
+ Module.PyEM_CountArgs = (func) => wasmTable.get(func).type().parameters.length;
22
23
+ return ;
24
});
25
26
void
@@ -43,7 +53,7 @@ EM_JS(int, _PyEM_CountFuncParams, (PyCFunctionWithKeywords func),
43
53
if (n !== undefined) {
44
54
return n;
45
55
}
46
- n = WebAssembly.Function.type(wasmTable.get(func)).parameters.length;
56
+ n = Module.PyEM_CountArgs(func);
47
57
_PyEM_CountFuncParams.cache.set(func, n);
48
58
49
59
0 commit comments