Merge pull request #323 from kiwix/fix_wrapper

Fix wrapper
This commit is contained in:
Matthieu Gautier 2020-02-12 10:47:29 +01:00 committed by GitHub
commit cc2b5e63ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -39,6 +39,16 @@ Java_org_kiwix_kiwixlib_Book_dispose(JNIEnv* env, jobject thisObj)
#define BOOK (getPtr<kiwix::Book>(env, thisObj)) #define BOOK (getPtr<kiwix::Book>(env, thisObj))
METHOD(void, Book, update__Lorg_kiwix_kiwixlib_Book_2, jobject otherBook)
{
BOOK->update(*getPtr<kiwix::Book>(env, otherBook));
}
METHOD(void, Book, update__Lorg_kiwix_kiwixlib_JNIKiwixReader_2, jobject reader)
{
BOOK->update(**Handle<kiwix::Reader>::getHandle(env, reader));
}
#define GETTER(retType, name) JNIEXPORT retType JNICALL \ #define GETTER(retType, name) JNIEXPORT retType JNICALL \
Java_org_kiwix_kiwixlib_Book_##name (JNIEnv* env, jobject thisObj) \ Java_org_kiwix_kiwixlib_Book_##name (JNIEnv* env, jobject thisObj) \
{ \ { \
@ -68,7 +78,7 @@ GETTER(jstring, getFaviconUrl)
GETTER(jstring, getFaviconMimeType) GETTER(jstring, getFaviconMimeType)
METHOD(jstring, Book, getTagStr, jstring tagName) try { METHOD(jstring, Book, getTagStr, jstring tagName) try {
auto cRet = Book->getTagStr(jni2c(tagName, env)); auto cRet = BOOK->getTagStr(jni2c(tagName, env));
return c2jni(cRet, env); return c2jni(cRet, env);
} catch(...) { } catch(...) {
return c2jni<std::string>("", env); return c2jni<std::string>("", env);

View File

@ -5,6 +5,10 @@ public class Book
{ {
public Book() { allocate(); } public Book() { allocate(); }
public native void update(Book book);
public native void update(JNIKiwixReader reader);
@Override @Override
protected void finalize() { dispose(); } protected void finalize() { dispose(); }