Teach syncqt to filter out QT_DEPRECATED_* macros
We already had code that filtered out QT_DEPRECATED_X("text"). But that isn't enough, because, by now, we have a true cornucopia of QT_DEPRECATED_* macros. And only some are called with an argument list. Move the filtering code into the subroutine filterDeprecationMacros, because our filtering is slightly more complex now: - Try to match a QT_DEPRECATED_* macro call. - Try to match balanced parentheses with a recursive regular expression. - Check whether the found balanced parentheses are directly behind QT_DEPRECATED_*, because only then it is the argument list of that macro. - Filter out what we've found. With this patch, syncqt doesn't discard deprecated classes anymore. Task-number: QTBUG-80347 Change-Id: I7872159639be330d5a039c98eac0c5007d9acb93 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
115d99b7de
commit
6c17436449
@ -192,6 +192,33 @@ sub shouldMasterInclude {
|
||||
return 1;
|
||||
}
|
||||
|
||||
######################################################################
|
||||
# Syntax: filterDeprecationMacros(line)
|
||||
# Params: line: a line of C++ source
|
||||
#
|
||||
# Purpose: Removes occurrences of QT_DEPRECATED_* macro calls.
|
||||
# The calls may have an argument list that is also removed.
|
||||
# Returns: The filtered line.
|
||||
######################################################################
|
||||
sub filterDeprecationMacros {
|
||||
my $line = $_[0];
|
||||
my $rest;
|
||||
if ($line =~ /(.*\s+)QT_DEPRECATED_[[:upper:][:digit:]_]+\s*(.*)/) {
|
||||
$line = $1;
|
||||
$rest = $2;
|
||||
|
||||
# Does the macro call have an argument list? If so, remove it.
|
||||
# The regular expression matches balanced parenthesis anywhere in $rest.
|
||||
# Therefore, we must check whether the match starts at index zero.
|
||||
if ($rest =~ /\((?:[^)(]+|(?R))*+\)/ && $-[0] == 0) {
|
||||
$line .= substr($rest, $+[0]);
|
||||
} else {
|
||||
$line .= $rest;
|
||||
}
|
||||
}
|
||||
return $line;
|
||||
}
|
||||
|
||||
######################################################################
|
||||
# Syntax: classNames(iheader, clean, requires)
|
||||
# Params: iheader, string, filename to parse for classname "symlinks"
|
||||
@ -298,7 +325,7 @@ sub classNames {
|
||||
|
||||
if($definition) {
|
||||
$definition =~ s=[\n\r]==g;
|
||||
$definition =~ s/QT_DEPRECATED_X\s*\(\s*".*?"\s*\)//g;
|
||||
$definition = filterDeprecationMacros($definition);
|
||||
my @symbols;
|
||||
my $post_kw = qr/Q_DECL_FINAL|final|sealed/; # add here macros and keywords that go after the class-name of a class definition
|
||||
if($definition =~ m/^ *typedef *.*\(\*([^\)]*)\)\(.*\);$/) {
|
||||
|
Loading…
Reference in New Issue
Block a user