aboutsummaryrefslogtreecommitdiffstats
path: root/native/jni/com_android_inputmethod_keyboard_ProximityInfo.cpp
diff options
context:
space:
mode:
authorKen Wakasa <kwakasa@google.com>2012-08-08 07:43:40 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-08-08 07:43:40 -0700
commit73205a3a1f7ddf7bacce8c78894e245a6ab654ba (patch)
tree6889b4afce3413fa621d80c605bdf2f3baf62a66 /native/jni/com_android_inputmethod_keyboard_ProximityInfo.cpp
parent8c5b13f49e47ff25c73f01a7ff9c46a2b4619866 (diff)
parentbb005f787f4e00bd832e6a78797be10af2994061 (diff)
downloadlatinime-73205a3a1f7ddf7bacce8c78894e245a6ab654ba.tar.gz
latinime-73205a3a1f7ddf7bacce8c78894e245a6ab654ba.tar.xz
latinime-73205a3a1f7ddf7bacce8c78894e245a6ab654ba.zip
am bb005f78: Start using JNI\'s Get<Type>ArrayRegion()
* commit 'bb005f787f4e00bd832e6a78797be10af2994061': Start using JNI's Get<Type>ArrayRegion()
Diffstat (limited to 'native/jni/com_android_inputmethod_keyboard_ProximityInfo.cpp')
-rw-r--r--native/jni/com_android_inputmethod_keyboard_ProximityInfo.cpp42
1 files changed, 10 insertions, 32 deletions
diff --git a/native/jni/com_android_inputmethod_keyboard_ProximityInfo.cpp b/native/jni/com_android_inputmethod_keyboard_ProximityInfo.cpp
index 0f2c2da43..a01ac3780 100644
--- a/native/jni/com_android_inputmethod_keyboard_ProximityInfo.cpp
+++ b/native/jni/com_android_inputmethod_keyboard_ProximityInfo.cpp
@@ -25,43 +25,21 @@ namespace latinime {
static jlong latinime_Keyboard_setProximityInfo(JNIEnv *env, jobject object,
jstring localeJStr, jint maxProximityCharsSize, jint displayWidth, jint displayHeight,
- jint gridWidth, jint gridHeight, jint mostCommonkeyWidth, jintArray proximityCharsArray,
- jint keyCount, jintArray keyXCoordinateArray, jintArray keyYCoordinateArray,
- jintArray keyWidthArray, jintArray keyHeightArray, jintArray keyCharCodeArray,
- jfloatArray sweetSpotCenterXArray, jfloatArray sweetSpotCenterYArray,
- jfloatArray sweetSpotRadiusArray) {
+ jint gridWidth, jint gridHeight, jint mostCommonkeyWidth, jintArray proximityChars,
+ jint keyCount, jintArray keyXCoordinates, jintArray keyYCoordinates,
+ jintArray keyWidths, jintArray keyHeights, jintArray keyCharCodes,
+ jfloatArray sweetSpotCenterXs, jfloatArray sweetSpotCenterYs, jfloatArray sweetSpotRadii) {
const char *localeCStr = env->GetStringUTFChars(localeJStr, 0);
- jint *proximityChars = env->GetIntArrayElements(proximityCharsArray, 0);
- jint *keyXCoordinates = safeGetIntArrayElements(env, keyXCoordinateArray);
- jint *keyYCoordinates = safeGetIntArrayElements(env, keyYCoordinateArray);
- jint *keyWidths = safeGetIntArrayElements(env, keyWidthArray);
- jint *keyHeights = safeGetIntArrayElements(env, keyHeightArray);
- jint *keyCharCodes = safeGetIntArrayElements(env, keyCharCodeArray);
- jfloat *sweetSpotCenterXs = safeGetFloatArrayElements(env, sweetSpotCenterXArray);
- jfloat *sweetSpotCenterYs = safeGetFloatArrayElements(env, sweetSpotCenterYArray);
- jfloat *sweetSpotRadii = safeGetFloatArrayElements(env, sweetSpotRadiusArray);
- ProximityInfo *proximityInfo = new ProximityInfo(
- localeCStr, maxProximityCharsSize, displayWidth, displayHeight, gridWidth, gridHeight,
- mostCommonkeyWidth, (const int32_t*)proximityChars, keyCount,
- (const int32_t*)keyXCoordinates, (const int32_t*)keyYCoordinates,
- (const int32_t*)keyWidths, (const int32_t*)keyHeights, (const int32_t*)keyCharCodes,
- (const float*)sweetSpotCenterXs, (const float*)sweetSpotCenterYs,
- (const float*)sweetSpotRadii);
- safeReleaseFloatArrayElements(env, sweetSpotRadiusArray, sweetSpotRadii);
- safeReleaseFloatArrayElements(env, sweetSpotCenterYArray, sweetSpotCenterYs);
- safeReleaseFloatArrayElements(env, sweetSpotCenterXArray, sweetSpotCenterXs);
- safeReleaseIntArrayElements(env, keyCharCodeArray, keyCharCodes);
- safeReleaseIntArrayElements(env, keyHeightArray, keyHeights);
- safeReleaseIntArrayElements(env, keyWidthArray, keyWidths);
- safeReleaseIntArrayElements(env, keyYCoordinateArray, keyYCoordinates);
- safeReleaseIntArrayElements(env, keyXCoordinateArray, keyXCoordinates);
- env->ReleaseIntArrayElements(proximityCharsArray, proximityChars, 0);
+ ProximityInfo *proximityInfo = new ProximityInfo(env, localeCStr, maxProximityCharsSize,
+ displayWidth, displayHeight, gridWidth, gridHeight, mostCommonkeyWidth, proximityChars,
+ keyCount, keyXCoordinates, keyYCoordinates, keyWidths, keyHeights, keyCharCodes,
+ sweetSpotCenterXs, sweetSpotCenterYs, sweetSpotRadii);
env->ReleaseStringUTFChars(localeJStr, localeCStr);
- return (jlong)proximityInfo;
+ return reinterpret_cast<jlong>(proximityInfo);
}
static void latinime_Keyboard_release(JNIEnv *env, jobject object, jlong proximityInfo) {
- ProximityInfo *pi = (ProximityInfo*)proximityInfo;
+ ProximityInfo *pi = reinterpret_cast<ProximityInfo*>(proximityInfo);
if (!pi) return;
delete pi;
}