Serialization can be used in order to store permanantly some runtime value. Serialization of all values is possible, except Abstracts, with the special cases of 'int32 and 'hash which are handled as specific cases.

Serialization of bytecode function is possible, but will result in a runtime exception when deserializing if the function offset in the bytecode has changed.

You can define the __serialize method of an object. When this method is found when serializing the object, it is called with no arguments and its return value will be serialized. The name of the module the method is declared in will also be serialized. When unserializing, the module is loaded and its __unserialize exported function is called with the value that was returned by __serialize.

string serialize(any) Serialize any value recursively any unserialize(string, #loader) Unserialize a stored value. Need a loader to look for modules if some bytecode functions have been serialized.

© 2019 Haxe Foundation | Contribute to this page