Add an equivalence test for the optimized Ok() method (#280) The C++ back end rewrites the per-field Ok() checks of conditional fields that share a discriminant into a switch, and gates residual arms on the residual predicate alone. There is no option to emit the unoptimized form, so this test pins Ok() to an independent reference written directly from its definition: the structure is complete, and every field's existence is Known and, when present, the field is Ok(). Every structure with a conditional discriminant in condition.emb, plus LargeConditionals, DisjunctionConditionals and OuterGuardedUnion from many_conditionals.emb, is checked at every buffer length from zero to its full size. The bytes that existence conditions read take every value; the remaining payload bytes take two fill patterns; the four-byte discriminants are sampled over every arm, the gaps between arms and the top of the range, as documented in the test. Each test also asserts the number of buffers it checked, so the enumeration cannot shrink unnoticed. Compiled against headers regenerated with earlier generators and the same schema, the test fails on the master generator (ResidualConditional-, DisjunctionConditional- and EnumConditionalDiscriminant: a buffer with `outer != 1` is wrongly rejected) and passes from the guard-demotion fix onwards.
Emboss is a tool for generating code that reads and writes binary data structures. It is designed to help write code that communicates with hardware devices such as GPS receivers, LIDAR scanners, or actuators.
Emboss takes specifications of binary data structures, and produces code that will efficiently and safely read and write those structures.
Currently, Emboss only generates C++ code, but the compiler is structured so that writing new back ends is relatively easy -- contact emboss-dev@google.com if you think Emboss would be useful, but your project uses a different language.
If you're sitting down with a manual that looks something like this or this, Emboss is meant for you.
Emboss is not designed to handle text-based protocols; if you can use minicom or telnet to connect to your device, and manually enter commands and see responses, Emboss probably won't help you.
Emboss is intended for cases where you do not control the data format. If you are defining your own format, you may be better off using Protocol Buffers or Cap'n Proto or BSON or some similar system.
In C++, packed structs are most common method of dealing with these kinds of structures; however, they have a number of drawbacks compared to Emboss views:
Emboss does not help you transmit data over a wire -- you must use something else to actually transmit bytes back and forth. This is partly because there are too many possible ways of communicating with devices, but also because it allows you to manipulate structures independently of where they came from or where they are going.
Emboss does not help you interpret your data, or implement any kind of higher-level logic. It is strictly meant to help you turn bit patterns into something suitable for your programming language to handle.
Emboss is currently under development. While it should be entirely ready for many data formats, it may still be missing features. If you find something that Emboss can't handle, please contact emboss-dev@google.com to see if and when support can be added.
Emboss is not an officially supported Google product: while the Emboss authors will try to answer feature requests, bug reports, and questions, there is no SLA (service level agreement).
Head over to the User Guide to get started.