Skip to content

Commit

Permalink
Fix issue with having arrays in base classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob-carlborg committed Mar 28, 2013
1 parent c8f018b commit 9c63266
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 5 additions & 2 deletions orange/serialization/Serializer.d
Original file line number Diff line number Diff line change
Expand Up @@ -844,8 +844,11 @@ class Serializer
auto array = Array(value.ptr, value.length, ElementTypeOfArray!(T).sizeof);

archive.archiveArray(array, arrayToString!(T), key, id, {
foreach (i, e ; value)
serializeInternal(e, toData(i));
for (size_t i = 0; i < value.length; i++)
{
const e = value[i];
serializeInternal(e, toData(i));
}
});

if (value.length > 0)
Expand Down
2 changes: 2 additions & 0 deletions tests/BaseClass.d
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ XmlArchive!(char) archive;
class Base
{
int a;
int[] c;

int getA ()
{
Expand Down Expand Up @@ -62,6 +63,7 @@ unittest
assert(archive.data().containsXmlTag("int", `key="b" id="1"`, "4"));
assert(archive.data().containsXmlTag("base", `type="tests.BaseClass.Base" key="1" id="2"`));
assert(archive.data().containsXmlTag("int", `key="a" id="3"`, "3"));
assert(archive.data().containsXmlTag("array", `type="inout(int)" length="0" key="c" id="4"`, true));
};
};

Expand Down

0 comments on commit 9c63266

Please sign in to comment.