John Reck | 9fa4071 | 2014-05-09 15:26:59 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include "jni.h" |
| 18 | #include <nativehelper/JNIHelp.h> |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 19 | #include "core_jni_helpers.h" |
John Reck | 9fa4071 | 2014-05-09 15:26:59 -0700 | [diff] [blame] | 20 | |
| 21 | namespace android { |
| 22 | |
| 23 | static void incStrong(JNIEnv* env, jobject clazz, jlong objPtr) { |
| 24 | VirtualLightRefBase* obj = reinterpret_cast<VirtualLightRefBase*>(objPtr); |
| 25 | obj->incStrong(0); |
| 26 | } |
| 27 | |
| 28 | static void decStrong(JNIEnv* env, jobject clazz, jlong objPtr) { |
| 29 | VirtualLightRefBase* obj = reinterpret_cast<VirtualLightRefBase*>(objPtr); |
| 30 | obj->decStrong(0); |
| 31 | } |
| 32 | |
| 33 | // ---------------------------------------------------------------------------- |
| 34 | // JNI Glue |
| 35 | // ---------------------------------------------------------------------------- |
| 36 | |
| 37 | const char* const kClassPathName = "com/android/internal/util/VirtualRefBasePtr"; |
| 38 | |
Daniel Micay | 76f6a86 | 2015-09-19 17:31:01 -0400 | [diff] [blame] | 39 | static const JNINativeMethod gMethods[] = { |
John Reck | 9fa4071 | 2014-05-09 15:26:59 -0700 | [diff] [blame] | 40 | { "nIncStrong", "(J)V", (void*) incStrong }, |
| 41 | { "nDecStrong", "(J)V", (void*) decStrong }, |
| 42 | }; |
| 43 | |
| 44 | int register_com_android_internal_util_VirtualRefBasePtr(JNIEnv* env) { |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 45 | return RegisterMethodsOrDie(env, kClassPathName, gMethods, NELEM(gMethods)); |
John Reck | 9fa4071 | 2014-05-09 15:26:59 -0700 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | |
| 49 | } // namespace android |