I'm trying to find a "meta language" that can be used to define a structure and get/set code for members. The catch is that the structure already exists in code, and this "meta language" would serve as bit-for-bit replacement of the original hand-coded structure to allow the headers describing the structures to be generated. The point is that the structures are used as part of a protocol between a C# application and an embedded device (not linux based, think smaller and more constrained like a PIC or CM0.) The meta language would act as
- Documentation for the structure members
- Generate C# structs and implementation for get/set operations
- Generate packed ANSI-C structs and get/set functions
The meta language would need to support
- enumeration definitions (of a specified size - ie uint16_t, uint8_t, or smaller as for multi-bit enumerations)
- bit-arrays (of specified size - ie 48-bit array is packed into 6 bytes,)
- bit-structure/enumeration arrays (of specified size - ie a 2-bit structure of 48 indexes is 12 bytes,)
- specification for endianness and bit-order,
- generate binary structures that can be read directly by either the generated ANSI-C code or the C-sharp code for the purpose of sending over a network.
It would also be nice to have some limited validation of the data when received.
So far I've looked at
- BSON
- Etch
- Hessian Avro
- ICE
- MessagePack
- Protocol Buffers
- Thrift
All of these are great for documentation and when building a new protocol, but trying to maintain compatibility with an existing protocol and these fall short due to the type encoding inherent in the data marshaling.
I've also looked at ASN.1 for ECN encoding, but that seems to be too unreadable causing issue with Documentation.
I've looked at Generating C# structure from C structure but there wasn't a good option there.
Any recommendations?