1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-12-24 14:17:58 +03:00

Expand "sqlite3_vfs*" JS-to-WASM function argument conversions to accept VFS names (JS strings) and capi.sqlite3_vfs instances. Implement sqlite3_js_vfs_create_file() to facilitate creation of file-upload features which store the file in VFS-specific storage (where possible, e.g. "unix" and "opfs" VFSes). Correct an argument type check in the SQLite3Error and WasmAllocError constructors.

FossilOrigin-Name: e1009b16d351b23676ad7bffab0c91b373a92132eb855c9af61991b50cd237ed
This commit is contained in:
stephan
2022-12-01 03:55:28 +00:00
parent 85ec20ac66
commit 2b2199570d
6 changed files with 225 additions and 64 deletions

View File

@@ -1313,7 +1313,7 @@ self.WhWasmUtilInstaller = function(target){
const __xResultAdapterCheck =
(t)=>xcv.result[t] || toss("Result adapter not found:",t);
cache.xWrap.convertArg = (t,v)=>__xArgAdapterCheck(t)(v);
cache.xWrap.convertResult =
(t,v)=>(null===t ? v : (t ? __xResultAdapterCheck(t)(v) : undefined));
@@ -1442,7 +1442,7 @@ self.WhWasmUtilInstaller = function(target){
exception.
Clients may map their own result and argument adapters using
xWrap.resultAdapter() and xWrap.argAdaptor(), noting that not all
xWrap.resultAdapter() and xWrap.argAdapter(), noting that not all
type conversions are valid for both arguments _and_ result types
as they often have different memory ownership requirements.
@@ -1497,7 +1497,7 @@ self.WhWasmUtilInstaller = function(target){
};
}/*xWrap()*/;
/** Internal impl for xWrap.resultAdapter() and argAdaptor(). */
/** Internal impl for xWrap.resultAdapter() and argAdapter(). */
const __xAdapter = function(func, argc, typeName, adapter, modeName, xcvPart){
if('string'===typeof typeName){
if(1===argc) return xcvPart[typeName];
@@ -1575,7 +1575,7 @@ self.WhWasmUtilInstaller = function(target){
*/
target.xWrap.argAdapter = function f(typeName, adapter){
return __xAdapter(f, arguments.length, typeName, adapter,
'argAdaptor()', xcv.arg);
'argAdapter()', xcv.arg);
};
/**
@@ -1601,6 +1601,33 @@ self.WhWasmUtilInstaller = function(target){
return target.xWrap(fname, resultType, argTypes||[]).apply(null, args||[]);
};
/**
This function is ONLY exposed in the public API to facilitate
testing. It should not be used in application-level code, only
in test code.
Expects to be given (typeName, value) and returns a conversion
of that value as has been registered using argAdapter().
It throws if no adapter is found.
ACHTUNG: the adapter may require that a scopedAllocPush() is
active and it may allocate memory within that scope.
*/
target.xWrap.testConvertArg = cache.xWrap.convertArg;
/**
This function is ONLY exposed in the public API to facilitate
testing. It should not be used in application-level code, only
in test code.
Expects to be given (typeName, value) and returns a conversion
of that value as has been registered using resultAdapter().
It throws if no adapter is found.
ACHTUNG: the adapter may allocate memory which the caller may need
to know how to free.
*/
target.xWrap.testConvertResult = cache.xWrap.convertResult;
return target;
};