mirror of
https://github.com/kiwix/java-libkiwix.git
synced 2025-09-12 00:27:46 -04:00
Introduce macros.h to define common macro
This commit is contained in:
parent
edea648634
commit
29518279dc
@ -26,33 +26,29 @@
|
||||
#include <zim/archive.h>
|
||||
|
||||
#define NATIVE_TYPE kiwix::Book
|
||||
#define THIS GET_PTR(NATIVE_TYPE)
|
||||
#define TYPENAME libkiwix_Book
|
||||
#include <macros.h>
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_kiwix_libkiwix_Book_allocate(
|
||||
JNIEnv* env, jobject thisObj)
|
||||
METHOD0(void, allocate)
|
||||
{
|
||||
SET_PTR(std::make_shared<NATIVE_TYPE>());
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_kiwix_libkiwix_Book_dispose(JNIEnv* env, jobject thisObj)
|
||||
METHOD0(void, dispose)
|
||||
{
|
||||
dispose<NATIVE_TYPE>(env, thisObj);
|
||||
}
|
||||
|
||||
METHOD(void, Book, update__Lorg_kiwix_libkiwix_Book_2, jobject otherBook)
|
||||
METHOD(void, update__Lorg_kiwix_libkiwix_Book_2, jobject otherBook)
|
||||
{
|
||||
THIS->update(*getPtr<kiwix::Book>(env, otherBook));
|
||||
}
|
||||
|
||||
METHOD(void, Book, update__Lorg_kiwix_libkiwix_JNIKiwixReader_2, jobject archive)
|
||||
METHOD(void, update__Lorg_kiwix_libkiwix_JNIKiwixReader_2, jobject archive)
|
||||
{
|
||||
THIS->update(*getPtr<zim::Archive>(env, archive));
|
||||
}
|
||||
|
||||
#define GETTER(retType, name) GETTER_METHOD(retType, libkiwix_Book, THIS, name)
|
||||
|
||||
GETTER(jstring, getId)
|
||||
GETTER(jstring, getPath)
|
||||
GETTER(jboolean, isPathValid)
|
||||
@ -74,10 +70,8 @@ GETTER(jstring, getFavicon)
|
||||
GETTER(jstring, getFaviconUrl)
|
||||
GETTER(jstring, getFaviconMimeType)
|
||||
|
||||
METHOD(jstring, Book, getTagStr, jstring tagName) try {
|
||||
METHOD(jstring, getTagStr, jstring tagName) try {
|
||||
return TO_JNI(THIS->getTagStr(TO_C(tagName)));
|
||||
} catch(...) {
|
||||
return c2jni<std::string>("", env);
|
||||
}
|
||||
|
||||
#undef GETTER
|
||||
|
@ -25,27 +25,29 @@
|
||||
#include "utils.h"
|
||||
|
||||
#define NATIVE_TYPE kiwix::Filter
|
||||
#define THIS GET_PTR(NATIVE_TYPE)
|
||||
#define TYPENAME libkiwix_Filter
|
||||
#include "macros.h"
|
||||
|
||||
|
||||
|
||||
/* Kiwix Reader JNI functions */
|
||||
METHOD0(void, Filter, allocate) {
|
||||
METHOD0(void, allocate) {
|
||||
SET_PTR(std::make_shared<NATIVE_TYPE>());
|
||||
}
|
||||
|
||||
METHOD0(void, Filter, dispose) {
|
||||
METHOD0(void, dispose) {
|
||||
dispose<kiwix::Library>(env, thisObj);
|
||||
}
|
||||
|
||||
|
||||
#define FORWARD(name, args_type) \
|
||||
METHOD(jobject, Filter, name, args_type value) { \
|
||||
METHOD(jobject, name, args_type value) { \
|
||||
THIS->name(jni2c(value, env)); \
|
||||
return thisObj; \
|
||||
}
|
||||
|
||||
#define FORWARDA(name, args_type) \
|
||||
METHOD(jobject, Filter, name, jobjectArray value) { \
|
||||
METHOD(jobject, name, jobjectArray value) { \
|
||||
THIS->name(jni2c<args_type>(value, env)); \
|
||||
return thisObj; \
|
||||
}
|
||||
|
@ -26,11 +26,13 @@
|
||||
#include "utils.h"
|
||||
|
||||
#define NATIVE_TYPE kiwix::Server
|
||||
#define THIS GET_PTR(NATIVE_TYPE)
|
||||
#define TYPENAME libkiwix_Server
|
||||
#include <macros.h>
|
||||
|
||||
|
||||
|
||||
/* Kiwix Reader JNI functions */
|
||||
JNIEXPORT void JNICALL Java_org_kiwix_kiwixlib_JNIKiwixServer_setNativeServer(
|
||||
JNIEnv* env, jobject thisObj, jobject jLibrary)
|
||||
METHOD(void, setNativeServer, jobject jLibrary)
|
||||
{
|
||||
LOG("Attempting to create server");
|
||||
Lock l;
|
||||
@ -43,57 +45,48 @@ JNIEXPORT void JNICALL Java_org_kiwix_kiwixlib_JNIKiwixServer_setNativeServer(
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_kiwix_kiwixlib_JNIKiwixServer_dispose(JNIEnv* env, jobject obj)
|
||||
METHOD0(void, dispose)
|
||||
{
|
||||
dispose<NATIVE_TYPE>(env, obj);
|
||||
dispose<NATIVE_TYPE>(env, thisObj);
|
||||
}
|
||||
|
||||
/* Kiwix library functions */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_kiwix_kiwixlib_JNIKiwixServer_setRoot(JNIEnv* env, jobject thisObj, jstring root)
|
||||
METHOD(void, setRoot, jstring root)
|
||||
{
|
||||
THIS->setRoot(TO_C(root));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_kiwix_kiwixlib_JNIKiwixServer_setAddress(JNIEnv* env, jobject thisObj, jstring address)
|
||||
METHOD(void, setAddress, jstring address)
|
||||
{
|
||||
THIS->setAddress(TO_C(address));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_kiwix_kiwixlib_JNIKiwixServer_setPort(JNIEnv* env, jobject thisObj, int port)
|
||||
METHOD(void, setPort, int port)
|
||||
{
|
||||
THIS->setPort(TO_C(port));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_kiwix_kiwixlib_JNIKiwixServer_setNbThreads(JNIEnv* env, jobject thisObj, int threads)
|
||||
METHOD(void, setNbThreads, int threads)
|
||||
{
|
||||
THIS->setNbThreads(TO_C(threads));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_kiwix_kiwixlib_JNIKiwixServer_setTaskbar(JNIEnv* env, jobject thisObj, jboolean withTaskbar, jboolean withLibraryButton)
|
||||
METHOD(void, setTaskbar, jboolean withTaskbar, jboolean withLibraryButton)
|
||||
{
|
||||
THIS->setTaskbar(TO_C(withTaskbar), TO_C(withLibraryButton));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_kiwix_kiwixlib_JNIKiwixServer_setBlockExternalLinks(JNIEnv* env, jobject thisObj, jboolean blockExternalLinks)
|
||||
METHOD(void, setBlockExternalLinks, jboolean blockExternalLinks)
|
||||
{
|
||||
THIS->setBlockExternalLinks(TO_C(blockExternalLinks));
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_org_kiwix_kiwixlib_JNIKiwixServer_start(JNIEnv* env, jobject thisObj)
|
||||
METHOD0(jboolean, start)
|
||||
{
|
||||
return THIS->start();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_kiwix_kiwixlib_JNIKiwixServer_stop(JNIEnv* env, jobject thisObj)
|
||||
METHOD0(void, stop)
|
||||
{
|
||||
THIS->stop();
|
||||
}
|
||||
|
@ -25,18 +25,16 @@
|
||||
#include "utils.h"
|
||||
|
||||
#define NATIVE_TYPE kiwix::Library
|
||||
#define THIS GET_PTR(NATIVE_TYPE)
|
||||
#define TYPENAME libkiwix_Library
|
||||
#include "macros.h"
|
||||
|
||||
/* Kiwix Reader JNI functions */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_kiwix_kiwixlib_Library_allocate(
|
||||
JNIEnv* env, jobject thisObj)
|
||||
METHOD0(void, allocate)
|
||||
{
|
||||
SET_PTR(std::make_shared<NATIVE_TYPE>());
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_kiwix_kiwixlib_Library_dispose(JNIEnv* env, jobject thisObj)
|
||||
METHOD0(void, dispose)
|
||||
{
|
||||
dispose<NATIVE_TYPE>(env, thisObj);
|
||||
}
|
||||
@ -59,24 +57,22 @@ Java_org_kiwix_kiwixlib_Library_addBook(
|
||||
return false;
|
||||
}*/
|
||||
|
||||
METHOD(jobject, Library, getBookById, jstring id) {
|
||||
METHOD(jobject, getBookById, jstring id) {
|
||||
auto obj = NEW_OBJECT("org/kiwix/libkiwix/Book");
|
||||
SET_HANDLE(kiwix::Book, obj, THIS->getBookById(TO_C(id)));
|
||||
return obj;
|
||||
}
|
||||
|
||||
METHOD(jint, Library, getBookCount, jboolean localBooks, jboolean remoteBooks) {
|
||||
METHOD(jint, getBookCount, jboolean localBooks, jboolean remoteBooks) {
|
||||
return THIS->getBookCount(localBooks, remoteBooks);
|
||||
}
|
||||
|
||||
#define GETTER(retType, name) GETTER_METHOD(retType, libkiwix_Library, THIS, name)
|
||||
|
||||
GETTER(jobjectArray, getBooksIds)
|
||||
GETTER(jobjectArray, getBooksLanguages)
|
||||
GETTER(jobjectArray, getBooksCreators)
|
||||
GETTER(jobjectArray, getBooksPublishers)
|
||||
|
||||
METHOD(jobjectArray, Library, filter, jobject filterObj) {
|
||||
METHOD(jobjectArray, filter, jobject filterObj) {
|
||||
auto filter = getPtr<kiwix::Filter>(env, filterObj);
|
||||
return c2jni(THIS->filter(*filter), env);
|
||||
}
|
||||
|
@ -25,33 +25,26 @@
|
||||
#include "utils.h"
|
||||
|
||||
#define NATIVE_TYPE kiwix::Manager
|
||||
#define THIS GET_PTR(NATIVE_TYPE)
|
||||
#define TYPENAME libkiwix_Manager
|
||||
#include <macros.h>
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_kiwix_libkiwix_Manager_allocate(
|
||||
JNIEnv* env, jobject thisObj, jobject libraryObj)
|
||||
METHOD(void, allocate, jobject libraryObj)
|
||||
{
|
||||
auto lib = getPtr<kiwix::Library>(env, libraryObj);
|
||||
SET_PTR(std::make_shared<NATIVE_TYPE>(lib.get()));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_kiwix_libkiwix_Manager_dispose(JNIEnv* env, jobject thisObj)
|
||||
METHOD0(void, dispose)
|
||||
{
|
||||
dispose<kiwix::Manager>(env, thisObj);
|
||||
dispose<NATIVE_TYPE>(env, thisObj);
|
||||
}
|
||||
|
||||
#define MANAGER (getPtr<kiwix::Manager>(env, thisObj))
|
||||
|
||||
/* Kiwix manager functions */
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_org_kiwix_libkiwix_Manager_readFile(
|
||||
JNIEnv* env, jobject thisObj, jstring path)
|
||||
METHOD(jboolean, readFile, jstring path)
|
||||
{
|
||||
auto cPath = jni2c(path, env);
|
||||
auto cPath = TO_C(path);
|
||||
|
||||
try {
|
||||
return MANAGER->readFile(cPath);
|
||||
return THIS->readFile(cPath);
|
||||
} catch (std::exception& e) {
|
||||
LOG("Unable to get readFile");
|
||||
LOG("%s", e.what());
|
||||
@ -59,15 +52,13 @@ Java_org_kiwix_libkiwix_Manager_readFile(
|
||||
return false;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_org_kiwix_libkiwix_Manager_readXml(
|
||||
JNIEnv* env, jobject thisObj, jstring content, jstring libraryPath)
|
||||
METHOD(jboolean, readXml, jstring content, jstring libraryPath)
|
||||
{
|
||||
auto cContent = jni2c(content, env);
|
||||
auto cPath = jni2c(libraryPath, env);
|
||||
auto cContent = TO_C(content);
|
||||
auto cPath = TO_C(libraryPath);
|
||||
|
||||
try {
|
||||
return MANAGER->readXml(cContent, false, cPath);
|
||||
return THIS->readXml(cContent, false, cPath);
|
||||
} catch (std::exception& e) {
|
||||
LOG("Unable to get ZIM id");
|
||||
LOG("%s", e.what());
|
||||
@ -76,15 +67,13 @@ Java_org_kiwix_libkiwix_Manager_readXml(
|
||||
return false;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_org_kiwix_libkiwix_Manager_readOpds(
|
||||
JNIEnv* env, jobject thisObj, jstring content, jstring urlHost)
|
||||
METHOD(jboolean, readOpds, jstring content, jstring urlHost)
|
||||
{
|
||||
auto cContent = jni2c(content, env);
|
||||
auto cUrl = jni2c(urlHost, env);
|
||||
auto cContent = TO_C(content);
|
||||
auto cUrl = TO_C(urlHost);
|
||||
|
||||
try {
|
||||
return MANAGER->readOpds(cContent, cUrl);
|
||||
return THIS->readOpds(cContent, cUrl);
|
||||
} catch (std::exception& e) {
|
||||
LOG("Unable to get ZIM id");
|
||||
LOG("%s", e.what());
|
||||
@ -93,14 +82,12 @@ Java_org_kiwix_libkiwix_Manager_readOpds(
|
||||
return false;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_org_kiwix_libkiwix_Manager_readBookmarkFile(
|
||||
JNIEnv* env, jobject thisObj, jstring path)
|
||||
METHOD(jboolean, readBookmarkFile, jstring path)
|
||||
{
|
||||
auto cPath = jni2c(path, env);
|
||||
auto cPath = TO_C(path);
|
||||
|
||||
try {
|
||||
return MANAGER->readBookmarkFile(cPath);
|
||||
return THIS->readBookmarkFile(cPath);
|
||||
} catch (std::exception& e) {
|
||||
LOG("Unable to get ZIM id");
|
||||
LOG("%s", e.what());
|
||||
@ -109,18 +96,15 @@ Java_org_kiwix_libkiwix_Manager_readBookmarkFile(
|
||||
return false;
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_org_kiwix_libkiwix_Manager_addBookFromPath(
|
||||
JNIEnv* env, jobject thisObj,
|
||||
jstring pathToOpen, jstring pathToSave, jstring url, jboolean checkMetaData)
|
||||
METHOD(jstring, addBookFromPath, jstring pathToOpen, jstring pathToSave, jstring url, jboolean checkMetaData)
|
||||
{
|
||||
auto cPathToOpen = jni2c(pathToOpen, env);
|
||||
auto cPathToSave = jni2c(pathToSave, env);
|
||||
auto cUrl = jni2c(url, env);
|
||||
auto cPathToOpen = TO_C(pathToOpen);
|
||||
auto cPathToSave = TO_C(pathToSave);
|
||||
auto cUrl = TO_C(url);
|
||||
jstring id = NULL;
|
||||
|
||||
try {
|
||||
auto cId = MANAGER->addBookFromPathAndGetId(cPathToOpen, cPathToSave, cUrl, checkMetaData);
|
||||
auto cId = THIS->addBookFromPathAndGetId(cPathToOpen, cPathToSave, cUrl, checkMetaData);
|
||||
if ( !cId.empty() ) {
|
||||
id = c2jni(cId, env);
|
||||
}
|
||||
|
@ -30,9 +30,13 @@
|
||||
#include <zim/archive.h>
|
||||
#include <zim/item.h>
|
||||
|
||||
#define CLASSNAME "org/kiwix/libzim/Archive"
|
||||
#define NATIVE_TYPE zim::Archive
|
||||
#define TYPENAME libzim_Archive
|
||||
#include <macros.h>
|
||||
|
||||
/* Kiwix Reader JNI functions */
|
||||
JNIEXPORT void JNICALL Java_org_kiwix_libzim_Archive_setNativeArchive(
|
||||
JNIEnv* env, jobject thisObj, jstring filename)
|
||||
METHOD(void, setNativeArchive, jstring filename)
|
||||
{
|
||||
std::string cPath = TO_C(filename);
|
||||
|
||||
@ -115,10 +119,6 @@ Java_org_kiwix_libzim_Archive_dispose(JNIEnv* env, jobject thisObj)
|
||||
dispose<zim::Archive>(env, thisObj);
|
||||
}
|
||||
|
||||
#define THIS GET_PTR(zim::Archive)
|
||||
#define GETTER(retType, name) GETTER_METHOD(retType, libzim_Archive, THIS, name)
|
||||
|
||||
|
||||
GETTER(jstring, getFilename)
|
||||
GETTER(jlong, getFilesize)
|
||||
GETTER(jint, getAllEntryCount)
|
||||
@ -126,15 +126,15 @@ GETTER(jint, getEntryCount)
|
||||
GETTER(jint, getArticleCount)
|
||||
GETTER(jint, getMediaCount)
|
||||
|
||||
METHOD0(jstring, libzim_Archive, getUuid) {
|
||||
METHOD0(jstring, getUuid) {
|
||||
return TO_JNI(std::string(THIS->getUuid()));
|
||||
}
|
||||
|
||||
METHOD(jstring, libzim_Archive, getMetadata, jstring name) {
|
||||
METHOD(jstring, getMetadata, jstring name) {
|
||||
return TO_JNI(THIS->getMetadata(TO_C(name)));
|
||||
}
|
||||
|
||||
METHOD(jobject, libzim_Archive, getMetadataItem, jstring name) {
|
||||
METHOD(jobject, getMetadataItem, jstring name) {
|
||||
auto obj = NEW_OBJECT("org/kiwix/libzim/Item");
|
||||
SET_HANDLE(zim::Item, obj, THIS->getMetadataItem(TO_C(name)));
|
||||
return obj;
|
||||
@ -142,71 +142,71 @@ METHOD(jobject, libzim_Archive, getMetadataItem, jstring name) {
|
||||
|
||||
GETTER(jobjectArray, getMetadataKeys)
|
||||
|
||||
METHOD(jobject, libzim_Archive, getIllustrationItem, jint size) {
|
||||
METHOD(jobject, getIllustrationItem, jint size) {
|
||||
auto obj = NEW_OBJECT("org/kiwix/libzim/Item");
|
||||
SET_HANDLE(zim::Item, obj, THIS->getIllustrationItem(TO_C(size)));
|
||||
return obj;
|
||||
}
|
||||
|
||||
METHOD(jboolean, libzim_Archive, hasIllustration, jint size) {
|
||||
METHOD(jboolean, hasIllustration, jint size) {
|
||||
return TO_JNI(THIS->hasIllustration(TO_C(size)));
|
||||
}
|
||||
|
||||
GETTER(jlongArray, getIllustrationSizes)
|
||||
|
||||
METHOD(jobject, libzim_Archive, getEntryByPath, jlong index) {
|
||||
METHOD(jobject, getEntryByPath, jlong index) {
|
||||
auto obj = NEW_OBJECT("org/kiwix/libzim/Entry");
|
||||
SET_HANDLE(zim::Entry, obj, THIS->getEntryByPath(TO_C(index)));
|
||||
return obj;
|
||||
}
|
||||
|
||||
METHOD(jobject, libzim_Archive, getEntryByPath, jstring path) {
|
||||
METHOD(jobject, getEntryByPath, jstring path) {
|
||||
auto obj = NEW_OBJECT("org/kiwix/libzim/Entry");
|
||||
SET_HANDLE(zim::Entry, obj, THIS->getEntryByPath(TO_C(path)));
|
||||
return obj;
|
||||
}
|
||||
|
||||
METHOD(jobject, libzim_Archive, getEntryByTitle, jlong index) {
|
||||
METHOD(jobject, getEntryByTitle, jlong index) {
|
||||
auto obj = NEW_OBJECT("org/kiwix/libzim/Entry");
|
||||
SET_HANDLE(zim::Entry, obj, THIS->getEntryByTitle(TO_C(index)));
|
||||
return obj;
|
||||
}
|
||||
|
||||
METHOD(jobject, libzim_Archive, getEntryByTitle, jstring title) {
|
||||
METHOD(jobject, getEntryByTitle, jstring title) {
|
||||
auto obj = NEW_OBJECT("org/kiwix/libzim/Entry");
|
||||
SET_HANDLE(zim::Entry, obj, THIS->getEntryByTitle(TO_C(title)));
|
||||
return obj;
|
||||
}
|
||||
|
||||
METHOD(jobject, libzim_Archive, getEntryByClusterOrder, jlong index) {
|
||||
METHOD(jobject, getEntryByClusterOrder, jlong index) {
|
||||
auto obj = NEW_OBJECT("org/kiwix/libzim/Entry");
|
||||
SET_HANDLE(zim::Entry, obj, THIS->getEntryByClusterOrder(TO_C(index)));
|
||||
return obj;
|
||||
}
|
||||
|
||||
METHOD0(jobject, libzim_Archive, getMainEntry) {
|
||||
METHOD0(jobject, getMainEntry) {
|
||||
auto obj = NEW_OBJECT("org/kiwix/libzim/Entry");
|
||||
SET_HANDLE(zim::Entry, obj, THIS->getMainEntry());
|
||||
return obj;
|
||||
}
|
||||
|
||||
METHOD0(jobject, libzim_Archive, getRandomEntry) {
|
||||
METHOD0(jobject, getRandomEntry) {
|
||||
auto obj = NEW_OBJECT("org/kiwix/libzim/Entry");
|
||||
SET_HANDLE(zim::Entry, obj, THIS->getRandomEntry());
|
||||
return obj;
|
||||
}
|
||||
|
||||
METHOD(jboolean, libzim_Archive, hasEntryByPath, jstring path) {
|
||||
METHOD(jboolean, hasEntryByPath, jstring path) {
|
||||
return TO_JNI(THIS->hasEntryByPath(TO_C(path)));
|
||||
}
|
||||
|
||||
METHOD(jboolean, libzim_Archive, hasEntryByTitle, jstring title) {
|
||||
METHOD(jboolean, hasEntryByTitle, jstring title) {
|
||||
return TO_JNI(THIS->hasEntryByPath(TO_C(title)));
|
||||
}
|
||||
|
||||
GETTER(jboolean, hasMainEntry)
|
||||
|
||||
METHOD(jboolean, libzim_Archive, hasIllustration, jlong size) {
|
||||
METHOD(jboolean, hasIllustration, jlong size) {
|
||||
return TO_JNI(THIS->hasIllustration(TO_C(size)));
|
||||
}
|
||||
|
||||
@ -222,7 +222,7 @@ GETTER(jboolean, hasNewNamespaceScheme)
|
||||
#define ITER_BY_PATH 0
|
||||
#define ITER_BY_TITLE 1
|
||||
#define ITER_EFFICIENT 2
|
||||
METHOD0(jobject, libzim_Archive, iterByPath) {
|
||||
METHOD0(jobject, iterByPath) {
|
||||
auto range = THIS->iterByPath();
|
||||
jclass objClass = env->FindClass("org/kiwix/libzim/EntryIterator");
|
||||
jmethodID initMethod = env->GetMethodID(objClass, "<init>", "(I)V");
|
||||
@ -234,7 +234,7 @@ METHOD0(jobject, libzim_Archive, iterByPath) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
METHOD0(jobject, libzim_Archive, iterByTitle) {
|
||||
METHOD0(jobject, iterByTitle) {
|
||||
auto range = THIS->iterByTitle();
|
||||
jclass objClass = env->FindClass("org/kiwix/libzim/EntryIterator");
|
||||
jmethodID initMethod = env->GetMethodID(objClass, "<init>", "(I)V");
|
||||
@ -246,7 +246,7 @@ METHOD0(jobject, libzim_Archive, iterByTitle) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
METHOD0(jobject, libzim_Archive, iterEfficient) {
|
||||
METHOD0(jobject, iterEfficient) {
|
||||
auto range = THIS->iterEfficient();
|
||||
jclass objClass = env->FindClass("org/kiwix/libzim/EntryIterator");
|
||||
jmethodID initMethod = env->GetMethodID(objClass, "<init>", "(I)V");
|
||||
@ -258,7 +258,7 @@ METHOD0(jobject, libzim_Archive, iterEfficient) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
METHOD(jobject, libzim_Archive, findByPath, jstring path) {
|
||||
METHOD(jobject, findByPath, jstring path) {
|
||||
auto range = THIS->findByPath(TO_C(path));
|
||||
jclass objClass = env->FindClass("org/kiwix/libzim/EntryIterator");
|
||||
jmethodID initMethod = env->GetMethodID(objClass, "<init>", "(I)V");
|
||||
@ -270,7 +270,7 @@ METHOD(jobject, libzim_Archive, findByPath, jstring path) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
METHOD(jobject, libzim_Archive, findByTitle, jstring title) {
|
||||
METHOD(jobject, findByTitle, jstring title) {
|
||||
auto range = THIS->findByTitle(TO_C(title));
|
||||
jclass objClass = env->FindClass("org/kiwix/libzim/EntryIterator");
|
||||
jmethodID initMethod = env->GetMethodID(objClass, "<init>", "(I)V");
|
||||
|
@ -28,17 +28,19 @@
|
||||
|
||||
#include <zim/blob.h>
|
||||
|
||||
#define CLASSNAME "org/kiwix/libzim/Blob"
|
||||
#define NATIVE_TYPE zim::Blob
|
||||
#define TYPENAME libzim_Blob
|
||||
#include <macros.h>
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_kiwix_kiwixlib_libzim_Blob_dispose(JNIEnv* env, jobject thisObj)
|
||||
|
||||
|
||||
METHOD0(void, dispose)
|
||||
{
|
||||
dispose<NATIVE_TYPE>(env, thisObj);
|
||||
}
|
||||
#define THIS GET_PTR(NATIVE_TYPE)
|
||||
#define GETTER(retType, name) GETTER_METHOD(retType, libzim_Blob, THIS, name)
|
||||
|
||||
METHOD0(jstring, libzim_Blob, getData) {
|
||||
METHOD0(jstring, getData) {
|
||||
return TO_JNI(std::string(*THIS));
|
||||
}
|
||||
GETTER(jlong, size)
|
||||
|
@ -29,34 +29,33 @@
|
||||
#include <zim/entry.h>
|
||||
#include <zim/item.h>
|
||||
|
||||
#define CLASSNAME "org/kiwix/libzim/Entry"
|
||||
#define NATIVE_TYPE zim::Entry
|
||||
#define TYPENAME libzim_Entry
|
||||
#include <macros.h>
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_kiwix_kiwixlib_libzim_Entry_dispose(JNIEnv* env, jobject thisObj)
|
||||
|
||||
METHOD0(void, dispose)
|
||||
{
|
||||
dispose<NATIVE_TYPE>(env, thisObj);
|
||||
}
|
||||
|
||||
#define THIS GET_PTR(NATIVE_TYPE)
|
||||
#define GETTER(retType, name) GETTER_METHOD(retType, libzim_Entry, THIS, name)
|
||||
|
||||
|
||||
GETTER(jboolean, isRedirect)
|
||||
GETTER(jstring, getTitle)
|
||||
GETTER(jstring, getPath)
|
||||
METHOD(jobject, libzim_Entry, getItem, jboolean follow) {
|
||||
METHOD(jobject, getItem, jboolean follow) {
|
||||
auto obj = NEW_OBJECT("org/kiwix/libzim/Item");
|
||||
SET_HANDLE(zim::Item, obj, THIS->getItem(TO_C(follow)));
|
||||
return obj;
|
||||
}
|
||||
|
||||
METHOD0(jobject, libzim_Entry, getRedirect) {
|
||||
METHOD0(jobject, getRedirect) {
|
||||
auto obj = NEW_OBJECT("org/kiwix/libzim/Item");
|
||||
SET_HANDLE(zim::Item, obj, THIS->getRedirect());
|
||||
return obj;
|
||||
}
|
||||
|
||||
METHOD0(jobject, libzim_Entry, getRedirectEntry) {
|
||||
METHOD0(jobject, getRedirectEntry) {
|
||||
auto obj = NEW_OBJECT("org/kiwix/libzim/Entry");
|
||||
SET_HANDLE(zim::Entry, obj, THIS->getRedirectEntry());
|
||||
return obj;
|
||||
|
@ -29,6 +29,10 @@
|
||||
#include <zim/entry.h>
|
||||
#include <zim/search.h>
|
||||
|
||||
#define CLASSNAME "org/kiwix/libzim/EntryIterator"
|
||||
#define TYPENAME libzim_EntryIterator
|
||||
#include "macros.h"
|
||||
|
||||
#define PATH_NATIVE_TYPE zim::Archive::iterator<zim::EntryOrder::pathOrder>
|
||||
#define TITLE_NATIVE_TYPE zim::Archive::iterator<zim::EntryOrder::titleOrder>
|
||||
#define EFFICIENT_NATIVE_TYPE zim::Archive::iterator<zim::EntryOrder::efficientOrder>
|
||||
@ -39,7 +43,7 @@ inline int get_order(JNIEnv* env, jobject thisObj) {
|
||||
return TO_C(env->GetIntField(thisObj, fieldId));
|
||||
}
|
||||
|
||||
METHOD0(void, libzim_EntryIterotar, dispose)
|
||||
METHOD0(void, dispose)
|
||||
{
|
||||
// Delete end iterator
|
||||
switch (get_order(env, thisObj)) {
|
||||
@ -59,7 +63,7 @@ METHOD0(void, libzim_EntryIterotar, dispose)
|
||||
}
|
||||
|
||||
|
||||
METHOD0(jboolean, libzim_EntryIterator, hasNext) {
|
||||
METHOD0(jboolean, hasNext) {
|
||||
switch (get_order(env, thisObj)) {
|
||||
case 0: {
|
||||
PATH_NATIVE_TYPE next(*GET_PTR(PATH_NATIVE_TYPE));
|
||||
@ -82,7 +86,7 @@ METHOD0(jboolean, libzim_EntryIterator, hasNext) {
|
||||
}
|
||||
}
|
||||
|
||||
METHOD0(jobject, libzim_EntryIterator, next) {
|
||||
METHOD0(jobject, next) {
|
||||
switch (get_order(env, thisObj)) {
|
||||
case 0: {
|
||||
(*GET_PTR(PATH_NATIVE_TYPE))++;
|
||||
|
@ -28,22 +28,21 @@
|
||||
|
||||
#include <zim/item.h>
|
||||
|
||||
#define CLASSNAME "org/kiwix/libzim/Item"
|
||||
#define NATIVE_TYPE zim::Item
|
||||
#define TYPENAME libzim_Item
|
||||
#include <macros.h>
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_kiwix_kiwixlib_libzim_Item_dispose(JNIEnv* env, jobject thisObj)
|
||||
METHOD0(void, dispose)
|
||||
{
|
||||
dispose<NATIVE_TYPE>(env, thisObj);
|
||||
}
|
||||
|
||||
#define THIS GET_PTR(NATIVE_TYPE)
|
||||
#define GETTER(retType, name) GETTER_METHOD(retType, libzim_Item, THIS, name)
|
||||
|
||||
GETTER(jstring, getTitle)
|
||||
GETTER(jstring, getPath)
|
||||
GETTER(jstring, getMimetype)
|
||||
|
||||
METHOD0(jobject, libzim_Item, getData) {
|
||||
METHOD0(jobject, getData) {
|
||||
auto obj = NEW_OBJECT("org/kiwix/libzim/Blob");
|
||||
SET_HANDLE(zim::Blob, obj, THIS->getData());
|
||||
return obj;
|
||||
|
@ -28,10 +28,12 @@
|
||||
|
||||
#include <zim/search.h>
|
||||
|
||||
#define CLASSNAME "org/kiwix/libzim/Query"
|
||||
#define NATIVE_TYPE zim::Query
|
||||
#define TYPENAME libzim_Query
|
||||
#include <macros.h>
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_kiwix_libzim_Query_getNativeQuery(
|
||||
JNIEnv* env, jobject thisObj, jstring query)
|
||||
METHOD(void, setNativeQuery, jstring query)
|
||||
{
|
||||
auto cQuery = TO_C(query);
|
||||
Lock l;
|
||||
@ -44,21 +46,17 @@ JNIEXPORT void JNICALL Java_org_kiwix_libzim_Query_getNativeQuery(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_kiwix_kiwixlib_libzim_Query_dispose(JNIEnv* env, jobject thisObj)
|
||||
METHOD0(void, dispose)
|
||||
{
|
||||
dispose<NATIVE_TYPE>(env, thisObj);
|
||||
}
|
||||
|
||||
#define THIS GET_PTR(NATIVE_TYPE)
|
||||
|
||||
METHOD(jobject, libzim_Query, setQuery, jstring query) {
|
||||
METHOD(jobject, setQuery, jstring query) {
|
||||
THIS->setQuery(TO_C(query));
|
||||
return thisObj;
|
||||
}
|
||||
|
||||
METHOD(jobject, libzim_Query, setGeorange, jfloat latitude, jfloat longitude, jfloat distance) {
|
||||
METHOD(jobject, setGeorange, jfloat latitude, jfloat longitude, jfloat distance) {
|
||||
THIS->setGeorange(TO_C(latitude), TO_C(longitude), TO_C(distance));
|
||||
return thisObj;
|
||||
}
|
||||
|
@ -28,16 +28,18 @@
|
||||
|
||||
#include <zim/search.h>
|
||||
|
||||
#define CLASSNAME "org/kiwix/libzim/Search"
|
||||
#define NATIVE_TYPE zim::Search
|
||||
#define TYPENAME libzim_Search
|
||||
#include <macros.h>
|
||||
|
||||
METHOD0(void, libzim_Search, dispose)
|
||||
|
||||
METHOD0(void, dispose)
|
||||
{
|
||||
dispose<NATIVE_TYPE>(env, thisObj);
|
||||
}
|
||||
|
||||
#define THIS GET_PTR(NATIVE_TYPE)
|
||||
|
||||
METHOD(jobject, libzim_Search, getResults, jint start, jint maxResults) {
|
||||
METHOD(jobject, getResults, jint start, jint maxResults) {
|
||||
auto results = THIS->getResults(TO_C(start), TO_C(maxResults));
|
||||
auto obj = NEW_OBJECT("ork/kiwix/libzim/SearchIterator");
|
||||
SET_HANDLE(zim::SearchIterator, obj, results.begin());
|
||||
@ -48,7 +50,4 @@ METHOD(jobject, libzim_Search, getResults, jint start, jint maxResults) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
METHOD0(jlong, libzim_Search, getEstimatedMatches) {
|
||||
return TO_JNI(THIS->getEstimatedMatches());
|
||||
}
|
||||
|
||||
GETTER(jlong, getEstimatedMatches)
|
||||
|
@ -29,17 +29,18 @@
|
||||
#include <zim/entry.h>
|
||||
#include <zim/search.h>
|
||||
|
||||
#define CLASSNAME "org/kiwix/libzim/SearchIterator"
|
||||
#define NATIVE_TYPE zim::SearchIterator
|
||||
#define TYPENAME libzim_SearchIterator
|
||||
#include <macros.h>
|
||||
|
||||
METHOD0(void, libzim_SearchIterator, dispose)
|
||||
METHOD0(void, dispose)
|
||||
{
|
||||
// Delete end iterator
|
||||
dispose<NATIVE_TYPE>(env, thisObj, "nativeHandleEnd");
|
||||
dispose<NATIVE_TYPE>(env, thisObj);
|
||||
}
|
||||
|
||||
#define THIS GET_PTR(NATIVE_TYPE)
|
||||
#define GETTER(retType, name) GETTER_METHOD(retType, libzim_SearchIterator, THIS, name)
|
||||
|
||||
GETTER(jstring, getPath)
|
||||
GETTER(jstring, getTitle)
|
||||
@ -49,18 +50,18 @@ GETTER(jint, getWordCount)
|
||||
GETTER(jint, getFileIndex)
|
||||
GETTER(jint, getSize)
|
||||
|
||||
METHOD0(jstring, libzim_SearchIterator, getZimId) {
|
||||
METHOD0(jstring, getZimId) {
|
||||
return TO_JNI(std::string(THIS->getZimId()));
|
||||
}
|
||||
|
||||
METHOD0(jboolean, libzim_SearchIterator, hasNext) {
|
||||
METHOD0(jboolean, hasNext) {
|
||||
zim::SearchIterator next(*THIS);
|
||||
next++;
|
||||
auto end = getPtr<NATIVE_TYPE>(env, thisObj, "nativeHandleEnd");
|
||||
return next == *end;
|
||||
}
|
||||
|
||||
METHOD0(jobject, libzim_SearchIterator, next) {
|
||||
METHOD0(jobject, next) {
|
||||
(*THIS)++;
|
||||
zim::Entry entry = **THIS;
|
||||
auto obj = NEW_OBJECT("org/kiwix/libzim/Entry");
|
||||
|
@ -28,10 +28,12 @@
|
||||
|
||||
#include <zim/search.h>
|
||||
|
||||
#define CLASSNAME "org/kiwix/libzim/Searcher"
|
||||
#define NATIVE_TYPE zim::Searcher
|
||||
#define TYPENAME libzim_Searcher
|
||||
#include <macros.h>
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_kiwix_libzim_Searcher_setNativeSearcher(
|
||||
JNIEnv* env, jobject thisObj, jobject archive)
|
||||
METHOD(void, setNativeSearcher, jobject archive)
|
||||
{
|
||||
|
||||
Lock l;
|
||||
@ -46,28 +48,25 @@ JNIEXPORT void JNICALL Java_org_kiwix_libzim_Searcher_setNativeSearcher(
|
||||
}
|
||||
|
||||
|
||||
METHOD0(void, libzim_Searcher, dispose)
|
||||
METHOD0(void, dispose)
|
||||
{
|
||||
dispose<NATIVE_TYPE>(env, thisObj);
|
||||
}
|
||||
|
||||
#define THIS GET_PTR(NATIVE_TYPE)
|
||||
#define GETTER(retType, name) GETTER_METHOD(retType, libzim_Searcher, THIS, name)
|
||||
|
||||
METHOD(jobject, libzim_Searcher, addArchive, jobject archive) {
|
||||
METHOD(jobject, addArchive, jobject archive) {
|
||||
auto cArchive = getPtr<zim::Archive>(env, archive);
|
||||
THIS->addArchive(*cArchive);
|
||||
return thisObj;
|
||||
}
|
||||
|
||||
METHOD(jobject, libzim_Searcher, search, jobject query) {
|
||||
METHOD(jobject, search, jobject query) {
|
||||
auto cQuery = getPtr<zim::Query>(env, query);
|
||||
auto obj = NEW_OBJECT("org/kiwix/libzim/Search");
|
||||
SET_HANDLE(zim::Search, obj, THIS->search(*cQuery));
|
||||
return obj;
|
||||
}
|
||||
|
||||
METHOD(void, libzim_Searcher, setVerbose, jboolean verbose) {
|
||||
METHOD(void, setVerbose, jboolean verbose) {
|
||||
THIS->setVerbose(TO_C(verbose));
|
||||
}
|
||||
|
||||
|
@ -28,17 +28,16 @@
|
||||
|
||||
#include <zim/suggestion.h>
|
||||
|
||||
#define CLASSNAME "org/kiwix/libzim/SuggestionItem"
|
||||
#define NATIVE_TYPE zim::SuggestionItem
|
||||
#define TYPENAME libzim_SuggestionItem
|
||||
#include <macros.h>
|
||||
|
||||
METHOD0(void, libzim_SuggestionItem, dispose)
|
||||
METHOD0(void, dispose)
|
||||
{
|
||||
dispose<NATIVE_TYPE>(env, thisObj);
|
||||
}
|
||||
|
||||
#define THIS GET_PTR(NATIVE_TYPE)
|
||||
#define GETTER(retType, name) GETTER_METHOD(retType, libzim_SuggestionItem, THIS, name)
|
||||
|
||||
|
||||
GETTER(jstring, getTitle)
|
||||
GETTER(jstring, getPath)
|
||||
GETTER(jstring, getSnippet)
|
||||
|
@ -28,26 +28,27 @@
|
||||
|
||||
#include <zim/suggestion.h>
|
||||
|
||||
#define CLASSNAME "org/kiwix/libzim/SuggestionIterator"
|
||||
#define NATIVE_TYPE zim::SuggestionIterator
|
||||
#define TYPENAME libzim_SuggestionIterator
|
||||
#include <macros.h>
|
||||
|
||||
METHOD0(void, libzim_SuggestionIterator, dispose)
|
||||
|
||||
METHOD0(void, dispose)
|
||||
{
|
||||
// Delete end iterator
|
||||
dispose<NATIVE_TYPE>(env, thisObj, "nativeHandleEnd");
|
||||
dispose<NATIVE_TYPE>(env, thisObj);
|
||||
}
|
||||
|
||||
#define THIS GET_PTR(NATIVE_TYPE)
|
||||
#define GETTER(retType, name) GETTER_METHOD(retType, libzim_SuggestionIterator, THIS, name)
|
||||
|
||||
METHOD0(jboolean, libzim_SearchIterator, hasNext) {
|
||||
METHOD0(jboolean, hasNext) {
|
||||
NATIVE_TYPE next(*THIS);
|
||||
next++;
|
||||
auto end = getPtr<NATIVE_TYPE>(env, thisObj, "nativeHandleEnd");
|
||||
return next == *end;
|
||||
}
|
||||
|
||||
METHOD0(jobject, libzim_SearchIterator, next) {
|
||||
METHOD0(jobject, next) {
|
||||
(*THIS)++;
|
||||
zim::SuggestionItem item = **THIS;
|
||||
auto obj = NEW_OBJECT("org/kiwix/libzim/SuggestionItem");
|
||||
|
@ -28,16 +28,17 @@
|
||||
|
||||
#include <zim/suggestion.h>
|
||||
|
||||
#define CLASSNAME "org/kiwix/libzim/SuggestionSearch"
|
||||
#define NATIVE_TYPE zim::SuggestionSearch
|
||||
#define TYPENAME libzim_SuggestionSearch
|
||||
#include <macros.h>
|
||||
|
||||
METHOD0(void, libzim_SuggestionSearch, dispose)
|
||||
METHOD0(void, dispose)
|
||||
{
|
||||
dispose<NATIVE_TYPE>(env, thisObj);
|
||||
}
|
||||
|
||||
#define THIS GET_PTR(NATIVE_TYPE)
|
||||
|
||||
METHOD(jobject, libzim_SuggestionSearch, getResults, jint start, jint maxResults) {
|
||||
METHOD(jobject, getResults, jint start, jint maxResults) {
|
||||
auto results = THIS->getResults(TO_C(start), TO_C(maxResults));
|
||||
auto obj = NEW_OBJECT("ork/kiwix/libzim/SuggestionIterator");
|
||||
SET_HANDLE(zim::SuggestionIterator, obj, results.begin());
|
||||
@ -48,7 +49,4 @@ METHOD(jobject, libzim_SuggestionSearch, getResults, jint start, jint maxResults
|
||||
return obj;
|
||||
}
|
||||
|
||||
METHOD0(jlong, libzim_SuggestionSearch, getEstimatedMatches) {
|
||||
return TO_JNI(THIS->getEstimatedMatches());
|
||||
}
|
||||
|
||||
GETTER(jlong, getEstimatedMatches)
|
||||
|
@ -29,9 +29,11 @@
|
||||
#include <zim/suggestion.h>
|
||||
|
||||
#define NATIVE_TYPE zim::SuggestionSearcher
|
||||
#define TYPENAME libzim_SuggestionSearcher
|
||||
#include <macros.h>
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_kiwix_libzim_SuggestionSearcher_setNativeSearcher(
|
||||
JNIEnv* env, jobject thisObj, jobject archive)
|
||||
|
||||
METHOD(void, setNativeSearcher, jobject archive)
|
||||
{
|
||||
|
||||
Lock l;
|
||||
@ -46,21 +48,18 @@ JNIEXPORT void JNICALL Java_org_kiwix_libzim_SuggestionSearcher_setNativeSearche
|
||||
}
|
||||
|
||||
|
||||
METHOD0(void, libzim_SuggestionSearcher, dispose)
|
||||
METHOD0(void, dispose)
|
||||
{
|
||||
dispose<NATIVE_TYPE>(env, thisObj);
|
||||
}
|
||||
|
||||
#define THIS GET_PTR(NATIVE_TYPE)
|
||||
#define GETTER(retType, name) GETTER_METHOD(retType, libzim_SuggestionSearcher, THIS, name)
|
||||
|
||||
METHOD(jobject, libzim_SuggestionSearcher, suggest, jstring query) {
|
||||
METHOD(jobject, suggest, jstring query) {
|
||||
auto obj = NEW_OBJECT("org/kiwix/libzim/SuggestionSearch");
|
||||
SET_HANDLE(zim::SuggestionSearch, obj, THIS->suggest(TO_C(query)));
|
||||
return obj;
|
||||
}
|
||||
|
||||
METHOD(void, libzim_SuggestionSearcher, setVerbose, jboolean verbose) {
|
||||
METHOD(void, setVerbose, jboolean verbose) {
|
||||
THIS->setVerbose(TO_C(verbose));
|
||||
}
|
||||
|
||||
|
41
lib/src/main/cpp/macros.h
Normal file
41
lib/src/main/cpp/macros.h
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Emmanuel Engelhart <kelson@kiwix.org>
|
||||
* Copyright (C) 2017 Matthieu Gautier <mgautier@kymeria.fr>
|
||||
*
|
||||
* 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 3 of the License, or
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
// You must define NATIVE_TYPE("zim::Archive") and TYPENAME("zim__Archive")
|
||||
|
||||
|
||||
#define BUILD_METHOD_NX(TYPE, NAME) Java_org_kiwix_ ## TYPE ## _ ## NAME
|
||||
#define BUILD_METHOD(TYPE, NAME) BUILD_METHOD_NX(TYPE, NAME)
|
||||
|
||||
#define THIS getPtr<NATIVE_TYPE>(env, thisObj)
|
||||
|
||||
#define METHOD0(retType, name) \
|
||||
JNIEXPORT retType JNICALL BUILD_METHOD(TYPENAME, name) ( \
|
||||
JNIEnv* env, jobject thisObj)
|
||||
|
||||
#define METHOD(retType, name, ...) \
|
||||
JNIEXPORT retType JNICALL BUILD_METHOD(TYPENAME ,name) ( \
|
||||
JNIEnv* env, jobject thisObj, __VA_ARGS__)
|
||||
|
||||
#define GETTER(retType, name) METHOD0(retType, name) { \
|
||||
return TO_JNI(THIS->name()); \
|
||||
}
|
||||
|
@ -108,18 +108,6 @@ void dispose(JNIEnv* env, jobject thisObj, const char* handleName = "nativeHandl
|
||||
env->SetLongField(thisObj, fieldId, 0);
|
||||
}
|
||||
|
||||
#define METHOD0(retType, class, name) \
|
||||
JNIEXPORT retType JNICALL Java_org_kiwix_##class##_##name( \
|
||||
JNIEnv* env, jobject thisObj)
|
||||
|
||||
#define METHOD(retType, class, name, ...) \
|
||||
JNIEXPORT retType JNICALL Java_org_kiwix_##class##_##name( \
|
||||
JNIEnv* env, jobject thisObj, __VA_ARGS__)
|
||||
|
||||
#define GETTER_METHOD(retType, class, THIS, name) METHOD0(retType, class, name) { \
|
||||
return TO_JNI(THIS->name()); \
|
||||
}
|
||||
|
||||
inline jfieldID getHandleField(JNIEnv* env, jobject obj, const char* handleName)
|
||||
{
|
||||
jclass c = env->GetObjectClass(obj);
|
||||
|
Loading…
x
Reference in New Issue
Block a user