diff options
Diffstat (limited to 'ext/wasm/api/sqlite3-api-prologue.js')
-rw-r--r-- | ext/wasm/api/sqlite3-api-prologue.js | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/ext/wasm/api/sqlite3-api-prologue.js b/ext/wasm/api/sqlite3-api-prologue.js index ca6fad8f8..5e7f1bae2 100644 --- a/ext/wasm/api/sqlite3-api-prologue.js +++ b/ext/wasm/api/sqlite3-api-prologue.js @@ -199,11 +199,25 @@ self.sqlite3ApiBootstrap = function sqlite3ApiBootstrap( A very few exceptions require an additional level of proxy function or may otherwise require special attention in the WASM - environment, and all such cases are document here. Those not - documented otherwise are installed as 1-to-1 proxies for their + environment, and all such cases are documented somewhere below + in this file or in sqlite3-api-glue.js. capi members which are + not documented are installed as 1-to-1 proxies for their C-side counterparts. */ const capi = Object.create(null); + /** + Holds state which are specific to the WASM-related + infrastructure and glue code. It is not expected that client + code will normally need these, but they're exposed here in case + it does. These APIs are _not_ to be considered an + official/stable part of the sqlite3 WASM API. They may change + as the developers' experience suggests appropriate changes. + + Note that a number of members of this object are injected + dynamically after the api object is fully constructed, so + not all are documented in this file. + */ + const wasm = Object.create(null); /** Functionally equivalent to the SQLite3Error constructor but may @@ -339,11 +353,13 @@ self.sqlite3ApiBootstrap = function sqlite3ApiBootstrap( /** If v is-a Array, its join('') result is returned. If isSQLableTypedArray(v) is true then typedArrayToString(v) is + returned. If it looks like a WASM pointer, wasm.cstringToJs(v) is returned. Else v is returned as-is. */ const flexibleString = function(v){ if(isSQLableTypedArray(v)) return typedArrayToString(v); else if(Array.isArray(v)) return v.join(''); + else if(wasm.isPtr(v)) v = wasm.cstringToJs(v); return v; }; @@ -615,19 +631,7 @@ self.sqlite3ApiBootstrap = function sqlite3ApiBootstrap( typedArrayPart }; - /** - Holds state which are specific to the WASM-related - infrastructure and glue code. It is not expected that client - code will normally need these, but they're exposed here in case - it does. These APIs are _not_ to be considered an - official/stable part of the sqlite3 WASM API. They may change - as the developers' experience suggests appropriate changes. - - Note that a number of members of this object are injected - dynamically after the api object is fully constructed, so - not all are documented inline here. - */ - const wasm = { + Object.assign(wasm, { /** Emscripten APIs have a deep-seated assumption that all pointers are 32 bits. We'll remain optimistic that that won't always be @@ -695,7 +699,7 @@ self.sqlite3ApiBootstrap = function sqlite3ApiBootstrap( dealloc: undefined/*installed later*/ /* Many more wasm-related APIs get installed later on. */ - }/*wasm*/; + }/*wasm*/); /** wasm.alloc()'s srcTypedArray.byteLength bytes, |