diff options
author | stephan <stephan@noemail.net> | 2022-10-03 08:21:06 +0000 |
---|---|---|
committer | stephan <stephan@noemail.net> | 2022-10-03 08:21:06 +0000 |
commit | ef9cd12ec4d14c836e198171eef3e04f674bb039 (patch) | |
tree | f8caf72f87a4bd2c8f192dfcc3c3ae953e4ad808 /ext/wasm/api/sqlite3-api-glue.js | |
parent | 510a9d1c6456a959f316353737f60e9300e600e4 (diff) | |
download | sqlite-ef9cd12ec4d14c836e198171eef3e04f674bb039.tar.gz sqlite-ef9cd12ec4d14c836e198171eef3e04f674bb039.zip |
Minor JS API tweaks prompted by documenting them.
FossilOrigin-Name: a82e6faaa642b09d241232c4daa67134d4dfa24bf3ca3725740346ca5269b381
Diffstat (limited to 'ext/wasm/api/sqlite3-api-glue.js')
-rw-r--r-- | ext/wasm/api/sqlite3-api-glue.js | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/ext/wasm/api/sqlite3-api-glue.js b/ext/wasm/api/sqlite3-api-glue.js index f80bade38..bbd5b446f 100644 --- a/ext/wasm/api/sqlite3-api-glue.js +++ b/ext/wasm/api/sqlite3-api-glue.js @@ -50,7 +50,7 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ 'flexible-string'-type arguments */ const xString = wasm.xWrap.argAdapter('string'); wasm.xWrap.argAdapter( - 'flexible-string', (v)=>xString(util.arrayToString(v)) + 'flexible-string', (v)=>xString(util.flexibleString(v)) ); } @@ -216,8 +216,8 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ "*"/*xInverse*/, "*"/*xDestroy*/] ); - const __setUdfResult = function(pCtx, val){ - //console.warn("setUdfResult",typeof val, val); + const __udfSetResult = function(pCtx, val){ + //console.warn("udfSetResult",typeof val, val); switch(typeof val) { case 'boolean': capi.sqlite3_result_int(pCtx, val ? 1 : 0); @@ -259,9 +259,9 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ default: toss3("Don't not how to handle this UDF result value:",(typeof val), val); }; - }/*__setUdfResult()*/; + }/*__udfSetResult()*/; - const __convertUdfArgs = function(argc, pArgv){ + const __udfConvertArgs = function(argc, pArgv){ let i, pVal, valType, arg; const tgt = []; for(i = 0; i < argc; ++i){ @@ -307,9 +307,9 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ tgt.push(arg); } return tgt; - }/*__convertUdfArgs()*/; + }/*__udfConvertArgs()*/; - const __setUdfError = (pCtx, e)=>{ + const __udfSetError = (pCtx, e)=>{ if(e instanceof sqlite3.WasmAllocError){ capi.sqlite3_result_error_nomem(pCtx); }else{ @@ -319,25 +319,25 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ const __xFunc = function(callback){ return function(pCtx, argc, pArgv){ - try{ __setUdfResult(pCtx, callback(pCtx, ...__convertUdfArgs(argc, pArgv))) } + try{ __udfSetResult(pCtx, callback(pCtx, ...__udfConvertArgs(argc, pArgv))) } catch(e){ //console.error('xFunc() caught:',e); - __setUdfError(pCtx, e); + __udfSetError(pCtx, e); } }; }; const __xInverseAndStep = function(callback){ return function(pCtx, argc, pArgv){ - try{ callback(pCtx, ...__convertUdfArgs(argc, pArgv)) } - catch(e){ __setUdfError(pCtx, e) } + try{ callback(pCtx, ...__udfConvertArgs(argc, pArgv)) } + catch(e){ __udfSetError(pCtx, e) } }; }; const __xFinalAndValue = function(callback){ return function(pCtx){ - try{ __setUdfResult(pCtx, callback(pCtx)) } - catch(e){ __setUdfError(pCtx, e) } + try{ __udfSetResult(pCtx, callback(pCtx)) } + catch(e){ __udfSetError(pCtx, e) } }; }; @@ -446,7 +446,7 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ }; /** A helper for UDFs implemented in JS and bound to WASM by the - client. Given a JS value, setUdfResult(pCtx,X) calls one of the + client. Given a JS value, udfSetResult(pCtx,X) calls one of the sqlite3_result_xyz(pCtx,...) routines, depending on X's data type: @@ -458,9 +458,9 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ Anything else triggers sqlite3_result_error(). */ - capi.sqlite3_create_function_v2.setUdfResult = - capi.sqlite3_create_function.setUdfResult = - capi.sqlite3_create_window_function.setUdfResult = __setUdfResult; + capi.sqlite3_create_function_v2.udfSetResult = + capi.sqlite3_create_function.udfSetResult = + capi.sqlite3_create_window_function.udfSetResult = __udfSetResult; /** A helper for UDFs implemented in JS and bound to WASM by the @@ -480,9 +480,9 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ The conversion will throw only on allocation error or an internal error. */ - capi.sqlite3_create_function_v2.convertUdfArgs = - capi.sqlite3_create_function.convertUdfArgs = - capi.sqlite3_create_window_function.convertUdfArgs = __convertUdfArgs; + capi.sqlite3_create_function_v2.udfConvertArgs = + capi.sqlite3_create_function.udfConvertArgs = + capi.sqlite3_create_window_function.udfConvertArgs = __udfConvertArgs; /** A helper for UDFs implemented in JS and bound to WASM by the @@ -492,9 +492,9 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ depending on whether the 2nd argument is a sqlite3.WasmAllocError object or not. */ - capi.sqlite3_create_function_v2.setUdfError = - capi.sqlite3_create_function.setUdfError = - capi.sqlite3_create_window_function.setUdfError = __setUdfError; + capi.sqlite3_create_function_v2.udfSetError = + capi.sqlite3_create_function.udfSetError = + capi.sqlite3_create_window_function.udfSetError = __udfSetError; }/*sqlite3_create_function_v2() and sqlite3_create_window_function() proxies*/; |