示例#1
0
            private void WriteString(MutableString /*!*/ value)
            {
                SubclassData instanceWriter = new SubclassData(this, value, typeof(MutableString));

                _writer.Write((byte)'"');
                WriteStringValue(value);
            }
示例#2
0
            private void WriteRegex(RubyRegex /*!*/ value)
            {
                SubclassData instanceWriter = new SubclassData(this, value, typeof(RubyRegex));

                _writer.Write((byte)'/');
                WriteStringValue(value.GetPattern());
                _writer.Write((byte)value.Options);
            }
示例#3
0
            private void WriteArray(RubyArray /*!*/ value)
            {
                SubclassData instanceWriter = new SubclassData(this, value, typeof(RubyArray));

                _writer.Write((byte)'[');
                WriteInt32(value.Count);
                foreach (object obj in value)
                {
                    WriteAnObject(obj);
                }
            }
示例#4
0
            private void WriteStruct(RubyStruct /*!*/ obj)
            {
                SubclassData instanceWriter = new SubclassData(this, obj, typeof(RubyStruct));

                _writer.Write((byte)'S');
                RubyClass theClass = _context.GetClassOf(obj);

                TestForAnonymous(theClass);
                WriteSymbol(theClass.Name);
                var names = obj.GetNames();

                WriteInt32(names.Count);
                foreach (string name in names)
                {
                    int index = obj.GetIndex(name);
                    WriteSymbol(name);
                    WriteAnObject(obj[index]);
                }
            }
示例#5
0
            private void WriteHash(Hash /*!*/ value)
            {
                if (value.DefaultProc != null)
                {
                    throw RubyExceptions.CreateTypeError("can't dump hash with default proc");
                }

                SubclassData instanceWriter = new SubclassData(this, value, typeof(Hash));
                char         typeFlag       = (value.DefaultValue != null) ? '}' : '{';

                _writer.Write((byte)typeFlag);
                WriteInt32(value.Count);
                foreach (KeyValuePair <object, object> pair in value)
                {
                    WriteAnObject(pair.Key);
                    WriteAnObject(pair.Value);
                }
                if (value.DefaultValue != null)
                {
                    WriteAnObject(value.DefaultValue);
                }
            }
示例#6
0
 private void WriteStruct(RubyStruct/*!*/ obj) {
     SubclassData instanceWriter = new SubclassData(this, obj, typeof(RubyStruct));
     _writer.Write((byte)'S');
     RubyClass theClass = _context.GetClassOf(obj);
     TestForAnonymous(theClass);
     WriteSymbol(theClass.Name);
     var names = obj.GetNames();
     WriteInt32(names.Count);
     foreach (string name in names) {
         int index = obj.GetIndex(name);
         WriteSymbol(name);
         WriteAnObject(obj[index]);
     }
 }
示例#7
0
            private void WriteHash(Hash/*!*/ value) {
                if (value.DefaultProc != null) {
                    throw RubyExceptions.CreateTypeError("can't dump hash with default proc");
                }

                SubclassData instanceWriter = new SubclassData(this, value, typeof(Hash));
                char typeFlag = (value.DefaultValue != null) ? '}' : '{';
                _writer.Write((byte)typeFlag);
                WriteInt32(value.Count);
                foreach (KeyValuePair<object, object> pair in value) {
                    WriteAnObject(pair.Key);
                    WriteAnObject(pair.Value);
                }
                if (value.DefaultValue != null) {
                    WriteAnObject(value.DefaultValue);
                }
            }
示例#8
0
 private void WriteArray(RubyArray/*!*/ value) {
     SubclassData instanceWriter = new SubclassData(this, value, typeof(RubyArray));
     _writer.Write((byte)'[');
     WriteInt32(value.Count);
     foreach (object obj in value) {
         WriteAnObject(obj);
     }
 }
示例#9
0
 private void WriteRegex(RubyRegex/*!*/ value) {
     SubclassData instanceWriter = new SubclassData(this, value, typeof(RubyRegex));
     _writer.Write((byte)'/');
     WriteStringValue(value.GetPattern());
     _writer.Write((byte)value.Options);
 }
示例#10
0
 private void WriteString(MutableString/*!*/ value) {
     SubclassData instanceWriter = new SubclassData(this, value, typeof(MutableString));
     _writer.Write((byte)'"');
     WriteStringValue(value);
 }