billyquith / ponder

C++ reflection library with Lua binding, and JSON and XML serialisation.
http://billyquith.github.io/ponder/
Other
633 stars 92 forks source link

Bad data when serializing an Array #90

Closed EvilPotat0 closed 6 years ago

EvilPotat0 commented 6 years ago

When I try to serialize the following I get invalid values for the array

Class A { public: A() { arrayTest[0] = 1; arrayTest[1] = 2; arrayTest[2] = 3; arrayTest[3] = 4; arrayTest[4] = 5; arrayTest[5] = 6; } int arrayTest[6]; } PONDER_TYPE(A) void Declare() { ponder::Class::declare() .constructor() .property("arrayTest", &A::arrayTest); }

I'm using the serialize function in ponder-xml/common.hpp and I get the following xml for the array:

0 -842150451 -842150451 -842150451 -842150451 -842150451

I think the get for index 0 returns the memory offset from the object to the start of the array and the rest is all bogus. If I do the same thing but with std::vector it works fine and I get the expected xml output.

Maybe I just have something setup incorrectly but everything else seems fine it's just normal arrays I seem to be having issues with. Any help would be much appreciated.

billyquith commented 6 years ago

Hi. TBH I haven't used the XML serialisation.

Someone has done some fixes in a branch of Ponder. You could look there. I intend to refactor it at some point but busy at the moment.

I guess converting/wrapping the static array as std::array would be the way to go.

billyquith commented 6 years ago

Closing as fixed in #43