wikiheaders.pl: Add support for deprecated functions.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
diff --git a/build-scripts/wikiheaders.pl b/build-scripts/wikiheaders.pl
index 0cb945a..209a0d5 100755
--- a/build-scripts/wikiheaders.pl
+++ b/build-scripts/wikiheaders.pl
@@ -270,6 +270,7 @@ usage() if not defined $wikipath;
my @standard_wiki_sections = (
'Draft',
'[Brief]',
+ 'Deprecated',
'Syntax',
'Function Parameters',
'Return Value',
@@ -309,7 +310,7 @@ while (readdir(DH)) {
my @templines;
my $str;
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 = ();
$decl = $_;
$str = '';
@@ -345,7 +346,7 @@ while (readdir(DH)) {
$decl = <FH>;
$decl = '' if not defined $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";
foreach (@templines) {
push @contents, $_;
@@ -373,8 +374,8 @@ while (readdir(DH)) {
#print("DECL: [$decl]\n");
my $fn = '';
- if ($decl =~ /\A\s*extern\s+DECLSPEC\s+(const\s+|)(unsigned\s+|)(.*?)\s*(\*?)\s*SDLCALL\s+(.*?)\s*\((.*?)\);/) {
- $fn = $5;
+ if ($decl =~ /\A\s*extern\s+(SDL_DEPRECATED\s+|)DECLSPEC\s+(const\s+|)(unsigned\s+|)(.*?)\s*(\*?)\s*SDLCALL\s+(.*?)\s*\((.*?)\);/) {
+ $fn = $6;
#$decl =~ s/\A\s*extern\s+DECLSPEC\s+(.*?)\s+SDLCALL/$1/;
} else {
#print "Found doxygen but no function sig:\n$str\n\n";
@@ -391,9 +392,10 @@ while (readdir(DH)) {
foreach (@decllines) {
if ($decl eq '') {
$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 {
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 "
$decl .= $trimmed;
}
@@ -561,6 +563,7 @@ if ($copy_direction == 1) { # --copy-to-headers
my $returns = %$sectionsref{'Return Value'};
my $version = %$sectionsref{'Version'};
my $related = %$sectionsref{'Related Functions'};
+ my $deprecated = %$sectionsref{'Deprecated'};
my $brief = %$sectionsref{'[Brief]'};
my $addblank = 0;
my $str = '';
@@ -586,6 +589,21 @@ if ($copy_direction == 1) { # --copy-to-headers
$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) {
$str .= "\n" if $addblank; $addblank = (defined $returns) ? 0 : 1;
my @lines = split /\n/, dewikify($wikitype, $params);
@@ -775,7 +793,7 @@ if ($copy_direction == 1) { # --copy-to-headers
my $decl = $headerdecls{$fn};
#$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 = '';
if ($wikitype eq 'mediawiki') {
@@ -829,6 +847,21 @@ if ($copy_direction == 1) { # --copy-to-headers
}
$desc =~ s/[\s\n]+\Z//ms;
$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/) {
my $desc = $1;
while (@doxygenlines) {
diff --git a/src/dynapi/gendynapi.pl b/src/dynapi/gendynapi.pl
index dc1d22c..419415b 100755
--- a/src/dynapi/gendynapi.pl
+++ b/src/dynapi/gendynapi.pl
@@ -55,7 +55,7 @@ while (my $d = readdir(HEADERS)) {
open(HEADER, '<', $header) or die("Can't open $header: $!\n");
while (<HEADER>) {
chomp;
- next if not /\A\s*extern\s+DECLSPEC/;
+ next if not /\A\s*extern\s+(SDL_DEPRECATED\s+|)DECLSPEC/;
my $decl = "$_ ";
if (not $decl =~ /\)\s*;/) {
while (<HEADER>) {
@@ -70,13 +70,13 @@ while (my $d = readdir(HEADERS)) {
$decl =~ s/\s+\Z//;
#print("DECL: [$decl]\n");
- if ($decl =~ /\A\s*extern\s+DECLSPEC\s+(const\s+|)(unsigned\s+|)(.*?)\s*(\*?)\s*SDLCALL\s+(.*?)\s*\((.*?)\);/) {
- my $rc = "$1$2$3$4";
- my $fn = $5;
+ if ($decl =~ /\A\s*extern\s+(SDL_DEPRECATED\s+|)DECLSPEC\s+(const\s+|)(unsigned\s+|)(.*?)\s*(\*?)\s*SDLCALL\s+(.*?)\s*\((.*?)\);/) {
+ my $rc = "$2$3$4$5";
+ my $fn = $6;
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");