Ibam.xs

filter: Statementstmt 0.0% 0 / 49 Branchbran 0.0% 0 / 46 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 95 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
↑ Summary ibam.inl »
1 #include "ibam.hpp"
2  
3 extern "C" {
4 #include "EXTERN.h"
5 #include "perl.h"
6 #include "XSUB.h"
7 #include "proto.h"
8  
9 #include "ppport.h"
10 }
11  
12 SV*
13 0 new_ibam_object(ibam* i, char* CLASS)
14 {
15 SV* obj;
16 SV* sv;
17 HV* stash;
18 0 obj = (SV*)newHV();
19 0 sv_magic(obj, 0, PERL_MAGIC_ext, (const char*)i, 0);
20 0 sv = newRV_inc(obj);
21 0 stash = gv_stashpv(CLASS, 1);
22 0 sv_bless(sv, stash);
23  
24 0 return sv;
25 }
26  
27 ibam*
28 0 get_ibam_object(SV* sv)
29 {
30 MAGIC *mg;
31  
32 0 ▶ if (!sv || !SvOK(sv) || !SvROK(sv) || !(mg = mg_find(SvRV(sv), PERL_MAGIC_ext)))
Branch: 5 branches
BranchTrueFalseTotal
if (!sv || !SvOK(sv) || !SvROK(sv) || !(mg = mg_find(SvRV(sv), PERL_MAGIC_ext))) 0 0 0
if (!sv || !SvOK(sv) || !SvROK(sv) || !(mg = mg_find(SvRV(sv), PERL_MAGIC_ext))) 0 0 0
if (!sv || !SvOK(sv) || !SvROK(sv) || !(mg = mg_find(SvRV(sv), PERL_MAGIC_ext))) 0 0 0
if (!sv || !SvOK(sv) || !SvROK(sv) || !(mg = mg_find(SvRV(sv), PERL_MAGIC_ext))) 0 0 0
if (!sv || !SvOK(sv) || !SvROK(sv) || !(mg = mg_find(SvRV(sv), PERL_MAGIC_ext))) 0 0 0
33 0 return NULL;
34 0 return (ibam*)mg->mg_ptr;
35 }
36  
37 bool
38 0 get_do_second_correction(SV* sv)
39 {
40 0 ▶ if (!sv || !SvOK(sv) || !SvROK(sv))
Branch: 3 branches
BranchTrueFalseTotal
if (!sv || !SvOK(sv) || !SvROK(sv)) 0 0 0
if (!sv || !SvOK(sv) || !SvROK(sv)) 0 0 0
if (!sv || !SvOK(sv) || !SvROK(sv)) 0 0 0
41 0 return FALSE;
42 0 return SvTRUE(*hv_fetch((HV*)SvRV(sv), "do_second_correction", 20, 0));
43 }
44  
45 MODULE = Sys::Ibam PACKAGE = Sys::Ibam
46  
47 PROTOTYPES: ENABLE
48  
49 void
50 ibam::new(do_second_correction=TRUE)
51 int do_second_correction
52 PPCODE:
53 0 ▶ ST(0) = new_ibam_object(new ibam(), CLASS);
Branch: 3 branches
BranchTrueFalseTotal
ST(0) = new_ibam_object(new ibam(), CLASS); 0 0 0
ST(0) = new_ibam_object(new ibam(), CLASS); 0 0 0
ST(0) = new_ibam_object(new ibam(), CLASS); 0 0 0
54 0 HV* hv = (HV*)SvRV(ST(0));
55 0 hv_store(hv, "do_second_correction", 20, newSViv(do_second_correction), 0);
56 0 sv_2mortal(ST(0));
57 0 XSRETURN(1);
58  
59 void
60 ibam::DESTROY()
61  
62 void
63 ibam::import_old_data()
64 CODE:
65 0 THIS->import();
66  
67 void
68 ibam::update_statistics()
69  
70 void
71 ibam::ignore_statistics()
72  
73 void
74 ibam::save()
75  
76 const char*
77 ibam::profile_filename(n, type)
78 int n
79 char* type
80 PREINIT:
81 int profile_type;
82 0 string filename;
83 CODE:
84 0 ▶ if (strcmp(type, "full") == 0)
Branch: 1 branch
BranchTrueFalseTotal
if (strcmp(type, "full") == 0) 0 0 0
85 0 profile_type = 0;
86 0 ▶ else if (strcmp(type, "battery") == 0)
Branch: 1 branch
BranchTrueFalseTotal
else if (strcmp(type, "battery") == 0) 0 0 0
87 0 profile_type = 1;
88 0 ▶ else if (strcmp(type, "charge") == 0)
Branch: 1 branch
BranchTrueFalseTotal
else if (strcmp(type, "charge") == 0) 0 0 0
89 0 profile_type = 2;
90 0 ▶ else if (strcmp(type, "") == 0)
Branch: 1 branch
BranchTrueFalseTotal
else if (strcmp(type, "") == 0) 0 0 0
91 0 profile_type = 3;
92 else
93 0 XSRETURN_UNDEF;
94  
95 0 ▶ filename = THIS->profile_filename(n, profile_type);
Branch: 1 branch
BranchTrueFalseTotal
filename = THIS->profile_filename(n, profile_type); 0 0 0
96 0 RETVAL = filename.c_str();
97 OUTPUT:
98 RETVAL
99  
100 int
101 ibam::current_profile_number()
102  
103 char*
104 ibam::current_profile_type()
105 PREINIT:
106 0 ▶ char* types[4] = {"full", "battery", "charge", ""};
Branch: 1 branch
BranchTrueFalseTotal
char* types[4] = {"full", "battery", "charge", ""}; 0 0 0
107 CODE:
108 0 ▶ RETVAL = types[(THIS->current_profile_type() & 3)];
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = types[(THIS->current_profile_type() & 3)]; 0 0 0
109 OUTPUT:
110 RETVAL
111  
112 void
113 ibam::set_profile_logging(n)
114 SV* n
115 CODE:
116 0 ▶ THIS->set_profile_logging(SvTRUE(n) ? 1 : 0);
Branch: 1 branch
BranchTrueFalseTotal
THIS->set_profile_logging(SvTRUE(n) ? 1 : 0); 0 0 0
117  
118 int
119 ibam::profile_logging_setting()
120  
121 int
122 ibam::seconds_left_battery_bios()
123  
124 int
125 ibam::seconds_left_battery()
126 CODE:
127 0 RETVAL = THIS->seconds_left_battery();
128 0 ▶ if (get_do_second_correction(ST(0)))
Branch: 1 branch
BranchTrueFalseTotal
if (get_do_second_correction(ST(0))) 0 0 0
129 0 RETVAL += THIS->seconds_battery_correction();
130 OUTPUT:
131 RETVAL
132  
133 int
134 ibam::seconds_left_battery_adaptive()
135 CODE:
136 0 RETVAL = THIS->seconds_left_battery_adaptive();
137 0 ▶ if (get_do_second_correction(ST(0)))
Branch: 1 branch
BranchTrueFalseTotal
if (get_do_second_correction(ST(0))) 0 0 0
138 0 RETVAL += THIS->seconds_battery_correction();
139 OUTPUT:
140 RETVAL
141  
142 int
143 ibam::percent_battery_bios()
144  
145 int
146 ibam::percent_battery()
147  
148 int
149 ibam::seconds_left_charge()
150 CODE:
151 0 RETVAL = THIS->seconds_left_charge();
152 0 ▶ if (get_do_second_correction(ST(0)))
Branch: 1 branch
BranchTrueFalseTotal
if (get_do_second_correction(ST(0))) 0 0 0
153 0 RETVAL += THIS->seconds_charge_correction();
154 OUTPUT:
155 RETVAL
156  
157 int
158 ibam::seconds_left_charge_adaptive()
159 CODE:
160 0 RETVAL = THIS->seconds_left_charge_adaptive();
161 0 ▶ if (get_do_second_correction(ST(0)))
Branch: 1 branch
BranchTrueFalseTotal
if (get_do_second_correction(ST(0))) 0 0 0
162 0 RETVAL += THIS->seconds_charge_correction();
163 OUTPUT:
164 RETVAL
165  
166 int
167 ibam::percent_charge()
168  
169 int
170 ibam::seconds_battery_total()
171  
172 int
173 ibam::seconds_battery_total_adaptive()
174  
175 int
176 ibam::seconds_charge_total()
177  
178 int
179 ibam::seconds_charge_total_adaptive()
180  
181 int
182 ibam::seconds_battery_correction()
183  
184 int
185 ibam::seconds_charge_correction()
186  
187 int
188 ibam::on_battery()
189 CODE:
190 0 RETVAL = THIS->onBattery();
191 OUTPUT:
192 RETVAL
193  
194 int
195 ibam::charging()
196  
197 int
198 ibam::valid()
199  
200 void
201 ibam::update()
↑ Summary ibam.inl »