commit | 5b3812671124153698c840422fafaf25545bfb1e | [log] [tgz] |
---|---|---|
author | Dmitri Prime <bolms@google.com> | Mon May 01 23:55:07 2023 -0700 |
committer | GitHub <noreply@github.com> | Mon May 01 23:55:07 2023 -0700 |
tree | da3ff1232be10508a4c8c0068d50e840d1a5c99d | |
parent | 053bd6c7203364ae6f796d71414a4dcf4672bd89 [diff] |
Factor back-end attribute checking into the back end. (#80) Factor back-end attribute checking into the back end. This change splits up `front_end/attribute_checker.py`, moving the generic parts to a new file `util/attribute_util.py`, and moving the back-end-specific parts to `back_end/cpp/header_generator.py`. Some tests from `front_end/attribute_checker_test.py` were moved to a new test suite, `header_generator_test.py`. There should probably be a `util/attribute_checker_test.py`, but for now the old tests provide sufficient coverage. As a result of moving some attribute checking into the back end, `generate_header()` can now return errors. A future change should convert some of the `assert` statements in the same file into error returns. In order for the `emboss_codegen_cpp.py` driver to properly display errors, the original source code of the `.emb` is now included verbatim in the IR, increasing the IR size by about 3%. This change does still enforce some minimal checking of back end attributes: the back end must be listed in the new `[expected_back_ends]` attribute (default value `"cpp"`), or it is considered to be an error. This change does not document the `[expected_back_ends]` attribute because it is not currently useful for end users.
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.