Exemplo n.º 1
0
        public T InvokeCall <T>(string name, string sig, params object[] args)
        {
            T      local;
            Type   type     = typeof(T);
            IntPtr methodID = AndroidJNI.GetMethodID(this.RawClass, name, sig);

            if (methodID == IntPtr.Zero)
            {
                Debug.LogError("Cannot get method for " + name);
                throw new Exception("Cannot get method for " + name);
            }
            jvalue[] jvalueArray = ConstructArgArray(args);
            try
            {
                if (type == typeof(bool))
                {
                    return((T)AndroidJNI.CallBooleanMethod(this.raw, methodID, jvalueArray));
                }
                if (type == typeof(string))
                {
                    return((T)AndroidJNI.CallStringMethod(this.raw, methodID, jvalueArray));
                }
                if (type == typeof(int))
                {
                    return((T)AndroidJNI.CallIntMethod(this.raw, methodID, jvalueArray));
                }
                if (type == typeof(float))
                {
                    return((T)AndroidJNI.CallFloatMethod(this.raw, methodID, jvalueArray));
                }
                if (type == typeof(double))
                {
                    return((T)AndroidJNI.CallDoubleMethod(this.raw, methodID, jvalueArray));
                }
                if (type == typeof(byte))
                {
                    return((T)AndroidJNI.CallByteMethod(this.raw, methodID, jvalueArray));
                }
                if (type == typeof(char))
                {
                    return((T)AndroidJNI.CallCharMethod(this.raw, methodID, jvalueArray));
                }
                if (type == typeof(long))
                {
                    return((T)AndroidJNI.CallLongMethod(this.raw, methodID, jvalueArray));
                }
                if (type == typeof(short))
                {
                    return((T)AndroidJNI.CallShortMethod(this.raw, methodID, jvalueArray));
                }
                local = this.InvokeObjectCall <T>(name, sig, args);
            }
            finally
            {
                AndroidJNIHelper.DeleteJNIArgArray(args, jvalueArray);
            }
            return(local);
        }
 public static byte CallByteMethod(IntPtr obj, IntPtr methodId, jvalue[] args)
 {
     try {
         return(AndroidJNI.CallByteMethod(obj, methodId, args));
     }
     finally {
         CheckException();
     }
 }
Exemplo n.º 3
0
        public T InvokeCall <T>(string name, string sig, params object[] args)
        {
            System.Type type        = typeof(T);
            IntPtr      objectClass = AndroidJNI.GetObjectClass(this.raw);
            IntPtr      methodID    = AndroidJNI.GetMethodID(objectClass, name, sig);

            jvalue[] jvalueArray = ConstructArgArray(args);
            if (objectClass == IntPtr.Zero)
            {
                Debug.LogError("Cannot get rawClass object!");
                throw new Exception("Cannot get rawClass object");
            }
            if (methodID == IntPtr.Zero)
            {
                Debug.LogError("Cannot get method for " + name);
                throw new Exception("Cannot get method for " + name);
            }
            if (type == typeof(bool))
            {
                return((T)AndroidJNI.CallBooleanMethod(this.raw, methodID, jvalueArray));
            }
            if (type == typeof(string))
            {
                return((T)AndroidJNI.CallStringMethod(this.raw, methodID, jvalueArray));
            }
            if (type == typeof(int))
            {
                return((T)AndroidJNI.CallIntMethod(this.raw, methodID, jvalueArray));
            }
            if (type == typeof(float))
            {
                return((T)AndroidJNI.CallFloatMethod(this.raw, methodID, jvalueArray));
            }
            if (type == typeof(double))
            {
                return((T)AndroidJNI.CallDoubleMethod(this.raw, methodID, jvalueArray));
            }
            if (type == typeof(byte))
            {
                return((T)AndroidJNI.CallByteMethod(this.raw, methodID, jvalueArray));
            }
            if (type == typeof(char))
            {
                return((T)AndroidJNI.CallCharMethod(this.raw, methodID, jvalueArray));
            }
            if (type == typeof(long))
            {
                return((T)AndroidJNI.CallLongMethod(this.raw, methodID, jvalueArray));
            }
            if (type == typeof(short))
            {
                return((T)AndroidJNI.CallShortMethod(this.raw, methodID, jvalueArray));
            }
            return(this.InvokeObjectCall <T>(name, sig, args));
        }
Exemplo n.º 4
0
        public T InvokeCall <T>(string name, string sig, params object[] args)
        {
            Type   t      = typeof(T);
            IntPtr method = AndroidJNI.GetMethodID(RawClass, name, sig);

            jvalue[] jArgs = ConstructArgArray(args);

            if (method == IntPtr.Zero)
            {
                Debug.LogError("Cannot get method for " + name);
                throw new Exception("Cannot get method for " + name);
            }

            if (t == typeof(bool))
            {
                return((T)(object)AndroidJNI.CallBooleanMethod(raw, method, jArgs));
            }
            else if (t == typeof(string))
            {
                return((T)(object)AndroidJNI.CallStringMethod(raw, method, jArgs));
            }
            else if (t == typeof(int))
            {
                return((T)(object)AndroidJNI.CallIntMethod(raw, method, jArgs));
            }
            else if (t == typeof(float))
            {
                return((T)(object)AndroidJNI.CallFloatMethod(raw, method, jArgs));
            }
            else if (t == typeof(double))
            {
                return((T)(object)AndroidJNI.CallDoubleMethod(raw, method, jArgs));
            }
            else if (t == typeof(byte))
            {
                return((T)(object)AndroidJNI.CallByteMethod(raw, method, jArgs));
            }
            else if (t == typeof(char))
            {
                return((T)(object)AndroidJNI.CallCharMethod(raw, method, jArgs));
            }
            else if (t == typeof(long))
            {
                return((T)(object)AndroidJNI.CallLongMethod(raw, method, jArgs));
            }
            else if (t == typeof(short))
            {
                return((T)(object)AndroidJNI.CallShortMethod(raw, method, jArgs));
            }
            else
            {
                return(InvokeObjectCall <T>(name, sig, args));
            }
        }
Exemplo n.º 5
0
        public T InvokeCall <T>(string name, string sig, params object[] args)
        {
            Type   t        = typeof(T);
            IntPtr rawClass = AndroidJNI.GetObjectClass(raw);
            IntPtr method   = AndroidJNI.GetMethodID(rawClass, name, sig);

            jvalue[] jArgs = ConstructArgArray(args);

            if (t == typeof(bool))
            {
                return((T)(object)AndroidJNI.CallBooleanMethod(raw, method, jArgs));
            }
            else if (t == typeof(string))
            {
                return((T)(object)AndroidJNI.CallStringMethod(raw, method, jArgs));
            }
            else if (t == typeof(int))
            {
                return((T)(object)AndroidJNI.CallIntMethod(raw, method, jArgs));
            }
            else if (t == typeof(float))
            {
                return((T)(object)AndroidJNI.CallFloatMethod(raw, method, jArgs));
            }
            else if (t == typeof(double))
            {
                return((T)(object)AndroidJNI.CallDoubleMethod(raw, method, jArgs));
            }
            else if (t == typeof(byte))
            {
                return((T)(object)AndroidJNI.CallByteMethod(raw, method, jArgs));
            }
            else if (t == typeof(char))
            {
                return((T)(object)AndroidJNI.CallCharMethod(raw, method, jArgs));
            }
            else if (t == typeof(long))
            {
                return((T)(object)AndroidJNI.CallLongMethod(raw, method, jArgs));
            }
            else if (t == typeof(short))
            {
                return((T)(object)AndroidJNI.CallShortMethod(raw, method, jArgs));
            }
            else
            {
                return(InvokeObjectCall <T>(name, sig, args));
            }
        }
Exemplo n.º 6
0
        public T InvokeCall <T>(string name, string sig, params object[] args)
        {
            Type   type     = typeof(T);
            IntPtr methodId = AndroidJNI.GetMethodID(AndroidJNI.GetObjectClass(this.raw), name, sig);

            jvalue[] jvalueArray = JavaObjWrapper.ConstructArgArray(args);
            if ((object)type == (object)typeof(bool))
            {
                return((T)(ValueType)AndroidJNI.CallBooleanMethod(this.raw, methodId, jvalueArray));
            }
            if ((object)type == (object)typeof(string))
            {
                return((T)AndroidJNI.CallStringMethod(this.raw, methodId, jvalueArray));
            }
            if ((object)type == (object)typeof(int))
            {
                return((T)(ValueType)AndroidJNI.CallIntMethod(this.raw, methodId, jvalueArray));
            }
            if ((object)type == (object)typeof(float))
            {
                return((T)(ValueType)AndroidJNI.CallFloatMethod(this.raw, methodId, jvalueArray));
            }
            if ((object)type == (object)typeof(double))
            {
                return((T)(ValueType)AndroidJNI.CallDoubleMethod(this.raw, methodId, jvalueArray));
            }
            if ((object)type == (object)typeof(byte))
            {
                return((T)(ValueType)AndroidJNI.CallByteMethod(this.raw, methodId, jvalueArray));
            }
            if ((object)type == (object)typeof(char))
            {
                return((T)(ValueType)AndroidJNI.CallCharMethod(this.raw, methodId, jvalueArray));
            }
            if ((object)type == (object)typeof(long))
            {
                return((T)(ValueType)AndroidJNI.CallLongMethod(this.raw, methodId, jvalueArray));
            }
            if ((object)type == (object)typeof(short))
            {
                return((T)(ValueType)AndroidJNI.CallShortMethod(this.raw, methodId, jvalueArray));
            }
            return(this.InvokeObjectCall <T>(name, sig, args));
        }