include/jsf_parse.h

filter: Statementstmt 98.4% 445 / 452 Branchbran 68.7% 400 / 582 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 81.7% 845 / 1034 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« Fast.xs ↑ Summary include/jsf_types.h »
1 #ifndef JSF_PARSE_H
2 #define JSF_PARSE_H
3  
4 /* Schema SV -> arena IR. One jsf_node_t per subschema; children built into
5 * local offset variables (never a held node pointer across an arena alloc,
6 * per principle 9), then written into the parent by re-fetching it. $ref is
7 * collected during the walk and resolved same-document in a second pass.
8 *
9 * Needs jsf_arena.h, jsf_ir.h, jsf_types.h, jsf_compiled.h + the Perl API. */
10  
11 typedef struct jsf_pctx {
12 jsf_compiled_t *C;
13 HV *path2off; /* full URI string -> IV node offset */
14 AV *refreqs; /* flat triples: node_off(IV), ref(PV), base(PV) */
15 SV *base; /* current base URI (from the nearest $id scope) */
16 SV *resolver; /* coderef: uri -> schema ref (remote docs), or undef */
17 HV *loaded; /* document URIs already fetched */
18 int auto_fetch; /* fetch remote docs via Fetch when no resolver */
19 } jsf_pctx;
20  
21 static uint32_t jsf_parse_schema(pTHX_ jsf_pctx *P, SV *schema, SV *path);
22  
23 /* ---- small helpers ------------------------------------------------------ */
24  
25 491 static uint32_t jsf__type_bit(pTHX_ SV *s) {
26 491 STRLEN l; const char *p = SvPV_const(s, l);
27 491 switch (l) {
28 17 ▶ case 4: if (memEQ(p, "null", 4)) return JSF_T_NULL; break;
Branch: 1 branch
BranchTrueFalseTotal
case 4: if (memEQ(p, "null", 4)) return JSF_T_NULL; break; 17 0 17
29 47 ▶ case 5: if (memEQ(p, "array", 5)) return JSF_T_ARRAY; break;
Branch: 1 branch
BranchTrueFalseTotal
case 5: if (memEQ(p, "array", 5)) return JSF_T_ARRAY; break; 47 0 47
30 295 ▶ case 6: if (memEQ(p, "object", 6)) return JSF_T_OBJECT;
Branch: 1 branch
BranchTrueFalseTotal
case 6: if (memEQ(p, "object", 6)) return JSF_T_OBJECT; 87 208 295
31 208 ▶ if (memEQ(p, "string", 6)) return JSF_T_STRING;
Branch: 1 branch
BranchTrueFalseTotal
if (memEQ(p, "string", 6)) return JSF_T_STRING; 160 48 208
32 48 ▶ if (memEQ(p, "number", 6)) return JSF_T_NUMBER; break;
Branch: 1 branch
BranchTrueFalseTotal
if (memEQ(p, "number", 6)) return JSF_T_NUMBER; break; 48 0 48
33 132 ▶ case 7: if (memEQ(p, "boolean", 7)) return JSF_T_BOOLEAN;
Branch: 1 branch
BranchTrueFalseTotal
case 7: if (memEQ(p, "boolean", 7)) return JSF_T_BOOLEAN; 45 87 132
34 87 ▶ if (memEQ(p, "integer", 7)) return JSF_T_INTEGER; break;
Branch: 1 branch
BranchTrueFalseTotal
if (memEQ(p, "integer", 7)) return JSF_T_INTEGER; break; 87 0 87
35 }
36 0 return 0; /* unknown type name: ignored */
37 }
38  
39 469 static uint32_t jsf__type_mask(pTHX_ SV *tv) {
40 469 uint32_t m = 0;
41 491 ▶ if (SvROK(tv) && SvTYPE(SvRV(tv)) == SVt_PVAV) {
Branch: 2 branches
BranchTrueFalseTotal
if (SvROK(tv) && SvTYPE(SvRV(tv)) == SVt_PVAV) { 22 447 469
if (SvROK(tv) && SvTYPE(SvRV(tv)) == SVt_PVAV) { 22 0 22
42 22 AV *av = (AV *)SvRV(tv);
43 22 SSize_t i, n = av_len(av) + 1;
44 66 ▶ for (i = 0; i < n; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < n; i++) { 44 22 66
45 44 SV **e = av_fetch(av, i, 0);
46 44 ▶ if (e && *e) m |= jsf__type_bit(aTHX_ *e);
Branch: 2 branches
BranchTrueFalseTotal
if (e && *e) m |= jsf__type_bit(aTHX_ *e); 44 0 44
if (e && *e) m |= jsf__type_bit(aTHX_ *e); 44 0 44
47 }
48 } else {
49 447 m = jsf__type_bit(aTHX_ tv);
50 }
51 469 return m;
52 }
53  
54 /* a JSON boolean object, or a bare truthy/falsey scalar used as a schema */
55 239 static int jsf__schema_is_bool(pTHX_ SV *s, int *val) {
56 239 ▶ if (SvROK(s)) {
Branch: 1 branch
BranchTrueFalseTotal
if (SvROK(s)) { 235 4 239
57 235 ▶ if (SvOBJECT(SvRV(s)) && jsf__is_bool_class(aTHX_ s)) { *val = SvTRUE(s) ? 1 : 0; return 1; }
Branch: 2 branches
BranchTrueFalseTotal
if (SvOBJECT(SvRV(s)) && jsf__is_bool_class(aTHX_ s)) { *val = SvTRUE(s) ? 1 : 0; return 1; } 209 26 235
if (SvOBJECT(SvRV(s)) && jsf__is_bool_class(aTHX_ s)) { *val = SvTRUE(s) ? 1 : 0; return 1; } 209 0 209
58 26 return 0; /* a ref (hash/array) is not a boolean schema */
59 }
60 4 *val = SvTRUE(s) ? 1 : 0;
61 4 return 1; /* bare scalar schema -> boolean by truthiness */
62 }
63  
64 /* is this an object keyword we handle, or a benign annotation? otherwise it is
65 * "unsupported" (recorded for the conformance skip list). */
66 2598 static int jsf__recognised(const char *k, STRLEN l) {
67 static const char *const ok[] = {
68 /* matrix */
69 "type","enum","const","minimum","maximum","exclusiveMinimum",
70 "exclusiveMaximum","multipleOf","minLength","maxLength","pattern",
71 "format","items","prefixItems","minItems","maxItems","uniqueItems",
72 "contains","minContains","maxContains","properties","patternProperties",
73 "additionalProperties","required","minProperties","maxProperties",
74 "propertyNames","dependentRequired","dependentSchemas","allOf","anyOf",
75 "oneOf","not","if","then","else","$ref","$defs",
76 "unevaluatedProperties","unevaluatedItems","$dynamicRef","$dynamicAnchor",
77 /* benign annotations / identifiers */
78 "$schema","$id","$anchor","$comment","$vocabulary","title","description",
79 "default","examples","deprecated","readOnly","writeOnly","example",
80 "contentMediaType","contentEncoding","contentSchema","definitions",
81 NULL
82 };
83 int i;
84 67564 ▶ for (i = 0; ok[i]; i++)
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; ok[i]; i++) 67563 1 67564
85 67563 ▶ if ((STRLEN)strlen(ok[i]) == l && memEQ(k, ok[i], l)) return 1;
Branch: 2 branches
BranchTrueFalseTotal
if ((STRLEN)strlen(ok[i]) == l && memEQ(k, ok[i], l)) return 1; 7281 60282 67563
if ((STRLEN)strlen(ok[i]) == l && memEQ(k, ok[i], l)) return 1; 2597 4684 7281
86 1 return 0;
87 }
88  
89 534 static int jsf__cmp_propent(char *base, const jsf_propent *a, const jsf_propent *b) {
90 534 const char *sa = base + a->name_off + sizeof(jsf_str_t);
91 534 const char *sb = base + b->name_off + sizeof(jsf_str_t);
92 534 uint32_t la = a->name_len, lb = b->name_len, m = la < lb ? la : lb;
93 534 int c = memcmp(sa, sb, m);
94 534 ▶ if (c) return c;
Branch: 1 branch
BranchTrueFalseTotal
if (c) return c; 534 0 534
95 0 ▶ return la < lb ? -1 : (la > lb ? 1 : 0);
Branch: 1 branch
BranchTrueFalseTotal
return la < lb ? -1 : (la > lb ? 1 : 0); 0 0 0
96 }
97  
98 /* child path = parent + "/" + seg (+ optional "/" + name). No pointer escaping
99 * in v0.01 (names with '/' or '~' are a documented limitation). */
100 812 static SV *jsf__child_path(pTHX_ SV *path, const char *seg, const char *name, STRLEN nlen) {
101 812 SV *cp = sv_2mortal(newSVsv(path));
102 812 sv_catpvs(cp, "/");
103 812 sv_catpv(cp, seg);
104 812 ▶ if (name) { sv_catpvs(cp, "/"); sv_catpvn(cp, name, nlen); }
Branch: 1 branch
BranchTrueFalseTotal
if (name) { sv_catpvs(cp, "/"); sv_catpvn(cp, name, nlen); } 523 289 812
105 812 return cp;
106 }
107  
108 /* ---- block builders (each returns an arena offset) ---------------------- */
109  
110 191 static uint32_t jsf__build_props(pTHX_ jsf_pctx *P, SV *pv, SV *path) {
111 191 jsf_arena_t *a = P->C->arena;
112 191 HV *h = (HV *)SvRV(pv);
113 191 I32 nk = hv_iterinit(h);
114 191 ▶ jsf_propent *tmp = (jsf_propent *)malloc(sizeof(jsf_propent) * (nk > 0 ? nk : 1));
Branch: 1 branch
BranchTrueFalseTotal
jsf_propent *tmp = (jsf_propent *)malloc(sizeof(jsf_propent) * (nk > 0 ? nk : 1)); 191 0 191
115 191 uint32_t cnt = 0, off, i, j;
116 jsf_proptab *pt;
117 HE *he;
118 char *base;
119 jsf_propent key;
120 191 ▶ if (!tmp) croak("oom");
Branch: 1 branch
BranchTrueFalseTotal
if (!tmp) croak("oom"); 0 191 191
121 523 ▶ while ((he = hv_iternext(h))) {
Branch: 1 branch
BranchTrueFalseTotal
while ((he = hv_iternext(h))) { 332 191 523
122 332 ▶ STRLEN kl; char *k = HePV(he, kl);
Branch: 1 branch
BranchTrueFalseTotal
STRLEN kl; char *k = HePV(he, kl); 0 332 332
123 332 SV *cpath = jsf__child_path(aTHX_ path, "properties", k, kl);
124 332 uint32_t child_off = jsf_parse_schema(aTHX_ P, HeVAL(he), cpath);
125 332 uint32_t name_off = jsf_arena_intern(a, k, (uint32_t)kl);
126 332 ▶ U32 hh; PERL_HASH(hh, k, kl);
Branch: 1 branch
BranchTrueFalseTotal
U32 hh; PERL_HASH(hh, k, kl); 332 0 332
127 332 tmp[cnt].name_off = name_off; tmp[cnt].child_off = child_off;
128 332 tmp[cnt].hash = hh; tmp[cnt].name_len = (uint32_t)kl;
129 332 cnt++;
130 }
131 /* insertion sort by name (deterministic order + bsearch); base is stable
132 * here because interning is done and we alloc the block afterwards. */
133 191 base = a->base;
134 332 ▶ for (i = 1; i < cnt; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 1; i < cnt; i++) { 141 191 332
135 141 key = tmp[i]; j = i;
136 576 ▶ while (j > 0 && jsf__cmp_propent(base, &tmp[j - 1], &key) > 0) { tmp[j] = tmp[j - 1]; j--; }
Branch: 2 branches
BranchTrueFalseTotal
while (j > 0 && jsf__cmp_propent(base, &tmp[j - 1], &key) > 0) { tmp[j] = tmp[j - 1]; j--; } 534 42 576
while (j > 0 && jsf__cmp_propent(base, &tmp[j - 1], &key) > 0) { tmp[j] = tmp[j - 1]; j--; } 435 99 534
137 141 tmp[j] = key;
138 }
139 191 off = jsf_arena_alloc(a, (uint32_t)(sizeof(jsf_proptab) + cnt * sizeof(jsf_propent)), JSF_ALIGNOF(jsf_propent));
140 191 pt = (jsf_proptab *)jsf_arena_ptr(a, off);
141 191 pt->n = cnt;
142 191 ▶ if (cnt) memcpy((char *)pt + sizeof(jsf_proptab), tmp, cnt * sizeof(jsf_propent));
Branch: 1 branch
BranchTrueFalseTotal
if (cnt) memcpy((char *)pt + sizeof(jsf_proptab), tmp, cnt * sizeof(jsf_propent)); 191 0 191
143 191 free(tmp);
144 191 return off;
145 }
146  
147 63 static uint32_t jsf__build_reqset(pTHX_ jsf_pctx *P, SV *rv, uint32_t props_off) {
148 63 jsf_arena_t *a = P->C->arena;
149 63 AV *av = (AV *)SvRV(rv);
150 63 SSize_t i, n = av_len(av) + 1;
151 63 ▶ jsf_reqent *tmp = (jsf_reqent *)malloc(sizeof(jsf_reqent) * (n > 0 ? n : 1));
Branch: 1 branch
BranchTrueFalseTotal
jsf_reqent *tmp = (jsf_reqent *)malloc(sizeof(jsf_reqent) * (n > 0 ? n : 1)); 62 1 63
152 uint32_t off; jsf_reqset *rs;
153 63 ▶ if (!tmp) croak("oom");
Branch: 1 branch
BranchTrueFalseTotal
if (!tmp) croak("oom"); 0 63 63
154 136 ▶ for (i = 0; i < n; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < n; i++) { 73 63 136
155 73 SV **e = av_fetch(av, i, 0);
156 146 ▶ STRLEN kl; const char *k = (e && *e) ? SvPV_const(*e, kl) : "";
Branch: 2 branches
BranchTrueFalseTotal
STRLEN kl; const char *k = (e && *e) ? SvPV_const(*e, kl) : ""; 73 0 73
STRLEN kl; const char *k = (e && *e) ? SvPV_const(*e, kl) : ""; 73 0 73
157 73 ▶ uint32_t name_off = jsf_arena_intern(a, k, (uint32_t)(e && *e ? kl : 0));
Branch: 2 branches
BranchTrueFalseTotal
uint32_t name_off = jsf_arena_intern(a, k, (uint32_t)(e && *e ? kl : 0)); 73 0 73
uint32_t name_off = jsf_arena_intern(a, k, (uint32_t)(e && *e ? kl : 0)); 73 0 73
158 73 uint32_t idx = JSF_NO_IDX;
159 73 ▶ if (props_off != JSF_NULL_OFF) {
Branch: 1 branch
BranchTrueFalseTotal
if (props_off != JSF_NULL_OFF) { 55 18 73
160 55 jsf_proptab *pt = (jsf_proptab *)jsf_arena_ptr(a, props_off);
161 55 jsf_propent *en = (jsf_propent *)((char *)pt + sizeof(jsf_proptab));
162 uint32_t p;
163 63 ▶ for (p = 0; p < pt->n; p++) if (en[p].name_off == name_off) { idx = p; break; }
Branch: 2 branches
BranchTrueFalseTotal
for (p = 0; p < pt->n; p++) if (en[p].name_off == name_off) { idx = p; break; } 53 8 61
for (p = 0; p < pt->n; p++) if (en[p].name_off == name_off) { idx = p; break; } 61 2 63
164 }
165 73 tmp[i].name_off = name_off; tmp[i].prop_idx = idx;
166 }
167 63 off = jsf_arena_alloc(a, (uint32_t)(sizeof(jsf_reqset) + n * sizeof(jsf_reqent)), JSF_ALIGNOF(jsf_reqent));
168 63 rs = (jsf_reqset *)jsf_arena_ptr(a, off);
169 63 rs->n = (uint32_t)n;
170 63 ▶ if (n) memcpy((char *)rs + sizeof(jsf_reqset), tmp, n * sizeof(jsf_reqent));
Branch: 1 branch
BranchTrueFalseTotal
if (n) memcpy((char *)rs + sizeof(jsf_reqset), tmp, n * sizeof(jsf_reqent)); 62 1 63
171 63 free(tmp);
172 63 return off;
173 }
174  
175 144 static uint32_t jsf__build_offlist(pTHX_ jsf_pctx *P, SV *av_sv, SV *path, const char *seg) {
176 144 jsf_arena_t *a = P->C->arena;
177 144 AV *av = (AV *)SvRV(av_sv);
178 144 SSize_t i, n = av_len(av) + 1;
179 144 ▶ uint32_t *tmp = (uint32_t *)malloc(sizeof(uint32_t) * (n > 0 ? n : 1));
Branch: 1 branch
BranchTrueFalseTotal
uint32_t *tmp = (uint32_t *)malloc(sizeof(uint32_t) * (n > 0 ? n : 1)); 144 0 144
180 uint32_t off; jsf_offlist *ol;
181 144 ▶ if (!tmp) croak("oom");
Branch: 1 branch
BranchTrueFalseTotal
if (!tmp) croak("oom"); 0 144 144
182 399 ▶ for (i = 0; i < n; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < n; i++) { 255 144 399
183 255 SV **e = av_fetch(av, i, 0);
184 255 SV *cp = sv_2mortal(newSVsv(path));
185 255 sv_catpvs(cp, "/"); sv_catpv(cp, seg);
186 255 sv_catpvf(cp, "/%d", (int)i);
187 255 ▶ tmp[i] = (e && *e) ? jsf_parse_schema(aTHX_ P, *e, cp) : JSF_NULL_OFF;
Branch: 2 branches
BranchTrueFalseTotal
tmp[i] = (e && *e) ? jsf_parse_schema(aTHX_ P, *e, cp) : JSF_NULL_OFF; 255 0 255
tmp[i] = (e && *e) ? jsf_parse_schema(aTHX_ P, *e, cp) : JSF_NULL_OFF; 255 0 255
188 }
189 144 off = jsf_arena_alloc(a, (uint32_t)(sizeof(jsf_offlist) + n * sizeof(uint32_t)), JSF_ALIGNOF(uint32_t));
190 144 ol = (jsf_offlist *)jsf_arena_ptr(a, off);
191 144 ol->n = (uint32_t)n;
192 144 ▶ if (n) memcpy((char *)ol + sizeof(jsf_offlist), tmp, n * sizeof(uint32_t));
Branch: 1 branch
BranchTrueFalseTotal
if (n) memcpy((char *)ol + sizeof(jsf_offlist), tmp, n * sizeof(uint32_t)); 144 0 144
193 144 free(tmp);
194 144 return off;
195 }
196  
197 16 static uint32_t jsf__build_pattab(pTHX_ jsf_pctx *P, SV *pv, SV *path) {
198 16 jsf_arena_t *a = P->C->arena;
199 16 HV *h = (HV *)SvRV(pv);
200 16 I32 nk = hv_iterinit(h);
201 16 ▶ jsf_patent *tmp = (jsf_patent *)malloc(sizeof(jsf_patent) * (nk > 0 ? nk : 1));
Branch: 1 branch
BranchTrueFalseTotal
jsf_patent *tmp = (jsf_patent *)malloc(sizeof(jsf_patent) * (nk > 0 ? nk : 1)); 16 0 16
202 16 uint32_t cnt = 0, off; jsf_pattab *pt; HE *he;
203 16 ▶ if (!tmp) croak("oom");
Branch: 1 branch
BranchTrueFalseTotal
if (!tmp) croak("oom"); 0 16 16
204 35 ▶ while ((he = hv_iternext(h))) {
Branch: 1 branch
BranchTrueFalseTotal
while ((he = hv_iternext(h))) { 19 16 35
205 19 ▶ STRLEN kl; char *k = HePV(he, kl);
Branch: 1 branch
BranchTrueFalseTotal
STRLEN kl; char *k = HePV(he, kl); 0 19 19
206 19 SV *cpath = jsf__child_path(aTHX_ path, "patternProperties", k, kl);
207 19 uint32_t child_off = jsf_parse_schema(aTHX_ P, HeVAL(he), cpath);
208 19 uint32_t pat_off = jsf_arena_intern(a, k, (uint32_t)kl);
209 19 tmp[cnt].pat_off = pat_off; tmp[cnt].child_off = child_off; cnt++;
210 }
211 16 off = jsf_arena_alloc(a, (uint32_t)(sizeof(jsf_pattab) + cnt * sizeof(jsf_patent)), JSF_ALIGNOF(jsf_patent));
212 16 pt = (jsf_pattab *)jsf_arena_ptr(a, off);
213 16 pt->n = cnt;
214 16 ▶ if (cnt) memcpy((char *)pt + sizeof(jsf_pattab), tmp, cnt * sizeof(jsf_patent));
Branch: 1 branch
BranchTrueFalseTotal
if (cnt) memcpy((char *)pt + sizeof(jsf_pattab), tmp, cnt * sizeof(jsf_patent)); 16 0 16
215 16 free(tmp);
216 16 return off;
217 }
218  
219 /* a bare list of interned name offsets (for dependentRequired values) */
220 6 static uint32_t jsf__build_namelist(pTHX_ jsf_pctx *P, SV *av_sv) {
221 6 jsf_arena_t *a = P->C->arena;
222 6 AV *av = (AV *)SvRV(av_sv);
223 6 SSize_t i, n = av_len(av) + 1;
224 6 ▶ uint32_t *tmp = (uint32_t *)malloc(sizeof(uint32_t) * (n > 0 ? n : 1));
Branch: 1 branch
BranchTrueFalseTotal
uint32_t *tmp = (uint32_t *)malloc(sizeof(uint32_t) * (n > 0 ? n : 1)); 5 1 6
225 uint32_t off; jsf_offlist *ol;
226 6 ▶ if (!tmp) croak("oom");
Branch: 1 branch
BranchTrueFalseTotal
if (!tmp) croak("oom"); 0 6 6
227 12 ▶ for (i = 0; i < n; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < n; i++) { 6 6 12
228 6 SV **e = av_fetch(av, i, 0);
229 12 ▶ STRLEN kl; const char *k = (e && *e) ? SvPV_const(*e, kl) : "";
Branch: 2 branches
BranchTrueFalseTotal
STRLEN kl; const char *k = (e && *e) ? SvPV_const(*e, kl) : ""; 6 0 6
STRLEN kl; const char *k = (e && *e) ? SvPV_const(*e, kl) : ""; 6 0 6
230 6 ▶ tmp[i] = jsf_arena_intern(a, k, (uint32_t)(e && *e ? kl : 0));
Branch: 2 branches
BranchTrueFalseTotal
tmp[i] = jsf_arena_intern(a, k, (uint32_t)(e && *e ? kl : 0)); 6 0 6
tmp[i] = jsf_arena_intern(a, k, (uint32_t)(e && *e ? kl : 0)); 6 0 6
231 }
232 6 off = jsf_arena_alloc(a, (uint32_t)(sizeof(jsf_offlist) + n * sizeof(uint32_t)), JSF_ALIGNOF(uint32_t));
233 6 ol = (jsf_offlist *)jsf_arena_ptr(a, off);
234 6 ol->n = (uint32_t)n;
235 6 ▶ if (n) memcpy((char *)ol + sizeof(jsf_offlist), tmp, n * sizeof(uint32_t));
Branch: 1 branch
BranchTrueFalseTotal
if (n) memcpy((char *)ol + sizeof(jsf_offlist), tmp, n * sizeof(uint32_t)); 5 1 6
236 6 free(tmp);
237 6 return off;
238 }
239  
240 8 static uint32_t jsf__build_depsch(pTHX_ jsf_pctx *P, SV *pv, SV *path) {
241 8 jsf_arena_t *a = P->C->arena;
242 8 HV *h = (HV *)SvRV(pv);
243 8 I32 nk = hv_iterinit(h);
244 8 ▶ jsf_dsent *tmp = (jsf_dsent *)malloc(sizeof(jsf_dsent) * (nk > 0 ? nk : 1));
Branch: 1 branch
BranchTrueFalseTotal
jsf_dsent *tmp = (jsf_dsent *)malloc(sizeof(jsf_dsent) * (nk > 0 ? nk : 1)); 8 0 8
245 8 uint32_t cnt = 0, off; jsf_dstab *dt; HE *he;
246 8 ▶ if (!tmp) croak("oom");
Branch: 1 branch
BranchTrueFalseTotal
if (!tmp) croak("oom"); 0 8 8
247 20 ▶ while ((he = hv_iternext(h))) {
Branch: 1 branch
BranchTrueFalseTotal
while ((he = hv_iternext(h))) { 12 8 20
248 12 ▶ STRLEN kl; char *k = HePV(he, kl);
Branch: 1 branch
BranchTrueFalseTotal
STRLEN kl; char *k = HePV(he, kl); 0 12 12
249 12 SV *cpath = jsf__child_path(aTHX_ path, "dependentSchemas", k, kl);
250 12 uint32_t sch = jsf_parse_schema(aTHX_ P, HeVAL(he), cpath);
251 12 uint32_t name_off = jsf_arena_intern(a, k, (uint32_t)kl);
252 12 tmp[cnt].name_off = name_off; tmp[cnt].sch_off = sch; cnt++;
253 }
254 8 off = jsf_arena_alloc(a, (uint32_t)(sizeof(jsf_dstab) + cnt * sizeof(jsf_dsent)), JSF_ALIGNOF(jsf_dsent));
255 8 dt = (jsf_dstab *)jsf_arena_ptr(a, off);
256 8 dt->n = cnt;
257 8 ▶ if (cnt) memcpy((char *)dt + sizeof(jsf_dstab), tmp, cnt * sizeof(jsf_dsent));
Branch: 1 branch
BranchTrueFalseTotal
if (cnt) memcpy((char *)dt + sizeof(jsf_dstab), tmp, cnt * sizeof(jsf_dsent)); 8 0 8
258 8 free(tmp);
259 8 return off;
260 }
261  
262 5 static uint32_t jsf__build_deptab(pTHX_ jsf_pctx *P, SV *pv) {
263 5 jsf_arena_t *a = P->C->arena;
264 5 HV *h = (HV *)SvRV(pv);
265 5 I32 nk = hv_iterinit(h);
266 5 ▶ jsf_depent *tmp = (jsf_depent *)malloc(sizeof(jsf_depent) * (nk > 0 ? nk : 1));
Branch: 1 branch
BranchTrueFalseTotal
jsf_depent *tmp = (jsf_depent *)malloc(sizeof(jsf_depent) * (nk > 0 ? nk : 1)); 5 0 5
267 5 uint32_t cnt = 0, off; jsf_deptab *dt; HE *he;
268 5 ▶ if (!tmp) croak("oom");
Branch: 1 branch
BranchTrueFalseTotal
if (!tmp) croak("oom"); 0 5 5
269 11 ▶ while ((he = hv_iternext(h))) {
Branch: 1 branch
BranchTrueFalseTotal
while ((he = hv_iternext(h))) { 6 5 11
270 6 ▶ STRLEN kl; char *k = HePV(he, kl);
Branch: 1 branch
BranchTrueFalseTotal
STRLEN kl; char *k = HePV(he, kl); 0 6 6
271 6 SV *val = HeVAL(he);
272 6 ▶ uint32_t names_off = (SvROK(val) && SvTYPE(SvRV(val)) == SVt_PVAV)
Branch: 1 branch
BranchTrueFalseTotal
uint32_t names_off = (SvROK(val) && SvTYPE(SvRV(val)) == SVt_PVAV) 6 0 6
273 12 ▶ ? jsf__build_namelist(aTHX_ P, val) : JSF_NULL_OFF;
Branch: 1 branch
BranchTrueFalseTotal
? jsf__build_namelist(aTHX_ P, val) : JSF_NULL_OFF; 6 0 6
274 6 uint32_t name_off = jsf_arena_intern(a, k, (uint32_t)kl);
275 6 tmp[cnt].name_off = name_off; tmp[cnt].names_off = names_off; cnt++;
276 }
277 5 off = jsf_arena_alloc(a, (uint32_t)(sizeof(jsf_deptab) + cnt * sizeof(jsf_depent)), JSF_ALIGNOF(jsf_depent));
278 5 dt = (jsf_deptab *)jsf_arena_ptr(a, off);
279 5 dt->n = cnt;
280 5 ▶ if (cnt) memcpy((char *)dt + sizeof(jsf_deptab), tmp, cnt * sizeof(jsf_depent));
Branch: 1 branch
BranchTrueFalseTotal
if (cnt) memcpy((char *)dt + sizeof(jsf_deptab), tmp, cnt * sizeof(jsf_depent)); 5 0 5
281 5 free(tmp);
282 5 return off;
283 }
284  
285 /* ---- the node parser ---------------------------------------------------- */
286  
287 1585 static uint32_t jsf_parse_schema(pTHX_ jsf_pctx *P, SV *schema, SV *path) {
288 1585 jsf_arena_t *a = P->C->arena;
289 1585 uint32_t off = jsf_arena_alloc(a, (uint32_t)sizeof(jsf_node_t), JSF_ALIGNOF(jsf_node_t));
290 HV *h;
291 1585 uint64_t present = 0;
292 1585 uint32_t type_mask = 0;
293 1585 uint8_t unique = 0;
294 /* local field accumulators */
295 1585 uint32_t enum_keep = 0, enum_n = 0, const_keep = 0, default_keep = 0;
296 1585 NV minimum=0, maximum=0, exmin=0, exmax=0, mulof=0;
297 1585 UV min_length=0, max_length=0, min_items=0, max_items=0;
298 1585 UV min_contains=0, max_contains=0, min_props=0, max_props=0;
299 1585 uint32_t pattern_off=0, format_off=0, items_off=0, prefix_off=0, contains_off=0;
300 1585 uint32_t props_off=0, patprops_off=0, addprops_off=0, required_off=0;
301 1585 uint32_t propnames_off=0, depreq_off=0, depsch_off=0;
302 1585 uint32_t allof_off=0, anyof_off=0, oneof_off=0, not_off=0;
303 1585 uint32_t if_off=0, then_off=0, else_off=0;
304 1585 uint32_t unevalprops_off=0, unevalitems_off=0;
305 1585 uint32_t dynref_name_off=0;
306 1585 uint8_t tag = JSF_TAG_NORMAL;
307 int bval;
308 jsf_node_t *n;
309 SV **e;
310 1585 SV *saved_base = NULL; /* restored on the way out if $id opened a scope */
311  
312 1585 ▶ if (off == JSF_NULL_OFF) croak("JSON::Schema::Fast: out of memory");
Branch: 1 branch
BranchTrueFalseTotal
if (off == JSF_NULL_OFF) croak("JSON::Schema::Fast: out of memory"); 0 1585 1585
313  
314 /* $id opens a new base-URI scope (reset the base-relative pointer to "#" and
315 * register the node under its bare $id); $anchor registers a named location;
316 * every node is registered under its canonical URI (base + pointer). */
317 2972 ▶ if (SvROK(schema) && SvTYPE(SvRV(schema)) == SVt_PVHV) {
Branch: 2 branches
BranchTrueFalseTotal
if (SvROK(schema) && SvTYPE(SvRV(schema)) == SVt_PVHV) { 1583 2 1585
if (SvROK(schema) && SvTYPE(SvRV(schema)) == SVt_PVHV) { 1387 196 1583
318 1387 HV *hh = (HV *)SvRV(schema);
319 1387 SV **idv = hv_fetchs(hh, "$id", 0), **anv;
320 1387 ▶ if (idv && *idv && SvPOK(*idv) && SvCUR(*idv)) {
Branch: 4 branches
BranchTrueFalseTotal
if (idv && *idv && SvPOK(*idv) && SvCUR(*idv)) { 123 1264 1387
if (idv && *idv && SvPOK(*idv) && SvCUR(*idv)) { 123 0 123
if (idv && *idv && SvPOK(*idv) && SvCUR(*idv)) { 123 0 123
if (idv && *idv && SvPOK(*idv) && SvCUR(*idv)) { 123 0 123
321 123 SV *resolved = jsf_uri_resolve(aTHX_ P->base, *idv);
322 123 saved_base = P->base;
323 123 P->base = jsf_uri_base_of(aTHX_ resolved);
324 123 path = sv_2mortal(newSVpvs("#"));
325 123 { SV *k = sv_2mortal(newSVsv(P->base)); (void)hv_store_ent(P->path2off, k, newSViv((IV)off), 0); }
326 }
327 1387 { SV *k = sv_2mortal(newSVsv(P->base)); sv_catsv(k, path); (void)hv_store_ent(P->path2off, k, newSViv((IV)off), 0); }
328 1387 ▶ if ((anv = hv_fetchs(hh, "$anchor", 0)) && *anv && SvPOK(*anv)) {
Branch: 3 branches
BranchTrueFalseTotal
if ((anv = hv_fetchs(hh, "$anchor", 0)) && *anv && SvPOK(*anv)) { 17 1370 1387
if ((anv = hv_fetchs(hh, "$anchor", 0)) && *anv && SvPOK(*anv)) { 17 0 17
if ((anv = hv_fetchs(hh, "$anchor", 0)) && *anv && SvPOK(*anv)) { 17 0 17
329 17 SV *k = sv_2mortal(newSVsv(P->base)); sv_catpvs(k, "#"); sv_catsv(k, *anv);
330 17 (void)hv_store_ent(P->path2off, k, newSViv((IV)off), 0);
331 }
332 /* $dynamicAnchor registers as a plain anchor AND in the dynamic map */
333 1387 ▶ if ((anv = hv_fetchs(hh, "$dynamicAnchor", 0)) && *anv && SvPOK(*anv)) {
Branch: 3 branches
BranchTrueFalseTotal
if ((anv = hv_fetchs(hh, "$dynamicAnchor", 0)) && *anv && SvPOK(*anv)) { 55 1332 1387
if ((anv = hv_fetchs(hh, "$dynamicAnchor", 0)) && *anv && SvPOK(*anv)) { 55 0 55
if ((anv = hv_fetchs(hh, "$dynamicAnchor", 0)) && *anv && SvPOK(*anv)) { 55 0 55
334 55 SV *k1 = sv_2mortal(newSVsv(P->base)); sv_catpvs(k1, "#"); sv_catsv(k1, *anv);
335 55 (void)hv_store_ent(P->path2off, k1, newSViv((IV)off), 0);
336 55 { SV *k2 = sv_2mortal(newSVsv(P->base)); sv_catpvs(k2, "#"); sv_catsv(k2, *anv);
337 55 (void)hv_store_ent(P->C->dynmap, k2, newSViv((IV)off), 0); }
338 55 P->C->has_dynamic = 1;
339 }
340 } else {
341 198 SV *k = sv_2mortal(newSVsv(P->base)); sv_catsv(k, path);
342 198 (void)hv_store_ent(P->path2off, k, newSViv((IV)off), 0);
343 }
344  
345 /* schemaLocation pointer (base-relative), minus the leading '#'. */
346 {
347 1585 STRLEN pl; const char *pp = SvPV_const(path, pl);
348 1585 ▶ uint32_t sp = jsf_arena_intern(a, pl > 0 ? pp + 1 : pp,
Branch: 1 branch
BranchTrueFalseTotal
uint32_t sp = jsf_arena_intern(a, pl > 0 ? pp + 1 : pp, 1585 0 1585
349 1585 ▶ (uint32_t)(pl > 0 ? pl - 1 : 0));
Branch: 1 branch
BranchTrueFalseTotal
(uint32_t)(pl > 0 ? pl - 1 : 0)); 1585 0 1585
350 1585 jsf_node_t *nn = (jsf_node_t *)jsf_arena_ptr(a, off);
351 1585 nn->schema_path_off = sp;
352 }
353  
354 /* boolean / non-object schema */
355 1585 ▶ if (!(SvROK(schema) && SvTYPE(SvRV(schema)) == SVt_PVHV)) {
Branch: 2 branches
BranchTrueFalseTotal
if (!(SvROK(schema) && SvTYPE(SvRV(schema)) == SVt_PVHV)) { 1583 2 1585
if (!(SvROK(schema) && SvTYPE(SvRV(schema)) == SVt_PVHV)) { 196 1387 1583
356 198 ▶ if (jsf__schema_is_bool(aTHX_ schema, &bval)) {
Branch: 1 branch
BranchTrueFalseTotal
if (jsf__schema_is_bool(aTHX_ schema, &bval)) { 198 0 198
357 198 n = (jsf_node_t *)jsf_arena_ptr(a, off);
358 198 ▶ n->tag = bval ? JSF_TAG_TRUE : JSF_TAG_FALSE;
Branch: 1 branch
BranchTrueFalseTotal
n->tag = bval ? JSF_TAG_TRUE : JSF_TAG_FALSE; 96 102 198
359 198 return off;
360 }
361 0 croak("JSON::Schema::Fast: schema must be a hashref or boolean");
362 }
363  
364 1387 h = (HV *)SvRV(schema);
365 1387 ▶ if (HvKEYS(h) == 0) { /* {} == true */
Branch: 2 branches
BranchTrueFalseTotal
if (HvKEYS(h) == 0) { /* {} == true */ 0 1387 1387
if (HvKEYS(h) == 0) { /* {} == true */ 38 1349 1387
366 38 n = (jsf_node_t *)jsf_arena_ptr(a, off);
367 38 n->tag = JSF_TAG_TRUE;
368 38 return off;
369 }
370  
371 /* count unsupported (out-of-matrix, non-annotation) keys */
372 {
373 1349 HE *he; hv_iterinit(h);
374 3947 ▶ while ((he = hv_iternext(h))) {
Branch: 1 branch
BranchTrueFalseTotal
while ((he = hv_iternext(h))) { 2598 1349 3947
375 2598 ▶ STRLEN kl; char *k = HePV(he, kl);
Branch: 1 branch
BranchTrueFalseTotal
STRLEN kl; char *k = HePV(he, kl); 0 2598 2598
376 2598 ▶ if (!jsf__recognised(k, kl)) P->C->unsupported++;
Branch: 1 branch
BranchTrueFalseTotal
if (!jsf__recognised(k, kl)) P->C->unsupported++; 1 2597 2598
377 }
378 }
379  
380 /* $defs first: build the definition subschemas so $ref can resolve them. */
381 1349 ▶ if ((e = hv_fetchs(h, "$defs", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e)) == SVt_PVHV) {
Branch: 4 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "$defs", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e)) == SVt_PVHV) { 112 1237 1349
if ((e = hv_fetchs(h, "$defs", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e)) == SVt_PVHV) { 112 0 112
if ((e = hv_fetchs(h, "$defs", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e)) == SVt_PVHV) { 112 0 112
if ((e = hv_fetchs(h, "$defs", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e)) == SVt_PVHV) { 112 0 112
382 112 HV *d = (HV *)SvRV(*e); HE *he; hv_iterinit(d);
383 272 ▶ while ((he = hv_iternext(d))) {
Branch: 1 branch
BranchTrueFalseTotal
while ((he = hv_iternext(d))) { 160 112 272
384 160 ▶ STRLEN kl; char *k = HePV(he, kl);
Branch: 1 branch
BranchTrueFalseTotal
STRLEN kl; char *k = HePV(he, kl); 0 160 160
385 160 SV *cp = jsf__child_path(aTHX_ path, "$defs", k, kl);
386 160 (void)jsf_parse_schema(aTHX_ P, HeVAL(he), cp);
387 }
388 }
389  
390 1349 ▶ if ((e = hv_fetchs(h, "type", 0)) && *e) { type_mask = jsf__type_mask(aTHX_ *e); present |= JSF_HAS_TYPE; }
Branch: 2 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "type", 0)) && *e) { type_mask = jsf__type_mask(aTHX_ *e); present |= JSF_HAS_TYPE; } 469 880 1349
if ((e = hv_fetchs(h, "type", 0)) && *e) { type_mask = jsf__type_mask(aTHX_ *e); present |= JSF_HAS_TYPE; } 469 0 469
391 1349 ▶ if ((e = hv_fetchs(h, "enum", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVAV) {
Branch: 4 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "enum", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVAV) { 28 1321 1349
if ((e = hv_fetchs(h, "enum", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVAV) { 28 0 28
if ((e = hv_fetchs(h, "enum", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVAV) { 28 0 28
if ((e = hv_fetchs(h, "enum", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVAV) { 28 0 28
392 28 AV *av = (AV *)SvRV(*e); SSize_t i, cnt = av_len(av) + 1;
393 28 enum_n = (uint32_t)cnt; enum_keep = 0;
394 83 ▶ for (i = 0; i < cnt; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < cnt; i++) { 55 28 83
395 55 SV **v = av_fetch(av, i, 0);
396 55 ▶ uint32_t idx = jsf_keep_push(aTHX_ P->C, (v && *v) ? *v : &PL_sv_undef);
Branch: 2 branches
BranchTrueFalseTotal
uint32_t idx = jsf_keep_push(aTHX_ P->C, (v && *v) ? *v : &PL_sv_undef); 55 0 55
uint32_t idx = jsf_keep_push(aTHX_ P->C, (v && *v) ? *v : &PL_sv_undef); 55 0 55
397 55 ▶ if (i == 0) enum_keep = idx;
Branch: 1 branch
BranchTrueFalseTotal
if (i == 0) enum_keep = idx; 27 28 55
398 }
399 28 present |= JSF_HAS_ENUM;
400 }
401 1349 ▶ if ((e = hv_fetchs(h, "const", 0)) && *e) { const_keep = jsf_keep_push(aTHX_ P->C, *e); present |= JSF_HAS_CONST; }
Branch: 2 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "const", 0)) && *e) { const_keep = jsf_keep_push(aTHX_ P->C, *e); present |= JSF_HAS_CONST; } 75 1274 1349
if ((e = hv_fetchs(h, "const", 0)) && *e) { const_keep = jsf_keep_push(aTHX_ P->C, *e); present |= JSF_HAS_CONST; } 75 0 75
402 1349 ▶ if ((e = hv_fetchs(h, "default", 0)) && *e) { default_keep = jsf_keep_push(aTHX_ P->C, *e); present |= JSF_HAS_DEFAULT; }
Branch: 2 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "default", 0)) && *e) { default_keep = jsf_keep_push(aTHX_ P->C, *e); present |= JSF_HAS_DEFAULT; } 32 1317 1349
if ((e = hv_fetchs(h, "default", 0)) && *e) { default_keep = jsf_keep_push(aTHX_ P->C, *e); present |= JSF_HAS_DEFAULT; } 32 0 32
403  
404 1349 ▶ if ((e = hv_fetchs(h, "minimum", 0)) && *e) { minimum = SvNV(*e); present |= JSF_HAS_MIN; }
Branch: 2 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "minimum", 0)) && *e) { minimum = SvNV(*e); present |= JSF_HAS_MIN; } 30 1319 1349
if ((e = hv_fetchs(h, "minimum", 0)) && *e) { minimum = SvNV(*e); present |= JSF_HAS_MIN; } 30 0 30
405 1349 ▶ if ((e = hv_fetchs(h, "maximum", 0)) && *e) { maximum = SvNV(*e); present |= JSF_HAS_MAX; }
Branch: 2 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "maximum", 0)) && *e) { maximum = SvNV(*e); present |= JSF_HAS_MAX; } 14 1335 1349
if ((e = hv_fetchs(h, "maximum", 0)) && *e) { maximum = SvNV(*e); present |= JSF_HAS_MAX; } 14 0 14
406 1349 ▶ if ((e = hv_fetchs(h, "exclusiveMinimum", 0)) && *e) { exmin = SvNV(*e); present |= JSF_HAS_EXMIN; }
Branch: 2 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "exclusiveMinimum", 0)) && *e) { exmin = SvNV(*e); present |= JSF_HAS_EXMIN; } 6 1343 1349
if ((e = hv_fetchs(h, "exclusiveMinimum", 0)) && *e) { exmin = SvNV(*e); present |= JSF_HAS_EXMIN; } 6 0 6
407 1349 ▶ if ((e = hv_fetchs(h, "exclusiveMaximum", 0)) && *e) { exmax = SvNV(*e); present |= JSF_HAS_EXMAX; }
Branch: 2 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "exclusiveMaximum", 0)) && *e) { exmax = SvNV(*e); present |= JSF_HAS_EXMAX; } 7 1342 1349
if ((e = hv_fetchs(h, "exclusiveMaximum", 0)) && *e) { exmax = SvNV(*e); present |= JSF_HAS_EXMAX; } 7 0 7
408 1349 ▶ if ((e = hv_fetchs(h, "multipleOf", 0)) && *e) { mulof = SvNV(*e); present |= JSF_HAS_MULOF; }
Branch: 2 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "multipleOf", 0)) && *e) { mulof = SvNV(*e); present |= JSF_HAS_MULOF; } 22 1327 1349
if ((e = hv_fetchs(h, "multipleOf", 0)) && *e) { mulof = SvNV(*e); present |= JSF_HAS_MULOF; } 22 0 22
409  
410 1349 ▶ if ((e = hv_fetchs(h, "minLength", 0)) && *e) { min_length = SvUV(*e); present |= JSF_HAS_MINLEN; }
Branch: 2 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "minLength", 0)) && *e) { min_length = SvUV(*e); present |= JSF_HAS_MINLEN; } 12 1337 1349
if ((e = hv_fetchs(h, "minLength", 0)) && *e) { min_length = SvUV(*e); present |= JSF_HAS_MINLEN; } 12 0 12
411 1349 ▶ if ((e = hv_fetchs(h, "maxLength", 0)) && *e) { max_length = SvUV(*e); present |= JSF_HAS_MAXLEN; }
Branch: 2 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "maxLength", 0)) && *e) { max_length = SvUV(*e); present |= JSF_HAS_MAXLEN; } 14 1335 1349
if ((e = hv_fetchs(h, "maxLength", 0)) && *e) { max_length = SvUV(*e); present |= JSF_HAS_MAXLEN; } 14 0 14
412 1359 ▶ if ((e = hv_fetchs(h, "pattern", 0)) && *e) { STRLEN l; const char *p = SvPV_const(*e, l); pattern_off = jsf_arena_intern(a, p, (uint32_t)l); present |= JSF_HAS_PATTERN; }
Branch: 2 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "pattern", 0)) && *e) { STRLEN l; const char *p = SvPV_const(*e, l); pattern_off = jsf_arena_intern(a, p, (uint32_t)l); present |= JSF_HAS_PATTERN; } 10 1339 1349
if ((e = hv_fetchs(h, "pattern", 0)) && *e) { STRLEN l; const char *p = SvPV_const(*e, l); pattern_off = jsf_arena_intern(a, p, (uint32_t)l); present |= JSF_HAS_PATTERN; } 10 0 10
413 1376 ▶ if ((e = hv_fetchs(h, "format", 0)) && *e) { STRLEN l; const char *p = SvPV_const(*e, l); format_off = jsf_arena_intern(a, p, (uint32_t)l); present |= JSF_HAS_FORMAT; }
Branch: 2 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "format", 0)) && *e) { STRLEN l; const char *p = SvPV_const(*e, l); format_off = jsf_arena_intern(a, p, (uint32_t)l); present |= JSF_HAS_FORMAT; } 27 1322 1349
if ((e = hv_fetchs(h, "format", 0)) && *e) { STRLEN l; const char *p = SvPV_const(*e, l); format_off = jsf_arena_intern(a, p, (uint32_t)l); present |= JSF_HAS_FORMAT; } 27 0 27
414  
415 1349 ▶ if ((e = hv_fetchs(h, "items", 0)) && *e) { items_off = jsf_parse_schema(aTHX_ P, *e, jsf__child_path(aTHX_ path, "items", NULL, 0)); present |= JSF_HAS_ITEMS; }
Branch: 2 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "items", 0)) && *e) { items_off = jsf_parse_schema(aTHX_ P, *e, jsf__child_path(aTHX_ path, "items", NULL, 0)); present |= JSF_HAS_ITEMS; } 59 1290 1349
if ((e = hv_fetchs(h, "items", 0)) && *e) { items_off = jsf_parse_schema(aTHX_ P, *e, jsf__child_path(aTHX_ path, "items", NULL, 0)); present |= JSF_HAS_ITEMS; } 59 0 59
416 1349 ▶ if ((e = hv_fetchs(h, "prefixItems", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVAV) { prefix_off = jsf__build_offlist(aTHX_ P, *e, path, "prefixItems"); present |= JSF_HAS_PREFIX; }
Branch: 4 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "prefixItems", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVAV) { prefix_off = jsf__build_offlist(aTHX_ P, *e, path, "prefixItems"); present |= JSF_HAS_PREFIX; } 48 1301 1349
if ((e = hv_fetchs(h, "prefixItems", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVAV) { prefix_off = jsf__build_offlist(aTHX_ P, *e, path, "prefixItems"); present |= JSF_HAS_PREFIX; } 48 0 48
if ((e = hv_fetchs(h, "prefixItems", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVAV) { prefix_off = jsf__build_offlist(aTHX_ P, *e, path, "prefixItems"); present |= JSF_HAS_PREFIX; } 48 0 48
if ((e = hv_fetchs(h, "prefixItems", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVAV) { prefix_off = jsf__build_offlist(aTHX_ P, *e, path, "prefixItems"); present |= JSF_HAS_PREFIX; } 48 0 48
417 1349 ▶ if ((e = hv_fetchs(h, "minItems", 0)) && *e) { min_items = SvUV(*e); present |= JSF_HAS_MINITEMS; }
Branch: 2 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "minItems", 0)) && *e) { min_items = SvUV(*e); present |= JSF_HAS_MINITEMS; } 8 1341 1349
if ((e = hv_fetchs(h, "minItems", 0)) && *e) { min_items = SvUV(*e); present |= JSF_HAS_MINITEMS; } 8 0 8
418 1349 ▶ if ((e = hv_fetchs(h, "maxItems", 0)) && *e) { max_items = SvUV(*e); present |= JSF_HAS_MAXITEMS; }
Branch: 2 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "maxItems", 0)) && *e) { max_items = SvUV(*e); present |= JSF_HAS_MAXITEMS; } 5 1344 1349
if ((e = hv_fetchs(h, "maxItems", 0)) && *e) { max_items = SvUV(*e); present |= JSF_HAS_MAXITEMS; } 5 0 5
419 1349 ▶ if ((e = hv_fetchs(h, "uniqueItems", 0)) && *e && SvTRUE(*e)) { unique = 1; present |= JSF_HAS_UNIQUE; }
Branch: 3 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "uniqueItems", 0)) && *e && SvTRUE(*e)) { unique = 1; present |= JSF_HAS_UNIQUE; } 13 1336 1349
if ((e = hv_fetchs(h, "uniqueItems", 0)) && *e && SvTRUE(*e)) { unique = 1; present |= JSF_HAS_UNIQUE; } 13 0 13
if ((e = hv_fetchs(h, "uniqueItems", 0)) && *e && SvTRUE(*e)) { unique = 1; present |= JSF_HAS_UNIQUE; } 10 3 13
420 1349 ▶ if ((e = hv_fetchs(h, "contains", 0)) && *e) { contains_off = jsf_parse_schema(aTHX_ P, *e, jsf__child_path(aTHX_ path, "contains", NULL, 0)); present |= JSF_HAS_CONTAINS; }
Branch: 2 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "contains", 0)) && *e) { contains_off = jsf_parse_schema(aTHX_ P, *e, jsf__child_path(aTHX_ path, "contains", NULL, 0)); present |= JSF_HAS_CONTAINS; } 26 1323 1349
if ((e = hv_fetchs(h, "contains", 0)) && *e) { contains_off = jsf_parse_schema(aTHX_ P, *e, jsf__child_path(aTHX_ path, "contains", NULL, 0)); present |= JSF_HAS_CONTAINS; } 26 0 26
421 1349 ▶ if ((e = hv_fetchs(h, "minContains", 0)) && *e){ min_contains = SvUV(*e); present |= JSF_HAS_MINCONT; }
Branch: 2 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "minContains", 0)) && *e){ min_contains = SvUV(*e); present |= JSF_HAS_MINCONT; } 12 1337 1349
if ((e = hv_fetchs(h, "minContains", 0)) && *e){ min_contains = SvUV(*e); present |= JSF_HAS_MINCONT; } 12 0 12
422 1349 ▶ if ((e = hv_fetchs(h, "maxContains", 0)) && *e){ max_contains = SvUV(*e); present |= JSF_HAS_MAXCONT; }
Branch: 2 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "maxContains", 0)) && *e){ max_contains = SvUV(*e); present |= JSF_HAS_MAXCONT; } 8 1341 1349
if ((e = hv_fetchs(h, "maxContains", 0)) && *e){ max_contains = SvUV(*e); present |= JSF_HAS_MAXCONT; } 8 0 8
423  
424 1349 ▶ if ((e = hv_fetchs(h, "properties", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVHV) { props_off = jsf__build_props(aTHX_ P, *e, path); present |= JSF_HAS_PROPS; }
Branch: 4 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "properties", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVHV) { props_off = jsf__build_props(aTHX_ P, *e, path); present |= JSF_HAS_PROPS; } 191 1158 1349
if ((e = hv_fetchs(h, "properties", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVHV) { props_off = jsf__build_props(aTHX_ P, *e, path); present |= JSF_HAS_PROPS; } 191 0 191
if ((e = hv_fetchs(h, "properties", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVHV) { props_off = jsf__build_props(aTHX_ P, *e, path); present |= JSF_HAS_PROPS; } 191 0 191
if ((e = hv_fetchs(h, "properties", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVHV) { props_off = jsf__build_props(aTHX_ P, *e, path); present |= JSF_HAS_PROPS; } 191 0 191
425 1349 ▶ if ((e = hv_fetchs(h, "patternProperties", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVHV) { patprops_off = jsf__build_pattab(aTHX_ P, *e, path); present |= JSF_HAS_PATPROPS; }
Branch: 4 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "patternProperties", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVHV) { patprops_off = jsf__build_pattab(aTHX_ P, *e, path); present |= JSF_HAS_PATPROPS; } 16 1333 1349
if ((e = hv_fetchs(h, "patternProperties", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVHV) { patprops_off = jsf__build_pattab(aTHX_ P, *e, path); present |= JSF_HAS_PATPROPS; } 16 0 16
if ((e = hv_fetchs(h, "patternProperties", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVHV) { patprops_off = jsf__build_pattab(aTHX_ P, *e, path); present |= JSF_HAS_PATPROPS; } 16 0 16
if ((e = hv_fetchs(h, "patternProperties", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVHV) { patprops_off = jsf__build_pattab(aTHX_ P, *e, path); present |= JSF_HAS_PATPROPS; } 16 0 16
426 1349 ▶ if ((e = hv_fetchs(h, "additionalProperties", 0)) && *e) {
Branch: 2 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "additionalProperties", 0)) && *e) { 41 1308 1349
if ((e = hv_fetchs(h, "additionalProperties", 0)) && *e) { 41 0 41
427 41 SV *ap = *e; int is_false = 0, b2;
428 41 ▶ if (jsf__schema_is_bool(aTHX_ ap, &b2) && !SvROK(ap)) is_false = !b2;
Branch: 2 branches
BranchTrueFalseTotal
if (jsf__schema_is_bool(aTHX_ ap, &b2) && !SvROK(ap)) is_false = !b2; 15 26 41
if (jsf__schema_is_bool(aTHX_ ap, &b2) && !SvROK(ap)) is_false = !b2; 2 13 15
429 39 ▶ else if (SvROK(ap) && SvOBJECT(SvRV(ap)) && jsf__is_bool_class(aTHX_ ap)) is_false = !SvTRUE(ap);
Branch: 3 branches
BranchTrueFalseTotal
else if (SvROK(ap) && SvOBJECT(SvRV(ap)) && jsf__is_bool_class(aTHX_ ap)) is_false = !SvTRUE(ap); 39 0 39
else if (SvROK(ap) && SvOBJECT(SvRV(ap)) && jsf__is_bool_class(aTHX_ ap)) is_false = !SvTRUE(ap); 13 26 39
else if (SvROK(ap) && SvOBJECT(SvRV(ap)) && jsf__is_bool_class(aTHX_ ap)) is_false = !SvTRUE(ap); 13 0 13
430 41 ▶ if (is_false) addprops_off = JSF_NULL_OFF;
Branch: 1 branch
BranchTrueFalseTotal
if (is_false) addprops_off = JSF_NULL_OFF; 13 28 41
431 28 else addprops_off = jsf_parse_schema(aTHX_ P, ap, jsf__child_path(aTHX_ path, "additionalProperties", NULL, 0));
432 41 present |= JSF_HAS_ADDPROPS;
433 }
434 1349 ▶ if ((e = hv_fetchs(h, "required", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVAV) { required_off = jsf__build_reqset(aTHX_ P, *e, props_off); present |= JSF_HAS_REQUIRED; }
Branch: 4 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "required", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVAV) { required_off = jsf__build_reqset(aTHX_ P, *e, props_off); present |= JSF_HAS_REQUIRED; } 63 1286 1349
if ((e = hv_fetchs(h, "required", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVAV) { required_off = jsf__build_reqset(aTHX_ P, *e, props_off); present |= JSF_HAS_REQUIRED; } 63 0 63
if ((e = hv_fetchs(h, "required", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVAV) { required_off = jsf__build_reqset(aTHX_ P, *e, props_off); present |= JSF_HAS_REQUIRED; } 63 0 63
if ((e = hv_fetchs(h, "required", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVAV) { required_off = jsf__build_reqset(aTHX_ P, *e, props_off); present |= JSF_HAS_REQUIRED; } 63 0 63
435 1349 ▶ if ((e = hv_fetchs(h, "minProperties", 0)) && *e) { min_props = SvUV(*e); present |= JSF_HAS_MINPROPS; }
Branch: 2 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "minProperties", 0)) && *e) { min_props = SvUV(*e); present |= JSF_HAS_MINPROPS; } 5 1344 1349
if ((e = hv_fetchs(h, "minProperties", 0)) && *e) { min_props = SvUV(*e); present |= JSF_HAS_MINPROPS; } 5 0 5
436 1349 ▶ if ((e = hv_fetchs(h, "maxProperties", 0)) && *e) { max_props = SvUV(*e); present |= JSF_HAS_MAXPROPS; }
Branch: 2 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "maxProperties", 0)) && *e) { max_props = SvUV(*e); present |= JSF_HAS_MAXPROPS; } 4 1345 1349
if ((e = hv_fetchs(h, "maxProperties", 0)) && *e) { max_props = SvUV(*e); present |= JSF_HAS_MAXPROPS; } 4 0 4
437 1349 ▶ if ((e = hv_fetchs(h, "propertyNames", 0)) && *e) { propnames_off = jsf_parse_schema(aTHX_ P, *e, jsf__child_path(aTHX_ path, "propertyNames", NULL, 0)); present |= JSF_HAS_PROPNAMES; }
Branch: 2 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "propertyNames", 0)) && *e) { propnames_off = jsf_parse_schema(aTHX_ P, *e, jsf__child_path(aTHX_ path, "propertyNames", NULL, 0)); present |= JSF_HAS_PROPNAMES; } 13 1336 1349
if ((e = hv_fetchs(h, "propertyNames", 0)) && *e) { propnames_off = jsf_parse_schema(aTHX_ P, *e, jsf__child_path(aTHX_ path, "propertyNames", NULL, 0)); present |= JSF_HAS_PROPNAMES; } 13 0 13
438 1349 ▶ if ((e = hv_fetchs(h, "dependentRequired", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVHV) { depreq_off = jsf__build_deptab(aTHX_ P, *e); present |= JSF_HAS_DEPREQ; }
Branch: 4 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "dependentRequired", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVHV) { depreq_off = jsf__build_deptab(aTHX_ P, *e); present |= JSF_HAS_DEPREQ; } 5 1344 1349
if ((e = hv_fetchs(h, "dependentRequired", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVHV) { depreq_off = jsf__build_deptab(aTHX_ P, *e); present |= JSF_HAS_DEPREQ; } 5 0 5
if ((e = hv_fetchs(h, "dependentRequired", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVHV) { depreq_off = jsf__build_deptab(aTHX_ P, *e); present |= JSF_HAS_DEPREQ; } 5 0 5
if ((e = hv_fetchs(h, "dependentRequired", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVHV) { depreq_off = jsf__build_deptab(aTHX_ P, *e); present |= JSF_HAS_DEPREQ; } 5 0 5
439 1349 ▶ if ((e = hv_fetchs(h, "dependentSchemas", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVHV) { depsch_off = jsf__build_depsch(aTHX_ P, *e, path); present |= JSF_HAS_DEPSCHEMAS; }
Branch: 4 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "dependentSchemas", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVHV) { depsch_off = jsf__build_depsch(aTHX_ P, *e, path); present |= JSF_HAS_DEPSCHEMAS; } 8 1341 1349
if ((e = hv_fetchs(h, "dependentSchemas", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVHV) { depsch_off = jsf__build_depsch(aTHX_ P, *e, path); present |= JSF_HAS_DEPSCHEMAS; } 8 0 8
if ((e = hv_fetchs(h, "dependentSchemas", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVHV) { depsch_off = jsf__build_depsch(aTHX_ P, *e, path); present |= JSF_HAS_DEPSCHEMAS; } 8 0 8
if ((e = hv_fetchs(h, "dependentSchemas", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVHV) { depsch_off = jsf__build_depsch(aTHX_ P, *e, path); present |= JSF_HAS_DEPSCHEMAS; } 8 0 8
440  
441 1349 ▶ if ((e = hv_fetchs(h, "allOf", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVAV) { allof_off = jsf__build_offlist(aTHX_ P, *e, path, "allOf"); present |= JSF_HAS_ALLOF; }
Branch: 4 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "allOf", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVAV) { allof_off = jsf__build_offlist(aTHX_ P, *e, path, "allOf"); present |= JSF_HAS_ALLOF; } 50 1299 1349
if ((e = hv_fetchs(h, "allOf", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVAV) { allof_off = jsf__build_offlist(aTHX_ P, *e, path, "allOf"); present |= JSF_HAS_ALLOF; } 50 0 50
if ((e = hv_fetchs(h, "allOf", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVAV) { allof_off = jsf__build_offlist(aTHX_ P, *e, path, "allOf"); present |= JSF_HAS_ALLOF; } 50 0 50
if ((e = hv_fetchs(h, "allOf", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVAV) { allof_off = jsf__build_offlist(aTHX_ P, *e, path, "allOf"); present |= JSF_HAS_ALLOF; } 50 0 50
442 1349 ▶ if ((e = hv_fetchs(h, "anyOf", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVAV) { anyof_off = jsf__build_offlist(aTHX_ P, *e, path, "anyOf"); present |= JSF_HAS_ANYOF; }
Branch: 4 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "anyOf", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVAV) { anyof_off = jsf__build_offlist(aTHX_ P, *e, path, "anyOf"); present |= JSF_HAS_ANYOF; } 25 1324 1349
if ((e = hv_fetchs(h, "anyOf", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVAV) { anyof_off = jsf__build_offlist(aTHX_ P, *e, path, "anyOf"); present |= JSF_HAS_ANYOF; } 25 0 25
if ((e = hv_fetchs(h, "anyOf", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVAV) { anyof_off = jsf__build_offlist(aTHX_ P, *e, path, "anyOf"); present |= JSF_HAS_ANYOF; } 25 0 25
if ((e = hv_fetchs(h, "anyOf", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVAV) { anyof_off = jsf__build_offlist(aTHX_ P, *e, path, "anyOf"); present |= JSF_HAS_ANYOF; } 25 0 25
443 1349 ▶ if ((e = hv_fetchs(h, "oneOf", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVAV) { oneof_off = jsf__build_offlist(aTHX_ P, *e, path, "oneOf"); present |= JSF_HAS_ONEOF; }
Branch: 4 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "oneOf", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVAV) { oneof_off = jsf__build_offlist(aTHX_ P, *e, path, "oneOf"); present |= JSF_HAS_ONEOF; } 21 1328 1349
if ((e = hv_fetchs(h, "oneOf", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVAV) { oneof_off = jsf__build_offlist(aTHX_ P, *e, path, "oneOf"); present |= JSF_HAS_ONEOF; } 21 0 21
if ((e = hv_fetchs(h, "oneOf", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVAV) { oneof_off = jsf__build_offlist(aTHX_ P, *e, path, "oneOf"); present |= JSF_HAS_ONEOF; } 21 0 21
if ((e = hv_fetchs(h, "oneOf", 0)) && *e && SvROK(*e) && SvTYPE(SvRV(*e))==SVt_PVAV) { oneof_off = jsf__build_offlist(aTHX_ P, *e, path, "oneOf"); present |= JSF_HAS_ONEOF; } 21 0 21
444 1349 ▶ if ((e = hv_fetchs(h, "unevaluatedProperties", 0)) && *e) { unevalprops_off = jsf_parse_schema(aTHX_ P, *e, jsf__child_path(aTHX_ path, "unevaluatedProperties", NULL, 0)); present |= JSF_HAS_UNEVALPROPS; P->C->has_unevaluated = 1; }
Branch: 2 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "unevaluatedProperties", 0)) && *e) { unevalprops_off = jsf_parse_schema(aTHX_ P, *e, jsf__child_path(aTHX_ path, "unevaluatedProperties", NULL, 0)); present |= JSF_HAS_UNEVALPROPS; P->C->has_unevaluated = 1; } 57 1292 1349
if ((e = hv_fetchs(h, "unevaluatedProperties", 0)) && *e) { unevalprops_off = jsf_parse_schema(aTHX_ P, *e, jsf__child_path(aTHX_ path, "unevaluatedProperties", NULL, 0)); present |= JSF_HAS_UNEVALPROPS; P->C->has_unevaluated = 1; } 57 0 57
445 1349 ▶ if ((e = hv_fetchs(h, "unevaluatedItems", 0)) && *e) { unevalitems_off = jsf_parse_schema(aTHX_ P, *e, jsf__child_path(aTHX_ path, "unevaluatedItems", NULL, 0)); present |= JSF_HAS_UNEVALITEMS; P->C->has_unevaluated = 1; }
Branch: 2 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "unevaluatedItems", 0)) && *e) { unevalitems_off = jsf_parse_schema(aTHX_ P, *e, jsf__child_path(aTHX_ path, "unevaluatedItems", NULL, 0)); present |= JSF_HAS_UNEVALITEMS; P->C->has_unevaluated = 1; } 31 1318 1349
if ((e = hv_fetchs(h, "unevaluatedItems", 0)) && *e) { unevalitems_off = jsf_parse_schema(aTHX_ P, *e, jsf__child_path(aTHX_ path, "unevaluatedItems", NULL, 0)); present |= JSF_HAS_UNEVALITEMS; P->C->has_unevaluated = 1; } 31 0 31
446 1349 ▶ if ((e = hv_fetchs(h, "not", 0)) && *e) { not_off = jsf_parse_schema(aTHX_ P, *e, jsf__child_path(aTHX_ path, "not", NULL, 0)); present |= JSF_HAS_NOT; }
Branch: 2 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "not", 0)) && *e) { not_off = jsf_parse_schema(aTHX_ P, *e, jsf__child_path(aTHX_ path, "not", NULL, 0)); present |= JSF_HAS_NOT; } 17 1332 1349
if ((e = hv_fetchs(h, "not", 0)) && *e) { not_off = jsf_parse_schema(aTHX_ P, *e, jsf__child_path(aTHX_ path, "not", NULL, 0)); present |= JSF_HAS_NOT; } 17 0 17
447 1349 ▶ if ((e = hv_fetchs(h, "if", 0)) && *e) { if_off = jsf_parse_schema(aTHX_ P, *e, jsf__child_path(aTHX_ path, "if", NULL, 0)); present |= JSF_HAS_IF; }
Branch: 2 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "if", 0)) && *e) { if_off = jsf_parse_schema(aTHX_ P, *e, jsf__child_path(aTHX_ path, "if", NULL, 0)); present |= JSF_HAS_IF; } 25 1324 1349
if ((e = hv_fetchs(h, "if", 0)) && *e) { if_off = jsf_parse_schema(aTHX_ P, *e, jsf__child_path(aTHX_ path, "if", NULL, 0)); present |= JSF_HAS_IF; } 25 0 25
448 1349 ▶ if ((e = hv_fetchs(h, "then", 0)) && *e) { then_off = jsf_parse_schema(aTHX_ P, *e, jsf__child_path(aTHX_ path, "then", NULL, 0)); }
Branch: 2 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "then", 0)) && *e) { then_off = jsf_parse_schema(aTHX_ P, *e, jsf__child_path(aTHX_ path, "then", NULL, 0)); } 18 1331 1349
if ((e = hv_fetchs(h, "then", 0)) && *e) { then_off = jsf_parse_schema(aTHX_ P, *e, jsf__child_path(aTHX_ path, "then", NULL, 0)); } 18 0 18
449 1349 ▶ if ((e = hv_fetchs(h, "else", 0)) && *e) { else_off = jsf_parse_schema(aTHX_ P, *e, jsf__child_path(aTHX_ path, "else", NULL, 0)); }
Branch: 2 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "else", 0)) && *e) { else_off = jsf_parse_schema(aTHX_ P, *e, jsf__child_path(aTHX_ path, "else", NULL, 0)); } 15 1334 1349
if ((e = hv_fetchs(h, "else", 0)) && *e) { else_off = jsf_parse_schema(aTHX_ P, *e, jsf__child_path(aTHX_ path, "else", NULL, 0)); } 15 0 15
450  
451 1349 ▶ if ((e = hv_fetchs(h, "$ref", 0)) && *e && SvPOK(*e)) {
Branch: 3 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "$ref", 0)) && *e && SvPOK(*e)) { 200 1149 1349
if ((e = hv_fetchs(h, "$ref", 0)) && *e && SvPOK(*e)) { 200 0 200
if ((e = hv_fetchs(h, "$ref", 0)) && *e && SvPOK(*e)) { 200 0 200
452 200 av_push(P->refreqs, newSViv((IV)off));
453 200 av_push(P->refreqs, newSVsv(*e));
454 200 av_push(P->refreqs, newSVsv(P->base));
455 200 present |= JSF_HAS_REF;
456 }
457 /* $dynamicRef: lexical fallback resolves like $ref (into ref_off); the
458 * fragment name drives the runtime dynamic-scope search. */
459 1349 ▶ if ((e = hv_fetchs(h, "$dynamicRef", 0)) && *e && SvPOK(*e)) {
Branch: 3 branches
BranchTrueFalseTotal
if ((e = hv_fetchs(h, "$dynamicRef", 0)) && *e && SvPOK(*e)) { 60 1289 1349
if ((e = hv_fetchs(h, "$dynamicRef", 0)) && *e && SvPOK(*e)) { 60 0 60
if ((e = hv_fetchs(h, "$dynamicRef", 0)) && *e && SvPOK(*e)) { 60 0 60
460 60 STRLEN dl; const char *dp = SvPV_const(*e, dl);
461 60 const char *hh2 = (const char *)memchr(dp, '#', dl);
462 60 av_push(P->refreqs, newSViv((IV)off));
463 60 av_push(P->refreqs, newSVsv(*e));
464 60 av_push(P->refreqs, newSVsv(P->base));
465 60 ▶ if (hh2 && dp + dl - (hh2 + 1) > 0)
Branch: 2 branches
BranchTrueFalseTotal
if (hh2 && dp + dl - (hh2 + 1) > 0) 60 0 60
if (hh2 && dp + dl - (hh2 + 1) > 0) 60 0 60
466 60 dynref_name_off = jsf_arena_intern(a, hh2 + 1, (uint32_t)(dp + dl - (hh2 + 1)));
467 60 present |= JSF_HAS_DYNREF;
468 60 P->C->has_dynamic = 1;
469 }
470  
471 /* fast-path tag */
472 1349 ▶ if (present == 0) tag = JSF_TAG_TRUE;
Branch: 1 branch
BranchTrueFalseTotal
if (present == 0) tag = JSF_TAG_TRUE; 37 1312 1349
473 1312 ▶ else if (present == JSF_HAS_TYPE) tag = JSF_TAG_TYPE_LEAF;
Branch: 1 branch
BranchTrueFalseTotal
else if (present == JSF_HAS_TYPE) tag = JSF_TAG_TYPE_LEAF; 297 1015 1312
474 1015 ▶ else if (present == JSF_HAS_CONST) tag = JSF_TAG_CONST_LEAF;
Branch: 1 branch
BranchTrueFalseTotal
else if (present == JSF_HAS_CONST) tag = JSF_TAG_CONST_LEAF; 74 941 1015
475 941 ▶ else if (present == JSF_HAS_ENUM) tag = JSF_TAG_ENUM_LEAF;
Branch: 1 branch
BranchTrueFalseTotal
else if (present == JSF_HAS_ENUM) tag = JSF_TAG_ENUM_LEAF; 23 918 941
476  
477 /* commit: fetch the node fresh (arena may have moved) and write it once.
478 * intern the resource base URI first (interning may move the arena). */
479 {
480 1349 uint32_t base_off = jsf_arena_intern(a, SvPVX(P->base), (uint32_t)SvCUR(P->base));
481 1349 n = (jsf_node_t *)jsf_arena_ptr(a, off);
482 1349 n->base_off = base_off;
483 1349 n->dynref_name_off = dynref_name_off;
484 }
485 1349 n->present = present; n->type_mask = type_mask; n->tag = tag; n->unique = unique;
486 1349 n->enum_keep = enum_keep; n->enum_n = enum_n; n->const_keep = const_keep;
487 1349 n->default_keep = default_keep;
488 1349 n->minimum = minimum; n->maximum = maximum; n->exmin = exmin; n->exmax = exmax; n->mulof = mulof;
489 1349 n->min_length = min_length; n->max_length = max_length;
490 1349 n->pattern_off = pattern_off; n->format_off = format_off;
491 1349 n->items_off = items_off; n->prefix_off = prefix_off;
492 1349 n->min_items = min_items; n->max_items = max_items;
493 1349 n->contains_off = contains_off; n->min_contains = min_contains; n->max_contains = max_contains;
494 1349 n->props_off = props_off; n->patprops_off = patprops_off; n->addprops_off = addprops_off;
495 1349 n->required_off = required_off; n->min_props = min_props; n->max_props = max_props;
496 1349 n->propnames_off = propnames_off; n->depreq_off = depreq_off;
497 1349 n->depsch_off = depsch_off;
498 1349 n->allof_off = allof_off; n->anyof_off = anyof_off; n->oneof_off = oneof_off; n->not_off = not_off;
499 1349 n->if_off = if_off; n->then_off = then_off; n->else_off = else_off;
500 1349 n->unevalprops_off = unevalprops_off; n->unevalitems_off = unevalitems_off;
501 1349 ▶ if (saved_base) P->base = saved_base; /* leave the $id scope */
Branch: 1 branch
BranchTrueFalseTotal
if (saved_base) P->base = saved_base; /* leave the $id scope */ 123 1226 1349
502 1349 return off;
503 }
504  
505 /* ---- $ref resolution (same-document) ------------------------------------ */
506  
507 /* Decode a $ref fragment into the raw form path2off is keyed by: percent-decode
508 * (URI fragment), then JSON Pointer unescape (~1 -> '/', ~0 -> '~'). Leaves a
509 * plain "#/$defs/Foo" untouched. */
510 12 static int jsf__hexval(char c) {
511 12 ▶ if (c >= '0' && c <= '9') return c - '0';
Branch: 2 branches
BranchTrueFalseTotal
if (c >= '0' && c <= '9') return c - '0'; 12 0 12
if (c >= '0' && c <= '9') return c - '0'; 12 0 12
512 0 ▶ if (c >= 'a' && c <= 'f') return c - 'a' + 10;
Branch: 2 branches
BranchTrueFalseTotal
if (c >= 'a' && c <= 'f') return c - 'a' + 10; 0 0 0
if (c >= 'a' && c <= 'f') return c - 'a' + 10; 0 0 0
513 0 ▶ if (c >= 'A' && c <= 'F') return c - 'A' + 10;
Branch: 2 branches
BranchTrueFalseTotal
if (c >= 'A' && c <= 'F') return c - 'A' + 10; 0 0 0
if (c >= 'A' && c <= 'F') return c - 'A' + 10; 0 0 0
514 0 return -1;
515 }
516 260 static SV *jsf_ptr_decode(pTHX_ const char *s, STRLEN len) {
517 260 SV *p1 = sv_2mortal(newSVpvn("", 0));
518 260 SV *p2 = sv_2mortal(newSVpvn("", 0));
519 STRLEN i, l2; const char *q;
520 2571 ▶ for (i = 0; i < len; ) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < len; ) { 2311 260 2571
521 2311 ▶ if (s[i] == '%' && i + 2 < len && jsf__hexval(s[i+1]) >= 0 && jsf__hexval(s[i+2]) >= 0) {
Branch: 4 branches
BranchTrueFalseTotal
if (s[i] == '%' && i + 2 < len && jsf__hexval(s[i+1]) >= 0 && jsf__hexval(s[i+2]) >= 0) { 3 2308 2311
if (s[i] == '%' && i + 2 < len && jsf__hexval(s[i+1]) >= 0 && jsf__hexval(s[i+2]) >= 0) { 3 0 3
if (s[i] == '%' && i + 2 < len && jsf__hexval(s[i+1]) >= 0 && jsf__hexval(s[i+2]) >= 0) { 3 0 3
if (s[i] == '%' && i + 2 < len && jsf__hexval(s[i+1]) >= 0 && jsf__hexval(s[i+2]) >= 0) { 3 0 3
522 3 char b = (char)((jsf__hexval(s[i+1]) << 4) | jsf__hexval(s[i+2]));
523 3 sv_catpvn(p1, &b, 1); i += 3;
524 2308 } else { sv_catpvn(p1, s + i, 1); i++; }
525 }
526 260 q = SvPV_const(p1, l2);
527 2568 ▶ for (i = 0; i < l2; ) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < l2; ) { 2308 260 2568
528 2308 ▶ if (q[i] == '~' && i + 1 < l2 && (q[i+1] == '0' || q[i+1] == '1')) {
Branch: 4 branches
BranchTrueFalseTotal
if (q[i] == '~' && i + 1 < l2 && (q[i+1] == '0' || q[i+1] == '1')) { 3 2305 2308
if (q[i] == '~' && i + 1 < l2 && (q[i+1] == '0' || q[i+1] == '1')) { 3 0 3
if (q[i] == '~' && i + 1 < l2 && (q[i+1] == '0' || q[i+1] == '1')) { 2 1 3
if (q[i] == '~' && i + 1 < l2 && (q[i+1] == '0' || q[i+1] == '1')) { 2 0 2
529 3 ▶ sv_catpvn(p2, q[i+1] == '1' ? "/" : "~", 1); i += 2;
Branch: 1 branch
BranchTrueFalseTotal
sv_catpvn(p2, q[i+1] == '1' ? "/" : "~", 1); i += 2; 2 1 3
530 2305 } else { sv_catpvn(p2, q + i, 1); i++; }
531 }
532 260 return p2;
533 }
534  
535 /* Ask the resolver coderef for the schema document at `uri`; a returned ref is
536 * used, anything else (undef) means "not available". Result is mortal. */
537 41 static SV *jsf_call_resolver(pTHX_ SV *resolver, const char *uri, STRLEN ulen) {
538 41 dSP; int count; SV *ret = NULL;
539 41 ▶ if (!resolver || !SvOK(resolver)) return NULL;
Branch: 2 branches
BranchTrueFalseTotal
if (!resolver || !SvOK(resolver)) return NULL; 41 0 41
if (!resolver || !SvOK(resolver)) return NULL; 0 41 41
540 41 ▶ ENTER; SAVETMPS; PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
ENTER; SAVETMPS; PUSHMARK(SP); 0 41 41
541 41 ▶ XPUSHs(sv_2mortal(newSVpvn(uri, ulen)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVpvn(uri, ulen))); 0 41 41
542 41 PUTBACK;
543 41 count = call_sv(resolver, G_SCALAR);
544 41 SPAGAIN;
545 41 ▶ if (count > 0) { SV *r = POPs; if (SvROK(r)) ret = newSVsv(r); }
Branch: 2 branches
BranchTrueFalseTotal
if (count > 0) { SV *r = POPs; if (SvROK(r)) ret = newSVsv(r); } 41 0 41
if (count > 0) { SV *r = POPs; if (SvROK(r)) ret = newSVsv(r); } 41 0 41
546 41 ▶ PUTBACK; FREETMPS; LEAVE;
Branch: 1 branch
BranchTrueFalseTotal
PUTBACK; FREETMPS; LEAVE; 41 0 41
547 41 ▶ return ret ? sv_2mortal(ret) : NULL;
Branch: 1 branch
BranchTrueFalseTotal
return ret ? sv_2mortal(ret) : NULL; 41 0 41
548 }
549  
550 /* Resolve each $ref against its base URI (fragment percent/~-decoded), looking
551 * the canonical URI up in the registry. When the target document has not been
552 * loaded, fetch it via the resolver, parse it into the same arena (which may
553 * append further refs), and retry. The refreqs array grows as documents load;
554 * the loop consumes it to the end. */
555 480 static void jsf_resolve_refs(pTHX_ jsf_pctx *P) {
556 480 SSize_t idx = 0;
557 738 ▶ while (idx + 2 <= av_len(P->refreqs)) {
Branch: 1 branch
BranchTrueFalseTotal
while (idx + 2 <= av_len(P->refreqs)) { 260 478 738
558 260 SV **oe = av_fetch(P->refreqs, idx, 0);
559 260 SV **pe = av_fetch(P->refreqs, idx + 1, 0);
560 260 SV **be = av_fetch(P->refreqs, idx + 2, 0);
561 260 uint32_t node_off = (uint32_t)SvIV(*oe);
562 260 SV *ref_copy = sv_2mortal(newSVsv(*pe)); /* survives re-parse */
563 260 SV *abs = jsf_uri_resolve(aTHX_ *be, *pe);
564 260 STRLEN al; const char *ap = SvPV_const(abs, al);
565 260 const char *hash = (const char *)memchr(ap, '#', al);
566 260 ▶ SV *doc = sv_2mortal(newSVpvn(ap, hash ? (STRLEN)(hash - ap) : al));
Branch: 1 branch
BranchTrueFalseTotal
SV *doc = sv_2mortal(newSVpvn(ap, hash ? (STRLEN)(hash - ap) : al)); 260 0 260
567 SV *key;
568 SV **te;
569 STRLEN kl; const char *kp;
570 260 idx += 3;
571  
572 260 ▶ if (hash) {
Branch: 1 branch
BranchTrueFalseTotal
if (hash) { 260 0 260
573 260 SV *frag = jsf_ptr_decode(aTHX_ hash + 1, al - (hash - ap) - 1);
574 260 key = sv_2mortal(newSVpvn(ap, hash - ap));
575 260 sv_catpvs(key, "#"); sv_catsv(key, frag);
576 } else {
577 0 key = sv_2mortal(newSVsv(abs));
578 }
579 260 kp = SvPV_const(key, kl);
580 260 te = hv_fetch(P->path2off, kp, (I32)kl, 0);
581  
582 260 ▶ if (!(te && *te && SvIOK(*te))) {
Branch: 3 branches
BranchTrueFalseTotal
if (!(te && *te && SvIOK(*te))) { 220 40 260
if (!(te && *te && SvIOK(*te))) { 220 0 220
if (!(te && *te && SvIOK(*te))) { 0 220 220
583 40 STRLEN dl; const char *dp = SvPV_const(doc, dl);
584 40 ▶ if (dl && !hv_exists(P->loaded, dp, (I32)dl)) {
Branch: 2 branches
BranchTrueFalseTotal
if (dl && !hv_exists(P->loaded, dp, (I32)dl)) { 39 1 40
if (dl && !hv_exists(P->loaded, dp, (I32)dl)) { 39 0 39
585 39 SV *sub = NULL;
586 39 (void)hv_store(P->loaded, dp, (I32)dl, &PL_sv_yes, 0);
587 39 ▶ if (P->resolver) sub = jsf_call_resolver(aTHX_ P->resolver, dp, dl);
Branch: 1 branch
BranchTrueFalseTotal
if (P->resolver) sub = jsf_call_resolver(aTHX_ P->resolver, dp, dl); 38 1 39
588 39 ▶ if (!sub && P->auto_fetch) sub = jsf_fetch_uri(aTHX_ dp, dl);
Branch: 2 branches
BranchTrueFalseTotal
if (!sub && P->auto_fetch) sub = jsf_fetch_uri(aTHX_ dp, dl); 1 38 39
if (!sub && P->auto_fetch) sub = jsf_fetch_uri(aTHX_ dp, dl); 1 0 1
589 39 ▶ if (sub) {
Branch: 1 branch
BranchTrueFalseTotal
if (sub) { 38 1 39
590 38 SV *saved = P->base;
591 uint32_t root2;
592 38 P->base = sv_2mortal(newSVsv(doc));
593 38 root2 = jsf_parse_schema(aTHX_ P, sub, sv_2mortal(newSVpvs("#")));
594 38 P->base = saved;
595 /* register the retrieval URI (in case $id is absent/differs) */
596 38 { SV *k1 = sv_2mortal(newSVsv(doc)); (void)hv_store_ent(P->path2off, k1, newSViv((IV)root2), 0);
597 38 SV *k2 = sv_2mortal(newSVsv(doc)); sv_catpvs(k2, "#"); (void)hv_store_ent(P->path2off, k2, newSViv((IV)root2), 0); }
598 38 kp = SvPV_const(key, kl); /* key SV unchanged */
599 38 te = hv_fetch(P->path2off, kp, (I32)kl, 0);
600 }
601 }
602 }
603  
604 518 ▶ if (te && *te && SvIOK(*te)) {
Branch: 3 branches
BranchTrueFalseTotal
if (te && *te && SvIOK(*te)) { 258 2 260
if (te && *te && SvIOK(*te)) { 258 0 258
if (te && *te && SvIOK(*te)) { 258 0 258
605 258 jsf_node_t *nd = (jsf_node_t *)jsf_arena_ptr(P->C->arena, node_off);
606 258 nd->ref_off = (uint32_t)SvIV(*te);
607 /* $dynamicRef "bookend": the dynamic-scope search only applies when
608 * the lexical target is itself the matching $dynamicAnchor; else it
609 * is a plain $ref (clear the dynamic name so runtime uses ref_off). */
610 258 ▶ if ((nd->present & JSF_HAS_DYNREF) && nd->dynref_name_off) {
Branch: 2 branches
BranchTrueFalseTotal
if ((nd->present & JSF_HAS_DYNREF) && nd->dynref_name_off) { 60 198 258
if ((nd->present & JSF_HAS_DYNREF) && nd->dynref_name_off) { 60 0 60
611 60 jsf_node_t *tgt = (jsf_node_t *)jsf_arena_ptr(P->C->arena, nd->ref_off);
612 60 uint32_t nml; const char *nm = jsf_str_bytes(P->C->arena, nd->dynref_name_off, &nml);
613 60 uint32_t tbl; const char *tb = jsf_str_bytes(P->C->arena, tgt->base_off, &tbl);
614 60 SV *dk = sv_2mortal(newSVpvn(tb, tbl)); STRLEN dkl; const char *dkp;
615 SV **de;
616 60 sv_catpvs(dk, "#"); sv_catpvn(dk, nm, nml);
617 60 dkp = SvPV_const(dk, dkl);
618 60 de = hv_fetch(P->C->dynmap, dkp, (I32)dkl, 0);
619 60 ▶ if (!(de && *de && SvIOK(*de) && (uint32_t)SvIV(*de) == nd->ref_off))
Branch: 4 branches
BranchTrueFalseTotal
if (!(de && *de && SvIOK(*de) && (uint32_t)SvIV(*de) == nd->ref_off)) 53 7 60
if (!(de && *de && SvIOK(*de) && (uint32_t)SvIV(*de) == nd->ref_off)) 53 0 53
if (!(de && *de && SvIOK(*de) && (uint32_t)SvIV(*de) == nd->ref_off)) 53 0 53
if (!(de && *de && SvIOK(*de) && (uint32_t)SvIV(*de) == nd->ref_off)) 0 53 53
620 7 nd->dynref_name_off = 0;
621 }
622 } else {
623 2 STRLEN rl; const char *rp = SvPV_const(ref_copy, rl);
624 2 croak("JSON::Schema::Fast: cannot resolve $ref '%.*s'", (int)rl, rp);
625 }
626 }
627 478 }
628  
629 /* ---- top-level compile -------------------------------------------------- */
630  
631 480 static jsf_compiled_t *jsf_compile_sv(pTHX_ SV *schema, SV *resolver, int auto_fetch) {
632 480 jsf_compiled_t *C = jsf_compiled_new(aTHX);
633 jsf_pctx P;
634 SV *root_path;
635 480 ▶ if (!C) croak("JSON::Schema::Fast: out of memory");
Branch: 1 branch
BranchTrueFalseTotal
if (!C) croak("JSON::Schema::Fast: out of memory"); 0 480 480
636 480 P.C = C;
637 480 P.path2off = (HV *)sv_2mortal((SV *)newHV());
638 480 P.refreqs = (AV *)sv_2mortal((SV *)newAV());
639 480 P.base = sv_2mortal(newSVpvs("")); /* default base URI */
640 480 ▶ P.resolver = (resolver && SvOK(resolver)) ? resolver : NULL;
Branch: 2 branches
BranchTrueFalseTotal
P.resolver = (resolver && SvOK(resolver)) ? resolver : NULL; 385 95 480
P.resolver = (resolver && SvOK(resolver)) ? resolver : NULL; 385 0 385
641 480 P.loaded = (HV *)sv_2mortal((SV *)newHV());
642 480 P.auto_fetch = auto_fetch;
643 480 root_path = sv_2mortal(newSVpvs("#"));
644 480 C->root = jsf_parse_schema(aTHX_ &P, schema, root_path);
645 480 jsf_resolve_refs(aTHX_ &P);
646  
647 /* $schema: a custom metaschema whose $vocabulary omits (or disables) the
648 * validation vocabulary turns the validation keywords into annotations. */
649 478 ▶ if (SvROK(schema) && SvTYPE(SvRV(schema)) == SVt_PVHV) {
Branch: 2 branches
BranchTrueFalseTotal
if (SvROK(schema) && SvTYPE(SvRV(schema)) == SVt_PVHV) { 478 0 478
if (SvROK(schema) && SvTYPE(SvRV(schema)) == SVt_PVHV) { 474 4 478
650 474 SV **sc = hv_fetchs((HV *)SvRV(schema), "$schema", 0);
651 474 ▶ if (sc && *sc && SvPOK(*sc)) {
Branch: 3 branches
BranchTrueFalseTotal
if (sc && *sc && SvPOK(*sc)) { 379 95 474
if (sc && *sc && SvPOK(*sc)) { 379 0 379
if (sc && *sc && SvPOK(*sc)) { 379 0 379
652 379 STRLEN sl; const char *sp = SvPV_const(*sc, sl);
653 static const char *STD = "https://json-schema.org/draft/2020-12/schema";
654 379 ▶ if (P.resolver && !(sl == strlen(STD) && memEQ(sp, STD, sl))) {
Branch: 3 branches
BranchTrueFalseTotal
if (P.resolver && !(sl == strlen(STD) && memEQ(sp, STD, sl))) { 379 0 379
if (P.resolver && !(sl == strlen(STD) && memEQ(sp, STD, sl))) { 376 3 379
if (P.resolver && !(sl == strlen(STD) && memEQ(sp, STD, sl))) { 0 376 376
655 3 SV *meta = jsf_call_resolver(aTHX_ P.resolver, sp, sl);
656 3 ▶ if (meta && SvROK(meta) && SvTYPE(SvRV(meta)) == SVt_PVHV) {
Branch: 3 branches
BranchTrueFalseTotal
if (meta && SvROK(meta) && SvTYPE(SvRV(meta)) == SVt_PVHV) { 3 0 3
if (meta && SvROK(meta) && SvTYPE(SvRV(meta)) == SVt_PVHV) { 3 0 3
if (meta && SvROK(meta) && SvTYPE(SvRV(meta)) == SVt_PVHV) { 3 0 3
657 3 SV **vv = hv_fetchs((HV *)SvRV(meta), "$vocabulary", 0);
658 3 ▶ if (vv && *vv && SvROK(*vv) && SvTYPE(SvRV(*vv)) == SVt_PVHV) {
Branch: 4 branches
BranchTrueFalseTotal
if (vv && *vv && SvROK(*vv) && SvTYPE(SvRV(*vv)) == SVt_PVHV) { 3 0 3
if (vv && *vv && SvROK(*vv) && SvTYPE(SvRV(*vv)) == SVt_PVHV) { 3 0 3
if (vv && *vv && SvROK(*vv) && SvTYPE(SvRV(*vv)) == SVt_PVHV) { 3 0 3
if (vv && *vv && SvROK(*vv) && SvTYPE(SvRV(*vv)) == SVt_PVHV) { 3 0 3
659 static const char *VV = "https://json-schema.org/draft/2020-12/vocab/validation";
660 3 SV **val = hv_fetch((HV *)SvRV(*vv), VV, (I32)strlen(VV), 0);
661 3 ▶ if (!val || !*val || !SvTRUE(*val)) C->no_validation_vocab = 1;
Branch: 3 branches
BranchTrueFalseTotal
if (!val || !*val || !SvTRUE(*val)) C->no_validation_vocab = 1; 1 2 3
if (!val || !*val || !SvTRUE(*val)) C->no_validation_vocab = 1; 1 0 1
if (!val || !*val || !SvTRUE(*val)) C->no_validation_vocab = 1; 0 1 1
662 }
663 }
664 }
665 }
666 }
667 478 return C;
668 }
669  
670 #endif /* JSF_PARSE_H */
« Fast.xs ↑ Summary include/jsf_types.h »