mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 10:19:33 +02:00
VoidMethod: in progress
This commit is contained in:
parent
cf9abfb502
commit
36d85ecbff
7 changed files with 85 additions and 11 deletions
|
@ -41,6 +41,7 @@ LOCAL_SRC_FILES := \
|
||||||
NativeFormats/JavaNativeFormatPlugin.cpp \
|
NativeFormats/JavaNativeFormatPlugin.cpp \
|
||||||
NativeFormats/JavaPluginCollection.cpp \
|
NativeFormats/JavaPluginCollection.cpp \
|
||||||
NativeFormats/util/AndroidUtil.cpp \
|
NativeFormats/util/AndroidUtil.cpp \
|
||||||
|
NativeFormats/util/Method.cpp \
|
||||||
NativeFormats/util/VoidMethod.cpp \
|
NativeFormats/util/VoidMethod.cpp \
|
||||||
NativeFormats/zlibrary/core/src/constants/ZLXMLNamespace.cpp \
|
NativeFormats/zlibrary/core/src/constants/ZLXMLNamespace.cpp \
|
||||||
NativeFormats/zlibrary/core/src/encoding/DummyEncodingConverter.cpp \
|
NativeFormats/zlibrary/core/src/encoding/DummyEncodingConverter.cpp \
|
||||||
|
|
|
@ -55,7 +55,7 @@ jmethodID AndroidUtil::MID_java_io_InputStream_close;
|
||||||
jmethodID AndroidUtil::MID_java_io_InputStream_read;
|
jmethodID AndroidUtil::MID_java_io_InputStream_read;
|
||||||
jmethodID AndroidUtil::MID_java_io_InputStream_skip;
|
jmethodID AndroidUtil::MID_java_io_InputStream_skip;
|
||||||
|
|
||||||
jmethodID AndroidUtil::MID_java_io_PrintStream_println;
|
VoidMethod AndroidUtil::MID_java_io_PrintStream_println;
|
||||||
|
|
||||||
jmethodID AndroidUtil::SMID_ZLibrary_Instance;
|
jmethodID AndroidUtil::SMID_ZLibrary_Instance;
|
||||||
jmethodID AndroidUtil::MID_ZLibrary_getVersionName;
|
jmethodID AndroidUtil::MID_ZLibrary_getVersionName;
|
||||||
|
@ -119,6 +119,7 @@ JNIEnv *AndroidUtil::getEnv() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CHECK_NULL(value) if ((value) == 0) { return false; }
|
#define CHECK_NULL(value) if ((value) == 0) { return false; }
|
||||||
|
#define CHECK_METHOD(method) if (!(method).check()) { return false; }
|
||||||
|
|
||||||
bool AndroidUtil::init(JavaVM* jvm) {
|
bool AndroidUtil::init(JavaVM* jvm) {
|
||||||
ourJavaVM = jvm;
|
ourJavaVM = jvm;
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "VoidMethod.h"
|
||||||
|
|
||||||
class ZLFile;
|
class ZLFile;
|
||||||
class ZLFileImage;
|
class ZLFileImage;
|
||||||
|
|
||||||
|
@ -65,7 +67,7 @@ public:
|
||||||
static jmethodID MID_java_io_InputStream_read;
|
static jmethodID MID_java_io_InputStream_read;
|
||||||
static jmethodID MID_java_io_InputStream_skip;
|
static jmethodID MID_java_io_InputStream_skip;
|
||||||
|
|
||||||
static jmethodID MID_java_io_PrintStream_println;
|
static VoidMethod MID_java_io_PrintStream_println;
|
||||||
|
|
||||||
static jmethodID SMID_ZLibrary_Instance;
|
static jmethodID SMID_ZLibrary_Instance;
|
||||||
static jmethodID MID_ZLibrary_getVersionName;
|
static jmethodID MID_ZLibrary_getVersionName;
|
||||||
|
|
29
jni/NativeFormats/util/Method.cpp
Normal file
29
jni/NativeFormats/util/Method.cpp
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
/*
|
||||||
|
* 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 "Method.h"
|
||||||
|
|
||||||
|
Method::Method(JNIEnv *env, jclass cls, const std::string &name, const std::string &signature) {
|
||||||
|
myEnv = env;
|
||||||
|
myId = env->GetMethodID(cls, name.c_str(), signature.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Method::check() {
|
||||||
|
return myId != 0;
|
||||||
|
}
|
38
jni/NativeFormats/util/Method.h
Normal file
38
jni/NativeFormats/util/Method.h
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __METHOD_H__
|
||||||
|
#define __METHOD_H__
|
||||||
|
|
||||||
|
#include <jni.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
class Method {
|
||||||
|
|
||||||
|
public:
|
||||||
|
Method(JNIEnv *env, jclass cls, const std::string &name, const std::string &signature);
|
||||||
|
bool check();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
JNIEnv *myEnv;
|
||||||
|
jmethodID myId;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* __METHOD_H__ */
|
|
@ -19,7 +19,12 @@
|
||||||
|
|
||||||
#include "VoidMethod.h"
|
#include "VoidMethod.h"
|
||||||
|
|
||||||
void VoidMethod::call(JNIEnv *env, jobject base, ...) {
|
VoidMethod::VoidMethod(JNIEnv *env, jclass cls, const std::string &name, const std::string &signature) : Method(env, cls, name, signature + "V") {
|
||||||
va_start(args);
|
}
|
||||||
env->CallVoidMethod(base, myId, va_list);
|
|
||||||
|
void VoidMethod::call(jobject base, ...) {
|
||||||
|
va_list lst;
|
||||||
|
va_start(lst, base);
|
||||||
|
myEnv->CallVoidMethod(base, myId, lst);
|
||||||
|
va_end(lst);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,15 +20,13 @@
|
||||||
#ifndef __VOIDMETHOD_H__
|
#ifndef __VOIDMETHOD_H__
|
||||||
#define __VOIDMETHOD_H__
|
#define __VOIDMETHOD_H__
|
||||||
|
|
||||||
#include <jni.h>
|
#include "Method.h"
|
||||||
|
|
||||||
class VoidMethod {
|
class VoidMethod : public Method {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void call(JNIEnv *env, jobject base, ...);
|
VoidMethod(JNIEnv *env, jclass cls, const std::string &name, const std::string &signature);
|
||||||
|
void call(jobject base, ...);
|
||||||
private:
|
|
||||||
jmethodID myId;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __VOIDMETHOD_H__ */
|
#endif /* __VOIDMETHOD_H__ */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue