CallStaticObjectMethod() public static method

public static CallStaticObjectMethod ( IntPtr clazz, IntPtr methodID, jvalue args ) : IntPtr
clazz System.IntPtr
methodID System.IntPtr
args jvalue
return System.IntPtr
コード例 #1
0
 public static IntPtr NewProxyInstance(int delegateHandle, IntPtr interfaze)
 {
     jvalue[] array = new jvalue[2];
     array[0].i = delegateHandle;
     array[1].l = interfaze;
     return(AndroidJNISafe.CallStaticObjectMethod(AndroidReflection.s_ReflectionHelperClass, AndroidReflection.s_ReflectionHelperNewProxyInstance, array));
 }
コード例 #2
0
 public static IntPtr GetConstructorMember(IntPtr jclass, string signature)
 {
     jvalue[] args = new jvalue[2];
     try
     {
         args[0].l = jclass;
         args[1].l = AndroidJNISafe.NewStringUTF(signature);
         return(AndroidJNISafe.CallStaticObjectMethod(AndroidReflection.s_ReflectionHelperClass, AndroidReflection.s_ReflectionHelperGetConstructorID, args));
     }
     finally
     {
         AndroidJNISafe.DeleteLocalRef(args[1].l);
     }
 }
コード例 #3
0
 public static IntPtr GetFieldMember(IntPtr jclass, string fieldName, string signature, bool isStatic)
 {
     jvalue[] args = new jvalue[4];
     try
     {
         args[0].l = jclass;
         args[1].l = AndroidJNISafe.NewStringUTF(fieldName);
         args[2].l = AndroidJNISafe.NewStringUTF(signature);
         args[3].z = isStatic;
         return(AndroidJNISafe.CallStaticObjectMethod(AndroidReflection.s_ReflectionHelperClass, AndroidReflection.s_ReflectionHelperGetFieldID, args));
     }
     finally
     {
         AndroidJNISafe.DeleteLocalRef(args[1].l);
         AndroidJNISafe.DeleteLocalRef(args[2].l);
     }
 }
コード例 #4
0
 public static IntPtr GetMethodMember(IntPtr jclass, string methodName, string signature, bool isStatic)
 {
     jvalue[] array = new jvalue[4];
     try
     {
         array[0].l = jclass;
         array[1].l = AndroidJNISafe.NewStringUTF(methodName);
         array[2].l = AndroidJNISafe.NewStringUTF(signature);
         array[3].z = isStatic;
         return(AndroidJNISafe.CallStaticObjectMethod(s_ReflectionHelperClass, s_ReflectionHelperGetMethodID, array));
     }
     finally
     {
         AndroidJNISafe.DeleteLocalRef(array[1].l);
         AndroidJNISafe.DeleteLocalRef(array[2].l);
     }
 }
コード例 #5
0
        protected ReturnType _CallStatic <ReturnType>(string methodName, params object[] args)
        {
            ReturnType local;

            if (args == null)
            {
                args = new object[1];
            }
            IntPtr methodID = AndroidJNIHelper.GetMethodID <ReturnType>(this.m_jclass, methodName, args, true);

            jvalue[] jvalueArray = AndroidJNIHelper.CreateJNIArgArray(args);
            try
            {
                if (AndroidReflection.IsPrimitive(typeof(ReturnType)))
                {
                    if (typeof(ReturnType) == typeof(int))
                    {
                        return((ReturnType)AndroidJNISafe.CallStaticIntMethod(this.m_jclass, methodID, jvalueArray));
                    }
                    if (typeof(ReturnType) == typeof(bool))
                    {
                        return((ReturnType)AndroidJNISafe.CallStaticBooleanMethod(this.m_jclass, methodID, jvalueArray));
                    }
                    if (typeof(ReturnType) == typeof(byte))
                    {
                        return((ReturnType)AndroidJNISafe.CallStaticByteMethod(this.m_jclass, methodID, jvalueArray));
                    }
                    if (typeof(ReturnType) == typeof(short))
                    {
                        return((ReturnType)AndroidJNISafe.CallStaticShortMethod(this.m_jclass, methodID, jvalueArray));
                    }
                    if (typeof(ReturnType) == typeof(long))
                    {
                        return((ReturnType)AndroidJNISafe.CallStaticLongMethod(this.m_jclass, methodID, jvalueArray));
                    }
                    if (typeof(ReturnType) == typeof(float))
                    {
                        return((ReturnType)AndroidJNISafe.CallStaticFloatMethod(this.m_jclass, methodID, jvalueArray));
                    }
                    if (typeof(ReturnType) == typeof(double))
                    {
                        return((ReturnType)AndroidJNISafe.CallStaticDoubleMethod(this.m_jclass, methodID, jvalueArray));
                    }
                    if (typeof(ReturnType) == typeof(char))
                    {
                        return((ReturnType)AndroidJNISafe.CallStaticCharMethod(this.m_jclass, methodID, jvalueArray));
                    }
                }
                else
                {
                    if (typeof(ReturnType) == typeof(string))
                    {
                        return((ReturnType)AndroidJNISafe.CallStaticStringMethod(this.m_jclass, methodID, jvalueArray));
                    }
                    if (typeof(ReturnType) == typeof(AndroidJavaClass))
                    {
                        return((ReturnType)AndroidJavaClassDeleteLocalRef(AndroidJNISafe.CallStaticObjectMethod(this.m_jclass, methodID, jvalueArray)));
                    }
                    if (typeof(ReturnType) == typeof(AndroidJavaObject))
                    {
                        return((ReturnType)AndroidJavaObjectDeleteLocalRef(AndroidJNISafe.CallStaticObjectMethod(this.m_jclass, methodID, jvalueArray)));
                    }
                    if (!AndroidReflection.IsAssignableFrom(typeof(Array), typeof(ReturnType)))
                    {
                        throw new Exception("JNI: Unknown return type '" + typeof(ReturnType) + "'");
                    }
                    return(AndroidJNIHelper.ConvertFromJNIArray <ReturnType>(AndroidJNISafe.CallStaticObjectMethod(this.m_jclass, methodID, jvalueArray)));
                }
                local = default(ReturnType);
            }
            finally
            {
                AndroidJNIHelper.DeleteJNIArgArray(args, jvalueArray);
            }
            return(local);
        }
コード例 #6
0
        protected ReturnType _CallStatic <ReturnType>(string methodName, params object[] args)
        {
            bool flag = args == null;

            if (flag)
            {
                args = new object[1];
            }
            IntPtr methodID = AndroidJNIHelper.GetMethodID <ReturnType>(this.m_jclass, methodName, args, true);

            jvalue[]   array = AndroidJNIHelper.CreateJNIArgArray(args);
            ReturnType result;

            try
            {
                bool flag2 = AndroidReflection.IsPrimitive(typeof(ReturnType));
                if (flag2)
                {
                    bool flag3 = typeof(ReturnType) == typeof(int);
                    if (flag3)
                    {
                        result = (ReturnType)((object)AndroidJNISafe.CallStaticIntMethod(this.m_jclass, methodID, array));
                    }
                    else
                    {
                        bool flag4 = typeof(ReturnType) == typeof(bool);
                        if (flag4)
                        {
                            result = (ReturnType)((object)AndroidJNISafe.CallStaticBooleanMethod(this.m_jclass, methodID, array));
                        }
                        else
                        {
                            bool flag5 = typeof(ReturnType) == typeof(byte);
                            if (flag5)
                            {
                                Debug.LogWarning("Return type <Byte> for Java method call is obsolete, use return type <SByte> instead");
                                result = (ReturnType)((object)((byte)AndroidJNISafe.CallStaticSByteMethod(this.m_jclass, methodID, array)));
                            }
                            else
                            {
                                bool flag6 = typeof(ReturnType) == typeof(sbyte);
                                if (flag6)
                                {
                                    result = (ReturnType)((object)AndroidJNISafe.CallStaticSByteMethod(this.m_jclass, methodID, array));
                                }
                                else
                                {
                                    bool flag7 = typeof(ReturnType) == typeof(short);
                                    if (flag7)
                                    {
                                        result = (ReturnType)((object)AndroidJNISafe.CallStaticShortMethod(this.m_jclass, methodID, array));
                                    }
                                    else
                                    {
                                        bool flag8 = typeof(ReturnType) == typeof(long);
                                        if (flag8)
                                        {
                                            result = (ReturnType)((object)AndroidJNISafe.CallStaticLongMethod(this.m_jclass, methodID, array));
                                        }
                                        else
                                        {
                                            bool flag9 = typeof(ReturnType) == typeof(float);
                                            if (flag9)
                                            {
                                                result = (ReturnType)((object)AndroidJNISafe.CallStaticFloatMethod(this.m_jclass, methodID, array));
                                            }
                                            else
                                            {
                                                bool flag10 = typeof(ReturnType) == typeof(double);
                                                if (flag10)
                                                {
                                                    result = (ReturnType)((object)AndroidJNISafe.CallStaticDoubleMethod(this.m_jclass, methodID, array));
                                                }
                                                else
                                                {
                                                    bool flag11 = typeof(ReturnType) == typeof(char);
                                                    if (flag11)
                                                    {
                                                        result = (ReturnType)((object)AndroidJNISafe.CallStaticCharMethod(this.m_jclass, methodID, array));
                                                    }
                                                    else
                                                    {
                                                        result = default(ReturnType);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    bool flag12 = typeof(ReturnType) == typeof(string);
                    if (flag12)
                    {
                        result = (ReturnType)((object)AndroidJNISafe.CallStaticStringMethod(this.m_jclass, methodID, array));
                    }
                    else
                    {
                        bool flag13 = typeof(ReturnType) == typeof(AndroidJavaClass);
                        if (flag13)
                        {
                            IntPtr intPtr = AndroidJNISafe.CallStaticObjectMethod(this.m_jclass, methodID, array);
                            result = ((intPtr == IntPtr.Zero) ? default(ReturnType) : ((ReturnType)((object)AndroidJavaObject.AndroidJavaClassDeleteLocalRef(intPtr))));
                        }
                        else
                        {
                            bool flag14 = typeof(ReturnType) == typeof(AndroidJavaObject);
                            if (flag14)
                            {
                                IntPtr intPtr2 = AndroidJNISafe.CallStaticObjectMethod(this.m_jclass, methodID, array);
                                result = ((intPtr2 == IntPtr.Zero) ? default(ReturnType) : ((ReturnType)((object)AndroidJavaObject.AndroidJavaObjectDeleteLocalRef(intPtr2))));
                            }
                            else
                            {
                                bool flag15 = AndroidReflection.IsAssignableFrom(typeof(Array), typeof(ReturnType));
                                if (!flag15)
                                {
                                    string arg_408_0 = "JNI: Unknown return type '";
                                    Type   expr_3F7  = typeof(ReturnType);
                                    throw new Exception(arg_408_0 + ((expr_3F7 != null) ? expr_3F7.ToString() : null) + "'");
                                }
                                IntPtr intPtr3 = AndroidJNISafe.CallStaticObjectMethod(this.m_jclass, methodID, array);
                                result = ((intPtr3 == IntPtr.Zero) ? default(ReturnType) : ((ReturnType)((object)AndroidJNIHelper.ConvertFromJNIArray <ReturnType>(intPtr3))));
                            }
                        }
                    }
                }
            }
            finally
            {
                AndroidJNIHelper.DeleteJNIArgArray(args, array);
            }
            return(result);
        }