| 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 -- [email protected] |
| 5 |
*/ |
| 6 |
|
| 7 |
#include "EXTERN.h" |
| 8 |
#include "perl.h" |
| 9 |
#include "XSUB.h" |
| 10 |
|
| 11 |
#include "XSParseSublike.h" |
| 12 |
|
| 13 |
static void red_pre_blockend(pTHX_ struct XSParseSublikeContext *ctx, void *_) |
| 14 |
{ |
| 15 |
/* Throw away the entire function body; replace it with a constant */ |
| 16 |
op_free(ctx->body); |
| 17 |
ctx->body = newSVOP(OP_CONST, 0, newSVpv("red", 0)); |
| 18 |
} |
| 19 |
|
| 20 |
static const struct XSParseSublikeHooks parse_red_hooks = { |
| 21 |
.ver = XSPARSESUBLIKE_ABI_VERSION, |
| 22 |
.permit_hintkey = "t::registrations/red", |
| 23 |
.pre_blockend = red_pre_blockend, |
| 24 |
}; |
| 25 |
|
| 26 |
static void blue_pre_blockend(pTHX_ struct XSParseSublikeContext *ctx, void *_) |
| 27 |
{ |
| 28 |
/* Throw away the entire function body; replace it with a constant */ |
| 29 |
op_free(ctx->body); |
| 30 |
ctx->body = newSVOP(OP_CONST, 0, newSVpv("blue", 0)); |
| 31 |
} |
| 32 |
|
| 33 |
static const struct XSParseSublikeHooks parse_blue_hooks = { |
| 34 |
.ver = XSPARSESUBLIKE_ABI_VERSION, |
| 35 |
.permit_hintkey = "t::registrations/blue", |
| 36 |
.pre_blockend = blue_pre_blockend, |
| 37 |
}; |
| 38 |
|
| 39 |
MODULE = t::registrations PACKAGE = t::registrations |
| 40 |
|
| 41 |
BOOT: |
| 42 |
boot_xs_parse_sublike(0); |
| 43 |
|
| 44 |
register_xs_parse_sublike("func", &parse_red_hooks, NULL); |
| 45 |
register_xs_parse_sublike("func", &parse_blue_hooks, NULL); |