| 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 |
▶ | if(ctx->body) |
Branch: 1 branch
| Branch | True | False | Total |
| if(ctx->body) |
0 |
1 |
1 |
|
| 16 |
0 |
| croak("Expected no_body to have ctx->body == NULL"); |
| 17 |
1 |
▶ | if(ctx->cv) |
Branch: 1 branch
| Branch | True | False | Total |
| if(ctx->cv) |
0 |
1 |
1 |
|
| 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 |
|
| .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 |
1 |
| boot_xs_parse_sublike(0); |
| 35 |
|
| |
| 36 |
1 |
| register_xs_parse_sublike("no_body", &parse_no_body_hooks, NULL); |