Beispiel #1
0
        public static string AsString(NetRuby ruby, object x)
        {
            if (x == null)
            {
                return(String.Empty);
            }
            if (x is string)
            {
                return((string)x);
            }
            if (x is RString)
            {
                return(x.ToString());
            }
            object o = ruby.Funcall(x, "to_s", null);

            return(o.ToString());
        }
Beispiel #2
0
        static public RClass ClassNew(NetRuby ruby, RMetaObject spr, object[] o)
        {
            if (spr == null)
            {
                spr = ruby.cObject;
            }
            else if (spr is RSingletonClass)
            {
                throw new eTypeError("can't make subclass of virtual class");
            }
            RClass klass = new RClass(ruby, spr);

            klass.klass = new RSingletonClass(spr.klass);
            klass.klass.AttachSingleton(klass);
            ruby.CallInit(klass, o);
            ruby.Funcall(spr, "inherited", new object[1] {
                klass
            });
            return(klass);
        }
Beispiel #3
0
        // create new instance(INFECTED) RString
        public static RString AsRString(NetRuby ruby, object x)
        {
            if (x == null)
            {
                return(new RString(ruby, String.Empty));
            }
            if (x is string)
            {
                return(new RString(ruby, (string)x, false));
            }
            if (x is RString)
            {
                return((RString)x);
            }
            object o = ruby.Funcall(x, "to_s", null);

            if (o is string)
            {
                return(new RString(ruby, (string)o));
            }
            if (o is RString)
            {
                RString r = (RString)o;
                if (x is RBasic && ((RBasic)x).IsTainted)
                {
                    r.Set(FL.TAINT);
                }
                return(r);
            }
            else if (o is RBasic)
            {
                return(((RBasic)o).ToRString());
            }
            else
            {
                return(new RString(ruby, o.ToString()));
            }
        }
Beispiel #4
0
 public virtual object Inspect()
 {
     return(ruby.Funcall(this, "to_s", null));
 }