diff options
author | stephan <stephan@noemail.net> | 2022-09-13 19:27:03 +0000 |
---|---|---|
committer | stephan <stephan@noemail.net> | 2022-09-13 19:27:03 +0000 |
commit | 5b9150079606c31741572ef2aca5e39e8f7f9b56 (patch) | |
tree | 1bd17b886340616bbe04572051244df3fd3c6dc8 /ext/wasm/api/sqlite3-api-cleanup.js | |
parent | 23d39ce54d2001af90e453765a38adcc964e5820 (diff) | |
download | sqlite-5b9150079606c31741572ef2aca5e39e8f7f9b56.tar.gz sqlite-5b9150079606c31741572ef2aca5e39e8f7f9b56.zip |
Add/apply various kvvfs-specific utility APIs to the JS layer to assist in testing and analysis. Correct a backwards default arg check for sqlite3ApiBootstrap(). Add exports for sqlite3_db_handle(), sqlite3_file_control(), and the SQLITE_FCNTL_xxx enum.
FossilOrigin-Name: 0d78961870ee9f22f1ba16d423377d28dcc36e04b1e31ffd57f3e2fd51f8f0f2
Diffstat (limited to 'ext/wasm/api/sqlite3-api-cleanup.js')
-rw-r--r-- | ext/wasm/api/sqlite3-api-cleanup.js | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/ext/wasm/api/sqlite3-api-cleanup.js b/ext/wasm/api/sqlite3-api-cleanup.js index 1b57cdc5d..0e99edf50 100644 --- a/ext/wasm/api/sqlite3-api-cleanup.js +++ b/ext/wasm/api/sqlite3-api-cleanup.js @@ -20,11 +20,17 @@ if('undefined' !== typeof Module){ // presumably an Emscripten build /** Install a suitable default configuration for sqlite3ApiBootstrap(). */ - const SABC = self.sqlite3ApiBootstrap.defaultConfig; - SABC.Module = Module /* ==> Currently needs to be exposed here for test code. NOT part - of the public API. */; - SABC.exports = Module['asm']; - SABC.memory = Module.wasmMemory /* gets set if built with -sIMPORT_MEMORY */; + const SABC = self.sqlite3ApiConfig || Object.create(null); + if(undefined===SABC.Module){ + SABC.Module = Module /* ==> Currently needs to be exposed here for + test code. NOT part of the public API. */; + } + if(undefined===SABC.exports){ + SABC.exports = Module['asm']; + } + if(undefined===SABC.memory){ + SABC.memory = Module.wasmMemory /* gets set if built with -sIMPORT_MEMORY */; + } /** For current (2022-08-22) purposes, automatically call @@ -35,8 +41,15 @@ if('undefined' !== typeof Module){ // presumably an Emscripten build configuration used by a no-args call to sqlite3ApiBootstrap(). */ //console.warn("self.sqlite3ApiConfig = ",self.sqlite3ApiConfig); - const sqlite3 = self.sqlite3ApiBootstrap(); - delete self.sqlite3ApiBootstrap; + const rmApiConfig = (SABC !== self.sqlite3ApiConfig); + self.sqlite3ApiConfig = SABC; + let sqlite3; + try{ + sqlite3 = self.sqlite3ApiBootstrap(); + }finally{ + delete self.sqlite3ApiBootstrap; + if(rmApiConfig) delete self.sqlite3ApiConfig; + } if(self.location && +self.location.port > 1024){ console.warn("Installing sqlite3 bits as global S for local dev/test purposes."); |