mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 02:09:35 +02:00
synchronization with native branch
This commit is contained in:
parent
4eb420ecaa
commit
f6452297c7
5 changed files with 38 additions and 2 deletions
|
@ -35,6 +35,7 @@ LOCAL_LDLIBS := -lz
|
||||||
LOCAL_STATIC_LIBRARIES := expat
|
LOCAL_STATIC_LIBRARIES := expat
|
||||||
|
|
||||||
LOCAL_SRC_FILES := \
|
LOCAL_SRC_FILES := \
|
||||||
|
NativeFormats/main.cpp \
|
||||||
NativeFormats/JavaNativeFormatPlugin.cpp \
|
NativeFormats/JavaNativeFormatPlugin.cpp \
|
||||||
NativeFormats/JavaPluginCollection.cpp \
|
NativeFormats/JavaPluginCollection.cpp \
|
||||||
NativeFormats/util/AndroidUtil.cpp \
|
NativeFormats/util/AndroidUtil.cpp \
|
||||||
|
|
28
jni/NativeFormats/main.cpp
Normal file
28
jni/NativeFormats/main.cpp
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2011-2012 Geometer Plus <contact@geometerplus.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||||
|
* 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <jni.h>
|
||||||
|
|
||||||
|
#include <AndroidUtil.h>
|
||||||
|
|
||||||
|
extern "C"
|
||||||
|
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved) {
|
||||||
|
AndroidUtil::init(jvm);
|
||||||
|
return JNI_VERSION_1_2;
|
||||||
|
}
|
|
@ -66,7 +66,7 @@ JNIEnv *AndroidUtil::getEnv() {
|
||||||
return env;
|
return env;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CHECK_NULL(value) if ((value) == 0) { return false; }
|
#define CHECK_NULL(value) if ((value) == 0) { throwRuntimeException(env, #value); }
|
||||||
|
|
||||||
bool AndroidUtil::init(JavaVM* jvm) {
|
bool AndroidUtil::init(JavaVM* jvm) {
|
||||||
ourJavaVM = jvm;
|
ourJavaVM = jvm;
|
||||||
|
@ -167,3 +167,8 @@ std::string AndroidUtil::convertNonUtfString(const std::string &str) {
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AndroidUtil::throwRuntimeException(JNIEnv *env, const std::string &message) {
|
||||||
|
jclass cls = env->FindClass("java/lang/RuntimeException");
|
||||||
|
env->ThrowNew(cls, message.c_str());
|
||||||
|
}
|
||||||
|
|
|
@ -77,6 +77,8 @@ public:
|
||||||
static bool extractJavaString(JNIEnv *env, jstring from, std::string &to);
|
static bool extractJavaString(JNIEnv *env, jstring from, std::string &to);
|
||||||
static jstring createJavaString(JNIEnv* env, const std::string &str);
|
static jstring createJavaString(JNIEnv* env, const std::string &str);
|
||||||
static std::string convertNonUtfString(const std::string &str);
|
static std::string convertNonUtfString(const std::string &str);
|
||||||
|
|
||||||
|
static void throwRuntimeException(JNIEnv *env, const std::string &message);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __ANDROIDUTIL_H__ */
|
#endif /* __ANDROIDUTIL_H__ */
|
||||||
|
|
|
@ -8,6 +8,6 @@
|
||||||
# project structure.
|
# project structure.
|
||||||
|
|
||||||
java.encoding=utf-8
|
java.encoding=utf-8
|
||||||
proguard.config=proguard.cfg
|
#proguard.config=proguard.cfg
|
||||||
# Project target.
|
# Project target.
|
||||||
target=android-8
|
target=android-8
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue