From 9fcca3d27c18693eddf65a0edc0f4e609a3a24fc Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 27 Jul 2023 17:50:10 +0000 Subject: Dynamically determine whether the wasm.xWrap() argc check can be applied, depending on how the wasm environment exposes its exports. FossilOrigin-Name: fd59226b34fffb1479fb2d7bd7c0aff982aa4a1a73e6c0d81de6eaf9c075998c --- ext/wasm/api/sqlite3-api-glue.js | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'ext/wasm/api/sqlite3-api-glue.js') diff --git a/ext/wasm/api/sqlite3-api-glue.js b/ext/wasm/api/sqlite3-api-glue.js index f444ec975..572efeed5 100644 --- a/ext/wasm/api/sqlite3-api-glue.js +++ b/ext/wasm/api/sqlite3-api-glue.js @@ -728,6 +728,15 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ Populate api object with sqlite3_...() by binding the "raw" wasm exports into type-converting proxies using wasm.xWrap(). */ + if(0 === wasm.exports.sqlite3_step.length){ + /* This environment wraps exports in nullary functions, which means + we must disable the arg-count validation we otherwise perform + on the wrappers. */ + wasm.xWrap.doArgcCheck = false; + sqlite3.config.warn( + "Disabling sqlite3.wasm.xWrap.doArgcCheck due to environmental quirks." + ); + } for(const e of wasm.bindingSignatures){ capi[e[0]] = wasm.xWrap.apply(null, e); } -- cgit v1.2.3