diff --git a/ext/jni/src/c/sqlite3-jni.c b/ext/jni/src/c/sqlite3-jni.c index e794e9c973..b28ea71144 100644 --- a/ext/jni/src/c/sqlite3-jni.c +++ b/ext/jni/src/c/sqlite3-jni.c @@ -2979,13 +2979,13 @@ JDECL(void,1result_1error)(JENV_CSELF, jobject jpCx, jbyteArray baMsg, switch(pjBuf ? eTextRep : SQLITE_UTF8){ case SQLITE_UTF8: { const char *zMsg = pjBuf ? (const char *)pjBuf : zUnspecified; - sqlite3_result_error(PtrGet_sqlite3_context(jpCx), zMsg, baLen); + sqlite3_result_error(PtrGet_sqlite3_context(jpCx), zMsg, (int)baLen); break; } case SQLITE_UTF16: { const void *zMsg = pjBuf ? (const void *)pjBuf : (const void *)zUnspecified; - sqlite3_result_error16(PtrGet_sqlite3_context(jpCx), zMsg, baLen); + sqlite3_result_error16(PtrGet_sqlite3_context(jpCx), zMsg, (int)baLen); break; } default: diff --git a/ext/jni/src/org/sqlite/jni/OutputPointer.java b/ext/jni/src/org/sqlite/jni/OutputPointer.java index f6524707df..82a90c9185 100644 --- a/ext/jni/src/org/sqlite/jni/OutputPointer.java +++ b/ext/jni/src/org/sqlite/jni/OutputPointer.java @@ -19,6 +19,23 @@ package org.sqlite.jni; We do not use a generic OutputPointer because working with those from the native JNI code is unduly quirky due to a lack of autoboxing at that level. + + The usage is similar for all of thes types: + + ``` + OutputPointer.sqlite3 out = new OutputPointer.sqlite3(); + assert( null==out.get() ); + int rc = sqlite3_open(":memory:", out); + if( 0!=rc ) ... error; + assert( null!=out.get() ); + sqlite3 db = out.take(); + assert( null==out.get() ); + ``` + + With the minor exception that the primitive types permit direct + access to the object's value via the `value` property, whereas the + JNI-level opaque types do not permit client-level code to set that + property. */ public final class OutputPointer { @@ -30,10 +47,13 @@ public final class OutputPointer { */ public static final class sqlite3 { private org.sqlite.jni.sqlite3 value; + //! Initializes with a null value. public sqlite3(){value = null;} + //! Sets the current value to null. public void clear(){value = null;} + //! Returns the current value. public final org.sqlite.jni.sqlite3 get(){return value;} - /** Equivalent to calling get() then clear(). */ + //! Equivalent to calling get() then clear(). public final org.sqlite.jni.sqlite3 take(){ final org.sqlite.jni.sqlite3 v = value; value = null; @@ -49,10 +69,13 @@ public final class OutputPointer { */ public static final class sqlite3_stmt { private org.sqlite.jni.sqlite3_stmt value; + //! Initializes with a null value. public sqlite3_stmt(){value = null;} + //! Sets the current value to null. public void clear(){value = null;} + //! Returns the current value. public final org.sqlite.jni.sqlite3_stmt get(){return value;} - /** Equivalent to calling get() then clear(). */ + //! Equivalent to calling get() then clear(). public final org.sqlite.jni.sqlite3_stmt take(){ final org.sqlite.jni.sqlite3_stmt v = value; value = null; @@ -70,9 +93,13 @@ public final class OutputPointer { consistency with the higher-level types. */ public int value; + //! Initializes with the value 0. public Int32(){this(0);} + //! Initializes with the value v. public Int32(int v){value = v;} + //! Returns the current value. public final int get(){return value;} + //! Sets the current value to v. public final void set(int v){value = v;} } @@ -86,9 +113,13 @@ public final class OutputPointer { consistency with the higher-level types. */ public long value; + //! Initializes with the value 0. public Int64(){this(0);} + //! Initializes with the value v. public Int64(long v){value = v;} + //! Returns the current value. public final long get(){return value;} + //! Sets the current value. public final void set(long v){value = v;} } @@ -102,9 +133,13 @@ public final class OutputPointer { consistency with the higher-level types. */ public java.lang.String value; + //! Initializes with a null value. public String(){this(null);} + //! Initializes with the value v. public String(java.lang.String v){value = v;} + //! Returns the current value. public final java.lang.String get(){return value;} + //! Sets the current value. public final void set(java.lang.String v){value = v;} } @@ -118,9 +153,13 @@ public final class OutputPointer { consistency with the higher-level types. */ public byte[] value; + //! Initializes with the value null. public ByteArray(){this(null);} + //! Initializes with the value v. public ByteArray(byte[] v){value = v;} + //! Returns the current value. public final byte[] get(){return value;} + //! Sets the current value. public final void set(byte[] v){value = v;} } } diff --git a/ext/jni/src/org/sqlite/jni/ResultCode.java b/ext/jni/src/org/sqlite/jni/ResultCode.java index 30626f7564..0989bc744d 100644 --- a/ext/jni/src/org/sqlite/jni/ResultCode.java +++ b/ext/jni/src/org/sqlite/jni/ResultCode.java @@ -13,24 +13,11 @@ */ package org.sqlite.jni; -//! Internal level of indirection requires because we cannot reference -// static enum members from an enum constructor. -class ResultCodeMap { - private static final java.util.Map i2e - = new java.util.HashMap<>(); - - public static void set(int i, ResultCode src){ - i2e.put(i, src); - } - public static ResultCode get(int i){ - return i2e.get(i); - } -} - /** - This enum of sqlite3 result codes is provided not for use with the - C-style API (with which it won't work) but for higher-level code which - may find it useful to map codes to human-readable names. + This enum contains all of the core and "extended" result codes used + by the sqlite3 library. It is provided not for use with the C-style + API (with which it won't work) but for higher-level code which may + find it useful to map SQLite result codes to human-readable names. */ public enum ResultCode { SQLITE_OK(SQLite3Jni.SQLITE_OK), @@ -140,12 +127,29 @@ public enum ResultCode { public final int value; - ResultCode(int v){ - value = v; - ResultCodeMap.set(v, this); + ResultCode(int rc){ + value = rc; + ResultCodeMap.set(rc, this); } + /** + Returns the entry from this enum for the given result code, or + null if no match is found. + */ public static ResultCode getEntryForInt(int rc){ return ResultCodeMap.get(rc); } + + /** + Internal level of indirection required because we cannot initialize + static enum members in an enum before the enum constructor is + invoked. + */ + private static final class ResultCodeMap { + private static final java.util.Map i2e + = new java.util.HashMap<>(); + private static void set(int rc, ResultCode e){ i2e.put(rc, e); } + private static ResultCode get(int rc){ return i2e.get(rc); } + } + } diff --git a/ext/jni/src/org/sqlite/jni/SQLite3Jni.java b/ext/jni/src/org/sqlite/jni/SQLite3Jni.java index 7c4447b733..9b2a176504 100644 --- a/ext/jni/src/org/sqlite/jni/SQLite3Jni.java +++ b/ext/jni/src/org/sqlite/jni/SQLite3Jni.java @@ -186,7 +186,9 @@ public final class SQLite3Jni { effects if invoked from within the execution of an auto-extension. i.e. auto extensions can neither be added, removed, nor cleared while one registered with this function is - running. + running. Auto-extensions registered directly with the library + via C code, as opposed to indirectly via Java, do not have that + limitation. See the AutoExtension class docs for more information. @@ -291,7 +293,8 @@ public final class SQLite3Jni { /** Works like the C API except that it returns false, without side - effects, if auto extensions are currently running. + effects, if auto extensions are currently running. (The JNI-level + list of extensions cannot be manipulated while it is being traversed.) */ public static synchronized native boolean sqlite3_cancel_auto_extension( @NotNull AutoExtension ax @@ -704,7 +707,8 @@ public final class SQLite3Jni { /** Works like the C API except that it has no side effects if auto - extensions are currently running. + extensions are currently running. (The JNI-level list of + extensions cannot be manipulated while it is being traversed.) */ public static synchronized native void sqlite3_reset_auto_extension(); diff --git a/manifest b/manifest index a5ad0a400c..d97b74319d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Further\ssimplifications\sin\sthe\sinterface\sof\sthe\sOutputPointer\sfamily\sof\sJava\sclasses. -D 2023-08-12T15:09:09.163 +C More\sJNI\sdocs. +D 2023-08-12T15:37:53.147 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -234,7 +234,7 @@ F ext/icu/sqliteicu.h fa373836ed5a1ee7478bdf8a1650689294e41d0c89c1daab26e9ae78a3 F ext/jni/GNUmakefile 6a6633f768431bc1195c1b64bcec162069e3ed02442808eef9bd173c59ed0ddd F ext/jni/README.md 7a614a2fa6c561205f7a53fd8626cf93a7b5711ff454fc1814517f796df398eb F ext/jni/jar-dist.make f90a553203a57934bf275bed86479485135a52f48ac5c1cfe6499ae07b0b35a4 -F ext/jni/src/c/sqlite3-jni.c e48ec95bc671cc281a5b442f6e80ea62b40947b6434ed07593bdd831b24ec979 +F ext/jni/src/c/sqlite3-jni.c bea6b8691a5fa3a8626a771757bb261208d3c5fc6598266d3b0ee23d88e35632 F ext/jni/src/c/sqlite3-jni.h c5f941b057a24ee62942e6e1bf5a7fd527e5004d20d9638e84a9382813c3cf2a F ext/jni/src/org/sqlite/jni/Authorizer.java 1308988f7f40579ea0e4deeaec3c6be971630566bd021c31367fe3f5140db892 F ext/jni/src/org/sqlite/jni/AutoExtension.java 18e83f6f463e306df60b2dceb65247d32af1f78af4bbbae9155411a8c6cdb093 @@ -249,12 +249,12 @@ F ext/jni/src/org/sqlite/jni/Fts5Function.java 65cde7151e441fee012250a5e03277de7 F ext/jni/src/org/sqlite/jni/Fts5PhraseIter.java 6642beda341c0b1b46af4e2d7f6f9ab03a7aede43277b2c92859176d6bce3be9 F ext/jni/src/org/sqlite/jni/Fts5Tokenizer.java 91489893596b6528c0df5cd7180bd5b55809c26e2b797fb321dfcdbc1298c060 F ext/jni/src/org/sqlite/jni/NativePointerHolder.java 9c5d901cce4f7e57c3d623f4e2476f9f79a8eed6e51b2a603f37866018e040ee -F ext/jni/src/org/sqlite/jni/OutputPointer.java b0adc42695f5c6d523f6b537b9eec7b5252581449d32a708aedfe323f6695407 +F ext/jni/src/org/sqlite/jni/OutputPointer.java d81f8bd43d2296ae373692370cfad16ddde76f5c14cd2760f7b4e1113ef56d4c F ext/jni/src/org/sqlite/jni/ProgressHandler.java 6f62053a828a572de809828b1ee495380677e87daa29a1c57a0e2c06b0a131dc -F ext/jni/src/org/sqlite/jni/ResultCode.java 7cdf993f2037ab7bd244c9a34dbaef2ace3beb5da5d7e7fda5c6f67634ceb647 +F ext/jni/src/org/sqlite/jni/ResultCode.java ba701f20213a5f259e94cfbfdd36eb7ac7ce7797f2c6c7fca2004ff12ce20f86 F ext/jni/src/org/sqlite/jni/RollbackHook.java b04c8abcc6ade44a8a57129e33765793f69df0ba909e49ba18d73f4268d92564 F ext/jni/src/org/sqlite/jni/SQLFunction.java 09ce81c1c637e31c3a830d4c859cce95d65f5e02ff45f8bd1985b3479381bc46 -F ext/jni/src/org/sqlite/jni/SQLite3Jni.java 18458d7419a9105e4987884f9a51a269a7aee3824abda861f937776a5dfd6b76 +F ext/jni/src/org/sqlite/jni/SQLite3Jni.java 4b6fd22e04e63eb65d8e4e38fda39ecf15ce244d034607517627ce2e766e7e65 F ext/jni/src/org/sqlite/jni/Tester1.java 07c14a90427529ceba54b5e8344ca03602f5789dc53c4163ce22f92d8c577a11 F ext/jni/src/org/sqlite/jni/TesterFts5.java 59e22dd24af033ea8827d36225a2f3297908fb6af8818ead8850c6c6847557b1 F ext/jni/src/org/sqlite/jni/Tracer.java a5cece9f947b0af27669b8baec300b6dd7ff859c3e6a6e4a1bd8b50f9714775d @@ -2091,8 +2091,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 265c8fd0d4d425054f6bf7e9cb607ad2e0e46189f16c3014f7fdf9b650085497 -R 82a7bb87064debdd63f799e45e3a7aa0 +P 962c3e0de2d64ab8a2bcf1a19f9c4224df3d15a41ac9f9b29da685be95c4ef7a +R 26b1f361ecc1f9ee890a179908638933 U stephan -Z 038e6a5cd04ee9dc715f1c7cadd72bf8 +Z c7ff43bec79fef52fa552298593f1614 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index ec186ef24c..1c45e63bd3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -962c3e0de2d64ab8a2bcf1a19f9c4224df3d15a41ac9f9b29da685be95c4ef7a \ No newline at end of file +290028d3ca5638f3bb18a0b243c7ba3c31c8a2b1a837c36ec29e0fc4ed6533f0 \ No newline at end of file