]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Use the new peek/poke() variants throughout tester1.js.
authorstephan <stephan@noemail.net>
Wed, 14 Dec 2022 14:40:36 +0000 (14:40 +0000)
committerstephan <stephan@noemail.net>
Wed, 14 Dec 2022 14:40:36 +0000 (14:40 +0000)
FossilOrigin-Name: ef7b783552f7783a728837fcfc81e493b135a7aac59747397e7e3d28f4309f95

ext/wasm/tester1.c-pp.js
manifest
manifest.uuid

index 81593bc211ed1e44786a4d5e9688aea3a83a841b..8b9efcb0a72de5b2271045fbc55ddcde326be777 100644 (file)
@@ -472,13 +472,13 @@ self.sqlite3InitModule = sqlite3InitModule;
         m = w.allocFromTypedArray(u);
         for(let i = 0; i < u.length; ++i){
           T.assert(u[i] === byteList[i])
-            .assert(u[i] === w.peek(m + i, 'i8'));
+            .assert(u[i] === w.peek8(m + i));
         }
         w.dealloc(m);
         m = w.allocFromTypedArray(u.buffer);
         for(let i = 0; i < u.length; ++i){
           T.assert(u[i] === byteList[i])
-            .assert(u[i] === w.peek(m + i, 'i8'));
+            .assert(u[i] === w.peek8(m + i));
         }
 
         w.dealloc(m);
@@ -577,14 +577,14 @@ self.sqlite3InitModule = sqlite3InitModule;
           let rc = w.cstrncpy(cpy, cStr, n+10);
           T.assert(n+1 === rc).
             assert("hello" === w.cstrToJs(cpy)).
-            assert(chr('o') === w.peek(cpy+n-1)).
-            assert(0 === w.peek(cpy+n));
+            assert(chr('o') === w.peek8(cpy+n-1)).
+            assert(0 === w.peek8(cpy+n));
           let cStr2 = w.scopedAllocCString("HI!!!");
           rc = w.cstrncpy(cpy, cStr2, 3);
           T.assert(3===rc).
             assert("HI!lo" === w.cstrToJs(cpy)).
-            assert(chr('!') === w.peek(cpy+2)).
-            assert(chr('l') === w.peek(cpy+3));
+            assert(chr('!') === w.peek8(cpy+2)).
+            assert(chr('l') === w.peek8(cpy+3));
         }finally{
           w.scopedAllocPop(scope);
         }
@@ -607,8 +607,8 @@ self.sqlite3InitModule = sqlite3InitModule;
         const jstr = "hällo, world!";
         const [cstr, n] = w.allocCString(jstr, true);
         T.assert(14 === n)
-          .assert(0===w.peek(cstr+n))
-          .assert(chr('!')===w.peek(cstr+n-1));
+          .assert(0===w.peek8(cstr+n))
+          .assert(chr('!')===w.peek8(cstr+n-1));
         w.dealloc(cstr);
       }
 
@@ -644,8 +644,8 @@ self.sqlite3InitModule = sqlite3InitModule;
 
           const [z1, z2, z3] = w.scopedAllocPtr(3);
           T.assert('number'===typeof z1).assert(z2>z1).assert(z3>z2)
-            .assert(0===w.peek(z1,'i32'), 'allocPtr() must zero the targets')
-            .assert(0===w.peek(z3,'i32'));
+            .assert(0===w.peek32(z1), 'allocPtr() must zero the targets')
+            .assert(0===w.peek32(z3));
         }finally{
           // Pop them in "incorrect" order to make sure they behave:
           w.scopedAllocPop(asc);
@@ -665,8 +665,8 @@ self.sqlite3InitModule = sqlite3InitModule;
           T.assert(1===w.scopedAlloc.level);
           const [cstr, n] = w.scopedAllocCString("hello, world", true);
           T.assert(12 === n)
-            .assert(0===w.peek(cstr+n))
-            .assert(chr('d')===w.peek(cstr+n-1));
+            .assert(0===w.peek8(cstr+n))
+            .assert(chr('d')===w.peek8(cstr+n-1));
         });
       }/*scopedAlloc()*/
 
@@ -730,7 +730,7 @@ self.sqlite3InitModule = sqlite3InitModule;
               const pI1 = w.scopedAlloc(8), pI2 = pI1+4;
               w.pokePtr([pI1, pI2], 0);
               const f = w.xWrap('sqlite3_wasm_test_int64_minmax',undefined,['i64*','i64*']);
-              const [r1, r2] = w.peek([pI1, pI2], 'i64');
+              const [r1, r2] = w.peek64([pI1, pI2]);
               T.assert(!Number.isSafeInteger(r1)).assert(!Number.isSafeInteger(r2));
             });
           }
@@ -974,8 +974,8 @@ self.sqlite3InitModule = sqlite3InitModule;
       try{
         const n = 520;
         const p = wasm.pstack.alloc(n);
-        T.assert(0===wasm.peek(p))
-          .assert(0===wasm.peek(p+n-1));
+        T.assert(0===wasm.peek8(p))
+          .assert(0===wasm.peek8(p+n-1));
         T.assert(undefined === capi.sqlite3_randomness(n - 10, p));
         let j, check = 0;
         const heap = wasm.heap8u();
@@ -1096,7 +1096,7 @@ self.sqlite3InitModule = sqlite3InitModule;
         rc = capi.sqlite3_db_status(this.db, capi.SQLITE_DBSTATUS_LOOKASIDE_USED,
                                     pCur, pHi, 0);
         T.assert(0===rc);
-        if(wasm.peek(pCur, 'i32')){
+        if(wasm.peek32(pCur)){
           warn("Cannot test db_config(SQLITE_DBCONFIG_LOOKASIDE)",
                "while lookaside memory is in use.");
         }else{
@@ -1104,21 +1104,21 @@ self.sqlite3InitModule = sqlite3InitModule;
                                       0, 4096, 12);
           T.assert(0 === rc);
         }
-        wasm.poke([pCur, pHi], 0, 'i32');
-        let [vCur, vHi] = wasm.peek([pCur, pHi], 'i32');
+        wasm.poke32([pCur, pHi], 0);
+        let [vCur, vHi] = wasm.peek32([pCur, pHi]);
         T.assert(0===vCur).assert(0===vHi);
         rc = capi.sqlite3_status(capi.SQLITE_STATUS_MEMORY_USED,
                                  pCur, pHi, 0);
-        [vCur, vHi] = wasm.peek([pCur, pHi], 'i32');
+        [vCur, vHi] = wasm.peek32([pCur, pHi]);
         //console.warn("i32 vCur,vHi",vCur,vHi);
         T.assert(0 === rc).assert(vCur > 0).assert(vHi >= vCur);
         if(wasm.bigIntEnabled){
           // Again in 64-bit. Recall that pCur and pHi are allocated
           // large enough to account for this re-use.
-          wasm.poke([pCur, pHi], 0, 'i64');
+          wasm.poke64([pCur, pHi], 0);
           rc = capi.sqlite3_status64(capi.SQLITE_STATUS_MEMORY_USED,
                                      pCur, pHi, 0);
-          [vCur, vHi] = wasm.peek([pCur, pHi], 'i64');
+          [vCur, vHi] = wasm.peek64([pCur, pHi]);
           //console.warn("i64 vCur,vHi",vCur,vHi);
           T.assert(0 === rc).assert(vCur > 0).assert(vHi >= vCur);
         }
@@ -1346,9 +1346,9 @@ self.sqlite3InitModule = sqlite3InitModule;
         T.assert(0===rc)
           .assert("INTEGER"===wasm.cstrToJs(wasm.peekPtr(pzDT)))
           .assert("BINARY"===wasm.cstrToJs(wasm.peekPtr(pzColl)))
-          .assert(0===wasm.peek(pNotNull,'i32'))
-          .assert(1===wasm.peek(pPK,'i32'))
-          .assert(0===wasm.peek(pAuto,'i32'))
+          .assert(0===wasm.peek32(pNotNull))
+          .assert(1===wasm.peek32(pPK))
+          .assert(0===wasm.peek32(pAuto))
       }finally{
         wasm.pstack.restore(stack);
       }
@@ -1495,11 +1495,11 @@ self.sqlite3InitModule = sqlite3InitModule;
           name: 'summer',
           xStep: (pCtx, n)=>{
             const ac = sjac(pCtx, 4);
-            wasm.poke(ac, wasm.peek(ac,'i32') + Number(n), 'i32');
+            wasm.poke32(ac, wasm.peek32(ac) + Number(n));
           },
           xFinal: (pCtx)=>{
             const ac = sjac(pCtx, 0);
-            return ac ? wasm.peek(ac,'i32') : 0;
+            return ac ? wasm.peek32(ac) : 0;
           }
         });
         let v = db.selectValue([
@@ -1518,13 +1518,13 @@ self.sqlite3InitModule = sqlite3InitModule;
           arity: -1,
           xStep: (pCtx, ...args)=>{
             const ac = sjac(pCtx, 4);
-            let sum = wasm.peek(ac, 'i32');
+            let sum = wasm.peek32(ac);
             for(const v of args) sum += Number(v);
-            wasm.poke(ac, sum, 'i32');
+            wasm.poke32(ac, sum);
           },
           xFinal: (pCtx)=>{
             const ac = sjac(pCtx, 0);
-            capi.sqlite3_result_int( pCtx, ac ? wasm.peek(ac,'i32') : 0 );
+            capi.sqlite3_result_int( pCtx, ac ? wasm.peek32(ac) : 0 );
             // xFinal() may either return its value directly or call
             // sqlite3_result_xyz() and return undefined. Both are
             // functionally equivalent.
@@ -1566,11 +1566,11 @@ self.sqlite3InitModule = sqlite3InitModule;
           name: 'summer64',
           xStep: (pCtx, n)=>{
             const ac = sjac(pCtx, 8);
-            wasm.poke(ac, wasm.peek(ac,'i64') + BigInt(n), 'i64');
+            wasm.poke64(ac, wasm.peek64(ac) + BigInt(n));
           },
           xFinal: (pCtx)=>{
             const ac = sjac(pCtx, 0);
-            return ac ? wasm.peek(ac,'i64') : 0n;
+            return ac ? wasm.peek64(ac) : 0n;
           }
         });
         let v = db.selectValue([
@@ -1593,11 +1593,11 @@ self.sqlite3InitModule = sqlite3InitModule;
         const sjac = (cx,n=4)=>capi.sqlite3_js_aggregate_context(cx,n);
         const xValueFinal = (pCtx)=>{
           const ac = sjac(pCtx, 0);
-          return ac ? wasm.peek(ac,'i32') : 0;
+          return ac ? wasm.peek32(ac) : 0;
         };
         const xStepInverse = (pCtx, n)=>{
           const ac = sjac(pCtx);
-          wasm.poke(ac, wasm.peek(ac,'i32') + Number(n), 'i32');
+          wasm.poke32(ac, wasm.peek32(ac) + Number(n));
         };
         db.createFunction({
           name: 'winsumint',
@@ -1716,35 +1716,26 @@ self.sqlite3InitModule = sqlite3InitModule;
         const stack = w.scopedAllocPush();
         let ptrInt;
         const origValue = 512;
-        const ptrValType = 'i32';
         try{
           ptrInt = w.scopedAlloc(4);
-          w.poke(ptrInt,origValue, ptrValType);
+          w.poke32(ptrInt,origValue);
           const cf = w.xGet('sqlite3_wasm_test_intptr');
           const oldPtrInt = ptrInt;
-          //log('ptrInt',ptrInt);
-          //log('peek(ptrInt)',w.peek(ptrInt));
-          T.assert(origValue === w.peek(ptrInt, ptrValType));
+          T.assert(origValue === w.peek32(ptrInt));
           const rc = cf(ptrInt);
-          //log('cf(ptrInt)',rc);
-          //log('ptrInt',ptrInt);
-          //log('peek(ptrInt)',w.peek(ptrInt,ptrValType));
           T.assert(2*origValue === rc).
-            assert(rc === w.peek(ptrInt,ptrValType)).
+            assert(rc === w.peek32(ptrInt)).
             assert(oldPtrInt === ptrInt);
           const pi64 = w.scopedAlloc(8)/*ptr to 64-bit integer*/;
           const o64 = 0x010203040506/*>32-bit integer*/;
-          const ptrType64 = 'i64';
           if(w.bigIntEnabled){
-            w.poke(pi64, o64, ptrType64);
+            w.poke64(pi64, o64);
             //log("pi64 =",pi64, "o64 = 0x",o64.toString(16), o64);
-            const v64 = ()=>w.peek(pi64,ptrType64)
-            //log("peek(pi64)",v64());
+            const v64 = ()=>w.peek64(pi64)
             T.assert(v64() == o64);
-            //T.assert(o64 === w.peek(pi64, ptrType64));
+            //T.assert(o64 === w.peek64(pi64));
             const cf64w = w.xGet('sqlite3_wasm_test_int64ptr');
             cf64w(pi64);
-            //log("peek(pi64)",v64());
             T.assert(v64() == BigInt(2 * o64));
             cf64w(pi64);
             T.assert(v64() == BigInt(4 * o64));
@@ -1756,8 +1747,8 @@ self.sqlite3InitModule = sqlite3InitModule;
 
             const pMin = w.scopedAlloc(16);
             const pMax = pMin + 8;
-            const g64 = (p)=>w.peek(p,ptrType64);
-            w.poke([pMin, pMax], 0, ptrType64);
+            const g64 = (p)=>w.peek64(p);
+            w.poke64([pMin, pMax], 0);
             const minMaxI64 = [
               w.xCall('sqlite3_wasm_test_int64_min'),
               w.xCall('sqlite3_wasm_test_int64_max')
@@ -1769,7 +1760,7 @@ self.sqlite3InitModule = sqlite3InitModule;
             T.assert(g64(pMin) === minMaxI64[0], "int64 mismatch").
               assert(g64(pMax) === minMaxI64[1], "int64 mismatch");
             //log("pMin",g64(pMin), "pMax",g64(pMax));
-            w.poke(pMin, minMaxI64[0], ptrType64);
+            w.poke64(pMin, minMaxI64[0]);
             T.assert(g64(pMin) === minMaxI64[0]).
               assert(minMaxI64[0] === db.selectValue("select ?",g64(pMin))).
               assert(minMaxI64[1] === db.selectValue("select ?",g64(pMax)));
index cdf27d20da83ae5094e91ed1895076d2e6e5f6e4..9a9ffa73272d3ba7b2431f1f6059db64e44420a0 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\sconvenience\svariants\sof\ssqlite3.wasm.peek/poke()\sfor\seach\snumeric\stype\sto\shelp\sreduce\serrors\srelated\sto\stypos\sin\sthe\sfinal\sargument\s(type-name\sstrings).\sIf\swasm.xWrap.FuncPtrAdapter\sis\scalled\sas\sa\sfunction,\sinstead\sof\sa\sconstructor,\sit\snow\sbehaves\sas\sif\sit\swere\scalled\sas\sa\sconstructor\s(previously\sit\sthrew\san\sexception).
-D 2022-12-14T14:28:54.534
+C Use\sthe\snew\speek/poke()\svariants\sthroughout\stester1.js.
+D 2022-12-14T14:40:36.897
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -555,7 +555,7 @@ F ext/wasm/test-opfs-vfs.html 1f2d672f3f3fce810dfd48a8d56914aba22e45c6834e262555
 F ext/wasm/test-opfs-vfs.js 44363db07b2a20e73b0eb1808de4400ca71b703af718d0fa6d962f15e73bf2ac
 F ext/wasm/tester1-worker.html d43f3c131d88f10d00aff3e328fed13c858d674ea2ff1ff90225506137f85aa9
 F ext/wasm/tester1.c-pp.html d34bef3d48e5cbc1c7c06882ad240fec49bf88f5f65696cc2c72c416933aa406
-F ext/wasm/tester1.c-pp.js c3e773ea73102d71ec65b84b9c11d1e8ba5bae7120becacda0afc33f27c85d44
+F ext/wasm/tester1.c-pp.js 3cd13daab6ee39b2adc1633997e8b61ce7951c413bb183a992a17f1d3ee3a508
 F ext/wasm/tests/opfs/concurrency/index.html 86d8ac435074d1e7007b91105f4897f368c165e8cecb6a9aa3d81f5cf5dcbe70
 F ext/wasm/tests/opfs/concurrency/test.js a98016113eaf71e81ddbf71655aa29b0fed9a8b79a3cdd3620d1658eb1cc9a5d
 F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2
@@ -2067,8 +2067,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 8fc4b3f10f61e965853a22bf7a64ad2511ef656d66658a7910bac35b0f9805ec
-R 956750acad49982af078888e9331781e
+P 14e3fc01b929fa3f9a2fdbd93deb4a8aad58c111d46369c772def0437152fa75
+R 23370b5322c80a73b2e34c004e84a278
 U stephan
-Z 5c4ee894557c0103a5bb5ffb259a8752
+Z b5d32139016c804b0ff917b0b3fe6ad0
 # Remove this line to create a well-formed Fossil manifest.
index af51d02cc28c0616bed082c98e8678c97fa7e3a7..b81e8b6028398a45c8ad480e8213a8fd00bc023d 100644 (file)
@@ -1 +1 @@
-14e3fc01b929fa3f9a2fdbd93deb4a8aad58c111d46369c772def0437152fa75
\ No newline at end of file
+ef7b783552f7783a728837fcfc81e493b135a7aac59747397e7e3d28f4309f95
\ No newline at end of file