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

Side by Side Diff: libadblockplus-android/jni/Utils.cpp

Issue 29422558: Issue 5167 - Update to use libadblockplus revision dca8df9af1a7 (Closed)
Patch Set: removed unneeded intermediate variable Created April 26, 2017, 6:57 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
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-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 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
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 157
158 JNIEnvAcquire::~JNIEnvAcquire() 158 JNIEnvAcquire::~JNIEnvAcquire()
159 { 159 {
160 if (attachmentStatus == JNI_EDETACHED) 160 if (attachmentStatus == JNI_EDETACHED)
161 { 161 {
162 javaVM->DetachCurrentThread(); 162 javaVM->DetachCurrentThread();
163 } 163 }
164 } 164 }
165 165
166 template<typename T> 166 template<typename T>
167 static jobject NewJniObject(JNIEnv* env, const T& value, jclass clazz, jmethodID ctor) 167 static jobject NewJniObject(JNIEnv* env, const T& value, jclass clazz, jmethodID ctor)
sergei 2017/04/26 09:21:00 `const T& value` -> `T&& value`
anton 2017/04/26 10:22:59 Acknowledged.
168 { 168 {
169 if (!value.get())
170 {
171 return 0;
172 }
173
174 return env->NewObject(clazz, ctor, JniPtrToLong(new T(value))); 169 return env->NewObject(clazz, ctor, JniPtrToLong(new T(value)));
sergei 2017/04/26 09:21:00 return env->NewObject(clazz, ctor, JniPtrToLong(ne
anton 2017/04/26 10:22:59 then we will have compile error: "Error:(169, 80)
sergei 2017/04/26 14:12:56 That is strange, is it when the type of value arg
175 } 170 }
176 171
177 template<typename T> 172 template<typename T>
178 static jobject NewJniObject(JNIEnv* env, const T& value, const char* javaClass) 173 static jobject NewJniObject(JNIEnv* env, const T& value, const char* javaClass)
179 { 174 {
180 JniLocalReference<jclass> clazz( env, env->FindClass(javaClass)); 175 JniLocalReference<jclass> clazz( env, env->FindClass(javaClass));
181 jmethodID ctor = env->GetMethodID(*clazz, "<init>", "(J)V"); 176 jmethodID ctor = env->GetMethodID(*clazz, "<init>", "(J)V");
182 return NewJniObject(env, value, *clazz, ctor); 177 return NewJniObject(env, value, *clazz, ctor);
183 } 178 }
184 179
185 jobject NewJniFilter(JNIEnv* env, const AdblockPlus::FilterPtr& filter) 180 jobject NewJniFilter(JNIEnv* env, AdblockPlus::Filter& filter)
186 { 181 {
187 return NewJniObject(env, filter, filterClass->Get(), filterCtor); 182 return NewJniObject(env, filter, filterClass->Get(), filterCtor);
188 } 183 }
189 184
190 jobject NewJniSubscription(JNIEnv* env, 185 jobject NewJniSubscription(JNIEnv* env, AdblockPlus::Subscription& subscription)
191 const AdblockPlus::SubscriptionPtr& subscription)
192 { 186 {
193 return NewJniObject(env, subscription, subscriptionClass->Get(), subscriptionC tor); 187 return NewJniObject(env, subscription, subscriptionClass->Get(), subscriptionC tor);
194 } 188 }
195 189
196 jobject NewJniNotification(JNIEnv* env, 190 jobject NewJniNotification(JNIEnv* env, AdblockPlus::Notification& notification)
197 const AdblockPlus::NotificationPtr& notification)
198 { 191 {
199 return NewJniObject(env, notification, notificationClass->Get(), notificationC tor); 192 return NewJniObject(env, notification, notificationClass->Get(), notificationC tor);
200 } 193 }
OLDNEW
« libadblockplus-android/jni/Utils.h ('K') | « libadblockplus-android/jni/Utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld