示例#1
0
        public virtual RBasic BasicSend(string name, RBasic[] args, RCBlock block)
        {
            RMetaObject origin;
            RCMethod    m = (RCMethod)klass.SearchMethod(name, out origin);

            /*
             * Console.WriteLine("sending");
             * Console.WriteLine("self " + this.ToString());
             * Console.WriteLine("send " + name + " found " + m.ToString());
             * foreach(RBasic ro in args) {
             *  Console.WriteLine("arg " + ro.ToString());
             * }
             */
            if (m == null)
            {
                Console.WriteLine("Available methods:");

                foreach (object o in klass.ClassInstanceMethods(new object[] { ruby.oTrue }))
                {
                    Console.WriteLine(o.ToString());
                }

                throw new Exception("Method not found: " + name);
            }
            return(m.Call(ruby.GetCurrentContext(), this, args, block));
        }
示例#2
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);
            }
示例#3
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);
            }
示例#4
0
 // A block argument to blocks is allowed in newer versions of Ruby
 public abstract RBasic Call(RThread thread, RBasic[] args, RCBlock block);
示例#5
0
文件: Thread.cs 项目: emtees/old-code
 public void PushLegacyBlock(RCBlock b)
 {
     //Console.WriteLine("Push block " + b);
     legacy_blocks.Push(b);
 }
示例#6
0
文件: Object.cs 项目: emtees/old-code
 public virtual RBasic BasicSend(string name, RBasic[] args, RCBlock block)
 {
     RMetaObject origin;
     RCMethod m = (RCMethod)klass.SearchMethod(name, out origin);
     /*
     Console.WriteLine("sending");
     Console.WriteLine("self " + this.ToString());
     Console.WriteLine("send " + name + " found " + m.ToString());
     foreach(RBasic ro in args) {
         Console.WriteLine("arg " + ro.ToString());
     }
     */
     if(m == null) {
         Console.WriteLine("Available methods:");
         
         foreach(object o in klass.ClassInstanceMethods(new object[] {ruby.oTrue})) {
             Console.WriteLine(o.ToString());
         }
         
         throw new Exception("Method not found: " + name);
     }
     return m.Call(ruby.GetCurrentContext(), this, args, block);
 }
示例#7
0
文件: Class.cs 项目: emtees/old-code
            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;
            }
示例#8
0
文件: Class.cs 项目: emtees/old-code
 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;
 }
示例#9
0
 public void PushLegacyBlock(RCBlock b)
 {
     //Console.WriteLine("Push block " + b);
     legacy_blocks.Push(b);
 }
示例#10
0
 // A block argument to blocks is allowed in newer versions of Ruby
 public abstract RBasic Call(RThread thread, RBasic[] args, RCBlock block);