| 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 red_pre_blockend(pTHX_ struct XSParseSublikeContext *ctx, void *_) |
|
14
|
|
|
|
|
|
|
{ |
|
15
|
|
|
|
|
|
|
/* Throw away the entire function body; replace it with a constant */ |
|
16
|
1
|
|
|
|
|
|
op_free(ctx->body); |
|
17
|
1
|
|
|
|
|
|
ctx->body = newSVOP(OP_CONST, 0, newSVpv("red", 0)); |
|
18
|
1
|
|
|
|
|
|
} |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
static const struct XSParseSublikeHooks parse_red_hooks = { |
|
21
|
|
|
|
|
|
|
.permit_hintkey = "t::registrations/red", |
|
22
|
|
|
|
|
|
|
.pre_blockend = red_pre_blockend, |
|
23
|
|
|
|
|
|
|
}; |
|
24
|
|
|
|
|
|
|
|
|
25
|
1
|
|
|
|
|
|
static void blue_pre_blockend(pTHX_ struct XSParseSublikeContext *ctx, void *_) |
|
26
|
|
|
|
|
|
|
{ |
|
27
|
|
|
|
|
|
|
/* Throw away the entire function body; replace it with a constant */ |
|
28
|
1
|
|
|
|
|
|
op_free(ctx->body); |
|
29
|
1
|
|
|
|
|
|
ctx->body = newSVOP(OP_CONST, 0, newSVpv("blue", 0)); |
|
30
|
1
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
static const struct XSParseSublikeHooks parse_blue_hooks = { |
|
33
|
|
|
|
|
|
|
.permit_hintkey = "t::registrations/blue", |
|
34
|
|
|
|
|
|
|
.pre_blockend = blue_pre_blockend, |
|
35
|
|
|
|
|
|
|
}; |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
MODULE = t::registrations PACKAGE = t::registrations |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
BOOT: |
|
40
|
1
|
|
|
|
|
|
boot_xs_parse_sublike(0); |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
register_xs_parse_sublike("func", &parse_red_hooks, NULL); |
|
43
|
|
|
|
|
|
|
register_xs_parse_sublike("func", &parse_blue_hooks, NULL); |