mirror of https://github.com/encounter/SDL.git
wikiheaders.pl: Add support for deprecated functions.
This commit is contained in:
parent
dbe55350ce
commit
d9d8f51eec
|
@ -270,6 +270,7 @@ usage() if not defined $wikipath;
|
||||||
my @standard_wiki_sections = (
|
my @standard_wiki_sections = (
|
||||||
'Draft',
|
'Draft',
|
||||||
'[Brief]',
|
'[Brief]',
|
||||||
|
'Deprecated',
|
||||||
'Syntax',
|
'Syntax',
|
||||||
'Function Parameters',
|
'Function Parameters',
|
||||||
'Return Value',
|
'Return Value',
|
||||||
|
@ -309,7 +310,7 @@ while (readdir(DH)) {
|
||||||
my @templines;
|
my @templines;
|
||||||
my $str;
|
my $str;
|
||||||
my $has_doxygen = 1;
|
my $has_doxygen = 1;
|
||||||
if (/\A\s*extern\s+DECLSPEC/) { # a function declaration without a doxygen comment?
|
if (/\A\s*extern\s+(SDL_DEPRECATED\s+|)DECLSPEC/) { # a function declaration without a doxygen comment?
|
||||||
@templines = ();
|
@templines = ();
|
||||||
$decl = $_;
|
$decl = $_;
|
||||||
$str = '';
|
$str = '';
|
||||||
|
@ -345,7 +346,7 @@ while (readdir(DH)) {
|
||||||
$decl = <FH>;
|
$decl = <FH>;
|
||||||
$decl = '' if not defined $decl;
|
$decl = '' if not defined $decl;
|
||||||
chomp($decl);
|
chomp($decl);
|
||||||
if (not $decl =~ /\A\s*extern\s+DECLSPEC/) {
|
if (not $decl =~ /\A\s*extern\s+(SDL_DEPRECATED\s+|)DECLSPEC/) {
|
||||||
#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) {
|
||||||
push @contents, $_;
|
push @contents, $_;
|
||||||
|
@ -373,8 +374,8 @@ while (readdir(DH)) {
|
||||||
#print("DECL: [$decl]\n");
|
#print("DECL: [$decl]\n");
|
||||||
|
|
||||||
my $fn = '';
|
my $fn = '';
|
||||||
if ($decl =~ /\A\s*extern\s+DECLSPEC\s+(const\s+|)(unsigned\s+|)(.*?)\s*(\*?)\s*SDLCALL\s+(.*?)\s*\((.*?)\);/) {
|
if ($decl =~ /\A\s*extern\s+(SDL_DEPRECATED\s+|)DECLSPEC\s+(const\s+|)(unsigned\s+|)(.*?)\s*(\*?)\s*SDLCALL\s+(.*?)\s*\((.*?)\);/) {
|
||||||
$fn = $5;
|
$fn = $6;
|
||||||
#$decl =~ s/\A\s*extern\s+DECLSPEC\s+(.*?)\s+SDLCALL/$1/;
|
#$decl =~ s/\A\s*extern\s+DECLSPEC\s+(.*?)\s+SDLCALL/$1/;
|
||||||
} else {
|
} else {
|
||||||
#print "Found doxygen but no function sig:\n$str\n\n";
|
#print "Found doxygen but no function sig:\n$str\n\n";
|
||||||
|
@ -391,9 +392,10 @@ while (readdir(DH)) {
|
||||||
foreach (@decllines) {
|
foreach (@decllines) {
|
||||||
if ($decl eq '') {
|
if ($decl eq '') {
|
||||||
$decl = $_;
|
$decl = $_;
|
||||||
$decl =~ s/\Aextern\s+DECLSPEC\s+(.*?)\s+(\*?)SDLCALL\s+/$1$2 /;
|
$decl =~ s/\Aextern\s+(SDL_DEPRECATED\s+|)DECLSPEC\s+(.*?)\s+(\*?)SDLCALL\s+/$2$3 /;
|
||||||
} else {
|
} else {
|
||||||
my $trimmed = $_;
|
my $trimmed = $_;
|
||||||
|
# !!! FIXME: trim space for SDL_DEPRECATED if it was used, too.
|
||||||
$trimmed =~ s/\A\s{24}//; # 24 for shrinking to match the removed "extern DECLSPEC SDLCALL "
|
$trimmed =~ s/\A\s{24}//; # 24 for shrinking to match the removed "extern DECLSPEC SDLCALL "
|
||||||
$decl .= $trimmed;
|
$decl .= $trimmed;
|
||||||
}
|
}
|
||||||
|
@ -561,6 +563,7 @@ if ($copy_direction == 1) { # --copy-to-headers
|
||||||
my $returns = %$sectionsref{'Return Value'};
|
my $returns = %$sectionsref{'Return Value'};
|
||||||
my $version = %$sectionsref{'Version'};
|
my $version = %$sectionsref{'Version'};
|
||||||
my $related = %$sectionsref{'Related Functions'};
|
my $related = %$sectionsref{'Related Functions'};
|
||||||
|
my $deprecated = %$sectionsref{'Deprecated'};
|
||||||
my $brief = %$sectionsref{'[Brief]'};
|
my $brief = %$sectionsref{'[Brief]'};
|
||||||
my $addblank = 0;
|
my $addblank = 0;
|
||||||
my $str = '';
|
my $str = '';
|
||||||
|
@ -586,6 +589,21 @@ if ($copy_direction == 1) { # --copy-to-headers
|
||||||
$str .= wordwrap($remarks) . "\n";
|
$str .= wordwrap($remarks) . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (defined $deprecated) {
|
||||||
|
# !!! FIXME: lots of code duplication in all of these.
|
||||||
|
$str .= "\n" if $addblank; $addblank = 1;
|
||||||
|
my $v = dewikify($wikitype, $deprecated);
|
||||||
|
my $whitespacelen = length("\\deprecated") + 1;
|
||||||
|
my $whitespace = ' ' x $whitespacelen;
|
||||||
|
$v = wordwrap($v, -$whitespacelen);
|
||||||
|
my @desclines = split /\n/, $v;
|
||||||
|
my $firstline = shift @desclines;
|
||||||
|
$str .= "\\deprecated $firstline\n";
|
||||||
|
foreach (@desclines) {
|
||||||
|
$str .= "${whitespace}$_\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (defined $params) {
|
if (defined $params) {
|
||||||
$str .= "\n" if $addblank; $addblank = (defined $returns) ? 0 : 1;
|
$str .= "\n" if $addblank; $addblank = (defined $returns) ? 0 : 1;
|
||||||
my @lines = split /\n/, dewikify($wikitype, $params);
|
my @lines = split /\n/, dewikify($wikitype, $params);
|
||||||
|
@ -775,7 +793,7 @@ if ($copy_direction == 1) { # --copy-to-headers
|
||||||
|
|
||||||
my $decl = $headerdecls{$fn};
|
my $decl = $headerdecls{$fn};
|
||||||
#$decl =~ s/\*\s+SDLCALL/ *SDLCALL/; # Try to make "void * Function" become "void *Function"
|
#$decl =~ s/\*\s+SDLCALL/ *SDLCALL/; # Try to make "void * Function" become "void *Function"
|
||||||
#$decl =~ s/\A\s*extern\s+DECLSPEC\s+(.*?)\s+(\*?)SDLCALL/$1$2/;
|
#$decl =~ s/\A\s*extern\s+(SDL_DEPRECATED\s+|)DECLSPEC\s+(.*?)\s+(\*?)SDLCALL/$2$3/;
|
||||||
|
|
||||||
my $syntax = '';
|
my $syntax = '';
|
||||||
if ($wikitype eq 'mediawiki') {
|
if ($wikitype eq 'mediawiki') {
|
||||||
|
@ -829,6 +847,21 @@ if ($copy_direction == 1) { # --copy-to-headers
|
||||||
}
|
}
|
||||||
$desc =~ s/[\s\n]+\Z//ms;
|
$desc =~ s/[\s\n]+\Z//ms;
|
||||||
$sections{'Return Value'} = wordwrap("$retstr " . wikify($wikitype, $desc)) . "\n";
|
$sections{'Return Value'} = wordwrap("$retstr " . wikify($wikitype, $desc)) . "\n";
|
||||||
|
} elsif ($l =~ /\A\\deprecated\s+(.*)\Z/) {
|
||||||
|
my $desc = $1;
|
||||||
|
while (@doxygenlines) {
|
||||||
|
my $subline = $doxygenlines[0];
|
||||||
|
$subline =~ s/\A\s*//;
|
||||||
|
last if $subline =~ /\A\\/; # some sort of doxygen command, assume we're past this thing.
|
||||||
|
shift @doxygenlines; # dump this line from the array; we're using it.
|
||||||
|
if ($subline eq '') { # empty line, make sure it keeps the newline char.
|
||||||
|
$desc .= "\n";
|
||||||
|
} else {
|
||||||
|
$desc .= " $subline";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$desc =~ s/[\s\n]+\Z//ms;
|
||||||
|
$sections{'Deprecated'} = wordwrap(wikify($wikitype, $desc)) . "\n";
|
||||||
} elsif ($l =~ /\A\\since\s+(.*)\Z/) {
|
} elsif ($l =~ /\A\\since\s+(.*)\Z/) {
|
||||||
my $desc = $1;
|
my $desc = $1;
|
||||||
while (@doxygenlines) {
|
while (@doxygenlines) {
|
||||||
|
|
|
@ -55,7 +55,7 @@ while (my $d = readdir(HEADERS)) {
|
||||||
open(HEADER, '<', $header) or die("Can't open $header: $!\n");
|
open(HEADER, '<', $header) or die("Can't open $header: $!\n");
|
||||||
while (<HEADER>) {
|
while (<HEADER>) {
|
||||||
chomp;
|
chomp;
|
||||||
next if not /\A\s*extern\s+DECLSPEC/;
|
next if not /\A\s*extern\s+(SDL_DEPRECATED\s+|)DECLSPEC/;
|
||||||
my $decl = "$_ ";
|
my $decl = "$_ ";
|
||||||
if (not $decl =~ /\)\s*;/) {
|
if (not $decl =~ /\)\s*;/) {
|
||||||
while (<HEADER>) {
|
while (<HEADER>) {
|
||||||
|
@ -70,13 +70,13 @@ while (my $d = readdir(HEADERS)) {
|
||||||
$decl =~ s/\s+\Z//;
|
$decl =~ s/\s+\Z//;
|
||||||
#print("DECL: [$decl]\n");
|
#print("DECL: [$decl]\n");
|
||||||
|
|
||||||
if ($decl =~ /\A\s*extern\s+DECLSPEC\s+(const\s+|)(unsigned\s+|)(.*?)\s*(\*?)\s*SDLCALL\s+(.*?)\s*\((.*?)\);/) {
|
if ($decl =~ /\A\s*extern\s+(SDL_DEPRECATED\s+|)DECLSPEC\s+(const\s+|)(unsigned\s+|)(.*?)\s*(\*?)\s*SDLCALL\s+(.*?)\s*\((.*?)\);/) {
|
||||||
my $rc = "$1$2$3$4";
|
my $rc = "$2$3$4$5";
|
||||||
my $fn = $5;
|
my $fn = $6;
|
||||||
|
|
||||||
next if $existing{$fn}; # already slotted into the jump table.
|
next if $existing{$fn}; # already slotted into the jump table.
|
||||||
|
|
||||||
my @params = split(',', $6);
|
my @params = split(',', $7);
|
||||||
|
|
||||||
#print("rc == '$rc', fn == '$fn', params == '$params'\n");
|
#print("rc == '$rc', fn == '$fn', params == '$params'\n");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue