Skip to content

Commit

Permalink
building, todo add smarter types for handling union selectors
Browse files Browse the repository at this point in the history
Signed-off-by: Bill Roberts <[email protected]>
  • Loading branch information
williamcroberts committed Feb 29, 2024
1 parent 63388a4 commit eb19dc2
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3,756 deletions.
11 changes: 11 additions & 0 deletions script/yaml_mu_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,14 @@ def parse(self) -> dict:
elif isinstance(node, pycparser.c_ast.Typedef):
if isinstance(node.type, pycparser.c_ast.TypeDecl):
type_name = node.name

# TODO TODO LOOK THOUGH THE constants (#defines) and:
# 1. if a type prefix has constants, associate it to that type
# 2. if a tyepe resolves somewhere along the line to something with a prefix, stop it there.
# Example: TPMI_ALG_HASH -> TPMI_ALG_ID

if type_name == "TPMI_ALG_HASH":
pass
# if type_name.startswith("TPM2B_"):
aliases = getattr(node.type.type, "names", None)
if aliases and type_name not in aliases:
Expand Down Expand Up @@ -1081,6 +1089,9 @@ def generate_protos(proj_root: str, needed_protos: list[str]):
cprsr, proj_root, "yaml-tpmt", "TPMT_", needed_protos, needed_leafs
)

# TODO generated leaf functions for UNIONS should unpack them and call the proper
# underlying method based on type.

# generate_union_code_gen(
# cprsr, proj_root, needed_protos, needed_leafs
# )
Expand Down
2 changes: 1 addition & 1 deletion src/tss2-mu-yaml/yaml-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static int yaml_add_str(yaml_document_t *doc, const char *str) {
\
char *x = calloc(1, MAX_CHARS); \
return_if_null(x, "Out of memory.", TSS2_MU_RC_MEMORY); \
snprintf(x, MAX_CHARS, fmt, in); \
snprintf(x, MAX_CHARS, "%"fmt, in); \
*out = x; \
return TSS2_RC_SUCCESS; \
}
Expand Down
Loading

0 comments on commit eb19dc2

Please sign in to comment.