Exemplo n.º 1
0
 private static global::net.sf.jni4net.utils.JniHandle MakeGenericMethod5(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle typeArguments)
 {
     // ([Lsystem/Type;)Lsystem/reflection/MethodInfo;
     // ([LSystem/Type;)LSystem/Reflection/MethodInfo;
     global::net.sf.jni4net.jni.JNIEnv      @__env    = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp);
     global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle);
     try {
         global::System.Reflection.MethodInfo @__real = global::net.sf.jni4net.utils.Convertor.StrongJp2C <global::System.Reflection.MethodInfo>(@__env, @__obj);
         @__return = global::net.sf.jni4net.utils.Convertor.StrongC2Jp <global::System.Reflection.MethodInfo>(@__env, @__real.MakeGenericMethod(global::net.sf.jni4net.utils.Convertor.ArrayStrongJp2C <global::System.Type[], global::System.Type>(@__env, typeArguments)));
     }catch (global::System.Exception __ex) { @__env.ThrowExisting(__ex); }
     return(@__return);
 }
Exemplo n.º 2
0
        public static object callMethod(object obj, global::System.Reflection.MethodBase[] methods, int methodLength, global::haxe.root.Array args)
        {
            unchecked
            {
                if ((methodLength == 0))
                {
                    throw global::haxe.lang.HaxeException.wrap("No available methods");
                }

                int      length          = ((int)(global::haxe.lang.Runtime.getField_f(args, "length", 520590566, true)));
                object[] oargs           = new object[((int)(length))];
                global::System.Type[] ts = new global::System.Type[((int)(length))];
                int[] rates = new int[((int)((methods as global::System.Array).Length))];
                {
                    int _g = 0;
                    while ((_g < ((int)(length))))
                    {
                        int i = _g++;
                        oargs[i] = args[i];
                        if ((!(global::haxe.lang.Runtime.eq(args[i], default(object)))))
                        {
                            ts[i] = global::cs.Lib.nativeType(args[i]);
                        }
                    }
                }

                int last = 0;
                if ((methodLength > 1))
                {
                    {
                        int _g1 = 0;
                        while ((_g1 < methodLength))
                        {
                            int i1 = _g1++;
                            global::System.Reflection.ParameterInfo[] @params = methods[i1].GetParameters();
                            if (((@params as global::System.Array).Length != length))
                            {
                                continue;
                            }
                            else
                            {
                                bool fits  = true;
                                int  crate = 0;
                                {
                                    int _g2  = 0;
                                    int _g11 = (@params as global::System.Array).Length;
                                    while ((_g2 < _g11))
                                    {
                                        int i2 = _g2++;
                                        global::System.Type param = @params[i2].ParameterType;
                                        string strParam           = global::haxe.lang.Runtime.concat(global::Std.@string(param), "");
                                        if (param.IsAssignableFrom(((global::System.Type)(ts[i2]))))
                                        {
                                            continue;
                                        }
                                        else
                                        {
                                            if ((strParam.StartsWith("haxe.lang.Null") || (((global::haxe.lang.Runtime.eq(oargs[i2], default(object)) || (oargs[i2] is global::System.IConvertible))) && (((global::System.Type)(typeof(global::System.IConvertible)))).IsAssignableFrom(((global::System.Type)(param))))))
                                            {
                                                crate++;
                                                continue;
                                            }
                                            else
                                            {
                                                if (!(param.ContainsGenericParameters))
                                                {
                                                    fits = false;
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                }

                                if (fits)
                                {
                                    rates[last]     = crate;
                                    methods[last++] = methods[i1];
                                }
                            }
                        }
                    }

                    methodLength = last;
                }
                else
                {
                    if (((methodLength == 1) && ((methods[0].GetParameters() as global::System.Array).Length != length)))
                    {
                        methodLength = 0;
                    }
                }

                if ((methodLength == 0))
                {
                    throw global::haxe.lang.HaxeException.wrap(global::haxe.lang.Runtime.concat("Invalid calling parameters for method ", (methods[0] as global::System.Reflection.MemberInfo).Name));
                }

                double best       = global::Math.POSITIVE_INFINITY;
                int    bestMethod = 0;
                {
                    int _g3 = 0;
                    while ((_g3 < methodLength))
                    {
                        int i3 = _g3++;
                        if ((rates[i3] < best))
                        {
                            bestMethod = i3;
                            best       = ((double)(rates[i3]));
                        }
                    }
                }

                methods[0] = methods[bestMethod];
                global::System.Reflection.ParameterInfo[] params1 = methods[0].GetParameters();
                {
                    int _g12 = 0;
                    int _g4  = (params1 as global::System.Array).Length;
                    while ((_g12 < _g4))
                    {
                        int i4 = _g12++;
                        global::System.Type param1 = params1[i4].ParameterType;
                        string strParam1           = global::haxe.lang.Runtime.concat(global::Std.@string(param1), "");
                        if (strParam1.StartsWith("haxe.lang.Null"))
                        {
                            oargs[i4] = global::haxe.lang.Runtime.mkNullable(oargs[i4], param1);
                        }
                        else
                        {
                            if ((((global::System.Type)(typeof(global::System.IConvertible)))).IsAssignableFrom(((global::System.Type)(param1))))
                            {
                                if (global::haxe.lang.Runtime.eq(oargs[i4], default(object)))
                                {
                                    if (param1.IsValueType)
                                    {
                                        oargs[i4] = global::System.Activator.CreateInstance(((global::System.Type)(param1)));
                                    }
                                }
                                else
                                {
                                    oargs[i4] = (((global::System.IConvertible)(oargs[i4]))).ToType(((global::System.Type)(param1)), ((global::System.IFormatProvider)(default(global::System.IFormatProvider))));
                                }
                            }
                        }
                    }
                }

                if ((methods[0].ContainsGenericParameters && (methods[0] is global::System.Reflection.MethodInfo)))
                {
                    global::System.Reflection.MethodInfo m = ((global::System.Reflection.MethodInfo)(methods[0]));
                    global::System.Type[] tgs = (m as global::System.Reflection.MethodBase).GetGenericArguments();
                    {
                        int _g13 = 0;
                        int _g5  = (tgs as global::System.Array).Length;
                        while ((_g13 < _g5))
                        {
                            int i5 = _g13++;
                            tgs[i5] = typeof(object);
                        }
                    }

                    m = m.MakeGenericMethod(((global::System.Type[])(tgs)));
                    object retg = (m as global::System.Reflection.MethodBase).Invoke(((object)(obj)), ((object[])(oargs)));
                    return(global::haxe.lang.Runtime.unbox(retg));
                }

                global::System.Reflection.MethodBase m1 = methods[0];
                if ((global::haxe.lang.Runtime.eq(obj, default(object)) && (m1 is global::System.Reflection.ConstructorInfo)))
                {
                    object ret = (((global::System.Reflection.ConstructorInfo)(m1))).Invoke(((object[])(oargs)));
                    return(global::haxe.lang.Runtime.unbox(ret));
                }

                object ret1 = m1.Invoke(((object)(obj)), ((object[])(oargs)));
                return(global::haxe.lang.Runtime.unbox(ret1));
            }
        }