- SimpleAnimation *a(new SimpleAnimation);
- ReadSimpleAnimation(*a, *v.GetLiteral().GetProperties());
- return a;
- }
- } else if (animations.count(v.GetIdentifier())) {
- return animations[v.GetIdentifier()];
- } else if (source.IsDefined(v.GetIdentifier())) {
- ReadDefinition(source.GetDefinition(v.GetIdentifier()));
- if (animations.count(v.GetIdentifier())) {
- return animations[v.GetIdentifier()];
- } else {
- throw Error("cannot use " + source.GetDefinition(v.GetIdentifier()).Identifier() + " " + v.GetIdentifier() + " as animation");
+ int typeId(0), id(0);
+ switch (v.GetLiteral().GetType()) {
+ case Literal::ARRAY_VALUES:
+ throw Error("cannot copy value arrays, sorry");
+ break;
+ case Literal::ARRAY_PROPS:
+ throw Error("cannot copy property list arrays, sorry");
+ break;
+ case Literal::BOOLEAN:
+ {
+ typeId = TypeDescription::GetTypeId("Boolean");
+ id = values[typeId].size();
+ const TypeDescription &td(TypeDescription::Get(typeId));
+ char *object(new char[td.Size()]);
+ values[typeId].push_back(new (object) bool(v.GetLiteral().GetBoolean()));
+ }
+ break;
+ case Literal::COLOR:
+ {
+ typeId = TypeDescription::GetTypeId("Color");
+ id = values[typeId].size();
+ const TypeDescription &td(TypeDescription::Get(typeId));
+ char *object(new char[td.Size()]);
+ values[typeId].push_back(new (object) Color(v.GetLiteral().GetRed(), v.GetLiteral().GetGreen(), v.GetLiteral().GetBlue(), v.GetLiteral().GetAlpha()));
+ }
+ break;
+ case Literal::NUMBER:
+ {
+ typeId = TypeDescription::GetTypeId("Number");
+ id = values[typeId].size();
+ const TypeDescription &td(TypeDescription::Get(typeId));
+ char *object(new char[td.Size()]);
+ values[typeId].push_back(new (object) int(v.GetLiteral().GetNumber()));
+ }
+ break;
+ case Literal::PATH:
+ {
+ typeId = TypeDescription::GetTypeId("Path");
+ id = values[typeId].size();
+ char *str(new char[v.GetLiteral().GetString().size() + 1]);
+ std::memcpy(str, v.GetLiteral().GetString().c_str(), v.GetLiteral().GetString().size());
+ str[v.GetLiteral().GetString().size()] = '\0';
+ values[typeId].push_back(str);
+ }
+ break;
+ case Literal::STRING:
+ {
+ typeId = TypeDescription::GetTypeId("String");
+ id = values[typeId].size();
+ char *str(new char[v.GetLiteral().GetString().size() + 1]);
+ std::memcpy(str, v.GetLiteral().GetString().c_str(), v.GetLiteral().GetString().size());
+ str[v.GetLiteral().GetString().size()] = '\0';
+ values[typeId].push_back(str);
+ }
+ break;
+ case Literal::VECTOR:
+ {
+ typeId = TypeDescription::GetTypeId("Vector");
+ id = values[typeId].size();
+ const TypeDescription &td(TypeDescription::Get(typeId));
+ char *object(new char[td.Size()]);
+ values[typeId].push_back(new (object) Vector<int>(v.GetLiteral().GetX(), v.GetLiteral().GetY()));
+ }
+ break;
+ case Literal::OBJECT:
+ {
+ typeId = TypeDescription::GetTypeId(v.GetLiteral().GetTypeName());
+ const TypeDescription &td(TypeDescription::Get(typeId));
+ id = values[typeId].size();
+ char *object(new char[td.Size()]);
+ td.Construct(object);
+ ReadObject(typeId, id, object, *v.GetLiteral().GetProperties());
+ }
+ break;
+ }
+ return values[typeId][id];