HaxeDoc2

(やまだぃちぅ) #1

18 this.y = y;
19 }
20
21 @:keep
22 function hxSerialize(s:Serializer){
23 s.serialize(x);
24 }
25
26 @:keep
27 function hxUnserialize(u:Unserializer){
28 x = u.unserialize();
29 y = -1;
30 }
31 }


In this example we decide that we want to ignore the value of member variableyand do not
serialize it. Instead we default it to-1inhxUnserialize. Both methods are annotated with the
:keepmetadata to prevent dead code elimination (8.2) from removing them as they are never
properly referenced in the code.

10.7.1 Serialization format


Each supported value is translated to a distinct prefix character, followed by the necessary data.

null: n

Int: zfor zero, orifollowed by the integer itself (e.g.i456)

Float: NaN:k
negative infinity: m
positive infinity:p
normal Float:dfollowed by the float display (e.g.d1.45e-8)

Bool: tfortrue,fforfalse

String: yfollowed by the url encoded string length, then:and the url encoded string (e.g.
y10:hi%20there for "hi there"..

String(cached):Rfollowed by the string cache ID (e.g. R456). String caching is always en-
abled.

name-value pairs:a serialized string representing the namee, followed by the value

structure:ofollowed by the list of name-value pairs, followed byg(e.g.oy1:xi2y1:kngfor
{x:2, k:null})

List: lfollowed by the list of serialized items, followed byh(e.g.lnnhfor a list of twonull
values)

Array: afollowed by the list of serialized items, followed byh. For multiple consecutivenull
values,ufollowed by the number ofnullvalues is used (e.g. ai1i2u4i7ni9h for
[1,2,null,null,null,null,7,null,9])

Date: vfollowed by the date itself (e.g.d2010-01-01 12:45:10)
Free download pdf