File: build.xs

package info (click to toggle)
libxs-parse-keyword-perl 0.48-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 572 kB
  • sloc: ansic: 2,037; perl: 1,013; sh: 6; makefile: 3
file content (39 lines) | stat: -rw-r--r-- 927 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
/*  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, 2021 -- leonerd@leonerd.org.uk
 */

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

#include "XSParseKeyword.h"

static int build(pTHX_ OP **out, XSParseKeywordPiece *args[], size_t nargs, void *hookdata)
{
  /* concat the exprs together */
  *out = newBINOP(OP_CONCAT, 0,
    newBINOP(OP_CONCAT, 0, args[0]->op, newSVOP(OP_CONST, 0, newSVpvs("|"))),
    args[1]->op);

  return KEYWORD_PLUGIN_EXPR;
}

static const struct XSParseKeywordHooks hooks_build = {
  .permit_hintkey = "t::build/permit",

  .pieces = (const struct XSParseKeywordPieceType []){
    XPK_BLOCK,
    XPK_TERMEXPR,
    {0}
  },
  .build = &build,
};

MODULE = t::build  PACKAGE = t::build

BOOT:
  boot_xs_parse_keyword(0);

  register_xs_parse_keyword("build", &hooks_build, NULL);