Skip to content

Commit

Permalink
ocispec: fix style
Browse files Browse the repository at this point in the history
Signed-off-by: Giuseppe Scrivano <[email protected]>
  • Loading branch information
giuseppe committed Sep 5, 2024
1 parent 7b27d0a commit d371222
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 20 deletions.
8 changes: 4 additions & 4 deletions src/ocispec/headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,13 @@ def header_reflect(structs, schema_info, header):
length = len(structs)
toptype = structs[length - 1].typ if length != 0 else ""
if toptype == 'object':
header.append(f"{prefix} *{prefix}_parse_file(const char *filename, const struct parser_context *ctx, "\
header.append(f"{prefix} *{prefix}_parse_file (const char *filename, const struct parser_context *ctx, "\
"parser_error *err);\n\n")
header.append(f"{prefix} *{prefix}_parse_file_stream(FILE *stream, const struct parser_context *ctx, "\
header.append(f"{prefix} *{prefix}_parse_file_stream (FILE *stream, const struct parser_context *ctx, "\
"parser_error *err);\n\n")
header.append(f"{prefix} *{prefix}_parse_data(const char *jsondata, const struct parser_context *ctx, "\
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, const struct parser_context *ctx, "\
"parser_error *err);\n\n")
elif toptype == 'array':
header_reflect_top_array(structs[length - 1], prefix, header)
Expand Down
24 changes: 16 additions & 8 deletions src/ocispec/json_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,8 @@ free_json_map_int_int (json_map_int_int *map)

define_cleaner_function (json_map_int_int *, free_json_map_int_int)

json_map_int_int *make_json_map_int_int (yajl_val src, const struct parser_context *ctx, parser_error *err)
json_map_int_int *
make_json_map_int_int (yajl_val src, const struct parser_context *ctx, parser_error *err)
{
__auto_cleanup (free_json_map_int_int) json_map_int_int *ret = NULL;
size_t i;
Expand Down Expand Up @@ -689,7 +690,8 @@ free_json_map_int_bool (json_map_int_bool *map)

define_cleaner_function (json_map_int_bool *, free_json_map_int_bool)

json_map_int_bool *make_json_map_int_bool (yajl_val src, const struct parser_context *ctx, parser_error *err)
json_map_int_bool *
make_json_map_int_bool (yajl_val src, const struct parser_context *ctx, parser_error *err)
{
__auto_cleanup (free_json_map_int_bool) json_map_int_bool *ret = NULL;
size_t i;
Expand Down Expand Up @@ -861,7 +863,8 @@ free_json_map_int_string (json_map_int_string *map)

define_cleaner_function (json_map_int_string *, free_json_map_int_string)

json_map_int_string *make_json_map_int_string (yajl_val src, const struct parser_context *ctx, parser_error *err)
json_map_int_string *
make_json_map_int_string (yajl_val src, const struct parser_context *ctx, parser_error *err)
{
__auto_cleanup (free_json_map_int_string) json_map_int_string *ret = NULL;
size_t i;
Expand Down Expand Up @@ -1020,7 +1023,8 @@ free_json_map_string_int (json_map_string_int *map)

define_cleaner_function (json_map_string_int *, free_json_map_string_int)

json_map_string_int *make_json_map_string_int (yajl_val src, const struct parser_context *ctx, parser_error *err)
json_map_string_int *
make_json_map_string_int (yajl_val src, const struct parser_context *ctx, parser_error *err)
{
__auto_cleanup (free_json_map_string_int) json_map_string_int *ret = NULL;
size_t i;
Expand Down Expand Up @@ -1181,7 +1185,8 @@ free_json_map_string_int64 (json_map_string_int64 *map)

define_cleaner_function (json_map_string_int64 *, free_json_map_string_int64)

json_map_string_int64 *make_json_map_string_int64 (yajl_val src, const struct parser_context *ctx,
json_map_string_int64 *
make_json_map_string_int64 (yajl_val src, const struct parser_context *ctx,
parser_error *err)
{
__auto_cleanup (free_json_map_string_int64) json_map_string_int64 *ret = NULL;
Expand Down Expand Up @@ -1316,7 +1321,8 @@ free_json_map_string_bool (json_map_string_bool *map)

define_cleaner_function (json_map_string_bool *, free_json_map_string_bool)

json_map_string_bool *make_json_map_string_bool (yajl_val src, const struct parser_context *ctx, parser_error *err)
json_map_string_bool *
make_json_map_string_bool (yajl_val src, const struct parser_context *ctx, parser_error *err)
{
__auto_cleanup (free_json_map_string_bool) json_map_string_bool *ret = NULL;
size_t i;
Expand Down Expand Up @@ -1485,7 +1491,8 @@ free_json_map_string_string (json_map_string_string *map)

define_cleaner_function (json_map_string_string *, free_json_map_string_string)

json_map_string_string *make_json_map_string_string (yajl_val src, const struct parser_context *ctx,
json_map_string_string *
make_json_map_string_string (yajl_val src, const struct parser_context *ctx,
parser_error *err)
{
__auto_cleanup (free_json_map_string_string) json_map_string_string *ret = NULL;
Expand Down Expand Up @@ -1628,7 +1635,8 @@ cleanup_yajl_gen (yajl_gen g)

define_cleaner_function (yajl_gen, cleanup_yajl_gen)

char *json_marshal_string (const char *str, size_t length, const struct parser_context *ctx, parser_error *err)
char *
json_marshal_string (const char *str, size_t length, const struct parser_context *ctx, parser_error *err)
{
__auto_cleanup (cleanup_yajl_gen) yajl_gen g = NULL;
struct parser_context tmp_ctx = { 0 };
Expand Down
15 changes: 7 additions & 8 deletions src/ocispec/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,8 @@ def parse_obj_arr_obj(obj, c_file, prefix, obj_typename):
}
for (i = 0; i < tree->u.object.len; i++)
{""" \
f"if ({condition})" \
{\n""" \
f" if ({condition})" \
"""{
if (ctx->options & OPT_PARSE_FULLKEY)
{
Expand All @@ -339,13 +339,12 @@ def parse_obj_arr_obj(obj, c_file, prefix, obj_typename):
j++;
}
}
if (ctx->options & OPT_PARSE_STRICT)
{
if (j > 0 && ctx->errfile != NULL)
(void) fprintf (ctx->errfile, "WARNING: unknown key found\\n");
}
if ((ctx->options & OPT_PARSE_STRICT) && j > 0 && ctx->errfile != NULL)
(void) fprintf (ctx->errfile, "WARNING: unknown key found\\n");
if (ctx->options & OPT_PARSE_FULLKEY)
ret->_residual = resi;
ret->_residual = resi;
}
""")

Expand Down

0 comments on commit d371222

Please sign in to comment.