Internal JNI binding docs.
FossilOrigin-Name: 991c66197e4dc7297fce3b20a1b4846873bcd4ce8add36aac71bd2e0e73c207b
This commit is contained in:
parent
888e14f551
commit
33c8e9d233
@ -147,7 +147,7 @@
|
||||
JFuncName(Suffix)
|
||||
/* First 2 parameters to all JNI bindings. */
|
||||
#define JENV_JSELF JNIEnv * env, jobject jSelf
|
||||
/* Helper to squelch -Xcheck:jni warnings about
|
||||
/* Helpers to squelch -Xcheck:jni warnings about
|
||||
not having checked for exceptions. */
|
||||
#define IFTHREW if((*env)->ExceptionCheck(env))
|
||||
#define EXCEPTION_IGNORE (void)((*env)->ExceptionCheck(env))
|
||||
@ -157,10 +157,14 @@
|
||||
#define IFTHREW_CLEAR IFTHREW EXCEPTION_CLEAR
|
||||
|
||||
|
||||
/** Helpers for extracting pointers from jobjects, noting that the
|
||||
corresponding Java interfaces have already done the type-checking.
|
||||
*/
|
||||
#define PtrGet_sqlite3(OBJ) getNativePointer(env,OBJ,ClassNames.sqlite3)
|
||||
#define PtrGet_sqlite3_stmt(OBJ) getNativePointer(env,OBJ,ClassNames.sqlite3_stmt)
|
||||
#define PtrGet_sqlite3_value(OBJ) getNativePointer(env,OBJ,ClassNames.sqlite3_value)
|
||||
#define PtrGet_sqlite3_context(OBJ) getNativePointer(env,OBJ,ClassNames.sqlite3_context)
|
||||
/* Helpers for Java value reference management. */
|
||||
#define REF_G(VAR) (*env)->NewGlobalRef(env, VAR)
|
||||
/*#define REF_L(VAR) (*env)->NewLocalRef(env, VAR)*/
|
||||
#define UNREF_G(VAR) if(VAR) (*env)->DeleteGlobalRef(env, (VAR))
|
||||
@ -190,14 +194,15 @@ static const struct {
|
||||
return (jint)CName(); \
|
||||
}
|
||||
|
||||
/** Create a trivial JNI wrapper for (int CName(int)). */
|
||||
#define WRAP_INT_INT(JniNameSuffix,CName) \
|
||||
JDECL(jint,JniNameSuffix)(JNIEnv *env, jobject jSelf, jint arg){ \
|
||||
return (jint)CName((int)arg); \
|
||||
}
|
||||
|
||||
/** Create a trivial JNI wrapper for (const mutf8_string *
|
||||
CName(void)). This is only value for functions which are known to
|
||||
return ASCII or text compatible with Modified UTF8. */
|
||||
CName(void)). This is only valid for functions which are known to
|
||||
return ASCII or text which is equivalent in UTF-8 and MUTF-8. */
|
||||
#define WRAP_MUTF8_VOID(JniNameSuffix,CName) \
|
||||
JDECL(jstring,JniNameSuffix)(JENV_JSELF){ \
|
||||
return (*env)->NewStringUTF( env, CName() ); \
|
||||
@ -209,16 +214,6 @@ static const struct {
|
||||
EXCEPTION_IGNORE /* squelch -Xcheck:jni */; \
|
||||
return rc; \
|
||||
}
|
||||
/** Create a trivial JNI wrapper for (int CName(sqlite3*)). */
|
||||
#define WRAP_INT_DB(JniNameSuffix,CName) \
|
||||
JDECL(jint,JniNameSuffix)(JENV_JSELF, jobject pDb){ \
|
||||
return (jint)CName(PtrGet_sqlite3(pDb)); \
|
||||
}
|
||||
/** Create a trivial JNI wrapper for (int64 CName(sqlite3*)). */
|
||||
#define WRAP_INT64_DB(JniNameSuffix,CName) \
|
||||
JDECL(jlong,JniNameSuffix)(JENV_JSELF, jobject pDb){ \
|
||||
return (jlong)CName(PtrGet_sqlite3(pDb)); \
|
||||
}
|
||||
/** Create a trivial JNI wrapper for (int CName(sqlite3_stmt*,int)). */
|
||||
#define WRAP_INT_STMT_INT(JniNameSuffix,CName) \
|
||||
JDECL(jint,JniNameSuffix)(JENV_JSELF, jobject pStmt, jint n){ \
|
||||
@ -229,6 +224,16 @@ static const struct {
|
||||
JDECL(jstring,JniNameSuffix)(JENV_JSELF, jobject pStmt, jint ndx){ \
|
||||
return (*env)->NewStringUTF(env, CName(PtrGet_sqlite3_stmt(pStmt), (int)ndx)); \
|
||||
}
|
||||
/** Create a trivial JNI wrapper for (int CName(sqlite3*)). */
|
||||
#define WRAP_INT_DB(JniNameSuffix,CName) \
|
||||
JDECL(jint,JniNameSuffix)(JENV_JSELF, jobject pDb){ \
|
||||
return (jint)CName(PtrGet_sqlite3(pDb)); \
|
||||
}
|
||||
/** Create a trivial JNI wrapper for (int64 CName(sqlite3*)). */
|
||||
#define WRAP_INT64_DB(JniNameSuffix,CName) \
|
||||
JDECL(jlong,JniNameSuffix)(JENV_JSELF, jobject pDb){ \
|
||||
return (jlong)CName(PtrGet_sqlite3(pDb)); \
|
||||
}
|
||||
/** Create a trivial JNI wrapper for (int CName(sqlite3_value*)). */
|
||||
#define WRAP_INT_SVALUE(JniNameSuffix,CName) \
|
||||
JDECL(jint,JniNameSuffix)(JENV_JSELF, jobject jpSValue){ \
|
||||
@ -248,7 +253,7 @@ enum {
|
||||
/**
|
||||
Size of the per-JNIEnv cache. We have no way of knowing how many
|
||||
distinct JNIEnv's will be used in any given run, but know that it
|
||||
will normally be only 1. Perhaps (just speculating) differen
|
||||
will normally be only 1. Perhaps (just speculating) different
|
||||
threads use separate JNIEnvs? If that's the case, we don't(?)
|
||||
have enough info to evict from the cache when those JNIEnvs
|
||||
expire.
|
||||
@ -261,26 +266,33 @@ enum {
|
||||
Need enough space for (only) the library's NativePointerHolder
|
||||
types, a fixed count known at build-time. If we add more than this
|
||||
a fatal error will be triggered with a reminder to increase this.
|
||||
This value needs to be at least the number of entries in the
|
||||
ClassNames object, as that value is our upper limit. The
|
||||
ClassNames entries are the keys for this particular cache.
|
||||
*/
|
||||
NphCache_SIZE = 10
|
||||
NphCache_SIZE = sizeof(ClassNames) / sizeof(char const *)
|
||||
};
|
||||
|
||||
/**
|
||||
Cache for NativePointerHolder lookups.
|
||||
Cache entry for NativePointerHolder lookups.
|
||||
*/
|
||||
typedef struct NphCacheLine NphCacheLine;
|
||||
struct NphCacheLine {
|
||||
const char * zClassName /* "full/class/Name" */;
|
||||
jclass klazz /* global ref to concrete NPH class */;
|
||||
jmethodID midSet /* setNativePointer() */;
|
||||
jmethodID midGet /* getNativePointer() */;
|
||||
jmethodID midCtor /* constructor */;
|
||||
jfieldID fidSetAgg /* sqlite3_context::aggregateContext */;
|
||||
const char * zClassName /* "full/class/Name". Must be a static string
|
||||
from the ClassNames struct. */;
|
||||
jclass klazz /* global ref to concrete NativePointerHolder class */;
|
||||
jmethodID midCtor /* klazz's constructor */;
|
||||
jmethodID midSet /* NativePointerHolder.setNativePointer() */;
|
||||
jmethodID midGet /* NativePointerHolder.getNativePointer() */;
|
||||
jfieldID fidSetAgg /* sqlite3_context::aggregateContext */;
|
||||
};
|
||||
|
||||
/**
|
||||
Cache for per-JNIEnv data.
|
||||
*/
|
||||
typedef struct JNIEnvCacheLine JNIEnvCacheLine;
|
||||
struct JNIEnvCacheLine {
|
||||
JNIEnv *env;
|
||||
JNIEnv *env /* env in which this cache entry was created */;
|
||||
jclass globalClassObj /* global ref to java.lang.Object */;
|
||||
jclass globalClassLong /* global ref to java.lang.Long */;
|
||||
jmethodID ctorLong1 /* the Long(long) constructor */;
|
||||
@ -298,7 +310,7 @@ static void NphCacheLine_clear(JNIEnv *env, NphCacheLine * p){
|
||||
}
|
||||
|
||||
static void JNIEnvCacheLine_clear(JNIEnvCacheLine * p){
|
||||
JNIEnv *env = p->env;
|
||||
JNIEnv * const env = p->env;
|
||||
int i;
|
||||
if(env){
|
||||
UNREF_G(p->globalClassObj);
|
||||
@ -323,9 +335,9 @@ static void JNIEnvCache_clear(JNIEnvCache * p){
|
||||
*/
|
||||
typedef struct {
|
||||
JNIEnv * env; /* env registered from */;
|
||||
jobject jObj /* BusyHandlerJni instance */;
|
||||
jobject jObj /* BusyHandler instance */;
|
||||
jclass klazz /* jObj's class */;
|
||||
jmethodID jmidxCallback;
|
||||
jmethodID jmidxCallback /* klazz's xCallback method */;
|
||||
} BusyHandlerJni;
|
||||
|
||||
|
||||
|
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
||||
C Fix\san\sincorrect\sfile\spath\sin\sext/jni/README.md
|
||||
D 2023-07-28T18:02:02.238
|
||||
C Internal\sJNI\sbinding\sdocs.
|
||||
D 2023-07-28T18:44:11.596
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||
@ -232,7 +232,7 @@ F ext/icu/icu.c c074519b46baa484bb5396c7e01e051034da8884bad1a1cb7f09bbe6be3f0282
|
||||
F ext/icu/sqliteicu.h fa373836ed5a1ee7478bdf8a1650689294e41d0c89c1daab26e9ae78a32075a8
|
||||
F ext/jni/GNUmakefile 56a014dbff9516774d895ec1ae9df0ed442765b556f79a0fc0b5bc438217200d
|
||||
F ext/jni/README.md b62f1f0e67a6295e9a0283d4dffad6ed30ec50352aa36b3bd323a26593606c0f
|
||||
F ext/jni/src/c/sqlite3-jni.c 9d0d58f3633bd8f467f893f45548873ed2c5451c673b0782b3cc6bfa92327b10
|
||||
F ext/jni/src/c/sqlite3-jni.c f7f4934cb2698c674842974c1b47d0cba0927ebc5781b0c15304b7ed6c46b743
|
||||
F ext/jni/src/c/sqlite3-jni.h c9bb150a38dce09cc2794d5aac8fa097288d9946fbb15250fd0a23c31957f506
|
||||
F ext/jni/src/org/sqlite/jni/BusyHandler.java 1b1d3e5c86cd796a0580c81b6af6550ad943baa25e47ada0dcca3aff3ebe978c
|
||||
F ext/jni/src/org/sqlite/jni/Collation.java 8dffbb00938007ad0967b2ab424d3c908413af1bbd3d212b9c9899910f1218d1
|
||||
@ -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 e21cf2e8f13465dbff33f9c21580752c1d8c077d6a253f56f04dab0d47eb99b8
|
||||
R c9d00a4dcbaf6ac6c795d4a5ee33d6c2
|
||||
P bcefa2df563260933c7ab5df90872580f71010c11419f6b1de7b1e2747237ff8
|
||||
R 934bdd7c3796e2624766f5d43e958073
|
||||
U stephan
|
||||
Z 889f38fca7122981dd02f9cd0f38c680
|
||||
Z 1f7372379f92cca45c2da16bb8bc1a04
|
||||
# Remove this line to create a well-formed Fossil manifest.
|
||||
|
@ -1 +1 @@
|
||||
bcefa2df563260933c7ab5df90872580f71010c11419f6b1de7b1e2747237ff8
|
||||
991c66197e4dc7297fce3b20a1b4846873bcd4ce8add36aac71bd2e0e73c207b
|
Loading…
Reference in New Issue
Block a user