I've now added a serialisation class with an encoding function. No decode yet.
This class ignores pointers, handling of that will come down the track. The big hassle here is that there are three cases: (a) It's a pod without an encoder: use bit-blit as the encoder. (b) It has a user specified encoder: use the encoder. (c) Abort the program At present the compiler does not generate encoders for structs etc. Doing this is a little tricky. Turns out it's easier to write code in Felix than Ocaml. Felix generates finalisers for non-pod's by simply calling the C++ destructor. If the type is an aggregate of pod's I have no idea what happens: to detect this requires recursive analysis of the structure (because it may contain other structures) and it's a pod if all the primitive leaves are POD's. If one of the components has a user specified finaliser, too bad! It will not be called! Finalisers only apply to top level objects. [That's a BUG really: workaround: make sure all finalisable objects are represented by pointers to heap objects] For serialisation the issue is more critical. A struct of ints and floats can be blitted but if there's just one string in there, the compiler has to generate blits for each non-string component and call the special string encoder for the string. It should do this for finalisers as well. This cannot be done at run time because the "tree" structure of structs is not represented (at the moment). Note that doing so would slow down the collector: having to traverse a tree to find pointers rather than current array of offsets is a huge difference (yea, we could do both, regard the offsets as an optimisation/cache). Also it will cause a heap of RTTI objects to be emitted. At present this the numbers are fairly limited. -- john skaller skal...@users.sourceforge.net http://felix-lang.org ------------------------------------------------------------------------------ Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_jan _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language