aboutsummaryrefslogtreecommitdiff
path: root/ext/wasm/api/sqlite3-api-glue.js
diff options
context:
space:
mode:
authorstephan <stephan@noemail.net>2022-10-03 09:21:37 +0000
committerstephan <stephan@noemail.net>2022-10-03 09:21:37 +0000
commit7ff8da876d147f8bc15814bc172e78c43a5afb8f (patch)
tree4a4540da76bb7047d1bfe23f53c7fcf440e31d47 /ext/wasm/api/sqlite3-api-glue.js
parentbdfd7ea03a4764dcfaa091303c2b8bbf3fd323a0 (diff)
downloadsqlite-7ff8da876d147f8bc15814bc172e78c43a5afb8f.tar.gz
sqlite-7ff8da876d147f8bc15814bc172e78c43a5afb8f.zip
OPFS VFS now lazily opens its sync access handle, as a step towards experimenting with relinquishing it during idle times to help avoid cross-tab and page-reload locking issues.
FossilOrigin-Name: a984e1ba435731413a541f86c50232bc7d6e33aff6ba4cca90f89188e7b82a2c
Diffstat (limited to 'ext/wasm/api/sqlite3-api-glue.js')
-rw-r--r--ext/wasm/api/sqlite3-api-glue.js56
1 files changed, 24 insertions, 32 deletions
diff --git a/ext/wasm/api/sqlite3-api-glue.js b/ext/wasm/api/sqlite3-api-glue.js
index bbd5b446f..e31618d5e 100644
--- a/ext/wasm/api/sqlite3-api-glue.js
+++ b/ext/wasm/api/sqlite3-api-glue.js
@@ -24,27 +24,32 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
self.WhWasmUtilInstaller(capi.wasm);
delete self.WhWasmUtilInstaller;
+ /**
+ Install JS<->C struct bindings for the non-opaque struct types we
+ need... */
+ sqlite3.StructBinder = self.Jaccwabyt({
+ heap: 0 ? wasm.memory : wasm.heap8u,
+ alloc: wasm.alloc,
+ dealloc: wasm.dealloc,
+ functionTable: wasm.functionTable,
+ bigIntEnabled: wasm.bigIntEnabled,
+ memberPrefix: '$'
+ });
+ delete self.Jaccwabyt;
+
if(0){
- /* "The problem" is that the following isn't type-safe.
- OTOH, nothing about WASM pointers is. */
- /**
- Add the `.pointer` xWrap() signature entry to extend the
- `pointer` arg handler to check for a `pointer` property. This
- can be used to permit, e.g., passing an sqlite3.oo1.DB instance
- to a C-style sqlite3_xxx function which takes an `sqlite3*`
- argument.
- */
- const xPointer = wasm.xWrap.argAdapter('pointer');
- const adapter = function(v){
- if(v && v.constructor){
- const x = v.pointer;
- if(Number.isInteger(x)) return x;
- else toss("Invalid (object) type for .pointer-type argument.");
+ /* "The problem" is that the following isn't even remotely
+ type-safe. OTOH, nothing about WASM pointers is. */
+ const argPointer = wasm.xWrap.argAdapter('*');
+ wasm.xWrap.argAdapter('StructType', (v)=>{
+ if(v && v.constructor && v instanceof StructBinder.StructType){
+ v = v.pointer;
}
- return xPointer(v);
- };
- wasm.xWrap.argAdapter('.pointer', adapter);
- } /* ".pointer" xWrap() argument adapter */
+ return (v === (v | 0) /* v is a 32-bit integer */)
+ ? argPointer(v)
+ : toss("Invalid (object) type for StructType-type argument.");
+ });
+ }
if(1){/* Convert Arrays and certain TypedArrays to strings for
'flexible-string'-type arguments */
@@ -605,19 +610,6 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
};
}/*wasm.pstack filler*/
- /**
- Install JS<->C struct bindings for the non-opaque struct types we
- need... */
- sqlite3.StructBinder = self.Jaccwabyt({
- heap: 0 ? wasm.memory : wasm.heap8u,
- alloc: wasm.alloc,
- dealloc: wasm.dealloc,
- functionTable: wasm.functionTable,
- bigIntEnabled: wasm.bigIntEnabled,
- memberPrefix: '$'
- });
- delete self.Jaccwabyt;
-
{/* Import C-level constants and structs... */
const cJson = wasm.xCall('sqlite3_wasm_enum_json');
if(!cJson){