xs/DateRel.xsi

filter: Statementstmt 91.3% 95 / 104 Branchbran 48.0% 150 / 312 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 58.8% 245 / 416 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« xs/private.h ↑ Summary xs/Date.xs »
1 MODE: INLINE
2  
3 #include "private.h"
4  
5 static inline DateRel xs_daterel_ctor (SV* arg, SV* till) {
6 return till ? DateRel(sv2date(arg), sv2date(till)) : sv2daterel(arg);
7 }
8  
9 static inline DateRel xs_daterel_ymd (SV** args, I32 items) {
10 ptime_t vals[8] = {0, 0, 0, 0, 0, 0, 0, 0};
11 list2vals(args, items, vals);
12 return DateRel(vals[0], vals[1], vals[2], vals[3], vals[4], vals[5]);
13 }
14  
15 MODULE = Date PACKAGE = Date
16 PROTOTYPES: DISABLE
17  
18 BOOT {
19 48 ▶ Stash stash("Date::Rel", GV_ADD);
Branch: 1 branch
BranchTrueFalseTotal
Stash stash("Date::Rel", GV_ADD); 48 0 48
20
21 432 ▶ xs::exp::create_constants(stash, {
Branch: 4 branches
BranchTrueFalseTotal
xs::exp::create_constants(stash, { 48 0 48
xs::exp::create_constants(stash, { 48 0 48
xs::exp::create_constants(stash, { 384 48 432
xs::exp::create_constants(stash, { 0 0 0
22 {"FORMAT_SIMPLE", (int)DateRel::Format::simple},
23 {"FORMAT_ISO8601D", (int)DateRel::Format::iso8601d},
24 {"FORMAT_ISO8601I", (int)DateRel::Format::iso8601i},
25
26 {"INPUT_FORMAT_ALL", DateRel::InputFormat::all},
27 {"INPUT_FORMAT_SIMPLE", DateRel::InputFormat::simple},
28 {"INPUT_FORMAT_ISO8601", DateRel::InputFormat::iso8601},
29 {"INPUT_FORMAT_ISO8601D", DateRel::InputFormat::iso8601d},
30 {"INPUT_FORMAT_ISO8601I", DateRel::InputFormat::iso8601i},
31 });
32 48 }
33  
34 #///////////////////////////// STATIC FUNCTIONS ///////////////////////////////////
35  
36 DateRel* rdate (SV* from = {}, SV* till = {}) {
37 36 RETVAL = new DateRel(xs_daterel_ctor(from, till));
38 36 ▶}
Branch: 4 branches
BranchTrueFalseTotal
} 36 0 36
} 35 1 36
} 35 0 35
} 1 0 1
39  
40 DateRel* rdate_ymd (...) {
41 4 RETVAL = new DateRel(xs_daterel_ymd(&ST(0), items));
42 4 ▶}
Branch: 4 branches
BranchTrueFalseTotal
} 4 0 4
} 4 0 4
} 4 0 4
} 0 0 0
43  
44 const DateRel* rdate_const (SV* from = {}, SV* till = {}) {
45 337 RETVAL = new DateRel(xs_daterel_ctor(from, till));
46 337 ▶}
Branch: 4 branches
BranchTrueFalseTotal
} 337 0 337
} 337 0 337
} 337 0 337
} 0 0 0
47  
48 const DateRel* rdate_ymd_const (...) {
49 0 RETVAL = new DateRel(xs_daterel_ymd(&ST(0), items));
50 0 ▶}
Branch: 4 branches
BranchTrueFalseTotal
} 0 0 0
} 0 0 0
} 0 0 0
} 0 0 0
51  
52 #///////////////////////////// OBJECT METHODS ///////////////////////////////////
53 MODULE = Date PACKAGE = Date::Rel
54 PROTOTYPES: DISABLE
55  
56 DateRel* new (SV*, SV* from = {}, SV* till = {}) {
57 25 RETVAL = new DateRel(xs_daterel_ctor(from, till));
58 25 ▶}
Branch: 4 branches
BranchTrueFalseTotal
} 25 0 25
} 24 1 25
} 24 0 24
} 1 0 1
59  
60 DateRel* new_ymd (...) {
61 4 RETVAL = new DateRel(xs_daterel_ymd(&ST(1), items - 1));
62 4 ▶}
Branch: 4 branches
BranchTrueFalseTotal
} 4 0 4
} 4 0 4
} 4 0 4
} 0 0 0
63  
64 void DateRel::set (SV* from, SV* till = {}) {
65 4 ▶ *THIS = xs_daterel_ctor(from, till);
Branch: 2 branches
BranchTrueFalseTotal
*THIS = xs_daterel_ctor(from, till); 3 1 4
*THIS = xs_daterel_ctor(from, till); 3 0 3
66 }
67  
68 void DateRel::set_ymd (...) {
69 2 ▶ *THIS = xs_daterel_ymd(&ST(1), items - 1);
Branch: 2 branches
BranchTrueFalseTotal
*THIS = xs_daterel_ymd(&ST(1), items - 1); 2 0 2
*THIS = xs_daterel_ymd(&ST(1), items - 1); 2 0 2
70 }
71  
72 1 std::error_code DateRel::error ()
73 1  
74 ptime_t DateRel::sec (SV* newval = NULL) {
75 13 if (newval) {
76 13 ▶ THIS->sec(xs::in<ptime_t>(newval));
Branch: 1 branch
BranchTrueFalseTotal
THIS->sec(xs::in<ptime_t>(newval)); 0 13 13
77 0 ▶ }
Branch: 1 branch
BranchTrueFalseTotal
} 0 0 0
78 RETVAL = THIS->sec();
79 13 ▶}
Branch: 1 branch
BranchTrueFalseTotal
} 13 0 13
80  
81 ptime_t DateRel::min (SV* newval = NULL) {
82 13 if (newval) THIS->min(xs::in<ptime_t>(newval));
83 13 ▶ RETVAL = THIS->min();
Branch: 2 branches
BranchTrueFalseTotal
RETVAL = THIS->min(); 0 13 13
RETVAL = THIS->min(); 0 0 0
84 13 ▶}
Branch: 1 branch
BranchTrueFalseTotal
} 13 0 13
85  
86 ptime_t DateRel::hour (SV* newval = NULL) {
87 13 if (newval) {
88 13 ▶ THIS->hour(xs::in<ptime_t>(newval));
Branch: 1 branch
BranchTrueFalseTotal
THIS->hour(xs::in<ptime_t>(newval)); 0 13 13
89 0 ▶ }
Branch: 1 branch
BranchTrueFalseTotal
} 0 0 0
90 RETVAL = THIS->hour();
91 13 ▶}
Branch: 1 branch
BranchTrueFalseTotal
} 13 0 13
92  
93 ptime_t DateRel::day (SV* newval = NULL) {
94 10 if (newval) {
95 10 ▶ THIS->day(xs::in<ptime_t>(newval));
Branch: 1 branch
BranchTrueFalseTotal
THIS->day(xs::in<ptime_t>(newval)); 0 10 10
96 0 ▶ }
Branch: 1 branch
BranchTrueFalseTotal
} 0 0 0
97 RETVAL = THIS->day();
98 10 ▶}
Branch: 1 branch
BranchTrueFalseTotal
} 10 0 10
99  
100 ptime_t DateRel::month (SV* newval = NULL) {
101 11 if (newval) {
102 11 ▶ THIS->month(xs::in<ptime_t>(newval));
Branch: 1 branch
BranchTrueFalseTotal
THIS->month(xs::in<ptime_t>(newval)); 0 11 11
103 0 ▶ }
Branch: 1 branch
BranchTrueFalseTotal
} 0 0 0
104 RETVAL = THIS->month();
105 11 ▶}
Branch: 1 branch
BranchTrueFalseTotal
} 11 0 11
106  
107 ptime_t DateRel::year (SV* newval = NULL) {
108 12 if (newval) {
109 12 ▶ THIS->year(xs::in<ptime_t>(newval));
Branch: 1 branch
BranchTrueFalseTotal
THIS->year(xs::in<ptime_t>(newval)); 1 11 12
110 1 ▶ }
Branch: 1 branch
BranchTrueFalseTotal
} 1 0 1
111 RETVAL = THIS->year();
112 12 ▶}
Branch: 1 branch
BranchTrueFalseTotal
} 12 0 12
113  
114 Date* DateRel::from (SV* fromSV = NULL) {
115 6 if (fromSV) {
116 6 ▶ THIS->from(sv2date(fromSV));
Branch: 1 branch
BranchTrueFalseTotal
THIS->from(sv2date(fromSV)); 2 4 6
117 2 ▶ XSRETURN_UNDEF;
Branch: 2 branches
BranchTrueFalseTotal
XSRETURN_UNDEF; 2 0 2
XSRETURN_UNDEF; 2 0 2
118 2 }
119 if (!THIS->from()) XSRETURN_UNDEF;
120 4 ▶ RETVAL = new Date(*(THIS->from()));
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = new Date(*(THIS->from())); 0 4 4
121 4 ▶}
Branch: 4 branches
BranchTrueFalseTotal
} 4 0 4
} 4 0 4
} 4 0 4
} 0 0 0
122  
123 Date* DateRel::till () : const {
124 2 auto till = THIS->till();
125 2 ▶ if (!till) XSRETURN_UNDEF;
Branch: 1 branch
BranchTrueFalseTotal
if (!till) XSRETURN_UNDEF; 2 0 2
126 2 ▶ RETVAL = new Date(*till);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = new Date(*till); 0 2 2
127 2 ▶}
Branch: 4 branches
BranchTrueFalseTotal
} 2 0 2
} 2 0 2
} 2 0 2
} 0 0 0
128  
129 ptime_t DateRel::to_secs () : ALIAS(duration=1) const {
130 21 PERL_UNUSED_VAR(ix);
131 RETVAL = THIS->to_secs();
132 21 ▶}
Branch: 2 branches
BranchTrueFalseTotal
} 21 0 21
} 21 0 21
133  
134 4 ▶double DateRel::to_mins () : const
Branch: 1 branch
BranchTrueFalseTotal
double DateRel::to_mins () : const 0 4 4
135  
136 2 ▶double DateRel::to_hours () : const
Branch: 1 branch
BranchTrueFalseTotal
double DateRel::to_hours () : const 0 2 2
137  
138 2 ▶double DateRel::to_days () : const
Branch: 1 branch
BranchTrueFalseTotal
double DateRel::to_days () : const 0 2 2
139  
140 2 ▶double DateRel::to_months () : const
Branch: 1 branch
BranchTrueFalseTotal
double DateRel::to_months () : const 0 2 2
141  
142 2 ▶double DateRel::to_years () : const
Branch: 1 branch
BranchTrueFalseTotal
double DateRel::to_years () : const 0 2 2
143  
144 string DateRel::to_string (int format = (int)DateRel::Format::simple) : const {
145 53 ▶ RETVAL = THIS->to_string((DateRel::Format)format);
Branch: 2 branches
BranchTrueFalseTotal
RETVAL = THIS->to_string((DateRel::Format)format); 53 0 53
RETVAL = THIS->to_string((DateRel::Format)format); 53 0 53
146 }
147  
148 string DateRel::_op_str (...) : const {
149 5 ▶ RETVAL = THIS->to_string();
Branch: 2 branches
BranchTrueFalseTotal
RETVAL = THIS->to_string(); 5 0 5
RETVAL = THIS->to_string(); 5 0 5
150 }
151  
152 bool DateRel::to_bool (...) : const {
153 0 ▶ RETVAL = THIS->duration();
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = THIS->duration(); 0 0 0
154 }
155  
156 ptime_t DateRel::to_number (...) : const {
157 3 RETVAL = THIS->duration();
158 3 ▶}
Branch: 2 branches
BranchTrueFalseTotal
} 3 0 3
} 3 0 3
159  
160 Sv DateRel::sum (Sv arg, ...) : const {
161 20 ▶ if (arg.is_object_ref()) {
Branch: 1 branch
BranchTrueFalseTotal
if (arg.is_object_ref()) { 14 6 20
162 14 ▶ Stash s = Object(arg).stash();
Branch: 2 branches
BranchTrueFalseTotal
Stash s = Object(arg).stash(); 14 0 14
Stash s = Object(arg).stash(); 14 0 14
163 14 ▶ if (s.name() == "Date") RETVAL = xs::out(new Date(*xs::in<Date*>(arg) + *THIS));
Branch: 8 branches
BranchTrueFalseTotal
if (s.name() == "Date") RETVAL = xs::out(new Date(*xs::in<Date*>(arg) + *THIS)); 14 0 14
if (s.name() == "Date") RETVAL = xs::out(new Date(*xs::in<Date*>(arg) + *THIS)); 14 0 14
if (s.name() == "Date") RETVAL = xs::out(new Date(*xs::in<Date*>(arg) + *THIS)); 1 13 14
if (s.name() == "Date") RETVAL = xs::out(new Date(*xs::in<Date*>(arg) + *THIS)); 1 0 1
if (s.name() == "Date") RETVAL = xs::out(new Date(*xs::in<Date*>(arg) + *THIS)); 1 0 1
if (s.name() == "Date") RETVAL = xs::out(new Date(*xs::in<Date*>(arg) + *THIS)); 1 0 1
if (s.name() == "Date") RETVAL = xs::out(new Date(*xs::in<Date*>(arg) + *THIS)); 1 0 1
if (s.name() == "Date") RETVAL = xs::out(new Date(*xs::in<Date*>(arg) + *THIS)); 0 0 0
164 13 ▶ else RETVAL = xs::out(new DateRel(*THIS + *xs::in<const DateRel*>(arg)), Object(ST(0)).stash());
Branch: 7 branches
BranchTrueFalseTotal
else RETVAL = xs::out(new DateRel(*THIS + *xs::in<const DateRel*>(arg)), Object(ST(0)).stash()); 13 0 13
else RETVAL = xs::out(new DateRel(*THIS + *xs::in<const DateRel*>(arg)), Object(ST(0)).stash()); 13 0 13
else RETVAL = xs::out(new DateRel(*THIS + *xs::in<const DateRel*>(arg)), Object(ST(0)).stash()); 13 0 13
else RETVAL = xs::out(new DateRel(*THIS + *xs::in<const DateRel*>(arg)), Object(ST(0)).stash()); 13 0 13
else RETVAL = xs::out(new DateRel(*THIS + *xs::in<const DateRel*>(arg)), Object(ST(0)).stash()); 13 0 13
else RETVAL = xs::out(new DateRel(*THIS + *xs::in<const DateRel*>(arg)), Object(ST(0)).stash()); 13 0 13
else RETVAL = xs::out(new DateRel(*THIS + *xs::in<const DateRel*>(arg)), Object(ST(0)).stash()); 0 0 0
165 14 }
166 6 ▶ else RETVAL = xs::out(new DateRel(*THIS + sv2daterel(arg)), Object(ST(0)).stash());
Branch: 7 branches
BranchTrueFalseTotal
else RETVAL = xs::out(new DateRel(*THIS + sv2daterel(arg)), Object(ST(0)).stash()); 6 0 6
else RETVAL = xs::out(new DateRel(*THIS + sv2daterel(arg)), Object(ST(0)).stash()); 6 0 6
else RETVAL = xs::out(new DateRel(*THIS + sv2daterel(arg)), Object(ST(0)).stash()); 6 0 6
else RETVAL = xs::out(new DateRel(*THIS + sv2daterel(arg)), Object(ST(0)).stash()); 6 0 6
else RETVAL = xs::out(new DateRel(*THIS + sv2daterel(arg)), Object(ST(0)).stash()); 6 0 6
else RETVAL = xs::out(new DateRel(*THIS + sv2daterel(arg)), Object(ST(0)).stash()); 6 0 6
else RETVAL = xs::out(new DateRel(*THIS + sv2daterel(arg)), Object(ST(0)).stash()); 0 0 0
167 }
168  
169 SV* DateRel::add (Sv arg, ...) {
170 5 ▶ *THIS += sv2daterel(arg);
Branch: 2 branches
BranchTrueFalseTotal
*THIS += sv2daterel(arg); 4 1 5
*THIS += sv2daterel(arg); 4 0 4
171 4 XSRETURN(1);
172 }
173  
174 DateRel* DateRel::difference (Sv arg, bool reverse = false) : const {
175 12 auto op = sv2daterel(arg);
176 12 ▶ RETVAL = new DateRel(reverse ? (op - *THIS) : (*THIS - op));
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = new DateRel(reverse ? (op - *THIS) : (*THIS - op)); 10 2 12
177 10 ▶ PROTO = Object(ST(0)).stash();
Branch: 5 branches
BranchTrueFalseTotal
PROTO = Object(ST(0)).stash(); 10 0 10
PROTO = Object(ST(0)).stash(); 5 5 10
PROTO = Object(ST(0)).stash(); 5 0 5
PROTO = Object(ST(0)).stash(); 5 0 5
PROTO = Object(ST(0)).stash(); 0 0 0
178 10 ▶}
Branch: 3 branches
BranchTrueFalseTotal
} 10 0 10
} 10 0 10
} 10 0 10
179  
180 SV* DateRel::subtract (Sv arg, ...) {
181 8 ▶ *THIS -= sv2daterel(arg);
Branch: 2 branches
BranchTrueFalseTotal
*THIS -= sv2daterel(arg); 6 2 8
*THIS -= sv2daterel(arg); 6 0 6
182 6 XSRETURN(1);
183 }
184  
185 DateRel* DateRel::product (SV* arg, ...) : const {
186 23 RETVAL = new DateRel(*THIS * SvNV(arg));
187 23 ▶ PROTO = Object(ST(0)).stash();
Branch: 4 branches
BranchTrueFalseTotal
PROTO = Object(ST(0)).stash(); 23 0 23
PROTO = Object(ST(0)).stash(); 23 0 23
PROTO = Object(ST(0)).stash(); 23 0 23
PROTO = Object(ST(0)).stash(); 0 0 0
188 23 ▶}
Branch: 3 branches
BranchTrueFalseTotal
} 23 0 23
} 23 0 23
} 23 0 23
189  
190 SV* DateRel::multiply (SV* arg, ...) {
191 2 *THIS *= SvNV(arg);
192 2 XSRETURN(1);
193 }
194  
195 DateRel* DateRel::quotient (SV* arg, bool reverse = false) : const {
196 15 if (reverse) throw "Date: illegal divison $num/$reldate";
197 15 ▶ RETVAL = new DateRel(*THIS / SvNV(arg));
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = new DateRel(*THIS / SvNV(arg)); 6 9 15
198 9 ▶ PROTO = Object(ST(0)).stash();
Branch: 4 branches
BranchTrueFalseTotal
PROTO = Object(ST(0)).stash(); 9 0 9
PROTO = Object(ST(0)).stash(); 9 0 9
PROTO = Object(ST(0)).stash(); 9 0 9
PROTO = Object(ST(0)).stash(); 0 0 0
199 9 ▶}
Branch: 3 branches
BranchTrueFalseTotal
} 9 0 9
} 9 0 9
} 9 0 9
200  
201 SV* DateRel::divide (SV* arg, bool reverse = false) {
202 2 ▶ if (reverse) throw "Date: illegal divison $num/$reldate";
Branch: 1 branch
BranchTrueFalseTotal
if (reverse) throw "Date: illegal divison $num/$reldate"; 0 2 2
203 2 *THIS /= SvNV(arg);
204 2 XSRETURN(1);
205 }
206  
207 DateRel* DateRel::negated (...) : const {
208 2 RETVAL = new DateRel(THIS->negated());
209 2 ▶ PROTO = Object(ST(0)).stash();
Branch: 3 branches
BranchTrueFalseTotal
PROTO = Object(ST(0)).stash(); 2 0 2
PROTO = Object(ST(0)).stash(); 2 0 2
PROTO = Object(ST(0)).stash(); 0 0 0
210 2 ▶}
Branch: 3 branches
BranchTrueFalseTotal
} 2 0 2
} 2 0 2
} 2 0 2
211  
212 SV* DateRel::negate () {
213 0 THIS->negate();
214 0 XSRETURN(1);
215 }
216  
217 int DateRel::compare (Sv arg, bool reverse) : const {
218 26 ▶ RETVAL = THIS->compare(sv2daterel(arg));
Branch: 2 branches
BranchTrueFalseTotal
RETVAL = THIS->compare(sv2daterel(arg)); 25 1 26
RETVAL = THIS->compare(sv2daterel(arg)); 25 0 25
219 25 ▶ if (reverse) RETVAL = -RETVAL;
Branch: 1 branch
BranchTrueFalseTotal
if (reverse) RETVAL = -RETVAL; 2 23 25
220 25 ▶ if (RETVAL < 0) RETVAL = -1;
Branch: 1 branch
BranchTrueFalseTotal
if (RETVAL < 0) RETVAL = -1; 5 20 25
221 20 ▶ else if (RETVAL > 0) RETVAL = 1;
Branch: 1 branch
BranchTrueFalseTotal
else if (RETVAL > 0) RETVAL = 1; 5 15 20
222 }
223  
224 bool DateRel::is_same (Sv arg, ...) : const {
225 92 ▶ RETVAL = THIS->is_same(sv2daterel(arg));
Branch: 3 branches
BranchTrueFalseTotal
RETVAL = THIS->is_same(sv2daterel(arg)); 91 1 92
RETVAL = THIS->is_same(sv2daterel(arg)); 91 0 91
RETVAL = THIS->is_same(sv2daterel(arg)); 91 0 91
226 }
227  
228 int DateRel::includes (Sv arg) : const {
229 6 ▶ RETVAL = THIS->includes(sv2date(arg));
Branch: 3 branches
BranchTrueFalseTotal
RETVAL = THIS->includes(sv2date(arg)); 6 0 6
RETVAL = THIS->includes(sv2date(arg)); 6 0 6
RETVAL = THIS->includes(sv2date(arg)); 0 6 6
230 }
231  
232 DateRel* DateRel::clone () {
233 2 RETVAL = new DateRel(*THIS);
234 2 ▶ PROTO = Object(ST(0)).stash();
Branch: 3 branches
BranchTrueFalseTotal
PROTO = Object(ST(0)).stash(); 2 0 2
PROTO = Object(ST(0)).stash(); 2 0 2
PROTO = Object(ST(0)).stash(); 0 0 0
235 2 ▶}
Branch: 3 branches
BranchTrueFalseTotal
} 2 0 2
} 2 0 2
} 2 0 2
« xs/private.h ↑ Summary xs/Date.xs »