From 20ad6abbd0a8f470f7f31986895e282961ddaba2 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Tue, 11 Jul 2023 14:34:58 -0700 Subject: [PATCH] Follow pep 7 --- Python/emscripten_trampoline.c | 62 +++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 27 deletions(-) diff --git a/Python/emscripten_trampoline.c b/Python/emscripten_trampoline.c index 77eddd3cb16eff..2a80ec4f18d757 100644 --- a/Python/emscripten_trampoline.c +++ b/Python/emscripten_trampoline.c @@ -1,6 +1,6 @@ #if defined(PY_CALL_TRAMPOLINE) -#include // EM_JS, EM_JS_DEPS +#include // EM_JS #include #include "pycore_runtime.h" // _PyRuntime @@ -10,19 +10,24 @@ * https://github.com/GoogleChromeLabs/wasm-feature-detect/blob/main/src/detectors/type-reflection/index.js */ EM_JS(int, _PyEM_detect_type_reflection, (), { - return "Function" in WebAssembly; + return "Function" in WebAssembly; }); void _Py_EmscriptenTrampoline_Init(_PyRuntimeState *runtime) { - runtime->wasm_type_reflection_available = _PyEM_detect_type_reflection(); + runtime->wasm_type_reflection_available = _PyEM_detect_type_reflection(); } /** * Backwards compatible trampoline works with all JS runtimes */ -EM_JS(PyObject*, _PyEM_TrampolineCall_JavaScript, (PyCFunctionWithKeywords func, PyObject *arg1, PyObject *arg2, PyObject *arg3), { +EM_JS(PyObject*, +_PyEM_TrampolineCall_JavaScript, (PyCFunctionWithKeywords func, + PyObject *arg1, + PyObject *arg2, + PyObject *arg3), +{ return wasmTable.get(func)(arg1, arg2, arg3); } ); @@ -31,14 +36,16 @@ EM_JS(PyObject*, _PyEM_TrampolineCall_JavaScript, (PyCFunctionWithKeywords func, * In runtimes with WebAssembly type reflection, count the number of parameters * and cast to the appropriate signature */ -EM_JS(int, _PyEM_CountFuncParams, (PyCFunctionWithKeywords func), { - let n = _PyEM_CountFuncParams.cache.get(func); - if (n !== undefined) { +EM_JS(int, _PyEM_CountFuncParams, (PyCFunctionWithKeywords func), +{ + let n = _PyEM_CountFuncParams.cache.get(func); + + if (n !== undefined) { + return n; + } + n = WebAssembly.Function.type(wasmTable.get(func)).parameters.length; + _PyEM_CountFuncParams.cache.set(func, n); return n; - } - n = WebAssembly.Function.type(wasmTable.get(func)).parameters.length; - _PyEM_CountFuncParams.cache.set(func, n); - return n; } _PyEM_CountFuncParams.cache = new Map(); ) @@ -52,23 +59,24 @@ typedef PyObject* (*three_arg)(PyObject*, PyObject*, PyObject*); PyObject* _PyEM_TrampolineCall_Reflection(PyCFunctionWithKeywords func, - PyObject* self, - PyObject* args, - PyObject* kw) + PyObject* self, + PyObject* args, + PyObject* kw) { - switch (_PyEM_CountFuncParams(func)) { - case 0: - return ((zero_arg)func)(); - case 1: - return ((one_arg)func)(self); - case 2: - return ((two_arg)func)(self, args); - case 3: - return ((three_arg)func)(self, args, kw); - default: - PyErr_SetString(PyExc_SystemError, "Handler takes too many arguments"); - return NULL; - } + switch (_PyEM_CountFuncParams(func)) { + case 0: + return ((zero_arg)func)(); + case 1: + return ((one_arg)func)(self); + case 2: + return ((two_arg)func)(self, args); + case 3: + return ((three_arg)func)(self, args, kw); + default: + PyErr_SetString(PyExc_SystemError, + "Handler takes too many arguments"); + return NULL; + } } #endif