mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
More work on the JS side of the virtual table APIs.
FossilOrigin-Name: cb9881ec001b0e2faf047e57acfd1722d2b546255a54e0f850f568edfe2df1cd
This commit is contained in:
@ -37,20 +37,6 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
|
||||
});
|
||||
delete self.Jaccwabyt;
|
||||
|
||||
if(0){
|
||||
/* "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 wasm.isPtr(v)
|
||||
? argPointer(v)
|
||||
: toss("Invalid (object) type for StructType-type argument.");
|
||||
});
|
||||
}
|
||||
|
||||
{/* Convert Arrays and certain TypedArrays to strings for
|
||||
'flexible-string'-type arguments */
|
||||
const xString = wasm.xWrap.argAdapter('string');
|
||||
@ -68,15 +54,21 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
|
||||
`sqlite3_vfs*` via capi.sqlite3_vfs.pointer.
|
||||
*/
|
||||
const aPtr = wasm.xWrap.argAdapter('*');
|
||||
const nilType = function(){};
|
||||
wasm.xWrap.argAdapter('sqlite3_filename', aPtr)
|
||||
('sqlite3_stmt*', aPtr)
|
||||
('sqlite3_context*', aPtr)
|
||||
('sqlite3_value*', aPtr)
|
||||
('void*', aPtr)
|
||||
('sqlite3*', (v)=>{
|
||||
if(sqlite3.oo1 && v instanceof sqlite3.oo1.DB) v = v.pointer;
|
||||
return aPtr(v);
|
||||
})
|
||||
('sqlite3*', (v)=>
|
||||
aPtr((v instanceof (sqlite3?.oo1?.DB || nilType))
|
||||
? v.pointer : v))
|
||||
('sqlite3_index_info*', (v)=>
|
||||
aPtr((v instanceof (capi.sqlite3_index_info || nilType))
|
||||
? v.pointer : v))
|
||||
('sqlite3_module*', (v)=>
|
||||
aPtr((v instanceof (capi.sqlite3_module || nilType))
|
||||
? v.pointer : v))
|
||||
/**
|
||||
`sqlite3_vfs*`:
|
||||
|
||||
@ -87,14 +79,13 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
|
||||
*/
|
||||
('sqlite3_vfs*', (v)=>{
|
||||
if('string'===typeof v){
|
||||
const x = capi.sqlite3_vfs_find(v);
|
||||
/* A NULL sqlite3_vfs pointer will be treated as the default
|
||||
VFS in many contexts. We specifically do not want that
|
||||
behavior here. */
|
||||
if(!x) sqlite3.SQLite3Error.toss("Unknown sqlite3_vfs name:",v);
|
||||
return x;
|
||||
}else if(v instanceof sqlite3.capi.sqlite3_vfs) v = v.pointer;
|
||||
return aPtr(v);
|
||||
return capi.sqlite3_vfs_find(v)
|
||||
|| sqlite3.SQLite3Error.toss("Unknown sqlite3_vfs name:",v);
|
||||
}
|
||||
return aPtr((v instanceof capi.sqlite3_vfs) ? v.pointer : v);
|
||||
});
|
||||
|
||||
wasm.xWrap.resultAdapter('sqlite3*', aPtr)
|
||||
@ -127,7 +118,7 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
|
||||
: fI64Disabled(e[0]);
|
||||
}
|
||||
|
||||
/* There's no(?) need to expose bindingSignatures to clients,
|
||||
/* There's no need to expose bindingSignatures to clients,
|
||||
implicitly making it part of the public interface. */
|
||||
delete wasm.bindingSignatures;
|
||||
|
||||
@ -141,21 +132,8 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
|
||||
return errCode;
|
||||
};
|
||||
}
|
||||
|
||||
}/*xWrap() bindings*/;
|
||||
|
||||
/**
|
||||
When registering a VFS and its related components it may be
|
||||
necessary to ensure that JS keeps a reference to them to keep
|
||||
them from getting garbage collected. Simply pass each such value
|
||||
to this function and a reference will be held to it for the life
|
||||
of the app.
|
||||
*/
|
||||
capi.sqlite3_vfs_register.addReference = function f(...args){
|
||||
if(!f._) f._ = [];
|
||||
f._.push(...args);
|
||||
};
|
||||
|
||||
/**
|
||||
Internal helper to assist in validating call argument counts in
|
||||
the hand-written sqlite3_xyz() wrappers. We do this only for
|
||||
@ -603,10 +581,11 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
|
||||
}
|
||||
wasm.ctype = JSON.parse(wasm.cstringToJs(cJson));
|
||||
//console.debug('wasm.ctype length =',wasm.cstrlen(cJson));
|
||||
const defineGroups = ['access', 'blobFinalizers', 'dataTypes',
|
||||
const defineGroups = ['access', 'authorizer',
|
||||
'blobFinalizers', 'dataTypes',
|
||||
'encodings', 'fcntl', 'flock', 'ioCap',
|
||||
'limits',
|
||||
'openFlags', 'prepareFlags', 'resultCodes',
|
||||
'limits', 'openFlags',
|
||||
'prepareFlags', 'resultCodes',
|
||||
'serialize', 'syncFlags', 'trace', 'udfFlags',
|
||||
'version' ];
|
||||
if(wasm.bigIntEnabled){
|
||||
@ -658,7 +637,10 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
|
||||
capi.sqlite3_index_info[k] = capi[k];
|
||||
delete capi[k];
|
||||
}
|
||||
}
|
||||
capi.sqlite3_vtab_config =
|
||||
(pDb, op, arg=0)=>wasm.exports.sqlite3_wasm_vtab_config(
|
||||
wasm.xWrap.argAdapter('sqlite3*')(pDb), op, arg);
|
||||
}/* end vtab-related setup */
|
||||
}/*end C constant and struct imports*/
|
||||
|
||||
const pKvvfs = capi.sqlite3_vfs_find("kvvfs");
|
||||
|
Reference in New Issue
Block a user