cgen.py, templates: use new `_CompoundOp` for structure fields
This patch adds the `_CompoundOp` class which inherits `_Op`. It also
makes `_AlignOp` and `_WriteOp` inherit a new `_LeadOf` class. The final
operation class hierarchy is:
_Op
_CompoundOp
_LeafOp
_AlignOp
_WriteOp
A compound operation is a simple container of suboperations (compound or
leaf). It is expected that a compound field type leads to a compound
operation.
As of this version, the only "real" compound field type is the structure
field type.
`_OpsBuilder` becomes `_OpBuilder` and does not accumulate operations
anymore: it still has a state, but its build_for_root_ft() method
returns a `_CompoundOp` object for a given root structure field type.
The returned compound operation can contain an "align" operation for the
structure field itself as its first suboperation.
Because an `_OpBuilder` doesn't accumulate operations anymore, there's
no need to copy operations anymore.
For a structure field type, _OpBuilder._build_for_ft() returns a single
compound operation having the new serialization and size templates
`serialize-write-struct-statements.j2` and
`size-write-struct-statements.j2`. Those templates contain a C comment
and a simple loop to render the appropriate template for each
suboperation, forwarding the `stream_type` and `ev_type` context
variables.
`barectf.c.j2` is changed to render a single template for any compound
operation. This removes many loops.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
This page took 0.026239 seconds and 4 git commands to generate.