OLD | NEW |
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 |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 static jboolean JNICALL JniIsNull(JNIEnv* env, jclass clazz, jlong ptr) | 31 static jboolean JNICALL JniIsNull(JNIEnv* env, jclass clazz, jlong ptr) |
32 { | 32 { |
33 try | 33 try |
34 { | 34 { |
35 return JniGetJsValue(ptr)->IsNull() ? JNI_TRUE : JNI_FALSE; | 35 return JniGetJsValue(ptr)->IsNull() ? JNI_TRUE : JNI_FALSE; |
36 } | 36 } |
37 CATCH_THROW_AND_RETURN(env, JNI_FALSE) | 37 CATCH_THROW_AND_RETURN(env, JNI_FALSE) |
38 } | 38 } |
39 | 39 |
| 40 static jboolean JNICALL JniIsNumber(JNIEnv* env, jclass clazz, jlong ptr) |
| 41 { |
| 42 try |
| 43 { |
| 44 return JniGetJsValue(ptr)->IsNumber() ? JNI_TRUE : JNI_FALSE; |
| 45 } |
| 46 CATCH_THROW_AND_RETURN(env, JNI_FALSE) |
| 47 } |
| 48 |
40 static jboolean JNICALL JniIsString(JNIEnv* env, jclass clazz, jlong ptr) | 49 static jboolean JNICALL JniIsString(JNIEnv* env, jclass clazz, jlong ptr) |
41 { | 50 { |
42 try | 51 try |
43 { | 52 { |
44 return JniGetJsValue(ptr)->IsString() ? JNI_TRUE : JNI_FALSE; | 53 return JniGetJsValue(ptr)->IsString() ? JNI_TRUE : JNI_FALSE; |
45 } | 54 } |
46 CATCH_THROW_AND_RETURN(env, JNI_FALSE) | 55 CATCH_THROW_AND_RETURN(env, JNI_FALSE) |
47 } | 56 } |
48 | 57 |
49 static jboolean JNICALL JniIsBoolean(JNIEnv* env, jclass clazz, jlong ptr) | 58 static jboolean JNICALL JniIsBoolean(JNIEnv* env, jclass clazz, jlong ptr) |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 //void SetProperty(const std::string& name, JsValuePtr value); | 194 //void SetProperty(const std::string& name, JsValuePtr value); |
186 //void SetProperty(const std::string& name, const char* val); | 195 //void SetProperty(const std::string& name, const char* val); |
187 //inline void SetProperty(const std::string& name, int val); | 196 //inline void SetProperty(const std::string& name, int val); |
188 //std::string GetClass() const; | 197 //std::string GetClass() const; |
189 //JsValuePtr Call(const JsValueList& params = JsValueList(), AdblockPlus::JsValu
ePtr thisPtr = AdblockPlus::JsValuePtr()) const; | 198 //JsValuePtr Call(const JsValueList& params = JsValueList(), AdblockPlus::JsValu
ePtr thisPtr = AdblockPlus::JsValuePtr()) const; |
190 | 199 |
191 static JNINativeMethod methods[] = | 200 static JNINativeMethod methods[] = |
192 { | 201 { |
193 { (char*)"isUndefined", (char*)"(J)Z", (void*)JniIsUndefined }, | 202 { (char*)"isUndefined", (char*)"(J)Z", (void*)JniIsUndefined }, |
194 { (char*)"isNull", (char*)"(J)Z", (void*)JniIsNull }, | 203 { (char*)"isNull", (char*)"(J)Z", (void*)JniIsNull }, |
| 204 { (char*)"isNumber", (char*)"(J)Z", (void*)JniIsNumber }, |
195 { (char*)"isString", (char*)"(J)Z", (void*)JniIsString }, | 205 { (char*)"isString", (char*)"(J)Z", (void*)JniIsString }, |
196 { (char*)"isBoolean", (char*)"(J)Z", (void*)JniIsBoolean }, | 206 { (char*)"isBoolean", (char*)"(J)Z", (void*)JniIsBoolean }, |
197 { (char*)"isObject", (char*)"(J)Z", (void*)JniIsObject }, | 207 { (char*)"isObject", (char*)"(J)Z", (void*)JniIsObject }, |
198 { (char*)"isArray", (char*)"(J)Z", (void*)JniIsArray }, | 208 { (char*)"isArray", (char*)"(J)Z", (void*)JniIsArray }, |
199 { (char*)"isFunction", (char*)"(J)Z", (void*)JniIsFunction }, | 209 { (char*)"isFunction", (char*)"(J)Z", (void*)JniIsFunction }, |
200 { (char*)"asString", (char*)"(J)Ljava/lang/String;", (void*)JniAsString }, | 210 { (char*)"asString", (char*)"(J)Ljava/lang/String;", (void*)JniAsString }, |
201 { (char*)"asLong", (char*)"(J)J", (void*)JniAsLong }, | 211 { (char*)"asLong", (char*)"(J)J", (void*)JniAsLong }, |
202 { (char*)"asBoolean", (char*)"(J)Z", (void*)JniAsBoolean }, | 212 { (char*)"asBoolean", (char*)"(J)Z", (void*)JniAsBoolean }, |
203 { (char*)"asList", (char*)"(J)Ljava/util/List;", (void*)JniAsList }, | 213 { (char*)"asList", (char*)"(J)Ljava/util/List;", (void*)JniAsList }, |
204 { (char*)"getProperty", (char*)"(JLjava/lang/String;)" TYP("JsValue"), (void*)
JniGetProperty }, | 214 { (char*)"getProperty", (char*)"(JLjava/lang/String;)" TYP("JsValue"), (void*)
JniGetProperty }, |
205 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor } | 215 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor } |
206 }; | 216 }; |
207 | 217 |
208 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_JsValue_re
gisterNatives(JNIEnv *env, jclass clazz) | 218 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_JsValue_re
gisterNatives(JNIEnv *env, jclass clazz) |
209 { | 219 { |
210 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); | 220 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); |
211 } | 221 } |
OLD | NEW |