lib/XS/Parse/Keyword.xs

filter: Statementstmt 45.4% 15 / 33 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 40.5% 15 / 37 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« hax/optree-additions.c.inc ↑ Summary hax/newOP_CUSTOM.c.inc »
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, 2021-2024 -- leonerd@leonerd.org.uk
5 */
6  
7 #define PERL_NO_GET_CONTEXT
8  
9 #include "EXTERN.h"
10 #include "perl.h"
11 #include "XSUB.h"
12  
13 #include "XSParseKeyword.h"
14 #include "XSParseInfix.h"
15  
16 #include "keyword.h"
17 #include "infix.h"
18  
19 /* v1 hooks.newop did not pass parsedata */
20 struct XSParseInfixHooks_v1 {
21 U16 flags;
22 U8 lhs_flags, rhs_flags;
23 enum XSParseInfixClassification cls;
24  
25 const char *wrapper_func_name;
26  
27 const char *permit_hintkey;
28 bool (*permit) (pTHX_ void *hookdata);
29  
30 OP *(*new_op)(pTHX_ U32 flags, OP *lhs, OP *rhs, void *hookdata);
31 OP *(*ppaddr)(pTHX);
32  
33 OP *(*parse_rhs)(pTHX_ void *hookdata);
34 };
35  
36 0 static void XSParseInfix_register_v1(pTHX_ const char *opname, const struct XSParseInfixHooks_v1 *hooks_v1, void *hookdata)
37 {
38 0 ▶ if(hooks_v1->rhs_flags & (1 << 7) /* was XPI_OPERAND_CUSTOM */)
Branch: 1 branch
BranchTrueFalseTotal
if(hooks_v1->rhs_flags & (1 << 7) /* was XPI_OPERAND_CUSTOM */) 0 0 0
39 0 croak("XPI_OPERAND_CUSTOM is no longer supported");
40 0 ▶ if(hooks_v1->parse_rhs)
Branch: 1 branch
BranchTrueFalseTotal
if(hooks_v1->parse_rhs) 0 0 0
41 0 croak("XSParseInfixHooks.parse_rhs is no longer supported");
42  
43 struct XSParseInfixHooks *hooks;
44 0 Newx(hooks, 1, struct XSParseInfixHooks);
45  
46 0 hooks->flags = hooks_v1->flags | (1<<15) /* NO_PARSEDATA */;
47 0 hooks->lhs_flags = hooks_v1->lhs_flags;
48 0 hooks->rhs_flags = hooks_v1->rhs_flags;
49 0 hooks->cls = hooks_v1->cls;
50  
51 0 hooks->wrapper_func_name = hooks_v1->wrapper_func_name;
52  
53 0 hooks->permit_hintkey = hooks_v1->permit_hintkey;
54 0 hooks->permit = hooks_v1->permit;
55 0 hooks->new_op = (OP *(*)(pTHX_ U32, OP *, OP *, SV **, void *))hooks_v1->new_op;
56 0 hooks->ppaddr = hooks_v1->ppaddr;
57 0 hooks->parse = NULL;
58  
59 0 XSParseInfix_register(aTHX_ opname, hooks, hookdata);
60 0 }
61  
62 MODULE = XS::Parse::Keyword PACKAGE = XS::Parse::Infix
63  
64 bool check_opname(SV *opname)
65 CODE:
66 {
67 STRLEN namelen;
68 2 const char *namepv = SvPV(opname, namelen);
69 2 RETVAL = XSParseInfix_check_opname(aTHX_ namepv, namelen);
70 }
71 OUTPUT:
72 RETVAL
73  
74 MODULE = XS::Parse::Keyword PACKAGE = XS::Parse::Keyword
75  
76 BOOT:
77 /* legacy version0 support */
78 24 sv_setiv(*hv_fetchs(PL_modglobal, "XS::Parse::Keyword/ABIVERSION", 1), XSPARSEKEYWORD_ABI_VERSION);
79  
80 /* newer versions */
81 24 sv_setiv(*hv_fetchs(PL_modglobal, "XS::Parse::Keyword/ABIVERSION_MIN", 1), 1);
82 24 sv_setiv(*hv_fetchs(PL_modglobal, "XS::Parse::Keyword/ABIVERSION_MAX", 1), XSPARSEKEYWORD_ABI_VERSION);
83  
84 24 sv_setuv(*hv_fetchs(PL_modglobal, "XS::Parse::Keyword/register()@1", 1), PTR2UV(&XSParseKeyword_register_v1));
85 24 sv_setuv(*hv_fetchs(PL_modglobal, "XS::Parse::Keyword/register()@2", 1), PTR2UV(&XSParseKeyword_register_v2));
86  
87 24 XSParseKeyword_boot(aTHX);
88  
89  
90 24 sv_setiv(*hv_fetchs(PL_modglobal, "XS::Parse::Infix/ABIVERSION_MIN", 1), 1);
91 24 sv_setiv(*hv_fetchs(PL_modglobal, "XS::Parse::Infix/ABIVERSION_MAX", 1), XSPARSEINFIX_ABI_VERSION);
92  
93 24 sv_setuv(*hv_fetchs(PL_modglobal, "XS::Parse::Infix/parse()@2", 1), PTR2UV(&XSParseInfix_parse));
94 24 sv_setuv(*hv_fetchs(PL_modglobal, "XS::Parse::Infix/new_op()@0", 1), PTR2UV(&XSParseInfix_new_op));
95 24 sv_setuv(*hv_fetchs(PL_modglobal, "XS::Parse::Infix/register()@1", 1), PTR2UV(&XSParseInfix_register_v1));
96 24 sv_setuv(*hv_fetchs(PL_modglobal, "XS::Parse::Infix/register()@2", 1), PTR2UV(&XSParseInfix_register));
97  
98 24 XSParseInfix_boot(aTHX);
« hax/optree-additions.c.inc ↑ Summary hax/newOP_CUSTOM.c.inc »