Debian Codegraph @

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