Skip to content

Commit 14c379e

Browse files
committed
Make autodoc aware of embed.h compatibility macros
embed.h has compatibility macros for things like croak(). These had never been output in perlapi, so there was no signature given for these. And now, PERL_WANT_VARARGS is available to get them to assume that a thread context is available. Mention that in each applicable entry.
1 parent e92fcde commit 14c379e

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

autodoc.pl

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,25 @@
8484
# apidoc_item
8585
my $item_flags_re = qr/[dD fF mM nN oO pT uU Wx;]/xx;
8686

87+
# This is a copy of the list in regen/embed.pl.
88+
my @have_compatibility_macros = qw(
89+
croak
90+
deb
91+
die
92+
form
93+
load_module
94+
mess
95+
newSVpvf
96+
sv_catpvf
97+
sv_catpvf_mg
98+
sv_setpvf
99+
sv_setpvf_mg
100+
warn
101+
warner
102+
);
103+
my %has_compat_macro;
104+
$has_compat_macro{$_} = 1 for @have_compatibility_macros;
105+
87106
use constant {
88107
NOT_APIDOC => -1,
89108
ILLEGAL_APIDOC => 0, # Must be 0 so evaluates to 'false'
@@ -1648,6 +1667,7 @@ ($fh, $section_name, $element_name, $docref)
16481667
my @deprecated;
16491668
my @experimental;
16501669
my @xrefs;
1670+
my @compat_macros;
16511671

16521672
for (my $i = 0; $i < @items; $i++) {
16531673
last if $docref->{'xref_only'}; # Place holder
@@ -1664,6 +1684,7 @@ ($fh, $section_name, $element_name, $docref)
16641684

16651685
push @deprecated, "C<$name>" if $item->{flags} =~ /D/;
16661686
push @experimental, "C<$name>" if $item->{flags} =~ /x/;
1687+
push @compat_macros, $name if $has_compat_macro{$name};
16671688
}
16681689

16691690
# While we're going though the items, construct a nice list of where
@@ -1887,7 +1908,8 @@ ($fh, $section_name, $element_name, $docref)
18871908
# expect both the thread context and the format to be the
18881909
# first parameter to the function; and only one can be in
18891910
# that position.
1890-
my $cant_use_short_name = ( $flags =~ /f/
1911+
my $cant_use_short_name = ( ! $has_compat_macro{$name}
1912+
&& $flags =~ /f/
18911913
&& $flags !~ /T/
18921914
&& $name !~ /strftime/);
18931915

@@ -2178,6 +2200,18 @@ ($fh, $section_name, $element_name, $docref)
21782200
}
21792201
}
21802202

2203+
for my $compat (@compat_macros) {
2204+
print $fh <<~"EOT";
2205+
2206+
Note: When called from XS code, $compat(...) expands to
2207+
C<Perl_${compat}_no_context(...)> unless C<PERL_WANT_VARARGS> has
2208+
been C<#defined>, in which case it expands to
2209+
C<Perl_$compat(aTHX_ ...)>. When called from the perl core,
2210+
it assumes C<aTHX> is available, so expands to
2211+
C<Perl_$compat(aTHX_ ...)>
2212+
EOT
2213+
}
2214+
21812215
if (grep { /\S/ } @usage) {
21822216
print $fh "\n=over $usage_indent\n\n";
21832217
print $fh join "", @usage;

regen/embed.pl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ BEGIN
3737
# parameter; this was just to avoid breaking existing source. Hence no new
3838
# functions need be added to the list of such macros. This is the list.
3939
# All have varargs.
40+
#
41+
# N.B. If you change this list, update the copy in autodoc.pl. This is likely
42+
# to never happen, so not worth coding automatic synchronization.
4043
my @have_compatibility_macros = qw(
4144
croak
4245
deb

0 commit comments

Comments
 (0)