mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
Rename 'static-string' argument adapter to 'string:static'. Replace JS unit tests which were lost via editing a generated copy of tester1.js instead of the original tester1.c-pp.js input file.
FossilOrigin-Name: 9d81d51d5a255b42f8416da850c992a9e4c8eebc940e0702a9262cfcaa6d7b2f
This commit is contained in:
@ -45,7 +45,7 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
|
||||
);
|
||||
|
||||
/**
|
||||
The 'static-string' argument adapter treats its argument as
|
||||
The 'string:static' argument adapter treats its argument as
|
||||
either...
|
||||
|
||||
- WASM pointer: assumed to be a long-lived C-string which gets
|
||||
@ -66,7 +66,7 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
|
||||
need it to.
|
||||
*/
|
||||
wasm.xWrap.argAdapter(
|
||||
'static-string',
|
||||
'string:static',
|
||||
function(v){
|
||||
if(wasm.isPtr(v)) return v;
|
||||
v = ''+v;
|
||||
|
@ -885,7 +885,7 @@ self.sqlite3ApiBootstrap = function sqlite3ApiBootstrap(
|
||||
["sqlite3_bind_parameter_count", "int", "sqlite3_stmt*"],
|
||||
["sqlite3_bind_parameter_index","int", "sqlite3_stmt*", "string"],
|
||||
["sqlite3_bind_pointer", "int",
|
||||
"sqlite3_stmt*", "int", "*", "static-string", "*"],
|
||||
"sqlite3_stmt*", "int", "*", "string:static", "*"],
|
||||
["sqlite3_bind_text","int", "sqlite3_stmt*", "int", "string", "int", "int"
|
||||
/* We should arguably create a hand-written binding of
|
||||
bind_text() which does more flexible text conversion, along
|
||||
@ -961,7 +961,7 @@ self.sqlite3ApiBootstrap = function sqlite3ApiBootstrap(
|
||||
["sqlite3_result_int",undefined, "sqlite3_context*", "int"],
|
||||
["sqlite3_result_null",undefined, "sqlite3_context*"],
|
||||
["sqlite3_result_pointer",undefined,
|
||||
"sqlite3_context*", "*", "static-string", "*"],
|
||||
"sqlite3_context*", "*", "string:static", "*"],
|
||||
["sqlite3_result_text",undefined, "sqlite3_context*", "string", "int", "*"],
|
||||
["sqlite3_result_zeroblob", undefined, "sqlite3_context*", "int"],
|
||||
["sqlite3_serialize","*", "sqlite3*", "string", "*", "int"],
|
||||
@ -984,7 +984,7 @@ self.sqlite3ApiBootstrap = function sqlite3ApiBootstrap(
|
||||
["sqlite3_value_bytes","int", "sqlite3_value*"],
|
||||
["sqlite3_value_double","f64", "sqlite3_value*"],
|
||||
["sqlite3_value_int","int", "sqlite3_value*"],
|
||||
["sqlite3_value_pointer", "*", "sqlite3_value*", "static-string"],
|
||||
["sqlite3_value_pointer", "*", "sqlite3_value*", "string:static"],
|
||||
["sqlite3_value_text", "string", "sqlite3_value*"],
|
||||
["sqlite3_value_type", "int", "sqlite3_value*"],
|
||||
["sqlite3_vfs_find", "*", "string"],
|
||||
|
@ -660,6 +660,26 @@ self.sqlite3InitModule = sqlite3InitModule;
|
||||
T.assert(rc>0 && Number.isFinite(rc));
|
||||
rc = w.xCallWrapped('sqlite3_wasm_enum_json','utf8');
|
||||
T.assert('string'===typeof rc).assert(rc.length>300);
|
||||
|
||||
|
||||
{ // 'string:static' argAdapter() sanity checks...
|
||||
let argAd = w.xWrap.argAdapter('string:static');
|
||||
let p0 = argAd('foo'), p1 = argAd('bar');
|
||||
T.assert(w.isPtr(p0) && w.isPtr(p1))
|
||||
.assert(p0 !== p1)
|
||||
.assert(p0 === argAd('foo'))
|
||||
.assert(p1 === argAd('bar'));
|
||||
}
|
||||
|
||||
// 'flexible-string' argAdapter() sanity checks...
|
||||
w.scopedAllocCall(()=>{
|
||||
const argAd = w.xWrap.argAdapter('flexible-string');
|
||||
const cj = (v)=>w.cstringToJs(argAd(v));
|
||||
T.assert('Hi' === cj('Hi'))
|
||||
.assert('hi' === cj(['h','i']))
|
||||
.assert('HI' === cj(new Uint8Array([72, 73])));
|
||||
});
|
||||
|
||||
if(haveWasmCTests()){
|
||||
if(!sqlite3.config.useStdAlloc){
|
||||
fw = w.xWrap('sqlite3_wasm_test_str_hello', 'utf8:dealloc',['i32']);
|
||||
|
Reference in New Issue
Block a user