|
17 | 17 | */
|
18 | 18 |
|
19 | 19 |
|
| 20 | +/** |
| 21 | + * @module SqlJs |
| 22 | + */ |
20 | 23 | // Wait for preRun to run, and then finish our initialization
|
21 | 24 | Module["onRuntimeInitialized"] = (function onRuntimeInitialized() {
|
22 | 25 | "use strict";
|
@@ -174,21 +177,23 @@ Module["onRuntimeInitialized"] = (function onRuntimeInitialized() {
|
174 | 177 | );
|
175 | 178 |
|
176 | 179 | /** Represents a prepared statement.
|
177 |
| -
|
178 |
| - Prepared statements allow you to have a template sql string, |
179 |
| - that you can execute multiple times with different parameters. |
180 |
| -
|
181 |
| - You can't instantiate this class directly, you have to use a |
182 |
| - [Database](Database.html) object in order to create a statement. |
183 |
| -
|
184 |
| - **Warning**: When you close a database (using db.close()), |
185 |
| - all its statements are closed too and become unusable. |
186 |
| -
|
187 |
| - @see Database.html#prepare-dynamic |
188 |
| - @see https://en.wikipedia.org/wiki/Prepared_statement |
189 |
| -
|
190 |
| - Statements can't be created by the API user, only by Database::prepare |
191 |
| - @private |
| 180 | + * Prepared statements allow you to have a template sql string, |
| 181 | + * that you can execute multiple times with different parameters. |
| 182 | + * |
| 183 | + * You can't instantiate this class directly, you have to use a |
| 184 | + * {@link Database} object in order to create a statement. |
| 185 | + * |
| 186 | + * **Warning**: When you close a database (using db.close()), |
| 187 | + * all its statements are closed too and become unusable. |
| 188 | + * |
| 189 | + * Statements can't be created by the API user directly, only by Database::prepare |
| 190 | + * |
| 191 | + * @see Database.html#prepare-dynamic |
| 192 | + * @see https://en.wikipedia.org/wiki/Prepared_statement |
| 193 | + * |
| 194 | + * @classdesc A prepared statement |
| 195 | + * @constructs Statement |
| 196 | + * @memberof module:SqlJs |
192 | 197 | */
|
193 | 198 | function Statement(stmt1, db) {
|
194 | 199 | this.stmt = stmt1;
|
@@ -264,12 +269,12 @@ Module["onRuntimeInitialized"] = (function onRuntimeInitialized() {
|
264 | 269 | this.pos = 1;
|
265 | 270 | ret = sqlite3_step(this.stmt);
|
266 | 271 | switch (ret) {
|
267 |
| - case SQLITE_ROW: |
268 |
| - return true; |
269 |
| - case SQLITE_DONE: |
270 |
| - return false; |
271 |
| - default: |
272 |
| - return this.db.handleError(ret); |
| 272 | + case SQLITE_ROW: |
| 273 | + return true; |
| 274 | + case SQLITE_DONE: |
| 275 | + return false; |
| 276 | + default: |
| 277 | + return this.db.handleError(ret); |
273 | 278 | }
|
274 | 279 | };
|
275 | 280 |
|
@@ -336,18 +341,18 @@ Module["onRuntimeInitialized"] = (function onRuntimeInitialized() {
|
336 | 341 | ref = sqlite3_data_count(this.stmt);
|
337 | 342 | while (field < ref) {
|
338 | 343 | switch (sqlite3_column_type(this.stmt, field)) {
|
339 |
| - case SQLITE_INTEGER: |
340 |
| - case SQLITE_FLOAT: |
341 |
| - results1.push(this.getNumber(field)); |
342 |
| - break; |
343 |
| - case SQLITE_TEXT: |
344 |
| - results1.push(this.getString(field)); |
345 |
| - break; |
346 |
| - case SQLITE_BLOB: |
347 |
| - results1.push(this.getBlob(field)); |
348 |
| - break; |
349 |
| - default: |
350 |
| - results1.push(null); |
| 344 | + case SQLITE_INTEGER: |
| 345 | + case SQLITE_FLOAT: |
| 346 | + results1.push(this.getNumber(field)); |
| 347 | + break; |
| 348 | + case SQLITE_TEXT: |
| 349 | + results1.push(this.getString(field)); |
| 350 | + break; |
| 351 | + case SQLITE_BLOB: |
| 352 | + results1.push(this.getBlob(field)); |
| 353 | + break; |
| 354 | + default: |
| 355 | + results1.push(null); |
351 | 356 | }
|
352 | 357 | field += 1;
|
353 | 358 | }
|
@@ -495,25 +500,25 @@ Module["onRuntimeInitialized"] = (function onRuntimeInitialized() {
|
495 | 500 | this.pos += 1;
|
496 | 501 | }
|
497 | 502 | switch (typeof val) {
|
498 |
| - case "string": |
499 |
| - return this.bindString(val, pos); |
500 |
| - case "number": |
501 |
| - case "boolean": |
502 |
| - return this.bindNumber(val + 0, pos); |
503 |
| - case "object": |
504 |
| - if (val === null) { |
505 |
| - return this.bindNull(pos); |
506 |
| - } |
507 |
| - if (val.length != null) { |
508 |
| - return this.bindBlob(val, pos); |
509 |
| - } |
510 |
| - break; |
511 |
| - default: |
512 |
| - break; |
| 503 | + case "string": |
| 504 | + return this.bindString(val, pos); |
| 505 | + case "number": |
| 506 | + case "boolean": |
| 507 | + return this.bindNumber(val + 0, pos); |
| 508 | + case "object": |
| 509 | + if (val === null) { |
| 510 | + return this.bindNull(pos); |
| 511 | + } |
| 512 | + if (val.length != null) { |
| 513 | + return this.bindBlob(val, pos); |
| 514 | + } |
| 515 | + break; |
| 516 | + default: |
| 517 | + break; |
513 | 518 | }
|
514 | 519 | throw (
|
515 | 520 | "Wrong API use : tried to bind a value of an unknown type ("
|
516 |
| - + val + ")." |
| 521 | + + val + ")." |
517 | 522 | );
|
518 | 523 | };
|
519 | 524 |
|
@@ -907,31 +912,31 @@ Module["onRuntimeInitialized"] = (function onRuntimeInitialized() {
|
907 | 912 | return;
|
908 | 913 | }
|
909 | 914 | switch (typeof result) {
|
910 |
| - case "boolean": |
911 |
| - sqlite3_result_int(cx, result ? 1 : 0); |
912 |
| - break; |
913 |
| - case "number": |
914 |
| - sqlite3_result_double(cx, result); |
915 |
| - break; |
916 |
| - case "string": |
917 |
| - sqlite3_result_text(cx, result, -1, -1); |
918 |
| - break; |
919 |
| - case "object": |
920 |
| - if (result === null) { |
921 |
| - sqlite3_result_null(cx); |
922 |
| - } else if (result.length != null) { |
923 |
| - var blobptr = allocate(result, "i8", ALLOC_NORMAL); |
924 |
| - sqlite3_result_blob(cx, blobptr, result.length, -1); |
925 |
| - _free(blobptr); |
926 |
| - } else { |
927 |
| - sqlite3_result_error(cx, ( |
928 |
| - "Wrong API use : tried to return a value " |
| 915 | + case "boolean": |
| 916 | + sqlite3_result_int(cx, result ? 1 : 0); |
| 917 | + break; |
| 918 | + case "number": |
| 919 | + sqlite3_result_double(cx, result); |
| 920 | + break; |
| 921 | + case "string": |
| 922 | + sqlite3_result_text(cx, result, -1, -1); |
| 923 | + break; |
| 924 | + case "object": |
| 925 | + if (result === null) { |
| 926 | + sqlite3_result_null(cx); |
| 927 | + } else if (result.length != null) { |
| 928 | + var blobptr = allocate(result, "i8", ALLOC_NORMAL); |
| 929 | + sqlite3_result_blob(cx, blobptr, result.length, -1); |
| 930 | + _free(blobptr); |
| 931 | + } else { |
| 932 | + sqlite3_result_error(cx, ( |
| 933 | + "Wrong API use : tried to return a value " |
929 | 934 | + "of an unknown type (" + result + ")."
|
930 |
| - ), -1); |
931 |
| - } |
932 |
| - break; |
933 |
| - default: |
934 |
| - sqlite3_result_null(cx); |
| 935 | + ), -1); |
| 936 | + } |
| 937 | + break; |
| 938 | + default: |
| 939 | + sqlite3_result_null(cx); |
935 | 940 | }
|
936 | 941 | }
|
937 | 942 | if (Object.prototype.hasOwnProperty.call(this.functions, name)) {
|
|
0 commit comments