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, 2021 -- 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
|
0
|
|
|
|
|
if(hooks_v1->rhs_flags & XPI_OPERAND_CUSTOM) |
39
|
0
|
|
|
|
|
|
croak("XPI_OPERAND_CUSTOM is no longer supported"); |
40
|
0
|
0
|
|
|
|
|
if(hooks_v1->parse_rhs) |
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::Keyword |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
BOOT: |
65
|
|
|
|
|
|
|
/* legacy version0 support */ |
66
|
22
|
|
|
|
|
|
sv_setiv(*hv_fetchs(PL_modglobal, "XS::Parse::Keyword/ABIVERSION", 1), XSPARSEKEYWORD_ABI_VERSION); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
/* newer versions */ |
69
|
22
|
|
|
|
|
|
sv_setiv(*hv_fetchs(PL_modglobal, "XS::Parse::Keyword/ABIVERSION_MIN", 1), 1); |
70
|
22
|
|
|
|
|
|
sv_setiv(*hv_fetchs(PL_modglobal, "XS::Parse::Keyword/ABIVERSION_MAX", 1), XSPARSEKEYWORD_ABI_VERSION); |
71
|
|
|
|
|
|
|
|
72
|
22
|
|
|
|
|
|
sv_setuv(*hv_fetchs(PL_modglobal, "XS::Parse::Keyword/register()@1", 1), PTR2UV(&XSParseKeyword_register_v1)); |
73
|
22
|
|
|
|
|
|
sv_setuv(*hv_fetchs(PL_modglobal, "XS::Parse::Keyword/register()@2", 1), PTR2UV(&XSParseKeyword_register_v2)); |
74
|
|
|
|
|
|
|
|
75
|
22
|
|
|
|
|
|
XSParseKeyword_boot(aTHX); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
22
|
|
|
|
|
|
sv_setiv(*hv_fetchs(PL_modglobal, "XS::Parse::Infix/ABIVERSION_MIN", 1), 1); |
79
|
22
|
|
|
|
|
|
sv_setiv(*hv_fetchs(PL_modglobal, "XS::Parse::Infix/ABIVERSION_MAX", 1), XSPARSEINFIX_ABI_VERSION); |
80
|
|
|
|
|
|
|
|
81
|
22
|
|
|
|
|
|
sv_setuv(*hv_fetchs(PL_modglobal, "XS::Parse::Infix/parse()@2", 1), PTR2UV(&XSParseInfix_parse)); |
82
|
22
|
|
|
|
|
|
sv_setuv(*hv_fetchs(PL_modglobal, "XS::Parse::Infix/new_op()@0", 1), PTR2UV(&XSParseInfix_new_op)); |
83
|
22
|
|
|
|
|
|
sv_setuv(*hv_fetchs(PL_modglobal, "XS::Parse::Infix/register()@1", 1), PTR2UV(&XSParseInfix_register_v1)); |
84
|
22
|
|
|
|
|
|
sv_setuv(*hv_fetchs(PL_modglobal, "XS::Parse::Infix/register()@2", 1), PTR2UV(&XSParseInfix_register)); |
85
|
|
|
|
|
|
|
|
86
|
22
|
|
|
|
|
|
XSParseInfix_boot(aTHX); |