xs/data.xs

filter: Statementstmt 100% 49 / 49 Branchbran 81.8% 18 / 22 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 94.3% 67 / 71 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« xs/rules.xs ↑ Summary blib/lib/Time/Keeper/Zone.pm »
1 # Doors onto the compiled tables, for the tests only. The engine that
2 # answers questions from them is Phase 04.
3  
4 MODULE = Time::Keeper::Zone PACKAGE = Time::Keeper::Zone
5  
6 SV *
7 _tzdata_version()
8 CODE:
9 1 RETVAL = newSVpvs(TKZ_TZDATA_VERSION);
10 OUTPUT:
11 RETVAL
12  
13 # (zones, links, lookup entries, types, transitions, footers, Windows names)
14 void
15 _counts()
16 PPCODE:
17 1 ▶ EXTEND(SP, 7);
Branch: 1 branch
BranchTrueFalseTotal
EXTEND(SP, 7); 0 1 1
18 1 mPUSHu(TKZ_ZONE_COUNT);
19 1 mPUSHu(TKZ_LINK_COUNT);
20 1 mPUSHu(TKZ_LOOKUP_COUNT);
21 1 mPUSHu(TKZ_TYPE_COUNT);
22 1 mPUSHu(TKZ_TRANS_COUNT);
23 1 mPUSHu(TKZ_FOOTER_COUNT);
24 1 mPUSHu(TKZ_WINDOWS_COUNT);
25  
26 # Every name in lookup order, as (name, canonical zone, is a link) triples.
27 void
28 _lookup_table()
29 PREINIT:
30 int i;
31 PPCODE:
32 1 ▶ EXTEND(SP, TKZ_LOOKUP_COUNT * 3);
Branch: 1 branch
BranchTrueFalseTotal
EXTEND(SP, TKZ_LOOKUP_COUNT * 3); 0 1 1
33 598 ▶ for (i = 0; i < TKZ_LOOKUP_COUNT; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < TKZ_LOOKUP_COUNT; i++) { 597 1 598
34 597 const tkz_lookup_entry *e = &tkz_lookup[i];
35 597 mPUSHp(tkz_names + e->name, strlen(tkz_names + e->name));
36 597 mPUSHp(tkz_names + tkz_zones[e->zone].name, strlen(tkz_names + tkz_zones[e->zone].name));
37 597 mPUSHu(e->is_link);
38 }
39  
40 # (Windows name, zone) pairs.
41 void
42 _windows_table()
43 PREINIT:
44 int i;
45 PPCODE:
46 1 ▶ EXTEND(SP, TKZ_WINDOWS_COUNT * 2);
Branch: 1 branch
BranchTrueFalseTotal
EXTEND(SP, TKZ_WINDOWS_COUNT * 2); 0 1 1
47 140 ▶ for (i = 0; i < TKZ_WINDOWS_COUNT; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < TKZ_WINDOWS_COUNT; i++) { 139 1 140
48 139 const tkz_windows_entry *w = &tkz_windows[i];
49 139 mPUSHp(tkz_windows_names + w->name, strlen(tkz_windows_names + w->name));
50 139 mPUSHp(tkz_names + tkz_zones[w->zone].name, strlen(tkz_names + tkz_zones[w->zone].name));
51 }
52  
53 # One canonical zone, by its exact name, as a hash: its initial type, its
54 # transitions and its footer. undef for a name that is not a zone.
55 SV *
56 _zone_dump(name)
57 const char *name
58 PREINIT:
59 351 int i, z = -1;
60 uint32_t t;
61 HV *hv;
62 AV *trans;
63 const tkz_zone *zone;
64 CODE:
65 61237 ▶ for (i = 0; i < TKZ_ZONE_COUNT; i++)
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < TKZ_ZONE_COUNT; i++) 61235 2 61237
66 61235 ▶ if (strEQ(tkz_names + tkz_zones[i].name, name)) { z = i; break; }
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(tkz_names + tkz_zones[i].name, name)) { z = i; break; } 349 60886 61235
67 351 ▶ if (z < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (z < 0) 2 349 351
68 2 XSRETURN_UNDEF;
69 349 zone = &tkz_zones[z];
70 349 hv = newHV();
71 349 (void)hv_stores(hv, "name", newSVpv(tkz_names + zone->name, 0));
72 349 (void)hv_stores(hv, "initial", tkz_type_av(aTHX_ zone->initial_type));
73 349 trans = newAV();
74 17885 ▶ for (t = 0; t < zone->n_trans; t++) {
Branch: 1 branch
BranchTrueFalseTotal
for (t = 0; t < zone->n_trans; t++) { 17536 349 17885
75 17536 AV *row = (AV *)SvRV(tkz_type_av(aTHX_ tkz_trans_type[zone->first_trans + t]));
76 17536 av_unshift(row, 1);
77 17536 av_store(row, 0, tkz_newSVi64(aTHX_ tkz_trans_at[zone->first_trans + t]));
78 17536 av_push(trans, newRV_noinc((SV *)row));
79 }
80 349 (void)hv_stores(hv, "transitions", newRV_noinc((SV *)trans));
81 349 ▶ if (zone->footer != TKZ_NO_FOOTER) {
Branch: 1 branch
BranchTrueFalseTotal
if (zone->footer != TKZ_NO_FOOTER) { 349 0 349
82 349 const tkz_footer *f = &tkz_footers[zone->footer];
83 349 HV *fh = newHV();
84 349 (void)hv_stores(fh, "text", newSVpv(tkz_footer_text + f->text, 0));
85 349 (void)hv_stores(fh, "std_utoff", newSViv(f->std_utoff));
86 349 (void)hv_stores(fh, "dst_utoff", newSViv(f->dst_utoff));
87 349 (void)hv_stores(fh, "std", tkz_type_av(aTHX_ f->std_type));
88 349 ▶ if (f->dst_type != 0xFFFF) {
Branch: 1 branch
BranchTrueFalseTotal
if (f->dst_type != 0xFFFF) { 108 241 349
89 108 (void)hv_stores(fh, "dst", tkz_type_av(aTHX_ f->dst_type));
90 108 (void)hv_stores(fh, "start", tkz_rule_hv(aTHX_ &f->start));
91 108 (void)hv_stores(fh, "end", tkz_rule_hv(aTHX_ &f->end));
92 }
93 349 (void)hv_stores(hv, "footer", newRV_noinc((SV *)fh));
94 }
95 349 RETVAL = newRV_noinc((SV *)hv);
96 OUTPUT:
97 RETVAL
« xs/rules.xs ↑ Summary blib/lib/Time/Keeper/Zone.pm »