File: parts.xs

package info (click to toggle)
libxs-parse-sublike-perl 0.37-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 516 kB
  • sloc: ansic: 944; perl: 930; sh: 6; makefile: 3
file content (44 lines) | stat: -rw-r--r-- 1,240 bytes parent folder | download | duplicates (2)
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
37
38
39
40
41
42
43
44
/*  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 bool parts_permit(pTHX_ void *_);

static struct XSParseSublikeHooks parse_parts_hooks = {
  .ver    = XSPARSESUBLIKE_ABI_VERSION,
  .permit = parts_permit,
};

static bool parts_permit(pTHX_ void *_)
{
  parse_parts_hooks.require_parts = 0;
  parse_parts_hooks.skip_parts     = 0;

  if(hv_fetchs(GvHV(PL_hintgv), "t::parts/require-name", 0))
    parse_parts_hooks.require_parts |= XS_PARSE_SUBLIKE_PART_NAME;
  if(hv_fetchs(GvHV(PL_hintgv), "t::parts/skip-name", 0))
    parse_parts_hooks.skip_parts |= XS_PARSE_SUBLIKE_PART_NAME;

  if(hv_fetchs(GvHV(PL_hintgv), "t::parts/skip-attrs", 0))
    parse_parts_hooks.skip_parts |= XS_PARSE_SUBLIKE_PART_ATTRS;

  if(hv_fetchs(GvHV(PL_hintgv), "t::parts/skip-signature", 0))
    parse_parts_hooks.skip_parts |= XS_PARSE_SUBLIKE_PART_SIGNATURE;

  return TRUE;
}

MODULE = t::parts  PACKAGE = t::parts

BOOT:
  boot_xs_parse_sublike(0);

  register_xs_parse_sublike("parts", &parse_parts_hooks, NULL);