1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Export sqlite3_vtab_collation() to wasm. Rename 'flexible-string' JS argument adapter to 'string:flexible' for consistency.

FossilOrigin-Name: 15f8042fddaeabab43dd187c463d3ccc56758cbf19bf2ca4837d9087a4850c1a
This commit is contained in:
stephan
2022-12-05 13:12:48 +00:00
parent cf8f0d2046
commit 9a49a97487
7 changed files with 48 additions and 47 deletions

View File

@ -103,6 +103,7 @@ _sqlite3_value_type
_sqlite3_vfs_find _sqlite3_vfs_find
_sqlite3_vfs_register _sqlite3_vfs_register
_sqlite3_vfs_unregister _sqlite3_vfs_unregister
_sqlite3_vtab_collation
_sqlite3_vtab_distinct _sqlite3_vtab_distinct
_sqlite3_vtab_in _sqlite3_vtab_in
_sqlite3_vtab_in_first _sqlite3_vtab_in_first

View File

@ -38,10 +38,10 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
delete self.Jaccwabyt; delete self.Jaccwabyt;
{/* Convert Arrays and certain TypedArrays to strings for {/* Convert Arrays and certain TypedArrays to strings for
'flexible-string'-type arguments */ 'string:flexible'-type arguments */
const xString = wasm.xWrap.argAdapter('string'); const xString = wasm.xWrap.argAdapter('string');
wasm.xWrap.argAdapter( wasm.xWrap.argAdapter(
'flexible-string', (v)=>xString(util.flexibleString(v)) 'string:flexible', (v)=>xString(util.flexibleString(v))
); );
/** /**
@ -176,29 +176,9 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
(1===n?"":'s')+"."); (1===n?"":'s')+".");
}; };
/**
Helper for flexible-string conversions which require a
byte-length counterpart argument. Passed a value and its
ostensible length, this function returns [V,N], where V
is either v or a transformed copy of v and N is either n,
-1, or the byte length of v (if it's a byte array).
*/
const __flexiString = function(v,n){
if('string'===typeof v){
n = -1;
}else if(util.isSQLableTypedArray(v)){
n = v.byteLength;
v = util.typedArrayToString(v);
}else if(Array.isArray(v)){
v = v.join("");
n = -1;
}
return [v, n];
};
if(1){/* Special-case handling of sqlite3_exec() */ if(1){/* Special-case handling of sqlite3_exec() */
const __exec = wasm.xWrap("sqlite3_exec", "int", const __exec = wasm.xWrap("sqlite3_exec", "int",
["sqlite3*", "flexible-string", "*", "*", "**"]); ["sqlite3*", "string:flexible", "*", "*", "**"]);
/* Documented in the api object's initializer. */ /* Documented in the api object's initializer. */
capi.sqlite3_exec = function f(pDb, sql, callback, pVoid, pErrMsg){ capi.sqlite3_exec = function f(pDb, sql, callback, pVoid, pErrMsg){
if(f.length!==arguments.length){ if(f.length!==arguments.length){
@ -549,6 +529,26 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
if(1){/* Special-case handling of sqlite3_prepare_v2() and if(1){/* Special-case handling of sqlite3_prepare_v2() and
sqlite3_prepare_v3() */ sqlite3_prepare_v3() */
/**
Helper for string:flexible conversions which require a
byte-length counterpart argument. Passed a value and its
ostensible length, this function returns [V,N], where V
is either v or a transformed copy of v and N is either n,
-1, or the byte length of v (if it's a byte array).
*/
const __flexiString = (v,n)=>{
if('string'===typeof v){
n = -1;
}else if(util.isSQLableTypedArray(v)){
n = v.byteLength;
v = util.typedArrayToString(v);
}else if(Array.isArray(v)){
v = v.join("");
n = -1;
}
return [v, n];
};
/** /**
Scope-local holder of the two impls of sqlite3_prepare_v2/v3(). Scope-local holder of the two impls of sqlite3_prepare_v2/v3().
*/ */

View File

@ -192,13 +192,13 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
/** /**
Sets SQL which should be exec()'d on a DB instance after it is Sets SQL which should be exec()'d on a DB instance after it is
opened with the given VFS pointer. The SQL may be any type opened with the given VFS pointer. The SQL may be any type
supported by the "flexible-string" function argument supported by the "string:flexible" function argument conversion.
conversion. Alternately, the 2nd argument may be a function, in Alternately, the 2nd argument may be a function, in which case it
which case it is called with (theOo1DbObject,sqlite3Namespace) at is called with (theOo1DbObject,sqlite3Namespace) at the end of
the end of the DB() constructor. The function must throw on the DB() constructor. The function must throw on error, in which
error, in which case the db is closed and the exception is case the db is closed and the exception is propagated. This
propagated. This function is intended only for use by DB function is intended only for use by DB subclasses or sqlite3_vfs
subclasses or sqlite3_vfs implementations. implementations.
*/ */
dbCtorHelper.setVfsPostOpenSql = function(pVfs, sql){ dbCtorHelper.setVfsPostOpenSql = function(pVfs, sql){
__vfsPostOpenSql[pVfs] = sql; __vfsPostOpenSql[pVfs] = sql;

View File

@ -602,7 +602,7 @@ self.sqlite3ApiBootstrap = function sqlite3ApiBootstrap(
If the callback is not a JS function then this binding performs If the callback is not a JS function then this binding performs
no translation of the callback, but the sql argument is still no translation of the callback, but the sql argument is still
converted to a WASM string for the call using the converted to a WASM string for the call using the
"flexible-string" argument converter. "string:flexible" argument converter.
*/ */
sqlite3_exec: (pDb, sql, callback, pVoid, pErrMsg)=>{}/*installed later*/, sqlite3_exec: (pDb, sql, callback, pVoid, pErrMsg)=>{}/*installed later*/,
@ -910,7 +910,7 @@ self.sqlite3ApiBootstrap = function sqlite3ApiBootstrap(
["sqlite3_column_type","int", "sqlite3_stmt*", "int"], ["sqlite3_column_type","int", "sqlite3_stmt*", "int"],
["sqlite3_compileoption_get", "string", "int"], ["sqlite3_compileoption_get", "string", "int"],
["sqlite3_compileoption_used", "int", "string"], ["sqlite3_compileoption_used", "int", "string"],
["sqlite3_complete", "int", "flexible-string"], ["sqlite3_complete", "int", "string:flexible"],
/* sqlite3_create_function(), sqlite3_create_function_v2(), and /* sqlite3_create_function(), sqlite3_create_function_v2(), and
sqlite3_create_window_function() use hand-written bindings to sqlite3_create_window_function() use hand-written bindings to
simplify handling of their function-type arguments. */ simplify handling of their function-type arguments. */
@ -1012,7 +1012,7 @@ self.sqlite3ApiBootstrap = function sqlite3ApiBootstrap(
["sqlite3*","string","sqlite3_module*","*"]], ["sqlite3*","string","sqlite3_module*","*"]],
["sqlite3_create_module_v2", "int", ["sqlite3_create_module_v2", "int",
["sqlite3*","string","sqlite3_module*","*","*"]], ["sqlite3*","string","sqlite3_module*","*","*"]],
["sqlite3_declare_vtab", "int", ["sqlite3*", "flexible-string"]], ["sqlite3_declare_vtab", "int", ["sqlite3*", "string:flexible"]],
["sqlite3_drop_modules", "int", ["sqlite3*", "**"]], ["sqlite3_drop_modules", "int", ["sqlite3*", "**"]],
["sqlite3_malloc64", "*","i64"], ["sqlite3_malloc64", "*","i64"],
["sqlite3_msize", "i64", "*"], ["sqlite3_msize", "i64", "*"],
@ -1023,7 +1023,7 @@ self.sqlite3ApiBootstrap = function sqlite3ApiBootstrap(
["sqlite3_total_changes64", "i64", ["sqlite3*"]], ["sqlite3_total_changes64", "i64", ["sqlite3*"]],
["sqlite3_uri_int64", "i64", ["sqlite3_filename", "string", "i64"]], ["sqlite3_uri_int64", "i64", ["sqlite3_filename", "string", "i64"]],
["sqlite3_value_int64","i64", "sqlite3_value*"], ["sqlite3_value_int64","i64", "sqlite3_value*"],
//EXPERIMENTAL const char *sqlite3_vtab_collation(sqlite3_index_info*,int) ["sqlite3_vtab_collation","string","sqlite3_index_info*","int"],
["sqlite3_vtab_distinct","int", "sqlite3_index_info*"], ["sqlite3_vtab_distinct","int", "sqlite3_index_info*"],
["sqlite3_vtab_in","int", "sqlite3_index_info*", "int", "int"], ["sqlite3_vtab_in","int", "sqlite3_index_info*", "int", "int"],
["sqlite3_vtab_in_first", "int", "sqlite3_value*", "**"], ["sqlite3_vtab_in_first", "int", "sqlite3_value*", "**"],

View File

@ -671,9 +671,9 @@ self.sqlite3InitModule = sqlite3InitModule;
.assert(p1 === argAd('bar')); .assert(p1 === argAd('bar'));
} }
// 'flexible-string' argAdapter() sanity checks... // 'string:flexible' argAdapter() sanity checks...
w.scopedAllocCall(()=>{ w.scopedAllocCall(()=>{
const argAd = w.xWrap.argAdapter('flexible-string'); const argAd = w.xWrap.argAdapter('string:flexible');
const cj = (v)=>w.cstringToJs(argAd(v)); const cj = (v)=>w.cstringToJs(argAd(v));
T.assert('Hi' === cj('Hi')) T.assert('Hi' === cj('Hi'))
.assert('hi' === cj(['h','i'])) .assert('hi' === cj(['h','i']))

View File

@ -1,5 +1,5 @@
C Rename\s'static-string'\sargument\sadapter\sto\s'string:static'.\sReplace\sJS\sunit\stests\swhich\swere\slost\svia\sediting\sa\sgenerated\scopy\sof\stester1.js\sinstead\sof\sthe\soriginal\stester1.c-pp.js\sinput\sfile. C Export\ssqlite3_vtab_collation()\sto\swasm.\sRename\s'flexible-string'\sJS\sargument\sadapter\sto\s'string:flexible'\sfor\sconsistency.
D 2022-12-05T11:54:13.530 D 2022-12-05T13:12:48.698
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -494,7 +494,7 @@ F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34ce
F ext/wasm/GNUmakefile bfa47f169468ca9db031105b0e336db29a88e93c3abd217d0bbb2b8731fa5413 F ext/wasm/GNUmakefile bfa47f169468ca9db031105b0e336db29a88e93c3abd217d0bbb2b8731fa5413
F ext/wasm/README-dist.txt 2d670b426fc7c613b90a7d2f2b05b433088fe65181abead970980f0a4a75ea20 F ext/wasm/README-dist.txt 2d670b426fc7c613b90a7d2f2b05b433088fe65181abead970980f0a4a75ea20
F ext/wasm/README.md ef39861aa21632fdbca0bdd469f78f0096f6449a720f3f39642594af503030e9 F ext/wasm/README.md ef39861aa21632fdbca0bdd469f78f0096f6449a720f3f39642594af503030e9
F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api 21a7c443f496f891e5362db75884a5c3c72058559bbfbcae707ec5bbefd80de9 F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api e17dc504c135e0d9585282faa82bf8ef3c45465b086fb02fb5605e821efb5bbc
F ext/wasm/api/EXPORTED_RUNTIME_METHODS.sqlite3-api 1ec3c73e7d66e95529c3c64ac3de2470b0e9e7fbf7a5b41261c367cf4f1b7287 F ext/wasm/api/EXPORTED_RUNTIME_METHODS.sqlite3-api 1ec3c73e7d66e95529c3c64ac3de2470b0e9e7fbf7a5b41261c367cf4f1b7287
F ext/wasm/api/README.md 20a256f4aaae80035d2bb1c9e3e0a125570313a8d137d427471d7be10edde87a F ext/wasm/api/README.md 20a256f4aaae80035d2bb1c9e3e0a125570313a8d137d427471d7be10edde87a
F ext/wasm/api/extern-post-js.c-pp.js 8923f76c3d2213159e12d641dc750523ead5c848185dc4996fae5cc12397f88d F ext/wasm/api/extern-post-js.c-pp.js 8923f76c3d2213159e12d641dc750523ead5c848185dc4996fae5cc12397f88d
@ -503,9 +503,9 @@ F ext/wasm/api/post-js-footer.js cd0a8ec768501d9bd45d325ab0442037fb0e33d1f3b4f08
F ext/wasm/api/post-js-header.js 47b6b281f39ad59fa6e8b658308cd98ea292c286a68407b35ff3ed9cfd281a62 F ext/wasm/api/post-js-header.js 47b6b281f39ad59fa6e8b658308cd98ea292c286a68407b35ff3ed9cfd281a62
F ext/wasm/api/pre-js.c-pp.js b88499dc303c21fc3f55f2c364a0f814f587b60a95784303881169f9e91c1d5f 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-cleanup.js 680d5ccfff54459db136a49b2199d9f879c8405d9c99af1dda0cc5e7c29056f4
F ext/wasm/api/sqlite3-api-glue.js 2c45a3c05badb11c37152d9d819156420a5c026ef9cf6fee97512b279b33bf44 F ext/wasm/api/sqlite3-api-glue.js e3422737c64bb6d871ddff7f7c85e637cc1597edd3bc49ef537578c57d6cfaa9
F ext/wasm/api/sqlite3-api-oo1.js 91a7d7b9203fb0f031e6ba380a644a7f871e1798b388de399c01ed4087bac9e0 F ext/wasm/api/sqlite3-api-oo1.js 793883953d4024e7b8c5ee1c7a6cb49c18ca53a1d235a203f93746f8907d32ba
F ext/wasm/api/sqlite3-api-prologue.js 0dba5a99f795ce6bb88b621960cc3f5f3e6370ee6f16230a0b165136529fcf40 F ext/wasm/api/sqlite3-api-prologue.js 6f5aee50867dae4e0885dd1bd1913f1f42f433def15ca9309dc5b3e83ab5c667
F ext/wasm/api/sqlite3-api-worker1.js e94ba98e44afccfa482874cd9acb325883ade50ed1f9f9526beb9de1711f182f F ext/wasm/api/sqlite3-api-worker1.js e94ba98e44afccfa482874cd9acb325883ade50ed1f9f9526beb9de1711f182f
F ext/wasm/api/sqlite3-license-version-header.js a661182fc93fc2cf212dfd0b987f8e138a3ac98f850b1112e29b5fbdaecc87c3 F ext/wasm/api/sqlite3-license-version-header.js a661182fc93fc2cf212dfd0b987f8e138a3ac98f850b1112e29b5fbdaecc87c3
F ext/wasm/api/sqlite3-opfs-async-proxy.js f79dd8d98ef3e0b55c10bb2bee7a3840fa967318e1f577c156aafc34664271d1 F ext/wasm/api/sqlite3-opfs-async-proxy.js f79dd8d98ef3e0b55c10bb2bee7a3840fa967318e1f577c156aafc34664271d1
@ -555,7 +555,7 @@ F ext/wasm/test-opfs-vfs.html 1f2d672f3f3fce810dfd48a8d56914aba22e45c6834e262555
F ext/wasm/test-opfs-vfs.js 44363db07b2a20e73b0eb1808de4400ca71b703af718d0fa6d962f15e73bf2ac F ext/wasm/test-opfs-vfs.js 44363db07b2a20e73b0eb1808de4400ca71b703af718d0fa6d962f15e73bf2ac
F ext/wasm/tester1-worker.html 29b1d87f7d51f70d61645719fee657f3787fe939bb695f27034c75404e8f1e6f F ext/wasm/tester1-worker.html 29b1d87f7d51f70d61645719fee657f3787fe939bb695f27034c75404e8f1e6f
F ext/wasm/tester1.c-pp.html 74aa9b31c75f12490653f814b53c3dd39f40cd3f70d6a53a716f4e8587107399 F ext/wasm/tester1.c-pp.html 74aa9b31c75f12490653f814b53c3dd39f40cd3f70d6a53a716f4e8587107399
F ext/wasm/tester1.c-pp.js d03c8c50063ec82d38694db077fc75af390c8baa0f72eb52d3c4e4fde68ee95e F ext/wasm/tester1.c-pp.js 419a2fd31b0230e0495ed38a56dbe1e2bbc93c5953b796de43e2a70901970b83
F ext/wasm/tests/opfs/concurrency/index.html 86d8ac435074d1e7007b91105f4897f368c165e8cecb6a9aa3d81f5cf5dcbe70 F ext/wasm/tests/opfs/concurrency/index.html 86d8ac435074d1e7007b91105f4897f368c165e8cecb6a9aa3d81f5cf5dcbe70
F ext/wasm/tests/opfs/concurrency/test.js a98016113eaf71e81ddbf71655aa29b0fed9a8b79a3cdd3620d1658eb1cc9a5d F ext/wasm/tests/opfs/concurrency/test.js a98016113eaf71e81ddbf71655aa29b0fed9a8b79a3cdd3620d1658eb1cc9a5d
F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2 F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2
@ -2065,8 +2065,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P a94552434a657376d5ce1831de05c1b15fb153020848cd825fb0df413c3baa70 P 9d81d51d5a255b42f8416da850c992a9e4c8eebc940e0702a9262cfcaa6d7b2f
R 3e5f8074bc013b334ba01f938431dc3c R 277425a2c74bda828b2402faf303a6b1
U stephan U stephan
Z 6b18e44631fce1838526a30c03df5312 Z c0b7c94a232e1e96230a439e5bd96242
# Remove this line to create a well-formed Fossil manifest. # Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
9d81d51d5a255b42f8416da850c992a9e4c8eebc940e0702a9262cfcaa6d7b2f 15f8042fddaeabab43dd187c463d3ccc56758cbf19bf2ca4837d9087a4850c1a