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

Unified Diff: libadblockplus-android/jni/JniJsValue.cpp

Issue 29345353: Issue 4086 - JsValue.isNumber() crashes (Closed)
Patch Set: Created May 30, 2016, 11:13 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: libadblockplus-android/jni/JniJsValue.cpp
===================================================================
--- a/libadblockplus-android/jni/JniJsValue.cpp
+++ b/libadblockplus-android/jni/JniJsValue.cpp
@@ -32,16 +32,25 @@
{
try
{
return JniGetJsValue(ptr)->IsNull() ? JNI_TRUE : JNI_FALSE;
}
CATCH_THROW_AND_RETURN(env, JNI_FALSE)
}
+static jboolean JNICALL JniIsNumber(JNIEnv* env, jclass clazz, jlong ptr)
+{
+ try
+ {
+ return JniGetJsValue(ptr)->IsNumber() ? JNI_TRUE : JNI_FALSE;
+ }
+ CATCH_THROW_AND_RETURN(env, JNI_FALSE)
+}
+
static jboolean JNICALL JniIsString(JNIEnv* env, jclass clazz, jlong ptr)
{
try
{
return JniGetJsValue(ptr)->IsString() ? JNI_TRUE : JNI_FALSE;
}
CATCH_THROW_AND_RETURN(env, JNI_FALSE)
}
@@ -187,16 +196,17 @@
//inline void SetProperty(const std::string& name, int val);
//std::string GetClass() const;
//JsValuePtr Call(const JsValueList& params = JsValueList(), AdblockPlus::JsValuePtr thisPtr = AdblockPlus::JsValuePtr()) const;
static JNINativeMethod methods[] =
{
{ (char*)"isUndefined", (char*)"(J)Z", (void*)JniIsUndefined },
{ (char*)"isNull", (char*)"(J)Z", (void*)JniIsNull },
+ { (char*)"isNumber", (char*)"(J)Z", (void*)JniIsNumber },
{ (char*)"isString", (char*)"(J)Z", (void*)JniIsString },
{ (char*)"isBoolean", (char*)"(J)Z", (void*)JniIsBoolean },
{ (char*)"isObject", (char*)"(J)Z", (void*)JniIsObject },
{ (char*)"isArray", (char*)"(J)Z", (void*)JniIsArray },
{ (char*)"isFunction", (char*)"(J)Z", (void*)JniIsFunction },
{ (char*)"asString", (char*)"(J)Ljava/lang/String;", (void*)JniAsString },
{ (char*)"asLong", (char*)"(J)J", (void*)JniAsLong },
{ (char*)"asBoolean", (char*)"(J)Z", (void*)JniAsBoolean },
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld