From 5d903a64aca37ee7c2836e479e175336e9b7ca87 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 15 Aug 2022 21:52:05 -0700 Subject: findclasslist.pl: match unexported classes too MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Unexported structs do mark private API too. This change necessitated fixing the negative-lookahead, because otherwise we'd match a line like: class QVariant; With $1 = "QVarian" and the "t" stood for the negative lookahead. Pick-to: 6.4 Change-Id: Ic6547f8247454b47baa8fffd170bba2c68c29dbc Reviewed-by: Jörg Bornemann --- mkspecs/features/data/unix/findclasslist.pl | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'mkspecs') diff --git a/mkspecs/features/data/unix/findclasslist.pl b/mkspecs/features/data/unix/findclasslist.pl index ca5f856156..3d224aeedf 100644 --- a/mkspecs/features/data/unix/findclasslist.pl +++ b/mkspecs/features/data/unix/findclasslist.pl @@ -6,6 +6,13 @@ use strict; my $syntax = "findclasslist.pl\n" . "Replaces each \@FILE:filename\@ in stdin with the classes found in that file\n"; +# Match a struct or class declaration at the top-level, but not a forward +# declaration +my $classmatch = qr/^(?:struct|class)(?:\s+Q_\w*_EXPORT)?\s+(\w+)(\s*;$)?/; + +# Match an exported namespace +my $nsmatch = qr/^namespace\s+Q_\w+_EXPORT\s+(\w+)/; + $\ = $/; while () { chomp; @@ -24,9 +31,10 @@ while () { next if $1 eq "ignore" or $1 eq "ignore-next"; } - # Match a struct or class declaration, but not a forward declaration - $line =~ /^(?:struct|class|namespace) (?:Q_.*_EXPORT)? (\w+)(?!;)/ or next; - print $comment if $comment; + $line =~ s,\s*(//.*)?$,,; # remove // comments and trailing space + next unless $line =~ $nsmatch or $line =~ $classmatch; + next if $2 ne ""; # forward declaration + printf " *%d%s*;\n", length $1, $1; $comment = 0; } -- cgit v1.2.3