Stage 2 is now working except for some details. An extended example is given below. This version still doesn't handle pointers. Or functions..
The committed code fails in a couple of cases. In particular serialisation of top level "int" type doesn't work! This is because the standard library contains pre-built shape (RTTI) objects for a some important types, including "int", and those shapes don't have encode/decode functions installed in them. Will be fixed! See src/rtl/flx_rtl.[ch]pp. Serialisation causes the compiler to emit code for all shapes it can. This bogs down the C++ compilation for all code. I plan to fix this with an interesting technique I've not used before. The Felix resource manager allows you to write: fun f: int -> int requires header "#include <someheader.h>"; So if you use f, then the header gets included. I plan to do this: fun decoder: gc_shape_t -> decoder_t = "$1->decoder" requires header "#define FLX_SERIALISATION" ; Then, the Felix compiler will wrap the decoder and encoder functions in #ifdef FLX_SERIALISATION ... #endif and for the shapes something like: #ifdef FLX_SERIALSATION myencoder, #else 0, #endif although I'll probably use a macro: #ifdef FLX_SERIALISATION #define FLX_ENCODER (x) x #else #define FLX_ENCODER 0 #endif so I can just write: FLX_ENCODER(myencoder), which is a bit shorter. The effect will be that serialisation will only be enabled if (a) You use it (b) you specify -DFLX_SERIALISATION on the flx (or C++ compiler) command line Using the resource manager to effect conditional inclusion is old hat. Using it to effect conditional compilation is a new hat! The -D switch is vital, if you're making a plugin, because even if you don't do any serialisation in the plugin, the client of the plugin may do so. It's tempting to reverse the polarity of the switch, so you get serialisation by default, unless you turn it off to improve compile times. However I don't see how to make that work nicely with the resource manager (since the technique is to default off, and enable on use). If anyone can think of a safe method that avoids compiler time overheads I'd love to hear: the plugin case shows the default OFF isn't safe. Note of course the macro can be defined IN the code as well, so you can always force serialisation in a plugin. -- john skaller skal...@users.sourceforge.net http://felix-lang.org ------------------------------------------------------------------------------ Free Next-Gen Firewall Hardware Offer Buy your Sophos next-gen firewall before the end March 2013 and get the hardware for free! Learn more. http://p.sf.net/sfu/sophos-d2d-feb _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language