Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add format_matrix_subscript_accessor and update_template_data to CodegenConfig #186

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion symforce/codegen/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,9 @@ def generate_function(
self.namespace = namespace

template_data = dict(self.common_data(), spec=self)
template_dir = self.config.template_dir()
self.config.update_template_data(data=template_data)

template_dir = self.config.template_dir()
backend_name = self.config.backend_name()
if skip_directory_nesting:
out_function_dir = output_dir
Expand Down
10 changes: 10 additions & 0 deletions symforce/codegen/codegen_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,13 @@ def format_eigen_lcm_accessor(key: str, i: int) -> str:
Format accessor for eigen_lcm types.
"""
pass

def update_template_data(self, data: T.Dict[str, T.Any]) -> None:
"""
Derived classes may override this to customize the "template data" dict. This dict
is passed to jinja at code-generation time.

Args:
data: Dict passed by Codegen. The function should modify this in-place.
"""
pass