public object ruby_float(RBasic r, params object[] o) { if (o[0] == null || o[0] == ruby.oNil) return new RFloat(ruby, 0.0); RBasic x = ruby.InstanceOf(o[0]); return (RFloat)ruby.ConvertType(x, typeof(RFloat), "Float", "to_f"); }
internal RBasic(RBasic o) { ruby = o.ruby; if (o.klass is RSingletonClass) { RMetaObject org = o.klass; RMetaObject meta = (RMetaObject)org.Clone(); if (meta.m_tbl == null) meta.m_tbl = new st_table(); else meta.m_tbl.Clear(); /* foreach (DictionaryEntry ent in org.m_tbl) { RNMethod m = (RNMethod)ent.Value; meta.m_tbl.Add(ent.Key, new RNMethod(m)); } */ klass = meta; } else { klass = o.klass; } flags = o.flags; /* if (o.Test(FL.EXIVAR)) { ruby.CloneGenericIVar(this, o); } */ GetHashCode(); // define ID }
public object ruby_p(RBasic r, params object[] o) { foreach (object x in o) { System.Console.Out.Write(RString.AsString(ruby, ruby.Inspect(x)) + ruby.defaultRecSep); } // check defout and if file, then flush return null; }
private static object find_all(RBasic r, params object[] args) { /* NetRuby ruby = r.ruby; RArray ary = new RArray(ruby, true); ruby.Iterate(new NetRuby.IterationProc(Each), r, new NetRuby.BlockProc(find_all_i), ary); return ary; */ return null; //PH }
private static object collect(RBasic r, params object[] args) { /* NetRuby ruby = r.ruby; RArray ary = new RArray(ruby, true); ruby.Iterate(new NetRuby.IterationProc(Each), r, (ruby.IsBlockGiven) ? new NetRuby.BlockProc(collect_i) : new NetRuby.BlockProc(enum_all), ary); return ary; */ return null; //PH }
public object ruby_array(RBasic r, params object[] o) { RBasic x = ruby.InstanceOf(o[0]); object val; uint to_ary = ruby.intern("to_ary"); if (x.RespondTo(to_ary, false)) val = ruby.Funcall(x, to_ary, null); else val = ruby.Funcall(x, ruby.intern("to_a"), null); if (val is RArray == false) throw new eTypeError("`to_a' did not return Array"); return (RArray)val; }
public object IsKindOf(RBasic obj, params object[] o) { RMetaObject cl = ruby.ClassOf(obj); object c = o[0]; if (c is RMetaObject == false) { throw new eTypeError("class or module required"); } while (cl != null) { if (cl == c || cl.m_tbl == ((RMetaObject)c).m_tbl) return true; cl = cl.super; } return false; }
public object IsInstanceOf(RBasic r, params object[] args) { object o = args[0]; if (o == null) { return (r == ruby.oNil) ? true : false; } else if (o is bool) { return ((bool)o) ? r == ruby.oTrue : r == ruby.oFalse; } else if (o is RMetaObject == false) { throw new eTypeError("class or module required"); } return r.Class == o; }
public object ruby_print(RBasic r, params object[] o) { string s = String.Empty; if (o.Length == 0) { s = obj_to_s(NetRuby.lastLineGetter(0, null, ruby)); } else { foreach (object x in o) { s += obj_to_s(x); } } System.Console.Out.Write(s); return null; }
// A block argument to blocks is allowed in newer versions of Ruby public abstract RBasic Call(RThread thread, RBasic[] args, RCBlock block);
private object inspect_join(RBasic ary, object[] args) { RString rs = ((RArray)args[0]).Join(args[1]); return rs; }
static public RArray AssocNew(NetRuby ruby, RBasic car, RBasic cdr) { ArrayList ar = new ArrayList(); ar.Add(car); ar.Add(cdr); return new RArray(ruby, ar); }
static internal object add(RBasic r, params object[] args) { return ((RThreadGroup)r).Add(args[0]); }
static internal object tg_new(RBasic r, params object[] args) { return NewThreadGroup(args, (RMetaObject)r); }
static internal object thread_aset(RBasic r, params object[] args) { return ((RThread)r).SetTLS(args[0], args[1]); }
static internal object thread_priority_set(RBasic r, params object[] args) { NetRuby rb = r.ruby; long l = rb.InstanceOf(args[0]).ToInteger().ToLong(); if (Array.IndexOf(threadPtyVal, (int)l) < 0) { throw new ArgumentException("invalid thread priority value"); } ((RThread)r).Priority = (int)l; return null; }
/* static internal object thread_safe_level(RBasic r, params object[] args) { return ((RThread)r).safeLevel; } */ static internal object thread_aref(RBasic r, params object[] args) { return ((RThread)r).GetTLS(args[0]); }
static internal object thread_raise(RBasic r, params object[] args) { return ((RThread)r).Raise(args); }
static internal object thread_keyp(RBasic r, params object[] args) { return ((RThread)r).IsKey(args[0]); }
static internal object critical_getset(RBasic r, params object[] args) { throw new NotSupportedException("NETRuby can't handle Thread#critical"); }
static internal object list(RBasic r, params object[] args) { return ((RThreadGroup)r).List; }
static internal object thread_s_abort_exc(RBasic r, params object[] args) { NetRuby rb = r.ruby; return rb.cThread.AbortOnException; }
public void GlobalSet(string name, RBasic val) { GlobalEntry ent = ruby.global_entry(ruby.global_id(name)); ruby.GVarSet(ent, val); }
static internal object thread_s_abort_set(RBasic r, params object[] args) { NetRuby rb = r.ruby; bool b = RBasic.RTest(args[0]); rb.cThread.AbortOnException = b; return b; }
private object inspect_ary(RBasic ary, object[] args) { bool taint = false; StringBuilder result = new StringBuilder("["); for (int i = 0; i < ptr.Count; i++) { object o = ruby.Inspect(ptr[i]); if (o is RBasic && ((RBasic)o).IsTainted) taint = true; if (i > 0) result.AppendFormat(", {0}", (o == null) ? "nil" : o.ToString()); else result.Append(o.ToString()); } result.Append("]"); if (IsTainted || taint) return new RString(ruby, result.ToString(), true); else return result.ToString(); }
static internal object thread_abort_exc(RBasic r, params object[] args) { return ((RThread)r).AbortOnException; }
internal static object s_new(RBasic r, params object[] args) { NetRuby rb = r.ruby; RArray a = new RArray(rb, false, (RMetaObject)r); rb.CallInit(a, args); if (a.ptr == null) a.ptr = new ArrayList(); return a; }
static internal object thread_abort_set(RBasic r, params object[] args) { bool b = RBasic.RTest(args[0]); ((RThread)r).AbortOnException = b; return b; }
public RCBlock(RBasic self, RBasic[] locals) { this.self = self; this.locals = locals; }
static internal object thread_priority(RBasic r, params object[] args) { return ((RThread)r).Priority; }