JNI: apply an internal level of API indirection to avoid having to work with massively-mangled names for the various sqlite3_config() overloads.
FossilOrigin-Name: 24f20663b1c4e13ff7d9a89e1df6af2e6f5730e5042ae6479e0a8c1bb846f313
This commit is contained in:
parent
7df044633d
commit
253727b33d
@ -299,7 +299,7 @@ one of its three subclasses:
|
||||
- `SQLFunction.Window` implements window functions using four
|
||||
callbacks.
|
||||
|
||||
Search [`Tester1.java`](/file/ext/jni/src/org/sqlite/jni/Tester1.java) for
|
||||
Search [`Tester1.java`](/file/ext/jni/src/org/sqlite/jni/capi/Tester1.java) for
|
||||
`SQLFunction` for how it's used.
|
||||
|
||||
Reminder: see the disclaimer at the top of this document regarding the
|
||||
|
@ -3354,8 +3354,9 @@ S3JniApi(sqlite3_complete(),jint,1complete)(
|
||||
return rc;
|
||||
}
|
||||
|
||||
S3JniApi(sqlite3_config() /*for a small subset of options.*/,
|
||||
jint,1config__I)(JniArgsEnvClass, jint n){
|
||||
S3JniApi(sqlite3_config() /*for a small subset of options.*/
|
||||
sqlite3_config__enable()/* internal name to avoid name-mangling issues*/,
|
||||
jint,1config_1_1enable)(JniArgsEnvClass, jint n){
|
||||
switch( n ){
|
||||
case SQLITE_CONFIG_SINGLETHREAD:
|
||||
case SQLITE_CONFIG_MULTITHREAD:
|
||||
@ -3385,8 +3386,9 @@ static void s3jni_config_log(void *ignored, int errCode, const char *z){
|
||||
}
|
||||
}
|
||||
|
||||
S3JniApi(sqlite3_config() /* for SQLITE_CONFIG_LOG */,
|
||||
jint, 1config__Lorg_sqlite_jni_ConfigLogCallback_2
|
||||
S3JniApi(sqlite3_config() /* for SQLITE_CONFIG_LOG */
|
||||
sqlite3_config__config_log() /* internal name */,
|
||||
jint, 1config_1_1CONFIG_1LOG
|
||||
)(JniArgsEnvClass, jobject jLog){
|
||||
S3JniHook * const pHook = &SJG.hook.configlog;
|
||||
int rc = 0;
|
||||
@ -3460,9 +3462,10 @@ void sqlite3_init_sqllog(void){
|
||||
}
|
||||
#endif
|
||||
|
||||
S3JniApi(sqlite3_config() /* for SQLITE_CONFIG_SQLLOG */,
|
||||
jint, 1config__Lorg_sqlite_jni_ConfigSqllogCallback_2)(
|
||||
JniArgsEnvClass, jobject jLog){
|
||||
S3JniApi(sqlite3_config() /* for SQLITE_CONFIG_SQLLOG */
|
||||
sqlite3_config__SQLLOG() /*internal name*/,
|
||||
jint, 1config_1_1SQLLOG
|
||||
)(JniArgsEnvClass, jobject jLog){
|
||||
#ifndef SQLITE_ENABLE_SQLLOG
|
||||
return SQLITE_MISUSE;
|
||||
#else
|
||||
|
@ -1283,26 +1283,26 @@ JNIEXPORT jint JNICALL Java_org_sqlite_jni_capi_CApi_sqlite3_1complete
|
||||
|
||||
/*
|
||||
* Class: org_sqlite_jni_capi_CApi
|
||||
* Method: sqlite3_config
|
||||
* Method: sqlite3_config__enable
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_sqlite_jni_capi_CApi_sqlite3_1config__I
|
||||
JNIEXPORT jint JNICALL Java_org_sqlite_jni_capi_CApi_sqlite3_1config_1_1enable
|
||||
(JNIEnv *, jclass, jint);
|
||||
|
||||
/*
|
||||
* Class: org_sqlite_jni_capi_CApi
|
||||
* Method: sqlite3_config
|
||||
* Signature: (Lorg/sqlite/jni/capi/ConfigSqllogCallback;)I
|
||||
* Method: sqlite3_config__CONFIG_LOG
|
||||
* Signature: (Lorg/sqlite/jni/capi/ConfigLogCallback;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_sqlite_jni_capi_CApi_sqlite3_1config__Lorg_sqlite_jni_capi_ConfigSqllogCallback_2
|
||||
JNIEXPORT jint JNICALL Java_org_sqlite_jni_capi_CApi_sqlite3_1config_1_1CONFIG_1LOG
|
||||
(JNIEnv *, jclass, jobject);
|
||||
|
||||
/*
|
||||
* Class: org_sqlite_jni_capi_CApi
|
||||
* Method: sqlite3_config
|
||||
* Signature: (Lorg/sqlite/jni/capi/ConfigLogCallback;)I
|
||||
* Method: sqlite3_config__SQLLOG
|
||||
* Signature: (Lorg/sqlite/jni/capi/ConfigSqllogCallback;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_sqlite_jni_capi_CApi_sqlite3_1config__Lorg_sqlite_jni_capi_ConfigLogCallback_2
|
||||
JNIEXPORT jint JNICALL Java_org_sqlite_jni_capi_CApi_sqlite3_1config_1_1SQLLOG
|
||||
(JNIEnv *, jclass, jobject);
|
||||
|
||||
/*
|
||||
|
@ -1039,6 +1039,24 @@ public final class CApi {
|
||||
return sqlite3_complete( nulTerminateUtf8(sql) );
|
||||
}
|
||||
|
||||
/**
|
||||
Internal level of indirection for sqlite3_config(int).
|
||||
*/
|
||||
private static native int sqlite3_config__enable(int op);
|
||||
|
||||
/**
|
||||
Internal level of indirection for sqlite3_config(ConfigLogCallback).
|
||||
*/
|
||||
private static native int sqlite3_config__CONFIG_LOG(
|
||||
@Nullable ConfigLogCallback logger
|
||||
);
|
||||
|
||||
/**
|
||||
Internal level of indirection for sqlite3_config(ConfigSqllogCallback).
|
||||
*/
|
||||
private static native int sqlite3_config__SQLLOG(
|
||||
@Nullable ConfigSqllogCallback logger
|
||||
);
|
||||
|
||||
/**
|
||||
<p>Works like in the C API with the exception that it only supports
|
||||
@ -1055,12 +1073,14 @@ public final class CApi {
|
||||
the rest of the library. This must not be called when any other
|
||||
library APIs are being called.
|
||||
*/
|
||||
public static native int sqlite3_config(int op);
|
||||
public static int sqlite3_config(int op){
|
||||
return sqlite3_config__enable(op);
|
||||
}
|
||||
|
||||
/**
|
||||
If the native library was built with SQLITE_ENABLE_SQLLOG defined
|
||||
then this acts as a proxy for C's
|
||||
sqlite3_config(SQLITE_ENABLE_SQLLOG,...). This sets or clears the
|
||||
sqlite3_config(SQLITE_CONFIG_SQLLOG,...). This sets or clears the
|
||||
logger. If installation of a logger fails, any previous logger is
|
||||
retained.
|
||||
|
||||
@ -1071,13 +1091,17 @@ public final class CApi {
|
||||
the rest of the library. This must not be called when any other
|
||||
library APIs are being called.
|
||||
*/
|
||||
public static native int sqlite3_config( @Nullable ConfigSqllogCallback logger );
|
||||
public static int sqlite3_config( @Nullable ConfigSqllogCallback logger ){
|
||||
return sqlite3_config__SQLLOG(logger);
|
||||
}
|
||||
|
||||
/**
|
||||
The sqlite3_config() overload for handling the SQLITE_CONFIG_LOG
|
||||
option.
|
||||
*/
|
||||
public static native int sqlite3_config( @Nullable ConfigLogCallback logger );
|
||||
public static int sqlite3_config( @Nullable ConfigLogCallback logger ){
|
||||
return sqlite3_config__CONFIG_LOG(logger);
|
||||
}
|
||||
|
||||
/**
|
||||
Unlike the C API, this returns null if its argument is
|
||||
|
@ -19,6 +19,7 @@ import org.sqlite.jni.capi.sqlite3_stmt;
|
||||
import org.sqlite.jni.capi.sqlite3_backup;
|
||||
import org.sqlite.jni.capi.sqlite3_blob;
|
||||
import org.sqlite.jni.capi.OutputPointer;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/**
|
||||
This class represents a database connection, analog to the C-side
|
||||
@ -29,6 +30,8 @@ import org.sqlite.jni.capi.OutputPointer;
|
||||
*/
|
||||
public final class Sqlite implements AutoCloseable {
|
||||
private sqlite3 db;
|
||||
private static final boolean JNI_SUPPORTS_NIO =
|
||||
CApi.sqlite3_jni_supports_nio();
|
||||
|
||||
public static final int OK = CApi.SQLITE_OK;
|
||||
public static final int ERROR = CApi.SQLITE_ERROR;
|
||||
@ -972,7 +975,7 @@ public final class Sqlite implements AutoCloseable {
|
||||
|
||||
/**
|
||||
If this statement is still opened, its low-level handle is
|
||||
returned, eelse an IllegalArgumentException is thrown.
|
||||
returned, else an IllegalArgumentException is thrown.
|
||||
*/
|
||||
private sqlite3_stmt thisStmt(){
|
||||
if( null==stmt || 0==stmt.getNativePointer() ){
|
||||
@ -1773,6 +1776,17 @@ public final class Sqlite implements AutoCloseable {
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
/**
|
||||
If this blob is still opened, its low-level handle is
|
||||
returned, else an IllegalArgumentException is thrown.
|
||||
*/
|
||||
private sqlite3_blob thisBlob(){
|
||||
if( null==b || 0==b.getNativePointer() ){
|
||||
throw new IllegalArgumentException("This Blob has been finalized.");
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
/**
|
||||
Analog to sqlite3_blob_close().
|
||||
*/
|
||||
@ -1784,32 +1798,43 @@ public final class Sqlite implements AutoCloseable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Throws if the JVM does not have JNI-level support for
|
||||
ByteBuffer.
|
||||
*/
|
||||
private void checkNio(){
|
||||
if( !Sqlite.JNI_SUPPORTS_NIO ){
|
||||
throw new UnsupportedOperationException(
|
||||
"This JVM does not support JNI access to ByteBuffer."
|
||||
);
|
||||
}
|
||||
}
|
||||
/**
|
||||
Analog to sqlite3_blob_reopen() but throws on error.
|
||||
*/
|
||||
public void reopen(long newRowId){
|
||||
db.checkRc( CApi.sqlite3_blob_reopen(b, newRowId) );
|
||||
db.checkRc( CApi.sqlite3_blob_reopen(thisBlob(), newRowId) );
|
||||
}
|
||||
|
||||
/**
|
||||
Analog to sqlite3_blob_write() but throws on error.
|
||||
*/
|
||||
public void write( byte[] bytes, int atOffset ){
|
||||
db.checkRc( CApi.sqlite3_blob_write(b, bytes, atOffset) );
|
||||
db.checkRc( CApi.sqlite3_blob_write(thisBlob(), bytes, atOffset) );
|
||||
}
|
||||
|
||||
/**
|
||||
Analog to sqlite3_blob_read() but throws on error.
|
||||
*/
|
||||
public void read( byte[] dest, int atOffset ){
|
||||
db.checkRc( CApi.sqlite3_blob_read(b, dest, atOffset) );
|
||||
db.checkRc( CApi.sqlite3_blob_read(thisBlob(), dest, atOffset) );
|
||||
}
|
||||
|
||||
/**
|
||||
Analog to sqlite3_blob_bytes().
|
||||
*/
|
||||
public int bytes(){
|
||||
return CApi.sqlite3_blob_bytes(b);
|
||||
return CApi.sqlite3_blob_bytes(thisBlob());
|
||||
}
|
||||
}
|
||||
|
||||
|
22
manifest
22
manifest
@ -1,5 +1,5 @@
|
||||
C Add\sNEVER()\sto\sa\sbranch\smade\sunreachable\sby\s[6f9eed826f5b3d1c].
|
||||
D 2023-11-14T16:53:52.014
|
||||
C JNI:\sapply\san\sinternal\slevel\sof\sAPI\sindirection\sto\savoid\shaving\sto\swork\swith\smassively-mangled\snames\sfor\sthe\svarious\ssqlite3_config()\soverloads.
|
||||
D 2023-11-15T03:02:11.306
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||
@ -239,10 +239,10 @@ F ext/icu/README.txt 7ab7ced8ae78e3a645b57e78570ff589d4c672b71370f5aa9e1cd7024f4
|
||||
F ext/icu/icu.c c074519b46baa484bb5396c7e01e051034da8884bad1a1cb7f09bbe6be3f0282
|
||||
F ext/icu/sqliteicu.h fa373836ed5a1ee7478bdf8a1650689294e41d0c89c1daab26e9ae78a32075a8
|
||||
F ext/jni/GNUmakefile f2f3a31923293659b95225e932a286af1f2287d75bf88ad6c0fd1b9d9cd020d4
|
||||
F ext/jni/README.md ef9ac115e97704ea995d743b4a8334e23c659e5534c3b64065a5405256d5f2f4
|
||||
F ext/jni/README.md 78a0386f6813e5201142ff07f077f4dcf1bb66266c69c6bbd09edac69cadff60
|
||||
F ext/jni/jar-dist.make 030aaa4ae71dd86e4ec5e7c1e6cd86f9dfa47c4592c070d2e35157e42498e1fa
|
||||
F ext/jni/src/c/sqlite3-jni.c 524ca86d59c07db31ad6feb93f2dece977563e1264b903ccfbbdbeff5f288089
|
||||
F ext/jni/src/c/sqlite3-jni.h 0ed09051f16f612680603a297fefa2c131c4a7e98e0b41cdd9ece08428b47d48
|
||||
F ext/jni/src/c/sqlite3-jni.c 4fd9906698d296d4e4e4a54c3946461f8506f5b2a13a26cd7b27e0e5c7272bd0
|
||||
F ext/jni/src/c/sqlite3-jni.h e10321a23fe8433791f463adc15cf885406a7237788087f92a75a99f9a0fdf8f
|
||||
F ext/jni/src/org/sqlite/jni/annotation/NotNull.java 02091a8112e33389f1c160f506cd413168c8dfacbeda608a4946c6e3557b7d5a
|
||||
F ext/jni/src/org/sqlite/jni/annotation/Nullable.java 0b1879852707f752512d4db9d7edd0d8db2f0c2612316ce1c832715e012ff6ba
|
||||
F ext/jni/src/org/sqlite/jni/annotation/package-info.java 977b374aed9d5853cbf3438ba3b0940abfa2ea4574f702a2448ee143b98ac3ca
|
||||
@ -251,7 +251,7 @@ F ext/jni/src/org/sqlite/jni/capi/AggregateFunction.java 0b72cdff61533b564d65b63
|
||||
F ext/jni/src/org/sqlite/jni/capi/AuthorizerCallback.java c045a5b47e02bb5f1af91973814a905f12048c428a3504fbc5266d1c1be3de5a
|
||||
F ext/jni/src/org/sqlite/jni/capi/AutoExtensionCallback.java 74cc4998a73d6563542ecb90804a3c4f4e828cb4bd69e61226d1a51f4646e759
|
||||
F ext/jni/src/org/sqlite/jni/capi/BusyHandlerCallback.java 7b8e19810c42b0ad21a04b5d8c804b32ee5905d137148703f16a75b612c380ca
|
||||
F ext/jni/src/org/sqlite/jni/capi/CApi.java 7b2eae29f21db915bd358f3fab1eb9f1a4cbc8b2cc4c78aab7309cd69b71958a
|
||||
F ext/jni/src/org/sqlite/jni/capi/CApi.java 4cbcd18aec9da051a9d934a2ba663f9272c71ab6b17e01462f285df87c0c54fd
|
||||
F ext/jni/src/org/sqlite/jni/capi/CallbackProxy.java 57e2d275dcebe690b1fc1f3d34eb96879b2d7039bce30b563aee547bf45d8a8b
|
||||
F ext/jni/src/org/sqlite/jni/capi/CollationCallback.java e29bcfc540fdd343e2f5cca4d27235113f2886acb13380686756d5cabdfd065a
|
||||
F ext/jni/src/org/sqlite/jni/capi/CollationNeededCallback.java 5bfa226a8e7a92e804fd52d6e42b4c7b875fa7a94f8e2c330af8cc244a8920ab
|
||||
@ -296,7 +296,7 @@ F ext/jni/src/org/sqlite/jni/test-script-interpreter.md f9f25126127045d051e918fe
|
||||
F ext/jni/src/org/sqlite/jni/wrapper1/AggregateFunction.java d5c108b02afd3c63c9e5e53f71f85273c1bfdc461ae526e0a0bb2b25e4df6483
|
||||
F ext/jni/src/org/sqlite/jni/wrapper1/ScalarFunction.java 43c43adfb7866098aadaaca1620028a6ec82d5193149970019b1cce9eb59fb03
|
||||
F ext/jni/src/org/sqlite/jni/wrapper1/SqlFunction.java 27b141f5914c7cb0e40e90a301d5e05b77f3bd42236834a68031b7086381fafd
|
||||
F ext/jni/src/org/sqlite/jni/wrapper1/Sqlite.java 1d8ee109710fd41ba05c17b584f89fe6fcbb53ec1c305dc9686fc7a81fadd6f2
|
||||
F ext/jni/src/org/sqlite/jni/wrapper1/Sqlite.java 3914c4786adae73fd4533e9b3a3a882e9fc23f53e3810d2f2490cbf342d0508c
|
||||
F ext/jni/src/org/sqlite/jni/wrapper1/SqliteException.java 982538ddb4c0719ef87dfa664cd137b09890b546029a7477810bd64d4c47ee35
|
||||
F ext/jni/src/org/sqlite/jni/wrapper1/Tester2.java a9235aa3695e5ad2fca47d43d35a77220b1244d77e43dab1fa3f56555bfc3733
|
||||
F ext/jni/src/org/sqlite/jni/wrapper1/ValueHolder.java a84e90c43724a69c2ecebd601bc8e5139f869b7d08cb705c77ef757dacdd0593
|
||||
@ -2139,8 +2139,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 3a69679e41d23a760df349b2471a1ed306c087f9a7a7a2e2cba3723071dee6b2
|
||||
R 86e45bec612b162e274e644f32063331
|
||||
U drh
|
||||
Z b640c146c438183b53719e4f6331aea5
|
||||
P 26dcaa34e3521783bde687749d590eca54cecb4bb95ef332a4a6473c4141d052
|
||||
R 1457080e864b1bcae8f96b78786cdb55
|
||||
U stephan
|
||||
Z a407c77d672c175e671589a08a8a1a46
|
||||
# Remove this line to create a well-formed Fossil manifest.
|
||||
|
@ -1 +1 @@
|
||||
26dcaa34e3521783bde687749d590eca54cecb4bb95ef332a4a6473c4141d052
|
||||
24f20663b1c4e13ff7d9a89e1df6af2e6f5730e5042ae6479e0a8c1bb846f313
|
Loading…
Reference in New Issue
Block a user