Left: | ||
Right: |
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-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 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 if (notificationEnumClass) | 31 if (notificationEnumClass) |
32 { | 32 { |
33 delete notificationEnumClass; | 33 delete notificationEnumClass; |
34 notificationEnumClass = NULL; | 34 notificationEnumClass = NULL; |
35 } | 35 } |
36 } | 36 } |
37 | 37 |
38 static AdblockPlus::Notification* GetNotificationPtr(jlong ptr) | 38 static AdblockPlus::Notification* GetNotificationPtr(jlong ptr) |
39 { | 39 { |
40 return JniLongToTypePtr<AdblockPlus::NotificationPtr>(ptr)->get(); | 40 return JniLongToTypePtr<AdblockPlus::Notification>(ptr); |
sergei
2017/04/26 09:21:00
as far as I remember we store the pointer in Java
anton
2017/04/26 10:22:59
No, we do create the same object class as it was p
sergei
2017/04/26 14:12:56
Let's consider an example with Notification.
Java
anton
2017/04/27 06:21:01
We pass just `long` value to Java side without any
| |
41 } | 41 } |
42 | 42 |
43 static jobject JNICALL JniGetType(JNIEnv* env, jclass clazz, jlong ptr) | 43 static jobject JNICALL JniGetType(JNIEnv* env, jclass clazz, jlong ptr) |
44 { | 44 { |
45 AdblockPlus::NotificationType type; | 45 AdblockPlus::NotificationType type; |
46 try | 46 try |
47 { | 47 { |
48 type = GetNotificationPtr(ptr)->GetType(); | 48 type = GetNotificationPtr(ptr)->GetType(); |
49 } | 49 } |
50 CATCH_THROW_AND_RETURN(env, 0) | 50 CATCH_THROW_AND_RETURN(env, 0) |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 { (char*) "getTitle", (char*) "(J)Ljava/lang/String;", (void*) JniGetTitle }, | 109 { (char*) "getTitle", (char*) "(J)Ljava/lang/String;", (void*) JniGetTitle }, |
110 { (char*) "getType", (char*) "(J)" TYP("Notification$Type"), (void*) JniGetTyp e } | 110 { (char*) "getType", (char*) "(J)" TYP("Notification$Type"), (void*) JniGetTyp e } |
111 }; | 111 }; |
112 | 112 |
113 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_Notificati on_registerNatives( | 113 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_Notificati on_registerNatives( |
114 JNIEnv *env, jclass clazz) | 114 JNIEnv *env, jclass clazz) |
115 { | 115 { |
116 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); | 116 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); |
117 } | 117 } |
118 | 118 |
OLD | NEW |