Make a constant really constant (A104)
Change-Id: Ied1f9f96a574b1e6a8ee0a71bfb1604d9c962e1c
diff --git a/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp b/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp
index bee0662..4b18322 100644
--- a/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp
+++ b/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp
@@ -46,7 +46,8 @@
static jlong latinime_BinaryDictionary_open(JNIEnv *env, jobject object,
jstring sourceDir, jlong dictOffset, jlong dictSize,
- jint typedLetterMultiplier, jint fullWordMultiplier, jint maxWordLength, jint maxWords) {
+ jint typedLetterMultiplier, jint fullWordMultiplier, jint maxWordLength, jint maxWords,
+ jint maxPredictions) {
PROF_OPEN;
PROF_START(66);
const char *sourceDirChars = env->GetStringUTFChars(sourceDir, 0);
@@ -119,7 +120,7 @@
#endif // USE_MMAP_FOR_DICTIONARY
} else {
dictionary = new Dictionary(dictBuf, dictSize, fd, adjust, typedLetterMultiplier,
- fullWordMultiplier, maxWordLength, maxWords);
+ fullWordMultiplier, maxWordLength, maxWords, maxPredictions);
}
PROF_END(66);
PROF_CLOSE;
@@ -258,7 +259,7 @@
}
static JNINativeMethod sMethods[] = {
- {"openNative", "(Ljava/lang/String;JJIIII)J", (void*)latinime_BinaryDictionary_open},
+ {"openNative", "(Ljava/lang/String;JJIIIII)J", (void*)latinime_BinaryDictionary_open},
{"closeNative", "(J)V", (void*)latinime_BinaryDictionary_close},
{"getSuggestionsNative", "(JJ[I[I[I[I[IIIZ[IZ[C[I[I)I",
(void*) latinime_BinaryDictionary_getSuggestions},
diff --git a/native/jni/src/bigram_dictionary.cpp b/native/jni/src/bigram_dictionary.cpp
index 3bfbfad..2c3d165 100644
--- a/native/jni/src/bigram_dictionary.cpp
+++ b/native/jni/src/bigram_dictionary.cpp
@@ -27,8 +27,8 @@
namespace latinime {
-BigramDictionary::BigramDictionary(const unsigned char *dict, int maxWordLength)
- : DICT(dict), MAX_WORD_LENGTH(maxWordLength) {
+BigramDictionary::BigramDictionary(const unsigned char *dict, int maxWordLength, int maxPredictions)
+ : DICT(dict), MAX_WORD_LENGTH(maxWordLength), MAX_PREDICTIONS(maxPredictions) {
if (DEBUG_DICT) {
AKLOGI("BigramDictionary - constructor");
}
diff --git a/native/jni/src/bigram_dictionary.h b/native/jni/src/bigram_dictionary.h
index 5372276..fe5bd94 100644
--- a/native/jni/src/bigram_dictionary.h
+++ b/native/jni/src/bigram_dictionary.h
@@ -27,7 +27,7 @@
class Dictionary;
class BigramDictionary {
public:
- BigramDictionary(const unsigned char *dict, int maxWordLength);
+ BigramDictionary(const unsigned char *dict, int maxWordLength, int maxPredictions);
int getBigrams(const int32_t *word, int length, int *inputCodes, int codesSize,
unsigned short *outWords, int *frequencies, int maxWordLength, int maxBigrams) const;
int getBigramListPositionForWord(const int32_t *prevWord, const int prevWordLength,
@@ -49,6 +49,7 @@
const unsigned char *DICT;
const int MAX_WORD_LENGTH;
+ const int MAX_PREDICTIONS;
// TODO: Re-implement proximity correction for bigram correction
static const int MAX_ALTERNATIVES = 1;
};
diff --git a/native/jni/src/dictionary.cpp b/native/jni/src/dictionary.cpp
index 628a169..f3166e7 100644
--- a/native/jni/src/dictionary.cpp
+++ b/native/jni/src/dictionary.cpp
@@ -29,7 +29,7 @@
// TODO: Change the type of all keyCodes to uint32_t
Dictionary::Dictionary(void *dict, int dictSize, int mmapFd, int dictBufAdjust,
int typedLetterMultiplier, int fullWordMultiplier,
- int maxWordLength, int maxWords)
+ int maxWordLength, int maxWords, int maxPredictions)
: mDict((unsigned char*) dict), mDictSize(dictSize),
mMmapFd(mmapFd), mDictBufAdjust(dictBufAdjust) {
if (DEBUG_DICT) {
@@ -43,7 +43,7 @@
const unsigned int options = BinaryFormat::getFlags(mDict);
mUnigramDictionary = new UnigramDictionary(mDict + headerSize, typedLetterMultiplier,
fullWordMultiplier, maxWordLength, maxWords, options);
- mBigramDictionary = new BigramDictionary(mDict + headerSize, maxWordLength);
+ mBigramDictionary = new BigramDictionary(mDict + headerSize, maxWordLength, maxPredictions);
mGestureDecoder = new GestureDecoderWrapper(maxWordLength, maxWords);
mGestureDecoder->setDict(mUnigramDictionary, mBigramDictionary,
mDict + headerSize /* dict root */, 0 /* root pos */);
diff --git a/native/jni/src/dictionary.h b/native/jni/src/dictionary.h
index 431f103..6742b48 100644
--- a/native/jni/src/dictionary.h
+++ b/native/jni/src/dictionary.h
@@ -32,7 +32,7 @@
class Dictionary {
public:
Dictionary(void *dict, int dictSize, int mmapFd, int dictBufAdjust, int typedLetterMultipler,
- int fullWordMultiplier, int maxWordLength, int maxWords);
+ int fullWordMultiplier, int maxWordLength, int maxWords, int maxPredictions);
int getSuggestions(ProximityInfo *proximityInfo, int *xcoordinates, int *ycoordinates,
int *times, int *pointerIds, int *codes, int codesSize, int *prevWordChars,