Skip to content

Commit 15d28b9

Browse files
committed
XS: new parrser
Signed-off-by: Masatake YAMATO <[email protected]>
1 parent aec0a1d commit 15d28b9

File tree

19 files changed

+855
-9
lines changed

19 files changed

+855
-9
lines changed

Tmain/extras-long.d/run.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,27 @@
33

44
CTAGS=$1
55

6+
ignore_pcre2()
7+
{
8+
grep -v 'XS'
9+
}
10+
611
echo '# resetting'
712
${CTAGS} --quiet --options=NONE --with-list-header=no \
8-
--extras='{subparser}' --list-extras
13+
--extras='{subparser}' --list-extras | ignore_pcre2
914

1015
echo '# enabling 1'
1116
${CTAGS} --quiet --options=NONE --with-list-header=no \
12-
--extras=+'{pseudo}' --list-extras
17+
--extras=+'{pseudo}' --list-extras | ignore_pcre2
1318

1419
echo '# disabling 1'
1520
${CTAGS} --quiet --options=NONE --with-list-header=no \
16-
--extras=-'{fileScope}' --list-extras
21+
--extras=-'{fileScope}' --list-extras | ignore_pcre2
1722

1823
echo '# combination'
1924
${CTAGS} --quiet --options=NONE --with-list-header=no \
20-
--extras=-'{fileScope}+{inputFile}{reference}' --list-extras
25+
--extras=-'{fileScope}+{inputFile}{reference}' --list-extras | ignore_pcre2
2126

2227
echo '# combination with letters'
2328
${CTAGS} --quiet --options=NONE --with-list-header=no \
24-
--extras=-'{fileScope}+p{inputFile}q{reference}-f' --list-extras
29+
--extras=-'{fileScope}+p{inputFile}q{reference}-f' --list-extras | ignore_pcre2

Tmain/list-roles.d/run.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ ignore_yaml()
2323
grep -v 'Yaml'
2424
}
2525

26+
ignore_pcre2()
27+
{
28+
grep -v 'XS'
29+
}
30+
2631
# When introducing newly rewritten parser, we would like to provide
2732
# the both new parser and old parser for debugging and providing
2833
# migration period to users. In such case the prefix "Old" will be
@@ -34,16 +39,16 @@ ignore_old()
3439
}
3540

3641
title ''
37-
${CTAGS} --quiet --options=NONE --list-roles= | ignore_xml | ignore_old | ignore_yaml
42+
${CTAGS} --quiet --options=NONE --list-roles= | ignore_xml | ignore_old | ignore_yaml | ignore_pcre2
3843

3944
title 'all.*'
40-
${CTAGS} --quiet --options=NONE --list-roles='all.*' | ignore_xml | ignore_old | ignore_yaml
45+
${CTAGS} --quiet --options=NONE --list-roles='all.*' | ignore_xml | ignore_old | ignore_yaml | ignore_pcre2
4146

4247
title 'C.*'
4348
${CTAGS} --quiet --options=NONE --list-roles='C.*'
4449

4550
title 'all.d'
46-
${CTAGS} --quiet --options=NONE --list-roles='all.d' | ignore_xml | ignore_old | ignore_yaml
51+
${CTAGS} --quiet --options=NONE --list-roles='all.d' | ignore_xml | ignore_old | ignore_yaml | ignore_pcre2
4752

4853
title 'Sh.s'
4954
${CTAGS} --quiet --options=NONE --list-roles='Sh.s'
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--sort=no
2+
--extras-XS=-{noprefix}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
X input.xs /^MODULE = X PACKAGE = X PREFIX = xyz_$/;" m
2+
X input.xs /^MODULE = X PACKAGE = X PREFIX = xyz_$/;" p module:X
3+
xyz_f input.xs /^xyz_f(dbtype)$/;" f package:X.X typeref:typename:void
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pcre2
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
MODULE = X PACKAGE = X PREFIX = xyz_
2+
3+
void
4+
xyz_f(dbtype)
5+
char * dbtype

Units/parser-xs.r/pod.d/args.ctags

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
--sort=no
2+
--extras=+g
3+
--fields=+Sl
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
XS::Typemap input.xs /^MODULE = XS::Typemap PACKAGE = XS::Typemap$/;" m language:XS
2+
XS::Typemap input.xs /^MODULE = XS::Typemap PACKAGE = XS::Typemap$/;" p language:XS module:XS::Typemap
3+
T_SV input.xs /^T_SV( sv )$/;" f language:XS package:XS::Typemap.XS::Typemap typeref:typename:SV * signature:(SV * sv)
4+
T_SVREF input.xs /^T_SVREF( svref )$/;" f language:XS package:XS::Typemap.XS::Typemap typeref:typename:SVREF signature:(SVREF svref)
5+
intArrayPtr input.xs /^intArray * intArrayPtr( int nelem ) {$/;" f language:C typeref:typename:intArray * signature:(int nelem)
6+
TYPEMAPS input.xs /^=head1 TYPEMAPS$/;" c language:Pod

Units/parser-xs.r/pod.d/features

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pcre2

Units/parser-xs.r/pod.d/input.xs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/* Taken from perl-5.10.1/ext/XS-Typemap/Typemap.xs */
2+
3+
/* T_ARRAY - allocate some memory */
4+
intArray * intArrayPtr( int nelem ) {
5+
intArray * array;
6+
Newx(array, nelem, intArray);
7+
return array;
8+
}
9+
10+
11+
MODULE = XS::Typemap PACKAGE = XS::Typemap
12+
13+
PROTOTYPES: DISABLE
14+
15+
=head1 TYPEMAPS
16+
17+
Each C type is represented by an entry in the typemap file that
18+
is responsible for converting perl variables (SV, AV, HV and CV) to
19+
and from that type.
20+
21+
=over 4
22+
23+
=item T_SV
24+
25+
This simply passes the C representation of the Perl variable (an SV*)
26+
in and out of the XS layer. This can be used if the C code wants
27+
to deal directly with the Perl variable.
28+
29+
=cut
30+
31+
SV *
32+
T_SV( sv )
33+
SV * sv
34+
CODE:
35+
/* create a new sv for return that is a copy of the input
36+
do not simply copy the pointer since the SV will be marked
37+
mortal by the INPUT typemap when it is pushed back onto the stack */
38+
RETVAL = sv_mortalcopy( sv );
39+
/* increment the refcount since the default INPUT typemap mortalizes
40+
by default and we don't want to decrement the ref count twice
41+
by mistake */
42+
SvREFCNT_inc(RETVAL);
43+
OUTPUT:
44+
RETVAL
45+
46+
=item T_SVREF
47+
48+
Used to pass in and return a reference to an SV.
49+
50+
=cut
51+
52+
SVREF
53+
T_SVREF( svref )
54+
SVREF svref
55+
CODE:
56+
RETVAL = svref;
57+
OUTPUT:
58+
RETVAL
59+

0 commit comments

Comments
 (0)