Skip to content

Commit edea648

Browse files
committed
Introduce GETTER_METHOD in utils.h
1 parent ee5a6b3 commit edea648

File tree

12 files changed

+15
-46
lines changed

12 files changed

+15
-46
lines changed

lib/src/main/cpp/libkiwix/book.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,7 @@ METHOD(void, Book, update__Lorg_kiwix_libkiwix_JNIKiwixReader_2, jobject archive
5151
THIS->update(*getPtr<zim::Archive>(env, archive));
5252
}
5353

54-
#define GETTER(retType, name) JNIEXPORT retType JNICALL \
55-
Java_org_kiwix_libkiwix_Book_##name (JNIEnv* env, jobject thisObj) \
56-
{ \
57-
return TO_JNI(THIS->name()); \
58-
}
54+
#define GETTER(retType, name) GETTER_METHOD(retType, libkiwix_Book, THIS, name)
5955

6056
GETTER(jstring, getId)
6157
GETTER(jstring, getPath)

lib/src/main/cpp/libkiwix/library.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,7 @@ METHOD(jint, Library, getBookCount, jboolean localBooks, jboolean remoteBooks) {
6969
return THIS->getBookCount(localBooks, remoteBooks);
7070
}
7171

72-
#define GETTER(retType, name) JNIEXPORT retType JNICALL \
73-
Java_org_kiwix_libkiwix_Library_##name (JNIEnv* env, jobject thisObj) \
74-
{ \
75-
return TO_JNI(THIS->name()); \
76-
}
72+
#define GETTER(retType, name) GETTER_METHOD(retType, libkiwix_Library, THIS, name)
7773

7874
GETTER(jobjectArray, getBooksIds)
7975
GETTER(jobjectArray, getBooksLanguages)

lib/src/main/cpp/libzim/archive.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,7 @@ Java_org_kiwix_libzim_Archive_dispose(JNIEnv* env, jobject thisObj)
116116
}
117117

118118
#define THIS GET_PTR(zim::Archive)
119-
#define GETTER(retType, name) METHOD0(retType, libzim_Archive, name) \
120-
{ \
121-
return TO_JNI(THIS->name()); \
122-
}
119+
#define GETTER(retType, name) GETTER_METHOD(retType, libzim_Archive, THIS, name)
123120

124121

125122
GETTER(jstring, getFilename)

lib/src/main/cpp/libzim/blob.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@ Java_org_kiwix_kiwixlib_libzim_Blob_dispose(JNIEnv* env, jobject thisObj)
3636
dispose<NATIVE_TYPE>(env, thisObj);
3737
}
3838
#define THIS GET_PTR(NATIVE_TYPE)
39-
#define GETTER(retType, name) METHOD0(retType, libzim_Blob, name) \
40-
{ \
41-
return TO_JNI(THIS->name()); \
42-
}
39+
#define GETTER(retType, name) GETTER_METHOD(retType, libzim_Blob, THIS, name)
4340

4441
METHOD0(jstring, libzim_Blob, getData) {
4542
return TO_JNI(std::string(*THIS));

lib/src/main/cpp/libzim/entry.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@ Java_org_kiwix_kiwixlib_libzim_Entry_dispose(JNIEnv* env, jobject thisObj)
3838
}
3939

4040
#define THIS GET_PTR(NATIVE_TYPE)
41-
#define GETTER(retType, name) METHOD0(retType, libzim_Entry, name) \
42-
{ \
43-
return TO_JNI(THIS->name()); \
44-
}
41+
#define GETTER(retType, name) GETTER_METHOD(retType, libzim_Entry, THIS, name)
4542

4643

4744
GETTER(jboolean, isRedirect)

lib/src/main/cpp/libzim/item.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@ Java_org_kiwix_kiwixlib_libzim_Item_dispose(JNIEnv* env, jobject thisObj)
3737
}
3838

3939
#define THIS GET_PTR(NATIVE_TYPE)
40-
#define GETTER(retType, name) METHOD0(retType, libzim_Item, name) \
41-
{ \
42-
return TO_JNI(THIS->name()); \
43-
}
40+
#define GETTER(retType, name) GETTER_METHOD(retType, libzim_Item, THIS, name)
4441

4542
GETTER(jstring, getTitle)
4643
GETTER(jstring, getPath)

lib/src/main/cpp/libzim/search_iterator.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,7 @@ METHOD0(void, libzim_SearchIterator, dispose)
3939
}
4040

4141
#define THIS GET_PTR(NATIVE_TYPE)
42-
#define GETTER(retType, name) METHOD0(retType, libzim_SearchIterator, name) \
43-
{ \
44-
return TO_JNI(THIS->name()); \
45-
}
42+
#define GETTER(retType, name) GETTER_METHOD(retType, libzim_SearchIterator, THIS, name)
4643

4744
GETTER(jstring, getPath)
4845
GETTER(jstring, getTitle)

lib/src/main/cpp/libzim/searcher.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,7 @@ METHOD0(void, libzim_Searcher, dispose)
5252
}
5353

5454
#define THIS GET_PTR(NATIVE_TYPE)
55-
#define GETTER(retType, name) METHOD0(retType, libzim_Searcher, name) \
56-
{ \
57-
return TO_JNI(THIS->name()); \
58-
}
55+
#define GETTER(retType, name) GETTER_METHOD(retType, libzim_Searcher, THIS, name)
5956

6057
METHOD(jobject, libzim_Searcher, addArchive, jobject archive) {
6158
auto cArchive = getPtr<zim::Archive>(env, archive);

lib/src/main/cpp/libzim/suggestion_item.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@ METHOD0(void, libzim_SuggestionItem, dispose)
3636
}
3737

3838
#define THIS GET_PTR(NATIVE_TYPE)
39-
#define GETTER(retType, name) METHOD0(retType, libzim_SuggestionItem, name) \
40-
{ \
41-
return TO_JNI(THIS->name()); \
42-
}
39+
#define GETTER(retType, name) GETTER_METHOD(retType, libzim_SuggestionItem, THIS, name)
4340

4441

4542
GETTER(jstring, getTitle)

lib/src/main/cpp/libzim/suggestion_iterator.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@ METHOD0(void, libzim_SuggestionIterator, dispose)
3838
}
3939

4040
#define THIS GET_PTR(NATIVE_TYPE)
41-
#define GETTER(retType, name) METHOD0(retType, libzim_SuggestionIterator, name) \
42-
{ \
43-
return TO_JNI(THIS->name()); \
44-
}
41+
#define GETTER(retType, name) GETTER_METHOD(retType, libzim_SuggestionIterator, THIS, name)
4542

4643
METHOD0(jboolean, libzim_SearchIterator, hasNext) {
4744
NATIVE_TYPE next(*THIS);

0 commit comments

Comments
 (0)