Skip to content

Commit

Permalink
Merge pull request #127 from giuseppe/pack-present-tags
Browse files Browse the repository at this point in the history
libocispec: write _present tags together
  • Loading branch information
giuseppe authored May 11, 2023
2 parents 996bccc + 2c9fb39 commit c25972b
Showing 1 changed file with 7 additions and 2 deletions.
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

0 comments on commit c25972b

Please sign in to comment.