Last active
March 25, 2017 22:58
-
-
Save jerstlouis/80ddfcca3e3fe485a81e8520c83eb841 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "ecere" | |
class Unit | |
{ | |
String name; | |
public property const String name | |
{ | |
set { delete name; name = CopyString(value); } | |
get { return name; } | |
} | |
~Unit() { delete name; } | |
} | |
class Peasant : Unit { } | |
class King : Unit { } | |
class Knight : Unit { } | |
class Dragon : Unit { } | |
class Game | |
{ | |
public Array<Unit> units; | |
~Game() | |
{ | |
if(units) units.Free(); | |
delete units; | |
} | |
} | |
class App : Application | |
{ | |
void Main() | |
{ | |
Game game | |
{ { [ | |
King { name = "Arthur" }, | |
Peasant { name = "Pyp" }, | |
Peasant { name = "Eleanor" }, | |
Dragon { name = "Smaug" } | |
] } }; | |
ECONParser parser { }; | |
File f = FileOpen("units.econ", write); | |
if(f) | |
{ | |
WriteECONObject(f, game._class, game, 0); | |
delete f; | |
} | |
delete game; | |
f = FileOpen("units.econ", read); | |
if(f) | |
{ | |
parser.f = f; | |
parser.GetObject(class(Game), &game); | |
PrintLn(game); | |
delete f; | |
} | |
delete game; | |
delete parser; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment