| 1 |
|
| MODULE = Punk::OpenTelemetry PACKAGE = Punk::OpenTelemetry::Schema |
| 2 |
|
| |
| 3 |
|
| PROTOTYPES: DISABLE |
| 4 |
|
| |
| 5 |
|
| # The converter. Loading a schema file stays in Perl - it is a YAML parse and |
| 6 |
|
| # a directory search, done once, and neither is a hot path - but converting a |
| 7 |
|
| # payload walks every attribute hash in it, so that half is C. |
| 8 |
|
| |
| 9 |
|
| # Semantic version comparison. Exposed because it is the thing most easily got |
| 10 |
|
| # wrong and most cheaply asserted: "1.10.0" against "1.9.0" as strings puts |
| 11 |
|
| # them the wrong way round. |
| 12 |
|
| IV |
| 13 |
|
| _vcmp(a, b) |
| 14 |
|
| SV *a |
| 15 |
|
| SV *b |
| 16 |
|
| CODE: |
| 17 |
0 |
▶ | RETVAL = (IV)otel_schema_vcmp(aTHX_ a, b); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = (IV)otel_schema_vcmp(aTHX_ a, b); |
0 |
0 |
0 |
|
| 18 |
|
| OUTPUT: |
| 19 |
|
| RETVAL |
| 20 |
|
| |
| 21 |
|
| # The version at the end of a schema URL, or undef. |
| 22 |
|
| SV * |
| 23 |
|
| _url_version(url) |
| 24 |
|
| SV *url |
| 25 |
|
| CODE: |
| 26 |
|
| { |
| 27 |
0 |
| SV *v = otel_schema_url_version(aTHX_ url); |
| 28 |
0 |
▶ | if (!v) XSRETURN_UNDEF; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!v) XSRETURN_UNDEF; |
0 |
0 |
0 |
|
| 29 |
0 |
| RETVAL = newSVsv(v); |
| 30 |
|
| } |
| 31 |
|
| OUTPUT: |
| 32 |
|
| RETVAL |
| 33 |
|
| |
| 34 |
|
| # The keys of a versions hash, in semantic order. |
| 35 |
|
| SV * |
| 36 |
|
| _order(versions) |
| 37 |
|
| SV *versions |
| 38 |
|
| CODE: |
| 39 |
|
| { |
| 40 |
0 |
| HV *v = otel_hv_of(aTHX_ versions); |
| 41 |
0 |
| AV *out = newAV(); |
| 42 |
|
| HE *he; |
| 43 |
0 |
▶ | if (v) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (v) { |
0 |
0 |
0 |
|
| 44 |
0 |
| hv_iterinit(v); |
| 45 |
0 |
▶ | while ((he = hv_iternext(v))) |
Branch: 1 branch
| Branch | True | False | Total |
| while ((he = hv_iternext(v))) |
0 |
0 |
0 |
|
| 46 |
0 |
| av_push(out, newSVsv(hv_iterkeysv(he))); |
| 47 |
0 |
| sortsv(AvARRAY(out), (SSize_t)(av_len(out) + 1), |
| 48 |
|
| otel_schema_sortcmp); |
| 49 |
|
| } |
| 50 |
0 |
| RETVAL = newRV_noinc((SV *)out); |
| 51 |
|
| } |
| 52 |
|
| OUTPUT: |
| 53 |
|
| RETVAL |
| 54 |
|
| |
| 55 |
|
| # convert($self, $payload, from => $v, to => $v, signal => $s) |
| 56 |
|
| # |
| 57 |
|
| # The payload is modified IN PLACE and returned, so a caller can convert a |
| 58 |
|
| # batch on its way to the exporter without copying it. |
| 59 |
|
| SV * |
| 60 |
|
| convert(self, payload, ...) |
| 61 |
|
| SV *self |
| 62 |
|
| SV *payload |
| 63 |
|
| CODE: |
| 64 |
|
| { |
| 65 |
16 |
| HV *sh = otel_hv_of(aTHX_ self); |
| 66 |
16 |
| HV *pl = otel_hv_of(aTHX_ payload); |
| 67 |
16 |
| SV *from = NULL, *to = NULL; |
| 68 |
16 |
| const char *signal = "spans"; |
| 69 |
16 |
| STRLEN siglen = 5; |
| 70 |
|
| AV *order, *steps; |
| 71 |
16 |
| int dir = 0, forward, i, n; |
| 72 |
|
| |
| 73 |
16 |
▶ | if (!sh) croak("convert: not a schema object"); |
Branch: 1 branch
| Branch | True | False | Total |
| if (!sh) croak("convert: not a schema object"); |
0 |
16 |
16 |
|
| 74 |
64 |
▶ | for (i = 2; i + 1 < items; i += 2) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 2; i + 1 < items; i += 2) { |
48 |
16 |
64 |
|
| 75 |
48 |
| const char *k = SvPV_nolen(ST(i)); |
| 76 |
48 |
▶ | if (strEQ(k, "from")) from = ST(i + 1); |
Branch: 1 branch
| Branch | True | False | Total |
| if (strEQ(k, "from")) from = ST(i + 1); |
16 |
32 |
48 |
|
| 77 |
32 |
▶ | else if (strEQ(k, "to")) to = ST(i + 1); |
Branch: 1 branch
| Branch | True | False | Total |
| else if (strEQ(k, "to")) to = ST(i + 1); |
16 |
16 |
32 |
|
| 78 |
16 |
▶ | else if (strEQ(k, "signal") && SvOK(ST(i + 1))) |
Branch: 2 branches
| Branch | True | False | Total |
| else if (strEQ(k, "signal") && SvOK(ST(i + 1))) |
16 |
0 |
16 |
| else if (strEQ(k, "signal") && SvOK(ST(i + 1))) |
16 |
0 |
16 |
|
| 79 |
32 |
| signal = SvPV(ST(i + 1), siglen); |
| 80 |
|
| } |
| 81 |
16 |
▶ | if (!(from && SvOK(from))) croak("convert: need from"); |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(from && SvOK(from))) croak("convert: need from"); |
16 |
0 |
16 |
| if (!(from && SvOK(from))) croak("convert: need from"); |
0 |
16 |
16 |
|
| 82 |
16 |
▶ | if (!(to && SvOK(to))) croak("convert: need to"); |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(to && SvOK(to))) croak("convert: need to"); |
16 |
0 |
16 |
| if (!(to && SvOK(to))) croak("convert: need to"); |
0 |
16 |
16 |
|
| 83 |
|
| |
| 84 |
|
| /* A schema file lists the versions at which something CHANGED, not |
| 85 |
|
| * every version that ever existed, so a `from` below the lowest entry |
| 86 |
|
| * is the ordinary case - it means "produced before any of these |
| 87 |
|
| * changes" and the answer is to apply all of them. |
| 88 |
|
| * |
| 89 |
|
| * What the file genuinely cannot answer for is a version ABOVE its |
| 90 |
|
| * own: it records changes up to its schema_url and knows nothing |
| 91 |
|
| * beyond. That is an error the caller has to handle rather than a |
| 92 |
|
| * silent no-op, because returning unconverted telemetry quietly is |
| 93 |
|
| * indistinguishable from converting it correctly. */ |
| 94 |
16 |
| order = otel_h_av(aTHX_ sh, "order"); |
| 95 |
16 |
▶ | if (order && av_len(order) >= 0) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (order && av_len(order) >= 0) { |
16 |
0 |
16 |
| if (order && av_len(order) >= 0) { |
16 |
0 |
16 |
|
| 96 |
16 |
| SV **tp = av_fetch(order, av_len(order), 0); |
| 97 |
16 |
▶ | if (tp && *tp) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (tp && *tp) { |
16 |
0 |
16 |
| if (tp && *tp) { |
16 |
0 |
16 |
|
| 98 |
|
| int j; |
| 99 |
47 |
▶ | for (j = 0; j < 2; j++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (j = 0; j < 2; j++) { |
32 |
15 |
47 |
|
| 100 |
32 |
▶ | SV *v = j ? to : from; |
Branch: 1 branch
| Branch | True | False | Total |
| SV *v = j ? to : from; |
16 |
16 |
32 |
|
| 101 |
32 |
▶ | if (otel_schema_vcmp(aTHX_ v, *tp) > 0) |
Branch: 1 branch
| Branch | True | False | Total |
| if (otel_schema_vcmp(aTHX_ v, *tp) > 0) |
1 |
31 |
32 |
|
| 102 |
1 |
| croak("Punk::OpenTelemetry::Schema: this file " |
| 103 |
|
| "describes changes up to %" SVf " and cannot " |
| 104 |
|
| "convert %" SVf "\n", SVfARG(*tp), SVfARG(v)); |
| 105 |
|
| } |
| 106 |
|
| } |
| 107 |
|
| } |
| 108 |
|
| |
| 109 |
15 |
▶ | if (!pl) { RETVAL = newSVsv(payload); XSRETURN(1); } |
Branch: 1 branch
| Branch | True | False | Total |
| if (!pl) { RETVAL = newSVsv(payload); XSRETURN(1); } |
0 |
15 |
15 |
|
| 110 |
|
| |
| 111 |
15 |
| steps = otel_schema_walk(aTHX_ sh, from, to, &dir); |
| 112 |
15 |
| forward = dir > 0; |
| 113 |
15 |
| n = (int)(av_len(steps) + 1); |
| 114 |
57 |
▶ | for (i = 0; i < n; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < n; i++) { |
42 |
15 |
57 |
|
| 115 |
42 |
| SV **sp = av_fetch(steps, i, 0); |
| 116 |
|
| HV *map; |
| 117 |
42 |
▶ | if (!(sp && *sp)) continue; |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(sp && *sp)) continue; |
42 |
0 |
42 |
| if (!(sp && *sp)) continue; |
0 |
42 |
42 |
|
| 118 |
42 |
| map = otel_schema_renames(aTHX_ sh, *sp, signal, siglen); |
| 119 |
42 |
▶ | if (!HvUSEDKEYS(map)) continue; |
Branch: 2 branches
| Branch | True | False | Total |
| if (!HvUSEDKEYS(map)) continue; |
0 |
42 |
42 |
| if (!HvUSEDKEYS(map)) continue; |
10 |
32 |
42 |
|
| 120 |
32 |
| otel_schema_each_attrs(aTHX_ pl, signal, siglen, map, forward); |
| 121 |
32 |
▶ | if (siglen == 7 && memEQ(signal, "metrics", 7)) |
Branch: 2 branches
| Branch | True | False | Total |
| if (siglen == 7 && memEQ(signal, "metrics", 7)) |
2 |
30 |
32 |
| if (siglen == 7 && memEQ(signal, "metrics", 7)) |
2 |
0 |
2 |
|
| 122 |
2 |
| otel_schema_each_metric(aTHX_ pl, map, forward); |
| 123 |
|
| } |
| 124 |
15 |
| RETVAL = newSVsv(payload); |
| 125 |
|
| } |
| 126 |
|
| OUTPUT: |
| 127 |
|
| RETVAL |
| 128 |
|
| |
| 129 |
|
| # ---- sourcing a schema file ---------------------------------------------- |
| 130 |
|
| |
| 131 |
|
| # _parse_yaml($text): the document, through whichever YAML parser is present, |
| 132 |
|
| # fastest first. WHICH parser is a runtime question and not a build one: the |
| 133 |
|
| # feature is opt-in and most deployments never touch it, so a hard dependency |
| 134 |
|
| # would tax everyone for the few. There is no C YAML parser to reach for - |
| 135 |
|
| # File::Raw::YAML publishes no ABI - so this is a call by name, as the |
| 136 |
|
| # exporter calls HTTP::Date. |
| 137 |
|
| SV * |
| 138 |
|
| _parse_yaml(text) |
| 139 |
|
| SV *text |
| 140 |
|
| CODE: |
| 141 |
|
| { |
| 142 |
|
| static const char *const REQS[3] = { "require YAML::XS; 1", |
| 143 |
|
| "require YAML::PP; 1", |
| 144 |
|
| "require YAML; 1" }; |
| 145 |
8 |
| SV *out = NULL; |
| 146 |
|
| int i; |
| 147 |
16 |
▶ | for (i = 0; i < 3 && !out; i++) { |
Branch: 2 branches
| Branch | True | False | Total |
| for (i = 0; i < 3 && !out; i++) { |
16 |
0 |
16 |
| for (i = 0; i < 3 && !out; i++) { |
8 |
8 |
16 |
|
| 148 |
8 |
| dSP; int count; |
| 149 |
8 |
| eval_pv(REQS[i], FALSE); |
| 150 |
8 |
| SPAGAIN; |
| 151 |
8 |
▶ | if (SvTRUE(ERRSV)) continue; |
Branch: 2 branches
| Branch | True | False | Total |
| if (SvTRUE(ERRSV)) continue; |
8 |
0 |
8 |
| if (SvTRUE(ERRSV)) continue; |
0 |
8 |
8 |
|
| 152 |
8 |
| ENTER; SAVETMPS; |
| 153 |
8 |
▶ | if (i == 1) { /* YAML::PP->new->load_string($t) */ |
Branch: 1 branch
| Branch | True | False | Total |
| if (i == 1) { /* YAML::PP->new->load_string($t) */ |
0 |
8 |
8 |
|
| 154 |
0 |
| SV *pp = NULL; |
| 155 |
0 |
▶ | PUSHMARK(SP); EXTEND(SP, 1); |
Branch: 2 branches
| Branch | True | False | Total |
| PUSHMARK(SP); EXTEND(SP, 1); |
0 |
0 |
0 |
| PUSHMARK(SP); EXTEND(SP, 1); |
0 |
0 |
0 |
|
| 156 |
0 |
| PUSHs(sv_2mortal(newSVpvs("YAML::PP"))); |
| 157 |
0 |
| PUTBACK; |
| 158 |
0 |
| count = call_method("new", G_SCALAR | G_EVAL); |
| 159 |
0 |
| SPAGAIN; |
| 160 |
0 |
▶ | if (!SvTRUE(ERRSV) && count > 0) pp = SvREFCNT_inc(POPs); |
Branch: 3 branches
| Branch | True | False | Total |
| if (!SvTRUE(ERRSV) && count > 0) pp = SvREFCNT_inc(POPs); |
0 |
0 |
0 |
| if (!SvTRUE(ERRSV) && count > 0) pp = SvREFCNT_inc(POPs); |
0 |
0 |
0 |
| if (!SvTRUE(ERRSV) && count > 0) pp = SvREFCNT_inc(POPs); |
0 |
0 |
0 |
|
| 161 |
0 |
▶ | else if (count > 0) (void)POPs; |
Branch: 1 branch
| Branch | True | False | Total |
| else if (count > 0) (void)POPs; |
0 |
0 |
0 |
|
| 162 |
0 |
| PUTBACK; |
| 163 |
0 |
▶ | if (pp) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (pp) { |
0 |
0 |
0 |
|
| 164 |
0 |
| sv_2mortal(pp); |
| 165 |
0 |
▶ | PUSHMARK(SP); EXTEND(SP, 2); |
Branch: 2 branches
| Branch | True | False | Total |
| PUSHMARK(SP); EXTEND(SP, 2); |
0 |
0 |
0 |
| PUSHMARK(SP); EXTEND(SP, 2); |
0 |
0 |
0 |
|
| 166 |
0 |
| PUSHs(pp); PUSHs(text); |
| 167 |
0 |
| PUTBACK; |
| 168 |
0 |
| count = call_method("load_string", G_SCALAR | G_EVAL); |
| 169 |
0 |
| SPAGAIN; |
| 170 |
0 |
▶ | if (!SvTRUE(ERRSV) && count > 0) { |
Branch: 3 branches
| Branch | True | False | Total |
| if (!SvTRUE(ERRSV) && count > 0) { |
0 |
0 |
0 |
| if (!SvTRUE(ERRSV) && count > 0) { |
0 |
0 |
0 |
| if (!SvTRUE(ERRSV) && count > 0) { |
0 |
0 |
0 |
|
| 171 |
0 |
| SV *r = POPs; |
| 172 |
0 |
▶ | if (SvTRUE(r)) out = newSVsv(r); |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvTRUE(r)) out = newSVsv(r); |
0 |
0 |
0 |
|
| 173 |
|
| } |
| 174 |
0 |
▶ | else if (count > 0) (void)POPs; |
Branch: 1 branch
| Branch | True | False | Total |
| else if (count > 0) (void)POPs; |
0 |
0 |
0 |
|
| 175 |
0 |
| PUTBACK; |
| 176 |
|
| } |
| 177 |
|
| } |
| 178 |
|
| else { |
| 179 |
8 |
▶ | const char *fn = i ? "YAML::Load" : "YAML::XS::Load"; |
Branch: 1 branch
| Branch | True | False | Total |
| const char *fn = i ? "YAML::Load" : "YAML::XS::Load"; |
0 |
8 |
8 |
|
| 180 |
8 |
▶ | PUSHMARK(SP); EXTEND(SP, 1); |
Branch: 2 branches
| Branch | True | False | Total |
| PUSHMARK(SP); EXTEND(SP, 1); |
0 |
8 |
8 |
| PUSHMARK(SP); EXTEND(SP, 1); |
0 |
8 |
8 |
|
| 181 |
8 |
| PUSHs(text); |
| 182 |
8 |
| PUTBACK; |
| 183 |
8 |
| count = call_pv(fn, G_SCALAR | G_EVAL); |
| 184 |
8 |
| SPAGAIN; |
| 185 |
16 |
▶ | if (!SvTRUE(ERRSV) && count > 0) { |
Branch: 3 branches
| Branch | True | False | Total |
| if (!SvTRUE(ERRSV) && count > 0) { |
8 |
0 |
8 |
| if (!SvTRUE(ERRSV) && count > 0) { |
8 |
0 |
8 |
| if (!SvTRUE(ERRSV) && count > 0) { |
8 |
0 |
8 |
|
| 186 |
8 |
| SV *r = POPs; |
| 187 |
8 |
▶ | if (SvTRUE(r)) out = newSVsv(r); |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvTRUE(r)) out = newSVsv(r); |
8 |
0 |
8 |
|
| 188 |
|
| } |
| 189 |
0 |
▶ | else if (count > 0) (void)POPs; |
Branch: 1 branch
| Branch | True | False | Total |
| else if (count > 0) (void)POPs; |
0 |
0 |
0 |
|
| 190 |
8 |
| PUTBACK; |
| 191 |
|
| } |
| 192 |
8 |
▶ | FREETMPS; LEAVE; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; LEAVE; |
8 |
0 |
8 |
|
| 193 |
|
| } |
| 194 |
8 |
▶ | if (!out) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!out) |
0 |
8 |
8 |
|
| 195 |
0 |
| croak("Punk::OpenTelemetry::Schema: no usable YAML parser found " |
| 196 |
|
| "(File::Raw::YAML, YAML::XS, YAML::PP or YAML)\n"); |
| 197 |
8 |
| RETVAL = out; |
| 198 |
|
| } |
| 199 |
|
| OUTPUT: |
| 200 |
|
| RETVAL |
| 201 |
|
| |
| 202 |
|
| # _dirs(%opt): where a schema file may be found, in order. |
| 203 |
|
| # |
| 204 |
|
| # Nothing here is a network location and nothing here is a fallback TO one: a |
| 205 |
|
| # file is either on disk or it is not. |
| 206 |
|
| # |
| 207 |
|
| # 1. a directory the caller passes |
| 208 |
|
| # 2. $ENV{OTEL_SCHEMA_DIR}, for an operator carrying versions this release |
| 209 |
|
| # predates - the whole reason a search path exists rather than only the |
| 210 |
|
| # shipped file |
| 211 |
|
| # 3. the directory shipped beside this module, found through %INC rather |
| 212 |
|
| # than guessed, so it is right under blib, under a local::lib and |
| 213 |
|
| # installed |
| 214 |
|
| void |
| 215 |
|
| _dirs(...) |
| 216 |
|
| PPCODE: |
| 217 |
|
| { |
| 218 |
0 |
| AV *out = (AV *)sv_2mortal((SV *)newAV()); |
| 219 |
|
| SSize_t i, n; |
| 220 |
|
| int a; |
| 221 |
0 |
▶ | for (a = 0; a + 1 < items; a += 2) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (a = 0; a + 1 < items; a += 2) { |
0 |
0 |
0 |
|
| 222 |
|
| STRLEN kl; |
| 223 |
0 |
| const char *k = SvPV_const(ST(a), kl); |
| 224 |
0 |
▶ | if (kl == 3 && memEQ(k, "dir", 3) && SvOK(ST(a + 1))) |
Branch: 3 branches
| Branch | True | False | Total |
| if (kl == 3 && memEQ(k, "dir", 3) && SvOK(ST(a + 1))) |
0 |
0 |
0 |
| if (kl == 3 && memEQ(k, "dir", 3) && SvOK(ST(a + 1))) |
0 |
0 |
0 |
| if (kl == 3 && memEQ(k, "dir", 3) && SvOK(ST(a + 1))) |
0 |
0 |
0 |
|
| 225 |
0 |
| av_push(out, newSVsv(ST(a + 1))); |
| 226 |
|
| } |
| 227 |
|
| { |
| 228 |
0 |
| SV **e = hv_fetchs(GvHV(PL_envgv), "OTEL_SCHEMA_DIR", 0); |
| 229 |
0 |
▶ | if (e && *e && SvOK(*e)) av_push(out, newSVsv(*e)); |
Branch: 3 branches
| Branch | True | False | Total |
| if (e && *e && SvOK(*e)) av_push(out, newSVsv(*e)); |
0 |
0 |
0 |
| if (e && *e && SvOK(*e)) av_push(out, newSVsv(*e)); |
0 |
0 |
0 |
| if (e && *e && SvOK(*e)) av_push(out, newSVsv(*e)); |
0 |
0 |
0 |
|
| 230 |
|
| } |
| 231 |
|
| { |
| 232 |
0 |
| HV *inc = GvHV(PL_incgv); |
| 233 |
0 |
| SV **e = inc ? hv_fetchs(inc, "Punk/OpenTelemetry/Schema.pm", 0) |
| 234 |
0 |
▶ | : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| : NULL; |
0 |
0 |
0 |
|
| 235 |
0 |
▶ | if (e && *e && SvOK(*e)) { |
Branch: 3 branches
| Branch | True | False | Total |
| if (e && *e && SvOK(*e)) { |
0 |
0 |
0 |
| if (e && *e && SvOK(*e)) { |
0 |
0 |
0 |
| if (e && *e && SvOK(*e)) { |
0 |
0 |
0 |
|
| 236 |
|
| STRLEN l; |
| 237 |
0 |
| const char *p = SvPV_const(*e, l); |
| 238 |
0 |
▶ | if (l > 3 && memEQ(p + l - 3, ".pm", 3)) |
Branch: 2 branches
| Branch | True | False | Total |
| if (l > 3 && memEQ(p + l - 3, ".pm", 3)) |
0 |
0 |
0 |
| if (l > 3 && memEQ(p + l - 3, ".pm", 3)) |
0 |
0 |
0 |
|
| 239 |
0 |
| av_push(out, newSVpvn(p, l - 3)); |
| 240 |
|
| } |
| 241 |
|
| } |
| 242 |
0 |
| n = av_len(out) + 1; |
| 243 |
0 |
▶ | EXTEND(SP, n); |
Branch: 2 branches
| Branch | True | False | Total |
| EXTEND(SP, n); |
0 |
0 |
0 |
| EXTEND(SP, n); |
0 |
0 |
0 |
|
| 244 |
0 |
▶ | for (i = 0; i < n; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < n; i++) { |
0 |
0 |
0 |
|
| 245 |
0 |
| SV **e = av_fetch(out, i, 0); |
| 246 |
0 |
▶ | if (e && *e && SvOK(*e) && SvCUR(*e)) |
Branch: 4 branches
| Branch | True | False | Total |
| if (e && *e && SvOK(*e) && SvCUR(*e)) |
0 |
0 |
0 |
| if (e && *e && SvOK(*e) && SvCUR(*e)) |
0 |
0 |
0 |
| if (e && *e && SvOK(*e) && SvCUR(*e)) |
0 |
0 |
0 |
| if (e && *e && SvOK(*e) && SvCUR(*e)) |
0 |
0 |
0 |
|
| 247 |
0 |
| PUSHs(sv_2mortal(newSVsv(*e))); |
| 248 |
|
| } |
| 249 |
|
| } |
| 250 |
|
| |
| 251 |
|
| # file_for($class, $version, %opt): the file for a version, or undef. |
| 252 |
|
| # |
| 253 |
|
| # Undef is an ordinary answer, not an error: an unknown schema URL means the |
| 254 |
|
| # telemetry passes through unchanged, which is correct and is the only thing |
| 255 |
|
| # that does not involve reaching out to a third party from the request path. |
| 256 |
|
| SV * |
| 257 |
|
| file_for(class, version, ...) |
| 258 |
|
| SV *class |
| 259 |
|
| SV *version |
| 260 |
|
| CODE: |
| 261 |
|
| { |
| 262 |
|
| AV *dirs; |
| 263 |
|
| SSize_t di, dn; |
| 264 |
3 |
| SV *found = NULL; |
| 265 |
|
| PERL_UNUSED_VAR(class); |
| 266 |
3 |
▶ | if (!SvOK(version)) XSRETURN_UNDEF; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!SvOK(version)) XSRETURN_UNDEF; |
0 |
3 |
3 |
|
| 267 |
|
| { /* \A[0-9][0-9.]*\z - a version, and nothing that could climb out |
| 268 |
|
| * of the directory it is about to be joined to */ |
| 269 |
|
| STRLEN l, j; |
| 270 |
3 |
| const char *p = SvPV_const(version, l); |
| 271 |
3 |
▶ | if (!l || !isDIGIT(p[0])) XSRETURN_UNDEF; |
Branch: 2 branches
| Branch | True | False | Total |
| if (!l || !isDIGIT(p[0])) XSRETURN_UNDEF; |
3 |
0 |
3 |
| if (!l || !isDIGIT(p[0])) XSRETURN_UNDEF; |
1 |
2 |
3 |
|
| 272 |
13 |
▶ | for (j = 0; j < l; j++) |
Branch: 1 branch
| Branch | True | False | Total |
| for (j = 0; j < l; j++) |
11 |
2 |
13 |
|
| 273 |
11 |
▶ | if (!isDIGIT(p[j]) && p[j] != '.') XSRETURN_UNDEF; |
Branch: 2 branches
| Branch | True | False | Total |
| if (!isDIGIT(p[j]) && p[j] != '.') XSRETURN_UNDEF; |
4 |
7 |
11 |
| if (!isDIGIT(p[j]) && p[j] != '.') XSRETURN_UNDEF; |
0 |
4 |
4 |
|
| 274 |
|
| } |
| 275 |
2 |
| dirs = otel_schema_dirs(aTHX_ &ST(2), items - 2); |
| 276 |
2 |
| dn = av_len(dirs) + 1; |
| 277 |
3 |
▶ | for (di = 0; di < dn; di++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (di = 0; di < dn; di++) { |
2 |
1 |
3 |
|
| 278 |
2 |
| SV **d = av_fetch(dirs, di, 0); |
| 279 |
|
| SV *path; |
| 280 |
|
| Stat_t st; |
| 281 |
2 |
▶ | if (!(d && *d && SvOK(*d))) continue; |
Branch: 3 branches
| Branch | True | False | Total |
| if (!(d && *d && SvOK(*d))) continue; |
2 |
0 |
2 |
| if (!(d && *d && SvOK(*d))) continue; |
2 |
0 |
2 |
| if (!(d && *d && SvOK(*d))) continue; |
0 |
2 |
2 |
|
| 282 |
2 |
| path = sv_2mortal(newSVsv(*d)); |
| 283 |
2 |
| sv_catpvs(path, "/"); |
| 284 |
2 |
| sv_catsv(path, version); |
| 285 |
2 |
| sv_catpvs(path, ".yaml"); |
| 286 |
2 |
▶ | if (PerlLIO_stat(SvPV_nolen(path), &st) == 0 |
Branch: 1 branch
| Branch | True | False | Total |
| if (PerlLIO_stat(SvPV_nolen(path), &st) == 0 |
1 |
1 |
2 |
|
| 287 |
1 |
▶ | && S_ISREG(st.st_mode)) { |
Branch: 1 branch
| Branch | True | False | Total |
| && S_ISREG(st.st_mode)) { |
1 |
0 |
1 |
|
| 288 |
1 |
| found = path; |
| 289 |
1 |
| break; |
| 290 |
|
| } |
| 291 |
|
| } |
| 292 |
|
| /* Nothing on the path is an ORDINARY answer, and it has to return |
| 293 |
|
| * here rather than fall through: RETVAL is uninitialised until |
| 294 |
|
| * something is found, and handing the typemap a stack pointer is |
| 295 |
|
| * how a missing schema file becomes a crash. */ |
| 296 |
2 |
▶ | if (!found) XSRETURN_UNDEF; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!found) XSRETURN_UNDEF; |
1 |
1 |
2 |
|
| 297 |
1 |
| RETVAL = newSVsv(found); |
| 298 |
|
| } |
| 299 |
|
| OUTPUT: |
| 300 |
|
| RETVAL |
| 301 |
|
| |
| 302 |
|
| # shipped_version(): the semantic convention version this distribution emits, |
| 303 |
|
| # which is also the version of the file it ships. DERIVED from the C pin |
| 304 |
|
| # (OTEL_SCHEMA_URL in otel_semconv.h) rather than written down twice, so it |
| 305 |
|
| # cannot drift from what the encoder puts on the wire. |
| 306 |
|
| SV * |
| 307 |
|
| shipped_version(class = &PL_sv_undef) |
| 308 |
|
| SV *class |
| 309 |
|
| CODE: |
| 310 |
|
| { |
| 311 |
1 |
| SV *url = sv_2mortal(newSVpvs(OTEL_SCHEMA_URL)); |
| 312 |
|
| SV *v; |
| 313 |
|
| PERL_UNUSED_VAR(class); |
| 314 |
1 |
| v = otel_schema_url_version(aTHX_ url); |
| 315 |
1 |
▶ | if (!v) XSRETURN_UNDEF; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!v) XSRETURN_UNDEF; |
0 |
1 |
1 |
|
| 316 |
1 |
| RETVAL = newSVsv(v); |
| 317 |
|
| } |
| 318 |
|
| OUTPUT: |
| 319 |
|
| RETVAL |
| 320 |
|
| |
| 321 |
|
| # load($class, text => ... | path => ... | version => ...) |
| 322 |
|
| # |
| 323 |
|
| # With no source at all: the shipped file for the version this dist emits, |
| 324 |
|
| # which is what a caller almost always means. |
| 325 |
|
| SV * |
| 326 |
|
| load(class, ...) |
| 327 |
|
| SV *class |
| 328 |
|
| CODE: |
| 329 |
|
| { |
| 330 |
8 |
| SV *text = NULL, *path = NULL, *version = NULL; |
| 331 |
|
| SV *doc, *self; |
| 332 |
|
| HV *d, *versions; |
| 333 |
|
| int a; |
| 334 |
16 |
▶ | for (a = 1; a + 1 < items; a += 2) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (a = 1; a + 1 < items; a += 2) { |
8 |
8 |
16 |
|
| 335 |
|
| STRLEN kl; |
| 336 |
8 |
| const char *k = SvPV_const(ST(a), kl); |
| 337 |
8 |
▶ | if (kl == 4 && memEQ(k, "text", 4)) text = ST(a + 1); |
Branch: 2 branches
| Branch | True | False | Total |
| if (kl == 4 && memEQ(k, "text", 4)) text = ST(a + 1); |
6 |
2 |
8 |
| if (kl == 4 && memEQ(k, "text", 4)) text = ST(a + 1); |
4 |
2 |
6 |
|
| 338 |
4 |
▶ | else if (kl == 4 && memEQ(k, "path", 4)) path = ST(a + 1); |
Branch: 2 branches
| Branch | True | False | Total |
| else if (kl == 4 && memEQ(k, "path", 4)) path = ST(a + 1); |
2 |
2 |
4 |
| else if (kl == 4 && memEQ(k, "path", 4)) path = ST(a + 1); |
2 |
0 |
2 |
|
| 339 |
2 |
▶ | else if (kl == 7 && memEQ(k, "version", 7)) version = ST(a + 1); |
Branch: 2 branches
| Branch | True | False | Total |
| else if (kl == 7 && memEQ(k, "version", 7)) version = ST(a + 1); |
1 |
1 |
2 |
| else if (kl == 7 && memEQ(k, "version", 7)) version = ST(a + 1); |
1 |
0 |
1 |
|
| 340 |
|
| } |
| 341 |
8 |
▶ | if (!(text && SvOK(text))) text = NULL; |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(text && SvOK(text))) text = NULL; |
4 |
4 |
8 |
| if (!(text && SvOK(text))) text = NULL; |
0 |
4 |
4 |
|
| 342 |
8 |
▶ | if (!(path && SvOK(path))) path = NULL; |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(path && SvOK(path))) path = NULL; |
2 |
6 |
8 |
| if (!(path && SvOK(path))) path = NULL; |
0 |
2 |
2 |
|
| 343 |
|
| |
| 344 |
8 |
▶ | if (!text && !path) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!text && !path) { |
4 |
4 |
8 |
| if (!text && !path) { |
2 |
2 |
4 |
|
| 345 |
1 |
▶ | SV *v = (version && SvOK(version)) |
Branch: 1 branch
| Branch | True | False | Total |
| SV *v = (version && SvOK(version)) |
1 |
0 |
1 |
|
| 346 |
1 |
| ? sv_2mortal(newSVsv(version)) |
| 347 |
2 |
▶ | : otel_schema_url_version(aTHX_ |
Branch: 1 branch
| Branch | True | False | Total |
| : otel_schema_url_version(aTHX_ |
1 |
1 |
2 |
|
| 348 |
|
| sv_2mortal(newSVpvs(OTEL_SCHEMA_URL))); |
| 349 |
2 |
| path = otel_schema_file_for(aTHX_ v, &ST(1), items - 1); |
| 350 |
2 |
▶ | if (!path) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!path) { |
0 |
2 |
2 |
|
| 351 |
0 |
| AV *dirs = otel_schema_dirs(aTHX_ &ST(1), items - 1); |
| 352 |
0 |
| SV *joined = sv_2mortal(newSVpvs("")); |
| 353 |
0 |
| SSize_t i, n = av_len(dirs) + 1; |
| 354 |
0 |
▶ | for (i = 0; i < n; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < n; i++) { |
0 |
0 |
0 |
|
| 355 |
0 |
| SV **e = av_fetch(dirs, i, 0); |
| 356 |
0 |
▶ | if (i) sv_catpvs(joined, ", "); |
Branch: 1 branch
| Branch | True | False | Total |
| if (i) sv_catpvs(joined, ", "); |
0 |
0 |
0 |
|
| 357 |
0 |
▶ | if (e && *e) sv_catsv(joined, *e); |
Branch: 2 branches
| Branch | True | False | Total |
| if (e && *e) sv_catsv(joined, *e); |
0 |
0 |
0 |
| if (e && *e) sv_catsv(joined, *e); |
0 |
0 |
0 |
|
| 358 |
|
| } |
| 359 |
0 |
▶ | croak("Punk::OpenTelemetry::Schema->load: no schema file for " |
Branch: 1 branch
| Branch | True | False | Total |
| croak("Punk::OpenTelemetry::Schema->load: no schema file for " |
0 |
0 |
0 |
|
| 360 |
|
| "%" SVf " in %" SVf "\n", |
| 361 |
|
| SVfARG(v ? v : sv_2mortal(newSVpvs("(unknown version)"))), |
| 362 |
|
| SVfARG(joined)); |
| 363 |
|
| } |
| 364 |
|
| } |
| 365 |
|
| |
| 366 |
8 |
▶ | if (!text) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!text) { |
4 |
4 |
8 |
|
| 367 |
|
| PerlIO *fh; |
| 368 |
|
| SV *buf; |
| 369 |
|
| char chunk[8192]; |
| 370 |
|
| SSize_t got; |
| 371 |
4 |
| fh = PerlIO_open(SvPV_nolen(path), "r"); |
| 372 |
4 |
▶ | if (!fh) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!fh) |
0 |
4 |
4 |
|
| 373 |
0 |
| croak("Punk::OpenTelemetry::Schema->load: %" SVf ": %s\n", |
| 374 |
|
| SVfARG(path), Strerror(errno)); |
| 375 |
4 |
| buf = sv_2mortal(newSVpvs("")); |
| 376 |
14 |
▶ | while ((got = PerlIO_read(fh, chunk, sizeof chunk)) > 0) |
Branch: 1 branch
| Branch | True | False | Total |
| while ((got = PerlIO_read(fh, chunk, sizeof chunk)) > 0) |
10 |
4 |
14 |
|
| 377 |
10 |
| sv_catpvn(buf, chunk, (STRLEN)got); |
| 378 |
4 |
| PerlIO_close(fh); |
| 379 |
4 |
| text = buf; |
| 380 |
|
| } |
| 381 |
|
| |
| 382 |
|
| { /* the parse is the one call out; everything either side is here */ |
| 383 |
8 |
| dSP; int count; |
| 384 |
8 |
| doc = NULL; |
| 385 |
8 |
| ENTER; SAVETMPS; |
| 386 |
8 |
▶ | PUSHMARK(SP); EXTEND(SP, 1); PUSHs(text); PUTBACK; |
Branch: 2 branches
| Branch | True | False | Total |
| PUSHMARK(SP); EXTEND(SP, 1); PUSHs(text); PUTBACK; |
0 |
8 |
8 |
| PUSHMARK(SP); EXTEND(SP, 1); PUSHs(text); PUTBACK; |
0 |
8 |
8 |
|
| 387 |
8 |
| count = call_pv("Punk::OpenTelemetry::Schema::_parse_yaml", |
| 388 |
|
| G_SCALAR); |
| 389 |
8 |
| SPAGAIN; |
| 390 |
8 |
▶ | if (count > 0) doc = SvREFCNT_inc(POPs); |
Branch: 1 branch
| Branch | True | False | Total |
| if (count > 0) doc = SvREFCNT_inc(POPs); |
8 |
0 |
8 |
|
| 391 |
8 |
▶ | PUTBACK; FREETMPS; LEAVE; |
Branch: 1 branch
| Branch | True | False | Total |
| PUTBACK; FREETMPS; LEAVE; |
8 |
0 |
8 |
|
| 392 |
|
| } |
| 393 |
8 |
▶ | if (doc) sv_2mortal(doc); |
Branch: 1 branch
| Branch | True | False | Total |
| if (doc) sv_2mortal(doc); |
8 |
0 |
8 |
|
| 394 |
8 |
▶ | d = doc ? otel_hv_of(aTHX_ doc) : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| d = doc ? otel_hv_of(aTHX_ doc) : NULL; |
8 |
0 |
8 |
|
| 395 |
8 |
▶ | versions = d ? otel_h_hv(aTHX_ d, "versions") : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| versions = d ? otel_h_hv(aTHX_ d, "versions") : NULL; |
8 |
0 |
8 |
|
| 396 |
8 |
▶ | if (!versions) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!versions) |
1 |
7 |
8 |
|
| 397 |
1 |
| croak("Punk::OpenTelemetry::Schema: not a schema file " |
| 398 |
|
| "(no 'versions')\n"); |
| 399 |
|
| |
| 400 |
|
| { |
| 401 |
7 |
| HV *h = newHV(); |
| 402 |
7 |
| AV *order = newAV(); |
| 403 |
|
| HE *he; |
| 404 |
7 |
| SV *u = otel_h(aTHX_ d, "schema_url"); |
| 405 |
7 |
| SV *ff = otel_h(aTHX_ d, "file_format"); |
| 406 |
0 |
▶ | const char *cls = (SvROK(class) && SvOBJECT(SvRV(class))) |
Branch: 1 branch
| Branch | True | False | Total |
| const char *cls = (SvROK(class) && SvOBJECT(SvRV(class))) |
0 |
0 |
0 |
|
| 407 |
14 |
▶ | ? HvNAME(SvSTASH(SvRV(class))) : SvPV_nolen(class); |
Branch: 7 branches
| Branch | True | False | Total |
| ? HvNAME(SvSTASH(SvRV(class))) : SvPV_nolen(class); |
0 |
7 |
7 |
| ? HvNAME(SvSTASH(SvRV(class))) : SvPV_nolen(class); |
0 |
0 |
0 |
| ? HvNAME(SvSTASH(SvRV(class))) : SvPV_nolen(class); |
0 |
0 |
0 |
| ? HvNAME(SvSTASH(SvRV(class))) : SvPV_nolen(class); |
0 |
0 |
0 |
| ? HvNAME(SvSTASH(SvRV(class))) : SvPV_nolen(class); |
0 |
0 |
0 |
| ? HvNAME(SvSTASH(SvRV(class))) : SvPV_nolen(class); |
0 |
0 |
0 |
| ? HvNAME(SvSTASH(SvRV(class))) : SvPV_nolen(class); |
0 |
0 |
0 |
|
| 408 |
7 |
▶ | (void)hv_stores(h, "schema_url", u ? newSVsv(u) : newSV(0)); |
Branch: 1 branch
| Branch | True | False | Total |
| (void)hv_stores(h, "schema_url", u ? newSVsv(u) : newSV(0)); |
7 |
0 |
7 |
|
| 409 |
7 |
▶ | (void)hv_stores(h, "file_format", ff ? newSVsv(ff) : newSV(0)); |
Branch: 1 branch
| Branch | True | False | Total |
| (void)hv_stores(h, "file_format", ff ? newSVsv(ff) : newSV(0)); |
7 |
0 |
7 |
|
| 410 |
7 |
| (void)hv_stores(h, "versions", newSVsv(*hv_fetchs(d, "versions", 0))); |
| 411 |
7 |
| hv_iterinit(versions); |
| 412 |
72 |
▶ | while ((he = hv_iternext(versions))) |
Branch: 1 branch
| Branch | True | False | Total |
| while ((he = hv_iternext(versions))) |
65 |
7 |
72 |
|
| 413 |
65 |
| av_push(order, newSVsv(hv_iterkeysv(he))); |
| 414 |
|
| /* semantic order, not string order: the steps are applied one at |
| 415 |
|
| * a time, so the order IS the behaviour */ |
| 416 |
7 |
▶ | if (av_len(order) > 0) |
Branch: 1 branch
| Branch | True | False | Total |
| if (av_len(order) > 0) |
4 |
3 |
7 |
|
| 417 |
4 |
| sortsv(AvARRAY(order), (STRLEN)(av_len(order) + 1), |
| 418 |
|
| otel_schema_sortcmp); |
| 419 |
7 |
| (void)hv_stores(h, "order", newRV_noinc((SV *)order)); |
| 420 |
7 |
| self = sv_bless(newRV_noinc((SV *)h), gv_stashpv(cls, GV_ADD)); |
| 421 |
|
| } |
| 422 |
7 |
| RETVAL = self; |
| 423 |
|
| } |
| 424 |
|
| OUTPUT: |
| 425 |
|
| RETVAL |
| 426 |
|
| |
| 427 |
|
| # for_url($class, $url, %opt): load by schema URL, or undef when nothing local |
| 428 |
|
| # describes it - an ordinary answer, not a failure. |
| 429 |
|
| SV * |
| 430 |
|
| for_url(class, url, ...) |
| 431 |
|
| SV *class |
| 432 |
|
| SV *url |
| 433 |
|
| CODE: |
| 434 |
|
| { |
| 435 |
3 |
| SV *v = otel_schema_url_version(aTHX_ url); |
| 436 |
3 |
▶ | SV *f = v ? otel_schema_file_for(aTHX_ v, &ST(2), items - 2) : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| SV *f = v ? otel_schema_file_for(aTHX_ v, &ST(2), items - 2) : NULL; |
3 |
0 |
3 |
|
| 437 |
3 |
▶ | if (!f) XSRETURN_UNDEF; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!f) XSRETURN_UNDEF; |
1 |
2 |
3 |
|
| 438 |
|
| { |
| 439 |
2 |
| dSP; int count; SV *obj = NULL; |
| 440 |
2 |
| ENTER; SAVETMPS; |
| 441 |
2 |
▶ | PUSHMARK(SP); EXTEND(SP, 3); |
Branch: 2 branches
| Branch | True | False | Total |
| PUSHMARK(SP); EXTEND(SP, 3); |
0 |
2 |
2 |
| PUSHMARK(SP); EXTEND(SP, 3); |
0 |
2 |
2 |
|
| 442 |
2 |
| PUSHs(class); |
| 443 |
2 |
| PUSHs(sv_2mortal(newSVpvs("path"))); |
| 444 |
2 |
| PUSHs(f); |
| 445 |
2 |
| PUTBACK; |
| 446 |
2 |
| count = call_pv("Punk::OpenTelemetry::Schema::load", G_SCALAR); |
| 447 |
2 |
| SPAGAIN; |
| 448 |
2 |
▶ | if (count > 0) obj = SvREFCNT_inc(POPs); |
Branch: 1 branch
| Branch | True | False | Total |
| if (count > 0) obj = SvREFCNT_inc(POPs); |
2 |
0 |
2 |
|
| 449 |
2 |
▶ | PUTBACK; FREETMPS; LEAVE; |
Branch: 1 branch
| Branch | True | False | Total |
| PUTBACK; FREETMPS; LEAVE; |
2 |
0 |
2 |
|
| 450 |
2 |
▶ | if (obj) RETVAL = obj; |
Branch: 1 branch
| Branch | True | False | Total |
| if (obj) RETVAL = obj; |
2 |
0 |
2 |
|
| 451 |
|
| } |
| 452 |
|
| } |
| 453 |
|
| OUTPUT: |
| 454 |
|
| RETVAL |
| 455 |
|
| |
| 456 |
|
| # ---- the loaded object ---------------------------------------------------- |
| 457 |
|
| |
| 458 |
|
| SV * |
| 459 |
|
| schema_url(self) |
| 460 |
|
| SV *self |
| 461 |
|
| CODE: |
| 462 |
|
| { |
| 463 |
3 |
| HV *h = otel_hv_of(aTHX_ self); |
| 464 |
3 |
▶ | SV *u = h ? otel_h(aTHX_ h, "schema_url") : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| SV *u = h ? otel_h(aTHX_ h, "schema_url") : NULL; |
3 |
0 |
3 |
|
| 465 |
3 |
▶ | if (!u) XSRETURN_UNDEF; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!u) XSRETURN_UNDEF; |
0 |
3 |
3 |
|
| 466 |
3 |
| RETVAL = newSVsv(u); |
| 467 |
|
| } |
| 468 |
|
| OUTPUT: |
| 469 |
|
| RETVAL |
| 470 |
|
| |
| 471 |
|
| void |
| 472 |
|
| versions(self) |
| 473 |
|
| SV *self |
| 474 |
|
| PPCODE: |
| 475 |
|
| { |
| 476 |
4 |
| HV *h = otel_hv_of(aTHX_ self); |
| 477 |
4 |
▶ | AV *order = h ? otel_h_av(aTHX_ h, "order") : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| AV *order = h ? otel_h_av(aTHX_ h, "order") : NULL; |
4 |
0 |
4 |
|
| 478 |
4 |
▶ | SSize_t i, n = order ? av_len(order) + 1 : 0; |
Branch: 1 branch
| Branch | True | False | Total |
| SSize_t i, n = order ? av_len(order) + 1 : 0; |
4 |
0 |
4 |
|
| 479 |
|
| /* This was `@{ $_[0]{order} }`, and an array in scalar context is its |
| 480 |
|
| * COUNT. A list-returning XSUB in scalar context yields its LAST |
| 481 |
|
| * value instead, so scalar($s->versions) would quietly become a |
| 482 |
|
| * version string - true-ish, wrong, and only visible to something |
| 483 |
|
| * that compared it. */ |
| 484 |
4 |
▶ | if (GIMME_V == G_SCALAR) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (GIMME_V == G_SCALAR) { |
1 |
3 |
4 |
|
| 485 |
1 |
▶ | EXTEND(SP, 1); |
Branch: 1 branch
| Branch | True | False | Total |
| EXTEND(SP, 1); |
0 |
1 |
1 |
|
| 486 |
1 |
| mPUSHi((IV)n); |
| 487 |
1 |
| XSRETURN(1); |
| 488 |
|
| } |
| 489 |
3 |
▶ | EXTEND(SP, n); |
Branch: 2 branches
| Branch | True | False | Total |
| EXTEND(SP, n); |
3 |
0 |
3 |
| EXTEND(SP, n); |
0 |
3 |
3 |
|
| 490 |
37 |
▶ | for (i = 0; i < n; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < n; i++) { |
34 |
3 |
37 |
|
| 491 |
34 |
| SV **e = av_fetch(order, i, 0); |
| 492 |
34 |
▶ | PUSHs(sv_2mortal(newSVsv((e && *e) ? *e : &PL_sv_undef))); |
Branch: 2 branches
| Branch | True | False | Total |
| PUSHs(sv_2mortal(newSVsv((e && *e) ? *e : &PL_sv_undef))); |
34 |
0 |
34 |
| PUSHs(sv_2mortal(newSVsv((e && *e) ? *e : &PL_sv_undef))); |
34 |
0 |
34 |
|
| 493 |
|
| } |
| 494 |
|
| } |
| 495 |
|
| |
| 496 |
|
| IV |
| 497 |
|
| knows(self, v) |
| 498 |
|
| SV *self |
| 499 |
|
| SV *v |
| 500 |
|
| CODE: |
| 501 |
|
| { |
| 502 |
2 |
| HV *h = otel_hv_of(aTHX_ self); |
| 503 |
2 |
▶ | HV *versions = h ? otel_h_hv(aTHX_ h, "versions") : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| HV *versions = h ? otel_h_hv(aTHX_ h, "versions") : NULL; |
2 |
0 |
2 |
|
| 504 |
2 |
▶ | RETVAL = (versions && SvOK(v) && hv_exists_ent(versions, v, 0)) ? 1 : 0; |
Branch: 4 branches
| Branch | True | False | Total |
| RETVAL = (versions && SvOK(v) && hv_exists_ent(versions, v, 0)) ? 1 : 0; |
2 |
0 |
2 |
| RETVAL = (versions && SvOK(v) && hv_exists_ent(versions, v, 0)) ? 1 : 0; |
2 |
0 |
2 |
| RETVAL = (versions && SvOK(v) && hv_exists_ent(versions, v, 0)) ? 1 : 0; |
1 |
1 |
2 |
| RETVAL = (versions && SvOK(v) && hv_exists_ent(versions, v, 0)) ? 1 : 0; |
0 |
2 |
2 |
|
| 505 |
|
| } |
| 506 |
|
| OUTPUT: |
| 507 |
|
| RETVAL |