wasm.bindingSignatures = [
// Please keep these sorted by function name!
["sqlite3_aggregate_context","void*", "sqlite3_context*", "int"],
+ /* sqlite3_auto_extension() has a hand-written binding. */
/* sqlite3_bind_blob() and sqlite3_bind_text() have hand-written
bindings to permit more flexible inputs. */
["sqlite3_bind_double","int", "sqlite3_stmt*", "int", "f64"],
"*"
]],
["sqlite3_busy_timeout","int", "sqlite3*", "int"],
- /*[sqlite3_close_v2() is implemented by hand to perform some
- extra work. "sqlite3_close_v2", "int", "sqlite3*"],*/
+ /* sqlite3_cancel_auto_extension() has a hand-written binding. */
+ /* sqlite3_close_v2() is implemented by hand to perform some
+ extra work. */
["sqlite3_changes", "int", "sqlite3*"],
["sqlite3_clear_bindings","int", "sqlite3_stmt*"],
["sqlite3_collation_needed", "int", "sqlite3*", "*", "*"/*=>v(ppis)*/],
]],
["sqlite3_realloc", "*","*","int"],
["sqlite3_reset", "int", "sqlite3_stmt*"],
+ /* sqlite3_reset_auto_extension() has a hand-written binding. */
["sqlite3_result_blob", undefined, "sqlite3_context*", "*", "int", "*"],
["sqlite3_result_double", undefined, "sqlite3_context*", "f64"],
["sqlite3_result_error", undefined, "sqlite3_context*", "string", "int"],
});
delete self.Jaccwabyt;
- {/* Convert Arrays and certain TypedArrays to strings for
- 'string:flexible'-type arguments */
+ {// wasm.xWrap() bindings...
+
+ /* Convert Arrays and certain TypedArrays to strings for
+ 'string:flexible'-type arguments */
const __xString = wasm.xWrap.argAdapter('string');
wasm.xWrap.argAdapter(
'string:flexible', (v)=>__xString(util.flexibleString(v))
return rc || (this[v] = wasm.allocCString(v));
}.bind(Object.create(null))
);
- }/* special-case string-type argument conversions */
- if(1){// wasm.xWrap() bindings...
/**
Add some descriptive xWrap() aliases for '*' intended to (A)
initially improve readability/correctness of
from higher-level representations, e.g. capi.sqlite3_vfs to
`sqlite3_vfs*` via capi.sqlite3_vfs.pointer.
*/
- const aPtr = wasm.xWrap.argAdapter('*');
- const nilType = function(){};
- wasm.xWrap.argAdapter('sqlite3_filename', aPtr)
- ('sqlite3_context*', aPtr)
- ('sqlite3_value*', aPtr)
- ('void*', aPtr)
- ('sqlite3_changegroup*', aPtr)
- ('sqlite3_changeset_iter*', aPtr)
- //('sqlite3_rebaser*', aPtr)
- ('sqlite3_session*', aPtr)
+ const __xArgPtr = wasm.xWrap.argAdapter('*');
+ const nilType = function(){}/*a class no value can ever be an instance of*/;
+ wasm.xWrap.argAdapter('sqlite3_filename', __xArgPtr)
+ ('sqlite3_context*', __xArgPtr)
+ ('sqlite3_value*', __xArgPtr)
+ ('void*', __xArgPtr)
+ ('sqlite3_changegroup*', __xArgPtr)
+ ('sqlite3_changeset_iter*', __xArgPtr)
+ //('sqlite3_rebaser*', __xArgPtr)
+ ('sqlite3_session*', __xArgPtr)
('sqlite3_stmt*', (v)=>
- aPtr((v instanceof (sqlite3?.oo1?.Stmt || nilType))
+ __xArgPtr((v instanceof (sqlite3?.oo1?.Stmt || nilType))
? v.pointer : v))
('sqlite3*', (v)=>
- aPtr((v instanceof (sqlite3?.oo1?.DB || nilType))
+ __xArgPtr((v instanceof (sqlite3?.oo1?.DB || nilType))
? v.pointer : v))
('sqlite3_index_info*', (v)=>
- aPtr((v instanceof (capi.sqlite3_index_info || nilType))
+ __xArgPtr((v instanceof (capi.sqlite3_index_info || nilType))
? v.pointer : v))
('sqlite3_module*', (v)=>
- aPtr((v instanceof (capi.sqlite3_module || nilType))
+ __xArgPtr((v instanceof (capi.sqlite3_module || nilType))
? v.pointer : v))
/**
`sqlite3_vfs*`:
"Unknown sqlite3_vfs name:", v
);
}
- return aPtr((v instanceof (capi.sqlite3_vfs || nilType))
- ? v.pointer : v);
+ return __xArgPtr((v instanceof (capi.sqlite3_vfs || nilType))
+ ? v.pointer : v);
});
const __xRcPtr = wasm.xWrap.resultAdapter('*');
return errCode;
};
}
- }/*xWrap() bindings*/;
+ }/*xWrap() bindings*/
+
+ {/* Import C-level constants and structs... */
+ const cJson = wasm.xCall('sqlite3_wasm_enum_json');
+ if(!cJson){
+ toss("Maintenance required: increase sqlite3_wasm_enum_json()'s",
+ "static buffer size!");
+ }
+ //console.debug('wasm.ctype length =',wasm.cstrlen(cJson));
+ wasm.ctype = JSON.parse(wasm.cstrToJs(cJson));
+ // Groups of SQLITE_xyz macros...
+ const defineGroups = ['access', 'authorizer',
+ 'blobFinalizers', 'changeset',
+ 'config', 'dataTypes',
+ 'dbConfig', 'dbStatus',
+ 'encodings', 'fcntl', 'flock', 'ioCap',
+ 'limits', 'openFlags',
+ 'prepareFlags', 'resultCodes',
+ 'sqlite3Status',
+ 'stmtStatus', 'syncFlags',
+ 'trace', 'txnState', 'udfFlags',
+ 'version' ];
+ if(wasm.bigIntEnabled){
+ defineGroups.push('serialize', 'session', 'vtab');
+ }
+ for(const t of defineGroups){
+ for(const e of Object.entries(wasm.ctype[t])){
+ // ^^^ [k,v] there triggers a buggy code transformation via
+ // one of the Emscripten-driven optimizers.
+ capi[e[0]] = e[1];
+ }
+ }
+ const __rcMap = Object.create(null);
+ for(const t of ['resultCodes']){
+ for(const e of Object.entries(wasm.ctype[t])){
+ __rcMap[e[1]] = e[0];
+ }
+ }
+ /**
+ For the given integer, returns the SQLITE_xxx result code as a
+ string, or undefined if no such mapping is found.
+ */
+ capi.sqlite3_js_rc_str = (rc)=>__rcMap[rc];
+ /* Bind all registered C-side structs... */
+ const notThese = Object.assign(Object.create(null),{
+ // For each struct to NOT register, map its name to true:
+ WasmTestStruct: true,
+ /* We unregister the kvvfs VFS from Worker threads below. */
+ sqlite3_kvvfs_methods: !util.isUIThread(),
+ /* sqlite3_index_info and friends require int64: */
+ sqlite3_index_info: !wasm.bigIntEnabled,
+ sqlite3_index_constraint: !wasm.bigIntEnabled,
+ sqlite3_index_orderby: !wasm.bigIntEnabled,
+ sqlite3_index_constraint_usage: !wasm.bigIntEnabled
+ });
+ for(const s of wasm.ctype.structs){
+ if(!notThese[s.name]){
+ capi[s.name] = sqlite3.StructBinder(s);
+ }
+ }
+ if(capi.sqlite3_index_info){
+ /* Move these inner structs into sqlite3_index_info. Binding
+ ** them to WASM requires that we create global-scope structs to
+ ** model them with, but those are no longer needed after we've
+ ** passed them to StructBinder. */
+ for(const k of ['sqlite3_index_constraint',
+ 'sqlite3_index_orderby',
+ 'sqlite3_index_constraint_usage']){
+ capi.sqlite3_index_info[k] = capi[k];
+ delete capi[k];
+ }
+ capi.sqlite3_vtab_config = wasm.xWrap(
+ 'sqlite3_wasm_vtab_config','int',[
+ 'sqlite3*', 'int', 'int']
+ );
+ }/* end vtab-related setup */
+ }/*end C constant and struct imports*/
/**
Internal helper to assist in validating call argument counts in
*/
__dbCleanupMap.cleanup = function(pDb){
pDb = __argPDb(pDb);
- wasm.xWrap.FuncPtrAdapter.debugFuncInstall = true;
+ wasm.xWrap.FuncPtrAdapter.debugFuncInstall = false;
/**
Installing NULL functions in the C API will remove those
bindings. The FuncPtrAdapter which sits between us and the C
}/*sqlite3_create_function_v2() and sqlite3_create_window_function() proxies*/;
- if(1){/* Special-case handling of sqlite3_prepare_v2() and
- sqlite3_prepare_v3() */
+ {/* Special-case handling of sqlite3_prepare_v2() and
+ sqlite3_prepare_v3() */
/**
Helper for string:flexible conversions which require a
};
}/* sqlite3_config() */
- {/* Import C-level constants and structs... */
- const cJson = wasm.xCall('sqlite3_wasm_enum_json');
- if(!cJson){
- toss("Maintenance required: increase sqlite3_wasm_enum_json()'s",
- "static buffer size!");
- }
- //console.debug('wasm.ctype length =',wasm.cstrlen(cJson));
- wasm.ctype = JSON.parse(wasm.cstrToJs(cJson));
- // Groups of SQLITE_xyz macros...
- const defineGroups = ['access', 'authorizer',
- 'blobFinalizers', 'changeset',
- 'config', 'dataTypes',
- 'dbConfig', 'dbStatus',
- 'encodings', 'fcntl', 'flock', 'ioCap',
- 'limits', 'openFlags',
- 'prepareFlags', 'resultCodes',
- 'sqlite3Status',
- 'stmtStatus', 'syncFlags',
- 'trace', 'txnState', 'udfFlags',
- 'version' ];
- if(wasm.bigIntEnabled){
- defineGroups.push('serialize', 'session', 'vtab');
- }
- for(const t of defineGroups){
- for(const e of Object.entries(wasm.ctype[t])){
- // ^^^ [k,v] there triggers a buggy code transformation via
- // one of the Emscripten-driven optimizers.
- capi[e[0]] = e[1];
- }
- }
- const __rcMap = Object.create(null);
- for(const t of ['resultCodes']){
- for(const e of Object.entries(wasm.ctype[t])){
- __rcMap[e[1]] = e[0];
- }
- }
- /**
- For the given integer, returns the SQLITE_xxx result code as a
- string, or undefined if no such mapping is found.
- */
- capi.sqlite3_js_rc_str = (rc)=>__rcMap[rc];
- /* Bind all registered C-side structs... */
- const notThese = Object.assign(Object.create(null),{
- // For each struct to NOT register, map its name to true:
- WasmTestStruct: true,
- /* We unregister the kvvfs VFS from Worker threads below. */
- sqlite3_kvvfs_methods: !util.isUIThread(),
- /* sqlite3_index_info and friends require int64: */
- sqlite3_index_info: !wasm.bigIntEnabled,
- sqlite3_index_constraint: !wasm.bigIntEnabled,
- sqlite3_index_orderby: !wasm.bigIntEnabled,
- sqlite3_index_constraint_usage: !wasm.bigIntEnabled
- });
- for(const s of wasm.ctype.structs){
- if(!notThese[s.name]){
- capi[s.name] = sqlite3.StructBinder(s);
+ {/*auto-extension bindings.*/
+ const __autoExtFptr = new Set;
+
+ capi.sqlite3_auto_extension = function(fPtr){
+ if( fPtr instanceof Function ){
+ fPtr = wasm.installFunction('i(ppp)', fPtr);
+ }else if( 1!==arguments.length || !wasm.isPtr(fPtr) ){
+ return capi.SQLITE_MISUSE;
}
- }
- if(capi.sqlite3_index_info){
- /* Move these inner structs into sqlite3_index_info. Binding
- ** them to WASM requires that we create global-scope structs to
- ** model them with, but those are no longer needed after we've
- ** passed them to StructBinder. */
- for(const k of ['sqlite3_index_constraint',
- 'sqlite3_index_orderby',
- 'sqlite3_index_constraint_usage']){
- capi.sqlite3_index_info[k] = capi[k];
- delete capi[k];
+ const rc = wasm.exports.sqlite3_auto_extension(fPtr);
+ if( fPtr!==arguments[0] ){
+ if(0===rc) __autoExtFptr.add(fPtr);
+ else wasm.uninstallFunction(fPtr);
}
- capi.sqlite3_vtab_config = wasm.xWrap(
- 'sqlite3_wasm_vtab_config','int',[
- 'sqlite3*', 'int', 'int']
- );
- }/* end vtab-related setup */
- }/*end C constant and struct imports*/
+ return rc;
+ };
+
+ capi.sqlite3_cancel_auto_extension = function(fPtr){
+ /* We do not do an automatic JS-to-WASM function conversion here
+ because it would be senseless: the converted pointer would
+ never possibly match an already-installed one. */;
+ if(!fPtr || 1!==arguments.length || !wasm.isPtr(fPtr)) return 0;
+ return wasm.exports.sqlite3_cancel_auto_extension(fPtr);
+ /* Note that it "cannot happen" that a client passes a pointer which
+ is in __autoExtFptr because __autoExtFptr only contains automatic
+ conversions created inside sqlite3_auto_extension() and
+ never exposed to the client. */
+ };
+
+ capi.sqlite3_reset_auto_extension = function(){
+ wasm.exports.sqlite3_reset_auto_extension();
+ for(const fp of __autoExtFptr) wasm.uninstallFunction(fp);
+ __autoExtFptr.clear();
+ };
+ }/* auto-extension */
const pKvvfs = capi.sqlite3_vfs_find("kvvfs");
if( pKvvfs ){/* kvvfs-specific glue */
-C Fix\san\sinfinite\sloop\sin\sthe\sMEMSYS5\sauxiliary\smemory\sallocator\sthat\soccurs\nfor\smemory\sallocations\sbetween\s1GiB\sand\s2GiB\sin\ssize.\s\sError\sintroduced\nby\scheck-in\s[949133231f8f751a].\s\sThe\sproblem\sonly\saffects\sbuilds\sthat\ninclude\sthe\sSQLITE_ENABLE_MEMSYS5\scompile-time\soption.
-D 2022-12-26T15:14:24.028
+C Expose\sthe\sauto-extension\sAPI\sto\sJS\sand\sreorganize\ssome\snearby\scode.
+D 2022-12-26T17:15:05.417
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
F ext/wasm/GNUmakefile ffe0e9818a3b6b36c85a1d10dab76b220a8f5cd83439c62e50223a7970b3d68a
F ext/wasm/README-dist.txt 2d670b426fc7c613b90a7d2f2b05b433088fe65181abead970980f0a4a75ea20
F ext/wasm/README.md ef39861aa21632fdbca0bdd469f78f0096f6449a720f3f39642594af503030e9
-F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api beec6b5993e234153446aaa48e68d2a75db590b3c7eed26bd61e5fb5f8c9a881
+F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api 1e61a3ff4085974080ecf782d4defea6b7d443eaa98f9aea773b5f5b416b417c
F ext/wasm/api/EXPORTED_RUNTIME_METHODS.sqlite3-api 1ec3c73e7d66e95529c3c64ac3de2470b0e9e7fbf7a5b41261c367cf4f1b7287
F ext/wasm/api/README.md 77a2f1f2fc60a35def7455dffc8d3f2c56385d6ac5c6cecc60fa938252ea2c54
F ext/wasm/api/extern-post-js.c-pp.js 8923f76c3d2213159e12d641dc750523ead5c848185dc4996fae5cc12397f88d
F ext/wasm/api/post-js-header.js 47b6b281f39ad59fa6e8b658308cd98ea292c286a68407b35ff3ed9cfd281a62
F ext/wasm/api/pre-js.c-pp.js b88499dc303c21fc3f55f2c364a0f814f587b60a95784303881169f9e91c1d5f
F ext/wasm/api/sqlite3-api-cleanup.js 680d5ccfff54459db136a49b2199d9f879c8405d9c99af1dda0cc5e7c29056f4
-F ext/wasm/api/sqlite3-api-glue.js e16bf1de4c08d3906298d532e1e61478791286e768d7ba1538ca90d0fa344e12
+F ext/wasm/api/sqlite3-api-glue.js b55e13aadf33a037e9a6950f370d16e2b0e858b74a2070faa2c87d7cde48c80c
F ext/wasm/api/sqlite3-api-oo1.js 045c98796950c22556fc0842fe9f0d9a67f31920f247e24fb440571cdb6be5b0
F ext/wasm/api/sqlite3-api-prologue.js e862e5b79d565bd79c8ff59ebb6618a07ecb1a0262a1560dc6a10aa0f4d6f531
F ext/wasm/api/sqlite3-api-worker1.js c9ef8865f072e61251260b218aa4ed614a21a25e9e3cc6f22acf81794d32fc0b
F ext/wasm/common/SqliteTestUtil.js d8bf97ecb0705a2299765c8fc9e11b1a5ac7f10988bbf375a6558b7ca287067b
F ext/wasm/common/emscripten.css 11bd104b6c0d597c67d40cc8ecc0a60dae2b965151e3b6a37fa5708bac3acd15
F ext/wasm/common/testing.css 0ff15602a3ab2bad8aef2c3bd120c7ee3fd1c2054ad2ace7e214187ae68d926f
-F ext/wasm/common/whwasmutil.js 63188a5b90de3c17a2fdf3f1a90321ffdeaa2c34f6ca9d76f830fb0800867854
+F ext/wasm/common/whwasmutil.js cad510071533dbe47787bce53f2e0dcab5b05d2dde1dbe477d8fb04e00d4e8c4
F ext/wasm/demo-123-worker.html a0b58d9caef098a626a1a1db567076fca4245e8d60ba94557ede8684350a81ed
F ext/wasm/demo-123.html 8c70a412ce386bd3796534257935eb1e3ea5c581e5d5aea0490b8232e570a508
F ext/wasm/demo-123.js ebae30756585bca655b4ab2553ec9236a87c23ad24fc8652115dcedb06d28df6
F ext/wasm/test-opfs-vfs.js f09266873e1a34d9bdb6d3981ec8c9e382f31f215c9fd2f9016d2394b8ae9b7b
F ext/wasm/tester1-worker.html d43f3c131d88f10d00aff3e328fed13c858d674ea2ff1ff90225506137f85aa9
F ext/wasm/tester1.c-pp.html d34bef3d48e5cbc1c7c06882ad240fec49bf88f5f65696cc2c72c416933aa406
-F ext/wasm/tester1.c-pp.js 4a5b1a1f5296686f04db017e5984230a266f2c09f1e8d25d76682566b5cacbc2
+F ext/wasm/tester1.c-pp.js 93e3ebae7f0caa1b54265447f76b0485d4a28799e02b7c2a3cc92883aa84fda6
F ext/wasm/tests/opfs/concurrency/index.html 86d8ac435074d1e7007b91105f4897f368c165e8cecb6a9aa3d81f5cf5dcbe70
F ext/wasm/tests/opfs/concurrency/test.js a98016113eaf71e81ddbf71655aa29b0fed9a8b79a3cdd3620d1658eb1cc9a5d
F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P ae3ae92ec45d3d5de92e70876502f8108fc3fcd87848e86c2b83f8842f1ff139
-R af6df6d036a8bd991cf092623d05af75
-U drh
-Z 333253e835d0b6bf644788ba3ea65af5
+P 8da0f0c38a458c57f979d59b49cf4804ef81fc2eccabde1f166bab24dd1dabea
+R c287fdd5af6e6026238c7a465fc6dd21
+U stephan
+Z 8fd2961047ac7596d6fac75a1b2c944b
# Remove this line to create a well-formed Fossil manifest.