| 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 | .ver = XSPARSESUBLIKE_ABI_VERSION, | ||
| 22 | .permit_hintkey = "t::registrations/red", | ||
| 23 | .pre_blockend = red_pre_blockend, | ||
| 24 | }; | ||
| 25 | |||
| 26 | 1 | static void blue_pre_blockend(pTHX_ struct XSParseSublikeContext *ctx, void *_) | |
| 27 | { | ||
| 28 | /* Throw away the entire function body; replace it with a constant */ | ||
| 29 | 1 | op_free(ctx->body); | |
| 30 | 1 | ctx->body = newSVOP(OP_CONST, 0, newSVpv("blue", 0)); | |
| 31 | 1 | } | |
| 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 | 1 | boot_xs_parse_sublike(0); | |
| 43 | |||
| 44 | 1 | register_xs_parse_sublike("func", &parse_red_hooks, NULL); | |
| 45 | 1 | register_xs_parse_sublike("func", &parse_blue_hooks, NULL); |