Skip to content

Commit

Permalink
Converted json generation using jansson and removed yajl imports
Browse files Browse the repository at this point in the history
Signed-off-by: Sourav Moitra <[email protected]>
  • Loading branch information
xw19 committed Nov 26, 2024
1 parent d8953ab commit 77b7264
Show file tree
Hide file tree
Showing 14 changed files with 306 additions and 1,466 deletions.
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

0 comments on commit 77b7264

Please sign in to comment.