Skip to content

Commit

Permalink
refactor(jni): minor adjust to the headers
Browse files Browse the repository at this point in the history
split the common definitions to the jni-common.h
  • Loading branch information
WhiredPlanck committed Dec 13, 2022
1 parent 405d779 commit 7d3e450
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 25 deletions.
17 changes: 17 additions & 0 deletions app/src/main/jni/librime_jni/jni-common.h
@@ -0,0 +1,17 @@
#ifndef TRIME_JNI_COMMON_H
#define TRIME_JNI_COMMON_H

#include "jni-utils.h"

static GlobalRefSingleton *GlobalRef;

#define TAG "rime.jni"
#ifdef ANDROID
#include <android/log.h>
#define ALOGE(fmt, ...) __android_log_print(ANDROID_LOG_ERROR, TAG, fmt, ##__VA_ARGS__)
#define ALOGI(fmt, ...) __android_log_print(ANDROID_LOG_INFO, TAG, fmt, ##__VA_ARGS__)
#endif

#define BUFSIZE 256

#endif //TRIME_JNI_COMMON_H
3 changes: 1 addition & 2 deletions app/src/main/jni/librime_jni/levers.cc
@@ -1,6 +1,5 @@
#include "jni-common.h"
#include "rime_jni.h"
#include <jni.h>
#include <rime_levers_api.h>

// customize settings

Expand Down
6 changes: 0 additions & 6 deletions app/src/main/jni/librime_jni/levers.h

This file was deleted.

4 changes: 1 addition & 3 deletions app/src/main/jni/librime_jni/rime_jni.cc
@@ -1,8 +1,6 @@
#include <jni.h>
#include <string>
#include <rime_api.h>
#include "rime_jni.h"
#include "levers.h"
#include "jni-common.h"

extern void rime_require_module_lua();
extern void rime_require_module_charcode();
Expand Down
18 changes: 4 additions & 14 deletions app/src/main/jni/librime_jni/rime_jni.h
@@ -1,20 +1,10 @@
#ifndef RIME_JNI_H_
#define RIME_JNI_H_

#include "jni-utils.h"
#include <jni.h>
#include <rime_api.h>
#include <rime_levers_api.h>

static GlobalRefSingleton *GlobalRef;

#define TAG "Rime-JNI"
#ifdef ANDROID
#include <android/log.h>
#define ALOGE(fmt, ...) __android_log_print(ANDROID_LOG_ERROR, TAG, fmt, ##__VA_ARGS__)
#define ALOGI(fmt, ...) __android_log_print(ANDROID_LOG_INFO, TAG, fmt, ##__VA_ARGS__)
#else
#define ALOGE printf
#define ALOGI printf
#endif

#define BUFSIZE 256
jobject rimeSchemaListToJObject(JNIEnv *env, RimeSchemaList* list);

#endif // RIME_JNI_H_

0 comments on commit 7d3e450

Please sign in to comment.