Fix JNI as 64bit ready

Change-Id: I7a3ed2cee3b20744869aa5cf89ff9fd95f5ab8fe
main
Tadashi G. Takaoka 2011-10-31 20:44:01 +09:00
parent adc5e6f12c
commit 5fdcd7d5cd
4 changed files with 27 additions and 27 deletions

View File

@ -75,16 +75,16 @@ public class ProximityInfo {
return spellCheckerProximityInfo; return spellCheckerProximityInfo;
} }
private int mNativeProximityInfo; private long mNativeProximityInfo;
static { static {
Utils.loadNativeLibrary(); Utils.loadNativeLibrary();
} }
private native int setProximityInfoNative(int maxProximityCharsSize, int displayWidth, private native long setProximityInfoNative(int maxProximityCharsSize, int displayWidth,
int displayHeight, int gridWidth, int gridHeight, int[] proximityCharsArray, int displayHeight, int gridWidth, int gridHeight, int[] proximityCharsArray,
int keyCount, int[] keyXCoordinates, int[] keyYCoordinates, int keyCount, int[] keyXCoordinates, int[] keyYCoordinates,
int[] keyWidths, int[] keyHeights, int[] keyCharCodes, int[] keyWidths, int[] keyHeights, int[] keyCharCodes,
float[] sweetSpotCenterX, float[] sweetSpotCenterY, float[] sweetSpotRadii); float[] sweetSpotCenterX, float[] sweetSpotCenterY, float[] sweetSpotRadii);
private native void releaseProximityInfoNative(int nativeProximityInfo); private native void releaseProximityInfoNative(long nativeProximityInfo);
private final void setProximityInfo(int[][] gridNeighborKeyIndexes, int keyboardWidth, private final void setProximityInfo(int[][] gridNeighborKeyIndexes, int keyboardWidth,
int keyboardHeight, List<Key> keys, int keyboardHeight, List<Key> keys,
@ -157,7 +157,7 @@ public class ProximityInfo {
} }
} }
public int getNativeProximityInfo() { public long getNativeProximityInfo() {
return mNativeProximityInfo; return mNativeProximityInfo;
} }

View File

@ -46,7 +46,7 @@ public class BinaryDictionary extends Dictionary {
private static final int TYPED_LETTER_MULTIPLIER = 2; private static final int TYPED_LETTER_MULTIPLIER = 2;
private int mDicTypeId; private int mDicTypeId;
private int mNativeDict; private long mNativeDict;
private final int[] mInputCodes = new int[MAX_WORD_LENGTH * MAX_PROXIMITY_CHARS_SIZE]; private final int[] mInputCodes = new int[MAX_WORD_LENGTH * MAX_PROXIMITY_CHARS_SIZE];
private final char[] mOutputChars = new char[MAX_WORD_LENGTH * MAX_WORDS]; private final char[] mOutputChars = new char[MAX_WORD_LENGTH * MAX_WORDS];
private final char[] mOutputChars_bigrams = new char[MAX_WORD_LENGTH * MAX_BIGRAMS]; private final char[] mOutputChars_bigrams = new char[MAX_WORD_LENGTH * MAX_BIGRAMS];
@ -107,15 +107,15 @@ public class BinaryDictionary extends Dictionary {
Utils.loadNativeLibrary(); Utils.loadNativeLibrary();
} }
private native int openNative(String sourceDir, long dictOffset, long dictSize, private native long openNative(String sourceDir, long dictOffset, long dictSize,
int typedLetterMultiplier, int fullWordMultiplier, int maxWordLength, int typedLetterMultiplier, int fullWordMultiplier, int maxWordLength,
int maxWords, int maxAlternatives); int maxWords, int maxAlternatives);
private native void closeNative(int dict); private native void closeNative(long dict);
private native boolean isValidWordNative(int nativeData, char[] word, int wordLength); private native boolean isValidWordNative(long dict, char[] word, int wordLength);
private native int getSuggestionsNative(int dict, int proximityInfo, int[] xCoordinates, private native int getSuggestionsNative(long dict, long proximityInfo, int[] xCoordinates,
int[] yCoordinates, int[] inputCodes, int codesSize, int flags, char[] outputChars, int[] yCoordinates, int[] inputCodes, int codesSize, int flags, char[] outputChars,
int[] scores); int[] scores);
private native int getBigramsNative(int dict, char[] prevWord, int prevWordLength, private native int getBigramsNative(long dict, char[] prevWord, int prevWordLength,
int[] inputCodes, int inputCodesLength, char[] outputChars, int[] scores, int[] inputCodes, int inputCodesLength, char[] outputChars, int[] scores,
int maxWordLength, int maxBigrams, int maxAlternatives); int maxWordLength, int maxBigrams, int maxAlternatives);

View File

@ -28,7 +28,7 @@
namespace latinime { namespace latinime {
static jint latinime_Keyboard_setProximityInfo(JNIEnv *env, jobject object, static jlong latinime_Keyboard_setProximityInfo(JNIEnv *env, jobject object,
jint maxProximityCharsSize, jint displayWidth, jint displayHeight, jint gridWidth, jint maxProximityCharsSize, jint displayWidth, jint displayHeight, jint gridWidth,
jint gridHeight, jintArray proximityCharsArray, jint keyCount, jint gridHeight, jintArray proximityCharsArray, jint keyCount,
jintArray keyXCoordinateArray, jintArray keyYCoordinateArray, jintArray keyWidthArray, jintArray keyXCoordinateArray, jintArray keyYCoordinateArray, jintArray keyWidthArray,
@ -59,19 +59,19 @@ static jint latinime_Keyboard_setProximityInfo(JNIEnv *env, jobject object,
safeReleaseIntArrayElements(env, keyYCoordinateArray, keyYCoordinates); safeReleaseIntArrayElements(env, keyYCoordinateArray, keyYCoordinates);
safeReleaseIntArrayElements(env, keyXCoordinateArray, keyXCoordinates); safeReleaseIntArrayElements(env, keyXCoordinateArray, keyXCoordinates);
env->ReleaseIntArrayElements(proximityCharsArray, proximityChars, 0); env->ReleaseIntArrayElements(proximityCharsArray, proximityChars, 0);
return (jint)proximityInfo; return (jlong)proximityInfo;
} }
static void latinime_Keyboard_release(JNIEnv *env, jobject object, jint proximityInfo) { static void latinime_Keyboard_release(JNIEnv *env, jobject object, jlong proximityInfo) {
ProximityInfo *pi = (ProximityInfo*)proximityInfo; ProximityInfo *pi = (ProximityInfo*)proximityInfo;
if (!pi) return; if (!pi) return;
delete pi; delete pi;
} }
static JNINativeMethod sKeyboardMethods[] = { static JNINativeMethod sKeyboardMethods[] = {
{"setProximityInfoNative", "(IIIII[II[I[I[I[I[I[F[F[F)I", {"setProximityInfoNative", "(IIIII[II[I[I[I[I[I[F[F[F)J",
(void*)latinime_Keyboard_setProximityInfo}, (void*)latinime_Keyboard_setProximityInfo},
{"releaseProximityInfoNative", "(I)V", (void*)latinime_Keyboard_release} {"releaseProximityInfoNative", "(J)V", (void*)latinime_Keyboard_release}
}; };
int register_ProximityInfo(JNIEnv *env) { int register_ProximityInfo(JNIEnv *env) {

View File

@ -42,7 +42,7 @@ namespace latinime {
void releaseDictBuf(void* dictBuf, const size_t length, int fd); void releaseDictBuf(void* dictBuf, const size_t length, int fd);
static jint latinime_BinaryDictionary_open(JNIEnv *env, jobject object, static jlong latinime_BinaryDictionary_open(JNIEnv *env, jobject object,
jstring sourceDir, jlong dictOffset, jlong dictSize, jstring sourceDir, jlong dictOffset, jlong dictSize,
jint typedLetterMultiplier, jint fullWordMultiplier, jint maxWordLength, jint maxWords, jint typedLetterMultiplier, jint fullWordMultiplier, jint maxWordLength, jint maxWords,
jint maxAlternatives) { jint maxAlternatives) {
@ -122,11 +122,11 @@ static jint latinime_BinaryDictionary_open(JNIEnv *env, jobject object,
} }
PROF_END(66); PROF_END(66);
PROF_CLOSE; PROF_CLOSE;
return (jint)dictionary; return (jlong)dictionary;
} }
static int latinime_BinaryDictionary_getSuggestions(JNIEnv *env, jobject object, jint dict, static int latinime_BinaryDictionary_getSuggestions(JNIEnv *env, jobject object, jlong dict,
jint proximityInfo, jintArray xCoordinatesArray, jintArray yCoordinatesArray, jlong proximityInfo, jintArray xCoordinatesArray, jintArray yCoordinatesArray,
jintArray inputArray, jint arraySize, jint flags, jintArray inputArray, jint arraySize, jint flags,
jcharArray outputArray, jintArray frequencyArray) { jcharArray outputArray, jintArray frequencyArray) {
Dictionary *dictionary = (Dictionary*)dict; Dictionary *dictionary = (Dictionary*)dict;
@ -152,7 +152,7 @@ static int latinime_BinaryDictionary_getSuggestions(JNIEnv *env, jobject object,
return count; return count;
} }
static int latinime_BinaryDictionary_getBigrams(JNIEnv *env, jobject object, jint dict, static int latinime_BinaryDictionary_getBigrams(JNIEnv *env, jobject object, jlong dict,
jcharArray prevWordArray, jint prevWordLength, jintArray inputArray, jint inputArraySize, jcharArray prevWordArray, jint prevWordLength, jintArray inputArray, jint inputArraySize,
jcharArray outputArray, jintArray frequencyArray, jint maxWordLength, jint maxBigrams, jcharArray outputArray, jintArray frequencyArray, jint maxWordLength, jint maxBigrams,
jint maxAlternatives) { jint maxAlternatives) {
@ -176,7 +176,7 @@ static int latinime_BinaryDictionary_getBigrams(JNIEnv *env, jobject object, jin
return count; return count;
} }
static jboolean latinime_BinaryDictionary_isValidWord(JNIEnv *env, jobject object, jint dict, static jboolean latinime_BinaryDictionary_isValidWord(JNIEnv *env, jobject object, jlong dict,
jcharArray wordArray, jint wordLength) { jcharArray wordArray, jint wordLength) {
Dictionary *dictionary = (Dictionary*)dict; Dictionary *dictionary = (Dictionary*)dict;
if (!dictionary) return (jboolean) false; if (!dictionary) return (jboolean) false;
@ -188,7 +188,7 @@ static jboolean latinime_BinaryDictionary_isValidWord(JNIEnv *env, jobject objec
return result; return result;
} }
static void latinime_BinaryDictionary_close(JNIEnv *env, jobject object, jint dict) { static void latinime_BinaryDictionary_close(JNIEnv *env, jobject object, jlong dict) {
Dictionary *dictionary = (Dictionary*)dict; Dictionary *dictionary = (Dictionary*)dict;
if (!dictionary) return; if (!dictionary) return;
void *dictBuf = dictionary->getDict(); void *dictBuf = dictionary->getDict();
@ -218,11 +218,11 @@ void releaseDictBuf(void* dictBuf, const size_t length, int fd) {
} }
static JNINativeMethod sMethods[] = { static JNINativeMethod sMethods[] = {
{"openNative", "(Ljava/lang/String;JJIIIII)I", (void*)latinime_BinaryDictionary_open}, {"openNative", "(Ljava/lang/String;JJIIIII)J", (void*)latinime_BinaryDictionary_open},
{"closeNative", "(I)V", (void*)latinime_BinaryDictionary_close}, {"closeNative", "(J)V", (void*)latinime_BinaryDictionary_close},
{"getSuggestionsNative", "(II[I[I[III[C[I)I", (void*)latinime_BinaryDictionary_getSuggestions}, {"getSuggestionsNative", "(JJ[I[I[III[C[I)I", (void*)latinime_BinaryDictionary_getSuggestions},
{"isValidWordNative", "(I[CI)Z", (void*)latinime_BinaryDictionary_isValidWord}, {"isValidWordNative", "(J[CI)Z", (void*)latinime_BinaryDictionary_isValidWord},
{"getBigramsNative", "(I[CI[II[C[IIII)I", (void*)latinime_BinaryDictionary_getBigrams} {"getBigramsNative", "(J[CI[II[C[IIII)I", (void*)latinime_BinaryDictionary_getBigrams}
}; };
int register_BinaryDictionary(JNIEnv *env) { int register_BinaryDictionary(JNIEnv *env) {