symforce.codegen.types_package_codegen module#
- class TypesCodegenData(package_name: str, values_indices: Mapping[str, Dict[str, symforce.values.index_entry.IndexEntry]], shared_types: Mapping[str, str] | NoneType, scalar_type: str, output_dir: pathlib.Path, lcm_type_dir: pathlib.Path, lcm_bindings_output_dir: str | os.PathLike | NoneType, lcm_files: List[str], types_dict: Dict[str, Dict[str, Any]], typenames_dict: Dict[str, str], namespaces_dict: Dict[str, str], lcm_bindings_dirs: symforce.codegen.codegen_util.LcmBindingsDirs | NoneType = None)[source]#
Bases:
object
- Parameters:
package_name (str) –
values_indices (Mapping[str, Dict[str, IndexEntry]]) –
scalar_type (str) –
output_dir (Path) –
lcm_type_dir (Path) –
lcm_bindings_dirs (LcmBindingsDirs | None) –
- lcm_bindings_dirs: LcmBindingsDirs | None = None#
- 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 (Mapping[str, str] | None) –
Used to specify whether specific types and subtypes have already been generated, either externally or internally (e.g. 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 (str | PathLike | None) – Where to output the files.
.lcm
files are output inoutput_dir/lcmtypes
, and language-specific implementations are generated inoutput_dir/package_name
.lcm_bindings_output_dir (str | PathLike | None) – Where to output language-specific LCM bindings. Defaults to
output_dir
templates (TemplateList | None) – 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:
- 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
.
- typename_from_key(key, shared_types)[source]#
Compute a typename from a key, or from shared_types if provided by the user.
- get_subvalues_from_list_index(list_index)[source]#
Returns index of
Values
object if base element of list is aValues
object, otherwise returnsNone
.- Parameters:
list_index (Dict[str, IndexEntry]) –
- Return type:
Dict[str, IndexEntry] | None