Rename subsystem_DEPRECATED to subsystem_DEPRECATED_FUNCTION(X)

Start to explain what the replacement function is.
Generate the #define/#undef logic in generated header files.
Use gcc style where the deprecation warning is after the prototype.
This commit is contained in:
Love Hornquist Astrand
2011-05-17 23:12:51 -07:00
parent 9ed040da38
commit 305596d9ad
13 changed files with 105 additions and 97 deletions

View File

@@ -11,6 +11,7 @@ my $line = "";
my $debug = 0;
my $oproto = 1;
my $private_func_re = "^_";
my %depfunction = ();
Getopts('x:m:o:p:dqE:R:P:') || die "foo";
@@ -25,7 +26,7 @@ if($opt_q) {
if($opt_R) {
$private_func_re = $opt_R;
}
%flags = (
my %flags = (
'multiline-proto' => 1,
'header' => 1,
'function-blocking' => 0,
@@ -100,16 +101,21 @@ while(<>) {
s/^\s*//;
s/\s*$//;
s/\s+/ /g;
if($_ =~ /\)$/ or $_ =~ /DEPRECATED$/){
if($_ =~ /\)$/){
if(!/^static/ && !/^PRIVATE/){
$attr = "";
if(m/(.*)(__attribute__\s?\(.*\))/) {
$attr .= " $2";
$_ = $1;
}
if(m/(.*)\s(\w+DEPRECATED)/) {
if(m/(.*)\s(\w+DEPRECATED_FUNCTION)\s?(\(.*\))(.*)/) {
$depfunction{$2} = 1;
$attr .= " $2$3";
$_ = "$1 $4";
}
if(m/(.*)\s(\w+DEPRECATED)(.*)/) {
$attr .= " $2";
$_ = $1;
$_ = "$1 $3";
}
# remove outer ()
s/\s*\(/</;
@@ -302,17 +308,44 @@ if($flags{"gnuc-attribute"}) {
";
}
}
my $depstr = "";
my $undepstr = "";
foreach (keys %depfunction) {
$depstr .= "#ifndef $_
#if defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1 )))
#define $_(X) __attribute__((__deprecated__))
#else
#define $_(X)
#endif
#endif
";
$public_h_trailer .= "#undef $_
";
$private_h_trailer .= "#undef $_
#define $_(X)
";
}
$public_h_header .= $depstr;
$private_h_header .= $depstr;
if($flags{"cxx"}) {
$public_h_header .= "#ifdef __cplusplus
extern \"C\" {
#endif
";
$public_h_trailer .= "#ifdef __cplusplus
$public_h_trailer = "#ifdef __cplusplus
}
#endif
";
" . $public_h_trailer;
}
if ($opt_E) {
@@ -348,6 +381,9 @@ if ($opt_E) {
";
}
$public_h_trailer .= $undepstr;
$private_h_trailer .= $undepstr;
if ($public_h ne "" && $flags{"header"}) {
$public_h = $public_h_header . $public_h .
$public_h_trailer . "#endif /* $block */\n";