diff options
author | stephan <stephan@noemail.net> | 2023-08-29 15:39:57 +0000 |
---|---|---|
committer | stephan <stephan@noemail.net> | 2023-08-29 15:39:57 +0000 |
commit | 69a55ca17dc711a9b75eb738ab32336936d69fd7 (patch) | |
tree | e92325eb53315ca7872162ac4081cefc2da669dd /ext/wasm/api/sqlite3-api-prologue.js | |
parent | 0fc20a32c0fce51c34714363173c8a93771c1425 (diff) | |
download | sqlite-69a55ca17dc711a9b75eb738ab32336936d69fd7.tar.gz sqlite-69a55ca17dc711a9b75eb738ab32336936d69fd7.zip |
Get the JS SQLTester command handlers in place sans those which have to run SQL.
FossilOrigin-Name: d21b1217964a53f33b7ba3958b34aa8560dff8ede33e66f54aa0afbab7099ec3
Diffstat (limited to 'ext/wasm/api/sqlite3-api-prologue.js')
-rw-r--r-- | ext/wasm/api/sqlite3-api-prologue.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/ext/wasm/api/sqlite3-api-prologue.js b/ext/wasm/api/sqlite3-api-prologue.js index 5abb13b99..35c856269 100644 --- a/ext/wasm/api/sqlite3-api-prologue.js +++ b/ext/wasm/api/sqlite3-api-prologue.js @@ -1135,7 +1135,23 @@ globalThis.sqlite3ApiBootstrap = function sqlite3ApiBootstrap( return 1===n ? wasm.pstack.alloc(safePtrSize ? 8 : wasm.ptrSizeof) : wasm.pstack.allocChunks(n, safePtrSize ? 8 : wasm.ptrSizeof); + }, + + /** + Records the current pstack position, calls the given function, + and restores the pstack regardless of whether the function + throws. Returns the result of the call or propagates an + exception on error. + + Added in 3.44. + */ + call: function(f){ + const stackPos = wasm.pstack.pointer; + try{ return f() }finally{ + wasm.pstack.restore(stackPos); + } } + })/*wasm.pstack*/; Object.defineProperties(wasm.pstack, { /** @@ -1543,6 +1559,26 @@ globalThis.sqlite3ApiBootstrap = function sqlite3ApiBootstrap( } }; + /** + If v is a string, it is returned as-is. If it is-a Array, its + join("") result is returned. If is is a Uint8Array, Int8Array, + or ArrayBuffer, it is assumed to hold UTF-8-encoded text and is + decoded to a string. If it looks like a WASM pointer, + wasm.cstrToJs(sql) is returned. Else undefined is returned. + + The intent of this function is to convert SQL input text from a + variety of common forms to plain strings. + + Added in 3.44 + */ + capi.sqlite3_js_sql_to_string = (sql)=>{ + if('string' === typeof sql){ + return sql; + } + const x = flexibleString(v); + return x===v ? undefined : x; + } + if( util.isUIThread() ){ /* Features specific to the main window thread... */ |