CallCharMethod() 공개 정적인 메소드

public static CallCharMethod ( IntPtr obj, IntPtr methodID, jvalue args ) : char
obj System.IntPtr
methodID System.IntPtr
args jvalue
리턴 char
예제 #1
0
        protected ReturnType _Call <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, false);

            jvalue[] jvalueArray = AndroidJNIHelper.CreateJNIArgArray(args);
            try
            {
                if (AndroidReflection.IsPrimitive(typeof(ReturnType)))
                {
                    if (typeof(ReturnType) == typeof(int))
                    {
                        return((ReturnType)AndroidJNISafe.CallIntMethod(this.m_jobject, methodID, jvalueArray));
                    }
                    if (typeof(ReturnType) == typeof(bool))
                    {
                        return((ReturnType)AndroidJNISafe.CallBooleanMethod(this.m_jobject, methodID, jvalueArray));
                    }
                    if (typeof(ReturnType) == typeof(byte))
                    {
                        return((ReturnType)AndroidJNISafe.CallByteMethod(this.m_jobject, methodID, jvalueArray));
                    }
                    if (typeof(ReturnType) == typeof(short))
                    {
                        return((ReturnType)AndroidJNISafe.CallShortMethod(this.m_jobject, methodID, jvalueArray));
                    }
                    if (typeof(ReturnType) == typeof(long))
                    {
                        return((ReturnType)AndroidJNISafe.CallLongMethod(this.m_jobject, methodID, jvalueArray));
                    }
                    if (typeof(ReturnType) == typeof(float))
                    {
                        return((ReturnType)AndroidJNISafe.CallFloatMethod(this.m_jobject, methodID, jvalueArray));
                    }
                    if (typeof(ReturnType) == typeof(double))
                    {
                        return((ReturnType)AndroidJNISafe.CallDoubleMethod(this.m_jobject, methodID, jvalueArray));
                    }
                    if (typeof(ReturnType) == typeof(char))
                    {
                        return((ReturnType)AndroidJNISafe.CallCharMethod(this.m_jobject, methodID, jvalueArray));
                    }
                }
                else
                {
                    if (typeof(ReturnType) == typeof(string))
                    {
                        return((ReturnType)AndroidJNISafe.CallStringMethod(this.m_jobject, methodID, jvalueArray));
                    }
                    if (typeof(ReturnType) == typeof(AndroidJavaClass))
                    {
                        return((ReturnType)AndroidJavaClassDeleteLocalRef(AndroidJNISafe.CallObjectMethod(this.m_jobject, methodID, jvalueArray)));
                    }
                    if (typeof(ReturnType) == typeof(AndroidJavaObject))
                    {
                        return((ReturnType)AndroidJavaObjectDeleteLocalRef(AndroidJNISafe.CallObjectMethod(this.m_jobject, methodID, jvalueArray)));
                    }
                    if (!AndroidReflection.IsAssignableFrom(typeof(Array), typeof(ReturnType)))
                    {
                        throw new Exception("JNI: Unknown return type '" + typeof(ReturnType) + "'");
                    }
                    return(AndroidJNIHelper.ConvertFromJNIArray <ReturnType>(AndroidJNISafe.CallObjectMethod(this.m_jobject, methodID, jvalueArray)));
                }
                local = default(ReturnType);
            }
            finally
            {
                AndroidJNIHelper.DeleteJNIArgArray(args, jvalueArray);
            }
            return(local);
        }
예제 #2
0
        protected ReturnType _Call <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, false);

            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.CallIntMethod(this.m_jobject, methodID, array));
                    }
                    else
                    {
                        bool flag4 = typeof(ReturnType) == typeof(bool);
                        if (flag4)
                        {
                            result = (ReturnType)((object)AndroidJNISafe.CallBooleanMethod(this.m_jobject, 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.CallSByteMethod(this.m_jobject, methodID, array)));
                            }
                            else
                            {
                                bool flag6 = typeof(ReturnType) == typeof(sbyte);
                                if (flag6)
                                {
                                    result = (ReturnType)((object)AndroidJNISafe.CallSByteMethod(this.m_jobject, methodID, array));
                                }
                                else
                                {
                                    bool flag7 = typeof(ReturnType) == typeof(short);
                                    if (flag7)
                                    {
                                        result = (ReturnType)((object)AndroidJNISafe.CallShortMethod(this.m_jobject, methodID, array));
                                    }
                                    else
                                    {
                                        bool flag8 = typeof(ReturnType) == typeof(long);
                                        if (flag8)
                                        {
                                            result = (ReturnType)((object)AndroidJNISafe.CallLongMethod(this.m_jobject, methodID, array));
                                        }
                                        else
                                        {
                                            bool flag9 = typeof(ReturnType) == typeof(float);
                                            if (flag9)
                                            {
                                                result = (ReturnType)((object)AndroidJNISafe.CallFloatMethod(this.m_jobject, methodID, array));
                                            }
                                            else
                                            {
                                                bool flag10 = typeof(ReturnType) == typeof(double);
                                                if (flag10)
                                                {
                                                    result = (ReturnType)((object)AndroidJNISafe.CallDoubleMethod(this.m_jobject, methodID, array));
                                                }
                                                else
                                                {
                                                    bool flag11 = typeof(ReturnType) == typeof(char);
                                                    if (flag11)
                                                    {
                                                        result = (ReturnType)((object)AndroidJNISafe.CallCharMethod(this.m_jobject, methodID, array));
                                                    }
                                                    else
                                                    {
                                                        result = default(ReturnType);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    bool flag12 = typeof(ReturnType) == typeof(string);
                    if (flag12)
                    {
                        result = (ReturnType)((object)AndroidJNISafe.CallStringMethod(this.m_jobject, methodID, array));
                    }
                    else
                    {
                        bool flag13 = typeof(ReturnType) == typeof(AndroidJavaClass);
                        if (flag13)
                        {
                            IntPtr intPtr = AndroidJNISafe.CallObjectMethod(this.m_jobject, 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.CallObjectMethod(this.m_jobject, 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.CallObjectMethod(this.m_jobject, methodID, array);
                                result = ((intPtr3 == IntPtr.Zero) ? default(ReturnType) : ((ReturnType)((object)AndroidJNIHelper.ConvertFromJNIArray <ReturnType>(intPtr3))));
                            }
                        }
                    }
                }
            }
            finally
            {
                AndroidJNIHelper.DeleteJNIArgArray(args, array);
            }
            return(result);
        }