aboutsummaryrefslogtreecommitdiff
path: root/ext/wasm/api/sqlite3-api-prologue.js
diff options
context:
space:
mode:
authorstephan <stephan@noemail.net>2022-11-01 11:09:34 +0000
committerstephan <stephan@noemail.net>2022-11-01 11:09:34 +0000
commit0f32760e3c51975c27801e9f51b995fc1ed07c38 (patch)
treec73e786c993ecf7d6c495f36c33f243df0012b1e /ext/wasm/api/sqlite3-api-prologue.js
parent49048b148eac5f74eb6f1e9dfbd85ee8f95694a4 (diff)
downloadsqlite-0f32760e3c51975c27801e9f51b995fc1ed07c38.tar.gz
sqlite-0f32760e3c51975c27801e9f51b995fc1ed07c38.zip
Minor internal cleanups in the js pieces.
FossilOrigin-Name: 271391b4e32220ab4c32d69f579ecd2b03eb99da898955a1ef8fffc27216719d
Diffstat (limited to 'ext/wasm/api/sqlite3-api-prologue.js')
-rw-r--r--ext/wasm/api/sqlite3-api-prologue.js36
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,