Exemplo n.º 1
0
        public static bool SignatureEquals(this JavaArchiveReflectorMethod a, JavaArchiveReflectorMethod b, bool CheckReturnType = true)
        {
            if (a.MethodName != b.MethodName)
            {
                return(false);
            }

            if (CheckReturnType)
            {
                if (a.ReturnType != b.ReturnType)
                {
                    return(false);
                }
            }

            if (a.ParameterTypes.Length != b.ParameterTypes.Length)
            {
                return(false);
            }

            var value = true;

            for (int i = 0; i < a.ParameterTypes.Length; i++)
            {
                if (a.ParameterTypes[i] != b.ParameterTypes[i])
                {
                    value = false;
                    break;
                }
            }

            return(value);
        }
Exemplo n.º 2
0
        public JavaArchiveReflectorMethod[] Type_GetMethods(string TypeName)
        {
            var y = default(JavaArchiveReflectorMethod[]);
            var f = default(System.Reflection.MethodInfo[]);

            var t = this.clazzLoader.GetType(TypeName);

            try
            {
                // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20150402/scriptcorelibandroid-natives

                //f = t.GetMethods(); // what about protected members?
                f = t.GetMethods(
                    BindingFlags.DeclaredOnly | BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public
                    ); // what about protected members?
            }
            catch
            {
                System.Console.WriteLine("JavaArchiveReflector.Type_GetMethods error, TypeName: " + TypeName);

                // we did not find a type. skip constructors..
                y = new JavaArchiveReflectorMethod[0];
            }

            if (y == null)
            {
                y = new JavaArchiveReflectorMethod[f.Length];

                for (int i = 0; i < f.Length; i++)
                {
                    var fi = f[i];

                    //Caused by: java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.String;
                    //        at jsc.jvmi__i__d.Internal.Java.JavaArchiveReflector.Type_GetMethods(JavaArchiveReflector.java:277)
                    //        at jsc.jvmi._ToDelegates________02000048_.Type_GetMethods(_ToDelegates________02000048_.java:345)

                    //MethodThrows = fi.ToMethod().getExceptionTypes().Select(k => k.ToType().FullName).ToArray()

                    var MethodThrows = GetExceptionTypes(fi);

                    y[i] = new JavaArchiveReflectorMethod
                    {
                        MethodIndex = i,

                        ParameterTypes = f[i].GetParameterTypeFullNames(),
                        ReturnType     = f[i].ReturnType.FullName,

                        MethodName = f[i].Name,

                        IsPublic   = f[i].IsPublic,
                        IsFamily   = f[i].IsFamily,
                        IsStatic   = f[i].IsStatic,
                        IsAbstract = f[i].IsAbstract,

                        // can we use linq now?
                        MethodThrows = MethodThrows
                    };
                }
            }

            return(y);
        }
        public JavaArchiveReflectorMethod[] Type_GetMethods(string TypeName)
        {
            var y = default(JavaArchiveReflectorMethod[]);
            var f = default(System.Reflection.MethodInfo[]);

            var t = this.clazzLoader.GetType(TypeName);

            try
            {
                // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20150402/scriptcorelibandroid-natives

                //f = t.GetMethods(); // what about protected members?
                f = t.GetMethods(
                    BindingFlags.DeclaredOnly | BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public
                ); // what about protected members?
            }
            catch
            {
                System.Console.WriteLine("JavaArchiveReflector.Type_GetMethods error, TypeName: " + TypeName);

                // we did not find a type. skip constructors..
                y = new JavaArchiveReflectorMethod[0];
            }

            if (y == null)
            {
                y = new JavaArchiveReflectorMethod[f.Length];

                for (int i = 0; i < f.Length; i++)
                {
                    var fi = f[i];

                    //Caused by: java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.String;
                    //        at jsc.jvmi__i__d.Internal.Java.JavaArchiveReflector.Type_GetMethods(JavaArchiveReflector.java:277)
                    //        at jsc.jvmi._ToDelegates________02000048_.Type_GetMethods(_ToDelegates________02000048_.java:345)

                    //MethodThrows = fi.ToMethod().getExceptionTypes().Select(k => k.ToType().FullName).ToArray()

                    var MethodThrows = GetExceptionTypes(fi);

                    y[i] = new JavaArchiveReflectorMethod
                    {
                        MethodIndex = i,

                        ParameterTypes = f[i].GetParameterTypeFullNames(),
                        ReturnType = f[i].ReturnType.FullName,

                        MethodName = f[i].Name,

                        IsPublic = f[i].IsPublic,
                        IsFamily = f[i].IsFamily,
                        IsStatic = f[i].IsStatic,
                        IsAbstract = f[i].IsAbstract,

                        // can we use linq now?
                        MethodThrows = MethodThrows
                    };
                }
            }

            return y;
        }
        public static bool SignatureEquals(this JavaArchiveReflectorMethod a, JavaArchiveReflectorMethod b, bool CheckReturnType = true)
        {
            if (a.MethodName != b.MethodName)
                return false;

            if (CheckReturnType)
                if (a.ReturnType != b.ReturnType)
                    return false;

            if (a.ParameterTypes.Length != b.ParameterTypes.Length)
                return false;

            var value = true;
            for (int i = 0; i < a.ParameterTypes.Length; i++)
            {
                if (a.ParameterTypes[i] != b.ParameterTypes[i])
                {
                    value = false;
                    break;
                }
            }

            return value;
        }