Debian Codegraph @

t/actions.xs

raw
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 "XSParseSublike.h"
12
13 static void action_pre_subparse(pTHX_ struct XSParseSublikeContext *ctx, void *_)
14 {
15 const char *namestr = SvPVX(ctx->name);
16
17 if(strchr(namestr, 'i'))
18 ctx->actions &= ~XS_PARSE_SUBLIKE_ACTION_INSTALL_SYMBOL;
19 if(strchr(namestr, 'R'))
20 ctx->actions |= XS_PARSE_SUBLIKE_ACTION_REFGEN_ANONCODE;
21 if(strchr(namestr, 'E'))
22 ctx->actions |= XS_PARSE_SUBLIKE_ACTION_RET_EXPR;
23 }
24
25 static const struct XSParseSublikeHooks parse_action_hooks = {
26 .ver = XSPARSESUBLIKE_ABI_VERSION,
27 .permit_hintkey = "t::actions/action",
28 .flags = XS_PARSE_SUBLIKE_COMPAT_FLAG_DYNAMIC_ACTIONS,
29 .require_parts = XS_PARSE_SUBLIKE_PART_NAME,
30
31 .pre_subparse = action_pre_subparse,
32 };
33
34 MODULE = t::actions PACKAGE = t::actions
35
36 BOOT:
37 boot_xs_parse_sublike(0);
38
39 register_xs_parse_sublike("action", &parse_action_hooks, NULL);