Transformations¶
These are Yace Interface Definition transformations, transforming the loaded definitions into a different representation, this is usually done in order to produce an equivalent model with a representation better suited for emitting code.
E.g. symbols are snake_case in Yace Files, however, when emitting Rust or Python code, then it is very useful to have this transformed to CamelCase. By doings so at the IR-level, then the code-emitters need not concern inself with UPPERCASE/lowercase/snake_case/camelCase/PascalCase etc. this makes emitters a lot simpler.
Also, at the IR-level, then coding-conventions such as CamelCase can be shared by multiple targets.
- class yace.transformations.CStyle(model)¶
Transform symbols:
yace.ir.constants.Define
-> upper()yace.ir.constants.EnumValue
-> upper()
This transformation assumes a valid Yace-file according to the linter. Thus, the symbols are all lower-snake_case, and transformation not described above is not performed.
- visit(current, ancestors, depth)¶
…
- class yace.transformations.Camelizer(model)¶
Transform symbols:
Enum -> camelize()
EnumValue -> upper()
Struct|Enum|Bitfield -> camelize()
Additionally, then Enum / Struct / Union is added “postfix” to
entity.sym
. This is done for non-C languages, as enum/struct/union C-types rarely has equivalents in “foreign” languages. Rather, these are objects with subclasses encapsulating them, e.g. the Python ctypes.Thus, the Enum/Struct/Union needs to be added to the identifier, since it will otherwise potentially collide with other entities.
This transformation assumes a valid Yace-file according to the linter. Thus, the symbols are all lower-snake_case, and transformation not described above is not performed.
- visit(current, ancestors, depth)¶
This is the thing which class should implement
- class yace.transformations.HoistAnonMembers(model)¶
Extract nested entities, that is, struct/union/bitfield which from nested to top-level declaration, leaving behind a replace of the entity with a field with a typespec matching the extracted entity
- visit(current, ancestors, depth)¶
This is the thing which class should implement