ifgen.struct package — docs

Skip to main content
`Ctrl`+`K`

# ifgen.struct package

## Subpackages

- ifgen.struct.methods package
  - Subpackages
    - ifgen.struct.methods.fields package
      - Submodules
      - ifgen.struct.methods.fields.common module
      - ifgen.struct.methods.fields.getter module
      - ifgen.struct.methods.fields.setter module
      - Module contents
  - Submodules
  - ifgen.struct.methods.bit module
    - `bit_field_toggle_method()`
    - `clear_bit_method()`
    - `handle_description()`
    - `set_bit_method()`
  - ifgen.struct.methods.common module
    - `swap_fields()`
  - Module contents
    - `decode_endian()`
    - `encode_endian()`
    - `endian_str()`
    - `handle_endian()`
    - `protocol_json()`
    - `span_method()`
    - `struct_buffer_method()`
    - `struct_methods()`
- ifgen.struct.python package
  - Module contents
    - `cpp_ns_final()`
    - `python_dependencies()`
    - `python_enums_structs()`
    - `python_struct_field()`
    - `python_struct_fields()`
    - `python_struct_header()`

## Submodules

## ifgen.struct.header module

A module implementing a struct header-file interface generator.

ifgen.struct.header.cpp_struct_header(task: GenerateTask, writer: IndentedFileWriter) → None

  Create the contents of a C++ struct header file.

ifgen.struct.header.enforce_expected_size(size: int, data: dict[str, Any], assert_msg: str) → None

  Enforce an expected-size field.

ifgen.struct.header.struct_fields(task: GenerateTask, writer: IndentedFileWriter) → None

  Generate struct fields.

ifgen.struct.header.struct_header(task: GenerateTask, writer: IndentedFileWriter) → None

  Create the contents of a struct header file.

ifgen.struct.header.struct_instance(task: GenerateTask, writer: IndentedFileWriter, instance: dict[str, Any]) → None

  Generate struct instances.

ifgen.struct.header.struct_line(name: str, value: dict[str, int | str], volatile: bool, const: bool, packed: bool, array_length: int = None, default: str = None) → tuple[str, str | None]

  Build a string for a struct-field line.

## ifgen.struct.stream module

A module for implementing struct stream-related methods.

ifgen.struct.stream.struct_istream(task: GenerateTask, writer: IndentedFileWriter) → None

  Generate an input-stream handling method.

ifgen.struct.stream.struct_ostream(task: GenerateTask, writer: IndentedFileWriter) → None

  Generate an output-stream handling method.

ifgen.struct.stream.struct_stream_methods(task: GenerateTask, writer: IndentedFileWriter) → None

  Generate struct stream read and write methods.

## ifgen.struct.test module

A module implementing a unit-test output generator for structs.

ifgen.struct.test.assert_line(writer: IndentedFileWriter, data: str) → None

  Write an assert line to the file.

ifgen.struct.test.create_struct_test(task: GenerateTask) → None

  Create a unit test for the enum string-conversion methods.

ifgen.struct.test.unit_test_basic_method(task: GenerateTask, writer: IndentedFileWriter) → None

  Implement a simple encode-and-decode scenario with endianness as a function argument.

ifgen.struct.test.unit_test_body(task: GenerateTask, writer: IndentedFileWriter) → None

  Implement a unit test for a struct.

ifgen.struct.test.unit_test_stream_tests(task: GenerateTask, writer: IndentedFileWriter) → None

  Generate unit tests for stream interfaces.

## ifgen.struct.util module

Utility interfaces related to struct code generation.

ifgen.struct.util.struct_dependencies(task: GenerateTask) → set[str]

  Generates string type names for dependencies.

## Module contents

A module implementing interfaces for struct-file generation.

ifgen.struct.create_struct(task: GenerateTask) → None

  Create a header file based on a struct definition.

ifgen.struct.create_struct_test(task: GenerateTask) → None

  Create a unit test for the enum string-conversion methods.