blob: 1e3ec18f356e791d39d77f3bf36a5ea4869f8f01 [file] [log] [blame]
Chet Haase6e0ecb42010-11-03 19:41:18 -07001/*
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
26namespace android {
27
28// ----------------------------------------------------------------------------
29
30const char* const kClassPathName = "android/animation/PropertyValuesHolder";
31
Ashok Bhat0141e882014-01-17 16:44:27 +000032static jlong android_animation_PropertyValuesHolder_getIntMethod(
Chet Haase6e0ecb42010-11-03 19:41:18 -070033 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 Bhat0141e882014-01-17 16:44:27 +000038 return reinterpret_cast<jlong>(mid);
Chet Haase6e0ecb42010-11-03 19:41:18 -070039}
40
Ashok Bhat0141e882014-01-17 16:44:27 +000041static jlong android_animation_PropertyValuesHolder_getFloatMethod(
Chet Haase6e0ecb42010-11-03 19:41:18 -070042 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 Bhat0141e882014-01-17 16:44:27 +000047 return reinterpret_cast<jlong>(mid);
Chet Haase6e0ecb42010-11-03 19:41:18 -070048}
49
50static void android_animation_PropertyValuesHolder_callIntMethod(
Ashok Bhat0141e882014-01-17 16:44:27 +000051 JNIEnv* env, jclass pvhObject, jobject target, jlong methodID, jint arg)
Chet Haase6e0ecb42010-11-03 19:41:18 -070052{
Ashok Bhat0141e882014-01-17 16:44:27 +000053 env->CallVoidMethod(target, reinterpret_cast<jmethodID>(methodID), arg);
Chet Haase6e0ecb42010-11-03 19:41:18 -070054}
55
56static void android_animation_PropertyValuesHolder_callFloatMethod(
Ashok Bhat0141e882014-01-17 16:44:27 +000057 JNIEnv* env, jclass pvhObject, jobject target, jlong methodID, jfloat arg)
Chet Haase6e0ecb42010-11-03 19:41:18 -070058{
Ashok Bhat0141e882014-01-17 16:44:27 +000059 env->CallVoidMethod(target, reinterpret_cast<jmethodID>(methodID), arg);
Chet Haase6e0ecb42010-11-03 19:41:18 -070060}
61
62static JNINativeMethod gMethods[] = {
Ashok Bhat0141e882014-01-17 16:44:27 +000063 { "nGetIntMethod", "(Ljava/lang/Class;Ljava/lang/String;)J",
Chet Haase6e0ecb42010-11-03 19:41:18 -070064 (void*)android_animation_PropertyValuesHolder_getIntMethod },
Ashok Bhat0141e882014-01-17 16:44:27 +000065 { "nGetFloatMethod", "(Ljava/lang/Class;Ljava/lang/String;)J",
Chet Haase6e0ecb42010-11-03 19:41:18 -070066 (void*)android_animation_PropertyValuesHolder_getFloatMethod },
Ashok Bhat0141e882014-01-17 16:44:27 +000067 { "nCallIntMethod", "(Ljava/lang/Object;JI)V",
Chet Haase6e0ecb42010-11-03 19:41:18 -070068 (void*)android_animation_PropertyValuesHolder_callIntMethod },
Ashok Bhat0141e882014-01-17 16:44:27 +000069 { "nCallFloatMethod", "(Ljava/lang/Object;JF)V",
Chet Haase6e0ecb42010-11-03 19:41:18 -070070 (void*)android_animation_PropertyValuesHolder_callFloatMethod }
71};
72
73int register_android_animation_PropertyValuesHolder(JNIEnv* env)
74{
75 return AndroidRuntime::registerNativeMethods(env,
76 kClassPathName, gMethods, NELEM(gMethods));
77}
78
79};