private RubyStruct /*!*/ ReadStruct()
{
RubyStruct obj = (UnmarshalNewObject() as RubyStruct);
if (obj == null)
{
throw RubyExceptions.CreateArgumentError("non-initialized struct");
}
var names = obj.GetNames();
int count = ReadInt32();
if (count != names.Count)
{
throw RubyExceptions.CreateArgumentError("struct size differs");
}
for (int i = 0; i < count; i++)
{
string name = ReadIdentifier();
if (name != names[i])
{
RubyClass theClass = Context.GetClassOf(obj);
throw RubyExceptions.CreateTypeError("struct {0} not compatible ({1} for {2})", theClass.Name, name, names[i]);
}
obj[i] = ReadAnObject(false);
}
return(obj);
}