diff options
author | stephan <stephan@noemail.net> | 2022-12-08 18:18:37 +0000 |
---|---|---|
committer | stephan <stephan@noemail.net> | 2022-12-08 18:18:37 +0000 |
commit | 1a9a29815a82c6dc0fd05b314226199cdcc6b1ff (patch) | |
tree | 540ea43e377e09bf85c875ab32d95e90122478ff /ext/wasm/api/sqlite3-v-helper.js | |
parent | 500fa7d518c3ee7154732d8c4ada707476944367 (diff) | |
download | sqlite-1a9a29815a82c6dc0fd05b314226199cdcc6b1ff.tar.gz sqlite-1a9a29815a82c6dc0fd05b314226199cdcc6b1ff.zip |
Further docs and minor cleanups in the JS virtual table helper.
FossilOrigin-Name: c31e7488ac1a6b957782b72bd026b1f0590637b631e44a1fdf1dedeb5c587819
Diffstat (limited to 'ext/wasm/api/sqlite3-v-helper.js')
-rw-r--r-- | ext/wasm/api/sqlite3-v-helper.js | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/ext/wasm/api/sqlite3-v-helper.js b/ext/wasm/api/sqlite3-v-helper.js index a28fb389a..25f71556a 100644 --- a/ext/wasm/api/sqlite3-v-helper.js +++ b/ext/wasm/api/sqlite3-v-helper.js @@ -327,13 +327,19 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ }; /** - Internal helper for implementing xVtab and xCursor. - The first argument must be the logical name of the - handler ('xVtab' or 'xCursor') and the second must be - the capi.XYZ struct-type value, e.g. capi.sqlite3_vtab - or capi.sqlite3_vtab_cursor. + A factory function which implements a simple lifetime manager for + mappings between C struct pointers and their JS-level wrappers. + The first argument must be the logical name of the manager + (e.g. 'xVtab' or 'xCursor'), which is only used for error + reporting. The second must be the capi.XYZ struct-type value, + e.g. capi.sqlite3_vtab or capi.sqlite3_vtab_cursor. + + Returns an object with 4 methods: create(), get(), unget(), and + dispose(), plus a StructType member with the value of the 2nd + argument. The methods are documented in the body of this + function. */ - const __xLifetimeManager = function(name, StructType){ + const StructPtrMapper = function(name, StructType){ const __xWrap = __xWrapFactory(name,StructType); /** This object houses a small API for managing mappings of (`T*`) @@ -406,18 +412,18 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ instances in sqlite3_module methods to capi.sqlite3_vtab objects. - The API docs are in the API-internal __xLifetimeManager(). + The API docs are in the API-internal StructPtrMapper(). */ - vt.xVtab = __xLifetimeManager('xVtab', capi.sqlite3_vtab); + vt.xVtab = StructPtrMapper('xVtab', capi.sqlite3_vtab); /** A lifetime-management object for mapping `sqlite3_vtab_cursor*` instances in sqlite3_module methods to capi.sqlite3_vtab_cursor objects. - The API docs are in the API-internal __xLifetimeManager(). + The API docs are in the API-internal StructPtrMapper(). */ - vt.xCursor = __xLifetimeManager('xCursor', capi.sqlite3_vtab_cursor); + vt.xCursor = StructPtrMapper('xCursor', capi.sqlite3_vtab_cursor); /** Convenience form of creating an sqlite3_index_info wrapper, |