| 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, 2021 -- [email protected] |
| 5 |
*/ |
| 6 |
|
| 7 |
#include "EXTERN.h" |
| 8 |
#include "perl.h" |
| 9 |
#include "XSUB.h" |
| 10 |
|
| 11 |
#include "XSParseKeyword.h" |
| 12 |
|
| 13 |
static bool permit_stages(pTHX_ void *hookdata) |
| 14 |
{ |
| 15 |
HV *hints = GvHV(PL_hintgv); |
| 16 |
if(hv_fetchs(hints, "t::stages/permitfunc", 0)) |
| 17 |
return TRUE; |
| 18 |
|
| 19 |
return FALSE; |
| 20 |
} |
| 21 |
|
| 22 |
static void check_stages(pTHX_ void *hookdata) |
| 23 |
{ |
| 24 |
if(hv_fetchs(GvHV(PL_hintgv), "t::stages/check-capture", 0)) { |
| 25 |
sv_setsv(get_sv("t::stages::captured", GV_ADD), get_sv("main::VAR", 0)); |
| 26 |
} |
| 27 |
} |
| 28 |
|
| 29 |
static int parse_stages(pTHX_ OP **out, void *hookdata) |
| 30 |
{ |
| 31 |
/* Parse and ignore a block */ |
| 32 |
OP *block = parse_block(0); |
| 33 |
op_free(block); |
| 34 |
|
| 35 |
*out = newSVOP(OP_CONST, 0, newSVpvs("STAGE")); |
| 36 |
return KEYWORD_PLUGIN_EXPR; |
| 37 |
} |
| 38 |
|
| 39 |
static const struct XSParseKeywordHooks hooks_stages = { |
| 40 |
.permit_hintkey = "t::stages/permitkey", |
| 41 |
.permit = &permit_stages, |
| 42 |
|
| 43 |
.check = &check_stages, |
| 44 |
|
| 45 |
.parse = &parse_stages, |
| 46 |
}; |
| 47 |
|
| 48 |
MODULE = t::stages PACKAGE = t::stages |
| 49 |
|
| 50 |
BOOT: |
| 51 |
boot_xs_parse_keyword(0); |
| 52 |
|
| 53 |
register_xs_parse_keyword("stages", &hooks_stages, NULL); |