Example #1
0
        internal static MutableString /*!*/ ToS(RubyContext /*!*/ context, string /*!*/ methodName, RubyModule /*!*/ declaringModule, RubyModule /*!*/ targetModule,
                                                string /*!*/ classDisplayName)
        {
            MutableString result = MutableString.CreateMutable(context.GetIdentifierEncoding());

            result.Append("#<");
            result.Append(classDisplayName);
            result.Append(": ");

            if (ReferenceEquals(targetModule, declaringModule))
            {
                result.Append(declaringModule.GetDisplayName(context, true));
            }
            else
            {
                result.Append(targetModule.GetDisplayName(context, true));
                result.Append('(');
                result.Append(declaringModule.GetDisplayName(context, true));
                result.Append(')');
            }

            result.Append('#');
            result.Append(methodName);
            result.Append('>');
            return(result);
        }
Example #2
0
        public static MutableString /*!*/ Inspect(RubyContext /*!*/ context, TypeGroup /*!*/ self)
        {
            var result = MutableString.CreateMutable(context.GetIdentifierEncoding());

            result.Append("#<TypeGroup: ");

            bool isFirst = true;

            foreach (var entry in self.TypesByArity.ToSortedList((x, y) => x.Key - y.Key))
            {
                Type type = entry.Value;

                if (!isFirst)
                {
                    result.Append(", ");
                }
                else
                {
                    isFirst = false;
                }

                result.Append(context.GetTypeName(type, true));
            }
            result.Append('>');

            return(result);
        }
Example #3
0
 public static MutableString/*!*/ Inspect(RubyContext/*!*/ context, char self) {
     return MutableString.Create(
         MutableString.AppendUnicodeRepresentation(
             new StringBuilder().Append('\''), self.ToString(), MutableString.Escape.Special, '\'', -1
         ).Append("' (Char)").ToString(),
         context.GetIdentifierEncoding()
     );
 }
Example #4
0
 public static MutableString /*!*/ Inspect(RubyContext /*!*/ context, char self)
 {
     return(MutableString.Create(
                MutableString.AppendUnicodeRepresentation(
                    new StringBuilder().Append('\''), self.ToString(), MutableString.Escape.Special, '\'', -1
                    ).Append("' (Char)").ToString(),
                context.GetIdentifierEncoding()
                ));
 }
Example #5
0
 public static MutableString/*!*/ TagUri(RubyContext/*!*/ context, object self) {
     var result = MutableString.Create(Tags.RubyObject, context.GetIdentifierEncoding());
     var selfClass = context.GetClassOf(self);
     if (selfClass != context.ObjectClass) {
         return result.Append(':').Append(context.GetClassName(self));
     } else {
         return result;
     }
 }
Example #6
0
 public static MutableString/*!*/ Inspect(RubyContext/*!*/ context, RubyEncoding/*!*/ self) {
     // TODO: to_s overridden
     MutableString result = MutableString.CreateMutable(context.GetIdentifierEncoding());
     result.Append("#<");
     result.Append(context.GetClassDisplayName(self));
     result.Append(':');
     result.Append(self.Name);
     result.Append('>');
     return result;
 }
Example #7
0
        public static MutableString /*!*/ Inspect(RubyContext /*!*/ context, RubyEncoding /*!*/ self)
        {
            // TODO: to_s overridden
            MutableString result = MutableString.CreateMutable(context.GetIdentifierEncoding());

            result.Append("#<");
            result.Append(context.GetClassDisplayName(self));
            result.Append(':');
            result.Append(self.Name);
            result.Append('>');
            return(result);
        }
Example #8
0
        internal static MutableString /*!*/ GetTagUri(RubyContext /*!*/ context, object /*!*/ obj, string /*!*/ baseTag, Type /*!*/ baseType)
        {
            var result = MutableString.Create(baseTag, context.GetIdentifierEncoding());

            if (obj.GetType() != baseType)
            {
                return(result.Append(':').Append(context.GetClassName(obj)));
            }
            else
            {
                return(result);
            }
        }
Example #9
0
        public static MutableString /*!*/ Inspect(RubyContext /*!*/ context, BigDecimal /*!*/ self)
        {
            MutableString str = MutableString.CreateMutable(context.GetIdentifierEncoding());

            str.AppendFormat("#<{0}:", context.GetClassOf(self).Name);
            RubyUtils.AppendFormatHexObjectId(str, RubyUtils.GetObjectId(context, self));
            str.AppendFormat(",'{0}',{1}({2})>",
                             self.ToString(10),
                             self.PrecisionDigits,
                             self.MaxPrecisionDigits
                             );
            return(str);
        }
Example #10
0
        public static MutableString /*!*/ TagUri(RubyContext /*!*/ context, object self)
        {
            var result    = MutableString.Create(Tags.RubyObject, context.GetIdentifierEncoding());
            var selfClass = context.GetClassOf(self);

            if (selfClass != context.ObjectClass)
            {
                return(result.Append(':').Append(context.GetClassName(self)));
            }
            else
            {
                return(result);
            }
        }
Example #11
0
        public static MutableString /*!*/ TagUri(RubyContext /*!*/ context, object /*!*/ self)
        {
            var    result    = MutableString.Create(Tags.TimestampYmd, context.GetIdentifierEncoding());
            string className = context.GetClassName(self);

            if (className != "Date")
            {
                return(result.Append(':').Append(className));
            }
            else
            {
                return(result);
            }
        }
Example #12
0
        public static MutableString /*!*/ Inspect(RubyContext /*!*/ context, Thread /*!*/ self)
        {
            RubyThreadInfo.RegisterThread(Thread.CurrentThread);

            MutableString result = MutableString.CreateMutable(context.GetIdentifierEncoding());

            result.Append("#<");
            result.Append(context.GetClassDisplayName(self));
            result.Append(':');
            RubyUtils.AppendFormatHexObjectId(result, RubyUtils.GetObjectId(context, self));
            result.Append(' ');

            RubyThreadStatus status = GetStatus(self);

            switch (status)
            {
            case RubyThreadStatus.Unstarted:
                result.Append("unstarted");
                break;

            case RubyThreadStatus.Running:
                result.Append("run");
                break;

            case RubyThreadStatus.Sleeping:
                result.Append("sleep");
                break;

            case RubyThreadStatus.Aborting:
                result.Append("aborting");
                break;

            case RubyThreadStatus.Completed:
            case RubyThreadStatus.Aborted:
                result.Append("dead");
                break;
            }

            result.Append('>');
            return(result);
        }
Example #13
0
 internal static MutableString/*!*/ GetTagUri(RubyContext/*!*/ context, object/*!*/ obj, string/*!*/ baseTag, Type/*!*/ baseType) {
     var result = MutableString.Create(baseTag, context.GetIdentifierEncoding());
     if (obj.GetType() != baseType) {
         return result.Append(':').Append(context.GetClassName(obj));
     } else {
         return result;
     }
 }
Example #14
0
        public static MutableString/*!*/ Inspect(RubyContext/*!*/ context, TypeGroup/*!*/ self) {
            var result = MutableString.CreateMutable(context.GetIdentifierEncoding());
            result.Append("#<TypeGroup: ");

            bool isFirst = true;
            foreach (var entry in self.TypesByArity.ToSortedList((x, y) => x.Key - y.Key)) {
                Type type = entry.Value;

                if (!isFirst) {
                    result.Append(", ");
                } else {
                    isFirst = false;
                }

                result.Append(context.GetTypeName(type, true));
            }
            result.Append('>');

            return result;
        }
Example #15
0
 public static MutableString/*!*/ GetName(RubyContext/*!*/ context, TypeGroup/*!*/ self) {
     return MutableString.Create(self.Name, context.GetIdentifierEncoding());
 }
Example #16
0
 public static MutableString/*!*/ GetRubyName(RubyContext/*!*/ context, ClrName/*!*/ self) {
     return MutableString.Create(self.MangledName, context.GetIdentifierEncoding());
 }
Example #17
0
 public static Exception/*!*/ ReinitializeException(RubyContext/*!*/ context, Exception/*!*/ self, [DefaultParameterValue(null)]object message) {
     var instance = RubyExceptionData.GetInstance(self);
     instance.Backtrace = null;
     instance.Message = message ?? MutableString.Create(context.GetClassOf(self).Name, context.GetIdentifierEncoding());
     return self;
 }
Example #18
0
 private void WriteClass(RubyClass /*!*/ obj)
 {
     _writer.Write((byte)'c');
     TestForAnonymous(obj);
     WriteStringValue(obj.Name, _context.GetIdentifierEncoding());
 }
Example #19
0
 public static MutableString /*!*/ GetName(RubyContext /*!*/ context, TypeGroup /*!*/ self)
 {
     return(MutableString.Create(self.Name, context.GetIdentifierEncoding()));
 }
Example #20
0
        public static MutableString Inspect(RubyContext/*!*/ context, Thread/*!*/ self)
        {
            RubyThreadInfo.RegisterThread(Thread.CurrentThread);

            MutableString result = MutableString.CreateMutable(context.GetIdentifierEncoding());
            result.Append("#<");
            result.Append(context.GetClassDisplayName(self));
            result.Append(':');
            RubyUtils.AppendFormatHexObjectId(result, RubyUtils.GetObjectId(context, self));
            result.Append(' ');

            RubyThreadStatus status = GetStatus(self);
            switch (status) {
                case RubyThreadStatus.Unstarted:
                    result.Append("unstarted");
                    break;
                case RubyThreadStatus.Running:
                    result.Append("run");
                    break;
                case RubyThreadStatus.Sleeping:
                    result.Append("sleep");
                    break;
                case RubyThreadStatus.Aborting:
                    result.Append("aborting");
                    break;
                case RubyThreadStatus.Completed:
                case RubyThreadStatus.Aborted:
                    result.Append("dead");
                    break;
            }

            result.Append('>');
            return result;
        }
Example #21
0
 public static MutableString TagUri(RubyContext/*!*/ context, object/*!*/ self)
 {
     var result = MutableString.Create(Tags.TimestampYmd, context.GetIdentifierEncoding());
     string className = context.GetClassName(self);
     if (className != "Date") {
         return result.Append(':').Append(className);
     } else {
         return result;
     }
 }
Example #22
0
 public static MutableString /*!*/ GetRubyName(RubyContext /*!*/ context, ClrName /*!*/ self)
 {
     return(MutableString.Create(self.MangledName, context.GetIdentifierEncoding()));
 }
Example #23
0
 public static MutableString/*!*/ Inspect(RubyContext/*!*/ context, BigDecimal/*!*/ self) {
     MutableString str = MutableString.CreateMutable(context.GetIdentifierEncoding());
     str.AppendFormat("#<{0}:", context.GetClassOf(self).Name);
     RubyUtils.AppendFormatHexObjectId(str, RubyUtils.GetObjectId(context, self));
     str.AppendFormat(",'{0}',{1}({2})>", 
         self.ToString(10),
         self.PrecisionDigits,
         self.MaxPrecisionDigits
     );
     return str;
 }
Example #24
0
        public static Exception /*!*/ ReinitializeException(RubyContext /*!*/ context, Exception /*!*/ self, [DefaultParameterValue(null)] object message)
        {
            var instance = RubyExceptionData.GetInstance(self);

            instance.Backtrace = null;
            instance.Message   = message ?? MutableString.Create(context.GetClassOf(self).Name, context.GetIdentifierEncoding());
            return(self);
        }
Example #25
0
        public MutableString GetDisplayName(RubyContext/*!*/ context, bool showEmptyName) {
            if (IsSingletonClass) {
                RubyClass c = (RubyClass)this;
                object singletonOf;
                MutableString result = MutableString.CreateMutable(context.GetIdentifierEncoding());

                int nestings = 0;
                while (true) {
                    nestings++;
                    result.Append("#<Class:");

                    singletonOf = c.SingletonClassOf;

                    RubyModule module = singletonOf as RubyModule;

                    if (module == null || !module.IsSingletonClass && module.Name == null) {
                        nestings++;
                        result.Append("#<");
                        result.Append(c.SuperClass.GetName(context));
                        result.Append(':');
                        RubyUtils.AppendFormatHexObjectId(result, RubyUtils.GetObjectId(_context, singletonOf));
                        break;
                    }

                    if (!module.IsSingletonClass) {
                        result.Append(module.GetName(context));
                        break;
                    }

                    c = (RubyClass)module;
                }
                return result.Append('>', nestings);
            } else if (_name == null) {
                if (showEmptyName) {
                    return null;
                } else {
                    MutableString result = MutableString.CreateMutable(context.GetIdentifierEncoding());
                    result.Append("#<");
                    result.Append(_context.GetClassOf(this).GetName(context));
                    result.Append(':');
                    RubyUtils.AppendFormatHexObjectId(result, RubyUtils.GetObjectId(_context, this));
                    result.Append('>');
                    return result;
                }
            } else {
                return MutableString.CreateMutable(GetName(context), context.GetIdentifierEncoding());
            }
        }
Example #26
0
        /*!*/
        internal static MutableString ToS(RubyContext/*!*/ context, string/*!*/ methodName, RubyModule/*!*/ declaringModule, RubyModule/*!*/ targetModule, 
            string/*!*/ classDisplayName)
        {
            MutableString result = MutableString.CreateMutable(context.GetIdentifierEncoding());

            result.Append("#<");
            result.Append(classDisplayName);
            result.Append(": ");

            if (ReferenceEquals(targetModule, declaringModule)) {
                result.Append(declaringModule.GetDisplayName(context, true));
            } else {
                result.Append(targetModule.GetDisplayName(context, true));
                result.Append('(');
                result.Append(declaringModule.GetDisplayName(context, true));
                result.Append(')');
            }

            result.Append('#');
            result.Append(methodName);
            result.Append('>');
            return result;
        }
Example #27
0
 public static MutableString GetClrName(RubyContext/*!*/ context, ClrName/*!*/ self)
 {
     return MutableString.Create(self.ActualName, context.GetIdentifierEncoding());
 }