diff options
| author | 2014-01-17 16:44:27 +0000 | |
|---|---|---|
| committer | 2014-01-29 11:07:06 +0000 | |
| commit | fbb35fb39eb74c6fa7ba6804faeaccb80483be14 (patch) | |
| tree | 4722c5a5c438596ff70ce52c840a9af6d620c36f | |
| parent | 2b033dce9f252ae30ac88c9ba1569d18afaaf2cf (diff) | |
AArch64: Use of long for pointers in PropertyValuesHolder
Long is used in PropertyValuesHolder class to store native pointers
as they can be 64-bit. Note that jmethodID, a pointer to structures,
is also carried in long rather than int to support 64-bit system.
Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>
Signed-off-by: Ashok Bhat <ashok.bhat@arm.com>
(cherry picked from commit 0141e884344a5c267239079d615e1c9d9898a222)
Change-Id: I80408a7227427732db0d8b4c960bcb849b7c8060
3 files changed, 84 insertions, 84 deletions
diff --git a/core/java/android/animation/PropertyValuesHolder.java b/core/java/android/animation/PropertyValuesHolder.java index 1b028e0aab05..8fce80aa758b 100644 --- a/core/java/android/animation/PropertyValuesHolder.java +++ b/core/java/android/animation/PropertyValuesHolder.java @@ -1046,9 +1046,9 @@ public class PropertyValuesHolder implements Cloneable { static class IntPropertyValuesHolder extends PropertyValuesHolder { // Cache JNI functions to avoid looking them up twice - private static final HashMap<Class, HashMap<String, Integer>> sJNISetterPropertyMap = - new HashMap<Class, HashMap<String, Integer>>(); - int mJniSetter; + private static final HashMap<Class, HashMap<String, Long>> sJNISetterPropertyMap = + new HashMap<Class, HashMap<String, Long>>(); + long mJniSetter; private IntProperty mIntProperty; IntKeyframeSet mIntKeyframeSet; @@ -1148,11 +1148,11 @@ public class PropertyValuesHolder implements Cloneable { // Check new static hashmap<propName, int> for setter method try { mPropertyMapLock.writeLock().lock(); - HashMap<String, Integer> propertyMap = sJNISetterPropertyMap.get(targetClass); + HashMap<String, Long> propertyMap = sJNISetterPropertyMap.get(targetClass); if (propertyMap != null) { - Integer mJniSetterInteger = propertyMap.get(mPropertyName); - if (mJniSetterInteger != null) { - mJniSetter = mJniSetterInteger; + Long jniSetter = propertyMap.get(mPropertyName); + if (jniSetter != null) { + mJniSetter = jniSetter; } } if (mJniSetter == 0) { @@ -1160,7 +1160,7 @@ public class PropertyValuesHolder implements Cloneable { mJniSetter = nGetIntMethod(targetClass, methodName); if (mJniSetter != 0) { if (propertyMap == null) { - propertyMap = new HashMap<String, Integer>(); + propertyMap = new HashMap<String, Long>(); sJNISetterPropertyMap.put(targetClass, propertyMap); } propertyMap.put(mPropertyName, mJniSetter); @@ -1183,9 +1183,9 @@ public class PropertyValuesHolder implements Cloneable { static class FloatPropertyValuesHolder extends PropertyValuesHolder { // Cache JNI functions to avoid looking them up twice - private static final HashMap<Class, HashMap<String, Integer>> sJNISetterPropertyMap = - new HashMap<Class, HashMap<String, Integer>>(); - int mJniSetter; + private static final HashMap<Class, HashMap<String, Long>> sJNISetterPropertyMap = + new HashMap<Class, HashMap<String, Long>>(); + long mJniSetter; private FloatProperty mFloatProperty; FloatKeyframeSet mFloatKeyframeSet; @@ -1285,11 +1285,11 @@ public class PropertyValuesHolder implements Cloneable { // Check new static hashmap<propName, int> for setter method try { mPropertyMapLock.writeLock().lock(); - HashMap<String, Integer> propertyMap = sJNISetterPropertyMap.get(targetClass); + HashMap<String, Long> propertyMap = sJNISetterPropertyMap.get(targetClass); if (propertyMap != null) { - Integer mJniSetterInteger = propertyMap.get(mPropertyName); - if (mJniSetterInteger != null) { - mJniSetter = mJniSetterInteger; + Long jniSetter = propertyMap.get(mPropertyName); + if (jniSetter != null) { + mJniSetter = jniSetter; } } if (mJniSetter == 0) { @@ -1297,7 +1297,7 @@ public class PropertyValuesHolder implements Cloneable { mJniSetter = nGetFloatMethod(targetClass, methodName); if (mJniSetter != 0) { if (propertyMap == null) { - propertyMap = new HashMap<String, Integer>(); + propertyMap = new HashMap<String, Long>(); sJNISetterPropertyMap.put(targetClass, propertyMap); } propertyMap.put(mPropertyName, mJniSetter); @@ -1319,9 +1319,9 @@ public class PropertyValuesHolder implements Cloneable { } static class MultiFloatValuesHolder extends PropertyValuesHolder { - private int mJniSetter; - private static final HashMap<Class, HashMap<String, Integer>> sJNISetterPropertyMap = - new HashMap<Class, HashMap<String, Integer>>(); + private long mJniSetter; + private static final HashMap<Class, HashMap<String, Long>> sJNISetterPropertyMap = + new HashMap<Class, HashMap<String, Long>>(); public MultiFloatValuesHolder(String propertyName, TypeConverter converter, TypeEvaluator evaluator, Object... values) { @@ -1389,11 +1389,11 @@ public class PropertyValuesHolder implements Cloneable { } try { mPropertyMapLock.writeLock().lock(); - HashMap<String, Integer> propertyMap = sJNISetterPropertyMap.get(targetClass); + HashMap<String, Long> propertyMap = sJNISetterPropertyMap.get(targetClass); if (propertyMap != null) { - Integer jniSetterInteger = propertyMap.get(mPropertyName); - if (jniSetterInteger != null) { - mJniSetter = jniSetterInteger; + Long jniSetterLong = propertyMap.get(mPropertyName); + if (jniSetterLong != null) { + mJniSetter = jniSetterLong; } } if (mJniSetter == 0) { @@ -1409,7 +1409,7 @@ public class PropertyValuesHolder implements Cloneable { } if (mJniSetter != 0) { if (propertyMap == null) { - propertyMap = new HashMap<String, Integer>(); + propertyMap = new HashMap<String, Long>(); sJNISetterPropertyMap.put(targetClass, propertyMap); } propertyMap.put(mPropertyName, mJniSetter); @@ -1422,9 +1422,9 @@ public class PropertyValuesHolder implements Cloneable { } static class MultiIntValuesHolder extends PropertyValuesHolder { - private int mJniSetter; - private static final HashMap<Class, HashMap<String, Integer>> sJNISetterPropertyMap = - new HashMap<Class, HashMap<String, Integer>>(); + private long mJniSetter; + private static final HashMap<Class, HashMap<String, Long>> sJNISetterPropertyMap = + new HashMap<Class, HashMap<String, Long>>(); public MultiIntValuesHolder(String propertyName, TypeConverter converter, TypeEvaluator evaluator, Object... values) { @@ -1492,11 +1492,11 @@ public class PropertyValuesHolder implements Cloneable { } try { mPropertyMapLock.writeLock().lock(); - HashMap<String, Integer> propertyMap = sJNISetterPropertyMap.get(targetClass); + HashMap<String, Long> propertyMap = sJNISetterPropertyMap.get(targetClass); if (propertyMap != null) { - Integer jniSetterInteger = propertyMap.get(mPropertyName); - if (jniSetterInteger != null) { - mJniSetter = jniSetterInteger; + Long jniSetterLong = propertyMap.get(mPropertyName); + if (jniSetterLong != null) { + mJniSetter = jniSetterLong; } } if (mJniSetter == 0) { @@ -1512,7 +1512,7 @@ public class PropertyValuesHolder implements Cloneable { } if (mJniSetter != 0) { if (propertyMap == null) { - propertyMap = new HashMap<String, Integer>(); + propertyMap = new HashMap<String, Long>(); sJNISetterPropertyMap.put(targetClass, propertyMap); } propertyMap.put(mPropertyName, mJniSetter); @@ -1631,21 +1631,21 @@ public class PropertyValuesHolder implements Cloneable { } }; - native static private int nGetIntMethod(Class targetClass, String methodName); - native static private int nGetFloatMethod(Class targetClass, String methodName); - native static private int nGetMultipleIntMethod(Class targetClass, String methodName, + native static private long nGetIntMethod(Class targetClass, String methodName); + native static private long nGetFloatMethod(Class targetClass, String methodName); + native static private long nGetMultipleIntMethod(Class targetClass, String methodName, int numParams); - native static private int nGetMultipleFloatMethod(Class targetClass, String methodName, + native static private long nGetMultipleFloatMethod(Class targetClass, String methodName, int numParams); - native static private void nCallIntMethod(Object target, int methodID, int arg); - native static private void nCallFloatMethod(Object target, int methodID, float arg); - native static private void nCallTwoIntMethod(Object target, int methodID, int arg1, int arg2); - native static private void nCallFourIntMethod(Object target, int methodID, int arg1, int arg2, + native static private void nCallIntMethod(Object target, long methodID, int arg); + native static private void nCallFloatMethod(Object target, long methodID, float arg); + native static private void nCallTwoIntMethod(Object target, long methodID, int arg1, int arg2); + native static private void nCallFourIntMethod(Object target, long methodID, int arg1, int arg2, int arg3, int arg4); - native static private void nCallMultipleIntMethod(Object target, int methodID, int[] args); - native static private void nCallTwoFloatMethod(Object target, int methodID, float arg1, + native static private void nCallMultipleIntMethod(Object target, long methodID, int[] args); + native static private void nCallTwoFloatMethod(Object target, long methodID, float arg1, float arg2); - native static private void nCallFourFloatMethod(Object target, int methodID, float arg1, + native static private void nCallFourFloatMethod(Object target, long methodID, float arg1, float arg2, float arg3, float arg4); - native static private void nCallMultipleFloatMethod(Object target, int methodID, float[] args); + native static private void nCallMultipleFloatMethod(Object target, long methodID, float[] args); } diff --git a/core/jni/android_animation_PropertyValuesHolder.cpp b/core/jni/android_animation_PropertyValuesHolder.cpp index 73347ea5226f..ef1c4eda1d1e 100644 --- a/core/jni/android_animation_PropertyValuesHolder.cpp +++ b/core/jni/android_animation_PropertyValuesHolder.cpp @@ -29,25 +29,25 @@ namespace android { const char* const kClassPathName = "android/animation/PropertyValuesHolder"; -static jmethodID android_animation_PropertyValuesHolder_getIntMethod( +static jlong android_animation_PropertyValuesHolder_getIntMethod( JNIEnv* env, jclass pvhClass, jclass targetClass, jstring methodName) { const char *nativeString = env->GetStringUTFChars(methodName, 0); jmethodID mid = env->GetMethodID(targetClass, nativeString, "(I)V"); env->ReleaseStringUTFChars(methodName, nativeString); - return mid; + return reinterpret_cast<jlong>(mid); } -static jmethodID android_animation_PropertyValuesHolder_getFloatMethod( +static jlong android_animation_PropertyValuesHolder_getFloatMethod( JNIEnv* env, jclass pvhClass, jclass targetClass, jstring methodName) { const char *nativeString = env->GetStringUTFChars(methodName, 0); jmethodID mid = env->GetMethodID(targetClass, nativeString, "(F)V"); env->ReleaseStringUTFChars(methodName, nativeString); - return mid; + return reinterpret_cast<jlong>(mid); } -static jmethodID getMultiparameterMethod(JNIEnv* env, jclass targetClass, jstring methodName, +static jlong getMultiparameterMethod(JNIEnv* env, jclass targetClass, jstring methodName, jint parameterCount, char parameterType) { const char *nativeString = env->GetStringUTFChars(methodName, 0); @@ -58,48 +58,48 @@ static jmethodID getMultiparameterMethod(JNIEnv* env, jclass targetClass, jstrin jmethodID mid = env->GetMethodID(targetClass, nativeString, signature); delete[] signature; env->ReleaseStringUTFChars(methodName, nativeString); - return mid; + return reinterpret_cast<jlong>(mid); } -static jmethodID android_animation_PropertyValuesHolder_getMultipleFloatMethod( +static jlong android_animation_PropertyValuesHolder_getMultipleFloatMethod( JNIEnv* env, jclass pvhClass, jclass targetClass, jstring methodName, jint parameterCount) { return getMultiparameterMethod(env, targetClass, methodName, parameterCount, 'F'); } -static jmethodID android_animation_PropertyValuesHolder_getMultipleIntMethod( +static jlong android_animation_PropertyValuesHolder_getMultipleIntMethod( JNIEnv* env, jclass pvhClass, jclass targetClass, jstring methodName, jint parameterCount) { return getMultiparameterMethod(env, targetClass, methodName, parameterCount, 'I'); } static void android_animation_PropertyValuesHolder_callIntMethod( - JNIEnv* env, jclass pvhObject, jobject target, jmethodID methodID, int arg) + JNIEnv* env, jclass pvhObject, jobject target, jlong methodID, jint arg) { - env->CallVoidMethod(target, methodID, arg); + env->CallVoidMethod(target, reinterpret_cast<jmethodID>(methodID), arg); } static void android_animation_PropertyValuesHolder_callFloatMethod( - JNIEnv* env, jclass pvhObject, jobject target, jmethodID methodID, float arg) + JNIEnv* env, jclass pvhObject, jobject target, jlong methodID, jfloat arg) { - env->CallVoidMethod(target, methodID, arg); + env->CallVoidMethod(target, reinterpret_cast<jmethodID>(methodID), arg); } static void android_animation_PropertyValuesHolder_callTwoFloatMethod( - JNIEnv* env, jclass pvhObject, jobject target, jmethodID methodID, float arg1, float arg2) + JNIEnv* env, jclass pvhObject, jobject target, jlong methodID, float arg1, float arg2) { - env->CallVoidMethod(target, methodID, arg1, arg2); + env->CallVoidMethod(target, reinterpret_cast<jmethodID>(methodID), arg1, arg2); } static void android_animation_PropertyValuesHolder_callFourFloatMethod( - JNIEnv* env, jclass pvhObject, jobject target, jmethodID methodID, float arg1, float arg2, + JNIEnv* env, jclass pvhObject, jobject target, jlong methodID, float arg1, float arg2, float arg3, float arg4) { - env->CallVoidMethod(target, methodID, arg1, arg2, arg3, arg4); + env->CallVoidMethod(target, reinterpret_cast<jmethodID>(methodID), arg1, arg2, arg3, arg4); } static void android_animation_PropertyValuesHolder_callMultipleFloatMethod( - JNIEnv* env, jclass pvhObject, jobject target, jmethodID methodID, jfloatArray arg) + JNIEnv* env, jclass pvhObject, jobject target, jlong methodID, jfloatArray arg) { jsize parameterCount = env->GetArrayLength(arg); jfloat *floatValues = env->GetFloatArrayElements(arg, NULL); @@ -107,26 +107,26 @@ static void android_animation_PropertyValuesHolder_callMultipleFloatMethod( for (int i = 0; i < parameterCount; i++) { values[i].f = floatValues[i]; } - env->CallVoidMethodA(target, methodID, values); + env->CallVoidMethodA(target, reinterpret_cast<jmethodID>(methodID), values); delete[] values; env->ReleaseFloatArrayElements(arg, floatValues, JNI_ABORT); } static void android_animation_PropertyValuesHolder_callTwoIntMethod( - JNIEnv* env, jclass pvhObject, jobject target, jmethodID methodID, int arg1, int arg2) + JNIEnv* env, jclass pvhObject, jobject target, jlong methodID, int arg1, int arg2) { - env->CallVoidMethod(target, methodID, arg1, arg2); + env->CallVoidMethod(target, reinterpret_cast<jmethodID>(methodID), arg1, arg2); } static void android_animation_PropertyValuesHolder_callFourIntMethod( - JNIEnv* env, jclass pvhObject, jobject target, jmethodID methodID, int arg1, int arg2, + JNIEnv* env, jclass pvhObject, jobject target, jlong methodID, int arg1, int arg2, int arg3, int arg4) { - env->CallVoidMethod(target, methodID, arg1, arg2, arg3, arg4); + env->CallVoidMethod(target, reinterpret_cast<jmethodID>(methodID), arg1, arg2, arg3, arg4); } static void android_animation_PropertyValuesHolder_callMultipleIntMethod( - JNIEnv* env, jclass pvhObject, jobject target, jmethodID methodID, jintArray arg) + JNIEnv* env, jclass pvhObject, jobject target, jlong methodID, jintArray arg) { jsize parameterCount = env->GetArrayLength(arg); jint *intValues = env->GetIntArrayElements(arg, NULL); @@ -134,35 +134,35 @@ static void android_animation_PropertyValuesHolder_callMultipleIntMethod( for (int i = 0; i < parameterCount; i++) { values[i].i = intValues[i]; } - env->CallVoidMethodA(target, methodID, values); + env->CallVoidMethodA(target, reinterpret_cast<jmethodID>(methodID), values); delete[] values; env->ReleaseIntArrayElements(arg, intValues, JNI_ABORT); } static JNINativeMethod gMethods[] = { - { "nGetIntMethod", "(Ljava/lang/Class;Ljava/lang/String;)I", + { "nGetIntMethod", "(Ljava/lang/Class;Ljava/lang/String;)J", (void*)android_animation_PropertyValuesHolder_getIntMethod }, - { "nGetFloatMethod", "(Ljava/lang/Class;Ljava/lang/String;)I", + { "nGetFloatMethod", "(Ljava/lang/Class;Ljava/lang/String;)J", (void*)android_animation_PropertyValuesHolder_getFloatMethod }, - { "nGetMultipleFloatMethod", "(Ljava/lang/Class;Ljava/lang/String;I)I", + { "nGetMultipleFloatMethod", "(Ljava/lang/Class;Ljava/lang/String;I)J", (void*)android_animation_PropertyValuesHolder_getMultipleFloatMethod }, - { "nGetMultipleIntMethod", "(Ljava/lang/Class;Ljava/lang/String;I)I", + { "nGetMultipleIntMethod", "(Ljava/lang/Class;Ljava/lang/String;I)J", (void*)android_animation_PropertyValuesHolder_getMultipleIntMethod }, - { "nCallIntMethod", "(Ljava/lang/Object;II)V", + { "nCallIntMethod", "(Ljava/lang/Object;JI)V", (void*)android_animation_PropertyValuesHolder_callIntMethod }, - { "nCallFloatMethod", "(Ljava/lang/Object;IF)V", + { "nCallFloatMethod", "(Ljava/lang/Object;JF)V", (void*)android_animation_PropertyValuesHolder_callFloatMethod }, - { "nCallTwoFloatMethod", "(Ljava/lang/Object;IFF)V", + { "nCallTwoFloatMethod", "(Ljava/lang/Object;JFF)V", (void*)android_animation_PropertyValuesHolder_callTwoFloatMethod }, - { "nCallFourFloatMethod", "(Ljava/lang/Object;IFFFF)V", + { "nCallFourFloatMethod", "(Ljava/lang/Object;JFFFF)V", (void*)android_animation_PropertyValuesHolder_callFourFloatMethod }, - { "nCallMultipleFloatMethod", "(Ljava/lang/Object;I[F)V", + { "nCallMultipleFloatMethod", "(Ljava/lang/Object;J[F)V", (void*)android_animation_PropertyValuesHolder_callMultipleFloatMethod }, - { "nCallTwoIntMethod", "(Ljava/lang/Object;III)V", + { "nCallTwoIntMethod", "(Ljava/lang/Object;JII)V", (void*)android_animation_PropertyValuesHolder_callTwoIntMethod }, - { "nCallFourIntMethod", "(Ljava/lang/Object;IIIII)V", + { "nCallFourIntMethod", "(Ljava/lang/Object;JIIII)V", (void*)android_animation_PropertyValuesHolder_callFourIntMethod }, - { "nCallMultipleIntMethod", "(Ljava/lang/Object;I[I)V", + { "nCallMultipleIntMethod", "(Ljava/lang/Object;J[I)V", (void*)android_animation_PropertyValuesHolder_callMultipleIntMethod }, }; diff --git a/tools/layoutlib/bridge/src/android/animation/PropertyValuesHolder_Delegate.java b/tools/layoutlib/bridge/src/android/animation/PropertyValuesHolder_Delegate.java index 7b444aadb303..224eac601ae1 100644 --- a/tools/layoutlib/bridge/src/android/animation/PropertyValuesHolder_Delegate.java +++ b/tools/layoutlib/bridge/src/android/animation/PropertyValuesHolder_Delegate.java @@ -36,24 +36,24 @@ import com.android.tools.layoutlib.annotations.LayoutlibDelegate; /*package*/ class PropertyValuesHolder_Delegate { @LayoutlibDelegate - /*package*/ static int nGetIntMethod(Class<?> targetClass, String methodName) { + /*package*/ static long nGetIntMethod(Class<?> targetClass, String methodName) { // return 0 to force PropertyValuesHolder to use Java reflection. return 0; } @LayoutlibDelegate - /*package*/ static int nGetFloatMethod(Class<?> targetClass, String methodName) { + /*package*/ static long nGetFloatMethod(Class<?> targetClass, String methodName) { // return 0 to force PropertyValuesHolder to use Java reflection. return 0; } @LayoutlibDelegate - /*package*/ static void nCallIntMethod(Object target, int methodID, int arg) { + /*package*/ static void nCallIntMethod(Object target, long methodID, int arg) { // do nothing } @LayoutlibDelegate - /*package*/ static void nCallFloatMethod(Object target, int methodID, float arg) { + /*package*/ static void nCallFloatMethod(Object target, long methodID, float arg) { // do nothing } } |