From cf9abfb5021fc08b50f30ad127f7f13c936ce66f Mon Sep 17 00:00:00 2001 From: Nikolay Pultsin Date: Thu, 29 Mar 2012 17:57:22 +0100 Subject: [PATCH] an envelope for void methods --- jni/Android.mk | 1 + jni/NativeFormats/util/VoidMethod.cpp | 25 ++++++++++++++++++++ jni/NativeFormats/util/VoidMethod.h | 34 +++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 jni/NativeFormats/util/VoidMethod.cpp create mode 100644 jni/NativeFormats/util/VoidMethod.h diff --git a/jni/Android.mk b/jni/Android.mk index 337c3b559..a2c55a495 100644 --- a/jni/Android.mk +++ b/jni/Android.mk @@ -41,6 +41,7 @@ LOCAL_SRC_FILES := \ NativeFormats/JavaNativeFormatPlugin.cpp \ NativeFormats/JavaPluginCollection.cpp \ NativeFormats/util/AndroidUtil.cpp \ + NativeFormats/util/VoidMethod.cpp \ NativeFormats/zlibrary/core/src/constants/ZLXMLNamespace.cpp \ NativeFormats/zlibrary/core/src/encoding/DummyEncodingConverter.cpp \ NativeFormats/zlibrary/core/src/encoding/JavaEncodingConverter.cpp \ diff --git a/jni/NativeFormats/util/VoidMethod.cpp b/jni/NativeFormats/util/VoidMethod.cpp new file mode 100644 index 000000000..5eb7ab54c --- /dev/null +++ b/jni/NativeFormats/util/VoidMethod.cpp @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2011-2012 Geometer Plus + * + * 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 "VoidMethod.h" + +void VoidMethod::call(JNIEnv *env, jobject base, ...) { + va_start(args); + env->CallVoidMethod(base, myId, va_list); +} diff --git a/jni/NativeFormats/util/VoidMethod.h b/jni/NativeFormats/util/VoidMethod.h new file mode 100644 index 000000000..3148a1a44 --- /dev/null +++ b/jni/NativeFormats/util/VoidMethod.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2011-2012 Geometer Plus + * + * 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 __VOIDMETHOD_H__ +#define __VOIDMETHOD_H__ + +#include + +class VoidMethod { + +public: + void call(JNIEnv *env, jobject base, ...); + +private: + jmethodID myId; +}; + +#endif /* __VOIDMETHOD_H__ */