File Coverage

lib/Syntax/Operator/Divides.xs
Criterion Covered Total %
statement 12 12 100.0
branch 2 2 100.0
condition n/a
subroutine n/a
pod n/a
total 14 14 100.0


line stmt bran cond sub pod time code
1             /* You may distribute under the terms of either the GNU General Public License
2             * or the Artistic License (the same terms as Perl itself)
3             *
4             * (C) Paul Evans, 2016-2024 -- leonerd@leonerd.org.uk
5             */
6             #include "EXTERN.h"
7             #include "perl.h"
8             #include "XSUB.h"
9              
10             #include "XSParseInfix.h"
11              
12             #define HAVE_PERL_VERSION(R, V, S) \
13             (PERL_REVISION > (R) || (PERL_REVISION == (R) && (PERL_VERSION > (V) || (PERL_VERSION == (V) && (PERL_SUBVERSION >= (S))))))
14              
15             #include "newOP_CUSTOM.c.inc"
16              
17 4           static OP *pp_divides(pTHX)
18             {
19             dSP;
20              
21 4           (PL_ppaddr[OP_MODULO])(aTHX);
22              
23 4           SPAGAIN;
24              
25 4 100         if(SvTRUE(TOPs)) {
26 2           *SP = &PL_sv_no;
27             }
28             else {
29 2           *SP = &PL_sv_yes;
30             }
31              
32 4           return NORMAL;
33             }
34              
35 7           static OP *new_op_divides(pTHX_ U32 flags, OP *lhs, OP *rhs, SV **parsedata, void *hookdata)
36             {
37             OP *ret = newBINOP_CUSTOM(&pp_divides, flags, lhs, rhs);
38 7           ret->op_targ = pad_alloc(OP_CUSTOM, SVs_PADTMP);
39 7           return ret;
40             }
41              
42             static const struct XSParseInfixHooks hooks_divides = {
43             .cls = XPI_CLS_MATCH_MISC,
44             .wrapper_func_name = "Syntax::Operator::Divides::is_divisor",
45             .new_op = &new_op_divides,
46             .ppaddr = &pp_divides,
47             };
48              
49             MODULE = Syntax::Operator::Divides PACKAGE = Syntax::Operator::Divides
50              
51             BOOT:
52 3           boot_xs_parse_infix(0.43);
53              
54 3           register_xs_parse_infix("Syntax::Operator::Divides::%%", &hooks_divides, NULL);