Example #1
0
 /*!*/
 internal static string ConvertToFieldName(RubyContext/*!*/ context, object name)
 {
     // MRI doesn't use a dynamic conversion:
     if (name is RubySymbol || name is MutableString) {
         return name.ToString();
     } else {
         throw RubyExceptions.CreateTypeError("unexpected type {0}, expected Symbol or String", context.GetClassDisplayName(name));
     }
 }
Example #2
0
        public static object/*!*/ Xor(RubyContext/*!*/ context, object/*!*/ self, [NotNull]object/*!*/ other) {
            Debug.Assert(self is Enum);

            var result = EnumUtils.ExclusiveOr(self, other);
            if (result != null) {
                return result;
            }
            throw RubyExceptions.CreateUnexpectedTypeError(context, other, context.GetClassDisplayName(self));
        }
Example #3
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 #4
0
 private static RubyIO/*!*/ ToIo(RubyContext/*!*/ context, object obj) {
     RubyIO io = obj as RubyIO;
     if (io == null) {
         throw RubyExceptions.CreateTypeConversionError(context.GetClassDisplayName(obj), "IO");
     }
     return io;
 }
Example #5
0
 public static Exception/*!*/ CreateUnexpectedTypeError(RubyContext/*!*/ context, object param, string/*!*/ type) {
     return CreateTypeError("wrong argument type {0} (expected {1})", context.GetClassDisplayName(param), type);
 }
Example #6
0
 public static Node ToYamlNode(RubyContext/*!*/ context, object self, RubyRepresenter rep) {
     throw RubyExceptions.CreateTypeError("can't dump anonymous class " + context.GetClassDisplayName(self));
 }
        private object RequireWriteProtocol(RubyContext/*!*/ context, object value, string/*!*/ variableName) {
            if (!context.RespondTo(value, "write")) {
                throw RubyExceptions.CreateTypeError(String.Format("${0} must have write method, {1} given", variableName, context.GetClassDisplayName(value)));
            }

            return value;
        }
Example #8
0
 public static Exception/*!*/ MakeTypeConversionError(RubyContext/*!*/ context, object value, Type/*!*/ type) {
     return RubyExceptions.CreateTypeConversionError(context.GetClassDisplayName(value), context.GetTypeName(type, true));
 }
Example #9
0
        public static MutableString/*!*/ Inspect(RubyContext/*!*/ context, Thread/*!*/ self) {
            RubyThreadInfo.RegisterThread(Thread.CurrentThread);

            MutableString result = MutableString.CreateMutable(RubyEncoding.ClassName);
            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 #10
0
 public static RubyArray Coerce(RubyContext/*!*/ context, BigInteger/*!*/ self, object other) {
     throw RubyExceptions.CreateTypeError(String.Format("can't coerce {0} to Bignum", context.GetClassDisplayName(other)));
 }
Example #11
0
 public static Exception /*!*/ CreateUnexpectedTypeError(RubyContext /*!*/ context, object param, string /*!*/ type)
 {
     return(CreateTypeError("wrong argument type {0} (expected {1})", context.GetClassDisplayName(param), type));
 }
Example #12
0
 public override string GetObjectTypeName(object arg)
 {
     return(_context.GetClassDisplayName(arg));
 }
Example #13
0
 public static Node ToYamlNode(RubyContext /*!*/ context, object self, RubyRepresenter rep)
 {
     throw RubyExceptions.CreateTypeError("can't dump anonymous class " + context.GetClassDisplayName(self));
 }
Example #14
0
 internal static string /*!*/ ConvertToFieldName(RubyContext /*!*/ context, object name)
 {
     // MRI doesn't use a dynamic conversion:
     if (name is RubySymbol || name is MutableString)
     {
         return(name.ToString());
     }
     else
     {
         throw RubyExceptions.CreateTypeError("unexpected type {0}, expected Symbol or String", context.GetClassDisplayName(name));
     }
 }