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-2023 -- 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
|
|
|
|
|
|
|
#ifndef wrap_keyword_plugin |
14
|
|
|
|
|
|
|
# include "wrap_keyword_plugin.c.inc" |
15
|
|
|
|
|
|
|
#endif |
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
|
|
|
static void func_pre_subparse(pTHX_ struct XSParseSublikeContext *ctx, void *_logsv) |
18
|
|
|
|
|
|
|
{ |
19
|
|
|
|
|
|
|
SV *logsv = _logsv; |
20
|
1
|
|
|
|
|
|
sv_catpvs(logsv, "Sf"); |
21
|
1
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
|
|
|
static void func_post_blockstart(pTHX_ struct XSParseSublikeContext *ctx, void *_logsv) |
24
|
|
|
|
|
|
|
{ |
25
|
|
|
|
|
|
|
SV *logsv = _logsv; |
26
|
1
|
|
|
|
|
|
sv_catpvs(logsv, "Ef"); |
27
|
1
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
|
static void func_pre_blockend(pTHX_ struct XSParseSublikeContext *ctx, void *_logsv) |
30
|
|
|
|
|
|
|
{ |
31
|
|
|
|
|
|
|
SV *logsv = _logsv; |
32
|
1
|
|
|
|
|
|
sv_catpvs(logsv, "Lf"); |
33
|
1
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
1
|
|
|
|
|
|
static void func_post_newcv(pTHX_ struct XSParseSublikeContext *ctx, void *_logsv) |
36
|
|
|
|
|
|
|
{ |
37
|
|
|
|
|
|
|
SV *logsv = _logsv; |
38
|
1
|
|
|
|
|
|
sv_catpvs(logsv, "Nf"); |
39
|
1
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
static const struct XSParseSublikeHooks parse_func_hooks = { |
42
|
|
|
|
|
|
|
.permit_hintkey = "t::any/func", |
43
|
|
|
|
|
|
|
.pre_subparse = func_pre_subparse, |
44
|
|
|
|
|
|
|
.post_blockstart = func_post_blockstart, |
45
|
|
|
|
|
|
|
.pre_blockend = func_pre_blockend, |
46
|
|
|
|
|
|
|
.post_newcv = func_post_newcv, |
47
|
|
|
|
|
|
|
}; |
48
|
|
|
|
|
|
|
|
49
|
1
|
|
|
|
|
|
static void prefixed_pre_subparse(pTHX_ struct XSParseSublikeContext *ctx, void *_logsv) |
50
|
|
|
|
|
|
|
{ |
51
|
|
|
|
|
|
|
SV *logsv = _logsv; |
52
|
1
|
|
|
|
|
|
sv_catpvs(logsv, "Sp"); |
53
|
1
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
1
|
|
|
|
|
|
static void prefixed_post_blockstart(pTHX_ struct XSParseSublikeContext *ctx, void *_logsv) |
56
|
|
|
|
|
|
|
{ |
57
|
|
|
|
|
|
|
SV *logsv = _logsv; |
58
|
1
|
|
|
|
|
|
sv_catpvs(logsv, "Ep"); |
59
|
1
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
1
|
|
|
|
|
|
static void prefixed_pre_blockend(pTHX_ struct XSParseSublikeContext *ctx, void *_logsv) |
62
|
|
|
|
|
|
|
{ |
63
|
|
|
|
|
|
|
SV *logsv = _logsv; |
64
|
1
|
|
|
|
|
|
sv_catpvs(logsv, "Lp"); |
65
|
1
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
1
|
|
|
|
|
|
static void prefixed_post_newcv(pTHX_ struct XSParseSublikeContext *ctx, void *_logsv) |
68
|
|
|
|
|
|
|
{ |
69
|
|
|
|
|
|
|
SV *logsv = _logsv; |
70
|
1
|
|
|
|
|
|
sv_catpvs(logsv, "Np"); |
71
|
1
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
static const struct XSParseSublikeHooks parse_prefixed_hooks = { |
74
|
|
|
|
|
|
|
.pre_subparse = prefixed_pre_subparse, |
75
|
|
|
|
|
|
|
.post_blockstart = prefixed_post_blockstart, |
76
|
|
|
|
|
|
|
.pre_blockend = prefixed_pre_blockend, |
77
|
|
|
|
|
|
|
.post_newcv = prefixed_post_newcv, |
78
|
|
|
|
|
|
|
}; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
static int (*next_keyword_plugin)(pTHX_ char *, STRLEN, OP **); |
81
|
|
|
|
|
|
|
|
82
|
1283
|
|
|
|
|
|
static int my_keyword_plugin(pTHX_ char *kw, STRLEN kwlen, OP **op_ptr) |
83
|
|
|
|
|
|
|
{ |
84
|
1283
|
100
|
|
|
|
|
if(kwlen != 8 || !strEQ(kw, "prefixed")) |
|
|
100
|
|
|
|
|
|
85
|
1282
|
|
|
|
|
|
return (*next_keyword_plugin)(aTHX_ kw, kwlen, op_ptr); |
86
|
|
|
|
|
|
|
|
87
|
1
|
|
|
|
|
|
lex_read_space(0); |
88
|
|
|
|
|
|
|
|
89
|
2
|
|
|
|
|
|
return xs_parse_sublike_any(&parse_prefixed_hooks, SvREFCNT_inc(get_sv("main::LOG", 0)), |
90
|
|
|
|
|
|
|
op_ptr); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
MODULE = t::any PACKAGE = t::any |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
BOOT: |
96
|
1
|
|
|
|
|
|
boot_xs_parse_sublike(0); |
97
|
|
|
|
|
|
|
|
98
|
1
|
|
|
|
|
|
register_xs_parse_sublike("func", &parse_func_hooks, SvREFCNT_inc(get_sv("main::LOG", GV_ADD))); |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
wrap_keyword_plugin(&my_keyword_plugin, &next_keyword_plugin); |