main
30
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
86b58e83cb |
schemagen: reject absent additionalProperties
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-arm64, ubuntu-latest-arm64, true) (pull_request) Successful in 57s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-arm64, ubuntu-latest-arm64, false) (pull_request) Successful in 50s
CI / pre-commit (pull_request) Successful in 52s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-amd64, ubuntu-latest-amd64, true) (pull_request) Successful in 1m41s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-amd64, ubuntu-latest-amd64, false) (pull_request) Successful in 1m29s
Per the README contract, an object schema without an explicit `additionalProperties` was documented as rejected at generation time, but the code defaulted it to `false` and silently generated a strict parser that rejects valid documents with extra properties. Make the code match the documented contract by raising GenError when `additionalProperties` is absent, with a clear message instructing the author to set it explicitly to false. Update the README prose section to list absent additionalProperties alongside true, and fix existing schemas and tests to declare additionalProperties explicitly. Closes #55 |
||
|
|
cdff634057 |
Fix schemagen integer parser rejecting zero with negative exponents
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-arm64, ubuntu-latest-arm64, true) (pull_request) Successful in 51s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-arm64, ubuntu-latest-arm64, false) (pull_request) Successful in 50s
CI / pre-commit (pull_request) Successful in 56s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-amd64, ubuntu-latest-amd64, true) (pull_request) Successful in 1m33s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-amd64, ubuntu-latest-amd64, false) (pull_request) Successful in 1m33s
Move the zero-detection check in the generated parseJsonInt64 before the finalExp < 0 guard. Previously, valid JSON numbers whose mathematical value is 0 but written with a large negative exponent (e.g. 0e-2, 0.0e-2, -0e-2, 0e-20) were rejected because the negative-finalExp early return ran before the all-zero-digits branch could set out = 0. Non-zero values with negative exponents are still correctly rejected. Closes #56 |
||
|
|
5e462f1477 |
make WeaselJson_OVERFLOW a terminal state like WeaselJson_REJECT
CI / pre-commit (pull_request) Successful in 53s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-arm64, ubuntu-latest-arm64, true) (pull_request) Successful in 54s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-arm64, ubuntu-latest-arm64, false) (pull_request) Successful in 51s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-amd64, ubuntu-latest-amd64, true) (pull_request) Successful in 1m35s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-amd64, ubuntu-latest-amd64, false) (pull_request) Successful in 1m32s
When a parse step returned WeaselJson_OVERFLOW, the pushdown stack was left corrupted (frames had been popped before the failing push), but the overflow status was not made sticky the way WeaselJson_REJECT is. A subsequent end-of-data call WeaselJsonParser_parse(parser, nullptr, 0) could then dispatch through the corrupted stack and return WeaselJson_OK, accepting an incomplete, invalid too-deeply-nested document as valid JSON. Add an `overflowed` flag, set it whenever a continuation returns WeaselJson_OVERFLOW, and short-circuit parse() to return WeaselJson_OVERFLOW on every subsequent call. reset() clears the flag so a reused parser can accept a different document. This mirrors the existing stickiness handling for WeaselJson_REJECT. Closes #52 |
||
|
|
be92755cbf |
schemagen: add regression test for nullable cyclic $ref targets (issue #14)
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-arm64, ubuntu-latest-arm64, true) (pull_request) Successful in 54s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-arm64, ubuntu-latest-arm64, false) (pull_request) Successful in 56s
CI / pre-commit (pull_request) Successful in 51s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-amd64, ubuntu-latest-amd64, true) (pull_request) Successful in 1m32s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-amd64, ubuntu-latest-amd64, false) (pull_request) Successful in 1m27s
The generator already preserves nullability for self-referential object $defs thanks to prior fixes, but issue #14 had no regression coverage. Add a test using the exact reproduction schema from the issue and verify that both the outer and recursive `self` fields accept `null`. |
||
|
|
ababd3a8fd |
schemagen: reject self-referential array $ref cycles instead of crashing
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-arm64, ubuntu-latest-arm64, true) (pull_request) Successful in 55s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-arm64, ubuntu-latest-arm64, false) (pull_request) Successful in 51s
CI / pre-commit (pull_request) Successful in 52s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-amd64, ubuntu-latest-amd64, true) (pull_request) Successful in 1m32s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-amd64, ubuntu-latest-amd64, false) (pull_request) Successful in 1m26s
Cyclic array definitions (directly or through a chain of array $defs) created a self-referential TArr, which then caused infinite recursion in base_cpp, storage_cpp, and _walk_arrays. Object-only cycles are already broken with std::unique_ptr, but array-only cycles have no object edge for break_cycles to cut. Detect them after building an array's items by following TArr.elem links and raise a clear GenError so generation fails gracefully rather than overflowing the Python stack. Closes #33 |
||
|
|
681892107f |
schemagen: escape control characters in generated C++ string literals
CI / pre-commit (pull_request) Successful in 53s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-arm64, ubuntu-latest-arm64, true) (pull_request) Successful in 53s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-amd64, ubuntu-latest-amd64, true) (pull_request) Successful in 1m32s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-arm64, ubuntu-latest-arm64, false) (pull_request) Successful in 52s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-amd64, ubuntu-latest-amd64, false) (pull_request) Successful in 1m28s
Fixes #35. Add a helper to escape C++ string literals so that JSON control characters (\n, \r, \t, and other bytes below 0x20) are emitted as escape sequences instead of raw bytes. Use it for: - field comments that include the JSON property key - object key comparison literals in matchKey() - enum name arrays Also add regression tests that generate and syntax-check headers for schemas containing newlines and other control characters in property keys and enum values. |
||
|
|
ceb16e5405 |
schemagen: fix quadratic leading-zero strip in integer fallback
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-arm64, ubuntu-latest-arm64, true) (pull_request) Successful in 51s
CI / pre-commit (pull_request) Successful in 52s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-arm64, ubuntu-latest-arm64, false) (pull_request) Successful in 51s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-amd64, ubuntu-latest-amd64, true) (pull_request) Successful in 1m32s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-amd64, ubuntu-latest-amd64, false) (pull_request) Successful in 1m26s
Replace the O(k^2) loop that erased leading zeros one byte at a time from the front of a std::string with a single linear scan and one erase(0, n) call. Also adds regression tests for issue #34: - correctness cases for numbers with leading fractional zeros - a static check that the generated code no longer contains the quadratic pattern - a large-input case (100k leading zeros) that reproduces the vulnerable shape Closes #34 |
||
|
|
abeaae7ed7 |
schemagen: handle WeaselJsonParser_create failure in RootBuilder
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-arm64, ubuntu-latest-arm64, true) (pull_request) Successful in 51s
CI / pre-commit (pull_request) Successful in 53s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-arm64, ubuntu-latest-arm64, false) (pull_request) Successful in 51s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-amd64, ubuntu-latest-amd64, true) (pull_request) Successful in 1m34s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-amd64, ubuntu-latest-amd64, false) (pull_request) Successful in 1m27s
If WeaselJsonParser_create returns nullptr (e.g. negative stack size or allocation failure), set the existing error_ flag so that subsequent feed()/finish() calls return WeaselJson_REJECT instead of dereferencing the null parser_. Also add a regression test in test_gen.cpp that constructs a RootBuilder with an invalid stack size and verifies it rejects without crashing. Closes #36 |
||
|
|
e5c970a605 |
Include <cstdint> in json_value.h for uint8_t
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-arm64, ubuntu-latest-arm64, true) (pull_request) Successful in 52s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-arm64, ubuntu-latest-arm64, false) (pull_request) Successful in 50s
CI / pre-commit (pull_request) Successful in 53s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-amd64, ubuntu-latest-amd64, true) (pull_request) Successful in 1m29s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-amd64, ubuntu-latest-amd64, false) (pull_request) Successful in 1m24s
`escapeAsJsonString` uses `uint8_t` but the header did not include `<cstdint>`, making it dependent on other headers to define the type. Add the missing include so `json_value.h` is self-contained. |
||
|
|
96f61665bf |
python: raise OSError when shared library is missing
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-arm64, ubuntu-latest-arm64, true) (pull_request) Successful in 52s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-arm64, ubuntu-latest-arm64, false) (pull_request) Successful in 50s
CI / pre-commit (pull_request) Successful in 52s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-amd64, ubuntu-latest-amd64, true) (pull_request) Successful in 1m31s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-amd64, ubuntu-latest-amd64, false) (pull_request) Successful in 1m25s
Replace sys.exit(1) in WeaselJsonParser.__init__ with an OSError so callers can handle a missing libweaseljson gracefully. Also add a test that verifies the constructor raises OSError for a non-existent build directory. Closes #38 |
||
|
|
34fc22a7c2 |
Handle null parser in WeaselJsonParser_reset and _destroy
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-arm64, ubuntu-latest-arm64, true) (pull_request) Successful in 50s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-arm64, ubuntu-latest-arm64, false) (pull_request) Successful in 51s
CI / pre-commit (pull_request) Successful in 52s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-amd64, ubuntu-latest-amd64, true) (pull_request) Successful in 1m29s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-amd64, ubuntu-latest-amd64, false) (pull_request) Successful in 1m24s
WeaselJsonParser_create can return nullptr when allocation fails or the requested stack size is too small. Previously, passing that nullptr to WeaselJsonParser_reset or WeaselJsonParser_destroy dereferenced it before doing any work, causing immediate undefined behavior. Add an early null check to both functions so they behave like free(nullptr) (i.e., are a safe no-op). Also add a doctest case covering both a null returned from create and a literal nullptr. Closes #41 |
||
|
|
df693ef4c9 |
schemagen: reject scalar root values when root schema is object/array
CI / pre-commit (pull_request) Successful in 51s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-arm64, ubuntu-latest-arm64, true) (pull_request) Successful in 1m3s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-arm64, ubuntu-latest-arm64, false) (pull_request) Successful in 1m3s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-amd64, ubuntu-latest-amd64, true) (pull_request) Successful in 1m35s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-amd64, ubuntu-latest-amd64, false) (pull_request) Successful in 1m24s
The generated RootBuilder crashed (undefined behavior on std::vector::back()) when a JSON document's root value was a scalar or null while the schema declared a non-nullable object or array root. The stack starts empty for object/array roots, but cbStringData, cbNumberData, and cbBool called stack_.back() without checking for an empty stack. Add an empty-stack guard to the three scalar callbacks so they reject instead of crashing. cbNull already handles the empty-stack case. Regression tests added for: - non-nullable object root rejecting null, boolean, number, and string roots - nullable object root rejecting scalar roots - nullable array root rejecting scalar roots Closes #16 |
||
|
|
e155e0bbf4 |
schemagen: restore nullable tuple return for object schemas
CI / pre-commit (pull_request) Successful in 51s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-arm64, ubuntu-latest-arm64, true) (pull_request) Successful in 1m1s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-arm64, ubuntu-latest-arm64, false) (pull_request) Successful in 1m0s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-amd64, ubuntu-latest-amd64, true) (pull_request) Successful in 1m28s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-amd64, ubuntu-latest-amd64, false) (pull_request) Successful in 1m23s
The previous change to cache object definitions started returning the bare TObj from build_type for object schemas, discarding the nullable flag. This caused nullable root objects to be emitted as plain structs instead of std::optional<RootInner>, breaking the nullable root tests. Return the (TObj, nullable) tuple so callers (including the root emitter) see the correct nullability again. |
||
|
|
717f30099f |
schemagen: cache non-object $defs entries to avoid duplicate types
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-arm64, ubuntu-latest-arm64, true) (pull_request) Failing after 51s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-arm64, ubuntu-latest-arm64, false) (pull_request) Failing after 51s
CI / pre-commit (pull_request) Successful in 52s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-amd64, ubuntu-latest-amd64, true) (pull_request) Failing after 1m12s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-amd64, ubuntu-latest-amd64, false) (pull_request) Failing after 1m14s
Extend the existing per-definition cache (`self._building`) to enum, array, and scalar $defs, not just object definitions. This ensures that multiple $refs to the same non-object definition reuse the same C++ type instead of generating Role, Role2, Role3, etc. - Cache the built (type, nullable) tuple under defname for enum, scalar, and array definitions. - Pre-register array definitions before recursing into items so $ref cycles resolve to the same TArr instance. - Store object definitions as (TObj, nullable) tuples so nullable object $defs also preserve their nullability when referenced. Add a regression test for issue #17 covering reused enum and array-of-enum $defs. |
||
|
|
38079cc278 |
schemagen: parse integer fallback exactly for decimal/exponent forms
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-arm64, ubuntu-latest-arm64, true) (pull_request) Successful in 1m0s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-arm64, ubuntu-latest-arm64, false) (pull_request) Successful in 58s
CI / pre-commit (pull_request) Successful in 51s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-amd64, ubuntu-latest-amd64, true) (pull_request) Successful in 1m30s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-amd64, ubuntu-latest-amd64, false) (pull_request) Successful in 1m24s
Replace the double-based fallback in generated integer slots with a string-to-int64 parser that handles decimal points and exponents without losing precision near the int64 boundaries. The old path used std::from_chars<double> and compared against ±9223372036854775808.0, which rounds the int64 max and min so that valid values are rejected and out-of-range negatives are accepted. The new helper: - Parses sign, integer part, optional fraction, and optional exponent. - Strips trailing zeros to cancel fractional places. - Rejects non-integral values and overflow using exact uint64_t arithmetic. Adds regression tests covering root integer and object-field integer boundary values, including the cases from issue #19. |
||
|
|
16f13c241c |
schemagen: drop support for additionalProperties: true
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-arm64, ubuntu-latest-arm64, true) (pull_request) Successful in 52s
CI / pre-commit (pull_request) Successful in 51s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-arm64, ubuntu-latest-arm64, false) (pull_request) Successful in 48s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-amd64, ubuntu-latest-amd64, true) (pull_request) Successful in 1m29s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-amd64, ubuntu-latest-amd64, false) (pull_request) Successful in 1m24s
Following review feedback, the generator no longer supports permissive objects. Changes: - Reject `additionalProperties: true` at generation time. - Treat an absent `additionalProperties` as `false`, so every object is strict by default and unknown keys are rejected during parsing. - Remove the now-dead permissive-object infrastructure: `Kind::Skip`, `Cat::Skip`, `kSkip`, the per-frame `unknown` key set, and `isStrict()`. - Update the README feature/rejection tables accordingly. - Remove the permissive "loose" object from example.schema.json and the associated tests from test_gen.cpp. - Add Python unit tests verifying the new `additionalProperties` behavior. All tests pass (`ctest --output-on-failure`). |
||
|
|
ab95fefb09 |
schemagen: reject duplicate unknown keys in non-strict objects
Track unknown keys in a per-object unordered_set so that permissive objects (additionalProperties absent/true) still reject duplicate keys, matching the README guarantee. - Add std::unordered_set<std::string> to Frame. - Insert unknown keys in cbKeyData and reject duplicates before skipping. - Add a permissive "loose" subobject to example.schema.json. - Test single unknown key accepted and duplicate unknown/known keys rejected. |
||
|
|
b5491afb38 |
schemagen: fix nullable root types (#13)
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-arm64, ubuntu-latest-arm64, true) (pull_request) Successful in 52s
CI / pre-commit (pull_request) Successful in 54s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-arm64, ubuntu-latest-arm64, false) (pull_request) Successful in 47s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-amd64, ubuntu-latest-amd64, true) (pull_request) Successful in 1m35s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-amd64, ubuntu-latest-amd64, false) (pull_request) Successful in 1m27s
The C++ code generator now handles schemas where the top-level type is
nullable ("type": ["object", "null"], ["string", "null"], or
["array", "null"]).
Changes to weaseljson_schemagen.py:
- Rename the inner object struct when the root is a nullable object, so
the `using Root = std::optional<...>` alias no longer conflicts with
`struct Root`.
- Treat nullable root objects and arrays as container roots, emplacing
the inner value before pushing the root frame and pointing the frame at
the contained value.
- For nullable root scalars/enums, engage() now returns a pointer to the
value inside the optional rather than to the optional wrapper itself.
- cbNull() now safely accepts a top-level null when the root is nullable
and rejects it otherwise.
Regression tests added:
- nullable_object.schema.json + test_nullable_root.cpp
- nullable_string.schema.json
- nullable_array.schema.json
Closes #13
|
||
|
|
46ff8e2164 |
schemagen: reserve generated Root/Skip/RootScalar and avoid Kind/ArrN collisions
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-arm64, ubuntu-latest-arm64, true) (pull_request) Successful in 53s
CI / pre-commit (pull_request) Successful in 51s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-arm64, ubuntu-latest-arm64, false) (pull_request) Successful in 49s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-amd64, ubuntu-latest-amd64, true) (pull_request) Successful in 1m29s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-amd64, ubuntu-latest-amd64, false) (pull_request) Successful in 1m25s
Make the type-name allocator aware of the identifiers the generator emits itself (`Root` alias, `Skip`/`RootScalar` Kind enumerators) so user `$defs` names can no longer collide with them. Array-kind names (`Arr0`, `Arr1`, ...) are now allocated only after checking for object/enum names, preventing duplicate `Kind` enumerators when a schema defines e.g. `Arr0`. Add Python regression tests that also syntax-check the generated headers with a C++ compiler. Closes #21 |
||
|
|
a26e101191 |
check WeaselJsonParser_create return value in Python bindings
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-arm64, ubuntu-latest-arm64, true) (pull_request) Successful in 1m3s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-arm64, ubuntu-latest-arm64, false) (pull_request) Successful in 54s
CI / pre-commit (pull_request) Successful in 58s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-amd64, ubuntu-latest-amd64, true) (pull_request) Successful in 1m37s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-amd64, ubuntu-latest-amd64, false) (pull_request) Successful in 1m30s
Raise ValueError from __init__ when the C constructor returns NULL, instead of storing a NULL pointer that segfaults on parse()/reset(). Add defensive RuntimeError checks in parse() and reset() for closed or failed parsers. Add a test covering stackSize values that the C API rejects (-1, 0, 1, 2). Fixes #23 |
||
|
|
43e3c9904f |
Reject negative lengths in WeaselJsonParser_parse
CI / pre-commit (pull_request) Successful in 1m4s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-arm64, ubuntu-latest-arm64, false) (pull_request) Successful in 1m1s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-amd64, ubuntu-latest-amd64, true) (pull_request) Successful in 1m39s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-amd64, ubuntu-latest-amd64, false) (pull_request) Successful in 1m34s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-arm64, ubuntu-latest-arm64, true) (pull_request) Successful in 51s
`Parser3::parse` previously formed `buf + len` immediately, so passing a negative `len` from the C API caused undefined pointer arithmetic. Add an explicit `len < 0` check that returns `WeaselJson_REJECT` (and makes the rejected state sticky) before any `buf + len` computation. Also document the non-negative length precondition in the public header and add a regression test. Closes #24 |
||
|
|
9cd74631b6 |
schemagen: add C++20 keywords to the C++ keyword allow-list
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-arm64, ubuntu-latest-arm64, true) (pull_request) Successful in 54s
CI / pre-commit (pull_request) Successful in 1m5s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-arm64, ubuntu-latest-arm64, false) (pull_request) Successful in 54s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-amd64, ubuntu-latest-amd64, true) (pull_request) Successful in 1m54s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-amd64, ubuntu-latest-amd64, false) (pull_request) Successful in 1m33s
Add concept, consteval, constinit, co_await, co_return, co_yield, requires, module, and import to _CPP_KEYWORDS so property names that happen to be C++20 keywords get sanitized with a trailing underscore. Closes #18 |
||
|
|
9839104635 |
Make parser reject state sticky after WeaselJson_REJECT
CI / pre-commit (pull_request) Successful in 50s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-arm64, ubuntu-latest-arm64, true) (pull_request) Successful in 53s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-arm64, ubuntu-latest-arm64, false) (pull_request) Successful in 47s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-amd64, ubuntu-latest-amd64, true) (pull_request) Successful in 1m28s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-amd64, ubuntu-latest-amd64, false) (pull_request) Successful in 1m22s
After the parser returns WeaselJson_REJECT once, subsequent calls to WeaselJsonParser_parse (including the final len==0 EOF call) must keep returning WeaselJson_REJECT instead of potentially reporting OK. - Add a `rejected` flag to Parser3. - Clear the flag in reset(). - Check the flag at the start of parse() and immediately return REJECT. - Set the flag whenever a continuation returns REJECT. Add a test covering the exact reproduction from issue #12. |
||
|
|
2ad15708eb |
ci: register schemagen regression tests with ctest
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-arm64, ubuntu-latest-arm64, true) (pull_request) Successful in 53s
CI / pre-commit (pull_request) Successful in 51s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-arm64, ubuntu-latest-arm64, false) (pull_request) Successful in 51s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-amd64, ubuntu-latest-amd64, true) (pull_request) Successful in 1m30s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-amd64, ubuntu-latest-amd64, false) (pull_request) Successful in 1m24s
Remove the standalone "Run schemagen tests" workflow step and instead add the big-schema regression test to contrib/schemagen/CMakeLists.txt so ctest picks it up alongside schemagen_example. Update README to document both `ctest` and the convenience `./run_tests.sh`. Closes #3 |
||
|
|
ca474e3f99 |
schemagen: support objects with more than 32 properties
Replace the 32-bit `uint32_t seen` bitmask with a `std::vector<uint64_t>` bitset sized to the actual field count. `requiredMask` is now a vector of the same word count, and required-field checks use per-word masking so that optional fields do not cause false rejections. Adds big.schema.json + test_big.cpp regression tests covering the issue reproducer (40 required properties, missing/duplicate at index 32), plus run_tests.sh to exercise both test_gen.cpp and test_big.cpp. Fixes #3 |
||
|
|
859fa41ecb |
schemagen: move test configuration into contrib/schemagen/CMakeLists.txt
CI / pre-commit (pull_request) Successful in 51s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-arm64, ubuntu-latest-arm64, true) (pull_request) Successful in 51s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-amd64, ubuntu-latest-amd64, true) (pull_request) Successful in 1m28s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-arm64, ubuntu-latest-arm64, false) (pull_request) Successful in 49s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-amd64, ubuntu-latest-amd64, false) (pull_request) Successful in 1m22s
Addresses review feedback: keep the schemagen-specific CMake rules close to the tool instead of inline in the top-level CMakeLists.txt. The subdirectory file is added from the root and guarded by the same Python3 availability check that was already in use. |
||
|
|
359f4f4bb6 |
schemagen: deduplicate enum constants that collide after sanitization
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-arm64, ubuntu-latest-arm64, true) (pull_request) Successful in 51s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-arm64, ubuntu-latest-arm64, false) (pull_request) Successful in 51s
CI / pre-commit (pull_request) Successful in 51s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-amd64, ubuntu-latest-amd64, true) (pull_request) Successful in 1m29s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-amd64, ubuntu-latest-amd64, false) (pull_request) Successful in 1m22s
Distinct JSON enum values can sanitize to the same C++ identifier (e.g. "foo-bar" and "foo_bar" both become `foo_bar`), producing an invalid `enum class` with duplicate constants. Add `unique_enum_identifiers()` which appends a numeric suffix to later collisions while preserving enum declaration order, so the index-to-JSON-value mapping used by the generated parser stays intact. Also add contrib/schemagen/test_schemagen.py and wire the schemagen Python tests plus the existing example.schema.json/test_gen.cpp example into ctest via CMakeLists.txt. Closes #4 |
||
|
|
7a8e5f84f2 |
Python bindings: add missing on_key_data callback (#7)
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-arm64, ubuntu-latest-arm64, true) (push) Successful in 54s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-arm64, ubuntu-latest-arm64, false) (push) Successful in 50s
CI / pre-commit (push) Successful in 51s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-amd64, ubuntu-latest-amd64, true) (push) Successful in 1m31s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-amd64, ubuntu-latest-amd64, false) (push) Successful in 1m23s
Closes #6 Reviewed-on: #7 Co-authored-by: Weaselbot <weaselbot@weaselab.dev> Co-committed-by: Weaselbot <weaselbot@weaselab.dev> |
||
|
|
919b89c842 |
Parser3::reset: clear inKey and other per-parse transient state
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-arm64, ubuntu-latest-arm64, true) (pull_request) Successful in 52s
CI / pre-commit (pull_request) Successful in 51s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-arm64, ubuntu-latest-arm64, false) (pull_request) Successful in 49s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-amd64, ubuntu-latest-amd64, true) (pull_request) Successful in 1m30s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-amd64, ubuntu-latest-amd64, false) (pull_request) Successful in 1m24s
WeaselJsonParser_reset is documented to restore the parser to its newly-created state, but reset() only rewound the symbol stack. The inKey flag and transient DFA/codepoint state from the previous parse leaked into the next parse, so a top-level string after a mid-key reset was delivered via on_key_data instead of on_string_data. Reset inKey to false and clear utf8Codepoint, utf16Surrogate, minCodepoint, numDfa, and strDfa so the next document starts fresh. Add a test that reproduces the reported misrouting. |
||
|
|
47f1077100 |
schemagen: keep null elements in arrays with nullable item types
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-arm64, ubuntu-latest-arm64, true) (pull_request) Successful in 51s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-arm64, ubuntu-latest-arm64, false) (pull_request) Successful in 49s
CI / pre-commit (pull_request) Successful in 51s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-amd64, ubuntu-latest-amd64, true) (pull_request) Successful in 1m27s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-amd64, ubuntu-latest-amd64, false) (pull_request) Successful in 1m23s
For array types whose items are nullable ({"type": ["T", "null"]}),
the generated builder previously called valueComplete() on cbNull() without
appending anything to the owning vector. Null entries were silently dropped,
so vector indices no longer matched JSON array indices.
Generate isArrayKind() / appendNull() helpers and have cbNull() append a
default-constructed element when the current frame is an array. For
std::optional<T> items this appends an empty optional; for std::unique_ptr<T>
items it appends a null pointer. Add nullable string/integer array fields to
the example schema and test coverage to verify indices are preserved.
Fixes #5
|