]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Minor internal cleanups in the js pieces.
authorstephan <stephan@noemail.net>
Tue, 1 Nov 2022 11:09:34 +0000 (11:09 +0000)
committerstephan <stephan@noemail.net>
Tue, 1 Nov 2022 11:09:34 +0000 (11:09 +0000)
FossilOrigin-Name: 271391b4e32220ab4c32d69f579ecd2b03eb99da898955a1ef8fffc27216719d

ext/wasm/api/sqlite3-api-glue.js
ext/wasm/api/sqlite3-api-oo1.js
ext/wasm/api/sqlite3-api-prologue.js
manifest
manifest.uuid

index 1477af7598089511ab5e4f129710464b7bdbd52d..7e3e433cec03ea5c27ec6caa84b9f9accc7f71bf 100644 (file)
@@ -51,8 +51,8 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
     });
   }
 
-  if(1){/* Convert Arrays and certain TypedArrays to strings for
-           'flexible-string'-type arguments */
+  {/* Convert Arrays and certain TypedArrays to strings for
+      'flexible-string'-type arguments */
     const xString = wasm.xWrap.argAdapter('string');
     wasm.xWrap.argAdapter(
       'flexible-string', (v)=>xString(util.flexibleString(v))
index aaaeaa3d5ac844087e89eb4ef3aada0006c38ecf..02ce9c0ced7b5f19a556d2e7fdd186744f27beed 100644 (file)
@@ -401,11 +401,11 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
           break;
         case undefined:
         case 'this':
+          out.returnVal = ()=>db;
           break;
         default:
           toss3("Invalid returnValue value:",opt.returnValue);
     }
-    if(!out.returnVal) out.returnVal = ()=>db;
     if(opt.callback || opt.resultRows){
       switch((undefined===opt.rowMode)
              ? 'array' : opt.rowMode) {
@@ -762,15 +762,12 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
       affirmDbOpen(this);
       const arg = parseExecArgs(this, arguments);
       if(!arg.sql){
-        return (''===arg.sql) ? this : toss3("exec() requires an SQL string.");
+        return toss3("exec() requires an SQL string.");
       }
       const opt = arg.opt;
       const callback = opt.callback;
-      const returnValue = opt.returnValue || 'this';
-      const resultRows = (Array.isArray(opt.resultRows)
-                          ? opt.resultRows : (
-                            'resultRows'===returnValue ? [] : undefined
-                          ));
+      const resultRows =
+            Array.isArray(opt.resultRows) ? opt.resultRows : undefined;
       let stmt;
       let bind = opt.bind;
       let evalFirstResult = !!(arg.cbArg || opt.columnNames) /* true to evaluate the first result-returning query */;
index ca6fad8f847a716d97dce6d808e8f6cc8dae0576..5e7f1bae2ee26678eadcf635afecd1275286b690 100644 (file)
@@ -199,11 +199,25 @@ self.sqlite3ApiBootstrap = function sqlite3ApiBootstrap(
 
       A very few exceptions require an additional level of proxy
       function or may otherwise require special attention in the WASM
-      environment, and all such cases are document here. Those not
-      documented otherwise are installed as 1-to-1 proxies for their
+      environment, and all such cases are documented somewhere below
+      in this file or in sqlite3-api-glue.js. capi members which are
+      not documented are installed as 1-to-1 proxies for their
       C-side counterparts.
   */
   const capi = Object.create(null);
+  /**
+     Holds state which are specific to the WASM-related
+     infrastructure and glue code. It is not expected that client
+     code will normally need these, but they're exposed here in case
+     it does. These APIs are _not_ to be considered an
+     official/stable part of the sqlite3 WASM API. They may change
+     as the developers' experience suggests appropriate changes.
+
+     Note that a number of members of this object are injected
+     dynamically after the api object is fully constructed, so
+     not all are documented in this file.
+  */
+  const wasm = Object.create(null);
 
   /**
      Functionally equivalent to the SQLite3Error constructor but may
@@ -339,11 +353,13 @@ self.sqlite3ApiBootstrap = function sqlite3ApiBootstrap(
   /**
      If v is-a Array, its join('') result is returned.  If
      isSQLableTypedArray(v) is true then typedArrayToString(v) is
+     returned. If it looks like a WASM pointer, wasm.cstringToJs(v) is
      returned. Else v is returned as-is.
   */
   const flexibleString = function(v){
     if(isSQLableTypedArray(v)) return typedArrayToString(v);
     else if(Array.isArray(v)) return v.join('');
+    else if(wasm.isPtr(v)) v = wasm.cstringToJs(v);
     return v;
   };
 
@@ -615,19 +631,7 @@ self.sqlite3ApiBootstrap = function sqlite3ApiBootstrap(
     typedArrayPart
   };
     
-  /**
-     Holds state which are specific to the WASM-related
-     infrastructure and glue code. It is not expected that client
-     code will normally need these, but they're exposed here in case
-     it does. These APIs are _not_ to be considered an
-     official/stable part of the sqlite3 WASM API. They may change
-     as the developers' experience suggests appropriate changes.
-
-     Note that a number of members of this object are injected
-     dynamically after the api object is fully constructed, so
-     not all are documented inline here.
-  */
-  const wasm = {
+  Object.assign(wasm, {
     /**
        Emscripten APIs have a deep-seated assumption that all pointers
        are 32 bits. We'll remain optimistic that that won't always be
@@ -695,7 +699,7 @@ self.sqlite3ApiBootstrap = function sqlite3ApiBootstrap(
     dealloc: undefined/*installed later*/
 
     /* Many more wasm-related APIs get installed later on. */
-  }/*wasm*/;
+  }/*wasm*/);
 
   /**
      wasm.alloc()'s srcTypedArray.byteLength bytes,
index f644d6bc0635468579939fc264647d2b0cf31e22..13ac4f9c1a5c1aa28d36e116f624d5c44daac229 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Significant\scleanups\sand\sexpansion\sof\sthe\ssqlite3.opfs\sutilities.\sAdd\soo1.DB.dbVfsName().\sAdd\sVFS\sname\sto\sworker1:open's\sarguments\sand\sresult.
-D 2022-11-01T07:49:49.018
+C Minor\sinternal\scleanups\sin\sthe\sjs\spieces.
+D 2022-11-01T11:09:34.309
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -499,10 +499,10 @@ F ext/wasm/api/post-js-footer.js cd0a8ec768501d9bd45d325ab0442037fb0e33d1f3b4f08
 F ext/wasm/api/post-js-header.js d6ab3dfef4a06960d28a7eaa338d4e2a1a5981e9b38718168bbde8fdb2a439b8
 F ext/wasm/api/pre-js.js 287e462f969342b032c03900e668099fa1471d852df7a472de5bc349161d9c04
 F ext/wasm/api/sqlite3-api-cleanup.js ecdc69dbfccfe26146f04799fcfd4a6f5790d46e7e3b9b6e9b0491f92ed8ae34
-F ext/wasm/api/sqlite3-api-glue.js ebfd1d01b249c705482bfe3bdef3b1feaecf55821c46abf79b8105ec9b1c2b1a
-F ext/wasm/api/sqlite3-api-oo1.js ce8db98ab7c394fd8fb99ae135c46269a1a0162250a70e39e7975b4317a03640
+F ext/wasm/api/sqlite3-api-glue.js 9cfa26a9818532c80c2555bc98615de3b170d5db0cf4b141cc3aa83c33c8758f
+F ext/wasm/api/sqlite3-api-oo1.js e9a83489bbb4838ce0aee46eaaa9350e0e25a5b926b565e4f5ae8e840e4fbaed
 F ext/wasm/api/sqlite3-api-opfs.js 59b278ed00764fc47ba88be0582ab3fc3ce725e02b6d86459464cc029b9ac356
-F ext/wasm/api/sqlite3-api-prologue.js 850581aa0c759db25c04d64b340b0c5272f253fb195377acc8d851e376710ad3
+F ext/wasm/api/sqlite3-api-prologue.js 201b9ab9d101fdefa3175b02748ef39cba43bc7abe87a69b6faac24e58cd70f0
 F ext/wasm/api/sqlite3-api-worker1.js 4f920a54fb97d4ca50632d45bd7d011a55016eb5a5883725033abb450903bc6f
 F ext/wasm/api/sqlite3-license-version-header.js a661182fc93fc2cf212dfd0b987f8e138a3ac98f850b1112e29b5fbdaecc87c3
 F ext/wasm/api/sqlite3-opfs-async-proxy.js 2627bf8dc04c24783a55de40d8a6d18da31e81a9bb926a5b672b402f582099b5
@@ -2054,8 +2054,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 d15c9a4a323b825eb80e706e12e9df95e5db458024f51e6e537940efc8234d8b
-R 095ddbe256b2c65febf55a9bc126a8d9
+P 86a341d7e061f946b39e8647ddd4743013b851b33ae9e6e755d8dbc53fba5286
+R c124f1782fbda1f872463378ecd48f84
 U stephan
-Z 25b125153b5de3e07d69ba6b59e3eede
+Z b4351b5e7b55104b1aa36757ad482931
 # Remove this line to create a well-formed Fossil manifest.
index f229779db4ca875c7f66c1dee8532acefe959fb0..25de52f69f5ffdfec8015e2c6a78774bfa4de4ae 100644 (file)
@@ -1 +1 @@
-86a341d7e061f946b39e8647ddd4743013b851b33ae9e6e755d8dbc53fba5286
\ No newline at end of file
+271391b4e32220ab4c32d69f579ecd2b03eb99da898955a1ef8fffc27216719d
\ No newline at end of file