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
|
1
|
|
|
|
|
|
static void func_pre_subparse(pTHX_ struct XSParseSublikeContext *ctx, void *_logsv) |
14
|
|
|
|
|
|
|
{ |
15
|
|
|
|
|
|
|
SV *logsv = _logsv; |
16
|
1
|
|
|
|
|
|
sv_catpvs(logsv, "Sf"); |
17
|
1
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
|
|
|
static void func_post_blockstart(pTHX_ struct XSParseSublikeContext *ctx, void *_logsv) |
20
|
|
|
|
|
|
|
{ |
21
|
|
|
|
|
|
|
SV *logsv = _logsv; |
22
|
1
|
|
|
|
|
|
sv_catpvs(logsv, "Ef"); |
23
|
1
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
|
|
|
static void func_pre_blockend(pTHX_ struct XSParseSublikeContext *ctx, void *_logsv) |
26
|
|
|
|
|
|
|
{ |
27
|
|
|
|
|
|
|
SV *logsv = _logsv; |
28
|
1
|
|
|
|
|
|
sv_catpvs(logsv, "Lf"); |
29
|
1
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
|
static void func_post_newcv(pTHX_ struct XSParseSublikeContext *ctx, void *_logsv) |
32
|
|
|
|
|
|
|
{ |
33
|
|
|
|
|
|
|
SV *logsv = _logsv; |
34
|
1
|
|
|
|
|
|
sv_catpvs(logsv, "Nf"); |
35
|
1
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
static const struct XSParseSublikeHooks parse_func_hooks = { |
38
|
|
|
|
|
|
|
.permit_hintkey = "t::prefix/func", |
39
|
|
|
|
|
|
|
.pre_subparse = func_pre_subparse, |
40
|
|
|
|
|
|
|
.post_blockstart = func_post_blockstart, |
41
|
|
|
|
|
|
|
.pre_blockend = func_pre_blockend, |
42
|
|
|
|
|
|
|
.post_newcv = func_post_newcv, |
43
|
|
|
|
|
|
|
}; |
44
|
|
|
|
|
|
|
|
45
|
1
|
|
|
|
|
|
static void prefixed_pre_subparse(pTHX_ struct XSParseSublikeContext *ctx, void *_logsv) |
46
|
|
|
|
|
|
|
{ |
47
|
|
|
|
|
|
|
SV *logsv = _logsv; |
48
|
1
|
|
|
|
|
|
sv_catpvs(logsv, "Sp"); |
49
|
1
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
1
|
|
|
|
|
|
static void prefixed_post_blockstart(pTHX_ struct XSParseSublikeContext *ctx, void *_logsv) |
52
|
|
|
|
|
|
|
{ |
53
|
|
|
|
|
|
|
SV *logsv = _logsv; |
54
|
1
|
|
|
|
|
|
sv_catpvs(logsv, "Ep"); |
55
|
1
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
1
|
|
|
|
|
|
static void prefixed_pre_blockend(pTHX_ struct XSParseSublikeContext *ctx, void *_logsv) |
58
|
|
|
|
|
|
|
{ |
59
|
|
|
|
|
|
|
SV *logsv = _logsv; |
60
|
1
|
|
|
|
|
|
sv_catpvs(logsv, "Lp"); |
61
|
1
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
1
|
|
|
|
|
|
static void prefixed_post_newcv(pTHX_ struct XSParseSublikeContext *ctx, void *_logsv) |
64
|
|
|
|
|
|
|
{ |
65
|
|
|
|
|
|
|
SV *logsv = _logsv; |
66
|
1
|
|
|
|
|
|
sv_catpvs(logsv, "Np"); |
67
|
1
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
static const struct XSParseSublikeHooks parse_prefixed_hooks = { |
70
|
|
|
|
|
|
|
.flags = XS_PARSE_SUBLIKE_FLAG_PREFIX, |
71
|
|
|
|
|
|
|
.permit_hintkey = "t::prefix/prefixed", |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
.pre_subparse = prefixed_pre_subparse, |
74
|
|
|
|
|
|
|
.post_blockstart = prefixed_post_blockstart, |
75
|
|
|
|
|
|
|
.pre_blockend = prefixed_pre_blockend, |
76
|
|
|
|
|
|
|
.post_newcv = prefixed_post_newcv, |
77
|
|
|
|
|
|
|
}; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
MODULE = t::prefix PACKAGE = t::prefix |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
BOOT: |
82
|
1
|
|
|
|
|
|
boot_xs_parse_sublike(0); |
83
|
|
|
|
|
|
|
|
84
|
1
|
|
|
|
|
|
register_xs_parse_sublike("func", &parse_func_hooks, SvREFCNT_inc(get_sv("main::LOG", GV_ADD))); |
85
|
1
|
|
|
|
|
|
register_xs_parse_sublike("prefixed", &parse_prefixed_hooks, SvREFCNT_inc(get_sv("main::LOG", GV_ADD))); |