Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: libadblockplus-android/jni/JniSubscription.cpp

Issue 29347012: Issue 4188 - Update libadblockplus-android to use the latest libadblockplus (Closed)
Left Patch Set: Changes in libadblockplus-android repo with Sergei's changes Created Aug. 30, 2016, 11:02 a.m.
Right Patch Set: removed ctors with JsValue argument Created Dec. 12, 2016, 2:22 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 #include <AdblockPlus.h> 18 #include <AdblockPlus.h>
19 #include "Utils.h" 19 #include "Utils.h"
20 #include "JniJsValue.h" 20 #include "JniJsValue.h"
21 21
22 static AdblockPlus::Subscription* GetSubscriptionPtr(jlong ptr) 22 static AdblockPlus::Subscription* GetSubscriptionPtr(jlong ptr)
23 { 23 {
24 return JniLongToTypePtr<AdblockPlus::SubscriptionPtr>(ptr)->get(); 24 return JniLongToTypePtr<AdblockPlus::SubscriptionPtr>(ptr)->get();
25 }
26
27 static jlong JNICALL JniCtor(JNIEnv* env, jclass clazz, jlong jsValue)
28 {
29 try
30 {
31 return JniPtrToLong(new AdblockPlus::SubscriptionPtr(
32 *JniLongToTypePtr<AdblockPlus::SubscriptionPtr>(jsValue)));
33 }
34 CATCH_THROW_AND_RETURN(env, 0)
35 } 25 }
36 26
37 static jboolean JNICALL JniIsListed(JNIEnv* env, jclass clazz, jlong ptr) 27 static jboolean JNICALL JniIsListed(JNIEnv* env, jclass clazz, jlong ptr)
38 { 28 {
39 try 29 try
40 { 30 {
41 return GetSubscriptionPtr(ptr)->IsListed() ? JNI_TRUE : JNI_FALSE; 31 return GetSubscriptionPtr(ptr)->IsListed() ? JNI_TRUE : JNI_FALSE;
42 } 32 }
43 CATCH_THROW_AND_RETURN(env, JNI_FALSE) 33 CATCH_THROW_AND_RETURN(env, JNI_FALSE)
44 } 34 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 76
87 try 77 try
88 { 78 {
89 return *me == *other ? JNI_TRUE : JNI_FALSE; 79 return *me == *other ? JNI_TRUE : JNI_FALSE;
90 } 80 }
91 CATCH_THROW_AND_RETURN(env, JNI_FALSE) 81 CATCH_THROW_AND_RETURN(env, JNI_FALSE)
92 } 82 }
93 83
94 static JNINativeMethod methods[] = 84 static JNINativeMethod methods[] =
95 { 85 {
96 { (char*)"ctor", (char*)"(J)J", (void*)JniCtor },
97 { (char*)"isListed", (char*)"(J)Z", (void*)JniIsListed }, 86 { (char*)"isListed", (char*)"(J)Z", (void*)JniIsListed },
98 { (char*)"addToList", (char*)"(J)V", (void*)JniAddToList }, 87 { (char*)"addToList", (char*)"(J)V", (void*)JniAddToList },
99 { (char*)"removeFromList", (char*)"(J)V", (void*)JniRemoveFromList }, 88 { (char*)"removeFromList", (char*)"(J)V", (void*)JniRemoveFromList },
100 { (char*)"updateFilters", (char*)"(J)V", (void*)JniUpdateFilters }, 89 { (char*)"updateFilters", (char*)"(J)V", (void*)JniUpdateFilters },
101 { (char*)"isUpdating", (char*)"(J)Z", (void*)JniIsUpdating }, 90 { (char*)"isUpdating", (char*)"(J)Z", (void*)JniIsUpdating },
102 { (char*)"operatorEquals", (char*)"(JJ)Z", (void*)JniOperatorEquals } 91 { (char*)"operatorEquals", (char*)"(JJ)Z", (void*)JniOperatorEquals }
103 }; 92 };
104 93
105 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_Subscripti on_registerNatives(JNIEnv *env, jclass clazz) 94 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_Subscripti on_registerNatives(JNIEnv *env, jclass clazz)
106 { 95 {
107 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); 96 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0]));
108 } 97 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld