ivansafrin/Polycode — pull request #123 by mcclure (2012-07-29 20:12:22+00:00)
Title: XML fixes: support TYPE_ARRAY objects, fix comment crash

Fixes these problems with the Object and XML handling:

- Currently, TYPE_ARRAY objects are broken, both in serialization and deserialization. In the deserialization code, arrays are recognized incorrectly; effectively ANY container with two children becomes an array. The deserialization case is unimplemented.
- Currently, TiXmlElement::toElement() is used throughout the code without checking. toElement() can return NULL, for example in the presence of a comment. This means the presence of an xml comment in an object or material file will usually cause a segfault.
- Currently, it is impossible to represent any of the following things in the object format: An empty array; a one-element array; a nil string.

I address these problems by:

- Supporting a special attribute/element name "nil" which corresponds to an ObjectEntry with no name.
- Supporting special namespaces like "polyarray", "polystring" etc which force a loaded ObjectEntry to a particular type.
- Using the above two items to create an array serializer.
- Fixing the old array deserialization case to set array type in the case of successive repeated items (or the first item being nil) instead of setting it for all containers.

I tested this by creating several Objects and serializing and deserializing them.