[erlang-questions] record2ei: automated ei decoding from Erlang records to C structs

Max Lapshin max.lapshin@REDACTED
Tue Dec 4 10:56:44 CET 2012

When you write a C port you may experience some problems with unpacking
erlang records, that were sent to port with term_to_binary/1

I thought that it would be very nice to write:

port_command(Port, term_to_binary(#trade_event{price = Price, volume = V}))

and then write in C:

struct trade_event *evt = read_trade_event(buf, &idx);
handle(evt->price, evt->volume);

So I've written https://github.com/maxlapshin/record2ei

This is a small and very dumb generator of C header and C source that
generates C structures and their encoding/decoding functions that calls
boilerplate code like  ei_decode_long or ei_encode_binary.

It is very limited, yet it helped to me.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20121204/93e76209/attachment.htm>

More information about the erlang-questions mailing list