Skip to content

Commit 8dc934f

Browse files
committed
perlxs.pod: standardise version numbers in the doc
After the big rewrite, various bits of text which describe when a particular feature was introduced or changed have ended up using a random mixture of Perl, ParseXS and xsubpp version numbers. This commit standardises on xsubpp version numbers. These are mostly the same as ParseXS, but this handles the cases before ParseXS was split off from xsubpp. Perl versions suffer from not exactly matching when an xsubpp version number was incremented, and not matching what is used by the "REQUIRE:" keyword. This commit also adds a short new section which tries to explain how the three sets of version numbers are related.
1 parent ae80012 commit 8dc934f

File tree

2 files changed

+76
-53
lines changed

2 files changed

+76
-53
lines changed

dist/ExtUtils-ParseXS/lib/perlxs.pod

Lines changed: 75 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,32 @@ Various old practices, such as "K&R" XSUB function signature declarations,
7878
are no longer encouraged; but much old code will still be using them, so
7979
be cautious when using old code as examples for writing new code.
8080

81-
The syntax described in this document is valid for Perl installations back
82-
to 5.8.0 unless otherwise specified.
81+
=head2 Version numbers
82+
83+
Unless otherwise specified, the syntax described in this document is valid
84+
at least as far back as the 1.9508 version of the XS parser utility
85+
F<xsubpp>, which was bundled with Perl release 5.8.0.
86+
87+
In F<xsubpp> version 2.09_01, the bulk of the code for this utility was
88+
split out into a separate module, L<ExtUtils::ParseXS>. This module
89+
inherited the version numbering scheme of F<xsubpp>, and since then, the
90+
latter just uses the version number of the F<ParseXS.pm> which gets
91+
loaded. This splitting out means that a newer version of
92+
F<ExtUtils::ParseXS> can be installed via CPAN into an older Perl
93+
installation, allowing newer XS syntax to be used with older Perls.
94+
95+
(Between 1.98_01 and 2.09_01, F<ExtUtils::ParseXS> existed as a separate
96+
fork of F<xsubpp>, with some changes ported back and forwards with the
97+
perl distribution's F<xsubpp>, in a confusing manner.)
98+
99+
This document refers to changes in XS syntax by reference to F<xsubpp>
100+
version numbers. This should be understood as usually mapping directly to
101+
the same version number of F<ExtUtils::ParseXS>. To determine which
102+
version of this module was bundled with which release of Perl, you can use
103+
the F<corelist> utility which is usually a part of the Perl installation,
104+
e.g.
105+
106+
corelist -a ExtUtils::ParseXS
83107

84108
=head1 THE FORMAL SYNTAX OF AN XS FILE
85109

@@ -197,7 +221,7 @@ accurately specify where line breaks can occur.
197221
| xbody_generic_key
198222
| c_args
199223
| interface_macro
200-
| "SCOPE:" enable // Only in perl 5.44.0 onwards.
224+
| "SCOPE:" enable // Only in xsubpp 3.58 onwards.
201225

202226
input_line = C_type
203227
"&" ?
@@ -422,7 +446,7 @@ forth between Perl arguments and C auto variables.
422446

423447
There is a standard system typemap file which contains rules for common C
424448
and Perl types, but you can add your own typemap file in addition, and
425-
from perl 5.16.0 onwards you can also add typemap declarations inline
449+
from F<xsubpp> 3.01 onwards you can also add typemap declarations inline
426450
within the XS file. You can either just add mappings from new C types to
427451
existing XS types to make use of existing templates, or you can add new
428452
templates too. As an example of the former, if you're using a C header
@@ -583,9 +607,9 @@ appears to be a parameter name, and assumes that it must be the type. That
583607
will only then raise an error.
584608

585609
In addition, the XS parser has historically been very permissive, even to
586-
the point of accepting nonsense as input. Since Perl 5.44, more things are
587-
likely to warn or raise errors during XS parsing, rather than silently
588-
generating a non-compilable C code file.
610+
the point of accepting nonsense as input. Since around F<xsubpp> releases
611+
3.54-3.61, more things are likely to warn or raise errors during XS
612+
parsing, rather than silently generating a non-compilable C code file.
589613

590614
As mentioned earlier, an XSUB definition typically starts with C</\n\n\S/>
591615
and continues until the next C</\n\n\S/>. The XSUB definition consists of
@@ -1373,9 +1397,9 @@ count one too high, it will leak. This why the C<sv_2mortal()> is
13731397
required. Conversely for a pre-existing AV, the mortalisation isn't
13741398
required.
13751399

1376-
Since perl 5.16, there are a set of alternative XS types which can be used
1377-
for AVs etc which I<don't> increment the reference count of the AV when
1378-
being pointed to from the new RV. These can be enabled by mapping the
1400+
Since F<xsubpp> 3.06, there are a set of alternative XS types which can be
1401+
used for AVs etc which I<don't> increment the reference count of the AV
1402+
when being pointed to from the new RV. These can be enabled by mapping the
13791403
C<AV*> etc C types to these new XS types:
13801404

13811405
TYPEMAP: <<EOF
@@ -1779,12 +1803,13 @@ See L<perlsub/Prototypes> for more information about Perl prototypes.
17791803

17801804
EXPORT_XSUB_SYMBOLS: ENABLE | DISABLE
17811805

1782-
This keyword is present since 5.16.0, and its value is disabled by
1806+
This keyword is present since F<xsubpp> 3.04, and its value is disabled by
17831807
default.
17841808

1785-
Before 5.16.0, the C function which implemented an XSUB was exported.
1786-
Since 5.16.0, it is declared C<static>. The old behaviour can be restored
1787-
by enabling it. You are very unlikely to have a need for this keyword.
1809+
Before 3.04, the C function which implemented an XSUB was exported. Since
1810+
3.04, it is declared C<static> by default. The old behaviour can be
1811+
restored by enabling it. You are very unlikely to have a need for this
1812+
keyword.
17881813

17891814
=head3 The INCLUDE: Keyword
17901815

@@ -1810,7 +1835,7 @@ parser.
18101835

18111836
INCLUDE_COMMAND: $^X -e '...'
18121837

1813-
Since 5.14.0.
1838+
Since F<xsubpp> 2.2205.
18141839

18151840
Similar to C<INCLUDE: some_command|> except that the C<|> is implicit, and
18161841
it converts the special token C<$^X>, if present, to the path of the perl
@@ -1828,7 +1853,7 @@ interpreter which is running the XS parser.
18281853
my_sv_setiv($arg, (IV)$var);
18291854
EOF
18301855

1831-
Since 5.16.0.
1856+
Since F<xsubpp> 3.01.
18321857

18331858
Typemaps are mappings and code templates which allow the XS parser to
18341859
automatically generate code snippets which convert between Perl and C
@@ -1896,7 +1921,7 @@ next keyword or possible start of a new XSUB (C</\n\n\S/>).
18961921

18971922
FALLBACK: TRUE | FALSE | UNDEF
18981923

1899-
Since 5.8.1.
1924+
Since F<xsubpp> 2.09_01.
19001925

19011926
It defaults to C<UNDEF> for each package. It sets the default fallback
19021927
handling behaviour for overloaded methods in the current package (i.e.
@@ -2194,9 +2219,9 @@ treated specially. A bug in the XS parser meant that it used to skip any
21942219
parameter declaration which wasn't parsable. This inadvertently made many
21952220
things de facto placeholder declarations. A common usage was C<SV*>, which
21962221
is now officially treated as a placeholder for backwards compatibility.
2197-
Any other bare types without a parameter name are errors since
2198-
C<ExtUtils::ParseXS> 3.57. Note that the C<SV*> text will appear in any
2199-
C<usage()> error message. For example,
2222+
Any other bare types without a parameter name are errors since F<xsubpp>
2223+
3.57. Note that the C<SV*> text will appear in any C<usage()> error
2224+
message. For example,
22002225

22012226
void
22022227
foo(int a, SV*, char *c)
@@ -2581,9 +2606,10 @@ allowed.
25812606

25822607
It is sometimes needed because in traditional C, all variable
25832608
declarations must come before any statements. While this is no longer a
2584-
restriction in the perl interpreter source since 5.36.0, the C compiler
2585-
flags used when compiling XS code may be different and so, depending on
2586-
the compiler, it may still be necessary to preserve the correct ordering.
2609+
restriction in the perl interpreter source since Perl 5.36.0, the C
2610+
compiler flags used when compiling XS code may be different and so,
2611+
depending on the compiler, it may still be necessary to preserve the
2612+
correct ordering.
25872613

25882614
Any variable declarations generated by C<INPUT> and lines from C<PREINIT>
25892615
are output in the same order they appear in the XS source, followed by any
@@ -2807,9 +2833,9 @@ declaration and as part of the same paragraph (i.e. with no intervening
28072833
blank lines), such as in the example above. It will only affect the single
28082834
following XSUB.
28092835

2810-
The XSUB-scoped form has been available since perl-5.004, but was broken
2811-
by perl-5.12.0 (F<xsubpp> v2.21) and fixed in perl-5.44.0 (F<xsubpp>
2812-
v3.58). The file-scoped form has been available since perl-5.12.0 .
2836+
The XSUB-scoped form has been available since F<xsubpp> 1.9506, but was
2837+
broken in release 2.21 and fixed in 3.58. The file-scoped form has been
2838+
available since 2.21.
28132839

28142840
To support potentially complex type mappings, if an C<INPUT> typemap entry
28152841
contains a code comment like C</* SCOPE */>, then scoping will be
@@ -3323,8 +3349,8 @@ and C<arg2> will have set magic, while C<arg1> won't. The C<SETMAGIC>
33233349
setting remains in force until another C<SETMAGIC>, or notionally until
33243350
the end of the current C<OUTPUT> block. In fact the current setting will
33253351
carry over into any further C<OUTPUT> declarations within in the same
3326-
XSUB, or since Perl 5.40.0, only into any declarations within the same
3327-
case C<CASE> branch.
3352+
XSUB, or since F<xsubpp> 3.58, only into any declarations within the same
3353+
C<CASE> branch.
33283354

33293355
The current setting of C<SETMAGIC> is ignored for C<RETVAL>, which is
33303356
usually setting the value of a fresh temporary SV which won't have any
@@ -3359,7 +3385,7 @@ or similar. This can be overridden; for example
33593385
But importantly, unlike the similar syntax in C<INPUT> lines, the override
33603386
text is I<not> variable expanded. It is thus tricky to ensure that the
33613387
right arguments are used (such as C<ST(0)>). Basically this feature has a
3362-
design flaw and should probably be avoided. Since 5.16.0 it's been
3388+
design flaw and should probably be avoided. Since F<xsubpp> 3.01 it's been
33633389
possible to have locally defined typemaps using the L<TYPEMAP|/The
33643390
TYPEMAP: Keyword> keyword which is probably a better way to modify how
33653391
values are returned.
@@ -3723,9 +3749,8 @@ the same value, e.g.
37233749
divide = DIVIDE
37243750
division = DIVISION
37253751

3726-
Since Perl 5.38.0 or C<ExtUtils::ParseXS> 3.51, alias values may refer to
3727-
other alias names (or to the main function name) by using C<< => >> rather
3728-
than the C<=> symbol:
3752+
Since F<xsubpp> 3.51, alias values may refer to other alias names (or to
3753+
the main function name) by using C<< => >> rather than the C<=> symbol:
37293754

37303755
ALIAS:
37313756
divide = 3
@@ -3804,15 +3829,15 @@ function; in the example above, it doesn't cause a Perl function called
38043829
C<arith()> to be created.
38053830

38063831
See L</T_PTROBJ and opaque handles> for a complete example using
3807-
C<INTERFACE> with the C<T_PTROBJ> typemap. But note that before Perl
3808-
5.44.0 (F<ExtUtils::ParseXS> 3.60), C<INTERFACE> would not work properly
3809-
on XSUBs used with Perlish return types (as used by C<T_PTROBJ>), such as
3832+
C<INTERFACE> with the C<T_PTROBJ> typemap. But note that before F<xsubpp>
3833+
3.60, C<INTERFACE> would not work properly on XSUBs used with Perlish
3834+
return types (as used by C<T_PTROBJ>), such as
38103835

38113836
Foo::Bar
38123837
foo(...)
38133838
....
38143839

3815-
This has mostly been fixed in 5.44.0 onwards, but may generate invalid C
3840+
This has mostly been fixed in 3.60 onwards, but may generate invalid C
38163841
code (in particular, invalid function pointer casts) for XSUBs having a
38173842
C<C_ARGS> keyword, unless the value of C<C_ARGS> is a simple list of
38183843
parameter names.
@@ -3970,9 +3995,9 @@ after variable expansion, generate C code to convert back and forth
39703995
between Perl arguments and C auto variables.
39713996

39723997
There is a standard system typemap file bundled with Perl for common C and
3973-
Perl types, but in addition, you can add your own typemap file. From Perl
3974-
5.16.0 onwards you can also include extra typemap declarations in-line
3975-
within the XS file.
3998+
Perl types, but in addition, you can add your own typemap file. From
3999+
F<xsubpp> 3.01 onwards you can also include extra typemap declarations
4000+
in-line within the XS file.
39764001

39774002
=head3 Locations and ordering of typemap processing
39784003

@@ -4015,13 +4040,12 @@ command line switches, or programmatically by an array passed as:
40154040
These files are read in order, and the parser dies if any explicitly
40164041
listed file is not found.
40174042

4018-
Prior to Perl 5.10.0 and Perl 5.8.9, C<@INC> wasn't searched, and standard
4019-
files were searched for and processed I<before> any explicit ones. From
4020-
Perl 5.10.0 onwards, standard files were processed I<after> any explicit
4021-
ones. From Perl 5.44.0 (F<ExtUtils::ParseXS> 3.60) onwards, explicit files
4022-
are again processed last, and thus take priority over standard files.
4023-
In Perl 5.16.0 onwards, C<TYPEMAP> sections are then processed in order
4024-
after all files have been processed.
4043+
Prior to F<xsubpp> 2.09_01, C<@INC> wasn't searched, and standard files
4044+
were searched for and processed I<before> any explicit ones. From 2.09_01
4045+
onwards, standard files were processed I<after> any explicit ones. From
4046+
3.60 onwards, explicit files are again processed last, and thus take
4047+
priority over standard files. Separately, in 3.01 onwards, C<TYPEMAP>
4048+
sections are then processed in order after all files have been processed.
40254049

40264050
Note also that F<ExtUtils::MakeMaker> usually invokes F<xsubpp> with two
40274051
C<-typemap> arguments: the first being the system typemap and the second
@@ -4264,8 +4288,8 @@ using aliasing:
42644288
mynum_multiply
42654289
mynum_divide
42664290

4267-
but note that C<INTERFACE> only supports Perlish return types such
4268-
as C<My::Num> from Perl 5.44.0 (F<ExtUtils::ParseXS> 3.60) onwards.
4291+
but note that C<INTERFACE> only supports Perlish return types such as
4292+
C<My::Num> from F<xsubpp> 3.60 onwards.
42694293

42704294
This XS module might be accessed from Perl using code like this:
42714295

@@ -4356,7 +4380,7 @@ could be written longhand as:
43564380
OUTPUT:
43574381
RETVAL
43584382

4359-
Note that the type of C<THIS> (and, since Perl 5.42, C<CLASS>) can be
4383+
Note that the type of C<THIS> (and, since F<xsubpp> 3.55, C<CLASS>) can be
43604384
overridden with a line in an C<INPUT> section:
43614385

43624386
int
@@ -4849,12 +4873,11 @@ this model, the less likely conflicts will occur.
48494873

48504874
=head1 XS VERSION
48514875

4852-
This document covers features supported by C<ExtUtils::ParseXS>
4853-
(also known as C<xsubpp>) 3.60.
4876+
This document covers features supported by F<xsubpp> 3.60.
48544877

48554878
=head1 AUTHOR DIAGNOSTICS
48564879

4857-
As of version 3.49 a few parser warnings are disabled by default. While
4880+
As of F<xsubpp> 3.49, a few parser warnings are disabled by default. While
48584881
developing you can set C<$ENV{AUTHOR_WARNINGS}> to true in your
48594882
environment or in your Makefile.PL, or set
48604883
C<$ExtUtils::ParseXS::AUTHOR_WARNINGS> to true via code, or pass C<<

dist/ExtUtils-ParseXS/t/001-basic.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ EOF_CONTENT
466466
or die "Failed to open '$file' for read:$!";
467467
my $pod_version = "";
468468
while (defined(my $line= readline($fh))) {
469-
if ($line=~/\(also known as C<xsubpp>\)\s+(\d+\.\d+)/) {
469+
if ($line=~/\QThis document covers features supported by F<xsubpp> \E(\d+\.\d+)/) {
470470
$pod_version = $1;
471471
last;
472472
}

0 commit comments

Comments
 (0)