symforce.codegen.types_package_codegen module

class TypesCodegenData(package_name, values_indices, shared_types, scalar_type, output_dir, lcm_type_dir, lcm_bindings_output_dir, lcm_files, types_dict, typenames_dict, namespaces_dict, lcm_bindings_dirs=None)[source]

Bases: object

Parameters:
  • package_name (str) –

  • values_indices (Mapping[str, Dict[str, IndexEntry]]) –

  • shared_types (Optional[Mapping[str, str]]) –

  • scalar_type (str) –

  • output_dir (Path) –

  • lcm_type_dir (Path) –

  • lcm_bindings_output_dir (Union[str, PathLike, None]) –

  • lcm_files (List[str]) –

  • types_dict (Dict[str, Dict[str, Any]]) –

  • typenames_dict (Dict[str, str]) –

  • namespaces_dict (Dict[str, str]) –

  • lcm_bindings_dirs (Optional[LcmBindingsDirs]) –

package_name: str
values_indices: Mapping[str, Dict[str, IndexEntry]]
shared_types: Optional[Mapping[str, str]]
scalar_type: str
output_dir: Path
lcm_type_dir: Path
lcm_bindings_output_dir: Optional[Union[str, PathLike]]
lcm_files: List[str]
types_dict: Dict[str, Dict[str, Any]]
typenames_dict: Dict[str, str]
namespaces_dict: Dict[str, str]
lcm_bindings_dirs: Optional[LcmBindingsDirs] = None
__init__(package_name, values_indices, shared_types, scalar_type, output_dir, lcm_type_dir, lcm_bindings_output_dir, lcm_files, types_dict, typenames_dict, namespaces_dict, lcm_bindings_dirs=None)
Parameters:
  • package_name (str) –

  • values_indices (Mapping[str, Dict[str, IndexEntry]]) –

  • shared_types (Optional[Mapping[str, str]]) –

  • scalar_type (str) –

  • output_dir (Path) –

  • lcm_type_dir (Path) –

  • lcm_bindings_output_dir (Union[str, PathLike, None]) –

  • lcm_files (List[str]) –

  • types_dict (Dict[str, Dict[str, Any]]) –

  • typenames_dict (Dict[str, str]) –

  • namespaces_dict (Dict[str, str]) –

  • lcm_bindings_dirs (Optional[LcmBindingsDirs]) –

generate_types(package_name, file_name, values_indices, use_eigen_types, shared_types=None, scalar_type='double', output_dir=None, lcm_bindings_output_dir=None, templates=None)[source]

Generates LCM types from the given values_indices, including the necessary subtypes and references to external LCM types.

Parameters:
  • package_name (str) – Package of LCM types to be generated

  • file_name (str) – Name of the LCM file to generate (without the extension)

  • values_indices (Mapping[str, Dict[str, IndexEntry]]) – Mapping between the name each LCM type to be generated and its index (computed using Values.index())

  • shared_types (Optional[Mapping[str, str]]) –

    Used to specify whether specific types and subtypes have already been generated, either externally or internally (i.e. if one generated type is to represent multiple objects in values_indices). Usage examples:

    shared_types={“my_values””external_package.my_values”} (Reuse the implementation of “my_values” defined in package

    ”external_package”, meaning that “my_values” as defined in values_indices will not be generated. Note that “external_package” can equal package_name, e.g. when generating multiple functions in the same package which reuse the same types)

    shared_types={“my_values.V1””my_subvalues_t”, “my_values.V2””my_subvalues_t”} (Only generate one type named

    ”my_subvalues_t” to represent Values objects defined by “my_values.V1” and “my_values.V2”.

  • scalar_type (str) – Type of scalars used in LCM type definition

  • output_dir (Union[str, PathLike, None]) – Where to output the files. “.lcm” files are output in “output_dir/lcmtypes”, and language-specific implementations are generated in “output_dir/package_name”.

  • lcm_bindings_output_dir (Union[str, PathLike, None]) – Where to output language-specific LCM bindings. Defaults to output_dir

  • templates (Optional[TemplateList]) – TemplateList used if types are being generated as part of a larger code generation (e.g. when generating the types required by a generated function). If None, we generate both the “.lcm” files and the language-specific implementations, else we assume the templates and language-specific type implementations will be rendered in an external function.

  • use_eigen_types (bool) –

Return type:

TypesCodegenData

build_types_dict(package_name, values_indices, shared_types=None)[source]

Compute the structure of the types we need to generate for the given Values.

Parameters:
  • package_name (str) –

  • values_indices (Mapping[str, Dict[str, IndexEntry]]) –

  • shared_types (Optional[Mapping[str, str]]) –

Return type:

Dict[str, Dict[str, Any]]

typename_from_key(key, shared_types)[source]

Compute a typename from a key, or from shared_types if provided by the user.

Parameters:
  • key (str) –

  • shared_types (Mapping[str, str]) –

Return type:

str

get_subvalues_from_list_index(list_index)[source]

Returns index of Values object if base element of list is a Values object, otherwise returns None

Parameters:

list_index (Dict[str, IndexEntry]) –

Return type:

Optional[Dict[str, IndexEntry]]