Chet Haase | 6e0ecb4 | 2010-11-03 19:41:18 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 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 <stdio.h> |
| 18 | #include <assert.h> |
| 19 | |
| 20 | #include "jni.h" |
| 21 | #include <android_runtime/AndroidRuntime.h> |
| 22 | #include <utils/misc.h> |
| 23 | |
| 24 | // ---------------------------------------------------------------------------- |
| 25 | |
| 26 | namespace android { |
| 27 | |
| 28 | // ---------------------------------------------------------------------------- |
| 29 | |
| 30 | const char* const kClassPathName = "android/animation/PropertyValuesHolder"; |
| 31 | |
Ashok Bhat | 0141e88 | 2014-01-17 16:44:27 +0000 | [diff] [blame] | 32 | static jlong android_animation_PropertyValuesHolder_getIntMethod( |
Chet Haase | 6e0ecb4 | 2010-11-03 19:41:18 -0700 | [diff] [blame] | 33 | JNIEnv* env, jclass pvhClass, jclass targetClass, jstring methodName) |
| 34 | { |
| 35 | const char *nativeString = env->GetStringUTFChars(methodName, 0); |
| 36 | jmethodID mid = env->GetMethodID(targetClass, nativeString, "(I)V"); |
| 37 | env->ReleaseStringUTFChars(methodName, nativeString); |
Ashok Bhat | 0141e88 | 2014-01-17 16:44:27 +0000 | [diff] [blame] | 38 | return reinterpret_cast<jlong>(mid); |
Chet Haase | 6e0ecb4 | 2010-11-03 19:41:18 -0700 | [diff] [blame] | 39 | } |
| 40 | |
Ashok Bhat | 0141e88 | 2014-01-17 16:44:27 +0000 | [diff] [blame] | 41 | static jlong android_animation_PropertyValuesHolder_getFloatMethod( |
Chet Haase | 6e0ecb4 | 2010-11-03 19:41:18 -0700 | [diff] [blame] | 42 | JNIEnv* env, jclass pvhClass, jclass targetClass, jstring methodName) |
| 43 | { |
| 44 | const char *nativeString = env->GetStringUTFChars(methodName, 0); |
| 45 | jmethodID mid = env->GetMethodID(targetClass, nativeString, "(F)V"); |
| 46 | env->ReleaseStringUTFChars(methodName, nativeString); |
Ashok Bhat | 0141e88 | 2014-01-17 16:44:27 +0000 | [diff] [blame] | 47 | return reinterpret_cast<jlong>(mid); |
Chet Haase | 6e0ecb4 | 2010-11-03 19:41:18 -0700 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | static void android_animation_PropertyValuesHolder_callIntMethod( |
Ashok Bhat | 0141e88 | 2014-01-17 16:44:27 +0000 | [diff] [blame] | 51 | JNIEnv* env, jclass pvhObject, jobject target, jlong methodID, jint arg) |
Chet Haase | 6e0ecb4 | 2010-11-03 19:41:18 -0700 | [diff] [blame] | 52 | { |
Ashok Bhat | 0141e88 | 2014-01-17 16:44:27 +0000 | [diff] [blame] | 53 | env->CallVoidMethod(target, reinterpret_cast<jmethodID>(methodID), arg); |
Chet Haase | 6e0ecb4 | 2010-11-03 19:41:18 -0700 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | static void android_animation_PropertyValuesHolder_callFloatMethod( |
Ashok Bhat | 0141e88 | 2014-01-17 16:44:27 +0000 | [diff] [blame] | 57 | JNIEnv* env, jclass pvhObject, jobject target, jlong methodID, jfloat arg) |
Chet Haase | 6e0ecb4 | 2010-11-03 19:41:18 -0700 | [diff] [blame] | 58 | { |
Ashok Bhat | 0141e88 | 2014-01-17 16:44:27 +0000 | [diff] [blame] | 59 | env->CallVoidMethod(target, reinterpret_cast<jmethodID>(methodID), arg); |
Chet Haase | 6e0ecb4 | 2010-11-03 19:41:18 -0700 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | static JNINativeMethod gMethods[] = { |
Ashok Bhat | 0141e88 | 2014-01-17 16:44:27 +0000 | [diff] [blame] | 63 | { "nGetIntMethod", "(Ljava/lang/Class;Ljava/lang/String;)J", |
Chet Haase | 6e0ecb4 | 2010-11-03 19:41:18 -0700 | [diff] [blame] | 64 | (void*)android_animation_PropertyValuesHolder_getIntMethod }, |
Ashok Bhat | 0141e88 | 2014-01-17 16:44:27 +0000 | [diff] [blame] | 65 | { "nGetFloatMethod", "(Ljava/lang/Class;Ljava/lang/String;)J", |
Chet Haase | 6e0ecb4 | 2010-11-03 19:41:18 -0700 | [diff] [blame] | 66 | (void*)android_animation_PropertyValuesHolder_getFloatMethod }, |
Ashok Bhat | 0141e88 | 2014-01-17 16:44:27 +0000 | [diff] [blame] | 67 | { "nCallIntMethod", "(Ljava/lang/Object;JI)V", |
Chet Haase | 6e0ecb4 | 2010-11-03 19:41:18 -0700 | [diff] [blame] | 68 | (void*)android_animation_PropertyValuesHolder_callIntMethod }, |
Ashok Bhat | 0141e88 | 2014-01-17 16:44:27 +0000 | [diff] [blame] | 69 | { "nCallFloatMethod", "(Ljava/lang/Object;JF)V", |
Chet Haase | 6e0ecb4 | 2010-11-03 19:41:18 -0700 | [diff] [blame] | 70 | (void*)android_animation_PropertyValuesHolder_callFloatMethod } |
| 71 | }; |
| 72 | |
| 73 | int register_android_animation_PropertyValuesHolder(JNIEnv* env) |
| 74 | { |
| 75 | return AndroidRuntime::registerNativeMethods(env, |
| 76 | kClassPathName, gMethods, NELEM(gMethods)); |
| 77 | } |
| 78 | |
| 79 | }; |