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

Converting json genration code to jansson #145

Merged
merged 2 commits into from
Nov 26, 2024
Merged
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
6 changes: 3 additions & 3 deletions src/ocispec/headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def append_type_c_header(obj, header, prefix):
header.append(f"void free_{typename} ({typename} *ptr);\n\n")
header.append(f"{typename} *clone_{typename} ({typename} *src);\n")
header.append(f"{typename} *make_{typename} (json_t *jtree, const struct parser_context *ctx, parser_error *err);\n\n")
header.append(f"yajl_gen_status gen_{typename} (yajl_gen g, const {typename} *ptr, const struct parser_context *ctx, parser_error *err);\n\n")
header.append(f"int gen_{typename} (json_t *root, const {typename} *ptr, parser_error *err);\n\n")

def header_reflect_top_array(obj, prefix, header):
c_typ = helpers.get_prefixed_pointer(obj.name, obj.subtyp, prefix) or \
Expand Down Expand Up @@ -206,7 +206,7 @@ def header_reflect_top_array(obj, prefix, header):
header.append(f"{typename} *{typename}_parse_data(const char *jsondata, const struct "\
"parser_context *ctx, parser_error *err);\n\n")
header.append(f"char *{typename}_generate_json(const {typename} *ptr, "\
"const struct parser_context *ctx, parser_error *err);\n\n")
"parser_error *err);\n\n")

def header_reflect(structs, schema_info, header):
'''
Expand Down Expand Up @@ -239,7 +239,7 @@ def header_reflect(structs, schema_info, header):
"parser_error *err);\n\n")
header.append(f"{prefix} *{prefix}_parse_data (const char *jsondata, const struct parser_context *ctx, "\
"parser_error *err);\n\n")
header.append(f"char *{prefix}_generate_json (const {prefix} *ptr, const struct parser_context *ctx, "\
header.append(f"char *{prefix}_generate_json (const {prefix} *ptr,"\
"parser_error *err);\n\n")
elif toptype == 'array':
header_reflect_top_array(structs[length - 1], prefix, header)
Expand Down
Loading
Loading