| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 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 14 matching lines...) Expand all Loading... |
| 25 } | 25 } |
| 26 CATCH_THROW_AND_RETURN(env, 0) | 26 CATCH_THROW_AND_RETURN(env, 0) |
| 27 } | 27 } |
| 28 | 28 |
| 29 static void JNICALL JniDtor(JNIEnv* env, jclass clazz, jlong ptr) | 29 static void JNICALL JniDtor(JNIEnv* env, jclass clazz, jlong ptr) |
| 30 { | 30 { |
| 31 delete JniLongToTypePtr<JniFilterChangeCallback>(ptr); | 31 delete JniLongToTypePtr<JniFilterChangeCallback>(ptr); |
| 32 } | 32 } |
| 33 | 33 |
| 34 JniFilterChangeCallback::JniFilterChangeCallback(JNIEnv* env, jobject callbackOb
ject) | 34 JniFilterChangeCallback::JniFilterChangeCallback(JNIEnv* env, jobject callbackOb
ject) |
| 35 : JniCallbackBase(env, callbackObject) | 35 : JniCallbackBase(env, callbackObject), jsValueClass(new JniGlobalReference<jc
lass>(env, env->FindClass(PKG("JsValue")))) |
| 36 { | 36 { |
| 37 } | 37 } |
| 38 | 38 |
| 39 void JniFilterChangeCallback::Callback(const std::string& arg, const AdblockPlus
::JsValuePtr jsValue) | 39 void JniFilterChangeCallback::Callback(const std::string& arg, const AdblockPlus
::JsValuePtr jsValue) |
| 40 { | 40 { |
| 41 JNIEnvAcquire env(GetJavaVM()); | 41 JNIEnvAcquire env(GetJavaVM()); |
| 42 | 42 |
| 43 jclass clazz = env->GetObjectClass(GetCallbackObject()); | 43 jclass clazz = env->GetObjectClass(GetCallbackObject()); |
| 44 jmethodID method = env->GetMethodID(clazz, "filterChangeCallback", "(Ljava/lan
g/String;" TYP("JsValue") ")V"); | 44 jmethodID method = env->GetMethodID(clazz, "filterChangeCallback", "(Ljava/lan
g/String;" TYP("JsValue") ")V"); |
| 45 | 45 |
| 46 if (method) | 46 if (method) |
| 47 { | 47 { |
| 48 jstring jArg = env->NewStringUTF(arg.c_str()); | 48 jstring jArg = env->NewStringUTF(arg.c_str()); |
| 49 jobject jJsValue = NewJniJsValue(*env, jsValue); | 49 jobject jJsValue = NewJniJsValue(*env, jsValue, jsValueClass->Get()); |
| 50 env->CallVoidMethod(GetCallbackObject(), method, jArg, jJsValue); | 50 env->CallVoidMethod(GetCallbackObject(), method, jArg, jJsValue); |
| 51 } | 51 } |
| 52 | 52 |
| 53 CheckAndLogJavaException(*env); | 53 CheckAndLogJavaException(*env); |
| 54 } | 54 } |
| 55 | 55 |
| 56 static JNINativeMethod methods[] = | 56 static JNINativeMethod methods[] = |
| 57 { | 57 { |
| 58 { (char*)"ctor", (char*)"(Ljava/lang/Object;)J", (void*)JniCtor }, | 58 { (char*)"ctor", (char*)"(Ljava/lang/Object;)J", (void*)JniCtor }, |
| 59 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor } | 59 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor } |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_FilterChan
geCallback_registerNatives(JNIEnv *env, jclass clazz) | 62 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_FilterChan
geCallback_registerNatives(JNIEnv *env, jclass clazz) |
| 63 { | 63 { |
| 64 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); | 64 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); |
| 65 } | 65 } |
| OLD | NEW |