| 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
|
7
|
|
|
|
|
|
static bool stage_permit(pTHX_ void *_) |
|
16
|
|
|
|
|
|
|
{ |
|
17
|
7
|
100
|
|
|
|
|
if(!hv_fetchs(GvHV(PL_hintgv), "t::stages/permit", 0)) |
|
18
|
|
|
|
|
|
|
return FALSE; |
|
19
|
|
|
|
|
|
|
|
|
20
|
6
|
|
|
|
|
|
return TRUE; |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
6
|
|
|
|
|
|
static void stage_pre_subparse(pTHX_ struct XSParseSublikeContext *ctx, void *_) |
|
24
|
|
|
|
|
|
|
{ |
|
25
|
6
|
100
|
|
|
|
|
if(hv_fetchs(GvHV(PL_hintgv), "t::stages/pre_subparse-capture", 0)) { |
|
26
|
1
|
|
|
|
|
|
sv_setsv(get_sv("t::stages::captured", GV_ADD), get_sv("main::VAR", 0)); |
|
27
|
|
|
|
|
|
|
} |
|
28
|
6
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
6
|
|
|
|
|
|
static void stage_post_blockstart(pTHX_ struct XSParseSublikeContext *ctx, void *_) |
|
31
|
|
|
|
|
|
|
{ |
|
32
|
6
|
100
|
|
|
|
|
if(hv_fetchs(GvHV(PL_hintgv), "t::stages/post_blockstart-capture", 0)) { |
|
33
|
1
|
|
|
|
|
|
sv_setsv(get_sv("t::stages::captured", GV_ADD), get_sv("main::VAR", 0)); |
|
34
|
|
|
|
|
|
|
} |
|
35
|
6
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
6
|
|
|
|
|
|
static void stage_pre_blockend(pTHX_ struct XSParseSublikeContext *ctx, void *_) |
|
38
|
|
|
|
|
|
|
{ |
|
39
|
6
|
100
|
|
|
|
|
if(hv_fetchs(GvHV(PL_hintgv), "t::stages/pre_blockend-capture", 0)) { |
|
40
|
1
|
|
|
|
|
|
sv_setsv(get_sv("t::stages::captured", GV_ADD), get_sv("main::VAR", 0)); |
|
41
|
|
|
|
|
|
|
} |
|
42
|
6
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
6
|
|
|
|
|
|
static void stage_post_newcv(pTHX_ struct XSParseSublikeContext *ctx, void *_) |
|
45
|
|
|
|
|
|
|
{ |
|
46
|
6
|
100
|
|
|
|
|
if(hv_fetchs(GvHV(PL_hintgv), "t::stages/post_newcv-capture-cv", 0)) { |
|
47
|
1
|
|
|
|
|
|
sv_setrv_inc(get_sv("t::stages::captured", GV_ADD), (SV *)ctx->cv); |
|
48
|
|
|
|
|
|
|
} |
|
49
|
6
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
1
|
|
|
|
|
|
static bool stage_filter_attr(pTHX_ struct XSParseSublikeContext *ctx, SV *attr, SV *value, void *_) |
|
52
|
|
|
|
|
|
|
{ |
|
53
|
1
|
50
|
|
|
|
|
if(!hv_fetchs(GvHV(PL_hintgv), "t::stages/filter_attr-capture", 0)) |
|
54
|
|
|
|
|
|
|
return FALSE; |
|
55
|
|
|
|
|
|
|
|
|
56
|
1
|
|
|
|
|
|
AV *av = newAV(); |
|
57
|
1
|
|
|
|
|
|
av_push(av, SvREFCNT_inc(attr)); |
|
58
|
1
|
|
|
|
|
|
av_push(av, SvREFCNT_inc(value)); |
|
59
|
|
|
|
|
|
|
|
|
60
|
1
|
|
|
|
|
|
sv_setrv_noinc(get_sv("t::stages::captured", GV_ADD), (SV *)av); |
|
61
|
1
|
|
|
|
|
|
return TRUE; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
static const struct XSParseSublikeHooks parse_stages_hooks = { |
|
65
|
|
|
|
|
|
|
.flags = XS_PARSE_SUBLIKE_FLAG_FILTERATTRS, |
|
66
|
|
|
|
|
|
|
.permit = stage_permit, |
|
67
|
|
|
|
|
|
|
.pre_subparse = stage_pre_subparse, |
|
68
|
|
|
|
|
|
|
.post_blockstart = stage_post_blockstart, |
|
69
|
|
|
|
|
|
|
.pre_blockend = stage_pre_blockend, |
|
70
|
|
|
|
|
|
|
.post_newcv = stage_post_newcv, |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
.filter_attr = stage_filter_attr, |
|
73
|
|
|
|
|
|
|
}; |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
MODULE = t::stages PACKAGE = t::stages |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
BOOT: |
|
78
|
6
|
|
|
|
|
|
boot_xs_parse_sublike(0); |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
register_xs_parse_sublike("stages", &parse_stages_hooks, NULL); |