#!/usr/bin/perl -w
-#
+#
# Regenerate (overwriting only if changed):
#
# embed.h
my ($func, $flags) = @_;
return "Perl_$func" if $flags =~ /p/;
- return "S_$func" if $flags =~ /[Si]/;
+ return "S_$func" if $flags =~ /[SIi]/;
return $func;
}
}
my ($flags,$retval,$plain_func,@args) = @$_;
- if ($flags =~ / ( [^AabCDdEefGhiMmNnOoPpRrSsTUuWXx] ) /x) {
+ if ($flags =~ / ( [^AabCDdEefFGhIiMmNnOoPpRrSsTUuWXx] ) /x) {
die_at_end "flag $1 is not legal (for function $plain_func)";
}
my @nonnull;
warn "It is nonsensical to require the return value of a void function ($plain_func) to be checked";
}
- die_at_end "$plain_func: S flag is mutually exclusive from the i and p plags"
- if $flags =~ /S/ && $flags =~ /([ip])/;
+ die_at_end "$plain_func: S and p flags are mutually exclusive"
+ if $flags =~ /S/ && $flags =~ /p/;
die_at_end "$plain_func: m and $1 flags are mutually exclusive"
if $flags =~ /m/ && $flags =~ /([pS])/;
- die_at_end "$plain_func: u flag only usable with m" if $flags =~ /u/ && $flags !~ /m/;
+ die_at_end "$plain_func: u flag only usable with m" if $flags =~ /u/
+ && $flags !~ /m/;
my $static_inline = 0;
- if ($flags =~ /([Si])/) {
+ if ($flags =~ /([SIi])/) {
my $type;
if ($never_returns) {
- $type = $1 eq 'S' ? "PERL_STATIC_NO_RET" : "PERL_STATIC_INLINE_NO_RET";
+ $type = {
+ 'S' => 'PERL_STATIC_NO_RET',
+ 'i' => 'PERL_STATIC_INLINE_NO_RET',
+ 'I' => 'PERL_STATIC_FORCE_INLINE_NO_RET'
+ }->{$1};
}
else {
- $type = $1 eq 'S' ? "STATIC" : "PERL_STATIC_INLINE";
+ $type = {
+ 'S' => 'STATIC',
+ 'i' => 'PERL_STATIC_INLINE',
+ 'I' => 'PERL_STATIC_FORCE_INLINE'
+ }->{$1};
}
$retval = "$type $retval";
die_at_end "Don't declare static function '$plain_func' pure" if $flags =~ /P/;
- $static_inline = $type eq 'PERL_STATIC_INLINE';
+ $static_inline = $type =~ /^PERL_STATIC(?:_FORCE)?_INLINE/;
}
else {
if ($never_returns) {
die_at_end "For '$plain_func', M flag requires p flag"
if $flags =~ /M/ && $flags !~ /p/;
+ die_at_end "For '$plain_func', C flag requires one of [pIimb] flags"
+ if $flags =~ /C/ && $flags !~ /[Iibmp]/;
+ die_at_end "For '$plain_func', X flag requires one of [Iip] flags"
+ if $flags =~ /X/ && $flags !~ /[Iip]/;
+ die_at_end "For '$plain_func', X and m flags are mutually exclusive"
+ if $flags =~ /X/ && $flags =~ /m/;
+ die_at_end "For '$plain_func', [Ii] with [ACX] requires p flag"
+ if $flags =~ /[Ii]/ && $flags =~ /[ACX]/ && $flags !~ /p/;
die_at_end "For '$plain_func', b and m flags are mutually exclusive"
. " (try M flag)" if $flags =~ /b/ && $flags =~ /m/;
die_at_end "For '$plain_func', b flag without M flag requires D flag"
if $flags =~ /b/ && $flags !~ /M/ && $flags !~ /D/;
+ die_at_end "For '$plain_func', I and i flags are mutually exclusive"
+ if $flags =~ /I/ && $flags =~ /i/;
$func = full_name($plain_func, $flags);
$ret = "";
$ret .= @args ? "pTHX_ " : "pTHX";
}
if (@args) {
+ die_at_end "n flag is contradicted by having arguments"
+ if $flags =~ /n/;
my $n;
for my $arg ( @args ) {
++$n;
if ( $flags =~ /P/ ) {
push @attrs, "__attribute__pure__";
}
+ if ( $flags =~ /I/ ) {
+ push @attrs, "__attribute__always_inline__";
+ }
if( $flags =~ /f/ ) {
my $prefix = $has_context ? 'pTHX_' : '';
my ($args, $pat);
$prefix, $pat, $args;
}
}
+ elsif ((grep { $_ eq '...' } @args) && $flags !~ /F/) {
+ die_at_end "$plain_func: Function with '...' arguments must have"
+ . " f or F flag";
+ }
if ( @attrs ) {
$ret .= "\n";
$ret .= join( "\n", map { "\t\t\t$_" } @attrs );