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,6 +675,21 @@ while (my $d = readdir(DH)) {
my $sym = ''; my $sym = '';
if ($symtype == 1) { # a function if ($symtype == 1) { # a function
my $is_forced_inline = ($decl =~ /\A\s*SDL_FORCE_INLINE/);
if ($is_forced_inline) {
if (not $decl =~ /\)\s*(\{.*|)\s*\Z/) {
while (<FH>) {
chomp;
push @decllines, $_;
s/\A\s+//;
s/\s+\Z//;
$decl .= " $_";
last if /\)\s*(\{.*|)\s*\Z/;
}
}
$decl =~ s/\s*\)\s*(\{.*|)\s*\Z/);/;
} else {
if (not $decl =~ /\)\s*;/) { if (not $decl =~ /\)\s*;/) {
while (<FH>) { while (<FH>) {
chomp; chomp;
@ -677,13 +700,16 @@ while (my $d = readdir(DH)) {
last if /\)\s*;/; 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,6 +721,7 @@ while (my $d = readdir(DH)) {
next; next;
} }
if (!$is_forced_inline) { # !!! FIXME: maybe we need to do this for forced-inline stuff too?
$decl = ''; # build this with the line breaks, since it looks better for syntax highlighting. $decl = ''; # build this with the line breaks, since it looks better for syntax highlighting.
foreach (@decllines) { foreach (@decllines) {
if ($decl eq '') { if ($decl eq '') {
@ -708,6 +735,7 @@ while (my $d = readdir(DH)) {
} }
$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+/) {
$sym = $1; $sym = $1;