File: registrations.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 (45 lines) | stat: -rw-r--r-- 1,353 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
37
38
39
40
41
42
43
44
45
/*  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 red_pre_blockend(pTHX_ struct XSParseSublikeContext *ctx, void *_)
{
  /* Throw away the entire function body; replace it with a constant */
  op_free(ctx->body);
  ctx->body = newSVOP(OP_CONST, 0, newSVpv("red", 0));
}

static const struct XSParseSublikeHooks parse_red_hooks = {
  .ver            = XSPARSESUBLIKE_ABI_VERSION,
  .permit_hintkey = "t::registrations/red",
  .pre_blockend = red_pre_blockend,
};

static void blue_pre_blockend(pTHX_ struct XSParseSublikeContext *ctx, void *_)
{
  /* Throw away the entire function body; replace it with a constant */
  op_free(ctx->body);
  ctx->body = newSVOP(OP_CONST, 0, newSVpv("blue", 0));
}

static const struct XSParseSublikeHooks parse_blue_hooks = {
  .ver            = XSPARSESUBLIKE_ABI_VERSION,
  .permit_hintkey = "t::registrations/blue",
  .pre_blockend = blue_pre_blockend,
};

MODULE = t::registrations  PACKAGE = t::registrations

BOOT:
  boot_xs_parse_sublike(0);

  register_xs_parse_sublike("func", &parse_red_hooks, NULL);
  register_xs_parse_sublike("func", &parse_blue_hooks, NULL);