| 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-present eyeo GmbH | 3  * Copyright (C) 2006-present 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 21 matching lines...) Expand all  Loading... | 
| 32   appInfo.version = JniGetStringField(env, clazz, jAppInfo, "version"); | 32   appInfo.version = JniGetStringField(env, clazz, jAppInfo, "version"); | 
| 33 | 33 | 
| 34   appInfo.developmentBuild = JniGetBooleanField(env, clazz, jAppInfo, "developme
     ntBuild"); | 34   appInfo.developmentBuild = JniGetBooleanField(env, clazz, jAppInfo, "developme
     ntBuild"); | 
| 35 } | 35 } | 
| 36 | 36 | 
| 37 static AdblockPlus::JsEngine& GetJsEngineRef(jlong ptr) | 37 static AdblockPlus::JsEngine& GetJsEngineRef(jlong ptr) | 
| 38 { | 38 { | 
| 39   return *JniLongToTypePtr<JniJsEngine>(ptr)->jsEngine; | 39   return *JniLongToTypePtr<JniJsEngine>(ptr)->jsEngine; | 
| 40 } | 40 } | 
| 41 | 41 | 
| 42 static jlong JNICALL JniCtor(JNIEnv* env, jclass clazz, jobject jAppInfo, jlong 
     logSystemPtr) | 42 static jlong JNICALL JniCtor(JNIEnv* env, jclass clazz, jobject jAppInfo, jobjec
     t logSystem) | 
| 43 { | 43 { | 
| 44   AdblockPlus::AppInfo appInfo; | 44   AdblockPlus::AppInfo appInfo; | 
| 45 | 45 | 
| 46   TransformAppInfo(env, jAppInfo, appInfo); | 46   TransformAppInfo(env, jAppInfo, appInfo); | 
| 47 | 47 | 
| 48   try | 48   try | 
| 49   { | 49   { | 
| 50     AdblockPlus::TimerPtr timer = AdblockPlus::CreateDefaultTimer(); | 50     AdblockPlus::TimerPtr timer = AdblockPlus::CreateDefaultTimer(); | 
| 51     JniJsEngine* jniJsEngine = new JniJsEngine(); | 51     JniJsEngine* jniJsEngine = new JniJsEngine(); | 
| 52     jniJsEngine->timer = timer.get(); | 52     jniJsEngine->timer = timer.get(); | 
| 53     jniJsEngine->jsEngine = AdblockPlus::JsEngine::New(appInfo, std::move(timer)
     ); | 53     jniJsEngine->jsEngine = AdblockPlus::JsEngine::New(appInfo, std::move(timer)
     ); | 
| 54     if (logSystemPtr) | 54     if (logSystem) | 
| 55     { | 55     { | 
| 56       jniJsEngine->jsEngine->SetLogSystem(*JniLongToTypePtr<AdblockPlus::LogSyst
     emPtr>(logSystemPtr)); | 56       jniJsEngine->jsEngine->SetLogSystem(std::make_shared<JniLogSystemCallback>
     (env, logSystem)); | 
| 57     } | 57     } | 
| 58     return JniPtrToLong(jniJsEngine); | 58     return JniPtrToLong(jniJsEngine); | 
| 59   } | 59   } | 
| 60   CATCH_THROW_AND_RETURN(env, 0) | 60   CATCH_THROW_AND_RETURN(env, 0) | 
| 61 } | 61 } | 
| 62 | 62 | 
| 63 static void JNICALL JniDtor(JNIEnv* env, jclass clazz, jlong ptr) | 63 static void JNICALL JniDtor(JNIEnv* env, jclass clazz, jlong ptr) | 
| 64 { | 64 { | 
| 65   delete JniLongToTypePtr<JniJsEngine>(ptr); | 65   delete JniLongToTypePtr<JniJsEngine>(ptr); | 
| 66 } | 66 } | 
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 202 } | 202 } | 
| 203 | 203 | 
| 204 // TODO: List of functions that lack JNI bindings | 204 // TODO: List of functions that lack JNI bindings | 
| 205 //JsValuePtr NewObject(); | 205 //JsValuePtr NewObject(); | 
| 206 //JsValuePtr NewCallback(v8::InvocationCallback callback); | 206 //JsValuePtr NewCallback(v8::InvocationCallback callback); | 
| 207 //static JsEnginePtr FromArguments(const v8::Arguments& arguments); | 207 //static JsEnginePtr FromArguments(const v8::Arguments& arguments); | 
| 208 //JsValueList ConvertArguments(const v8::Arguments& arguments); | 208 //JsValueList ConvertArguments(const v8::Arguments& arguments); | 
| 209 | 209 | 
| 210 static JNINativeMethod methods[] = | 210 static JNINativeMethod methods[] = | 
| 211 { | 211 { | 
| 212   { (char*)"ctor", (char*)"(" TYP("AppInfo") "J)J", (void*)JniCtor }, | 212   { (char*)"ctor", (char*)"(" TYP("AppInfo") TYP("LogSystem")")J", (void*)JniCto
     r }, | 
| 213   { (char*)"dtor", (char*)"(J)V", (void*)JniDtor }, | 213   { (char*)"dtor", (char*)"(J)V", (void*)JniDtor }, | 
| 214 | 214 | 
| 215   { (char*)"setEventCallback", (char*)"(JLjava/lang/String;J)V", (void*)JniSetEv
     entCallback }, | 215   { (char*)"setEventCallback", (char*)"(JLjava/lang/String;J)V", (void*)JniSetEv
     entCallback }, | 
| 216   { (char*)"removeEventCallback", (char*)"(JLjava/lang/String;)V", (void*)JniRem
     oveEventCallback }, | 216   { (char*)"removeEventCallback", (char*)"(JLjava/lang/String;)V", (void*)JniRem
     oveEventCallback }, | 
| 217   { (char*)"triggerEvent", (char*)"(JLjava/lang/String;[J)V", (void*)JniTriggerE
     vent }, | 217   { (char*)"triggerEvent", (char*)"(JLjava/lang/String;[J)V", (void*)JniTriggerE
     vent }, | 
| 218 | 218 | 
| 219   { (char*)"evaluate", (char*)"(JLjava/lang/String;Ljava/lang/String;)" TYP("JsV
     alue"), (void*)JniEvaluate }, | 219   { (char*)"evaluate", (char*)"(JLjava/lang/String;Ljava/lang/String;)" TYP("JsV
     alue"), (void*)JniEvaluate }, | 
| 220 | 220 | 
| 221   { (char*)"setDefaultFileSystem", (char*)"(JLjava/lang/String;)V", (void*)JniSe
     tDefaultFileSystem }, | 221   { (char*)"setDefaultFileSystem", (char*)"(JLjava/lang/String;)V", (void*)JniSe
     tDefaultFileSystem }, | 
| 222   { (char*)"setWebRequest", (char*)"(JJ)V", (void*)JniSetWebRequest }, | 222   { (char*)"setWebRequest", (char*)"(JJ)V", (void*)JniSetWebRequest }, | 
| 223 | 223 | 
| 224   { (char*)"newValue", (char*)"(JJ)" TYP("JsValue"), (void*)JniNewLongValue }, | 224   { (char*)"newValue", (char*)"(JJ)" TYP("JsValue"), (void*)JniNewLongValue }, | 
| 225   { (char*)"newValue", (char*)"(JZ)" TYP("JsValue"), (void*)JniNewBooleanValue }
     , | 225   { (char*)"newValue", (char*)"(JZ)" TYP("JsValue"), (void*)JniNewBooleanValue }
     , | 
| 226   { (char*)"newValue", (char*)"(JLjava/lang/String;)" TYP("JsValue"), (void*)Jni
     NewStringValue } | 226   { (char*)"newValue", (char*)"(JLjava/lang/String;)" TYP("JsValue"), (void*)Jni
     NewStringValue } | 
| 227 }; | 227 }; | 
| 228 | 228 | 
| 229 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_JsEngine_r
     egisterNatives(JNIEnv *env, jclass clazz) | 229 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_JsEngine_r
     egisterNatives(JNIEnv *env, jclass clazz) | 
| 230 { | 230 { | 
| 231   env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); | 231   env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); | 
| 232 } | 232 } | 
| OLD | NEW | 
|---|