1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-27 20:41:58 +03:00

Minor internal cleanups in the js pieces.

FossilOrigin-Name: 271391b4e32220ab4c32d69f579ecd2b03eb99da898955a1ef8fffc27216719d
This commit is contained in:
stephan
2022-11-01 11:09:34 +00:00
parent 49048b148e
commit 0f32760e3c
5 changed files with 35 additions and 34 deletions

View File

@ -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,