wikiheaders: Add support for SDL_FORCE_INLINE functions.

main
Ryan C. Gordon 2024-04-13 20:08:14 -04:00
parent 239b34d760
commit 3c86af5901
No known key found for this signature in database
GPG Key ID: FA148B892AB48044
1 changed files with 49 additions and 21 deletions

View File

@ -612,6 +612,12 @@ while (my $d = readdir(DH)) {
$decl = $_; $decl = $_;
$str = ''; $str = '';
$has_doxygen = 0; $has_doxygen = 0;
} elsif (/\A\s*SDL_FORCE_INLINE/) { # a (forced-inline) function declaration without a doxygen comment?
$symtype = 1; # function declaration
@templines = ();
$decl = $_;
$str = '';
$has_doxygen = 0;
} elsif (not /\A\/\*\*\s*\Z/) { # not doxygen comment start? } elsif (not /\A\/\*\*\s*\Z/) { # not doxygen comment start?
push @contents, $_; push @contents, $_;
next; next;
@ -645,6 +651,8 @@ while (my $d = readdir(DH)) {
chomp($decl); chomp($decl);
if ($decl =~ /\A\s*extern\s+(SDL_DEPRECATED\s+|)DECLSPEC/) { if ($decl =~ /\A\s*extern\s+(SDL_DEPRECATED\s+|)DECLSPEC/) {
$symtype = 1; # function declaration $symtype = 1; # function declaration
} elsif ($decl =~ /\A\s*SDL_FORCE_INLINE/) {
$symtype = 1; # (forced-inline) function declaration
} elsif ($decl =~ /\A\s*\#\s*define\s+/) { } elsif ($decl =~ /\A\s*\#\s*define\s+/) {
$symtype = 2; # macro $symtype = 2; # macro
} elsif ($decl =~ /\A\s*(typedef\s+|)(struct|union)/) { } elsif ($decl =~ /\A\s*(typedef\s+|)(struct|union)/) {
@ -667,23 +675,41 @@ while (my $d = readdir(DH)) {
my $sym = ''; my $sym = '';
if ($symtype == 1) { # a function if ($symtype == 1) { # a function
if (not $decl =~ /\)\s*;/) { my $is_forced_inline = ($decl =~ /\A\s*SDL_FORCE_INLINE/);
while (<FH>) {
chomp; if ($is_forced_inline) {
push @decllines, $_; if (not $decl =~ /\)\s*(\{.*|)\s*\Z/) {
s/\A\s+//; while (<FH>) {
s/\s+\Z//; chomp;
$decl .= " $_"; push @decllines, $_;
last if /\)\s*;/; s/\A\s+//;
s/\s+\Z//;
$decl .= " $_";
last if /\)\s*(\{.*|)\s*\Z/;
}
} }
$decl =~ s/\s*\)\s*(\{.*|)\s*\Z/);/;
} else {
if (not $decl =~ /\)\s*;/) {
while (<FH>) {
chomp;
push @decllines, $_;
s/\A\s+//;
s/\s+\Z//;
$decl .= " $_";
last if /\)\s*;/;
}
}
$decl =~ s/\s+\);\Z/);/;
} }
$decl =~ s/\s+\);\Z/);/;
$decl =~ s/\s+\Z//; $decl =~ s/\s+\Z//;
if ($decl =~ /\A\s*extern\s+(SDL_DEPRECATED\s+|)DECLSPEC\s+(const\s+|)(unsigned\s+|)(.*?)\s*(\*?)\s*SDLCALL\s+(.*?)\s*\((.*?)\);/) { if (!$is_forced_inline && $decl =~ /\A\s*extern\s+(SDL_DEPRECATED\s+|)DECLSPEC\s+(const\s+|)(unsigned\s+|)(.*?)\s*(\*?)\s*SDLCALL\s+(.*?)\s*\((.*?)\);/) {
$sym = $6; $sym = $6;
#$decl =~ s/\A\s*extern\s+DECLSPEC\s+(.*?)\s+SDLCALL/$1/; #$decl =~ s/\A\s*extern\s+DECLSPEC\s+(.*?)\s+SDLCALL/$1/;
} elsif ($is_forced_inline && $decl =~ /\A\s*SDL_FORCE_INLINE\s+(SDL_DEPRECATED\s+|)(const\s+|)(unsigned\s+|)(.*?)([\*\s]+)(.*?)\s*\((.*?)\);/) {
$sym = $6;
} else { } else {
#print "Found doxygen but no function sig:\n$str\n\n"; #print "Found doxygen but no function sig:\n$str\n\n";
foreach (@templines) { foreach (@templines) {
@ -695,18 +721,20 @@ while (my $d = readdir(DH)) {
next; next;
} }
$decl = ''; # build this with the line breaks, since it looks better for syntax highlighting. if (!$is_forced_inline) { # !!! FIXME: maybe we need to do this for forced-inline stuff too?
foreach (@decllines) { $decl = ''; # build this with the line breaks, since it looks better for syntax highlighting.
if ($decl eq '') { foreach (@decllines) {
$decl = $_; if ($decl eq '') {
$decl =~ s/\Aextern\s+(SDL_DEPRECATED\s+|)DECLSPEC\s+(.*?)\s+(\*?)SDLCALL\s+/$2$3 /; $decl = $_;
} else { $decl =~ s/\Aextern\s+(SDL_DEPRECATED\s+|)DECLSPEC\s+(.*?)\s+(\*?)SDLCALL\s+/$2$3 /;
my $trimmed = $_; } else {
# !!! FIXME: trim space for SDL_DEPRECATED if it was used, too. my $trimmed = $_;
$trimmed =~ s/\A\s{24}//; # 24 for shrinking to match the removed "extern DECLSPEC SDLCALL " # !!! FIXME: trim space for SDL_DEPRECATED if it was used, too.
$decl .= $trimmed; $trimmed =~ s/\A\s{24}//; # 24 for shrinking to match the removed "extern DECLSPEC SDLCALL "
$decl .= $trimmed;
}
$decl .= "\n";
} }
$decl .= "\n";
} }
} elsif ($symtype == 2) { # a macro } elsif ($symtype == 2) { # a macro
if ($decl =~ /\A\s*\#\s*define\s+(.*?)(\(.*?\)|)\s+/) { if ($decl =~ /\A\s*\#\s*define\s+(.*?)(\(.*?\)|)\s+/) {