File: flags.xs

package info (click to toggle)
libxs-parse-sublike-perl 0.37-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 516 kB
  • sloc: ansic: 944; perl: 930; sh: 6; makefile: 3
file content (36 lines) | stat: -rw-r--r-- 963 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*  You may distribute under the terms of either the GNU General Public License
 *  or the Artistic License (the same terms as Perl itself)
 *
 *  (C) Paul Evans, 2020 -- leonerd@leonerd.org.uk
 */

#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"

#include "XSParseSublike.h"

static void no_body_post_newcv(pTHX_ struct XSParseSublikeContext *ctx, void *_)
{
  if(ctx->body)
    croak("Expected no_body to have ctx->body == NULL");
  if(ctx->cv)
    croak("Expected no_body to have ctx->cv == NULL");

  sv_setsv(get_sv("t::flags::captured_name", GV_ADD), ctx->name);
}

static const struct XSParseSublikeHooks parse_no_body_hooks = {
  .ver            = XSPARSESUBLIKE_ABI_VERSION,
  .permit_hintkey = "t::flags/no_body",
  .flags = XS_PARSE_SUBLIKE_FLAG_BODY_OPTIONAL,

  .post_newcv = no_body_post_newcv,
};

MODULE = t::flags  PACKAGE = t::flags

BOOT:
  boot_xs_parse_sublike(0);

  register_xs_parse_sublike("no_body", &parse_no_body_hooks, NULL);