Merge "Fix JNI" into jb-mr1-dev
This commit is contained in:
commit
814510305c
4 changed files with 16 additions and 9 deletions
|
@ -44,6 +44,10 @@
|
|||
<init>(...);
|
||||
}
|
||||
|
||||
-keepclasseswithmembernames class * {
|
||||
native <methods>;
|
||||
}
|
||||
|
||||
-keep class com.android.inputmethod.research.ResearchLogger {
|
||||
void flush();
|
||||
void publishCurrentLogUnit(...);
|
||||
|
|
|
@ -79,6 +79,7 @@ public class BinaryDictionary extends Dictionary {
|
|||
mUseFullEditDistance = useFullEditDistance;
|
||||
loadDictionary(filename, offset, length);
|
||||
mDicTraverseSession = new DicTraverseSession(locale);
|
||||
mDicTraverseSession.initSession(mNativeDict);
|
||||
}
|
||||
|
||||
static {
|
||||
|
|
|
@ -23,8 +23,8 @@ public class DicTraverseSession {
|
|||
JniUtils.loadNativeLibrary();
|
||||
}
|
||||
private native long setDicTraverseSessionNative(String locale);
|
||||
//private native void initDicTraverseSessionNative(long nativeDicTraverseSession,
|
||||
//long dictionary, int[] previousWord, int previousWordLength);
|
||||
private native void initDicTraverseSessionNative(long nativeDicTraverseSession,
|
||||
long dictionary, int[] previousWord, int previousWordLength);
|
||||
private native void releaseDicTraverseSessionNative(long nativeDicTraverseSession);
|
||||
|
||||
private long mNativeDicTraverseSession;
|
||||
|
@ -43,8 +43,8 @@ public class DicTraverseSession {
|
|||
}
|
||||
|
||||
public void initSession(long dictionary, int[] previousWord, int previousWordLength) {
|
||||
//initDicTraverseSessionNative(
|
||||
//mNativeDicTraverseSession, dictionary, previousWord, previousWordLength);
|
||||
initDicTraverseSessionNative(
|
||||
mNativeDicTraverseSession, dictionary, previousWord, previousWordLength);
|
||||
}
|
||||
|
||||
private final long createNativeDicTraverseSession(String locale) {
|
||||
|
|
|
@ -28,18 +28,20 @@ static jlong latinime_setDicTraverseSession(JNIEnv *env, jobject object, jstring
|
|||
return reinterpret_cast<jlong>(traverseSession);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void latinime_initDicTraverseSession(JNIEnv *env, jobject object, jlong traverseSession,
|
||||
jlong dictionary, jintArray previousWord, jint previousWordLength) {
|
||||
void *ts = reinterpret_cast<void*>(traverseSession);
|
||||
Dictionary *dict = reinterpret_cast<Dictionary*>(dictionary);
|
||||
if (!previousWord) {
|
||||
DicTraverseWrapper::initDicTraverseSession(ts, dict, 0, 0);
|
||||
return;
|
||||
}
|
||||
int prevWord[previousWordLength];
|
||||
env->GetIntArrayRegion(previousWord, 0, previousWordLength, prevWord);
|
||||
DicTraverseWrapper::initDicTraverseSession(ts, dict, prevWord, previousWordLength);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void latinime_DicTraverseSession_release(
|
||||
static void latinime_releaseDicTraverseSession(
|
||||
JNIEnv *env, jobject object, jlong traverseSession) {
|
||||
void *ts = reinterpret_cast<void*>(traverseSession);
|
||||
DicTraverseWrapper::releaseDicTraverseSession(ts);
|
||||
|
@ -47,8 +49,8 @@ static void latinime_DicTraverseSession_release(
|
|||
|
||||
static JNINativeMethod sMethods[] = {
|
||||
{"setDicTraverseSessionNative", "(Ljava/lang/String;)J", (void*)latinime_setDicTraverseSession},
|
||||
//{"initDicTraverseSessionNative", "(JJ[II)V", (void*)latinime_initDicTraverseSession},
|
||||
{"releaseDicTraverseSessionNative", "(J)V", (void*)latinime_DicTraverseSession_release}
|
||||
{"initDicTraverseSessionNative", "(JJ[II)V", (void*)latinime_initDicTraverseSession},
|
||||
{"releaseDicTraverseSessionNative", "(J)V", (void*)latinime_releaseDicTraverseSession}
|
||||
};
|
||||
|
||||
int register_DicTraverseSession(JNIEnv *env) {
|
||||
|
|
Loading…
Reference in a new issue