yeptris 0.6.64.0-riscv64-linux-gnu
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.adoc +150 -0
- data/ext/build_windows_native.rb +60 -0
- data/ext/libyeptris/extconf.rb +57 -0
- data/ext/yeptris_native/cbor_ruby.c +198 -0
- data/ext/yeptris_native/extconf.rb +99 -0
- data/ext/yeptris_native/json_ruby.c +414 -0
- data/ext/yeptris_native/version.h +29 -0
- data/ext/yeptris_native/yeptris_native.c +507 -0
- data/lib/yeptris/3.3/native.so +0 -0
- data/lib/yeptris/cbor.rb +169 -0
- data/lib/yeptris/document.rb +319 -0
- data/lib/yeptris/ffi.rb +572 -0
- data/lib/yeptris/json/descriptor.rb +266 -0
- data/lib/yeptris/json.rb +502 -0
- data/lib/yeptris/materializer.rb +389 -0
- data/lib/yeptris/node.rb +482 -0
- data/lib/yeptris/psych/class_loader.rb +24 -0
- data/lib/yeptris/psych/coder_shim.rb +55 -0
- data/lib/yeptris/psych/drop_in.rb +63 -0
- data/lib/yeptris/psych/encodable.rb +14 -0
- data/lib/yeptris/psych/handler.rb +95 -0
- data/lib/yeptris/psych/parser.rb +114 -0
- data/lib/yeptris/psych/scalar_scanner.rb +149 -0
- data/lib/yeptris/psych/tree_builder.rb +119 -0
- data/lib/yeptris/psych/visitors.rb +670 -0
- data/lib/yeptris/psych.rb +796 -0
- data/lib/yeptris/schema.rb +253 -0
- data/lib/yeptris/validation.rb +320 -0
- data/lib/yeptris/valueml.rb +477 -0
- data/lib/yeptris/yaml/descriptor.rb +56 -0
- data/lib/yeptris/yaml.rb +668 -0
- data/lib/yeptris.rb +130 -0
- data/libyeptris.so +0 -0
- data/vendor/libyeptris/CMakeLists.txt +280 -0
- data/vendor/libyeptris/cmake/yeptris-config.cmake.in +5 -0
- data/vendor/libyeptris/cmake/yeptris.pc.in +11 -0
- data/vendor/libyeptris/src/CMakeLists.txt +183 -0
- data/vendor/libyeptris/src/include/yeptris/api.h +32 -0
- data/vendor/libyeptris/src/include/yeptris/cbor.h +174 -0
- data/vendor/libyeptris/src/include/yeptris/dom.h +196 -0
- data/vendor/libyeptris/src/include/yeptris/emit.h +128 -0
- data/vendor/libyeptris/src/include/yeptris/error.h +42 -0
- data/vendor/libyeptris/src/include/yeptris/events.h +171 -0
- data/vendor/libyeptris/src/include/yeptris/json.h +57 -0
- data/vendor/libyeptris/src/include/yeptris/json.hpp +258 -0
- data/vendor/libyeptris/src/include/yeptris/jsonc_compat.h +115 -0
- data/vendor/libyeptris/src/include/yeptris/marshal.h +75 -0
- data/vendor/libyeptris/src/include/yeptris/parse.h +121 -0
- data/vendor/libyeptris/src/include/yeptris/plan.h +100 -0
- data/vendor/libyeptris/src/include/yeptris/resolve.h +81 -0
- data/vendor/libyeptris/src/include/yeptris/schema.h +121 -0
- data/vendor/libyeptris/src/include/yeptris/tape.h +128 -0
- data/vendor/libyeptris/src/include/yeptris/types.h +38 -0
- data/vendor/libyeptris/src/include/yeptris/validate.h +401 -0
- data/vendor/libyeptris/src/include/yeptris/values.h +108 -0
- data/vendor/libyeptris/src/include/yeptris/version.h.in +29 -0
- data/vendor/libyeptris/src/include/yeptris/visit.h +77 -0
- data/vendor/libyeptris/src/include/yeptris/yajl_compat.h +135 -0
- data/vendor/libyeptris/src/include/yeptris.h +24 -0
- data/vendor/libyeptris/src/yeptris/build.c +393 -0
- data/vendor/libyeptris/src/yeptris/cbor/cbor.h +35 -0
- data/vendor/libyeptris/src/yeptris/cbor/decode.c +1054 -0
- data/vendor/libyeptris/src/yeptris/cbor/encode.c +836 -0
- data/vendor/libyeptris/src/yeptris/cbor/encode_priv.h +32 -0
- data/vendor/libyeptris/src/yeptris/cbor/from_marshal.c +982 -0
- data/vendor/libyeptris/src/yeptris/cbor/sink.h +36 -0
- data/vendor/libyeptris/src/yeptris/common/chartype.c +41 -0
- data/vendor/libyeptris/src/yeptris/common/chartype.h +77 -0
- data/vendor/libyeptris/src/yeptris/common/cpu.c +81 -0
- data/vendor/libyeptris/src/yeptris/common/cpu.h +40 -0
- data/vendor/libyeptris/src/yeptris/common/error.c +65 -0
- data/vendor/libyeptris/src/yeptris/common/error.h +81 -0
- data/vendor/libyeptris/src/yeptris/common/mutex.h +45 -0
- data/vendor/libyeptris/src/yeptris/common/nametab.c +275 -0
- data/vendor/libyeptris/src/yeptris/common/nametab.h +68 -0
- data/vendor/libyeptris/src/yeptris/common/port.h +74 -0
- data/vendor/libyeptris/src/yeptris/common/simd_text.c +49 -0
- data/vendor/libyeptris/src/yeptris/common/simd_text.h +342 -0
- data/vendor/libyeptris/src/yeptris/common/simd_text_avx2.c +672 -0
- data/vendor/libyeptris/src/yeptris/common/simd_text_neon.c +793 -0
- data/vendor/libyeptris/src/yeptris/common/simd_text_scalar.c +324 -0
- data/vendor/libyeptris/src/yeptris/common/string_view.c +34 -0
- data/vendor/libyeptris/src/yeptris/common/string_view.h +93 -0
- data/vendor/libyeptris/src/yeptris/doc.h +86 -0
- data/vendor/libyeptris/src/yeptris/dom/dom.c +1312 -0
- data/vendor/libyeptris/src/yeptris/dom/dom.h +332 -0
- data/vendor/libyeptris/src/yeptris/dom/hpool.c +107 -0
- data/vendor/libyeptris/src/yeptris/dom/mapindex.c +173 -0
- data/vendor/libyeptris/src/yeptris/dom/mapindex.h +61 -0
- data/vendor/libyeptris/src/yeptris/dom/mutate.c +431 -0
- data/vendor/libyeptris/src/yeptris/dom/ytape.c +2323 -0
- data/vendor/libyeptris/src/yeptris/dom/ytape.h +96 -0
- data/vendor/libyeptris/src/yeptris/emit/emit.c +670 -0
- data/vendor/libyeptris/src/yeptris/emit/float/api.h +43 -0
- data/vendor/libyeptris/src/yeptris/emit/float/dragon.c +405 -0
- data/vendor/libyeptris/src/yeptris/emit/float/floatint.h +231 -0
- data/vendor/libyeptris/src/yeptris/emit/float/fpconv.c +428 -0
- data/vendor/libyeptris/src/yeptris/emit/float/print.c +396 -0
- data/vendor/libyeptris/src/yeptris/emit/style.c +21 -0
- data/vendor/libyeptris/src/yeptris/emit/style.h +32 -0
- data/vendor/libyeptris/src/yeptris/emit/writer.c +1951 -0
- data/vendor/libyeptris/src/yeptris/emit/writer.h +111 -0
- data/vendor/libyeptris/src/yeptris/encoding/bom.c +31 -0
- data/vendor/libyeptris/src/yeptris/encoding/encoding.h +63 -0
- data/vendor/libyeptris/src/yeptris/encoding/transcode.c +157 -0
- data/vendor/libyeptris/src/yeptris/encoding/utf8_validate.c +178 -0
- data/vendor/libyeptris/src/yeptris/events/capture.c +166 -0
- data/vendor/libyeptris/src/yeptris/events/capture.h +39 -0
- data/vendor/libyeptris/src/yeptris/events/iterparse.c +298 -0
- data/vendor/libyeptris/src/yeptris/events/pull.c +117 -0
- data/vendor/libyeptris/src/yeptris/events/push.c +151 -0
- data/vendor/libyeptris/src/yeptris/events/recorder.c +144 -0
- data/vendor/libyeptris/src/yeptris/events/values.c +630 -0
- data/vendor/libyeptris/src/yeptris/events/values_priv.h +53 -0
- data/vendor/libyeptris/src/yeptris/events/yaml_compat.c +86 -0
- data/vendor/libyeptris/src/yeptris/events/yaml_compat.h +90 -0
- data/vendor/libyeptris/src/yeptris/jsonapi/jsonc_compat.c +687 -0
- data/vendor/libyeptris/src/yeptris/jsonapi/yajl_compat.c +728 -0
- data/vendor/libyeptris/src/yeptris/marshal/to_json.c +650 -0
- data/vendor/libyeptris/src/yeptris/marshal.c +988 -0
- data/vendor/libyeptris/src/yeptris/memory/allocator.c +20 -0
- data/vendor/libyeptris/src/yeptris/memory/allocator.h +43 -0
- data/vendor/libyeptris/src/yeptris/memory/arena.c +150 -0
- data/vendor/libyeptris/src/yeptris/memory/arena.h +52 -0
- data/vendor/libyeptris/src/yeptris/memory/pool.c +133 -0
- data/vendor/libyeptris/src/yeptris/memory/pool.h +36 -0
- data/vendor/libyeptris/src/yeptris/parse/engine.c +6528 -0
- data/vendor/libyeptris/src/yeptris/parse/engine.h +96 -0
- data/vendor/libyeptris/src/yeptris/parse/events.h +137 -0
- data/vendor/libyeptris/src/yeptris/parse/numbers.c +374 -0
- data/vendor/libyeptris/src/yeptris/parse/numbers.h +33 -0
- data/vendor/libyeptris/src/yeptris/parse/scalars.c +435 -0
- data/vendor/libyeptris/src/yeptris/parse/scalars.h +87 -0
- data/vendor/libyeptris/src/yeptris/parse/stream_iter.c +358 -0
- data/vendor/libyeptris/src/yeptris/parse.c +1074 -0
- data/vendor/libyeptris/src/yeptris/plan.c +824 -0
- data/vendor/libyeptris/src/yeptris/resolve/compat11.c +339 -0
- data/vendor/libyeptris/src/yeptris/resolve/core12.c +153 -0
- data/vendor/libyeptris/src/yeptris/resolve/full12.c +201 -0
- data/vendor/libyeptris/src/yeptris/resolve/json12.c +109 -0
- data/vendor/libyeptris/src/yeptris/resolve/resolver.h +103 -0
- data/vendor/libyeptris/src/yeptris/resolve/tags.c +250 -0
- data/vendor/libyeptris/src/yeptris/scan/json.c +839 -0
- data/vendor/libyeptris/src/yeptris/scan/json.h +116 -0
- data/vendor/libyeptris/src/yeptris/scan/scan.c +862 -0
- data/vendor/libyeptris/src/yeptris/scan/scan.h +177 -0
- data/vendor/libyeptris/src/yeptris/schema.c +309 -0
- data/vendor/libyeptris/src/yeptris/tape.c +2375 -0
- data/vendor/libyeptris/src/yeptris/tape_in.h +39 -0
- data/vendor/libyeptris/src/yeptris/validate/compile.c +306 -0
- data/vendor/libyeptris/src/yeptris/validate/internal.h +347 -0
- data/vendor/libyeptris/src/yeptris/validate/jsonschema.c +1922 -0
- data/vendor/libyeptris/src/yeptris/validate/output.c +246 -0
- data/vendor/libyeptris/src/yeptris/validate/regexp.c +1600 -0
- data/vendor/libyeptris/src/yeptris/validate/registry.c +118 -0
- data/vendor/libyeptris/src/yeptris/validate/resources.c +601 -0
- data/vendor/libyeptris/src/yeptris/validate/stream.c +1155 -0
- data/vendor/libyeptris/src/yeptris/validate/validate.c +1043 -0
- data/vendor/libyeptris/src/yeptris/version.c +7 -0
- data/vendor/libyeptris/src/yeptris/visit/dom_visit.c +115 -0
- data/vendor/libyeptris/src/yeptris/visit/json_visit.c +293 -0
- data/vendor/libyeptris/src/yeptris/visit/yaml_visit.c +127 -0
- metadata +221 -0
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
/* validate.h — the validation face (issue #882).
|
|
2
|
+
*
|
|
3
|
+
* Two checks over one engine pass:
|
|
4
|
+
*
|
|
5
|
+
* 1. SCHEMA-FAMILY validation (`yeptris_validate`): parse + validate
|
|
6
|
+
* fused. Under YEPTRIS_SCHEMA_12_CORE the walk checks explicit-tag
|
|
7
|
+
* consistency (spec 10.3 resolution) and mapping-key uniqueness
|
|
8
|
+
* (spec 3.2.1.3: keys compare by canonical form — 0o13 and 0xB
|
|
9
|
+
* are the same key). Under YEPTRIS_SCHEMA_12_JSON the spec 10.2
|
|
10
|
+
* family applies: implicit resolution uses ONLY the JSON
|
|
11
|
+
* productions (the core extensions — 0o/0x radix, "+12.3",
|
|
12
|
+
* "True"/"~" casings — stay strings, per example 10.8's Invalid
|
|
13
|
+
* list), mapping keys must be strings (a key resolving to a
|
|
14
|
+
* non-string production is KEY_NOT_STRING; a no-production plain
|
|
15
|
+
* key IS a string, per example 10.8), explicit non-JSON tags are
|
|
16
|
+
* rejected; core checks still run. Under YEPTRIS_SCHEMA_12_FULL
|
|
17
|
+
* the spec 10.4 "other schema" family applies — the core schema
|
|
18
|
+
* "extended with additional tag resolution rules": untagged plains
|
|
19
|
+
* also resolve RFC3339-era timestamps (spec example 2.22's
|
|
20
|
+
* canonical/iso8601/spaced/date forms, classified by PyYAML's
|
|
21
|
+
* timestamp regex as the practice oracle) and the merge/value
|
|
22
|
+
* words, while explicit !!timestamp content must re-resolve
|
|
23
|
+
* through the same classifier (TAG_MISMATCH otherwise). !!binary
|
|
24
|
+
* rides as passthrough (base64 shaping is a construction concern);
|
|
25
|
+
* core checks still run. The 1.1 numeric quirks (underscores,
|
|
26
|
+
* sexagesimal, leading-0 octal, y/n booleans) stay with
|
|
27
|
+
* 11_COMPAT — full is spec-refereed, not psych-refereed.
|
|
28
|
+
*
|
|
29
|
+
* 2. JSON SCHEMA validation (`yeptris_json_schema_validate`): the
|
|
30
|
+
* schema arrives as bytes (parsed with the same engine), the
|
|
31
|
+
* target against it — draft 2020-12 keyword subset (see the entry
|
|
32
|
+
* comment). Unknown keywords are ignored, per 2020-12.
|
|
33
|
+
*
|
|
34
|
+
* The COMPILED-schema economy (`yeptris_schema_*`) retains one parsed
|
|
35
|
+
* schema for many instance streams; the TAG-DRIVEN registry
|
|
36
|
+
* (`yeptris_schema_registry_*`, #906 slice 4) binds compiled schemas
|
|
37
|
+
* to user tags over the family walk (`yeptris_validate_ex`). The
|
|
38
|
+
* report converts to the published JSON-Schema output shape
|
|
39
|
+
* (`yeptris_validate_report_write`, #906 slice 5).
|
|
40
|
+
*
|
|
41
|
+
* Every diagnostic carries a JSON-pointer instance path ("/a/b/0" —
|
|
42
|
+
* ~0/~1 escaped), a YEPTRIS_DIAG_* code, a bounded expected/got
|
|
43
|
+
* detail, and the offending node's 1-based line/column (0 = unknown:
|
|
44
|
+
* scalars whose bytes the DOM owns in its arena have no input
|
|
45
|
+
* position; the path still identifies them exactly).
|
|
46
|
+
*
|
|
47
|
+
* STREAMS (#885 item 4): a validated stream is addressed as an array
|
|
48
|
+
* of documents. When the input holds MORE THAN ONE document, every
|
|
49
|
+
* diagnostic path is prefixed with its document's index segment —
|
|
50
|
+
* "/1/a/b" is a/b of document 1 (0-based), so diagnostics name their
|
|
51
|
+
* document even when the miss is unpositioned (an empty document's
|
|
52
|
+
* Error-row scalar has no line/col). Line/col/offset stay
|
|
53
|
+
* input-absolute. Streams with a single document keep the bare
|
|
54
|
+
* instance pointers — existing consumers' paths are unchanged.
|
|
55
|
+
*
|
|
56
|
+
* Results are WHOLE REPORTS: one call, no per-diagnostic callback —
|
|
57
|
+
* the caller drains the flat array and frees the report once.
|
|
58
|
+
*/
|
|
59
|
+
#ifndef YEPTRIS_VALIDATE_H
|
|
60
|
+
#define YEPTRIS_VALIDATE_H
|
|
61
|
+
|
|
62
|
+
#include <stddef.h>
|
|
63
|
+
#include <stdint.h>
|
|
64
|
+
|
|
65
|
+
#include <yeptris/api.h>
|
|
66
|
+
#include <yeptris/error.h>
|
|
67
|
+
#include <yeptris/parse.h> /* YeptrisDocument, YeptrisSchema */
|
|
68
|
+
#include <yeptris/types.h>
|
|
69
|
+
|
|
70
|
+
#ifdef __cplusplus
|
|
71
|
+
extern "C" {
|
|
72
|
+
#endif
|
|
73
|
+
|
|
74
|
+
/* Diagnostic codes. Appending only — bindings hard-code the values
|
|
75
|
+
* (test_abi pins the head). */
|
|
76
|
+
typedef enum {
|
|
77
|
+
YEPTRIS_DIAG_NONE = 0,
|
|
78
|
+
/* the schema-family walk */
|
|
79
|
+
YEPTRIS_DIAG_TAG_MISMATCH = 1, /* explicit tag contradicts content */
|
|
80
|
+
YEPTRIS_DIAG_KEY_NOT_STRING = 2, /* json12: mapping key is not a string */
|
|
81
|
+
YEPTRIS_DIAG_NON_JSON_TYPE = 3, /* json12: plain scalar matches no
|
|
82
|
+
* JSON production / carries a
|
|
83
|
+
* non-JSON tag (spec 10.2.2 Error) */
|
|
84
|
+
YEPTRIS_DIAG_DUPLICATE_KEY = 4, /* equal keys in one mapping */
|
|
85
|
+
/* the JSON Schema walk */
|
|
86
|
+
YEPTRIS_DIAG_TYPE = 5,
|
|
87
|
+
YEPTRIS_DIAG_REQUIRED = 6,
|
|
88
|
+
YEPTRIS_DIAG_ENUM = 7,
|
|
89
|
+
YEPTRIS_DIAG_CONST = 8,
|
|
90
|
+
YEPTRIS_DIAG_PATTERN = 9,
|
|
91
|
+
YEPTRIS_DIAG_MINIMUM = 10,
|
|
92
|
+
YEPTRIS_DIAG_MAXIMUM = 11,
|
|
93
|
+
YEPTRIS_DIAG_EXCLUSIVE_MINIMUM = 12,
|
|
94
|
+
YEPTRIS_DIAG_EXCLUSIVE_MAXIMUM = 13,
|
|
95
|
+
YEPTRIS_DIAG_MIN_LENGTH = 14,
|
|
96
|
+
YEPTRIS_DIAG_MAX_LENGTH = 15,
|
|
97
|
+
YEPTRIS_DIAG_MIN_ITEMS = 16,
|
|
98
|
+
YEPTRIS_DIAG_MAX_ITEMS = 17,
|
|
99
|
+
YEPTRIS_DIAG_UNIQUE_ITEMS = 18,
|
|
100
|
+
YEPTRIS_DIAG_ADDITIONAL_PROPERTY = 19,
|
|
101
|
+
YEPTRIS_DIAG_ANY_OF = 20,
|
|
102
|
+
YEPTRIS_DIAG_ONE_OF = 21,
|
|
103
|
+
YEPTRIS_DIAG_NOT = 22,
|
|
104
|
+
YEPTRIS_DIAG_REF = 23, /* $ref unresolvable / chain too deep */
|
|
105
|
+
YEPTRIS_DIAG_FALSE_SCHEMA = 24, /* the schema is `false` here */
|
|
106
|
+
YEPTRIS_DIAG_DEPTH = 25, /* recursion guard tripped */
|
|
107
|
+
YEPTRIS_DIAG_LIMIT = 26, /* report truncated (the sentinel
|
|
108
|
+
* rides the LAST slot; more
|
|
109
|
+
* diagnostics were dropped) */
|
|
110
|
+
/* the 2020-12 sweep (#885 item 2) */
|
|
111
|
+
YEPTRIS_DIAG_MULTIPLE_OF = 27,
|
|
112
|
+
YEPTRIS_DIAG_MIN_PROPERTIES = 28,
|
|
113
|
+
YEPTRIS_DIAG_MAX_PROPERTIES = 29,
|
|
114
|
+
YEPTRIS_DIAG_CONTAINS = 30,
|
|
115
|
+
YEPTRIS_DIAG_MIN_CONTAINS = 31,
|
|
116
|
+
YEPTRIS_DIAG_MAX_CONTAINS = 32,
|
|
117
|
+
YEPTRIS_DIAG_DEPENDENT_REQUIRED = 33,
|
|
118
|
+
/* the 2020-12 unevaluated* annotation model (the sota sweep) */
|
|
119
|
+
YEPTRIS_DIAG_UNEVALUATED_PROPERTY = 34, /* no sibling/applicator evaluated it */
|
|
120
|
+
YEPTRIS_DIAG_UNEVALUATED_ITEM = 35,
|
|
121
|
+
} YeptrisDiagCode;
|
|
122
|
+
|
|
123
|
+
/* Bounded diagnostic text; always NUL-terminated (over-long paths and
|
|
124
|
+
* details truncate — the same discipline as the error channel). */
|
|
125
|
+
#define YEPTRIS_DIAG_PATH_MAX 256
|
|
126
|
+
#define YEPTRIS_DIAG_DETAIL_MAX 128
|
|
127
|
+
|
|
128
|
+
typedef struct yeptris_diagnostic {
|
|
129
|
+
uint32_t code; /* YeptrisDiagCode */
|
|
130
|
+
uint32_t line; /* 1-based; 0 = unknown */
|
|
131
|
+
uint32_t col; /* 1-based; 0 = unknown */
|
|
132
|
+
uint32_t offset;
|
|
133
|
+
char path[YEPTRIS_DIAG_PATH_MAX];
|
|
134
|
+
char detail[YEPTRIS_DIAG_DETAIL_MAX];
|
|
135
|
+
} yeptris_diagnostic;
|
|
136
|
+
YEPTRIS_CT_ASSERT(sizeof(yeptris_diagnostic) ==
|
|
137
|
+
16 + YEPTRIS_DIAG_PATH_MAX + YEPTRIS_DIAG_DETAIL_MAX);
|
|
138
|
+
|
|
139
|
+
/* The diagnostics list. Opaque; free it with
|
|
140
|
+
* yeptris_validate_report_free (one call, everything). */
|
|
141
|
+
typedef struct yeptris_validate_report yeptris_validate_report;
|
|
142
|
+
|
|
143
|
+
/* Diagnostic count (0 = the document is valid). */
|
|
144
|
+
YEPTRIS_API size_t yeptris_validate_report_count(const yeptris_validate_report* report);
|
|
145
|
+
|
|
146
|
+
/* Diagnostic i (0-based); NULL out of range. Memory: borrowed from the
|
|
147
|
+
* report — valid until yeptris_validate_report_free. */
|
|
148
|
+
YEPTRIS_API const yeptris_diagnostic*
|
|
149
|
+
yeptris_validate_report_at(const yeptris_validate_report* report, size_t index);
|
|
150
|
+
|
|
151
|
+
YEPTRIS_API void yeptris_validate_report_free(yeptris_validate_report* report);
|
|
152
|
+
|
|
153
|
+
/* Parses `buf` (the same front door as yeptris_parse_ex: encodings,
|
|
154
|
+
* BOM, NEL normalization) and validates every document of the stream
|
|
155
|
+
* against `schema` — the strict lanes: explicit-tag consistency,
|
|
156
|
+
* canonical-form key uniqueness, (12_JSON) string keys over the JSON
|
|
157
|
+
* productions, and (12_FULL) timestamp content against the full
|
|
158
|
+
* family's classifier. Paths are root-relative per document; a
|
|
159
|
+
* multi-document stream prefixes them with the document index (see
|
|
160
|
+
* STREAMS above), so diagnostics name their document. The parse's own
|
|
161
|
+
* guards compose: a document past the engine's depth cap fails the
|
|
162
|
+
* parse (YEPTRIS_ERROR_DEPTH) before any validation runs.
|
|
163
|
+
*
|
|
164
|
+
* Status: YEPTRIS_OK (valid; *out is a report — possibly with zero
|
|
165
|
+
* diagnostics for an empty stream); YEPTRIS_ERROR_SCHEMA (invalid:
|
|
166
|
+
* drain *out); YEPTRIS_ERROR_PARSE / DEPTH / ENCODING / MEMORY (the
|
|
167
|
+
* parse itself failed; *out stays NULL); YEPTRIS_ERROR_ARG.
|
|
168
|
+
*
|
|
169
|
+
* Memory: the caller owns *out; free it with
|
|
170
|
+
* yeptris_validate_report_free. */
|
|
171
|
+
YEPTRIS_API YeptrisStatus yeptris_validate(const char* buf, size_t len, YeptrisSchema schema,
|
|
172
|
+
yeptris_validate_report** out);
|
|
173
|
+
|
|
174
|
+
/* Validates an already-parsed document (or stream). The document is
|
|
175
|
+
* not modified; the report borrows nothing from it. */
|
|
176
|
+
YEPTRIS_API YeptrisStatus yeptris_validate_document(YeptrisDocument doc, YeptrisSchema schema,
|
|
177
|
+
yeptris_validate_report** out);
|
|
178
|
+
|
|
179
|
+
/* The EVENT-ROUTE twin of yeptris_validate (#902): the same parse
|
|
180
|
+
* (front-end, depth/encoding guards, statuses — the DOM route's
|
|
181
|
+
* sink-entry seam) feeding a streaming validator state machine. The
|
|
182
|
+
* family lanes ride the event walk itself; NO node tree is ever
|
|
183
|
+
* built. Everything observable is the DOM route's, by construction
|
|
184
|
+
* and by the differential gate:
|
|
185
|
+
*
|
|
186
|
+
* - diagnostics: the same code rail (0-35 after the sweep), the same report shape and
|
|
187
|
+
* cap, the same JSON-pointer paths and the stream face's
|
|
188
|
+
* per-document attribution — emitted in the DOM walk's order (a
|
|
189
|
+
* mapping's own tag check, its duplicate-key misses, then its
|
|
190
|
+
* pairs' content);
|
|
191
|
+
* - positions: the DOM route's region law — a diagnostic sits at the
|
|
192
|
+
* node's input-borrowed value bytes (0/0 when the engine pooled
|
|
193
|
+
* them), so line/col/offset match bit for bit;
|
|
194
|
+
* - statuses: OK / SCHEMA / PARSE / DEPTH / ENCODING / MEMORY / ARG,
|
|
195
|
+
* byte-identical argument gates (NULL with length, 11_COMPAT).
|
|
196
|
+
* All three families (12_CORE / 12_JSON / 12_FULL) ride both
|
|
197
|
+
* routes with identical verdicts.
|
|
198
|
+
*
|
|
199
|
+
* The compiled JSON Schema lane (yeptris_schema_validate) keeps the
|
|
200
|
+
* DOM route: its evaluator needs random access (uniqueItems, contains,
|
|
201
|
+
* required); a streaming twin waits for #901's annotation-model seam.
|
|
202
|
+
*
|
|
203
|
+
* Memory: the caller owns *out; free it with
|
|
204
|
+
* yeptris_validate_report_free. */
|
|
205
|
+
YEPTRIS_API YeptrisStatus yeptris_validate_stream(const char* buf, size_t len, YeptrisSchema schema,
|
|
206
|
+
yeptris_validate_report** out);
|
|
207
|
+
|
|
208
|
+
/* JSON Schema draft 2020-12 subset (#882 slice 2; #885 item 2; the
|
|
209
|
+
* 2020-12 sota sweep). `schema` is parsed with the same engine (JSON
|
|
210
|
+
* is YAML flow); document 0 of the stream is the schema. Keyword
|
|
211
|
+
* subset: type, enum, const, pattern, minimum, maximum,
|
|
212
|
+
* exclusiveMinimum, exclusiveMaximum (numeric, 2020-12 form),
|
|
213
|
+
* multipleOf (libm-free quotient test),
|
|
214
|
+
* minLength/maxLength (code points), minItems/maxItems, uniqueItems,
|
|
215
|
+
* contains (+ the minContains/maxContains qualifiers), items
|
|
216
|
+
* (+ prefixItems; the draft-07 array form rides as prefixItems),
|
|
217
|
+
* properties, required, patternProperties, propertyNames,
|
|
218
|
+
* minProperties/maxProperties, additionalProperties (bool or schema;
|
|
219
|
+
* excludes patternProperties matches), dependentRequired,
|
|
220
|
+
* dependentSchemas, if/then/else, allOf/anyOf/oneOf/not,
|
|
221
|
+
* unevaluatedProperties/unevaluatedItems (the 2020-12 annotation
|
|
222
|
+
* model: evaluations collect upward through the in-place applicators,
|
|
223
|
+
* a failed branch annotates nothing, and nothing crosses an
|
|
224
|
+
* instance-location boundary), $ref, $dynamicRef, boolean schemas.
|
|
225
|
+
* REFERENCES: $id base-URI composition (RFC 3986 path merge),
|
|
226
|
+
* $anchor/$dynamicAnchor plain-name fragments scoped to their nearest
|
|
227
|
+
* $id resource, JSON Pointer fragments with the percent layer
|
|
228
|
+
* (%25 -> '%', then ~0/~1), and $dynamicRef's runtime dynamic scope
|
|
229
|
+
* (the OUTERMOST schema resource in scope defining the anchor). No
|
|
230
|
+
* network: a reference resolves only against the schema's own
|
|
231
|
+
* identifier space — an external target (the metaschema, an HTTP
|
|
232
|
+
* fixture) is a DIAG_REF, never a fetch. Boolean schemas
|
|
233
|
+
* (`true`/`false`) apply. Unknown keywords and known keywords with
|
|
234
|
+
* unreadable values are ignored (2020-12). Instance types ride the
|
|
235
|
+
* core-schema resolution (the YAML->JSON data model): "y" is boolean,
|
|
236
|
+
* 1.0 is integer. The IETF WG's next-edition draft
|
|
237
|
+
* (draft-ietf-jsonschema-json-schema-00) carries these same keyword
|
|
238
|
+
* semantics — no evaluator delta; the diff record is
|
|
239
|
+
* docs/schema/ietf-wg-draft-delta.md.
|
|
240
|
+
*
|
|
241
|
+
* Status: as yeptris_validate, plus YEPTRIS_ERROR_ARG when the schema
|
|
242
|
+
* bytes hold no document, and YEPTRIS_ERROR_PARSE when they do not
|
|
243
|
+
* parse. A $ref that resolves nowhere is a DIAG_REF diagnostic, not a
|
|
244
|
+
* status. Recursion is depth-guarded (the engine's guard): a
|
|
245
|
+
* self-referential $ref over a deep or cyclic chain reports DIAG_DEPTH
|
|
246
|
+
* / DIAG_REF — never a crash. */
|
|
247
|
+
YEPTRIS_API YeptrisStatus yeptris_json_schema_validate(const char* schema, size_t schema_len,
|
|
248
|
+
const char* buf, size_t len,
|
|
249
|
+
yeptris_validate_report** out);
|
|
250
|
+
|
|
251
|
+
/* The COMPILED SCHEMA — the leptris-XSD economy (#885 item 3): parse
|
|
252
|
+
* the schema ONCE, validate MANY instance streams against the retained
|
|
253
|
+
* model. The handle owns everything it reads: the schema bytes (copied
|
|
254
|
+
* — the retained DOM's views borrow them), the parsed document, and
|
|
255
|
+
* the pattern kernel's compiled programs (the XSD content-model
|
|
256
|
+
* analog: `(a+)+$` compiles once here, not once per validated string
|
|
257
|
+
* the way the one-shot face pays). yeptris_schema_compile returns NULL
|
|
258
|
+
* on failure; yeptris_last_error() carries the why (bad arguments,
|
|
259
|
+
* bytes that hold no document, a schema that does not parse,
|
|
260
|
+
* allocation failure).
|
|
261
|
+
*
|
|
262
|
+
* yeptris_schema_validate keeps yeptris_json_schema_validate's exact
|
|
263
|
+
* status/report contract; diagnostics enumerate every miss across
|
|
264
|
+
* every document of the instance stream — the stream face's document
|
|
265
|
+
* attribution applies (see STREAMS above): a multi-document stream's
|
|
266
|
+
* paths carry the document index. yeptris_schema_free releases
|
|
267
|
+
* the handle and everything it owns in ONE call (no refcounting) —
|
|
268
|
+
* afterwards the handle is DEAD: passing it anywhere is undefined,
|
|
269
|
+
* exactly like a freed document. NULL is accepted (a no-op).
|
|
270
|
+
*
|
|
271
|
+
* Thread law: one schema handle per thread, like documents — the
|
|
272
|
+
* handle is immutable after compile (the pattern programs are built at
|
|
273
|
+
* compile time), so read-only sharing across threads is safe; reports
|
|
274
|
+
* are per-call and caller-owned. */
|
|
275
|
+
typedef struct yeptris_schema yeptris_schema;
|
|
276
|
+
|
|
277
|
+
YEPTRIS_API yeptris_schema* yeptris_schema_compile(const char* bytes, size_t n);
|
|
278
|
+
|
|
279
|
+
YEPTRIS_API YeptrisStatus yeptris_schema_validate(yeptris_schema* s, const char* buf, size_t len,
|
|
280
|
+
yeptris_validate_report** out);
|
|
281
|
+
|
|
282
|
+
YEPTRIS_API void yeptris_schema_free(yeptris_schema* s);
|
|
283
|
+
|
|
284
|
+
/* ---- the TAG-DRIVEN SCHEMA registry (#906 slice 4) -----------------------
|
|
285
|
+
*
|
|
286
|
+
* The dialect table's reserved slot: a compiled schema binds to a user
|
|
287
|
+
* tag, so a document node carrying `!shape` (its EXPLICIT tag, exactly
|
|
288
|
+
* the resolved bytes the DOM exposes — `!shape`, `!<tag:...>`, or a
|
|
289
|
+
* `%TAG`-resolved URI; `!!x` arrives as `tag:yaml.org,2002:x`) has its
|
|
290
|
+
* SUBTREE validated against the bound schema. Registration is the only
|
|
291
|
+
* extension point (OCP): the family walk reads the registry, it never
|
|
292
|
+
* grows schema branches.
|
|
293
|
+
*
|
|
294
|
+
* Matching is byte-exact on the tag's resolved form and fires only on
|
|
295
|
+
* an explicit tag — implicit (plain) typing never triggers a binding.
|
|
296
|
+
* An unregistered tag passes untouched: no diagnostic, no lane. The
|
|
297
|
+
* hook rides the DOM family walk (yeptris_validate_ex /
|
|
298
|
+
* yeptris_validate_document_ex): roots, sequence items and mapping
|
|
299
|
+
* VALUES (a tagged mapping KEY is not registry-validated — its
|
|
300
|
+
* instance path is undefined in the walk's model). Diagnostics from a
|
|
301
|
+
* bound subtree land at the tag site: the tag node's own path + the
|
|
302
|
+
* schema walk's instance pointers, with the offending node's
|
|
303
|
+
* line/col/offset; the report cap and codes are the shared rail.
|
|
304
|
+
* Bindings COMPOSE: a node inside a bound subtree that carries its own
|
|
305
|
+
* registered tag is validated by both schemas.
|
|
306
|
+
*
|
|
307
|
+
* THE REGISTRY LAW (the document-ownership law, no refcounting): the
|
|
308
|
+
* registry BORROWS the compiled schemas it binds — it owns nothing
|
|
309
|
+
* they own. A bound schema must OUTLIVE the registry: free the
|
|
310
|
+
* registry first (yeptris_schema_registry_free), then the schemas.
|
|
311
|
+
* Freeing a bound schema while its registry lives leaves the registry
|
|
312
|
+
* dead (a later lookup is undefined), exactly like a freed document.
|
|
313
|
+
* NULL is accepted everywhere a handle is (a NULL registry is simply
|
|
314
|
+
* no bindings; yeptris_schema_registry_free(NULL) is a no-op).
|
|
315
|
+
*
|
|
316
|
+
* Thread law: one registry per thread, like documents and schemas —
|
|
317
|
+
* it is mutable under register and read-only during validation;
|
|
318
|
+
* read-only sharing across threads (no register in flight) is safe. */
|
|
319
|
+
typedef struct yeptris_schema_registry yeptris_schema_registry;
|
|
320
|
+
|
|
321
|
+
/* A fresh empty registry; NULL on allocation failure. */
|
|
322
|
+
YEPTRIS_API yeptris_schema_registry* yeptris_schema_registry_new(void);
|
|
323
|
+
|
|
324
|
+
/* Binds `tag` (copied — nothing borrows the caller's bytes beyond the
|
|
325
|
+
* call) to the compiled `schema` (borrowed — see THE REGISTRY LAW).
|
|
326
|
+
* Status: YEPTRIS_OK; YEPTRIS_ERROR_ARG (NULL handle, an empty tag,
|
|
327
|
+
* or a NULL schema); YEPTRIS_ERROR_MEMORY. Re-registering a tag
|
|
328
|
+
* REPLACES the binding (last registration wins). */
|
|
329
|
+
YEPTRIS_API YeptrisStatus yeptris_schema_registry_register(yeptris_schema_registry* reg,
|
|
330
|
+
const char* tag, size_t tag_len,
|
|
331
|
+
const yeptris_schema* schema);
|
|
332
|
+
|
|
333
|
+
/* The schema bound to `tag` (exact bytes), or NULL. Memory: borrowed
|
|
334
|
+
* from the registry — valid until a register replaces the tag or the
|
|
335
|
+
* registry is freed. */
|
|
336
|
+
YEPTRIS_API const yeptris_schema* yeptris_schema_registry_lookup(const yeptris_schema_registry* reg,
|
|
337
|
+
const char* tag, size_t tag_len);
|
|
338
|
+
|
|
339
|
+
YEPTRIS_API void yeptris_schema_registry_free(yeptris_schema_registry* reg);
|
|
340
|
+
|
|
341
|
+
/* Validation options (size-versioned like yeptris_emit_options:
|
|
342
|
+
* initialize with {sizeof(yeptris_validate_options)} so future fields
|
|
343
|
+
* stay optional; NULL selects the defaults). */
|
|
344
|
+
typedef struct yeptris_validate_options {
|
|
345
|
+
uint32_t size; /* sizeof(yeptris_validate_options) */
|
|
346
|
+
/* The tag-driven registry (#906 slice 4): NULL = none. Only read
|
|
347
|
+
* when the caller's struct is large enough (size-versioned). The
|
|
348
|
+
* registry is borrowed for the call; see THE REGISTRY LAW above. */
|
|
349
|
+
const yeptris_schema_registry* registry;
|
|
350
|
+
} yeptris_validate_options;
|
|
351
|
+
|
|
352
|
+
/* yeptris_validate / yeptris_validate_document with options: the
|
|
353
|
+
* family walk plus, when a registry is attached, the tag-driven
|
|
354
|
+
* schema applications described above. Everything else (statuses,
|
|
355
|
+
* report shape, paths, positions) is the flat face's, unchanged. */
|
|
356
|
+
YEPTRIS_API YeptrisStatus yeptris_validate_ex(const char* buf, size_t len, YeptrisSchema schema,
|
|
357
|
+
const yeptris_validate_options* opts,
|
|
358
|
+
yeptris_validate_report** out);
|
|
359
|
+
|
|
360
|
+
YEPTRIS_API YeptrisStatus yeptris_validate_document_ex(YeptrisDocument doc, YeptrisSchema schema,
|
|
361
|
+
const yeptris_validate_options* opts,
|
|
362
|
+
yeptris_validate_report** out);
|
|
363
|
+
|
|
364
|
+
/* ---- the structured OUTPUT face (#906 slice 5) ---------------------------
|
|
365
|
+
*
|
|
366
|
+
* The report as the json-schema.org RECOMMENDED OUTPUT shape (core
|
|
367
|
+
* spec section 12; the meta-schema at
|
|
368
|
+
* https://json-schema.org/draft/2020-12/output/schema): one root
|
|
369
|
+
* output unit — {"valid", "keywordLocation", "instanceLocation"} and,
|
|
370
|
+
* when the report carries diagnostics, "errors" — with one child unit
|
|
371
|
+
* per diagnostic {valid, keywordLocation, instanceLocation, error}.
|
|
372
|
+
* This is the published BASIC form: the report is flat by the
|
|
373
|
+
* enumerated-misses law, so the schema-structured DETAILED/VERBOSE
|
|
374
|
+
* hierarchies (which need per-miss schema-side keyword paths the flat
|
|
375
|
+
* report does not carry) are not derivable from it. keywordLocation
|
|
376
|
+
* is derived from the diagnostic code — the keyword's name segment
|
|
377
|
+
* ("/type", "/required", ...; the family codes and the bookkeeping
|
|
378
|
+
* codes sit at the root pointer ""); it is a JSON Pointer, but NOT
|
|
379
|
+
* necessarily resolvable in the schema (the flat report carries no
|
|
380
|
+
* schema path). absoluteKeywordLocation is never emitted, and $ref
|
|
381
|
+
* sites report the root pointer, so the output always satisfies the
|
|
382
|
+
* published meta-schema. Strings are JSON-escaped (RFC 8259); the
|
|
383
|
+
* bytes are UTF-8; the transform is pure and deterministic — the same
|
|
384
|
+
* report always produces the same bytes.
|
|
385
|
+
*
|
|
386
|
+
* buf == NULL: returns the exact byte count needed, writes nothing.
|
|
387
|
+
* Otherwise writes at most cap bytes (NUL-terminated when cap
|
|
388
|
+
* allows) and returns the count written; when cap is too small
|
|
389
|
+
* nothing is written and the needed size is returned. Returns 0 on a
|
|
390
|
+
* NULL report (use the flat face for those — the transform never
|
|
391
|
+
* invents a verdict).
|
|
392
|
+
*
|
|
393
|
+
* Memory: writes into the caller's buffer; borrows nothing. */
|
|
394
|
+
YEPTRIS_API size_t yeptris_validate_report_write(const yeptris_validate_report* report, char* buf,
|
|
395
|
+
size_t cap);
|
|
396
|
+
|
|
397
|
+
#ifdef __cplusplus
|
|
398
|
+
}
|
|
399
|
+
#endif
|
|
400
|
+
|
|
401
|
+
#endif /* YEPTRIS_VALIDATE_H */
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/* values.h — the typed value stream (TODO.impl/15 phase F).
|
|
2
|
+
*
|
|
3
|
+
* The materialization fast path for FFI bindings: one parse, one
|
|
4
|
+
* drain of PRE-CONVERTED typed values. The C side runs the same
|
|
5
|
+
* engine the recorder drives, then converts every scalar by its
|
|
6
|
+
* resolver tag — the host walks a flat array and builds containers,
|
|
7
|
+
* never re-parsing text.
|
|
8
|
+
*
|
|
9
|
+
* The `is_key` bit carries the key/value alternation, so hosts need
|
|
10
|
+
* no pending-key bookkeeping; `tag_id` rides along so hosts with
|
|
11
|
+
* schema quirks (Psych's single-char y/n, PyYAML's dot-required
|
|
12
|
+
* floats) can re-decide a scalar's type from its raw bytes without
|
|
13
|
+
* re-running a conversion grammar.
|
|
14
|
+
*/
|
|
15
|
+
#ifndef YEPTRIS_VALUES_H
|
|
16
|
+
#define YEPTRIS_VALUES_H
|
|
17
|
+
|
|
18
|
+
#include <stddef.h>
|
|
19
|
+
#include <stdint.h>
|
|
20
|
+
|
|
21
|
+
#include <yeptris/api.h>
|
|
22
|
+
#include <yeptris/error.h>
|
|
23
|
+
#include <yeptris/resolve.h>
|
|
24
|
+
|
|
25
|
+
#ifdef __cplusplus
|
|
26
|
+
extern "C" {
|
|
27
|
+
#endif
|
|
28
|
+
|
|
29
|
+
typedef enum {
|
|
30
|
+
YEP_V_DOC = 0, /* document boundary */
|
|
31
|
+
YEP_V_NULL,
|
|
32
|
+
YEP_V_BOOL, /* b carries 0/1 */
|
|
33
|
+
YEP_V_INT, /* i */
|
|
34
|
+
YEP_V_FLOAT, /* d */
|
|
35
|
+
YEP_V_STR, /* off/len bytes */
|
|
36
|
+
YEP_V_TIMESTAMP, /* off/len bytes (host constructs the date) */
|
|
37
|
+
YEP_V_SEQ_OPEN,
|
|
38
|
+
YEP_V_MAP_OPEN,
|
|
39
|
+
YEP_V_CLOSE, /* closes the innermost open container */
|
|
40
|
+
YEP_V_ALIAS, /* off/len: the alias name */
|
|
41
|
+
/* decorates the entry that FOLLOWS it: the anchor name binds to
|
|
42
|
+
* that value (identity for aliases). Emitted only when anchored. */
|
|
43
|
+
YEP_V_ANCHOR, /* off/len: the name */
|
|
44
|
+
} YeptrisValueKind;
|
|
45
|
+
|
|
46
|
+
/* 24 bytes, ABI-pinned. Every scalar carries its raw bytes (off/len)
|
|
47
|
+
* next to a typed payload; `p` holds the INT bits or the FLOAT bits
|
|
48
|
+
* (reinterpreted by kind — hosts unpack it as ONE 64-bit field, so
|
|
49
|
+
* the record costs 7 values, not 8). */
|
|
50
|
+
typedef struct {
|
|
51
|
+
uint8_t kind; /* YeptrisValueKind */
|
|
52
|
+
uint8_t tag_id; /* the resolver's verdict for this scalar */
|
|
53
|
+
uint8_t is_key; /* the entry lands in the inner map's key slot */
|
|
54
|
+
uint8_t b; /* BOOL payload; implicit-plain flag otherwise */
|
|
55
|
+
uint32_t off; /* STR/TIMESTAMP/ALIAS/anchor bytes; SEQ/MAP OPEN:
|
|
56
|
+
* the collection's EXPLICIT tag text ("tag:yaml.
|
|
57
|
+
* org,2002:set") when it carries one — off/len stay
|
|
58
|
+
* 0 for untagged containers, so hosts re-tag
|
|
59
|
+
* containers without a second drain */
|
|
60
|
+
uint32_t len;
|
|
61
|
+
uint64_t p; /* INT or FLOAT payload, by kind */
|
|
62
|
+
} YeptrisValue;
|
|
63
|
+
YEPTRIS_CT_ASSERT(sizeof(YeptrisValue) == 24);
|
|
64
|
+
|
|
65
|
+
/* Parses `yaml` and drains the typed value stream. On success sets
|
|
66
|
+
* *vals / *count / *arena / *arena_len (both malloc'd; free with
|
|
67
|
+
* yeptris_value_free exactly once). Returns YEPTRIS_OK,
|
|
68
|
+
* YEPTRIS_ERROR_PARSE (details via yeptris_last_error), or
|
|
69
|
+
* YEPTRIS_ERROR_MEMORY / YEPTRIS_ERROR_ARG. */
|
|
70
|
+
YEPTRIS_API YeptrisStatus yeptris_value_drain(const char* yaml, size_t len, YeptrisSchema schema,
|
|
71
|
+
YeptrisValue** vals, size_t* count, char** arena,
|
|
72
|
+
size_t* arena_len);
|
|
73
|
+
|
|
74
|
+
YEPTRIS_API void yeptris_value_free(YeptrisValue* vals, char* arena);
|
|
75
|
+
|
|
76
|
+
/* Columnar projection of the same stream (task #42: the materializer
|
|
77
|
+
* wall is per-record struct decoding in FFI hosts — parallel typed
|
|
78
|
+
* buffers let bindings iterate C-speed arrays and unpack whole
|
|
79
|
+
* columns in one call). Same walk, same semantics, same arena; one
|
|
80
|
+
* carved allocation holds payloads/offs/lens/kinds/tags/is_keys/bools
|
|
81
|
+
* (payloads is the block base — yeptris_value_free_columns frees it
|
|
82
|
+
* and the arena; both are safe on a zero-entry drain). */
|
|
83
|
+
typedef struct {
|
|
84
|
+
size_t count;
|
|
85
|
+
size_t arena_len;
|
|
86
|
+
int64_t* payloads; /* INT or FLOAT bits, by kind */
|
|
87
|
+
uint32_t* offs; /* STR/TIMESTAMP/ALIAS/ANCHOR bytes; SEQ/MAP OPEN:
|
|
88
|
+
the explicit tag text when tagged (see
|
|
89
|
+
YeptrisValue.off) */
|
|
90
|
+
uint32_t* lens;
|
|
91
|
+
uint8_t* kinds; /* YeptrisValueKind */
|
|
92
|
+
uint8_t* tags; /* resolver verdict per scalar */
|
|
93
|
+
uint8_t* is_keys;
|
|
94
|
+
uint8_t* bools; /* BOOL payload; implicit-plain flag otherwise */
|
|
95
|
+
char* arena;
|
|
96
|
+
} YeptrisValueColumns;
|
|
97
|
+
|
|
98
|
+
YEPTRIS_API YeptrisStatus yeptris_value_drain_columns(const char* yaml, size_t len,
|
|
99
|
+
YeptrisSchema schema,
|
|
100
|
+
YeptrisValueColumns* cols);
|
|
101
|
+
|
|
102
|
+
YEPTRIS_API void yeptris_value_free_columns(YeptrisValueColumns* cols);
|
|
103
|
+
|
|
104
|
+
#ifdef __cplusplus
|
|
105
|
+
}
|
|
106
|
+
#endif
|
|
107
|
+
|
|
108
|
+
#endif /* YEPTRIS_VALUES_H */
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/* version.h — generated from the CMake project VERSION.
|
|
2
|
+
*
|
|
3
|
+
* CMakeLists.txt project(yeptris VERSION ...) is the single source of truth;
|
|
4
|
+
* scripts/bump-version.sh syncs vcpkg.json and CHANGELOG.md from it. Never
|
|
5
|
+
* hand-edit the generated file (it lives in the build tree).
|
|
6
|
+
*/
|
|
7
|
+
#ifndef YEPTRIS_VERSION_H
|
|
8
|
+
#define YEPTRIS_VERSION_H
|
|
9
|
+
|
|
10
|
+
#include <yeptris/api.h>
|
|
11
|
+
|
|
12
|
+
#define YEPTRIS_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
|
|
13
|
+
#define YEPTRIS_VERSION_MINOR @PROJECT_VERSION_MINOR@
|
|
14
|
+
#define YEPTRIS_VERSION_PATCH @PROJECT_VERSION_PATCH@
|
|
15
|
+
#define YEPTRIS_VERSION_STRING "@PROJECT_VERSION@"
|
|
16
|
+
|
|
17
|
+
#ifdef __cplusplus
|
|
18
|
+
extern "C" {
|
|
19
|
+
#endif
|
|
20
|
+
|
|
21
|
+
/* Returns the library version string ("major.minor.patch").
|
|
22
|
+
* Memory: static storage; valid for the lifetime of the process. */
|
|
23
|
+
YEPTRIS_API const char* yeptris_version(void);
|
|
24
|
+
|
|
25
|
+
#ifdef __cplusplus
|
|
26
|
+
}
|
|
27
|
+
#endif
|
|
28
|
+
|
|
29
|
+
#endif /* YEPTRIS_VERSION_H */
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/* visit.h — language-agnostic value visitor (TODO.restructure/22/24).
|
|
2
|
+
*
|
|
3
|
+
* A push-style sink over the parsed value stream. Hosts that build
|
|
4
|
+
* native objects (Ruby C-API, CPython, etc.) implement the vtable and
|
|
5
|
+
* receive one callback per scalar/container — no intermediate records,
|
|
6
|
+
* no DOM, no host-side walk. The JSON entry is a fused RFC 8259 scan
|
|
7
|
+
* that never allocates a tree; the YAML entry rides the engine; the
|
|
8
|
+
* node entry walks an existing DOM subtree.
|
|
9
|
+
*
|
|
10
|
+
* OCP: a new host is a new vtable, never a core edit. MECE: scanning
|
|
11
|
+
* stays in scan/; this header is only the sink contract. */
|
|
12
|
+
#ifndef YEPTRIS_VISIT_H
|
|
13
|
+
#define YEPTRIS_VISIT_H
|
|
14
|
+
|
|
15
|
+
#include <stddef.h>
|
|
16
|
+
#include <stdint.h>
|
|
17
|
+
|
|
18
|
+
#include <yeptris/api.h>
|
|
19
|
+
#include <yeptris/dom.h>
|
|
20
|
+
#include <yeptris/error.h>
|
|
21
|
+
#include <yeptris/resolve.h>
|
|
22
|
+
|
|
23
|
+
#ifdef __cplusplus
|
|
24
|
+
extern "C" {
|
|
25
|
+
#endif
|
|
26
|
+
|
|
27
|
+
/* Return 0 to continue, nonzero to abort (propagated as the status
|
|
28
|
+
* detail when non-zero; YEPTRIS_ERROR_INTERNAL is the library-side
|
|
29
|
+
* stand-in when the visitor doesn't set a more specific code). */
|
|
30
|
+
typedef struct YeptrisVisitVTable {
|
|
31
|
+
int (*on_null)(void* ctx);
|
|
32
|
+
int (*on_bool)(void* ctx, int truthy);
|
|
33
|
+
int (*on_int)(void* ctx, int64_t v);
|
|
34
|
+
int (*on_float)(void* ctx, double v);
|
|
35
|
+
/* bytes are borrowed from the input (or a short-lived decode
|
|
36
|
+
* scratch for escaped JSON strings — valid only for the duration
|
|
37
|
+
* of the callback). */
|
|
38
|
+
int (*on_string)(void* ctx, const char* p, size_t len);
|
|
39
|
+
int (*on_seq_start)(void* ctx);
|
|
40
|
+
int (*on_seq_end)(void* ctx);
|
|
41
|
+
int (*on_map_start)(void* ctx);
|
|
42
|
+
/* A map key is always a string callback immediately followed by
|
|
43
|
+
* the value; hosts that need the key/value pairing push the key
|
|
44
|
+
* on on_string when is_key is set. */
|
|
45
|
+
int (*on_map_end)(void* ctx);
|
|
46
|
+
/* Optional: 1 when the next scalar/container is a map key. NULL
|
|
47
|
+
* means the visitor does not distinguish (JSON keys are always
|
|
48
|
+
* strings fired via on_string before their value). */
|
|
49
|
+
int (*on_key)(void* ctx, const char* p, size_t len);
|
|
50
|
+
/* Optional document boundary (YAML multi-doc). NULL = ignore. */
|
|
51
|
+
int (*on_doc)(void* ctx);
|
|
52
|
+
/* Optional anchor/alias. NULL = materializer does not support
|
|
53
|
+
* identity (JSON never fires these). */
|
|
54
|
+
int (*on_anchor)(void* ctx, const char* name, size_t len);
|
|
55
|
+
int (*on_alias)(void* ctx, const char* name, size_t len);
|
|
56
|
+
} YeptrisVisitVTable;
|
|
57
|
+
|
|
58
|
+
/* Fused strict-JSON scan → visit. No DOM, no records. On success the
|
|
59
|
+
* visitor saw exactly one value (plus optional ws). */
|
|
60
|
+
YEPTRIS_API YeptrisStatus yeptris_visit_json(const char* data, size_t len,
|
|
61
|
+
const YeptrisVisitVTable* vt, void* ctx);
|
|
62
|
+
|
|
63
|
+
/* YAML parse → visit through the engine (schema selects the resolver).
|
|
64
|
+
* Multi-doc streams fire on_doc before each document's root value. */
|
|
65
|
+
YEPTRIS_API YeptrisStatus yeptris_visit(const char* data, size_t len, YeptrisSchema schema,
|
|
66
|
+
const YeptrisVisitVTable* vt, void* ctx);
|
|
67
|
+
|
|
68
|
+
/* Existing DOM subtree → visit (Node#to_ruby bulk path without
|
|
69
|
+
* records/Marshal). */
|
|
70
|
+
YEPTRIS_API YeptrisStatus yeptris_visit_node(YeptrisNode node, const YeptrisVisitVTable* vt,
|
|
71
|
+
void* ctx);
|
|
72
|
+
|
|
73
|
+
#ifdef __cplusplus
|
|
74
|
+
}
|
|
75
|
+
#endif
|
|
76
|
+
|
|
77
|
+
#endif /* YEPTRIS_VISIT_H */
|