mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
Duplicate code consolidation.
FossilOrigin-Name: 71f239747c7934310dedf9fc0cbf84fbeeed53808234067147335c12396849a1
This commit is contained in:
@ -1281,12 +1281,20 @@ static S3JniNphClass * S3JniGlobal__nph(JNIEnv * const env, S3JniNphRef const* p
|
||||
#define S3JniGlobal_nph(PREF) S3JniGlobal__nph(env, PREF)
|
||||
|
||||
/*
|
||||
** Returns the ID of the "nativePointer" field from the given
|
||||
** NativePointerHolder<T> class.
|
||||
** Common code for accessor functions for NativePointerHolder and
|
||||
** OutputPointer types. pRef must be a pointer from S3JniNphRefs. jOut
|
||||
** must be an instance of that class (Java's type safety takes care of
|
||||
** that requirement). If necessary, this fetches the jfieldID for
|
||||
** jOut's pRef->zMember, which must be of the type represented by the
|
||||
** JNI type signature pRef->zTypeSig, and stores it in
|
||||
** S3JniGlobal.nph[pRef->index]. Fails fatally if the pRef->zMember
|
||||
** property is not found, as that presents a serious internal misuse.
|
||||
**
|
||||
** Property lookups are cached on a per-pRef basis.
|
||||
*/
|
||||
static jfieldID NativePointerHolder_field(JNIEnv * const env,
|
||||
S3JniNphRef const* pRef){
|
||||
static jfieldID s3jni_nphop_field(JNIEnv * const env, S3JniNphRef const* pRef){
|
||||
S3JniNphClass * const pNC = S3JniGlobal_nph(pRef);
|
||||
|
||||
if( !pNC->fidValue ){
|
||||
S3JniMutex_Nph_enter;
|
||||
s3jni_incr( &SJG.metrics.nNphInit );
|
||||
@ -1294,10 +1302,11 @@ static jfieldID NativePointerHolder_field(JNIEnv * const env,
|
||||
pNC->fidValue = (*env)->GetFieldID(env, pNC->klazz,
|
||||
pRef->zMember, pRef->zTypeSig);
|
||||
S3JniExceptionIsFatal("Code maintenance required: missing "
|
||||
"nativePointer field.");
|
||||
"required S3JniNphClass::fidValue.");
|
||||
}
|
||||
S3JniMutex_Nph_leave;
|
||||
}
|
||||
assert( pNC->fidValue );
|
||||
return pNC->fidValue;
|
||||
}
|
||||
|
||||
@ -1308,7 +1317,8 @@ static jfieldID NativePointerHolder_field(JNIEnv * const env,
|
||||
*/
|
||||
static void NativePointerHolder__set(JNIEnv * env, S3JniNphRef const* pRef,
|
||||
jobject ppOut, const void * p){
|
||||
jfieldID const fid = NativePointerHolder_field(env, pRef);
|
||||
jfieldID const fid = s3jni_nphop_field(env, pRef);
|
||||
|
||||
S3JniMutex_Nph_enter;
|
||||
(*env)->SetLongField(env, ppOut, fid, (jlong)p);
|
||||
S3JniMutex_Nph_leave;
|
||||
@ -1319,23 +1329,21 @@ static void NativePointerHolder__set(JNIEnv * env, S3JniNphRef const* pRef,
|
||||
NativePointerHolder__set(env, PREF, PPOUT, P)
|
||||
|
||||
/*
|
||||
** Fetches a native ptr value from NativePointerHolder object ppOut.
|
||||
** zClassName must be a static string so we can use its address as a
|
||||
** cache key. This is a no-op if pObj is NULL.
|
||||
** Fetches a native ptr value from NativePointerHolder object pObj,
|
||||
** which must be of the native type described by pRef. This is a
|
||||
** no-op if pObj is NULL.
|
||||
*/
|
||||
static void * NativePointerHolder__get(JNIEnv * env, jobject pObj,
|
||||
S3JniNphRef const* pRef){
|
||||
void * rv = 0;
|
||||
if( pObj ){
|
||||
jfieldID const fid = NativePointerHolder_field(env, pRef);
|
||||
void * rv;
|
||||
jfieldID const fid = s3jni_nphop_field(env, pRef);
|
||||
S3JniMutex_Nph_enter;
|
||||
rv = (void*)(*env)->GetLongField(env, pObj, fid);
|
||||
S3JniMutex_Nph_leave;
|
||||
S3JniExceptionIsFatal("Cannot fetch NativePointerHolder.nativePointer.");
|
||||
return rv;
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
#define NativePointerHolder_get(JOBJ,NPHREF) \
|
||||
@ -1469,35 +1477,6 @@ static int S3JniAutoExtension_init(JNIEnv *const env,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** Common init for OutputPointer_set_Int32() and friends. pRef must be
|
||||
** a pointer from S3JniNphRefs. jOut must be an instance of that
|
||||
** class. If necessary, this fetches the jfieldID for jOut's [value]
|
||||
** property, which must be of the type represented by the JNI type
|
||||
** signature zTypeSig, and stores it in pRef's S3JniGlobal.nph entry.
|
||||
** Fails fatally if the property is not found, as that presents a
|
||||
** serious internal misuse.
|
||||
**
|
||||
** Property lookups are cached on a per-pRef basis. Do not use this
|
||||
** routine with the same pRef but different zTypeSig: it will
|
||||
** misbehave.
|
||||
*/
|
||||
static jfieldID OutputPointer_field(JNIEnv * const env, S3JniNphRef const * pRef){
|
||||
S3JniNphClass * const pNC = S3JniGlobal_nph(pRef);
|
||||
|
||||
assert( pNC->klazz );
|
||||
if( !pNC->fidValue ){
|
||||
S3JniMutex_Nph_enter;
|
||||
s3jni_incr( &SJG.metrics.nNphInit );
|
||||
if( !pNC->fidValue ){
|
||||
pNC->fidValue = (*env)->GetFieldID(env, pNC->klazz, pRef->zMember, pRef->zTypeSig);
|
||||
S3JniExceptionIsFatal("OutputPointer_field() could not find OutputPointer.*.value");
|
||||
}
|
||||
S3JniMutex_Nph_leave;
|
||||
}
|
||||
return pNC->fidValue;
|
||||
}
|
||||
|
||||
/*
|
||||
** Sets the value property of the OutputPointer.Int32 jOut object to
|
||||
** v.
|
||||
@ -1505,7 +1484,7 @@ static jfieldID OutputPointer_field(JNIEnv * const env, S3JniNphRef const * pRef
|
||||
static void OutputPointer_set_Int32(JNIEnv * const env, jobject const jOut,
|
||||
int v){
|
||||
(*env)->SetIntField(env, jOut,
|
||||
OutputPointer_field(
|
||||
s3jni_nphop_field(
|
||||
env, &S3JniNphRefs.OutputPointer_Int32
|
||||
), (jint)v);
|
||||
S3JniExceptionIsFatal("Cannot set OutputPointer.Int32.value");
|
||||
@ -1518,7 +1497,7 @@ static void OutputPointer_set_Int32(JNIEnv * const env, jobject const jOut,
|
||||
static void OutputPointer_set_Int64(JNIEnv * const env, jobject const jOut,
|
||||
jlong v){
|
||||
(*env)->SetLongField(env, jOut,
|
||||
OutputPointer_field(
|
||||
s3jni_nphop_field(
|
||||
env, &S3JniNphRefs.OutputPointer_Int64
|
||||
), v);
|
||||
S3JniExceptionIsFatal("Cannot set OutputPointer.Int64.value");
|
||||
@ -1532,7 +1511,7 @@ static void OutputPointer_set_obj(JNIEnv * const env,
|
||||
S3JniNphRef const * const pRef,
|
||||
jobject const jOut,
|
||||
jobject v){
|
||||
(*env)->SetObjectField(env, jOut, OutputPointer_field(env, pRef), v);
|
||||
(*env)->SetObjectField(env, jOut, s3jni_nphop_field(env, pRef), v);
|
||||
S3JniExceptionIsFatal("Cannot set OutputPointer.T.value");
|
||||
}
|
||||
|
||||
|
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
||||
C Move\sa\smetrics\scounter\sso\sthat\sit\scan\sbe\sused\sto\sindirectly\switness\sthe\srace\scondition\sfix\sfrom\s[f5274e00f17d58e0]\sby\srecording\svarying\sfinal\svalues\sfor\sthat\smetric\sacross\sconsecutive\smulti-threaded\stest\sruns.
|
||||
D 2023-08-28T13:18:46.495
|
||||
C Duplicate\scode\sconsolidation.
|
||||
D 2023-08-28T14:59:27.520
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||
@ -236,7 +236,7 @@ F ext/icu/sqliteicu.h fa373836ed5a1ee7478bdf8a1650689294e41d0c89c1daab26e9ae78a3
|
||||
F ext/jni/GNUmakefile 374873bf6d2cd6ceafb458e28b59140dbb074f01f7adddf7e15a3ee3daf44551
|
||||
F ext/jni/README.md 1332b1fa27918bd5d9ca2d0d4f3ac3a6ab86b9e3699dc5bfe32904a027f3d2a9
|
||||
F ext/jni/jar-dist.make 030aaa4ae71dd86e4ec5e7c1e6cd86f9dfa47c4592c070d2e35157e42498e1fa
|
||||
F ext/jni/src/c/sqlite3-jni.c 515464940aba09b6428f8a804660710aa365863d5a10699d5ac8321d83dddf64
|
||||
F ext/jni/src/c/sqlite3-jni.c 0b76d7947e474aa30f6636f42a4e00eb48ccad6f920f1d2a1ee2d9540709c578
|
||||
F ext/jni/src/c/sqlite3-jni.h 12e1a5ef5ee1795dc22577c285b4518dfd8aa4af45757f6cb81a555d967bf201
|
||||
F ext/jni/src/org/sqlite/jni/AbstractCollationCallback.java 95e88ba04f4aac51ffec65693e878e234088b2f21b387f4e4285c8b72b33e436
|
||||
F ext/jni/src/org/sqlite/jni/AggregateFunction.java 7312486bc65fecdb91753c0a4515799194e031f45edbe16a6373cea18f404dc4
|
||||
@ -2106,8 +2106,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 f5274e00f17d58e075f90ae5c1d4b38933da315e51592171fa35bcbd67b40b2a
|
||||
R 969ab0bad5a3d98cbcd198512cf4e202
|
||||
P 54d2209d24547dbb05e7c12daa27211593c34de8005e8adba0989b8d219f5f3b
|
||||
R 4b2923bf6d2c403adcf8638cd038e3aa
|
||||
U stephan
|
||||
Z 99163d5b88e11a26824bdaa0e0b1c0e2
|
||||
Z 68db36d58f6c1c3e233d49a0de3a9cc1
|
||||
# Remove this line to create a well-formed Fossil manifest.
|
||||
|
@ -1 +1 @@
|
||||
54d2209d24547dbb05e7c12daa27211593c34de8005e8adba0989b8d219f5f3b
|
||||
71f239747c7934310dedf9fc0cbf84fbeeed53808234067147335c12396849a1
|
Reference in New Issue
Block a user