Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 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 #ifndef UTILS_H | 18 #ifndef UTILS_H |
19 #define UTILS_H | 19 #define UTILS_H |
20 | 20 |
21 #include <string> | 21 #include <string> |
22 #include <algorithm> | 22 #include <algorithm> |
23 #include <jni.h> | 23 #include <jni.h> |
24 #include <stdexcept> | 24 #include <stdexcept> |
25 | 25 |
26 #include <AdblockPlus.h> | 26 #include <AdblockPlus.h> |
27 #include <AdblockPlus/tr1_memory.h> | 27 #include <AdblockPlus/tr1_memory.h> |
28 | 28 |
29 #include "v8/v8stdint.h" | |
30 | |
31 #define PKG(x) "org/adblockplus/libadblockplus/" x | 29 #define PKG(x) "org/adblockplus/libadblockplus/" x |
32 #define TYP(x) "L" PKG(x) ";" | 30 #define TYP(x) "L" PKG(x) ";" |
33 | 31 |
34 #define ABP_JNI_VERSION JNI_VERSION_1_6 | 32 #define ABP_JNI_VERSION JNI_VERSION_1_6 |
35 | 33 |
36 void JniThrowException(JNIEnv* env, const std::string& message); | 34 void JniThrowException(JNIEnv* env, const std::string& message); |
37 | 35 |
38 void JniThrowException(JNIEnv* env, const std::exception& e); | 36 void JniThrowException(JNIEnv* env, const std::exception& e); |
39 | 37 |
40 void JniThrowException(JNIEnv* env); | 38 void JniThrowException(JNIEnv* env); |
41 | 39 |
42 class JNIEnvAcquire; | 40 class JNIEnvAcquire; |
43 | 41 |
44 /** | 42 /** |
45 * This class is _NOT_ thread safe! | 43 * This class is _NOT_ thread safe! |
46 */ | 44 */ |
47 template<typename T> | 45 template<typename T> |
48 class JniLocalReference | 46 class JniLocalReference |
49 { | 47 { |
50 public: | 48 public: |
51 explicit JniLocalReference(JNIEnv* jniEnv, T object) | 49 JniLocalReference(JNIEnv* jniEnv, T object) |
Felix Dahlke
2015/02/03 05:22:50
Doesn't need to be explicit since there's two argu
René Jeschke
2015/02/03 13:51:26
Done.
| |
52 : jniEnv(jniEnv), object(object) | 50 : jniEnv(jniEnv), object(object) |
53 { | 51 { |
54 | 52 |
55 } | 53 } |
56 | 54 |
57 JniLocalReference(const JniLocalReference<T>& other); | 55 JniLocalReference(const JniLocalReference<T>& other); |
58 | 56 |
59 ~JniLocalReference() | 57 ~JniLocalReference() |
60 { | 58 { |
61 jniEnv->DeleteLocalRef(object); | 59 jniEnv->DeleteLocalRef(object); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
218 JniThrowException(jEnv, except); \ | 216 JniThrowException(jEnv, except); \ |
219 return retVal; \ | 217 return retVal; \ |
220 } \ | 218 } \ |
221 catch (...) \ | 219 catch (...) \ |
222 { \ | 220 { \ |
223 JniThrowException(jEnv); \ | 221 JniThrowException(jEnv); \ |
224 return retVal; \ | 222 return retVal; \ |
225 } | 223 } |
226 | 224 |
227 #endif | 225 #endif |
LEFT | RIGHT |