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

libocispec: write _present tags together #127

Merged
merged 1 commit into from
May 11, 2023
Merged
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
9 changes: 7 additions & 2 deletions src/ocispec/headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,20 @@ def append_type_c_header(obj, header, prefix):
header.write("typedef struct {\n")
if obj.children is None:
header.write(" char unuseful; // unuseful definition to avoid empty struct\n")
present_tags = []
for i in obj.children or []:
if helpers.judge_data_type(i.typ) or i.typ == 'boolean':
present_tags.append(" unsigned int %s_present : 1;\n" % (i.fixname))
if i.typ == 'array':
append_header_child_arr(i, header, prefix)
else:
append_header_child_others(i, header, prefix)
if helpers.judge_data_type(i.typ) or i.typ == 'boolean':
header.write(" unsigned int %s_present : 1;\n" % (i.fixname))
if obj.children is not None:
header.write(" yajl_val _residual;\n")
if len(present_tags) > 0:
header.write("\n")
for tag in present_tags:
header.write(tag)
typename = helpers.get_prefixed_name(obj.name, prefix)
header.write("}\n%s;\n\n" % typename)
header.write("void free_%s (%s *ptr);\n\n" % (typename, typename))
Expand Down