ac.c

filter: Statementstmt 84.0% 100 / 119 Branchbran 49.4% 88 / 178 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 63.3% 188 / 297 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
↑ Summary blib/lib/Algorithm/AhoCorasick/XS.pm »
1 /*
2 * This file was generated automatically by ExtUtils::ParseXS version 3.63 from the
3 * contents of ac.xs. Do not edit this file, edit ac.xs instead.
4 *
5 * ANY CHANGES MADE HERE WILL BE LOST!
6 *
7 */
8  
9 #line 1 "ac.xs"
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13 #include "EXTERN.h"
14 #include "perl.h"
15 #include "XSUB.h"
16 #ifdef __cplusplus
17 }
18 #endif
19  
20 #include "ppport.h"
21  
22 /* Perl 5.19.4 changed array indices from I32 to SSize_t */
23 #if PERL_BCDVERSION >= 0x5019004
24 #define AV_SIZE_MAX SSize_t_MAX
25 #else
26 #define AV_SIZE_MAX I32_MAX
27 #endif
28  
29 #undef do_open
30 #undef do_close
31  
32 #include "Matcher.hpp"
33  
34 typedef AhoCorasick::Matcher AhoCorasick__Matcher;
35 typedef AhoCorasick::match AhoCorasick__match;
36  
37 using std::vector;
38 using std::string;
39  
40 #line 41 "ac.c"
41 #ifndef PERL_UNUSED_VAR
42 # define PERL_UNUSED_VAR(var) if (0) var = var
43 #endif
44  
45 #ifndef dVAR
46 # define dVAR dNOOP
47 #endif
48  
49  
50 /* This stuff is not part of the API! You have been warned. */
51 #ifndef PERL_VERSION_DECIMAL
52 # define PERL_VERSION_DECIMAL(r,v,s) (r*1000000 + v*1000 + s)
53 #endif
54 #ifndef PERL_DECIMAL_VERSION
55 # define PERL_DECIMAL_VERSION \
56 PERL_VERSION_DECIMAL(PERL_REVISION,PERL_VERSION,PERL_SUBVERSION)
57 #endif
58 #ifndef PERL_VERSION_GE
59 # define PERL_VERSION_GE(r,v,s) \
60 (PERL_DECIMAL_VERSION >= PERL_VERSION_DECIMAL(r,v,s))
61 #endif
62 #ifndef PERL_VERSION_LE
63 # define PERL_VERSION_LE(r,v,s) \
64 (PERL_DECIMAL_VERSION <= PERL_VERSION_DECIMAL(r,v,s))
65 #endif
66  
67 /* XS_INTERNAL is the explicit static-linkage variant of the default
68 * XS macro.
69 *
70 * XS_EXTERNAL is the same as XS_INTERNAL except it does not include
71 * "static", ie. it exports XSUB symbols. You probably don't want that
72 * for anything but the BOOT XSUB.
73 *
74 * See XSUB.h in core!
75 */
76  
77  
78 /* TODO: This might be compatible further back than 5.10.0. */
79 #if PERL_VERSION_GE(5, 10, 0) && PERL_VERSION_LE(5, 15, 1)
80 # undef XS_EXTERNAL
81 # undef XS_INTERNAL
82 # if defined(__CYGWIN__) && defined(USE_DYNAMIC_LOADING)
83 # define XS_EXTERNAL(name) __declspec(dllexport) XSPROTO(name)
84 # define XS_INTERNAL(name) static XSPROTO(name)
85 # endif
86 # if defined(__SYMBIAN32__)
87 # define XS_EXTERNAL(name) EXPORT_C XSPROTO(name)
88 # define XS_INTERNAL(name) EXPORT_C static XSPROTO(name)
89 # endif
90 # ifndef XS_EXTERNAL
91 # if defined(HASATTRIBUTE_UNUSED) && !defined(__cplusplus)
92 # define XS_EXTERNAL(name) void name(pTHX_ CV* cv __attribute__unused__)
93 # define XS_INTERNAL(name) static void name(pTHX_ CV* cv __attribute__unused__)
94 # else
95 # ifdef __cplusplus
96 # define XS_EXTERNAL(name) extern "C" XSPROTO(name)
97 # define XS_INTERNAL(name) static XSPROTO(name)
98 # else
99 # define XS_EXTERNAL(name) XSPROTO(name)
100 # define XS_INTERNAL(name) static XSPROTO(name)
101 # endif
102 # endif
103 # endif
104 #endif
105  
106 /* perl >= 5.10.0 && perl <= 5.15.1 */
107  
108  
109 /* The XS_EXTERNAL macro is used for functions that must not be static
110 * like the boot XSUB of a module. If perl didn't have an XS_EXTERNAL
111 * macro defined, the best we can do is assume XS is the same.
112 * Dito for XS_INTERNAL.
113 */
114 #ifndef XS_EXTERNAL
115 # define XS_EXTERNAL(name) XS(name)
116 #endif
117 #ifndef XS_INTERNAL
118 # define XS_INTERNAL(name) XS(name)
119 #endif
120  
121 /* Now, finally, after all this mess, we want an ExtUtils::ParseXS
122 * internal macro that we're free to redefine for varying linkage due
123 * to the EXPORT_XSUB_SYMBOLS XS keyword. This is internal, use
124 * XS_EXTERNAL(name) or XS_INTERNAL(name) in your code if you need to!
125 */
126  
127 #undef XS_EUPXS
128 #if defined(PERL_EUPXS_ALWAYS_EXPORT)
129 # define XS_EUPXS(name) XS_EXTERNAL(name)
130 #else
131 /* default to internal */
132 # define XS_EUPXS(name) XS_INTERNAL(name)
133 #endif
134  
135 #ifndef PERL_ARGS_ASSERT_CROAK_XS_USAGE
136 #define PERL_ARGS_ASSERT_CROAK_XS_USAGE assert(cv); assert(params)
137  
138 /* prototype to pass -Wmissing-prototypes */
139 static void
140 S_croak_xs_usage(const CV *const cv, const char *const params);
141  
142 static void
143 S_croak_xs_usage(const CV *const cv, const char *const params)
144 {
145 const GV *const gv = CvGV(cv);
146  
147 PERL_ARGS_ASSERT_CROAK_XS_USAGE;
148  
149 if (gv) {
150 const char *const gvname = GvNAME(gv);
151 const HV *const stash = GvSTASH(gv);
152 const char *const hvname = stash ? HvNAME(stash) : NULL;
153  
154 if (hvname)
155 Perl_croak_nocontext("Usage: %s::%s(%s)", hvname, gvname, params);
156 else
157 Perl_croak_nocontext("Usage: %s(%s)", gvname, params);
158 } else {
159 /* Pants. I don't think that it should be possible to get here. */
160 Perl_croak_nocontext("Usage: CODE(0x%" UVxf ")(%s)", PTR2UV(cv), params);
161 }
162 }
163 #undef PERL_ARGS_ASSERT_CROAK_XS_USAGE
164  
165 #define croak_xs_usage S_croak_xs_usage
166  
167 #endif
168  
169 /* NOTE: the prototype of newXSproto() is different in versions of perls,
170 * so we define a portable version of newXSproto()
171 */
172 #ifdef newXS_flags
173 #define newXSproto_portable(name, c_impl, file, proto) newXS_flags(name, c_impl, file, proto, 0)
174 #else
175 #define newXSproto_portable(name, c_impl, file, proto) (PL_Sv=(SV*)newXS(name, c_impl, file), sv_setpv(PL_Sv, proto), (CV*)PL_Sv)
176 #endif /* !defined(newXS_flags) */
177  
178 #if PERL_VERSION_LE(5, 21, 5)
179 # define newXS_deffile(a,b) Perl_newXS(aTHX_ a,b,file)
180 #else
181 # define newXS_deffile(a,b) Perl_newXS_deffile(aTHX_ a,b)
182 #endif
183  
184 /* simple backcompat versions of the TARGx() macros with no optimisation */
185 #ifndef TARGi
186 # define TARGi(iv, do_taint) sv_setiv_mg(TARG, iv)
187 # define TARGu(uv, do_taint) sv_setuv_mg(TARG, uv)
188 # define TARGn(nv, do_taint) sv_setnv_mg(TARG, nv)
189 #endif
190  
191 #line 192 "ac.c"
192  
193 XS_EUPXS(XS_Algorithm__AhoCorasick__XS_new); /* prototype to pass -Wmissing-prototypes */
194 23 XS_EUPXS(XS_Algorithm__AhoCorasick__XS_new)
195 {
196 23 dVAR; dXSARGS;
197 23 ▶ if (items != 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 2) 1 22 23
198 1 croak_xs_usage(cv, "CLASS, keywords");
199 {
200 22 char * CLASS = (char *)SvPV_nolen(ST(0))
201 ;
202 AhoCorasick__Matcher * RETVAL;
203 22 vector<string> keywords;
204  
205 22 ▶ if (SvROK(ST(1)) && SvTYPE(SvRV(ST(1)))==SVt_PVAV) {
Branch: 2 branches
BranchTrueFalseTotal
if (SvROK(ST(1)) && SvTYPE(SvRV(ST(1)))==SVt_PVAV) { 22 0 22
if (SvROK(ST(1)) && SvTYPE(SvRV(ST(1)))==SVt_PVAV) { 22 0 22
206 22 AV* av = (AV*)SvRV(ST(1));
207 22 ▶ const unsigned int alen = av_len(av)+1;
Branch: 1 branch
BranchTrueFalseTotal
const unsigned int alen = av_len(av)+1; 22 0 22
208 22 ▶ keywords = std::vector<std::string>(alen);
Branch: 1 branch
BranchTrueFalseTotal
keywords = std::vector<std::string>(alen); 22 0 22
209 STRLEN len;
210 char* tmp;
211 SV** elem;
212  
213 68 ▶ for (unsigned int i = 0; i < alen; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (unsigned int i = 0; i < alen; i++) { 46 22 68
214 46 ▶ elem = av_fetch(av, i, 0);
Branch: 1 branch
BranchTrueFalseTotal
elem = av_fetch(av, i, 0); 46 0 46
215 46 ▶ if (elem != NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if (elem != NULL) { 46 0 46
216 92 tmp = SvPV(*elem, len);
217 92 ▶ keywords[i] = std::string(tmp, len);
Branch: 1 branch
BranchTrueFalseTotal
keywords[i] = std::string(tmp, len); 46 0 46
218 }
219 else
220 0 ▶ keywords[i] = std::string("");
Branch: 1 branch
BranchTrueFalseTotal
keywords[i] = std::string(""); 0 0 0
221 }
222 22 }
223 else
224 0 Perl_croak(aTHX_ "%s: %s is not an array reference",
225 "Algorithm::AhoCorasick::XS::new",
226 "keywords")
227 ;
228  
229 22 ▶ RETVAL = new AhoCorasick::Matcher(keywords);
Branch: 3 branches
BranchTrueFalseTotal
RETVAL = new AhoCorasick::Matcher(keywords); 22 0 22
RETVAL = new AhoCorasick::Matcher(keywords); 22 0 22
RETVAL = new AhoCorasick::Matcher(keywords); 0 0 0
230 {
231 SV * RETVALSV;
232 22 ▶ RETVALSV = sv_newmortal();
Branch: 1 branch
BranchTrueFalseTotal
RETVALSV = sv_newmortal(); 22 0 22
233 22 ▶ sv_setref_pv( RETVALSV, CLASS, (void*)RETVAL );
Branch: 1 branch
BranchTrueFalseTotal
sv_setref_pv( RETVALSV, CLASS, (void*)RETVAL ); 22 0 22
234 22 ST(0) = RETVALSV;
235 }
236 22 }
237 22 XSRETURN(1);
238 }
239  
240  
241 XS_EUPXS(XS_Algorithm__AhoCorasick__XS_DESTROY); /* prototype to pass -Wmissing-prototypes */
242 22 XS_EUPXS(XS_Algorithm__AhoCorasick__XS_DESTROY)
243 {
244 22 dVAR; dXSARGS;
245 22 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 22 22
246 0 croak_xs_usage(cv, "THIS");
247 {
248 AhoCorasick__Matcher * THIS;
249  
250 22 ▶ if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) )
Branch: 3 branches
BranchTrueFalseTotal
if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) ) 22 0 22
if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) ) 22 0 22
if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) ) 22 0 22
251 22 THIS = (AhoCorasick__Matcher *)SvIV((SV*)SvRV( ST(0) ));
252 else{
253 0 warn( "Algorithm::AhoCorasick::XS::DESTROY() -- THIS is not a blessed SV reference" );
254 0 XSRETURN_UNDEF;
255 }
256 ;
257  
258 22 ▶ delete THIS;
Branch: 1 branch
BranchTrueFalseTotal
delete THIS; 22 0 22
259 }
260 22 XSRETURN_EMPTY;
261 }
262  
263  
264 XS_EUPXS(XS_Algorithm__AhoCorasick__XS_first_match); /* prototype to pass -Wmissing-prototypes */
265 2 XS_EUPXS(XS_Algorithm__AhoCorasick__XS_first_match)
266 {
267 2 dVAR; dXSARGS;
268 2 ▶ if (items != 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 2) 0 2 2
269 0 croak_xs_usage(cv, "THIS, input");
270 {
271 AhoCorasick__Matcher * THIS;
272 2 vector<string> RETVAL;
273 2 string input;
274  
275 2 ▶ if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) )
Branch: 4 branches
BranchTrueFalseTotal
if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) ) 2 0 2
if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) ) 2 0 2
if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) ) 2 0 2
if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) ) 2 0 2
276 2 ▶ THIS = (AhoCorasick__Matcher *)SvIV((SV*)SvRV( ST(0) ));
Branch: 1 branch
BranchTrueFalseTotal
THIS = (AhoCorasick__Matcher *)SvIV((SV*)SvRV( ST(0) )); 2 0 2
277 else{
278 0 ▶ warn( "Algorithm::AhoCorasick::XS::first_match() -- THIS is not a blessed SV reference" );
Branch: 1 branch
BranchTrueFalseTotal
warn( "Algorithm::AhoCorasick::XS::first_match() -- THIS is not a blessed SV reference" ); 0 0 0
279 0 XSRETURN_UNDEF;
280 }
281 ;
282  
283 2 ▶ if (!SvOK(ST(1))) {
Branch: 1 branch
BranchTrueFalseTotal
if (!SvOK(ST(1))) { 0 2 2
284 0 input = std::string();
285 } else {
286 6 ▶ input = std::string(SvPV_nolen(ST(1)), SvCUR(ST(1)));
Branch: 2 branches
BranchTrueFalseTotal
input = std::string(SvPV_nolen(ST(1)), SvCUR(ST(1))); 2 0 2
input = std::string(SvPV_nolen(ST(1)), SvCUR(ST(1))); 2 0 2
287 }
288 ;
289  
290 2 ▶ RETVAL = THIS->first_match(input);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = THIS->first_match(input); 2 0 2
291 {
292 SV * RETVALSV;
293 2 ▶ RETVALSV = sv_newmortal();
Branch: 1 branch
BranchTrueFalseTotal
RETVALSV = sv_newmortal(); 2 0 2
294 {
295 U32 ix_RETVAL;
296 2 size_t size_RETVAL = RETVAL.size();
297 2 SSize_t extend_size =
298 /* The weird way this is written is because g++ is dumb
299 * enough to warn "comparison is always false" on something
300 * like:
301 *
302 * sizeof(a) > sizeof(b) && a > B_t_MAX
303 *
304 * (where the LH condition is false)
305 */
306 (size_RETVAL > (sizeof(size_RETVAL) > sizeof(SSize_t)
307 ? AV_SIZE_MAX : size_RETVAL))
308 ? -1 : (SSize_t)size_RETVAL;
309 2 ▶ EXTEND(SP, extend_size);
Branch: 4 branches
BranchTrueFalseTotal
EXTEND(SP, extend_size); 2 0 2
EXTEND(SP, extend_size); 0 2 2
EXTEND(SP, extend_size); 0 2 2
EXTEND(SP, extend_size); 0 0 0
310 3 ▶ for (ix_RETVAL = 0; ix_RETVAL < size_RETVAL; ix_RETVAL++) {
Branch: 1 branch
BranchTrueFalseTotal
for (ix_RETVAL = 0; ix_RETVAL < size_RETVAL; ix_RETVAL++) { 1 2 3
311 1 ▶ ST(ix_RETVAL) = sv_2mortal(newSVpvn(RETVAL[ix_RETVAL].c_str(), RETVAL[ix_RETVAL].length()));
Branch: 2 branches
BranchTrueFalseTotal
ST(ix_RETVAL) = sv_2mortal(newSVpvn(RETVAL[ix_RETVAL].c_str(), RETVAL[ix_RETVAL].length())); 1 0 1
ST(ix_RETVAL) = sv_2mortal(newSVpvn(RETVAL[ix_RETVAL].c_str(), RETVAL[ix_RETVAL].length())); 1 0 1
312 }
313 // xsubpp adds 'ST(0) = RETVALSV' which is undef, screwing this up
314 2 XSRETURN(size_RETVAL);
315 }
316 ST(0) = RETVALSV;
317 }
318 4 ▶ }
Branch: 2 branches
BranchTrueFalseTotal
} 0 2 2
} 0 2 2
319 0 XSRETURN(1);
320 }
321  
322  
323 XS_EUPXS(XS_Algorithm__AhoCorasick__XS_matches); /* prototype to pass -Wmissing-prototypes */
324 1623 XS_EUPXS(XS_Algorithm__AhoCorasick__XS_matches)
325 {
326 1623 dVAR; dXSARGS;
327 1623 ▶ if (items != 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 2) 0 1623 1623
328 0 croak_xs_usage(cv, "THIS, input");
329 {
330 AhoCorasick__Matcher * THIS;
331 1623 vector<string> RETVAL;
332 1623 string input;
333  
334 1623 ▶ if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) )
Branch: 4 branches
BranchTrueFalseTotal
if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) ) 1623 0 1623
if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) ) 1623 0 1623
if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) ) 1623 0 1623
if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) ) 1623 0 1623
335 1623 ▶ THIS = (AhoCorasick__Matcher *)SvIV((SV*)SvRV( ST(0) ));
Branch: 1 branch
BranchTrueFalseTotal
THIS = (AhoCorasick__Matcher *)SvIV((SV*)SvRV( ST(0) )); 1623 0 1623
336 else{
337 0 ▶ warn( "Algorithm::AhoCorasick::XS::matches() -- THIS is not a blessed SV reference" );
Branch: 1 branch
BranchTrueFalseTotal
warn( "Algorithm::AhoCorasick::XS::matches() -- THIS is not a blessed SV reference" ); 0 0 0
338 0 XSRETURN_UNDEF;
339 }
340 ;
341  
342 1623 ▶ if (!SvOK(ST(1))) {
Branch: 1 branch
BranchTrueFalseTotal
if (!SvOK(ST(1))) { 1 1622 1623
343 1 input = std::string();
344 } else {
345 4866 ▶ input = std::string(SvPV_nolen(ST(1)), SvCUR(ST(1)));
Branch: 2 branches
BranchTrueFalseTotal
input = std::string(SvPV_nolen(ST(1)), SvCUR(ST(1))); 1608 14 1622
input = std::string(SvPV_nolen(ST(1)), SvCUR(ST(1))); 1622 0 1622
346 }
347 ;
348  
349 1623 ▶ RETVAL = THIS->matches(input);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = THIS->matches(input); 1623 0 1623
350 {
351 SV * RETVALSV;
352 1623 ▶ RETVALSV = sv_newmortal();
Branch: 1 branch
BranchTrueFalseTotal
RETVALSV = sv_newmortal(); 1623 0 1623
353 {
354 U32 ix_RETVAL;
355 1623 size_t size_RETVAL = RETVAL.size();
356 1623 SSize_t extend_size =
357 /* The weird way this is written is because g++ is dumb
358 * enough to warn "comparison is always false" on something
359 * like:
360 *
361 * sizeof(a) > sizeof(b) && a > B_t_MAX
362 *
363 * (where the LH condition is false)
364 */
365 (size_RETVAL > (sizeof(size_RETVAL) > sizeof(SSize_t)
366 ? AV_SIZE_MAX : size_RETVAL))
367 ? -1 : (SSize_t)size_RETVAL;
368 1623 ▶ EXTEND(SP, extend_size);
Branch: 4 branches
BranchTrueFalseTotal
EXTEND(SP, extend_size); 1623 0 1623
EXTEND(SP, extend_size); 0 1623 1623
EXTEND(SP, extend_size); 0 1623 1623
EXTEND(SP, extend_size); 0 0 0
369 3190 ▶ for (ix_RETVAL = 0; ix_RETVAL < size_RETVAL; ix_RETVAL++) {
Branch: 1 branch
BranchTrueFalseTotal
for (ix_RETVAL = 0; ix_RETVAL < size_RETVAL; ix_RETVAL++) { 1567 1623 3190
370 1567 ▶ ST(ix_RETVAL) = sv_2mortal(newSVpvn(RETVAL[ix_RETVAL].c_str(), RETVAL[ix_RETVAL].length()));
Branch: 2 branches
BranchTrueFalseTotal
ST(ix_RETVAL) = sv_2mortal(newSVpvn(RETVAL[ix_RETVAL].c_str(), RETVAL[ix_RETVAL].length())); 1567 0 1567
ST(ix_RETVAL) = sv_2mortal(newSVpvn(RETVAL[ix_RETVAL].c_str(), RETVAL[ix_RETVAL].length())); 1567 0 1567
371 }
372 // xsubpp adds 'ST(0) = RETVALSV' which is undef, screwing this up
373 1623 XSRETURN(size_RETVAL);
374 }
375 ST(0) = RETVALSV;
376 }
377 3246 ▶ }
Branch: 2 branches
BranchTrueFalseTotal
} 0 1623 1623
} 0 1623 1623
378 0 XSRETURN(1);
379 }
380  
381  
382 XS_EUPXS(XS_Algorithm__AhoCorasick__XS_match_details); /* prototype to pass -Wmissing-prototypes */
383 3 XS_EUPXS(XS_Algorithm__AhoCorasick__XS_match_details)
384 {
385 3 dVAR; dXSARGS;
386 3 ▶ if (items != 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 2) 0 3 3
387 0 croak_xs_usage(cv, "THIS, input");
388 {
389 AhoCorasick__Matcher * THIS;
390 3 vector<AhoCorasick__match> RETVAL;
391 3 string input;
392  
393 3 ▶ if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) )
Branch: 4 branches
BranchTrueFalseTotal
if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) ) 3 0 3
if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) ) 3 0 3
if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) ) 3 0 3
if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) ) 3 0 3
394 3 ▶ THIS = (AhoCorasick__Matcher *)SvIV((SV*)SvRV( ST(0) ));
Branch: 1 branch
BranchTrueFalseTotal
THIS = (AhoCorasick__Matcher *)SvIV((SV*)SvRV( ST(0) )); 3 0 3
395 else{
396 0 ▶ warn( "Algorithm::AhoCorasick::XS::match_details() -- THIS is not a blessed SV reference" );
Branch: 1 branch
BranchTrueFalseTotal
warn( "Algorithm::AhoCorasick::XS::match_details() -- THIS is not a blessed SV reference" ); 0 0 0
397 0 XSRETURN_UNDEF;
398 }
399 ;
400  
401 3 ▶ if (!SvOK(ST(1))) {
Branch: 1 branch
BranchTrueFalseTotal
if (!SvOK(ST(1))) { 0 3 3
402 0 input = std::string();
403 } else {
404 9 ▶ input = std::string(SvPV_nolen(ST(1)), SvCUR(ST(1)));
Branch: 2 branches
BranchTrueFalseTotal
input = std::string(SvPV_nolen(ST(1)), SvCUR(ST(1))); 3 0 3
input = std::string(SvPV_nolen(ST(1)), SvCUR(ST(1))); 3 0 3
405 }
406 ;
407  
408 3 ▶ RETVAL = THIS->match_details(input);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = THIS->match_details(input); 3 0 3
409 {
410 SV * RETVALSV;
411 3 ▶ RETVALSV = sv_newmortal();
Branch: 1 branch
BranchTrueFalseTotal
RETVALSV = sv_newmortal(); 3 0 3
412 {
413 U32 ix_RETVAL;
414 3 size_t size_RETVAL = RETVAL.size();
415 3 SSize_t extend_size =
416 (size_RETVAL > (sizeof(size_RETVAL) > sizeof(SSize_t)
417 ? AV_SIZE_MAX : size_RETVAL))
418 ? -1 : (SSize_t)size_RETVAL;
419 3 ▶ EXTEND(SP, extend_size);
Branch: 4 branches
BranchTrueFalseTotal
EXTEND(SP, extend_size); 3 0 3
EXTEND(SP, extend_size); 0 3 3
EXTEND(SP, extend_size); 0 3 3
EXTEND(SP, extend_size); 0 0 0
420 9 ▶ for (ix_RETVAL = 0; ix_RETVAL < size_RETVAL; ix_RETVAL++) {
Branch: 1 branch
BranchTrueFalseTotal
for (ix_RETVAL = 0; ix_RETVAL < size_RETVAL; ix_RETVAL++) { 6 3 9
421 // Build a hashref from the match object
422 6 const AhoCorasick::match &m = RETVAL[ix_RETVAL];
423 6 ▶ HV *hv = newHV();
Branch: 1 branch
BranchTrueFalseTotal
HV *hv = newHV(); 6 0 6
424 6 STRLEN klen = m.keyword.length();
425 // 7=strlen("keyword"), 0=tell hv_store to calculate the hash
426 6 ▶ hv_store(hv, "word", 4, newSVpv(m.keyword.c_str(), klen), 0);
Branch: 2 branches
BranchTrueFalseTotal
hv_store(hv, "word", 4, newSVpv(m.keyword.c_str(), klen), 0); 6 0 6
hv_store(hv, "word", 4, newSVpv(m.keyword.c_str(), klen), 0); 6 0 6
427 6 ▶ hv_store(hv, "start", 5, newSViv(m.start), 0);
Branch: 2 branches
BranchTrueFalseTotal
hv_store(hv, "start", 5, newSViv(m.start), 0); 6 0 6
hv_store(hv, "start", 5, newSViv(m.start), 0); 6 0 6
428 6 ▶ hv_store(hv, "end", 3, newSViv(m.end), 0);
Branch: 2 branches
BranchTrueFalseTotal
hv_store(hv, "end", 3, newSViv(m.end), 0); 6 0 6
hv_store(hv, "end", 3, newSViv(m.end), 0); 6 0 6
429 6 ▶ ST(ix_RETVAL) = newRV_noinc((SV *)hv);
Branch: 1 branch
BranchTrueFalseTotal
ST(ix_RETVAL) = newRV_noinc((SV *)hv); 6 0 6
430 }
431 3 XSRETURN(size_RETVAL);
432 }
433 ST(0) = RETVALSV;
434 }
435 6 ▶ }
Branch: 2 branches
BranchTrueFalseTotal
} 0 3 3
} 0 3 3
436 0 XSRETURN(1);
437 }
438  
439 #ifdef __cplusplus
440 extern "C" {
441 #endif
442 XS_EXTERNAL(boot_Algorithm__AhoCorasick__XS); /* prototype to pass -Wmissing-prototypes */
443 5 XS_EXTERNAL(boot_Algorithm__AhoCorasick__XS)
444 {
445 #if PERL_VERSION_LE(5, 21, 5)
446 dVAR; dXSARGS;
447 #else
448 5 dVAR; dXSBOOTARGSXSAPIVERCHK;
449 #endif
450 #if PERL_VERSION_LE(5, 8, 999) /* PERL_VERSION_LT is 5.33+ */
451 char* file = __FILE__;
452 #else
453 5 const char* file = __FILE__;
454 #endif
455  
456 PERL_UNUSED_VAR(file);
457  
458 PERL_UNUSED_VAR(cv); /* -W */
459 PERL_UNUSED_VAR(items); /* -W */
460 #if PERL_VERSION_LE(5, 21, 5)
461 XS_VERSION_BOOTCHECK;
462 # ifdef XS_APIVERSION_BOOTCHECK
463 XS_APIVERSION_BOOTCHECK;
464 # endif
465 #endif
466  
467 5 (void)newXSproto_portable("Algorithm::AhoCorasick::XS::new", XS_Algorithm__AhoCorasick__XS_new, file, "$$");
468 5 (void)newXSproto_portable("Algorithm::AhoCorasick::XS::DESTROY", XS_Algorithm__AhoCorasick__XS_DESTROY, file, "$");
469 5 (void)newXSproto_portable("Algorithm::AhoCorasick::XS::first_match", XS_Algorithm__AhoCorasick__XS_first_match, file, "$$");
470 5 (void)newXSproto_portable("Algorithm::AhoCorasick::XS::matches", XS_Algorithm__AhoCorasick__XS_matches, file, "$$");
471 5 (void)newXSproto_portable("Algorithm::AhoCorasick::XS::match_details", XS_Algorithm__AhoCorasick__XS_match_details, file, "$$");
472 #if PERL_VERSION_LE(5, 21, 5)
473 # if PERL_VERSION_GE(5, 9, 0)
474 if (PL_unitcheckav)
475 call_list(PL_scopestack_ix, PL_unitcheckav);
476 # endif
477 XSRETURN_YES;
478 #else
479 5 Perl_xs_boot_epilog(aTHX_ ax);
480 #endif
481 5 }
482  
483 #ifdef __cplusplus
484 }
485 #endif
↑ Summary blib/lib/Algorithm/AhoCorasick/XS.pm »