A simple use of the analysis framework

Ben Ellis bellis at alumni.virginia.edu
Thu Jun 4 01:10:40 EDT 2009


Hello all,

I've cobbled together a narrow example of using Language.C.Analysis:
generating descriptions of a limited class of structs (those whose
members are integral types, floating types, or structs in the limited
class) defined in the "typedef struct { ... } <name>;" form.

While the code isn't beautiful or particularly general, the class of
structs covered is helpful for code generation of data transfer
objects; i.e., it was this or hand-code a bunch of Java classes that
just read different offsets from a ByteBuffer ;)  This is a real-world
use case which, unautomated, is a real pain in the ass.

Imai Keigo's examples of Language.C helped me a lot by demonstrating
Data.Generics; I hope that reading this example might help someone
else wade through the many data types in analysis output.  All the
other examples of Language.C.Analysis (all 2 of them) don't
destructure the analysis output nearly as much as mine-- which is
probably why they are so much more elegant :)

I welcome any comments or suggestions on better ways to achieve the
goal, especially ones that make the code less ugly.

Ben Ellis
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PlainStruct.lhs
Type: application/octet-stream
Size: 6540 bytes
Desc: not available
Url : http://projects.haskell.org/pipermail/language-c/attachments/20090604/362b2adb/attachment.obj 


More information about the Language-c mailing list