Skip to content

Refactor parser#169

Merged
giuseppe merged 6 commits intocontainers:mainfrom
giuseppe:refactor-parser
Apr 29, 2026
Merged

Refactor parser#169
giuseppe merged 6 commits intocontainers:mainfrom
giuseppe:refactor-parser

Conversation

@giuseppe
Copy link
Copy Markdown
Member

some cleanups, more details in each commit

@giuseppe giuseppe force-pushed the refactor-parser branch 2 times, most recently from 4843957 to a312988 Compare April 15, 2026 07:09
@giuseppe
Copy link
Copy Markdown
Member Author

@flouthoc PTAL

@giuseppe
Copy link
Copy Markdown
Member Author

@jnovy PTAL

@jnovy
Copy link
Copy Markdown

jnovy commented Apr 29, 2026

LGTM

clean refactoring — the json_api.py abstraction is well-structured and the commits are nicely atomic.

Minor observations:

  1. The spacing inconsistencies in generated macro calls (e.g. YAJL_GET_STRING ({val}) with space vs YAJL_GET_ARRAY_NO_CHECK({val}) without) are now centralized in json_api.py — might be worth a follow-up to normalize them.

  2. emit_array_gen_preamble's len_indent parameter could use a brief comment explaining why it exists.

  3. Have you verified byte-for-byte identical output on the existing schemas?

@giuseppe
Copy link
Copy Markdown
Member Author

3. Have you verified byte-for-byte identical output on the existing schemas?

yes I've verified that.

I'll take care of the nits

giuseppe and others added 6 commits April 29, 2026 18:02
Move all YAJL-specific C code fragments (type names, macros, function
calls) from sources.py and headers.py into a new json_api.py module.
This makes it possible to switch the underlying JSON library by
modifying json_api.py only, without touching the rest of the generator.

The generated C code is byte-for-byte identical.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
The do/get_val/array_check/len/values/calloc block was duplicated
identically across ObjectArrayHandler, PrimitiveArrayHandler, and
BasicMapArrayHandler. Extract it into emit_array_parse_preamble().

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
The if-OPT_GEN + gen_key + len setup + beautify_off + array_open +
check_gen_status block was duplicated across ObjectArrayHandler,
PrimitiveArrayHandler, and BasicMapArrayHandler. Extract it into
emit_array_gen_preamble().

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
StringType, BooleanPointerType, and NumericPointerType all manually
inlined the free()/NULL= pattern instead of using the existing
free_and_null() helper.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
BooleanPointerType and NumericPointerType had identical clone logic
(calloc + NULL check + dereference copy), differing only in sizeof
type. Extract into a shared helper.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
…en()

ObjectType, MapStringObjectType, and BasicMapType all had the same
if-OPT_GEN + gen_key + stat=gen_{type} + check_gen_status structure
in their emit_generate methods. Extract into a shared helper.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
@giuseppe
Copy link
Copy Markdown
Member Author

pushed a fixed version

@giuseppe giuseppe merged commit e40b36b into containers:main Apr 29, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants