xs/set.xs

filter: Statementstmt 90.6% 165 / 182 Branchbran 71.0% 98 / 138 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 82.1% 263 / 320 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« include/tkr/tkr_describe.h ↑ Summary xs/walk.xs »
1 # Sets: rules with dates added and removed; iCalendar text in and out; the
2 # frozen forms of a rule and a set.
3  
4 MODULE = Time::Keeper::Recurrence PACKAGE = Time::Keeper::Recurrence
5  
6 SV *
7 with(self, ...)
8 SV *self
9 PREINIT:
10 1036 const char *what = "Time::Keeper::Recurrence->with";
11 tkr_set_parts p;
12 CODE:
13 1036 tkr_parts_from_rule(aTHX_ &p, tkr_rule_of(aTHX_ self, what), what);
14 1035 tkr_with_args(aTHX_ &p, &ST(1), items - 1, what);
15 1029 RETVAL = tkr_set_new_sv(aTHX_ tkr_set_stash(aTHX), &p, what);
16 OUTPUT:
17 RETVAL
18  
19 SV *
20 ical(self)
21 SV *self
22 PREINIT:
23 49 const char *what = "Time::Keeper::Recurrence->ical";
24 tkr_set_parts p;
25 SV *set;
26 CODE:
27 49 tkr_parts_from_rule(aTHX_ &p, tkr_rule_of(aTHX_ self, what), what);
28 48 set = sv_2mortal(tkr_set_new_sv(aTHX_ tkr_set_stash(aTHX), &p, what));
29 48 RETVAL = newSVpvs("");
30 48 tkr_ical_write(aTHX_ tkr_set_of(aTHX_ set, what), RETVAL, 0, what);
31 OUTPUT:
32 RETVAL
33  
34 SV *
35 parse_ical(class, text)
36 SV *class
37 SV *text
38 PREINIT:
39 141 const char *what = "Time::Keeper::Recurrence->parse_ical";
40 tkr_set_parts p;
41 STRLEN len;
42 const char *s;
43 HV *stash;
44 CODE:
45 141 s = SvPV(text, len);
46 141 tkr_ical_parse(aTHX_ s, len, &p, what);
47 PERL_UNUSED_VAR(class);
48 126 RETVAL = tkr_set_new_sv(aTHX_ tkr_set_stash(aTHX), &p, what);
49 OUTPUT:
50 RETVAL
51  
52 void
53 STORABLE_freeze(self, cloning)
54 SV *self
55 SV *cloning
56 ALIAS:
57 FREEZE = 1
58 PREINIT:
59 const tkr_rule *r;
60 PPCODE:
61 PERL_UNUSED_VAR(cloning);
62 20 ▶ r = tkr_rule_of(aTHX_ self, ix ? "Time::Keeper::Recurrence->FREEZE" : "Time::Keeper::Recurrence->STORABLE_freeze");
Branch: 1 branch
BranchTrueFalseTotal
r = tkr_rule_of(aTHX_ self, ix ? "Time::Keeper::Recurrence->FREEZE" : "Time::Keeper::Recurrence->STORABLE_freeze"); 6 14 20
63 20 ▶ XPUSHs(sv_2mortal(tkr_rule_freeze_sv(aTHX_ r, ix ? "Time::Keeper::Recurrence->FREEZE" : "Time::Keeper::Recurrence->STORABLE_freeze")));
Branch: 2 branches
BranchTrueFalseTotal
XPUSHs(sv_2mortal(tkr_rule_freeze_sv(aTHX_ r, ix ? "Time::Keeper::Recurrence->FREEZE" : "Time::Keeper::Recurrence->STORABLE_freeze"))); 0 20 20
XPUSHs(sv_2mortal(tkr_rule_freeze_sv(aTHX_ r, ix ? "Time::Keeper::Recurrence->FREEZE" : "Time::Keeper::Recurrence->STORABLE_freeze"))); 6 14 20
64  
65 void
66 STORABLE_thaw(self, cloning, frozen)
67 SV *self
68 SV *cloning
69 SV *frozen
70 PREINIT:
71 14 const char *what = "Time::Keeper::Recurrence->STORABLE_thaw";
72 tkr_rule r;
73 PPCODE:
74 PERL_UNUSED_VAR(cloning);
75 14 tkr_rule_thaw(aTHX_ frozen, &r, what);
76 14 ▶ if (!SvROK(self))
Branch: 1 branch
BranchTrueFalseTotal
if (!SvROK(self)) 0 14 14
77 0 croak("%s: not a reference", what);
78 14 sv_setpvn(SvRV(self), (const char *)&r, sizeof r);
79 14 XSRETURN_EMPTY;
80  
81 SV *
82 THAW(class, serialiser, frozen)
83 SV *class
84 SV *serialiser
85 SV *frozen
86 PREINIT:
87 tkr_rule r;
88 CODE:
89 PERL_UNUSED_VAR(serialiser);
90 13 tkr_rule_thaw(aTHX_ frozen, &r, "Time::Keeper::Recurrence->THAW");
91 4 RETVAL = tkr_rule_new_sv(aTHX_ tkr_stash_for(aTHX_ class), &r);
92 OUTPUT:
93 RETVAL
94  
95 SV *
96 TO_JSON(self)
97 SV *self
98 PREINIT:
99 3 const char *what = "Time::Keeper::Recurrence->TO_JSON";
100 const tkr_rule *r;
101 char err[TKR_ERR];
102 CODE:
103 3 r = tkr_rule_of(aTHX_ self, what);
104 3 RETVAL = newSVpvs("");
105 3 ▶ if (r->flags & TKR_F_CRON) {
Branch: 1 branch
BranchTrueFalseTotal
if (r->flags & TKR_F_CRON) { 1 2 3
106 1 ▶ if (!tkr_cron_write(aTHX_ r, RETVAL, err))
Branch: 1 branch
BranchTrueFalseTotal
if (!tkr_cron_write(aTHX_ r, RETVAL, err)) 0 1 1
107 0 croak("%s: %s", what, err);
108 }
109 else
110 2 tkr_rrule_write(aTHX_ r, RETVAL);
111 OUTPUT:
112 RETVAL
113  
114 MODULE = Time::Keeper::Recurrence PACKAGE = Time::Keeper::Recurrence::Set
115  
116 SV *
117 with(self, ...)
118 SV *self
119 PREINIT:
120 299 const char *what = "Time::Keeper::Recurrence::Set->with";
121 tkr_set_parts p;
122 CODE:
123 299 tkr_parts_from_set(aTHX_ &p, tkr_set_of(aTHX_ self, what), what);
124 299 tkr_with_args(aTHX_ &p, &ST(1), items - 1, what);
125 298 RETVAL = tkr_set_new_sv(aTHX_ SvSTASH(SvRV(self)), &p, what);
126 OUTPUT:
127 RETVAL
128  
129 SV *
130 ical(self)
131 SV *self
132 PREINIT:
133 214 const char *what = "Time::Keeper::Recurrence::Set->ical";
134 CODE:
135 214 RETVAL = newSVpvs("");
136 214 tkr_ical_write(aTHX_ tkr_set_of(aTHX_ self, what), RETVAL, 0, what);
137 OUTPUT:
138 RETVAL
139  
140 SV *
141 parse_ical(class, text)
142 SV *class
143 SV *text
144 PREINIT:
145 1 const char *what = "Time::Keeper::Recurrence::Set->parse_ical";
146 tkr_set_parts p;
147 STRLEN len;
148 const char *s;
149 HV *stash;
150 CODE:
151 1 s = SvPV(text, len);
152 1 tkr_ical_parse(aTHX_ s, len, &p, what);
153 1 ▶ stash = SvROK(class) ? SvSTASH(SvRV(class)) : SvPOK(class) ? gv_stashsv(class, 0) : NULL;
Branch: 2 branches
BranchTrueFalseTotal
stash = SvROK(class) ? SvSTASH(SvRV(class)) : SvPOK(class) ? gv_stashsv(class, 0) : NULL; 0 1 1
stash = SvROK(class) ? SvSTASH(SvRV(class)) : SvPOK(class) ? gv_stashsv(class, 0) : NULL; 1 0 1
154 1 ▶ RETVAL = tkr_set_new_sv(aTHX_ stash ? stash : tkr_set_stash(aTHX), &p, what);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = tkr_set_new_sv(aTHX_ stash ? stash : tkr_set_stash(aTHX), &p, what); 0 1 1
155 OUTPUT:
156 RETVAL
157  
158 SV *
159 next(self, ...)
160 SV *self
161 ALIAS:
162 previous = 1
163 PREINIT:
164 static const char *const whats[] = { "Time::Keeper::Recurrence::Set->next", "Time::Keeper::Recurrence::Set->previous" };
165 const tkr_set *s;
166 tkr_setiter it;
167 40007 int64_t from, got, detail = 0;
168 int rc;
169 CODE:
170 40007 s = tkr_set_of(aTHX_ self, whats[ix]);
171 40007 ▶ from = items > 1 ? tkr_instant_arg(aTHX_ ST(1), whats[ix]) : tkr_now_sec(aTHX);
Branch: 1 branch
BranchTrueFalseTotal
from = items > 1 ? tkr_instant_arg(aTHX_ ST(1), whats[ix]) : tkr_now_sec(aTHX); 40007 0 40007
172 40007 ▶ if (ix)
Branch: 1 branch
BranchTrueFalseTotal
if (ix) 20003 20004 40007
173 20003 rc = tkr_set_previous(aTHX_ self, from, &got, &detail);
174 else {
175 20004 rc = tkr_setiter_init(aTHX_ &it, self, from, 0, 0);
176 20004 ▶ if (rc == TKR_W_GOT)
Branch: 1 branch
BranchTrueFalseTotal
if (rc == TKR_W_GOT) 20004 0 20004
177 20004 rc = tkr_setiter_next(aTHX_ &it, &got);
178 20004 detail = it.fail_wall;
179 20004 tkr_setiter_free(aTHX_ &it);
180 }
181 40007 tkr_set_rc_croak(aTHX_ rc, s, detail, whats[ix]);
182 40007 ▶ RETVAL = rc == TKR_W_GOT ? tkr_set_value_sv(aTHX_ s, got, whats[ix]) : &PL_sv_undef;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = rc == TKR_W_GOT ? tkr_set_value_sv(aTHX_ s, got, whats[ix]) : &PL_sv_undef; 40007 0 40007
183 OUTPUT:
184 RETVAL
185  
186 void
187 between(self, a, b)
188 SV *self
189 SV *a
190 SV *b
191 PREINIT:
192 1007 const char *what = "Time::Keeper::Recurrence::Set->between";
193 const tkr_set *s;
194 tkr_setiter it;
195 1007 int64_t from, to, got, n = 0, i;
196 SV *held;
197 int rc;
198 PPCODE:
199 1007 s = tkr_set_of(aTHX_ self, what);
200 1007 from = tkr_instant_arg(aTHX_ a, what);
201 1007 to = tkr_instant_arg(aTHX_ b, what);
202 1007 held = sv_2mortal(newSV(64 * sizeof(int64_t)));
203 1007 rc = tkr_setiter_init(aTHX_ &it, self, from, 1, 0);
204 1007 ▶ if (rc == TKR_W_GOT)
Branch: 1 branch
BranchTrueFalseTotal
if (rc == TKR_W_GOT) 1007 0 1007
205 19455671 ▶ while ((rc = tkr_setiter_next(aTHX_ &it, &got)) == TKR_W_GOT) {
Branch: 1 branch
BranchTrueFalseTotal
while ((rc = tkr_setiter_next(aTHX_ &it, &got)) == TKR_W_GOT) { 19455671 0 19455671
206 19455671 ▶ if (got >= to)
Branch: 1 branch
BranchTrueFalseTotal
if (got >= to) 1006 19454665 19455671
207 1006 break;
208 19454665 ▶ if (n >= TKR_BETWEEN_MAX) {
Branch: 1 branch
BranchTrueFalseTotal
if (n >= TKR_BETWEEN_MAX) { 1 19454664 19454665
209 1 tkr_setiter_free(aTHX_ &it);
210 1 croak("%s: more than %d occurrences; use iterate", what, TKR_BETWEEN_MAX);
211 }
212 19454664 ▶ if ((STRLEN)(n + 1) * sizeof(int64_t) > SvLEN(held))
Branch: 1 branch
BranchTrueFalseTotal
if ((STRLEN)(n + 1) * sizeof(int64_t) > SvLEN(held)) 6928 19447736 19454664
213 6928 ▶ SvGROW(held, SvLEN(held) * 2);
Branch: 2 branches
BranchTrueFalseTotal
SvGROW(held, SvLEN(held) * 2); 6928 0 6928
SvGROW(held, SvLEN(held) * 2); 6928 0 6928
214 19454664 ((int64_t *)SvPVX(held))[n++] = got;
215 }
216 1006 ▶ if (rc < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (rc < 0) { 0 1006 1006
217 0 int64_t detail = it.fail_wall;
218 0 tkr_setiter_free(aTHX_ &it);
219 0 tkr_set_rc_croak(aTHX_ rc, s, detail, what);
220 }
221 1006 tkr_setiter_free(aTHX_ &it);
222 1006 ▶ EXTEND(SP, n);
Branch: 2 branches
BranchTrueFalseTotal
EXTEND(SP, n); 1006 0 1006
EXTEND(SP, n); 2 1004 1006
223 9455670 ▶ for (i = 0; i < n; i++)
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < n; i++) 9454664 1006 9455670
224 9454664 PUSHs(sv_2mortal(tkr_set_value_sv(aTHX_ s, ((int64_t *)SvPVX(held))[i], what)));
225  
226 void
227 first(self, n)
228 SV *self
229 IV n
230 PREINIT:
231 1070 const char *what = "Time::Keeper::Recurrence::Set->first";
232 const tkr_set *s;
233 tkr_setiter it;
234 int64_t got, from;
235 int rc;
236 1070 IV i = 0;
237 PPCODE:
238 1070 s = tkr_set_of(aTHX_ self, what);
239 1070 ▶ if (n < 1 || n > TKR_BETWEEN_MAX)
Branch: 2 branches
BranchTrueFalseTotal
if (n < 1 || n > TKR_BETWEEN_MAX) 1070 0 1070
if (n < 1 || n > TKR_BETWEEN_MAX) 0 1070 1070
240 0 croak("%s: how many? %" IVdf " is not 1 to %d", what, n, TKR_BETWEEN_MAX);
241 1070 ▶ from = s->has_start ? s->start.sec : tkr_now_sec(aTHX);
Branch: 1 branch
BranchTrueFalseTotal
from = s->has_start ? s->start.sec : tkr_now_sec(aTHX); 1070 0 1070
242 1070 rc = tkr_setiter_init(aTHX_ &it, self, from, s->has_start, s->has_start);
243 1070 ▶ if (rc == TKR_W_GOT)
Branch: 1 branch
BranchTrueFalseTotal
if (rc == TKR_W_GOT) 1070 0 1070
244 21536 ▶ while (i < n && (rc = tkr_setiter_next(aTHX_ &it, &got)) == TKR_W_GOT) {
Branch: 2 branches
BranchTrueFalseTotal
while (i < n && (rc = tkr_setiter_next(aTHX_ &it, &got)) == TKR_W_GOT) { 20486 1050 21536
while (i < n && (rc = tkr_setiter_next(aTHX_ &it, &got)) == TKR_W_GOT) { 20466 20 20486
245 20466 ▶ XPUSHs(sv_2mortal(tkr_set_value_sv(aTHX_ s, got, what)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(tkr_set_value_sv(aTHX_ s, got, what))); 0 20466 20466
246 20466 i++;
247 }
248 1070 ▶ if (rc < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (rc < 0) { 0 1070 1070
249 0 int64_t detail = it.fail_wall;
250 0 tkr_setiter_free(aTHX_ &it);
251 0 tkr_set_rc_croak(aTHX_ rc, s, detail, what);
252 }
253 1070 tkr_setiter_free(aTHX_ &it);
254  
255 IV
256 contains(self, t)
257 SV *self
258 SV *t
259 PREINIT:
260 21518 ▶ const char *what = "Time::Keeper::Recurrence::Set->contains";
Branch: 1 branch
BranchTrueFalseTotal
const char *what = "Time::Keeper::Recurrence::Set->contains"; 21518 0 21518
261 const tkr_set *s;
262 time_keeper_instant in;
263 tkr_setiter it;
264 int64_t got;
265 int rc;
266 CODE:
267 21518 s = tkr_set_of(aTHX_ self, what);
268 21518 ▶ if ((tkr_tk(aTHX)->from_sv)(aTHX_ t, &in, NULL, NULL) != TIME_KEEPER_OK)
Branch: 1 branch
BranchTrueFalseTotal
if ((tkr_tk(aTHX)->from_sv)(aTHX_ t, &in, NULL, NULL) != TIME_KEEPER_OK) 0 21518 21518
269 0 croak("%s: a Time::Keeper value is wanted", what);
270 21518 rc = tkr_setiter_init(aTHX_ &it, self, in.sec, 1, 0);
271 21518 ▶ if (rc == TKR_W_GOT)
Branch: 1 branch
BranchTrueFalseTotal
if (rc == TKR_W_GOT) 21518 0 21518
272 21518 rc = tkr_setiter_next(aTHX_ &it, &got);
273 21518 ▶ if (rc < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (rc < 0) { 0 21518 21518
274 0 int64_t detail = it.fail_wall;
275 0 tkr_setiter_free(aTHX_ &it);
276 0 tkr_set_rc_croak(aTHX_ rc, s, detail, what);
277 }
278 21518 tkr_setiter_free(aTHX_ &it);
279 21518 ▶ RETVAL = rc == TKR_W_GOT && got == in.sec && in.nsec == tkr_set_nsec(s);
Branch: 4 branches
BranchTrueFalseTotal
RETVAL = rc == TKR_W_GOT && got == in.sec && in.nsec == tkr_set_nsec(s); 21518 0 21518
RETVAL = rc == TKR_W_GOT && got == in.sec && in.nsec == tkr_set_nsec(s); 20003 1515 21518
RETVAL = rc == TKR_W_GOT && got == in.sec && in.nsec == tkr_set_nsec(s); 20003 0 20003
RETVAL = rc == TKR_W_GOT && got == in.sec && in.nsec == tkr_set_nsec(s); 21510 8 21518
280 OUTPUT:
281 RETVAL
282  
283 void
284 _iterate_step(...)
285 PREINIT:
286 11 const char *what = "Time::Keeper::Recurrence::Set->iterate";
287 tkr_setiter *it;
288 const tkr_set *s;
289 int64_t got;
290 int rc;
291 PPCODE:
292 PERL_UNUSED_VAR(items);
293 11 it = tkr_setiter_of(aTHX_ cv, what);
294 11 s = (const tkr_set *)SvPVX(SvRV(it->set_sv));
295 11 rc = tkr_setiter_next(aTHX_ it, &got);
296 11 tkr_set_rc_croak(aTHX_ rc, s, it->fail_wall, what);
297 11 ▶ if (rc == TKR_W_GOT)
Branch: 1 branch
BranchTrueFalseTotal
if (rc == TKR_W_GOT) 9 2 11
298 9 ▶ XPUSHs(sv_2mortal(tkr_set_value_sv(aTHX_ s, got, what)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(tkr_set_value_sv(aTHX_ s, got, what))); 0 9 9
299 else
300 2 ▶ XPUSHs(&PL_sv_undef);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(&PL_sv_undef); 0 2 2
301  
302 SV *
303 iterate(self, ...)
304 SV *self
305 PREINIT:
306 3 const char *what = "Time::Keeper::Recurrence::Set->iterate";
307 const tkr_set *s;
308 tkr_setiter it;
309 int64_t from;
310 int rc, inclusive, from_start;
311 CV *cv;
312 SV *state;
313 CODE:
314 3 s = tkr_set_of(aTHX_ self, what);
315 3 ▶ if (items > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (items > 1) { 1 2 3
316 1 from = tkr_instant_arg(aTHX_ ST(1), what);
317 1 inclusive = from_start = 0;
318 }
319 else {
320 2 ▶ from = s->has_start ? s->start.sec : tkr_now_sec(aTHX);
Branch: 1 branch
BranchTrueFalseTotal
from = s->has_start ? s->start.sec : tkr_now_sec(aTHX); 2 0 2
321 2 inclusive = from_start = s->has_start;
322 }
323 3 rc = tkr_setiter_init(aTHX_ &it, self, from, inclusive, from_start);
324 3 ▶ if (rc < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (rc < 0) { 0 3 3
325 0 int64_t detail = it.fail_wall;
326 0 tkr_setiter_free(aTHX_ &it);
327 0 tkr_set_rc_croak(aTHX_ rc, s, detail, what);
328 }
329 3 cv = newXS(NULL, XS_Time__Keeper__Recurrence__Set__iterate_step, __FILE__);
330 3 state = newSVpvn((const char *)&it, sizeof it);
331 3 sv_magicext((SV *)cv, state, PERL_MAGIC_ext, &tkr_setiter_vtbl, NULL, 0);
332 3 SvREFCNT_dec(state);
333 3 RETVAL = newRV_noinc((SV *)cv);
334 OUTPUT:
335 RETVAL
336  
337 void
338 rules(self)
339 SV *self
340 ALIAS:
341 exrules = 1
342 PREINIT:
343 const tkr_set *s;
344 unsigned i, from, n;
345 PPCODE:
346 55 ▶ s = tkr_set_of(aTHX_ self, ix ? "Time::Keeper::Recurrence::Set->exrules" : "Time::Keeper::Recurrence::Set->rules");
Branch: 1 branch
BranchTrueFalseTotal
s = tkr_set_of(aTHX_ self, ix ? "Time::Keeper::Recurrence::Set->exrules" : "Time::Keeper::Recurrence::Set->rules"); 2 53 55
347 55 ▶ from = ix ? s->n_rules : 0;
Branch: 1 branch
BranchTrueFalseTotal
from = ix ? s->n_rules : 0; 2 53 55
348 55 ▶ n = ix ? s->n_exrules : s->n_rules;
Branch: 1 branch
BranchTrueFalseTotal
n = ix ? s->n_exrules : s->n_rules; 2 53 55
349 128 ▶ for (i = 0; i < n; i++)
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < n; i++) 73 55 128
350 73 ▶ XPUSHs(sv_2mortal(tkr_rule_new_sv(aTHX_ tkr_rule_stash(aTHX), &tkr_set_rules(s)[from + i])));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(tkr_rule_new_sv(aTHX_ tkr_rule_stash(aTHX), &tkr_set_rules(s)[from + i]))); 0 73 73
351  
352 void
353 rdates(self)
354 SV *self
355 ALIAS:
356 exdates = 1
357 PREINIT:
358 const char *what;
359 const tkr_set *s;
360 const tkr_date *d;
361 unsigned i, n;
362 PPCODE:
363 10 ▶ what = ix ? "Time::Keeper::Recurrence::Set->exdates" : "Time::Keeper::Recurrence::Set->rdates";
Branch: 1 branch
BranchTrueFalseTotal
what = ix ? "Time::Keeper::Recurrence::Set->exdates" : "Time::Keeper::Recurrence::Set->rdates"; 4 6 10
364 10 s = tkr_set_of(aTHX_ self, what);
365 10 ▶ d = ix ? tkr_set_exdates(s) : tkr_set_rdates(s);
Branch: 1 branch
BranchTrueFalseTotal
d = ix ? tkr_set_exdates(s) : tkr_set_rdates(s); 4 6 10
366 10 ▶ n = ix ? s->n_exdates : s->n_rdates;
Branch: 1 branch
BranchTrueFalseTotal
n = ix ? s->n_exdates : s->n_rdates; 4 6 10
367 61 ▶ for (i = 0; i < n; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < n; i++) { 51 10 61
368 SV *v;
369 51 PUTBACK;
370 51 ▶ if (d[i].is_day)
Branch: 1 branch
BranchTrueFalseTotal
if (d[i].is_day) 7 44 51
371 7 ▶ v = tkr_date_sv(aTHX_ tkr_floor_div(ix ? d[i].at : tkr_zone_wall(aTHX_ &s->zone, d[i].at), 86400), s->locale);
Branch: 1 branch
BranchTrueFalseTotal
v = tkr_date_sv(aTHX_ tkr_floor_div(ix ? d[i].at : tkr_zone_wall(aTHX_ &s->zone, d[i].at), 86400), s->locale); 5 2 7
372 else
373 44 v = tkr_set_value_sv(aTHX_ s, d[i].at, what);
374 51 SPAGAIN;
375 51 ▶ XPUSHs(sv_2mortal(v));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(v)); 0 51 51
376 }
377  
378 SV *
379 start(self)
380 SV *self
381 ALIAS:
382 zone = 1
383 gap = 2
384 overlap = 3
385 is_finite = 4
386 PREINIT:
387 static const char *const whats[] = { "Time::Keeper::Recurrence::Set->start", "Time::Keeper::Recurrence::Set->zone",
388 "Time::Keeper::Recurrence::Set->gap", "Time::Keeper::Recurrence::Set->overlap", "Time::Keeper::Recurrence::Set->is_finite" };
389 const tkr_set *s;
390 tkr_rule probe;
391 unsigned i;
392 CODE:
393 116 s = tkr_set_of(aTHX_ self, whats[ix]);
394 116 tkr_rule_init(&probe);
395 116 probe.zone = s->zone;
396 116 switch (ix) {
397 51 case 0:
398 51 ▶ RETVAL = s->has_start ? tkr_set_value_sv(aTHX_ s, s->start.sec, whats[ix]) : &PL_sv_undef;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = s->has_start ? tkr_set_value_sv(aTHX_ s, s->start.sec, whats[ix]) : &PL_sv_undef; 49 2 51
399 51 break;
400 55 case 1: RETVAL = tkr_zone_name_sv(aTHX_ &probe); break;
401 4 case 2: RETVAL = newSVpv(tkr_gap_names[s->gap], 0); break;
402 3 case 3: RETVAL = newSVpv(tkr_overlap_names[s->overlap], 0); break;
403 3 default:
404 3 RETVAL = &PL_sv_yes;
405 6 ▶ for (i = 0; i < s->n_rules; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < s->n_rules; i++) { 3 3 6
406 3 const tkr_rule *r = &tkr_set_rules(s)[i];
407 3 ▶ if ((r->flags & TKR_F_EVERY) || (!r->count && r->until_kind == TKR_UNTIL_NONE))
Branch: 3 branches
BranchTrueFalseTotal
if ((r->flags & TKR_F_EVERY) || (!r->count && r->until_kind == TKR_UNTIL_NONE)) 3 0 3
if ((r->flags & TKR_F_EVERY) || (!r->count && r->until_kind == TKR_UNTIL_NONE)) 2 1 3
if ((r->flags & TKR_F_EVERY) || (!r->count && r->until_kind == TKR_UNTIL_NONE)) 2 0 2
408 2 RETVAL = &PL_sv_no;
409 }
410 }
411 OUTPUT:
412 RETVAL
413  
414 void
415 STORABLE_freeze(self, cloning)
416 SV *self
417 SV *cloning
418 ALIAS:
419 FREEZE = 1
420 PREINIT:
421 const char *what;
422 const tkr_set *s;
423 PPCODE:
424 PERL_UNUSED_VAR(cloning);
425 8 ▶ what = ix ? "Time::Keeper::Recurrence::Set->FREEZE" : "Time::Keeper::Recurrence::Set->STORABLE_freeze";
Branch: 1 branch
BranchTrueFalseTotal
what = ix ? "Time::Keeper::Recurrence::Set->FREEZE" : "Time::Keeper::Recurrence::Set->STORABLE_freeze"; 3 5 8
426 8 s = tkr_set_of(aTHX_ self, what);
427 8 ▶ XPUSHs(sv_2mortal(tkr_set_freeze_sv(aTHX_ s, what)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(tkr_set_freeze_sv(aTHX_ s, what))); 0 8 8
428  
429 void
430 STORABLE_thaw(self, cloning, frozen)
431 SV *self
432 SV *cloning
433 SV *frozen
434 PREINIT:
435 5 const char *what = "Time::Keeper::Recurrence::Set->STORABLE_thaw";
436 tkr_set_parts p;
437 SV *made;
438 PPCODE:
439 PERL_UNUSED_VAR(cloning);
440 5 ▶ if (!SvROK(self))
Branch: 1 branch
BranchTrueFalseTotal
if (!SvROK(self)) 0 5 5
441 0 croak("%s: not a reference", what);
442 5 tkr_set_thaw(aTHX_ frozen, &p, what);
443 5 made = sv_2mortal(tkr_set_new_sv(aTHX_ tkr_set_stash(aTHX), &p, what));
444 5 sv_setsv(SvRV(self), SvRV(made));
445 5 XSRETURN_EMPTY;
446  
447 SV *
448 THAW(class, serialiser, frozen)
449 SV *class
450 SV *serialiser
451 SV *frozen
452 PREINIT:
453 4 const char *what = "Time::Keeper::Recurrence::Set->THAW";
454 tkr_set_parts p;
455 HV *stash;
456 CODE:
457 PERL_UNUSED_VAR(serialiser);
458 4 tkr_set_thaw(aTHX_ frozen, &p, what);
459 3 ▶ stash = SvROK(class) ? SvSTASH(SvRV(class)) : SvPOK(class) ? gv_stashsv(class, 0) : NULL;
Branch: 2 branches
BranchTrueFalseTotal
stash = SvROK(class) ? SvSTASH(SvRV(class)) : SvPOK(class) ? gv_stashsv(class, 0) : NULL; 0 3 3
stash = SvROK(class) ? SvSTASH(SvRV(class)) : SvPOK(class) ? gv_stashsv(class, 0) : NULL; 3 0 3
460 3 ▶ RETVAL = tkr_set_new_sv(aTHX_ stash ? stash : tkr_set_stash(aTHX), &p, what);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = tkr_set_new_sv(aTHX_ stash ? stash : tkr_set_stash(aTHX), &p, what); 0 3 3
461 OUTPUT:
462 RETVAL
463  
464 SV *
465 TO_JSON(self)
466 SV *self
467 PREINIT:
468 2 const char *what = "Time::Keeper::Recurrence::Set->TO_JSON";
469 CODE:
470 2 RETVAL = newSVpvs("");
471 2 tkr_ical_write(aTHX_ tkr_set_of(aTHX_ self, what), RETVAL, 0, what);
472 OUTPUT:
473 RETVAL
« include/tkr/tkr_describe.h ↑ Summary xs/walk.xs »