teptris 0.3.21.0-arm-linux → 0.3.23.0-arm-linux
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 +4 -4
- data/ext/teptris_ext/engine/README.md +1 -1
- data/ext/teptris_ext/engine/src/include/teptris/schema.h +7 -0
- data/ext/teptris_ext/engine/src/include/teptris/version.h +2 -2
- data/ext/teptris_ext/engine/src/teptris/schema/formats.c +34 -0
- data/ext/teptris_ext/engine/src/teptris/schema/json_read.c +5 -2
- data/ext/teptris_ext/engine/src/teptris/schema/metaschemas.c +243 -0
- data/ext/teptris_ext/engine/src/teptris/schema/metaschemas.h +15 -0
- data/ext/teptris_ext/engine/src/teptris/schema/refs.c +243 -0
- data/ext/teptris_ext/engine/src/teptris/schema/refs.h +24 -0
- data/ext/teptris_ext/engine/src/teptris/schema/schema.c +903 -55
- data/ext/teptris_ext/engine/src/teptris/schema/schema_internal.h +92 -3
- data/ext/teptris_ext/engine/src/teptris/schema/validate.c +463 -48
- data/lib/teptris/3.3/teptris_ext.so +0 -0
- data/lib/teptris/3.4/teptris_ext.so +0 -0
- data/lib/teptris/4.0/teptris_ext.so +0 -0
- data/lib/teptris/version.rb +1 -1
- metadata +5 -1
|
@@ -19,15 +19,18 @@ enum {
|
|
|
19
19
|
ST_NUMBER = 1 << 2, /* float or integer */
|
|
20
20
|
ST_BOOLEAN = 1 << 3,
|
|
21
21
|
ST_OBJECT = 1 << 4,
|
|
22
|
-
ST_ARRAY = 1 << 5
|
|
22
|
+
ST_ARRAY = 1 << 5,
|
|
23
|
+
ST_NULL = 1 << 6 /* the JSON null type (policy 1: no TOML value) */
|
|
23
24
|
};
|
|
24
|
-
#define ST_ANY
|
|
25
|
+
#define ST_ANY 0x7Fu
|
|
25
26
|
|
|
26
27
|
enum {
|
|
27
28
|
FMT_NONE = 0,
|
|
28
29
|
FMT_DATETIME,
|
|
29
30
|
FMT_DATE,
|
|
30
31
|
FMT_TIME,
|
|
32
|
+
FMT_DATETIME_LOCAL,
|
|
33
|
+
FMT_TIME_LOCAL,
|
|
31
34
|
/* the taplo parity set: every format the jsonschema crate (the
|
|
32
35
|
* engine behind taplo) asserts on; names outside this set are
|
|
33
36
|
* annotations on both sides */
|
|
@@ -104,6 +107,28 @@ struct sch_node {
|
|
|
104
107
|
bool items_set;
|
|
105
108
|
sch_node *add_items; /* additionalItems: applies beyond prefix */
|
|
106
109
|
bool add_items_set;
|
|
110
|
+
sch_node *uneval_props; /* unevaluatedProperties: frame-local */
|
|
111
|
+
sch_node *uneval_items; /* unevaluatedItems: frame-local */
|
|
112
|
+
sch_node *content_schema; /* contentSchema: asserts decoded content */
|
|
113
|
+
/* the dynamic anchors inside this node's own subtree (self
|
|
114
|
+
* included, document order): pushed as one scope frame whenever
|
|
115
|
+
* this node is applied — the dynamic scope grows per entered
|
|
116
|
+
* subschema, not per traversed anchor */
|
|
117
|
+
struct sch_scope_entry {
|
|
118
|
+
const char *name;
|
|
119
|
+
struct sch_node *node;
|
|
120
|
+
const jv *res; /* the anchor's own resource (nearest $id) */
|
|
121
|
+
} *self_scope;
|
|
122
|
+
size_t n_self_scope;
|
|
123
|
+
const jv *res_id; /* the resource root this node sits in */
|
|
124
|
+
bool dynamic_recursive; /* the ref site was a $recursiveRef */
|
|
125
|
+
const char *dynamic_anchor; /* $dynamicAnchor name carried here */
|
|
126
|
+
const char *recursive_anchor; /* "" when $recursiveAnchor is true */
|
|
127
|
+
const char *dynamic_ref; /* "#name" fragment for
|
|
128
|
+
* $dynamicRef / $recursiveRef */
|
|
129
|
+
sch_node *dynamic_ref_target; /* compile-resolved static fallback */
|
|
130
|
+
bool ref_only; /* draft-07-and-older: this $ref ignores siblings */
|
|
131
|
+
bool enum_empty; /* "enum": [] matches nothing */
|
|
107
132
|
sch_node *contains;
|
|
108
133
|
long min_contains, max_contains;
|
|
109
134
|
bool has_contains, has_min_contains, has_max_contains;
|
|
@@ -148,6 +173,8 @@ struct teptris_schema {
|
|
|
148
173
|
char err[256];
|
|
149
174
|
};
|
|
150
175
|
|
|
176
|
+
typedef struct teptris_resource teptris_resource;
|
|
177
|
+
|
|
151
178
|
typedef struct {
|
|
152
179
|
teptris_arena *a;
|
|
153
180
|
jv *root;
|
|
@@ -158,18 +185,76 @@ typedef struct {
|
|
|
158
185
|
bool in_progress;
|
|
159
186
|
} *memo;
|
|
160
187
|
size_t n_memo, cap_memo;
|
|
188
|
+
/* pointer-keyed hash over the memo (compile is O(n), not O(n^2)):
|
|
189
|
+
* open addressing, slot = entry index + 1, 0 = empty */
|
|
190
|
+
uint32_t *memo_hash;
|
|
191
|
+
size_t memo_hash_cap; /* power of two, 0 = absent */
|
|
192
|
+
/* the same treatment for the per-node base table */
|
|
193
|
+
uint32_t *node_base_hash;
|
|
194
|
+
size_t node_base_hash_cap;
|
|
161
195
|
/* dependency-list capacities (grow-in-place across keywords) */
|
|
162
196
|
size_t cap_dep_req, cap_dep_schemas;
|
|
163
|
-
/* anchors: "$anchor": name -> subtree
|
|
197
|
+
/* anchors: "$anchor": name -> subtree (doc-wide; the $anchor
|
|
198
|
+
* space of every loaded resource joins it) */
|
|
164
199
|
struct {
|
|
165
200
|
const char *name;
|
|
166
201
|
jv *target;
|
|
167
202
|
} *anchors;
|
|
168
203
|
size_t n_anchors, cap_anchors;
|
|
204
|
+
/* $dynamicAnchor targets (the static fallback for $dynamicRef) */
|
|
205
|
+
struct {
|
|
206
|
+
const char *name;
|
|
207
|
+
jv *target;
|
|
208
|
+
} *dyn_anchors;
|
|
209
|
+
size_t n_dyn_anchors, cap_dyn_anchors;
|
|
210
|
+
jv *rec_anchor_target;
|
|
211
|
+
/* the resource model: every base URI this compile has materialized */
|
|
212
|
+
teptris_resource *resources;
|
|
213
|
+
size_t n_resources, cap_resources;
|
|
214
|
+
/* the resource the walk is currently inside */
|
|
215
|
+
jv *cur_root; /* its root jv ("#" resolves here) */
|
|
216
|
+
const char *cur_abs; /* its base URI (NULL in local-only mode) */
|
|
217
|
+
const char *cur_dir; /* its fs dir (relative refs join against it) */
|
|
218
|
+
bool ref_exclusive; /* draft-07-and-older: $ref ignores siblings */
|
|
219
|
+
char base_dir[1024]; /* fs dir of the main schema ("" = none) */
|
|
220
|
+
/* the base every node was pre-passed with: compile looks each
|
|
221
|
+
* node's base up here (pointers reach subtrees whose $id chain
|
|
222
|
+
* the document walk would otherwise miss) */
|
|
223
|
+
/* scratch accumulator for attach_self_scope */
|
|
224
|
+
struct sch_scope_entry *entry_acc;
|
|
225
|
+
size_t n_entry_acc, cap_entry_acc;
|
|
226
|
+
/* which standard vocabularies the dialect keeps (8.1.2: a custom
|
|
227
|
+
* metaschema's $vocabulary decides; absent = all of them) */
|
|
228
|
+
unsigned vocab_mask;
|
|
229
|
+
/* standard vocabulary gates (the core vocabulary is mandatory and
|
|
230
|
+
* never gated) */
|
|
231
|
+
#define TEPTRIS_VOC_APPLICATOR 1u
|
|
232
|
+
#define TEPTRIS_VOC_UNEVALUATED 2u
|
|
233
|
+
#define TEPTRIS_VOC_VALIDATION 4u
|
|
234
|
+
#define TEPTRIS_VOC_FORMAT 8u
|
|
235
|
+
#define TEPTRIS_VOC_CONTENT 16u
|
|
236
|
+
#define TEPTRIS_VOC_ALL 31u
|
|
237
|
+
|
|
238
|
+
struct node_base {
|
|
239
|
+
const jv *node;
|
|
240
|
+
const char *abs;
|
|
241
|
+
const char *dir;
|
|
242
|
+
jv *root;
|
|
243
|
+
bool recursive;
|
|
244
|
+
} *node_bases;
|
|
245
|
+
size_t n_node_bases, cap_node_bases;
|
|
169
246
|
char *err;
|
|
170
247
|
size_t err_cap;
|
|
171
248
|
} sctx;
|
|
172
249
|
|
|
250
|
+
/* a materialized resource: a base URI naming a jv subtree */
|
|
251
|
+
struct teptris_resource {
|
|
252
|
+
const char *abs; /* base URI (file://... or empty for local-only) */
|
|
253
|
+
jv *root; /* the resource's root jv ("#" resolves here) */
|
|
254
|
+
sch_node *node; /* compiled root (memo-resolved) */
|
|
255
|
+
bool recursive_anchor; /* $recursiveAnchor: true on the root */
|
|
256
|
+
};
|
|
257
|
+
|
|
173
258
|
/* the tagged value the validator walks: converted from a document's
|
|
174
259
|
* DOM once per validate call, or synthesized (schema-side enum/const
|
|
175
260
|
* values, propertyNames strings) */
|
|
@@ -203,6 +288,7 @@ struct sch_svalue {
|
|
|
203
288
|
size_t n_members;
|
|
204
289
|
sch_svalue **items;
|
|
205
290
|
size_t n_items;
|
|
291
|
+
bool has_offset; /* offset datetimes only (kind rules for formats) */
|
|
206
292
|
};
|
|
207
293
|
|
|
208
294
|
/* schema.c */
|
|
@@ -212,6 +298,9 @@ sch_node *sch_resolve_pointer(sctx *c, const char *pointer);
|
|
|
212
298
|
* with |mant| < 10^18; false for non-finite d */
|
|
213
299
|
bool sch_decimal_of_double(double d, int64_t *mant, int *exp);
|
|
214
300
|
|
|
301
|
+
/* refs.c: the resource loader used by $ref resolution */
|
|
302
|
+
jv *sch_load_resource(sctx *c, const char *abs_uri);
|
|
303
|
+
|
|
215
304
|
/* formats.c */
|
|
216
305
|
/* the string-side format battery (the taplo parity set); datetimes
|
|
217
306
|
* reach it through their canonical text like any other string */
|