File Coverage

t/actions.xs
Criterion Covered Total %
statement 10 10 100.0
branch 6 6 100.0
condition n/a
subroutine n/a
pod n/a
total 16 16 100.0


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