HeapsIO / hxbit

Haxe Binary serialization and network synchronization library
155 stars 30 forks source link

Feature/custom serializable #13

Closed NuclearCookie closed 7 years ago

NuclearCookie commented 7 years ago

Addes support for custom serializable classes. Example included in readme page. Tested and works like a charm!

Fixes #10

ncannasse commented 7 years ago

Hi,

Thank you for the PR However I'm not much fan of the distinction between three interfaces Serializable/BaseSerializable/CustomSerializable.

Maybe another approach would be like this:

If the class has functions customSerialize and customUnserialize, call them at the end of serialize/unseriliaze (unless their are override, in which case our superclass will do for us).

This allow to mix some properties having @:s support and some others being custom-serialized, and still allow to subclass the class without disrupting the whole serialization.

NuclearCookie commented 7 years ago

Done. Much simpler indeed!

ncannasse commented 7 years ago

Nice ! out of curiosity, was @:keep in the documentation necessary ? since it's referenced from serialize/unserialize, it should not be required.

NuclearCookie commented 7 years ago

That's true. It might not have been necessary!