File Coverage

t/flags.xs
Criterion Covered Total %
statement 6 8 75.0
branch 2 4 50.0
condition n/a
subroutine n/a
pod n/a
total 8 12 66.6


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, 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 no_body_post_newcv(pTHX_ struct XSParseSublikeContext *ctx, void *_)
14             {
15 1 50         if(ctx->body)
16 0           croak("Expected no_body to have ctx->body == NULL");
17 1 50         if(ctx->cv)
18 0           croak("Expected no_body to have ctx->cv == NULL");
19              
20 1           sv_setsv(get_sv("t::flags::captured_name", GV_ADD), ctx->name);
21 1           }
22              
23             static const struct XSParseSublikeHooks parse_no_body_hooks = {
24             .permit_hintkey = "t::flags/no_body",
25             .flags = XS_PARSE_SUBLIKE_FLAG_BODY_OPTIONAL,
26              
27             .post_newcv = no_body_post_newcv,
28             };
29              
30             MODULE = t::flags PACKAGE = t::flags
31              
32             BOOT:
33 1           boot_xs_parse_sublike(0);
34              
35             register_xs_parse_sublike("no_body", &parse_no_body_hooks, NULL);