Skip to content

Commit ee5a6b3

Browse files
committed
Make METHOD macro not using libzim by default.
(Adapt only libzim part)
1 parent 4e840ba commit ee5a6b3

File tree

14 files changed

+62
-79
lines changed

14 files changed

+62
-79
lines changed

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

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +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) JNIEXPORT retType JNICALL \
120-
Java_org_kiwix_libzim_Archive_##name (JNIEnv* env, jobject thisObj) \
119+
#define GETTER(retType, name) METHOD0(retType, libzim_Archive, name) \
121120
{ \
122121
return TO_JNI(THIS->name()); \
123122
}
@@ -130,87 +129,87 @@ GETTER(jint, getEntryCount)
130129
GETTER(jint, getArticleCount)
131130
GETTER(jint, getMediaCount)
132131

133-
METHOD0(jstring, Archive, getUuid) {
132+
METHOD0(jstring, libzim_Archive, getUuid) {
134133
return TO_JNI(std::string(THIS->getUuid()));
135134
}
136135

137-
METHOD(jstring, Archive, getMetadata, jstring name) {
136+
METHOD(jstring, libzim_Archive, getMetadata, jstring name) {
138137
return TO_JNI(THIS->getMetadata(TO_C(name)));
139138
}
140139

141-
METHOD(jobject, Archive, getMetadataItem, jstring name) {
140+
METHOD(jobject, libzim_Archive, getMetadataItem, jstring name) {
142141
auto obj = NEW_OBJECT("org/kiwix/libzim/Item");
143142
SET_HANDLE(zim::Item, obj, THIS->getMetadataItem(TO_C(name)));
144143
return obj;
145144
}
146145

147146
GETTER(jobjectArray, getMetadataKeys)
148147

149-
METHOD(jobject, Archive, getIllustrationItem, jint size) {
148+
METHOD(jobject, libzim_Archive, getIllustrationItem, jint size) {
150149
auto obj = NEW_OBJECT("org/kiwix/libzim/Item");
151150
SET_HANDLE(zim::Item, obj, THIS->getIllustrationItem(TO_C(size)));
152151
return obj;
153152
}
154153

155-
METHOD(jboolean, Archive, hasIllustration, jint size) {
154+
METHOD(jboolean, libzim_Archive, hasIllustration, jint size) {
156155
return TO_JNI(THIS->hasIllustration(TO_C(size)));
157156
}
158157

159158
GETTER(jlongArray, getIllustrationSizes)
160159

161-
METHOD(jobject, Archive, getEntryByPath, jlong index) {
160+
METHOD(jobject, libzim_Archive, getEntryByPath, jlong index) {
162161
auto obj = NEW_OBJECT("org/kiwix/libzim/Entry");
163162
SET_HANDLE(zim::Entry, obj, THIS->getEntryByPath(TO_C(index)));
164163
return obj;
165164
}
166165

167-
METHOD(jobject, Archive, getEntryByPath, jstring path) {
166+
METHOD(jobject, libzim_Archive, getEntryByPath, jstring path) {
168167
auto obj = NEW_OBJECT("org/kiwix/libzim/Entry");
169168
SET_HANDLE(zim::Entry, obj, THIS->getEntryByPath(TO_C(path)));
170169
return obj;
171170
}
172171

173-
METHOD(jobject, Archive, getEntryByTitle, jlong index) {
172+
METHOD(jobject, libzim_Archive, getEntryByTitle, jlong index) {
174173
auto obj = NEW_OBJECT("org/kiwix/libzim/Entry");
175174
SET_HANDLE(zim::Entry, obj, THIS->getEntryByTitle(TO_C(index)));
176175
return obj;
177176
}
178177

179-
METHOD(jobject, Archive, getEntryByTitle, jstring title) {
178+
METHOD(jobject, libzim_Archive, getEntryByTitle, jstring title) {
180179
auto obj = NEW_OBJECT("org/kiwix/libzim/Entry");
181180
SET_HANDLE(zim::Entry, obj, THIS->getEntryByTitle(TO_C(title)));
182181
return obj;
183182
}
184183

185-
METHOD(jobject, Archive, getEntryByClusterOrder, jlong index) {
184+
METHOD(jobject, libzim_Archive, getEntryByClusterOrder, jlong index) {
186185
auto obj = NEW_OBJECT("org/kiwix/libzim/Entry");
187186
SET_HANDLE(zim::Entry, obj, THIS->getEntryByClusterOrder(TO_C(index)));
188187
return obj;
189188
}
190189

191-
METHOD0(jobject, Archive, getMainEntry) {
190+
METHOD0(jobject, libzim_Archive, getMainEntry) {
192191
auto obj = NEW_OBJECT("org/kiwix/libzim/Entry");
193192
SET_HANDLE(zim::Entry, obj, THIS->getMainEntry());
194193
return obj;
195194
}
196195

197-
METHOD0(jobject, Archive, getRandomEntry) {
196+
METHOD0(jobject, libzim_Archive, getRandomEntry) {
198197
auto obj = NEW_OBJECT("org/kiwix/libzim/Entry");
199198
SET_HANDLE(zim::Entry, obj, THIS->getRandomEntry());
200199
return obj;
201200
}
202201

203-
METHOD(jboolean, Archive, hasEntryByPath, jstring path) {
202+
METHOD(jboolean, libzim_Archive, hasEntryByPath, jstring path) {
204203
return TO_JNI(THIS->hasEntryByPath(TO_C(path)));
205204
}
206205

207-
METHOD(jboolean, Archive, hasEntryByTitle, jstring title) {
206+
METHOD(jboolean, libzim_Archive, hasEntryByTitle, jstring title) {
208207
return TO_JNI(THIS->hasEntryByPath(TO_C(title)));
209208
}
210209

211210
GETTER(jboolean, hasMainEntry)
212211

213-
METHOD(jboolean, Archive, hasIllustration, jlong size) {
212+
METHOD(jboolean, libzim_Archive, hasIllustration, jlong size) {
214213
return TO_JNI(THIS->hasIllustration(TO_C(size)));
215214
}
216215

@@ -226,7 +225,7 @@ GETTER(jboolean, hasNewNamespaceScheme)
226225
#define ITER_BY_PATH 0
227226
#define ITER_BY_TITLE 1
228227
#define ITER_EFFICIENT 2
229-
METHOD0(jobject, Archive, iterByPath) {
228+
METHOD0(jobject, libzim_Archive, iterByPath) {
230229
auto range = THIS->iterByPath();
231230
jclass objClass = env->FindClass("org/kiwix/libzim/EntryIterator");
232231
jmethodID initMethod = env->GetMethodID(objClass, "<init>", "(I)V");
@@ -238,7 +237,7 @@ METHOD0(jobject, Archive, iterByPath) {
238237
return obj;
239238
}
240239

241-
METHOD0(jobject, Archive, iterByTitle) {
240+
METHOD0(jobject, libzim_Archive, iterByTitle) {
242241
auto range = THIS->iterByTitle();
243242
jclass objClass = env->FindClass("org/kiwix/libzim/EntryIterator");
244243
jmethodID initMethod = env->GetMethodID(objClass, "<init>", "(I)V");
@@ -250,7 +249,7 @@ METHOD0(jobject, Archive, iterByTitle) {
250249
return obj;
251250
}
252251

253-
METHOD0(jobject, Archive, iterEfficient) {
252+
METHOD0(jobject, libzim_Archive, iterEfficient) {
254253
auto range = THIS->iterEfficient();
255254
jclass objClass = env->FindClass("org/kiwix/libzim/EntryIterator");
256255
jmethodID initMethod = env->GetMethodID(objClass, "<init>", "(I)V");
@@ -262,7 +261,7 @@ METHOD0(jobject, Archive, iterEfficient) {
262261
return obj;
263262
}
264263

265-
METHOD(jobject, Archive, findByPath, jstring path) {
264+
METHOD(jobject, libzim_Archive, findByPath, jstring path) {
266265
auto range = THIS->findByPath(TO_C(path));
267266
jclass objClass = env->FindClass("org/kiwix/libzim/EntryIterator");
268267
jmethodID initMethod = env->GetMethodID(objClass, "<init>", "(I)V");
@@ -274,7 +273,7 @@ METHOD(jobject, Archive, findByPath, jstring path) {
274273
return obj;
275274
}
276275

277-
METHOD(jobject, Archive, findByTitle, jstring title) {
276+
METHOD(jobject, libzim_Archive, findByTitle, jstring title) {
278277
auto range = THIS->findByTitle(TO_C(title));
279278
jclass objClass = env->FindClass("org/kiwix/libzim/EntryIterator");
280279
jmethodID initMethod = env->GetMethodID(objClass, "<init>", "(I)V");

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,12 @@ 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) JNIEXPORT retType JNICALL \
40-
Java_org_kiwix_libzim_Blob__##name (JNIEnv* env, jobject thisObj) \
39+
#define GETTER(retType, name) METHOD0(retType, libzim_Blob, name) \
4140
{ \
4241
return TO_JNI(THIS->name()); \
4342
}
4443

45-
METHOD0(jstring, Blob, getData) {
44+
METHOD0(jstring, libzim_Blob, getData) {
4645
return TO_JNI(std::string(*THIS));
4746
}
4847
GETTER(jlong, size)

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +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) JNIEXPORT retType JNICALL \
42-
Java_org_kiwix_libzim_Entry__##name (JNIEnv* env, jobject thisObj) \
41+
#define GETTER(retType, name) METHOD0(retType, libzim_Entry, name) \
4342
{ \
4443
return TO_JNI(THIS->name()); \
4544
}
@@ -48,19 +47,19 @@ Java_org_kiwix_libzim_Entry__##name (JNIEnv* env, jobject thisObj) \
4847
GETTER(jboolean, isRedirect)
4948
GETTER(jstring, getTitle)
5049
GETTER(jstring, getPath)
51-
METHOD(jobject, Entry, getItem, jboolean follow) {
50+
METHOD(jobject, libzim_Entry, getItem, jboolean follow) {
5251
auto obj = NEW_OBJECT("org/kiwix/libzim/Item");
5352
SET_HANDLE(zim::Item, obj, THIS->getItem(TO_C(follow)));
5453
return obj;
5554
}
5655

57-
METHOD0(jobject, Entry, getRedirect) {
56+
METHOD0(jobject, libzim_Entry, getRedirect) {
5857
auto obj = NEW_OBJECT("org/kiwix/libzim/Item");
5958
SET_HANDLE(zim::Item, obj, THIS->getRedirect());
6059
return obj;
6160
}
6261

63-
METHOD0(jobject, Entry, getRedirectEntry) {
62+
METHOD0(jobject, libzim_Entry, getRedirectEntry) {
6463
auto obj = NEW_OBJECT("org/kiwix/libzim/Entry");
6564
SET_HANDLE(zim::Entry, obj, THIS->getRedirectEntry());
6665
return obj;

lib/src/main/cpp/libzim/entry_iterator.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ inline int get_order(JNIEnv* env, jobject thisObj) {
3939
return TO_C(env->GetIntField(thisObj, fieldId));
4040
}
4141

42-
JNIEXPORT void JNICALL
43-
Java_org_kiwix_kiwixlib_libzim_EntryIterotar_dispose(JNIEnv* env, jobject thisObj)
42+
METHOD0(void, libzim_EntryIterotar, dispose)
4443
{
4544
// Delete end iterator
4645
switch (get_order(env, thisObj)) {
@@ -60,7 +59,7 @@ Java_org_kiwix_kiwixlib_libzim_EntryIterotar_dispose(JNIEnv* env, jobject thisOb
6059
}
6160

6261

63-
METHOD0(jboolean, EntryIterator, hasNext) {
62+
METHOD0(jboolean, libzim_EntryIterator, hasNext) {
6463
switch (get_order(env, thisObj)) {
6564
case 0: {
6665
PATH_NATIVE_TYPE next(*GET_PTR(PATH_NATIVE_TYPE));
@@ -83,7 +82,7 @@ METHOD0(jboolean, EntryIterator, hasNext) {
8382
}
8483
}
8584

86-
METHOD0(jobject, EntryIterator, next) {
85+
METHOD0(jobject, libzim_EntryIterator, next) {
8786
switch (get_order(env, thisObj)) {
8887
case 0: {
8988
(*GET_PTR(PATH_NATIVE_TYPE))++;

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +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) JNIEXPORT retType JNICALL \
41-
Java_org_kiwix_libzim_Item__##name (JNIEnv* env, jobject thisObj) \
40+
#define GETTER(retType, name) METHOD0(retType, libzim_Item, name) \
4241
{ \
4342
return TO_JNI(THIS->name()); \
4443
}
@@ -47,7 +46,7 @@ GETTER(jstring, getTitle)
4746
GETTER(jstring, getPath)
4847
GETTER(jstring, getMimetype)
4948

50-
METHOD0(jobject, Item, getData) {
49+
METHOD0(jobject, libzim_Item, getData) {
5150
auto obj = NEW_OBJECT("org/kiwix/libzim/Blob");
5251
SET_HANDLE(zim::Blob, obj, THIS->getData());
5352
return obj;

lib/src/main/cpp/libzim/query.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ Java_org_kiwix_kiwixlib_libzim_Query_dispose(JNIEnv* env, jobject thisObj)
5353

5454
#define THIS GET_PTR(NATIVE_TYPE)
5555

56-
METHOD(jobject, Query, setQuery, jstring query) {
56+
METHOD(jobject, libzim_Query, setQuery, jstring query) {
5757
THIS->setQuery(TO_C(query));
5858
return thisObj;
5959
}
6060

61-
METHOD(jobject, Query, setGeorange, jfloat latitude, jfloat longitude, jfloat distance) {
61+
METHOD(jobject, libzim_Query, setGeorange, jfloat latitude, jfloat longitude, jfloat distance) {
6262
THIS->setGeorange(TO_C(latitude), TO_C(longitude), TO_C(distance));
6363
return thisObj;
6464
}

lib/src/main/cpp/libzim/search.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,14 @@
3030

3131
#define NATIVE_TYPE zim::Search
3232

33-
JNIEXPORT void JNICALL
34-
Java_org_kiwix_kiwixlib_libzim_Search_dispose(JNIEnv* env, jobject thisObj)
33+
METHOD0(void, libzim_Search, dispose)
3534
{
3635
dispose<NATIVE_TYPE>(env, thisObj);
3736
}
3837

3938
#define THIS GET_PTR(NATIVE_TYPE)
4039

41-
METHOD(jobject, Search, getResults, jint start, jint maxResults) {
40+
METHOD(jobject, libzim_Search, getResults, jint start, jint maxResults) {
4241
auto results = THIS->getResults(TO_C(start), TO_C(maxResults));
4342
auto obj = NEW_OBJECT("ork/kiwix/libzim/SearchIterator");
4443
SET_HANDLE(zim::SearchIterator, obj, results.begin());
@@ -49,7 +48,7 @@ METHOD(jobject, Search, getResults, jint start, jint maxResults) {
4948
return obj;
5049
}
5150

52-
METHOD0(jlong, Search, getEstimatedMatches) {
51+
METHOD0(jlong, libzim_Search, getEstimatedMatches) {
5352
return TO_JNI(THIS->getEstimatedMatches());
5453
}
5554

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,15 @@
3131

3232
#define NATIVE_TYPE zim::SearchIterator
3333

34-
JNIEXPORT void JNICALL
35-
Java_org_kiwix_kiwixlib_libzim_SearchIterotar_dispose(JNIEnv* env, jobject thisObj)
34+
METHOD0(void, libzim_SearchIterator, dispose)
3635
{
3736
// Delete end iterator
3837
dispose<NATIVE_TYPE>(env, thisObj, "nativeHandleEnd");
3938
dispose<NATIVE_TYPE>(env, thisObj);
4039
}
4140

4241
#define THIS GET_PTR(NATIVE_TYPE)
43-
#define GETTER(retType, name) JNIEXPORT retType JNICALL \
44-
Java_org_kiwix_libzim_SearchIterator__##name (JNIEnv* env, jobject thisObj) \
42+
#define GETTER(retType, name) METHOD0(retType, libzim_SearchIterator, name) \
4543
{ \
4644
return TO_JNI(THIS->name()); \
4745
}
@@ -54,18 +52,18 @@ GETTER(jint, getWordCount)
5452
GETTER(jint, getFileIndex)
5553
GETTER(jint, getSize)
5654

57-
METHOD0(jstring, SearchIterator, getZimId) {
55+
METHOD0(jstring, libzim_SearchIterator, getZimId) {
5856
return TO_JNI(std::string(THIS->getZimId()));
5957
}
6058

61-
METHOD0(jboolean, SearchIterator, hasNext) {
59+
METHOD0(jboolean, libzim_SearchIterator, hasNext) {
6260
zim::SearchIterator next(*THIS);
6361
next++;
6462
auto end = getPtr<NATIVE_TYPE>(env, thisObj, "nativeHandleEnd");
6563
return next == *end;
6664
}
6765

68-
METHOD0(jobject, SearchIterator, next) {
66+
METHOD0(jobject, libzim_SearchIterator, next) {
6967
(*THIS)++;
7068
zim::Entry entry = **THIS;
7169
auto obj = NEW_OBJECT("org/kiwix/libzim/Entry");

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,33 +46,31 @@ JNIEXPORT void JNICALL Java_org_kiwix_libzim_Searcher_setNativeSearcher(
4646
}
4747

4848

49-
JNIEXPORT void JNICALL
50-
Java_org_kiwix_kiwixlib_libzim_Searcher_dispose(JNIEnv* env, jobject thisObj)
49+
METHOD0(void, libzim_Searcher, dispose)
5150
{
5251
dispose<NATIVE_TYPE>(env, thisObj);
5352
}
5453

5554
#define THIS GET_PTR(NATIVE_TYPE)
56-
#define GETTER(retType, name) JNIEXPORT retType JNICALL \
57-
Java_org_kiwix_libzim_Searcher__##name (JNIEnv* env, jobject thisObj) \
55+
#define GETTER(retType, name) METHOD0(retType, libzim_Searcher, name) \
5856
{ \
5957
return TO_JNI(THIS->name()); \
6058
}
6159

62-
METHOD(jobject, Searcher, addArchive, jobject archive) {
60+
METHOD(jobject, libzim_Searcher, addArchive, jobject archive) {
6361
auto cArchive = getPtr<zim::Archive>(env, archive);
6462
THIS->addArchive(*cArchive);
6563
return thisObj;
6664
}
6765

68-
METHOD(jobject, Searcher, search, jobject query) {
66+
METHOD(jobject, libzim_Searcher, search, jobject query) {
6967
auto cQuery = getPtr<zim::Query>(env, query);
7068
auto obj = NEW_OBJECT("org/kiwix/libzim/Search");
7169
SET_HANDLE(zim::Search, obj, THIS->search(*cQuery));
7270
return obj;
7371
}
7472

75-
METHOD(void, Searcher, setVerbose, jboolean verbose) {
73+
METHOD(void, libzim_Searcher, setVerbose, jboolean verbose) {
7674
THIS->setVerbose(TO_C(verbose));
7775
}
7876

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,13 @@
3030

3131
#define NATIVE_TYPE zim::SuggestionItem
3232

33-
JNIEXPORT void JNICALL
34-
Java_org_kiwix_kiwixlib_libzim_SuggestionItem_dispose(JNIEnv* env, jobject thisObj)
33+
METHOD0(void, libzim_SuggestionItem, dispose)
3534
{
3635
dispose<NATIVE_TYPE>(env, thisObj);
3736
}
3837

3938
#define THIS GET_PTR(NATIVE_TYPE)
40-
#define GETTER(retType, name) JNIEXPORT retType JNICALL \
41-
Java_org_kiwix_libzim_SuggestionItem__##name (JNIEnv* env, jobject thisObj) \
39+
#define GETTER(retType, name) METHOD0(retType, libzim_SuggestionItem, name) \
4240
{ \
4341
return TO_JNI(THIS->name()); \
4442
}

0 commit comments

Comments
 (0)