blob: 3d224aeedf22a12f0bf1da930339575d67923dec (
plain)
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
|
#!/usr/bin/env perl
# Copyright (C) 2016 Intel Corporation.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
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 (<STDIN>) {
chomp;
unless (/\@FILE:(.*)\@/) {
print;
next;
}
# Replace this line with the class list
open HDR, "<$1" or die("Could not open header $1: $!");
my $comment = " /* $1 */";
while (my $line = <HDR>) {
if ($line =~ /\bELFVERSION:(\S+)\b/) {
last if $1 eq "stop";
<HDR> if $1 eq "ignore-next"; # load next line
next if $1 eq "ignore" or $1 eq "ignore-next";
}
$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;
}
close HDR;
}
|