Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7c92b421 authored by Satoshi Kataoka's avatar Satoshi Kataoka
Browse files

Purge DicTraverseWrapper

bug: 8550444

Change-Id: Iad017e66ac579c6727b9f60ad9cda64e478200e5
parent 0e66ab74
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -47,7 +47,6 @@ LATIN_IME_JNI_SRC_FILES := \

LATIN_IME_CORE_SRC_FILES := \
    correction.cpp \
    dic_traverse_wrapper.cpp \
    unigram_dictionary.cpp \
    words_priority_queue.cpp \
    suggest/core/suggest.cpp \
+2 −1
Original line number Diff line number Diff line
@@ -137,7 +137,8 @@ static int latinime_BinaryDictionary_getSuggestions(JNIEnv *env, jclass clazz, j
    Dictionary *dictionary = reinterpret_cast<Dictionary *>(dict);
    if (!dictionary) return 0;
    ProximityInfo *pInfo = reinterpret_cast<ProximityInfo *>(proximityInfo);
    void *traverseSession = reinterpret_cast<void *>(dicTraverseSession);
    DicTraverseSession *traverseSession =
            reinterpret_cast<DicTraverseSession *>(dicTraverseSession);

    // Input values
    int xCoordinates[inputSize];
+8 −7
Original line number Diff line number Diff line
@@ -17,36 +17,37 @@
#define LOG_TAG "LatinIME: jni: Session"

#include "com_android_inputmethod_latin_DicTraverseSession.h"

#include "defines.h"
#include "dic_traverse_wrapper.h"
#include "jni.h"
#include "jni_common.h"
#include "suggest/core/session/dic_traverse_session.h"

namespace latinime {
class Dictionary;
static jlong latinime_setDicTraverseSession(JNIEnv *env, jclass clazz, jstring localeJStr) {
    void *traverseSession = DicTraverseWrapper::getDicTraverseSession(env, localeJStr);
    void *traverseSession = DicTraverseSession::getSessionInstance(env, localeJStr);
    return reinterpret_cast<jlong>(traverseSession);
}

static void latinime_initDicTraverseSession(JNIEnv *env, jclass clazz, jlong traverseSession,
        jlong dictionary, jintArray previousWord, jint previousWordLength) {
    void *ts = reinterpret_cast<void *>(traverseSession);
    DicTraverseSession *ts = reinterpret_cast<DicTraverseSession *>(traverseSession);
    Dictionary *dict = reinterpret_cast<Dictionary *>(dictionary);
    if (!previousWord) {
        DicTraverseWrapper::initDicTraverseSession(
        DicTraverseSession::initSessionInstance(
                ts, dict, 0 /* prevWord */, 0 /* prevWordLength*/, 0 /* suggestOptions */);
        return;
    }
    int prevWord[previousWordLength];
    env->GetIntArrayRegion(previousWord, 0, previousWordLength, prevWord);
    DicTraverseWrapper::initDicTraverseSession(
    DicTraverseSession::initSessionInstance(
            ts, dict, prevWord, previousWordLength, 0 /* suggestOptions */);
}

static void latinime_releaseDicTraverseSession(JNIEnv *env, jclass clazz, jlong traverseSession) {
    void *ts = reinterpret_cast<void *>(traverseSession);
    DicTraverseWrapper::releaseDicTraverseSession(ts);
    DicTraverseSession *ts = reinterpret_cast<DicTraverseSession *>(traverseSession);
    DicTraverseSession::releaseSessionInstance(ts);
}

static JNINativeMethod sMethods[] = {
+0 −26
Original line number Diff line number Diff line
/*
 * Copyright (C) 2012, The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#define LOG_TAG "LatinIME: jni: Session"

#include "dic_traverse_wrapper.h"

namespace latinime {
void *(*DicTraverseWrapper::sDicTraverseSessionFactoryMethod)(JNIEnv *, jstring) = 0;
void (*DicTraverseWrapper::sDicTraverseSessionReleaseMethod)(void *) = 0;
void (*DicTraverseWrapper::sDicTraverseSessionInitMethod)(
        void *, const Dictionary *const, const int *, const int, const SuggestOptions *const) = 0;
} // namespace latinime
+0 −68
Original line number Diff line number Diff line
/*
 * Copyright (C) 2012 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef LATINIME_DIC_TRAVERSE_WRAPPER_H
#define LATINIME_DIC_TRAVERSE_WRAPPER_H

#include "defines.h"
#include "jni.h"

namespace latinime {
class Dictionary;
class SuggestOptions;
// TODO: Remove
class DicTraverseWrapper {
 public:
    static void *getDicTraverseSession(JNIEnv *env, jstring locale) {
        if (sDicTraverseSessionFactoryMethod) {
            return sDicTraverseSessionFactoryMethod(env, locale);
        }
        return 0;
    }
    static void initDicTraverseSession(void *traverseSession, const Dictionary *const dictionary,
            const int *prevWord, const int prevWordLength,
            const SuggestOptions *const suggestOptions) {
        if (sDicTraverseSessionInitMethod) {
            sDicTraverseSessionInitMethod(
                    traverseSession, dictionary, prevWord, prevWordLength, suggestOptions);
        }
    }
    static void releaseDicTraverseSession(void *traverseSession) {
        if (sDicTraverseSessionReleaseMethod) {
            sDicTraverseSessionReleaseMethod(traverseSession);
        }
    }
    static void setTraverseSessionFactoryMethod(void *(*factoryMethod)(JNIEnv *, jstring)) {
        sDicTraverseSessionFactoryMethod = factoryMethod;
    }
    static void setTraverseSessionInitMethod(
            void (*initMethod)(void *, const Dictionary *const, const int *, const int,
                    const SuggestOptions *const)) {
        sDicTraverseSessionInitMethod = initMethod;
    }
    static void setTraverseSessionReleaseMethod(void (*releaseMethod)(void *)) {
        sDicTraverseSessionReleaseMethod = releaseMethod;
    }

 private:
    DISALLOW_IMPLICIT_CONSTRUCTORS(DicTraverseWrapper);
    static void *(*sDicTraverseSessionFactoryMethod)(JNIEnv *, jstring);
    static void (*sDicTraverseSessionInitMethod)(
            void *, const Dictionary *const, const int *, const int, const SuggestOptions *const);
    static void (*sDicTraverseSessionReleaseMethod)(void *);
};
} // namespace latinime
#endif // LATINIME_DIC_TRAVERSE_WRAPPER_H
Loading