-
Notifications
You must be signed in to change notification settings - Fork 17
/
RE2.xs
52 lines (44 loc) · 1.39 KB
/
RE2.xs
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
46
47
48
49
50
51
52
#include "re2_xs.h"
#include "ppport.h"
MODULE = re::engine::RE2 PACKAGE = re::engine::RE2
PROTOTYPES: ENABLE
void
ENGINE(...)
PROTOTYPE:
PPCODE:
XPUSHs(sv_2mortal(newSViv(PTR2IV(&re2_engine))));
# Use a typemap for this maybe, especially if we add more methods like it!
void
possible_match_range(SV *self, STRLEN len = 10)
PROTOTYPE:
PPCODE:
REGEXP* rx;
SV *possible_min, *possible_max;
if(!SvROK(self) || 0 != strcmp("re::engine::RE2", sv_reftype(SvRV(self), TRUE)))
croak("qr// reference to a re::engine::RE2 instance required");
rx = SvRX(self);
RE2_possible_match_range(aTHX_ rx, len, &possible_min, &possible_max);
mXPUSHs(possible_min);
mXPUSHs(possible_max);
HV*
named_captures(SV *self)
PROTOTYPE:
CODE:
REGEXP* rx;
if(!SvROK(self) || 0 != strcmp("re::engine::RE2", sv_reftype(SvRV(self), TRUE)))
croak("qr// reference to a re::engine::RE2 instance required");
rx = SvRX(self);
RETVAL = RE2_named_captures(aTHX_ rx);
OUTPUT:
RETVAL
int
number_of_capture_groups(SV *self)
PROTOTYPE:
CODE:
REGEXP* rx;
if(!SvROK(self) || 0 != strcmp("re::engine::RE2", sv_reftype(SvRV(self), TRUE)))
croak("qr// reference to a re::engine::RE2 instance required");
rx = SvRX(self);
RETVAL = RE2_number_of_capture_groups(aTHX_ rx);
OUTPUT:
RETVAL