mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-03 17:59:33 +02:00
jmethodID => Method classes
This commit is contained in:
parent
daf77393a2
commit
e3d0663ee7
11 changed files with 106 additions and 69 deletions
|
@ -17,8 +17,6 @@
|
|||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include <AndroidUtil.h>
|
||||
#include <JniEnvelope.h>
|
||||
#include <ZLFileImage.h>
|
||||
|
@ -31,7 +29,7 @@
|
|||
#include "fbreader/src/library/Tag.h"
|
||||
|
||||
static shared_ptr<FormatPlugin> findCppPlugin(JNIEnv *env, jobject base) {
|
||||
jstring fileTypeJava = (jstring)env->CallObjectMethod(base, AndroidUtil::MID_NativeFormatPlugin_supportedFileType);
|
||||
jstring fileTypeJava = AndroidUtil::Method_NativeFormatPlugin_supportedFileType->call(base);
|
||||
const std::string fileTypeCpp = AndroidUtil::fromJavaString(env, fileTypeJava);
|
||||
env->DeleteLocalRef(fileTypeJava);
|
||||
shared_ptr<FormatPlugin> plugin = PluginCollection::Instance().pluginByType(fileTypeCpp);
|
||||
|
@ -197,7 +195,7 @@ static jobject createTextModel(JNIEnv *env, jobject javaModel, ZLTextModel &mode
|
|||
jstring fileExtension = env->NewStringUTF(model.allocator().fileExtension().c_str());
|
||||
jint blocksNumber = (jint) model.allocator().blocksNumber();
|
||||
|
||||
jobject textModel = env->CallObjectMethod(javaModel, AndroidUtil::MID_NativeBookModel_createTextModel,
|
||||
jobject textModel = AndroidUtil::Method_NativeBookModel_createTextModel->call(javaModel,
|
||||
id, language,
|
||||
paragraphsNumber, entryIndices, entryOffsets,
|
||||
paragraphLenghts, textSizes, paragraphKinds,
|
||||
|
@ -292,7 +290,7 @@ JNIEXPORT void JNICALL Java_org_geometerplus_fbreader_formats_NativeFormatPlugin
|
|||
return;
|
||||
}
|
||||
|
||||
jstring javaPath = (jstring)env->CallObjectMethod(file, AndroidUtil::MID_ZLFile_getPath);
|
||||
jstring javaPath = AndroidUtil::Method_ZLFile_getPath->call(file);
|
||||
const std::string path = AndroidUtil::fromJavaString(env, javaPath);
|
||||
env->DeleteLocalRef(javaPath);
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <set>
|
||||
|
||||
#include <AndroidUtil.h>
|
||||
#include <JniEnvelope.h>
|
||||
|
||||
#include <ZLStringUtil.h>
|
||||
#include <ZLFile.h>
|
||||
|
@ -87,20 +88,20 @@ shared_ptr<Book> Book::loadFromJavaBook(JNIEnv *env, jobject javaBook) {
|
|||
jstring javaString;
|
||||
|
||||
jobject javaFile = env->GetObjectField(javaBook, AndroidUtil::FID_Book_File);
|
||||
javaString = (jstring)env->CallObjectMethod(javaFile, AndroidUtil::MID_ZLFile_getPath);
|
||||
javaString = AndroidUtil::Method_ZLFile_getPath->call(javaFile);
|
||||
const std::string path = AndroidUtil::fromJavaString(env, javaString);
|
||||
env->DeleteLocalRef(javaString);
|
||||
env->DeleteLocalRef(javaFile);
|
||||
|
||||
javaString = (jstring)env->CallObjectMethod(javaBook, AndroidUtil::MID_Book_getTitle);
|
||||
javaString = AndroidUtil::Method_Book_getTitle->call(javaBook);
|
||||
const std::string title = AndroidUtil::fromJavaString(env, javaString);
|
||||
env->DeleteLocalRef(javaString);
|
||||
|
||||
javaString = (jstring)env->CallObjectMethod(javaBook, AndroidUtil::MID_Book_getLanguage);
|
||||
javaString = AndroidUtil::Method_Book_getLanguage->call(javaBook);
|
||||
const std::string language = AndroidUtil::fromJavaString(env, javaString);
|
||||
env->DeleteLocalRef(javaString);
|
||||
|
||||
javaString = (jstring) env->CallObjectMethod(javaBook, AndroidUtil::MID_Book_getEncodingNoDetection);
|
||||
javaString = AndroidUtil::Method_Book_getEncodingNoDetection->call(javaBook);
|
||||
const std::string encoding = AndroidUtil::fromJavaString(env, javaString);
|
||||
env->DeleteLocalRef(javaString);
|
||||
|
||||
|
|
|
@ -43,42 +43,42 @@ const char * const AndroidUtil::Class_Tag = "org/geometerplus/fbreader/library/T
|
|||
const char * const AndroidUtil::Class_NativeBookModel = "org/geometerplus/fbreader/bookmodel/NativeBookModel";
|
||||
const char * const AndroidUtil::Class_BookReadingException = "org/geometerplus/fbreader/bookmodel/BookReadingException";
|
||||
|
||||
jmethodID AndroidUtil::MID_java_lang_String_toLowerCase;
|
||||
jmethodID AndroidUtil::MID_java_lang_String_toUpperCase;
|
||||
shared_ptr<StringMethod> AndroidUtil::Method_java_lang_String_toLowerCase;
|
||||
shared_ptr<StringMethod> AndroidUtil::Method_java_lang_String_toUpperCase;
|
||||
|
||||
jmethodID AndroidUtil::MID_java_util_Collection_toArray;
|
||||
|
||||
jmethodID AndroidUtil::SMID_java_util_Locale_getDefault;
|
||||
jmethodID AndroidUtil::MID_java_util_Locale_getLanguage;
|
||||
shared_ptr<StringMethod> AndroidUtil::Method_java_util_Locale_getLanguage;
|
||||
|
||||
shared_ptr<VoidMethod> AndroidUtil::Method_java_io_InputStream_close;
|
||||
shared_ptr<IntMethod> AndroidUtil::Method_java_io_InputStream_read;
|
||||
shared_ptr<LongMethod> AndroidUtil::Method_java_io_InputStream_skip;
|
||||
|
||||
jmethodID AndroidUtil::SMID_ZLibrary_Instance;
|
||||
jmethodID AndroidUtil::MID_ZLibrary_getVersionName;
|
||||
shared_ptr<StringMethod> AndroidUtil::Method_ZLibrary_getVersionName;
|
||||
|
||||
jmethodID AndroidUtil::MID_NativeFormatPlugin_init;
|
||||
jmethodID AndroidUtil::MID_NativeFormatPlugin_supportedFileType;
|
||||
shared_ptr<StringMethod> AndroidUtil::Method_NativeFormatPlugin_supportedFileType;
|
||||
|
||||
jmethodID AndroidUtil::SMID_PluginCollection_Instance;
|
||||
|
||||
jmethodID AndroidUtil::MID_Encoding_createConverter;
|
||||
shared_ptr<ObjectMethod> AndroidUtil::Method_Encoding_createConverter;
|
||||
|
||||
jfieldID AndroidUtil::FID_EncodingConverter_Name;
|
||||
shared_ptr<IntMethod> AndroidUtil::Method_EncodingConverter_convert;
|
||||
shared_ptr<VoidMethod> AndroidUtil::Method_EncodingConverter_reset;
|
||||
|
||||
jmethodID AndroidUtil::SMID_JavaEncodingCollection_Instance;
|
||||
jmethodID AndroidUtil::MID_JavaEncodingCollection_getEncoding_int;
|
||||
jmethodID AndroidUtil::MID_JavaEncodingCollection_getEncoding_String;
|
||||
shared_ptr<ObjectMethod> AndroidUtil::Method_JavaEncodingCollection_getEncoding_int;
|
||||
shared_ptr<ObjectMethod> AndroidUtil::Method_JavaEncodingCollection_getEncoding_String;
|
||||
shared_ptr<BooleanMethod> AndroidUtil::Method_JavaEncodingCollection_providesConverterFor;
|
||||
|
||||
jmethodID AndroidUtil::SMID_ZLFile_createFileByPath;
|
||||
jmethodID AndroidUtil::MID_ZLFile_children;
|
||||
shared_ptr<ObjectMethod> AndroidUtil::Method_ZLFile_children;
|
||||
shared_ptr<BooleanMethod> AndroidUtil::Method_ZLFile_exists;
|
||||
jmethodID AndroidUtil::MID_ZLFile_getInputStream;
|
||||
jmethodID AndroidUtil::MID_ZLFile_getPath;
|
||||
shared_ptr<ObjectMethod> AndroidUtil::Method_ZLFile_getInputStream;
|
||||
shared_ptr<StringMethod> AndroidUtil::Method_ZLFile_getPath;
|
||||
shared_ptr<BooleanMethod> AndroidUtil::Method_ZLFile_isDirectory;
|
||||
shared_ptr<LongMethod> AndroidUtil::Method_ZLFile_size;
|
||||
|
||||
|
@ -87,9 +87,9 @@ jmethodID AndroidUtil::MID_ZLFileImage_init;
|
|||
jmethodID AndroidUtil::SMID_Paths_cacheDirectory;
|
||||
|
||||
jfieldID AndroidUtil::FID_Book_File;
|
||||
jmethodID AndroidUtil::MID_Book_getTitle;
|
||||
jmethodID AndroidUtil::MID_Book_getLanguage;
|
||||
jmethodID AndroidUtil::MID_Book_getEncodingNoDetection;
|
||||
shared_ptr<StringMethod> AndroidUtil::Method_Book_getTitle;
|
||||
shared_ptr<StringMethod> AndroidUtil::Method_Book_getLanguage;
|
||||
shared_ptr<StringMethod> AndroidUtil::Method_Book_getEncodingNoDetection;
|
||||
shared_ptr<VoidMethod> AndroidUtil::Method_Book_setTitle;
|
||||
shared_ptr<VoidMethod> AndroidUtil::Method_Book_setSeriesInfo;
|
||||
shared_ptr<VoidMethod> AndroidUtil::Method_Book_setLanguage;
|
||||
|
@ -103,7 +103,7 @@ jmethodID AndroidUtil::SMID_Tag_getTag;
|
|||
jfieldID AndroidUtil::FID_NativeBookModel_Book;
|
||||
shared_ptr<VoidMethod> AndroidUtil::Method_NativeBookModel_initInternalHyperlinks;
|
||||
shared_ptr<VoidMethod> AndroidUtil::Method_NativeBookModel_initTOC;
|
||||
jmethodID AndroidUtil::MID_NativeBookModel_createTextModel;
|
||||
shared_ptr<ObjectMethod> AndroidUtil::Method_NativeBookModel_createTextModel;
|
||||
shared_ptr<VoidMethod> AndroidUtil::Method_NativeBookModel_setBookTextModel;
|
||||
shared_ptr<VoidMethod> AndroidUtil::Method_NativeBookModel_setFootnoteModel;
|
||||
shared_ptr<VoidMethod> AndroidUtil::Method_NativeBookModel_addImage;
|
||||
|
@ -117,7 +117,6 @@ JNIEnv *AndroidUtil::getEnv() {
|
|||
}
|
||||
|
||||
#define CHECK_NULL(value) if ((value) == 0) { return false; }
|
||||
#define CHECK_METHOD(method) if (!(method).check()) { return false; }
|
||||
|
||||
bool AndroidUtil::init(JavaVM* jvm) {
|
||||
ourJavaVM = jvm;
|
||||
|
@ -126,8 +125,8 @@ bool AndroidUtil::init(JavaVM* jvm) {
|
|||
jclass cls;
|
||||
|
||||
CHECK_NULL( cls = env->FindClass(Class_java_lang_String) );
|
||||
CHECK_NULL( MID_java_lang_String_toLowerCase = env->GetMethodID(cls, "toLowerCase", "()Ljava/lang/String;") );
|
||||
CHECK_NULL( MID_java_lang_String_toUpperCase = env->GetMethodID(cls, "toUpperCase", "()Ljava/lang/String;") );
|
||||
Method_java_lang_String_toLowerCase = new StringMethod(env, cls, "toLowerCase", "()");
|
||||
Method_java_lang_String_toUpperCase = new StringMethod(env, cls, "toUpperCase", "()");
|
||||
env->DeleteLocalRef(cls);
|
||||
|
||||
CHECK_NULL( cls = env->FindClass(Class_java_util_Collection) );
|
||||
|
@ -137,7 +136,7 @@ bool AndroidUtil::init(JavaVM* jvm) {
|
|||
|
||||
CHECK_NULL( cls = env->FindClass(Class_java_util_Locale) );
|
||||
CHECK_NULL( SMID_java_util_Locale_getDefault = env->GetStaticMethodID(cls, "getDefault", "()Ljava/util/Locale;") );
|
||||
CHECK_NULL( MID_java_util_Locale_getLanguage = env->GetMethodID(cls, "getLanguage", "()Ljava/lang/String;") );
|
||||
Method_java_util_Locale_getLanguage = new StringMethod(env, cls, "getLanguage", "()");
|
||||
env->DeleteLocalRef(cls);
|
||||
|
||||
CHECK_NULL( cls = env->FindClass(Class_java_io_InputStream) );
|
||||
|
@ -148,12 +147,12 @@ bool AndroidUtil::init(JavaVM* jvm) {
|
|||
|
||||
CHECK_NULL( cls = env->FindClass(Class_ZLibrary) );
|
||||
CHECK_NULL( SMID_ZLibrary_Instance = env->GetStaticMethodID(cls, "Instance", "()Lorg/geometerplus/zlibrary/core/library/ZLibrary;") );
|
||||
CHECK_NULL( MID_ZLibrary_getVersionName = env->GetMethodID(cls, "getVersionName", "()Ljava/lang/String;") );
|
||||
Method_ZLibrary_getVersionName = new StringMethod(env, cls, "getVersionName", "()");
|
||||
env->DeleteLocalRef(cls);
|
||||
|
||||
CHECK_NULL( cls = env->FindClass(Class_NativeFormatPlugin) );
|
||||
CHECK_NULL( MID_NativeFormatPlugin_init = env->GetMethodID(cls, "<init>", "(Ljava/lang/String;)V") );
|
||||
CHECK_NULL( MID_NativeFormatPlugin_supportedFileType = env->GetMethodID(cls, "supportedFileType", "()Ljava/lang/String;") );
|
||||
Method_NativeFormatPlugin_supportedFileType = new StringMethod(env, cls, "supportedFileType", "()");
|
||||
env->DeleteLocalRef(cls);
|
||||
|
||||
CHECK_NULL( cls = env->FindClass(Class_PluginCollection) );
|
||||
|
@ -161,7 +160,7 @@ bool AndroidUtil::init(JavaVM* jvm) {
|
|||
env->DeleteLocalRef(cls);
|
||||
|
||||
CHECK_NULL( cls = env->FindClass(Class_Encoding) );
|
||||
CHECK_NULL( MID_Encoding_createConverter = env->GetMethodID(cls, "createConverter", "()Lorg/geometerplus/zlibrary/core/encodings/EncodingConverter;") );
|
||||
Method_Encoding_createConverter = new ObjectMethod(env, cls, "createConverter", "()", "org/geometerplus/zlibrary/core/encodings/EncodingConverter");
|
||||
env->DeleteLocalRef(cls);
|
||||
|
||||
CHECK_NULL( cls = env->FindClass(Class_EncodingConverter) );
|
||||
|
@ -172,18 +171,18 @@ bool AndroidUtil::init(JavaVM* jvm) {
|
|||
|
||||
CHECK_NULL( cls = env->FindClass(Class_JavaEncodingCollection) );
|
||||
CHECK_NULL( SMID_JavaEncodingCollection_Instance = env->GetStaticMethodID(cls, "Instance", "()Lorg/geometerplus/zlibrary/core/encodings/JavaEncodingCollection;") );
|
||||
CHECK_NULL( MID_JavaEncodingCollection_getEncoding_String = env->GetMethodID(cls, "getEncoding", "(Ljava/lang/String;)Lorg/geometerplus/zlibrary/core/encodings/Encoding;") );
|
||||
CHECK_NULL( MID_JavaEncodingCollection_getEncoding_int = env->GetMethodID(cls, "getEncoding", "(I)Lorg/geometerplus/zlibrary/core/encodings/Encoding;") );
|
||||
Method_JavaEncodingCollection_getEncoding_String = new ObjectMethod(env, cls, "getEncoding", "(Ljava/lang/String;)", "org/geometerplus/zlibrary/core/encodings/Encoding");
|
||||
Method_JavaEncodingCollection_getEncoding_int = new ObjectMethod(env, cls, "getEncoding", "(I)", "org/geometerplus/zlibrary/core/encodings/Encoding");
|
||||
Method_JavaEncodingCollection_providesConverterFor = new BooleanMethod(env, cls, "providesConverterFor", "(Ljava/lang/String;)");
|
||||
env->DeleteLocalRef(cls);
|
||||
|
||||
CHECK_NULL( cls = env->FindClass(Class_ZLFile) );
|
||||
CHECK_NULL( SMID_ZLFile_createFileByPath = env->GetStaticMethodID(cls, "createFileByPath", "(Ljava/lang/String;)Lorg/geometerplus/zlibrary/core/filesystem/ZLFile;") );
|
||||
CHECK_NULL( MID_ZLFile_children = env->GetMethodID(cls, "children", "()Ljava/util/List;") );
|
||||
Method_ZLFile_children = new ObjectMethod(env, cls, "children", "()", "java/util/List");
|
||||
Method_ZLFile_exists = new BooleanMethod(env, cls, "exists", "()");
|
||||
Method_ZLFile_isDirectory = new BooleanMethod(env, cls, "isDirectory", "()");
|
||||
CHECK_NULL( MID_ZLFile_getInputStream = env->GetMethodID(cls, "getInputStream", "()Ljava/io/InputStream;") );
|
||||
CHECK_NULL( MID_ZLFile_getPath = env->GetMethodID(cls, "getPath", "()Ljava/lang/String;") );
|
||||
Method_ZLFile_getInputStream = new ObjectMethod(env, cls, "getInputStream", "()", "java/io/InputStream");
|
||||
Method_ZLFile_getPath = new StringMethod(env, cls, "getPath", "()");
|
||||
Method_ZLFile_size = new LongMethod(env, cls, "size", "()");
|
||||
env->DeleteLocalRef(cls);
|
||||
|
||||
|
@ -197,9 +196,9 @@ bool AndroidUtil::init(JavaVM* jvm) {
|
|||
|
||||
CHECK_NULL( cls = env->FindClass(Class_Book) );
|
||||
CHECK_NULL( FID_Book_File = env->GetFieldID(cls, "File", "Lorg/geometerplus/zlibrary/core/filesystem/ZLFile;") );
|
||||
CHECK_NULL( MID_Book_getTitle = env->GetMethodID(cls, "getTitle", "()Ljava/lang/String;") );
|
||||
CHECK_NULL( MID_Book_getLanguage = env->GetMethodID(cls, "getLanguage", "()Ljava/lang/String;") );
|
||||
CHECK_NULL( MID_Book_getEncodingNoDetection = env->GetMethodID(cls, "getEncodingNoDetection", "()Ljava/lang/String;") );
|
||||
Method_Book_getTitle = new StringMethod(env, cls, "getTitle", "()");
|
||||
Method_Book_getLanguage = new StringMethod(env, cls, "getLanguage", "()");
|
||||
Method_Book_getEncodingNoDetection = new StringMethod(env, cls, "getEncodingNoDetection", "()");
|
||||
Method_Book_setTitle = new VoidMethod(env, cls, "setTitle", "(Ljava/lang/String;)");
|
||||
Method_Book_setSeriesInfo = new VoidMethod(env, cls, "setSeriesInfo", "(Ljava/lang/String;F)");
|
||||
Method_Book_setLanguage = new VoidMethod(env, cls, "setLanguage", "(Ljava/lang/String;)");
|
||||
|
@ -217,7 +216,7 @@ bool AndroidUtil::init(JavaVM* jvm) {
|
|||
CHECK_NULL( FID_NativeBookModel_Book = env->GetFieldID(cls, "Book", "Lorg/geometerplus/fbreader/library/Book;") );
|
||||
Method_NativeBookModel_initInternalHyperlinks = new VoidMethod(env, cls, "initInternalHyperlinks", "(Ljava/lang/String;Ljava/lang/String;I)");
|
||||
Method_NativeBookModel_initTOC = new VoidMethod(env, cls, "initTOC", "(Lorg/geometerplus/zlibrary/text/model/ZLTextModel;[I[I)");
|
||||
CHECK_NULL( MID_NativeBookModel_createTextModel = env->GetMethodID(cls, "createTextModel", "(Ljava/lang/String;Ljava/lang/String;I[I[I[I[I[BLjava/lang/String;Ljava/lang/String;I)Lorg/geometerplus/zlibrary/text/model/ZLTextModel;") );
|
||||
Method_NativeBookModel_createTextModel = new ObjectMethod(env, cls, "createTextModel", "(Ljava/lang/String;Ljava/lang/String;I[I[I[I[I[BLjava/lang/String;Ljava/lang/String;I)", "org/geometerplus/zlibrary/text/model/ZLTextModel");
|
||||
Method_NativeBookModel_setBookTextModel = new VoidMethod(env, cls, "setBookTextModel", "(Lorg/geometerplus/zlibrary/text/model/ZLTextModel;)");
|
||||
Method_NativeBookModel_setFootnoteModel = new VoidMethod(env, cls, "setFootnoteModel", "(Lorg/geometerplus/zlibrary/text/model/ZLTextModel;)");
|
||||
Method_NativeBookModel_addImage = new VoidMethod(env, cls, "addImage", "(Ljava/lang/String;Lorg/geometerplus/zlibrary/core/image/ZLImage;)");
|
||||
|
|
|
@ -31,6 +31,7 @@ class VoidMethod;
|
|||
class IntMethod;
|
||||
class LongMethod;
|
||||
class BooleanMethod;
|
||||
class StringMethod;
|
||||
class ObjectMethod;
|
||||
|
||||
class ZLFile;
|
||||
|
@ -60,53 +61,53 @@ public:
|
|||
static const char * const Class_NativeBookModel;
|
||||
static const char * const Class_BookReadingException;
|
||||
|
||||
static jmethodID MID_java_lang_String_toLowerCase;
|
||||
static jmethodID MID_java_lang_String_toUpperCase;
|
||||
static shared_ptr<StringMethod> Method_java_lang_String_toLowerCase;
|
||||
static shared_ptr<StringMethod> Method_java_lang_String_toUpperCase;
|
||||
|
||||
static jmethodID MID_java_util_Collection_toArray;
|
||||
|
||||
static jmethodID SMID_java_util_Locale_getDefault;
|
||||
static jmethodID MID_java_util_Locale_getLanguage;
|
||||
static shared_ptr<StringMethod> Method_java_util_Locale_getLanguage;
|
||||
|
||||
static shared_ptr<VoidMethod> Method_java_io_InputStream_close;
|
||||
static shared_ptr<IntMethod> Method_java_io_InputStream_read;
|
||||
static shared_ptr<LongMethod> Method_java_io_InputStream_skip;
|
||||
|
||||
static jmethodID SMID_ZLibrary_Instance;
|
||||
static jmethodID MID_ZLibrary_getVersionName;
|
||||
static shared_ptr<StringMethod> Method_ZLibrary_getVersionName;
|
||||
|
||||
static jmethodID SMID_ZLFile_createFileByPath;
|
||||
static jmethodID MID_ZLFile_children;
|
||||
static shared_ptr<ObjectMethod> Method_ZLFile_children;
|
||||
static shared_ptr<BooleanMethod> Method_ZLFile_exists;
|
||||
static jmethodID MID_ZLFile_getInputStream;
|
||||
static jmethodID MID_ZLFile_getPath;
|
||||
static shared_ptr<ObjectMethod> Method_ZLFile_getInputStream;
|
||||
static shared_ptr<StringMethod> Method_ZLFile_getPath;
|
||||
static shared_ptr<BooleanMethod> Method_ZLFile_isDirectory;
|
||||
static shared_ptr<LongMethod> Method_ZLFile_size;
|
||||
|
||||
static jmethodID MID_ZLFileImage_init;
|
||||
|
||||
static jmethodID MID_NativeFormatPlugin_init;
|
||||
static jmethodID MID_NativeFormatPlugin_supportedFileType;
|
||||
static shared_ptr<StringMethod> Method_NativeFormatPlugin_supportedFileType;
|
||||
|
||||
static jmethodID SMID_PluginCollection_Instance;
|
||||
|
||||
static jmethodID MID_Encoding_createConverter;
|
||||
static shared_ptr<ObjectMethod> Method_Encoding_createConverter;
|
||||
|
||||
static jfieldID FID_EncodingConverter_Name;
|
||||
static shared_ptr<IntMethod> Method_EncodingConverter_convert;
|
||||
static shared_ptr<VoidMethod> Method_EncodingConverter_reset;
|
||||
|
||||
static jmethodID SMID_JavaEncodingCollection_Instance;
|
||||
static jmethodID MID_JavaEncodingCollection_getEncoding_String;
|
||||
static jmethodID MID_JavaEncodingCollection_getEncoding_int;
|
||||
static shared_ptr<ObjectMethod> Method_JavaEncodingCollection_getEncoding_String;
|
||||
static shared_ptr<ObjectMethod> Method_JavaEncodingCollection_getEncoding_int;
|
||||
static shared_ptr<BooleanMethod> Method_JavaEncodingCollection_providesConverterFor;
|
||||
|
||||
static jmethodID SMID_Paths_cacheDirectory;
|
||||
|
||||
static jfieldID FID_Book_File;
|
||||
static jmethodID MID_Book_getTitle;
|
||||
static jmethodID MID_Book_getLanguage;
|
||||
static jmethodID MID_Book_getEncodingNoDetection;
|
||||
static shared_ptr<StringMethod> Method_Book_getTitle;
|
||||
static shared_ptr<StringMethod> Method_Book_getLanguage;
|
||||
static shared_ptr<StringMethod> Method_Book_getEncodingNoDetection;
|
||||
static shared_ptr<VoidMethod> Method_Book_setTitle;
|
||||
static shared_ptr<VoidMethod> Method_Book_setSeriesInfo;
|
||||
static shared_ptr<VoidMethod> Method_Book_setLanguage;
|
||||
|
@ -120,7 +121,7 @@ public:
|
|||
static jfieldID FID_NativeBookModel_Book;
|
||||
static shared_ptr<VoidMethod> Method_NativeBookModel_initInternalHyperlinks;
|
||||
static shared_ptr<VoidMethod> Method_NativeBookModel_initTOC;
|
||||
static jmethodID MID_NativeBookModel_createTextModel;
|
||||
static shared_ptr<ObjectMethod> Method_NativeBookModel_createTextModel;
|
||||
static shared_ptr<VoidMethod> Method_NativeBookModel_setBookTextModel;
|
||||
static shared_ptr<VoidMethod> Method_NativeBookModel_setFootnoteModel;
|
||||
static shared_ptr<VoidMethod> Method_NativeBookModel_addImage;
|
||||
|
|
|
@ -63,4 +63,18 @@ public:
|
|||
jboolean call(jobject base, ...);
|
||||
};
|
||||
|
||||
class StringMethod : public Method {
|
||||
|
||||
public:
|
||||
StringMethod(JNIEnv *env, jclass cls, const std::string &name, const std::string &signature);
|
||||
jstring call(jobject base, ...);
|
||||
};
|
||||
|
||||
class ObjectMethod : public Method {
|
||||
|
||||
public:
|
||||
ObjectMethod(JNIEnv *env, jclass cls, const std::string &name, const std::string &returnType, const std::string &signature);
|
||||
jobject call(jobject base, ...);
|
||||
};
|
||||
|
||||
#endif /* __JNIENVELOPE_H__ */
|
||||
|
|
|
@ -69,3 +69,25 @@ jboolean BooleanMethod::call(jobject base, ...) {
|
|||
va_end(lst);
|
||||
return result;
|
||||
}
|
||||
|
||||
StringMethod::StringMethod(JNIEnv *env, jclass cls, const std::string &name, const std::string &signature) : Method(env, cls, name, signature + "Ljava/lang/String;") {
|
||||
}
|
||||
|
||||
jstring StringMethod::call(jobject base, ...) {
|
||||
va_list lst;
|
||||
va_start(lst, base);
|
||||
jstring result = (jstring)myEnv->CallObjectMethod(base, myId, lst);
|
||||
va_end(lst);
|
||||
return result;
|
||||
}
|
||||
|
||||
ObjectMethod::ObjectMethod(JNIEnv *env, jclass cls, const std::string &name, const std::string &returnType, const std::string &signature) : Method(env, cls, name, signature + "L" + returnType + ";") {
|
||||
}
|
||||
|
||||
jobject ObjectMethod::call(jobject base, ...) {
|
||||
va_list lst;
|
||||
va_start(lst, base);
|
||||
jobject result = myEnv->CallObjectMethod(base, myId, lst);
|
||||
va_end(lst);
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -68,8 +68,8 @@ JavaEncodingConverter::JavaEncodingConverter(const std::string &encoding) {
|
|||
jclass cls = env->FindClass(AndroidUtil::Class_JavaEncodingCollection);
|
||||
jobject collection = env->CallStaticObjectMethod(cls, AndroidUtil::SMID_JavaEncodingCollection_Instance);
|
||||
jstring encodingName = AndroidUtil::createJavaString(env, encoding);
|
||||
jobject javaEncoding = env->CallObjectMethod(collection, AndroidUtil::MID_JavaEncodingCollection_getEncoding_String, encodingName);
|
||||
myJavaConverter = env->CallObjectMethod(javaEncoding, AndroidUtil::MID_Encoding_createConverter);
|
||||
jobject javaEncoding = AndroidUtil::Method_JavaEncodingCollection_getEncoding_String->call(collection, encodingName);
|
||||
myJavaConverter = AndroidUtil::Method_Encoding_createConverter->call(javaEncoding);
|
||||
env->DeleteLocalRef(javaEncoding);
|
||||
env->DeleteLocalRef(encodingName);
|
||||
env->DeleteLocalRef(collection);
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <map>
|
||||
|
||||
#include <AndroidUtil.h>
|
||||
#include <JniEnvelope.h>
|
||||
|
||||
#include <ZLibrary.h>
|
||||
#include <ZLFile.h>
|
||||
|
@ -473,7 +474,7 @@ std::string ZLUnicodeUtil::toLower(const std::string &utf8String) {
|
|||
|
||||
JNIEnv *env = AndroidUtil::getEnv();
|
||||
jstring javaString = AndroidUtil::createJavaString(env, utf8String);
|
||||
jstring lowerCased = (jstring)env->CallObjectMethod(javaString, AndroidUtil::MID_java_lang_String_toLowerCase);
|
||||
jstring lowerCased = AndroidUtil::Method_java_lang_String_toLowerCase->call(javaString);
|
||||
if (javaString == lowerCased) {
|
||||
env->DeleteLocalRef(lowerCased);
|
||||
env->DeleteLocalRef(javaString);
|
||||
|
@ -517,7 +518,7 @@ std::string ZLUnicodeUtil::toUpper(const std::string &utf8String) {
|
|||
|
||||
JNIEnv *env = AndroidUtil::getEnv();
|
||||
jstring javaString = AndroidUtil::createJavaString(env, utf8String);
|
||||
jstring upperCased = (jstring)env->CallObjectMethod(javaString, AndroidUtil::MID_java_lang_String_toUpperCase);
|
||||
jstring upperCased = AndroidUtil::Method_java_lang_String_toUpperCase->call(javaString);
|
||||
if (javaString == upperCased) {
|
||||
env->DeleteLocalRef(upperCased);
|
||||
env->DeleteLocalRef(javaString);
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <set>
|
||||
|
||||
#include <AndroidUtil.h>
|
||||
#include <JniEnvelope.h>
|
||||
|
||||
#include "JavaFSDir.h"
|
||||
|
||||
|
@ -47,7 +48,7 @@ jobjectArray JavaFSDir::getFileChildren(JNIEnv *env) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
jobject list = env->CallObjectMethod(myJavaFile, AndroidUtil::MID_ZLFile_children);
|
||||
jobject list = AndroidUtil::Method_ZLFile_children->call(myJavaFile);
|
||||
if (list == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -73,7 +74,7 @@ void JavaFSDir::collectChildren(std::vector<std::string> &names, bool filesNotDi
|
|||
for (jsize i = 0; i < size; ++i) {
|
||||
jobject file = env->GetObjectArrayElement(array, i);
|
||||
|
||||
jstring javaPath = (jstring)env->CallObjectMethod(file, AndroidUtil::MID_ZLFile_getPath);
|
||||
jstring javaPath = AndroidUtil::Method_ZLFile_getPath->call(file);
|
||||
const char *chars = env->GetStringUTFChars(javaPath, 0);
|
||||
std::string path(chars);
|
||||
env->ReleaseStringUTFChars(javaPath, chars);
|
||||
|
|
|
@ -52,7 +52,7 @@ void JavaInputStream::initStream(JNIEnv *env) {
|
|||
}
|
||||
}
|
||||
|
||||
jobject stream = env->CallObjectMethod(myJavaFile, AndroidUtil::MID_ZLFile_getInputStream);
|
||||
jobject stream = AndroidUtil::Method_ZLFile_getInputStream->call(myJavaFile);
|
||||
if (env->ExceptionCheck()) {
|
||||
env->ExceptionClear();
|
||||
} else {
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <jni.h>
|
||||
#include <AndroidUtil.h>
|
||||
#include <JniEnvelope.h>
|
||||
|
||||
#include <ZLibrary.h>
|
||||
|
||||
|
@ -46,7 +46,7 @@ std::string ZLibrary::Language() {
|
|||
JNIEnv *env = AndroidUtil::getEnv();
|
||||
jclass cls = env->FindClass(AndroidUtil::Class_java_util_Locale);
|
||||
jobject locale = env->CallStaticObjectMethod(cls, AndroidUtil::SMID_java_util_Locale_getDefault);
|
||||
jstring javaLang = (jstring)env->CallObjectMethod(locale, AndroidUtil::MID_java_util_Locale_getLanguage);
|
||||
jstring javaLang = (jstring)AndroidUtil::Method_java_util_Locale_getLanguage->call(locale);
|
||||
const char *langData = env->GetStringUTFChars(javaLang, 0);
|
||||
std::string lang(langData);
|
||||
env->ReleaseStringUTFChars(javaLang, langData);
|
||||
|
@ -60,7 +60,7 @@ std::string ZLibrary::Version() {
|
|||
JNIEnv *env = AndroidUtil::getEnv();
|
||||
jclass cls = env->FindClass(AndroidUtil::Class_ZLibrary);
|
||||
jobject zlibrary = env->CallStaticObjectMethod(cls, AndroidUtil::SMID_ZLibrary_Instance);
|
||||
jstring javaVersion = (jstring)env->CallObjectMethod(zlibrary, AndroidUtil::MID_ZLibrary_getVersionName);
|
||||
jstring javaVersion = (jstring)AndroidUtil::Method_ZLibrary_getVersionName->call(zlibrary);
|
||||
const char *versionData = env->GetStringUTFChars(javaVersion, 0);
|
||||
std::string version(versionData);
|
||||
env->ReleaseStringUTFChars(javaVersion, versionData);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue