コード例 #1
0
            public override RBasic Call(RThread th, RBasic self, RBasic[] args, RCBlock block)
            {
                th.PushLegacyBlock(block);
                RBasic ret = RClass.ConvertToRuby(ruby, method(self, (object[])args));

                th.PopLegacyBlock();
                return(ret);
            }
コード例 #2
0
            public override RBasic Call(RThread th, RBasic self, RBasic[] args, RCBlock block)
            {
                th.PushLegacyBlock(block);

                /*
                 * Console.WriteLine("Invoke " + method_info.Name + " self=" + self.GetType().Name + ":" + self.ToString());
                 * Console.WriteLine("mi_type=" + method_info.DeclaringType.Name);
                 * foreach(ParameterInfo p in method_info.GetParameters()) {
                 *  Console.WriteLine("mparam: " + p.ParameterType.Name);
                 * }
                 * foreach(RBasic r in args) {
                 *  Console.WriteLine("realparam: " + r.GetType().Name);
                 * }
                 */

                // return (RBasic)method_info.Invoke(null, new object[] { self, args });
                ParameterInfo[] pi = method_info.GetParameters();
                RBasic          ret;

                if (pi.Length > 0 && pi[0].ParameterType == typeof(object[]))
                {
                    ret = RClass.ConvertToRuby(ruby, method_info.Invoke(self, new object[] { args }));
                }
                else
                {
                    object[] ca = new object[pi.Length];
                    for (int i = 0; i < pi.Length; i++)
                    {
                        if (pi[i].ParameterType == typeof(int))
                        {
                            ca[i] = args[i].ToInteger();
                        }
                        else
                        {
                            ca[i] = args[i];
                        }
                    }

                    ret = RClass.ConvertToRuby(ruby, method_info.Invoke(self, ca));
                }
                th.PopLegacyBlock();
                return(ret);
            }