| 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, 2020 -- leonerd@leonerd.org.uk |
|
5
|
|
|
|
|
|
|
*/ |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
#include "EXTERN.h" |
|
8
|
|
|
|
|
|
|
#include "perl.h" |
|
9
|
|
|
|
|
|
|
#include "XSUB.h" |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
#include "XSParseSublike.h" |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
#include "sv_setrv.c.inc" |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
#if (PERL_REVISION > 5) || (PERL_REVISION == 5 && PERL_VERSION >= 26) |
|
16
|
|
|
|
|
|
|
# define HAVE_SIGNATURES |
|
17
|
|
|
|
|
|
|
#endif |
|
18
|
|
|
|
|
|
|
|
|
19
|
11
|
|
|
|
|
|
static bool stage_permit(pTHX_ void *_) |
|
20
|
|
|
|
|
|
|
{ |
|
21
|
11
|
100
|
|
|
|
|
if(!hv_fetchs(GvHV(PL_hintgv), "t::stages/permit", 0)) |
|
22
|
1
|
|
|
|
|
|
return FALSE; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
return TRUE; |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
|
|
27
|
10
|
|
|
|
|
|
static void stage_pre_subparse(pTHX_ struct XSParseSublikeContext *ctx, void *_) |
|
28
|
|
|
|
|
|
|
{ |
|
29
|
10
|
100
|
|
|
|
|
if(hv_fetchs(GvHV(PL_hintgv), "t::stages/pre_subparse-capture", 0)) { |
|
30
|
1
|
|
|
|
|
|
sv_setsv(get_sv("t::stages::captured", GV_ADD), get_sv("main::VAR", 0)); |
|
31
|
|
|
|
|
|
|
} |
|
32
|
10
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
10
|
|
|
|
|
|
static void stage_post_blockstart(pTHX_ struct XSParseSublikeContext *ctx, void *_) |
|
35
|
|
|
|
|
|
|
{ |
|
36
|
10
|
100
|
|
|
|
|
if(hv_fetchs(GvHV(PL_hintgv), "t::stages/post_blockstart-capture", 0)) { |
|
37
|
1
|
|
|
|
|
|
sv_setsv(get_sv("t::stages::captured", GV_ADD), get_sv("main::VAR", 0)); |
|
38
|
|
|
|
|
|
|
} |
|
39
|
10
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
10
|
|
|
|
|
|
static void stage_pre_blockend(pTHX_ struct XSParseSublikeContext *ctx, void *_) |
|
42
|
|
|
|
|
|
|
{ |
|
43
|
10
|
100
|
|
|
|
|
if(hv_fetchs(GvHV(PL_hintgv), "t::stages/pre_blockend-capture", 0)) { |
|
44
|
1
|
|
|
|
|
|
sv_setsv(get_sv("t::stages::captured", GV_ADD), get_sv("main::VAR", 0)); |
|
45
|
|
|
|
|
|
|
} |
|
46
|
10
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
10
|
|
|
|
|
|
static void stage_post_newcv(pTHX_ struct XSParseSublikeContext *ctx, void *_) |
|
49
|
|
|
|
|
|
|
{ |
|
50
|
10
|
100
|
|
|
|
|
if(hv_fetchs(GvHV(PL_hintgv), "t::stages/post_newcv-capture-cv", 0)) { |
|
51
|
1
|
|
|
|
|
|
sv_setrv_inc(get_sv("t::stages::captured", GV_ADD), (SV *)ctx->cv); |
|
52
|
|
|
|
|
|
|
} |
|
53
|
10
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
1
|
|
|
|
|
|
static bool stage_filter_attr(pTHX_ struct XSParseSublikeContext *ctx, SV *attr, SV *value, void *_) |
|
56
|
|
|
|
|
|
|
{ |
|
57
|
1
|
50
|
|
|
|
|
if(!hv_fetchs(GvHV(PL_hintgv), "t::stages/filter_attr-capture", 0)) |
|
58
|
|
|
|
|
|
|
return FALSE; |
|
59
|
|
|
|
|
|
|
|
|
60
|
1
|
|
|
|
|
|
AV *av = newAV(); |
|
61
|
1
|
|
|
|
|
|
av_push(av, SvREFCNT_inc(attr)); |
|
62
|
1
|
|
|
|
|
|
av_push(av, SvREFCNT_inc(value)); |
|
63
|
|
|
|
|
|
|
|
|
64
|
1
|
|
|
|
|
|
sv_setrv_noinc(get_sv("t::stages::captured", GV_ADD), (SV *)av); |
|
65
|
1
|
|
|
|
|
|
return TRUE; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
#ifdef HAVE_SIGNATURES |
|
69
|
4
|
|
|
|
|
|
static void stage_start_signature(pTHX_ struct XSParseSublikeContext *ctx, void *_) |
|
70
|
|
|
|
|
|
|
{ |
|
71
|
4
|
100
|
|
|
|
|
if(hv_fetchs(GvHV(PL_hintgv), "t::stages/signature-add-$first", 0)) { |
|
72
|
1
|
|
|
|
|
|
PADOFFSET padix = pad_add_name_pvs("$first", 0, NULL, NULL); |
|
73
|
|
|
|
|
|
|
|
|
74
|
1
|
|
|
|
|
|
xps_signature_add_param(ctx, (&(struct XPSSignatureParamDetails){ |
|
75
|
|
|
|
|
|
|
.ver = XSPARSESUBLIKE_ABI_VERSION, |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
.sigil = '$', |
|
78
|
|
|
|
|
|
|
.padix = padix, |
|
79
|
|
|
|
|
|
|
})); |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
4
|
100
|
|
|
|
|
if(hv_fetchs(GvHV(PL_hintgv), "t::stages/signature-capture", 0)) { |
|
83
|
2
|
|
|
|
|
|
SV *sv = get_sv("t::stages::captured", GV_ADD); |
|
84
|
2
|
50
|
|
|
|
|
if(!SvPOK(sv)) |
|
85
|
2
|
|
|
|
|
|
sv_setpv(sv, ""); |
|
86
|
|
|
|
|
|
|
|
|
87
|
2
|
|
|
|
|
|
sv_catpv(sv, "(SIG"); |
|
88
|
|
|
|
|
|
|
} |
|
89
|
4
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
4
|
|
|
|
|
|
static void stage_finish_signature(pTHX_ struct XSParseSublikeContext *ctx, void *_) |
|
92
|
|
|
|
|
|
|
{ |
|
93
|
4
|
100
|
|
|
|
|
if(hv_fetchs(GvHV(PL_hintgv), "t::stages/signature-add-@rest", 0)) { |
|
94
|
1
|
|
|
|
|
|
PADOFFSET padix = pad_add_name_pvs("@rest", 0, NULL, NULL); |
|
95
|
|
|
|
|
|
|
|
|
96
|
1
|
|
|
|
|
|
xps_signature_add_param(ctx, (&(struct XPSSignatureParamDetails){ |
|
97
|
|
|
|
|
|
|
.ver = XSPARSESUBLIKE_ABI_VERSION, |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
.sigil = '@', |
|
100
|
|
|
|
|
|
|
.padix = padix, |
|
101
|
|
|
|
|
|
|
})); |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
4
|
100
|
|
|
|
|
if(hv_fetchs(GvHV(PL_hintgv), "t::stages/signature-capture", 0)) { |
|
105
|
2
|
|
|
|
|
|
SV *sv = get_sv("t::stages::captured", GV_ADD); |
|
106
|
2
|
50
|
|
|
|
|
if(!SvPOK(sv)) |
|
107
|
0
|
|
|
|
|
|
sv_setpv(sv, ""); |
|
108
|
|
|
|
|
|
|
|
|
109
|
2
|
|
|
|
|
|
sv_catpvf(sv, "[n=%" UVuf "])", xps_signature_query_params(ctx)); |
|
110
|
|
|
|
|
|
|
} |
|
111
|
4
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
#endif |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
static const struct XSParseSublikeHooks parse_stages_hooks = { |
|
115
|
|
|
|
|
|
|
.ver = XSPARSESUBLIKE_ABI_VERSION, |
|
116
|
|
|
|
|
|
|
.permit = stage_permit, |
|
117
|
|
|
|
|
|
|
.pre_subparse = stage_pre_subparse, |
|
118
|
|
|
|
|
|
|
.filter_attr = stage_filter_attr, |
|
119
|
|
|
|
|
|
|
.post_blockstart = stage_post_blockstart, |
|
120
|
|
|
|
|
|
|
.pre_blockend = stage_pre_blockend, |
|
121
|
|
|
|
|
|
|
.post_newcv = stage_post_newcv, |
|
122
|
|
|
|
|
|
|
#ifdef HAVE_SIGNATURES |
|
123
|
|
|
|
|
|
|
.start_signature = stage_start_signature, |
|
124
|
|
|
|
|
|
|
.finish_signature = stage_finish_signature, |
|
125
|
|
|
|
|
|
|
#endif |
|
126
|
|
|
|
|
|
|
}; |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
MODULE = t::stages PACKAGE = t::stages |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
BOOT: |
|
131
|
7
|
|
|
|
|
|
boot_xs_parse_sublike(0); |
|
132
|
|
|
|
|
|
|
|
|
133
|
7
|
|
|
|
|
|
register_xs_parse_sublike("stages", &parse_stages_hooks, NULL); |