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)); }
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); }
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); }
// A block argument to blocks is allowed in newer versions of Ruby public abstract RBasic Call(RThread thread, RBasic[] args, RCBlock block);
public void PushLegacyBlock(RCBlock b) { //Console.WriteLine("Push block " + b); legacy_blocks.Push(b); }
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); }
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; }
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; }