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
26namespace android {
27
28// ----------------------------------------------------------------------------
29
30const char* const kClassPathName = "android/animation/PropertyValuesHolder";
31
32static jmethodID android_animation_PropertyValuesHolder_getIntMethod(
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);
38    return mid;
39}
40
41static jmethodID android_animation_PropertyValuesHolder_getFloatMethod(
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);
47    return mid;
48}
49
50static void android_animation_PropertyValuesHolder_callIntMethod(
51        JNIEnv* env, jclass pvhObject, jobject target, jmethodID methodID, int arg)
52{
53    env->CallVoidMethod(target, methodID, arg);
54}
55
56static void android_animation_PropertyValuesHolder_callFloatMethod(
57        JNIEnv* env, jclass pvhObject, jobject target, jmethodID methodID, float arg)
58{
59    env->CallVoidMethod(target, methodID, arg);
60}
61
62static JNINativeMethod gMethods[] = {
63    {   "nGetIntMethod", "(Ljava/lang/Class;Ljava/lang/String;)I",
64            (void*)android_animation_PropertyValuesHolder_getIntMethod },
65    {   "nGetFloatMethod", "(Ljava/lang/Class;Ljava/lang/String;)I",
66            (void*)android_animation_PropertyValuesHolder_getFloatMethod },
67    {   "nCallIntMethod", "(Ljava/lang/Object;II)V",
68            (void*)android_animation_PropertyValuesHolder_callIntMethod },
69    {   "nCallFloatMethod", "(Ljava/lang/Object;IF)V",
70            (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};
80