aboutsummaryrefslogtreecommitdiffstats
path: root/native/jni/src/defines.h
diff options
context:
space:
mode:
Diffstat (limited to 'native/jni/src/defines.h')
-rw-r--r--native/jni/src/defines.h43
1 files changed, 21 insertions, 22 deletions
diff --git a/native/jni/src/defines.h b/native/jni/src/defines.h
index 96abfe8d4..4d5a2b261 100644
--- a/native/jni/src/defines.h
+++ b/native/jni/src/defines.h
@@ -23,19 +23,25 @@
#define AK_FORCE_INLINE inline
#endif // __GNUC__
-// This must be greater than or equal to MAX_WORD_LENGTH defined in BinaryDictionary.java
-#define MAX_WORD_LENGTH_INTERNAL 48
+#if defined(FLAG_DO_PROFILE) || defined(FLAG_DBG)
+#undef AK_FORCE_INLINE
+#define AK_FORCE_INLINE inline
+#endif // defined(FLAG_DO_PROFILE) || defined(FLAG_DBG)
+
+// Must be identical to Constants.Dictionary.MAX_WORD_LENGTH in Java
+#define MAX_WORD_LENGTH 48
+// Must be identical to BinaryDictionary.MAX_RESULTS in Java
+#define MAX_RESULTS 18
#if defined(FLAG_DO_PROFILE) || defined(FLAG_DBG)
#include <android/log.h>
#ifndef LOG_TAG
#define LOG_TAG "LatinIME: "
-#endif
+#endif // LOG_TAG
#define AKLOGE(fmt, ...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, fmt, ##__VA_ARGS__)
#define AKLOGI(fmt, ...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, fmt, ##__VA_ARGS__)
-#define DUMP_RESULT(words, frequencies, maxWordCount, maxWordLength) do { \
- dumpResult(words, frequencies, maxWordCount, maxWordLength); } while (0)
+#define DUMP_RESULT(words, frequencies) do { dumpResult(words, frequencies); } while (0)
#define DUMP_WORD(word, length) do { dumpWord(word, length); } while (0)
#define INTS_TO_CHARS(input, length, output) do { \
intArrayToCharArray(input, length, output); } while (0)
@@ -45,7 +51,7 @@ AK_FORCE_INLINE static int intArrayToCharArray(const int *source, const int sour
char *dest) {
int si = 0;
int di = 0;
- while (si < sourceSize && di < MAX_WORD_LENGTH_INTERNAL - 1 && 0 != source[si]) {
+ while (si < sourceSize && di < MAX_WORD_LENGTH - 1 && 0 != source[si]) {
const int codePoint = source[si++];
if (codePoint < 0x7F) {
dest[di++] = codePoint;
@@ -71,11 +77,10 @@ static inline void dumpWordInfo(const int *word, const int length, const int ran
}
}
-static inline void dumpResult(const int *outWords, const int *frequencies, const int maxWordCounts,
- const int maxWordLength) {
+static inline void dumpResult(const int *outWords, const int *frequencies) {
AKLOGI("--- DUMP RESULT ---------");
- for (int i = 0; i < maxWordCounts; ++i) {
- dumpWordInfo(&outWords[i * maxWordLength], maxWordLength, i, frequencies[i]);
+ for (int i = 0; i < MAX_RESULTS; ++i) {
+ dumpWordInfo(&outWords[i * MAX_WORD_LENGTH], MAX_WORD_LENGTH, i, frequencies[i]);
}
AKLOGI("-------------------------");
}
@@ -110,23 +115,23 @@ static inline void showStackTrace() {
}
free(strs);
}
-#else
+#else // __ANDROID__
#include <cassert>
#define DO_ASSERT_TEST
#define ASSERT(success) assert(success)
#define SHOW_STACK_TRACE
-#endif
+#endif // __ANDROID__
-#else
+#else // defined(FLAG_DO_PROFILE) || defined(FLAG_DBG)
#define AKLOGE(fmt, ...)
#define AKLOGI(fmt, ...)
-#define DUMP_RESULT(words, frequencies, maxWordCount, maxWordLength)
+#define DUMP_RESULT(words, frequencies)
#define DUMP_WORD(word, length)
#undef DO_ASSERT_TEST
#define ASSERT(success)
#define SHOW_STACK_TRACE
#define INTS_TO_CHARS(input, length, output)
-#endif
+#endif // defined(FLAG_DO_PROFILE) || defined(FLAG_DBG)
#ifdef FLAG_DO_PROFILE
// Profiler
@@ -311,7 +316,7 @@ static inline void prof_out(void) {
#define TWO_WORDS_CAPITALIZED_DEMOTION_RATE 50
#define TWO_WORDS_CORRECTION_DEMOTION_BASE 80
#define TWO_WORDS_PLUS_OTHER_ERROR_CORRECTION_DEMOTION_DIVIDER 1
-#define ZERO_DISTANCE_PROMOTION_RATE 110
+#define ZERO_DISTANCE_PROMOTION_RATE 110.0f
#define NEUTRAL_SCORE_SQUARED_RADIUS 8.0f
#define HALF_SCORE_SQUARED_RADIUS 32.0f
#define MAX_FREQ 255
@@ -347,14 +352,8 @@ static inline void prof_out(void) {
#define SUPPRESS_SHORT_MULTIPLE_WORDS_THRESHOLD_FREQ (MAX_FREQ * 58 / 100)
#define MAX_DEPTH_MULTIPLIER 3
-
#define FIRST_WORD_INDEX 0
-#define MAX_SPACES_INTERNAL 16
-
-// TODO: Change this to MAX_WORDS, remove MAX_WORDS in Java, and stop getting it from Java
-#define MAX_WORDS_INTERNAL 18
-
// Max Distance between point to key
#define MAX_POINT_TO_KEY_LENGTH 10000000