Add sqlite3changeset_new/old_js(), which work like sqlite3_preupdate_new/old_js() but on changesets.

FossilOrigin-Name: e8afad630b085a9208491e0516a6a30c9cda77a20b1aa2cba49b2f44eb9fa2f8
This commit is contained in:
stephan 2022-12-27 22:46:49 +00:00
parent 294968e030
commit 010ffff8d7
3 changed files with 39 additions and 19 deletions

View File

@ -1780,17 +1780,17 @@ self.sqlite3ApiBootstrap = function sqlite3ApiBootstrap(
};
/**
Internal impl of sqlite3_preupdate_new_js() and
sqlite3_preupdate_old_js().
Internal impl of sqlite3_preupdate_new/old_js() and
sqlite3changeset_new/old_js().
*/
const __preupdateNewOld = function(pDb, iCol, impl){
const __newOldValue = function(pObj, iCol, impl){
impl = capi[impl];
if(!this.ptr) this.ptr = wasm.allocPtr();
else wasm.pokePtr(this.ptr, 0);
const rc = impl(pDb, iCol, this.ptr);
return rc
? SQLite3Error.toss(rc,arguments[2]+"() failed with code "+rc)
: capi.sqlite3_value_to_js( wasm.peekPtr(this.ptr), true );
const rc = impl(pObj, iCol, this.ptr);
if(rc) return SQLite3Error.toss(rc,arguments[2]+"() failed with code "+rc);
const pv = wasm.peekPtr(this.ptr);
return pv ? capi.sqlite3_value_to_js( pv, true ) : undefined;
}.bind(Object.create(null));
/**
@ -1799,15 +1799,35 @@ self.sqlite3ApiBootstrap = function sqlite3ApiBootstrap(
passing it to sqlite3_value_to_js(). Throws on error.
*/
capi.sqlite3_preupdate_new_js =
(pDb, iCol)=>__preupdateNewOld(pDb, iCol, 'sqlite3_preupdate_new');
(pDb, iCol)=>__newOldValue(pDb, iCol, 'sqlite3_preupdate_new');
/**
A wrapper around sqlite3_preupdate_old() which fetches the
sqlite3_value at the given index and returns the result of
passing it to sqlite3_value_to_js(). Throws on error.
The sqlite3_preupdate_old() counterpart of
sqlite3_preupdate_new_js(), with an identical interface.
*/
capi.sqlite3_preupdate_old_js =
(pDb, iCol)=>__preupdateNewOld(pDb, iCol, 'sqlite3_preupdate_old');
(pDb, iCol)=>__newOldValue(pDb, iCol, 'sqlite3_preupdate_old');
/**
A wrapper around sqlite3changeset_new() which fetches the
sqlite3_value at the given index and returns the result of
passing it to sqlite3_value_to_js(). Throws on error.
If sqlite3changeset_new() succeeds but has no value to report,
this function returns the undefined value, noting that undefined
is a valid conversion from an `sqlite3_value`, so is unambiguous.
*/
capi.sqlite3changeset_new_js =
(pChangesetIter, iCol) => __newOldValue(pChangesetIter, iCol,
'sqlite3changeset_new');
/**
The sqlite3changeset_old() counterpart of
sqlite3changeset_new_js(), with an identical interface.
*/
capi.sqlite3changeset_old_js =
(pChangesetIter, iCol)=>__newOldValue(pChangesetIter, iCol,
'sqlite3changeset_old');
/* The remainder of the API will be set up in later steps. */
const sqlite3 = {

View File

@ -1,5 +1,5 @@
C Expose\ssqlite3_preupdate_hook()\sand\sfriends\sto\sthe\sJS\sAPI.
D 2022-12-27T14:34:32.202
C Add\ssqlite3changeset_new/old_js(),\swhich\swork\slike\ssqlite3_preupdate_new/old_js()\sbut\son\schangesets.
D 2022-12-27T22:46:49.004
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -505,7 +505,7 @@ F ext/wasm/api/pre-js.c-pp.js b88499dc303c21fc3f55f2c364a0f814f587b60a9578430388
F ext/wasm/api/sqlite3-api-cleanup.js 680d5ccfff54459db136a49b2199d9f879c8405d9c99af1dda0cc5e7c29056f4
F ext/wasm/api/sqlite3-api-glue.js a5f68e5cd6fe91528a10fe925c75c980440e4dcd02ef1db13a5eaa9c840a301b
F ext/wasm/api/sqlite3-api-oo1.js e9fba119e9b1716b3f731838ed1ab18741401bcf4c51d2a4a6e9d1d23cf9d771
F ext/wasm/api/sqlite3-api-prologue.js c53a482a38113d965914890cb8ab6f4c901558cc44c2073577e8f7fa2b28f269
F ext/wasm/api/sqlite3-api-prologue.js 0b9b463db92881990ab6995c863c5968969da3d2a5029112037cbf425c9cb6b1
F ext/wasm/api/sqlite3-api-worker1.js c9ef8865f072e61251260b218aa4ed614a21a25e9e3cc6f22acf81794d32fc0b
F ext/wasm/api/sqlite3-license-version-header.js a661182fc93fc2cf212dfd0b987f8e138a3ac98f850b1112e29b5fbdaecc87c3
F ext/wasm/api/sqlite3-opfs-async-proxy.js 7795b84b66a7a8dedc791340709b310bb497c3c72a80bef364fa2a58e2ddae3f
@ -2067,8 +2067,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P e3776796f55574f357eb429e20399389092a68e9ca00aa104ed33eb559ae0de5
R d834976b54fd785cca19e8460af50575
P cc02783a1210a083683320fae1ec1519e45b8e3003a9e32809d808513a2ce06b
R 4f85e5068b1f7d53223ca26505102a96
U stephan
Z ac4d1df745aa91809b44c04961ee6a48
Z b6fb88d70a94b98d9858b15a41c938e6
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
cc02783a1210a083683320fae1ec1519e45b8e3003a9e32809d808513a2ce06b
e8afad630b085a9208491e0516a6a30c9cda77a20b1aa2cba49b2f44eb9fa2f8