tasks a-s

This commit is contained in:
Ingy döt Net 2013-04-10 23:57:08 -07:00
parent 47bf37c096
commit b83f433714
12433 changed files with 156208 additions and 123 deletions

View file

@ -0,0 +1,50 @@
bundle Default {
class Thingy {
@id : Int;
New(id : Int) {
@id := id;
}
method : public : Print() ~ Nil {
@id->PrintLine();
}
}
class Person from Thingy {
@name : String;
New(id : Int, name : String) {
Parent(id);
@name := name;
}
method : public : Print() ~ Nil {
@id->PrintLine();
@name->PrintLine();
}
}
class Serial {
function : Main(args : String[]) ~ Nil {
t := Thingy->New(7);
p := Person->New(13, "Bush");
s := IO.Serializer->New();
s->Write(t->As(Base));
s->Write(p->As(Base));
writer := IO.FileWriter->New("objects.dat");
writer->WriteBuffer(s->Serialize());
writer->Close();
buffer := IO.FileReader->ReadBinaryFile("objects.dat");
d := IO.Deserializer->New(buffer);
t2 := d->ReadObject()->As(Thingy);
t2->Print();
p2 := d->ReadObject()->As(Person);
p2->Print();
}
}
}