diff options
Diffstat (limited to 'ext/wasm/api/sqlite3-api-glue.js')
-rw-r--r-- | ext/wasm/api/sqlite3-api-glue.js | 36 |
1 files changed, 8 insertions, 28 deletions
diff --git a/ext/wasm/api/sqlite3-api-glue.js b/ext/wasm/api/sqlite3-api-glue.js index 91b42cd93..972b4a2e0 100644 --- a/ext/wasm/api/sqlite3-api-glue.js +++ b/ext/wasm/api/sqlite3-api-glue.js @@ -138,7 +138,7 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ the range of supported argument types. */ [ "sqlite3_progress_handler", undefined, [ - "sqlite3*", "int", new wasm.xWrap.FuncPtrAdapter({ + "sqlite3*", "int", wasm.xWrap.FuncPtrAdapter({ name: 'xProgressHandler', signature: 'i(p)', bindScope: 'context', @@ -180,7 +180,7 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ "**", "**", "*", "*", "*"], ["sqlite3_total_changes", "int", "sqlite3*"], ["sqlite3_trace_v2", "int", "sqlite3*", "int", - new wasm.xWrap.FuncPtrAdapter({ + wasm.xWrap.FuncPtrAdapter({ name: 'sqlite3_trace_v2::callback', signature: 'i(ippp)', contextKey: (argIndex, argv)=>'sqlite3@'+argv[0] @@ -462,22 +462,11 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ const __collationContextKey = (argIndex,argv)=>{ return 'argv['+argIndex+']:sqlite3@'+argv[0]+ - ':'+((/*THIS IS WRONG. We can't sensibly use a converted-to-C-string - address here and don't have access to the JS string (IF ANY) - which the user passed in.*/ - ''+argv[1] - ).toLowerCase()); + ':'+wasm.cstrToJs(argv[1]).toLowerCase() }; const __ccv2 = wasm.xWrap( 'sqlite3_create_collation_v2', 'int', - 'sqlite3*','string','int','*','*','*' - /* int(*xCompare)(void*,int,const void*,int,const void*) */ - /* void(*xDestroy(void*) */ - ); - if(0){ - // Problem: we cannot, due to xWrap() arg-passing limitations, - // currently easily/efficiently get a per-collation distinct - // key for purposes of creating distinct FuncPtrAdapter contexts. + 'sqlite3*','string','int','*', new wasm.xWrap.FuncPtrAdapter({ /* int(*xCompare)(void*,int,const void*,int,const void*) */ name: 'xCompare', @@ -492,7 +481,7 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ bindScope: 'context', contextKey: __collationContextKey }) - } + ); /** Works exactly like C's sqlite3_create_collation_v2() except that: @@ -518,18 +507,9 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ ); } let rc, pfCompare, pfDestroy; - try{ - if(xCompare instanceof Function){ - pfCompare = wasm.installFunction(xCompare, 'i(pipip)'); - } - if(xDestroy instanceof Function){ - pfDestroy = wasm.installFunction(xDestroy, 'v(p)'); - } - rc = __ccv2(pDb, zName, eTextRep, pArg, - pfCompare || xCompare, pfDestroy || xDestroy); + try{ + rc = __ccv2(pDb, zName, eTextRep, pArg, xCompare, xDestroy); }catch(e){ - if(pfCompare) wasm.uninstallFunction(pfCompare); - if(pfDestroy) wasm.uninstallFunction(pfDestroy); rc = util.sqlite3_wasm_db_error(pDb, e); } return rc; @@ -539,7 +519,7 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ return (5===arguments.length) ? capi.sqlite3_create_collation_v2(pDb,zName,eTextRep,pArg,xCompare,0) : __dbArgcMismatch(pDb, 'sqlite3_create_collation', 5); - } + }; }/*sqlite3_create_collation() and friends*/ |