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.h35
1 files changed, 31 insertions, 4 deletions
diff --git a/native/jni/src/defines.h b/native/jni/src/defines.h
index 0286365bc..95a90275d 100644
--- a/native/jni/src/defines.h
+++ b/native/jni/src/defines.h
@@ -31,6 +31,9 @@
dumpResult(words, frequencies, maxWordCount, maxWordLength); } while (0)
#define DUMP_WORD(word, length) do { dumpWord(word, length); } while (0)
#define DUMP_WORD_INT(word, length) do { dumpWordInt(word, length); } while (0)
+// TODO: INTS_TO_CHARS
+#define SHORTS_TO_CHARS(input, length, output) do { \
+ shortArrayToCharArray(input, length, output); } while (0)
static inline void dumpWordInfo(const unsigned short *word, const int length,
const int rank, const int frequency) {
@@ -87,12 +90,29 @@ static inline void dumpWordInt(const int *word, const int length) {
AKLOGI("i[ %s ]", charBuf);
}
-#ifndef __ANDROID__
-#define ASSERT(success) do { if (!success) { showStackTrace(); assert(success);};} while (0)
-#define SHOW_STACK_TRACE do { showStackTrace(); } while (0)
+// TODO: Change this to intArrayToCharArray
+static inline void shortArrayToCharArray(
+ const unsigned short *input, const int length, char *output) {
+ int i = 0;
+ for (;i < length; ++i) {
+ const unsigned short c = input[i];
+ if (c == 0) {
+ break;
+ }
+ // static_cast only for debugging
+ output[i] = static_cast<char>(c);
+ }
+ output[i] = 0;
+}
+#ifndef __ANDROID__
+#include <cassert>
#include <execinfo.h>
#include <stdlib.h>
+
+#define ASSERT(success) do { if (!(success)) { showStackTrace(); assert(success);} } while (0)
+#define SHOW_STACK_TRACE do { showStackTrace(); } while (0)
+
static inline void showStackTrace() {
void *callstack[128];
int i, frames = backtrace(callstack, 128);
@@ -107,7 +127,8 @@ static inline void showStackTrace() {
free(strs);
}
#else
-#define ASSERT(success)
+#include <cassert>
+#define ASSERT(success) assert(success)
#define SHOW_STACK_TRACE
#endif
@@ -119,6 +140,8 @@ static inline void showStackTrace() {
#define DUMP_WORD_INT(word, length)
#define ASSERT(success)
#define SHOW_STACK_TRACE
+// TODO: INTS_TO_CHARS
+#define SHORTS_TO_CHARS(input, length, output)
#endif
#ifdef FLAG_DO_PROFILE
@@ -197,6 +220,8 @@ static inline void prof_out(void) {
#define DEBUG_CORRECTION_FREQ false
#define DEBUG_WORDS_PRIORITY_QUEUE false
+#define DEBUG_GEO_FULL false
+
#else // FLAG_DBG
#define DEBUG_DICT false
@@ -211,6 +236,8 @@ static inline void prof_out(void) {
#define DEBUG_CORRECTION_FREQ false
#define DEBUG_WORDS_PRIORITY_QUEUE false
+#define DEBUG_GEO_FULL false
+
#endif // FLAG_DBG
#ifndef U_SHORT_MAX