5 # Copyright (C) 2003 Morten Welinder.
7 # This program is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU General Public License as
9 # published by the Free Software Foundation; either version 2 of the
10 # License, or (at your option) any later version.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this library; if not, see <https://www.gnu.org/licenses/>.
20 # Author: Morten Welinder <terra@gnome.org>
28 warn "$0: should be run from top-level directory.\n"
29 unless -r
"configure.ac" && -r
'ChangeLog';
39 open (*FIND
, "find . '(' -type f -name '*.c' -print ')' -o '(' -type d '(' -name intl -o -name macros -o -name .git -o -name win32 ')' -prune ')' |")
40 or die "$0: cannot execute find: $!\n";
42 foreach my $filename (<FIND
>) {
44 $filename =~ s
|^\
./||;
46 next if $exceptions{$filename};
47 my $basename = $filename;
48 $basename =~ s
|^.*/||;
49 next if $base_exceptions{$basename};
51 my %is_an_object_type = ();
52 my $err = &pass1
($filename, \
%is_an_object_type);
57 $exitcode ||= &pass2
($filename, \
%is_an_object_type);
64 # -----------------------------------------------------------------------------
69 while ($s =~ m{(/\*|//)}) {
73 ($s =~ s{/\*.*\*/}{}) or ($s =~ s{/\*.*}{});
81 # -----------------------------------------------------------------------------
84 my ($filename,$pis_an_object_type) = @_;
87 if (open (*FIL
, "<$filename")) {
89 if (/^(([a-zA-Z_]+[a-zA-Z_0-9]*)_get_type)\s*\(/) {
90 $pis_an_object_type->{$2} = 1;
92 if (/\(GClassInitFunc\)\s*(([a-zA-Z_]+[a-zA-Z_0-9]*)_class_init)\s*,/) {
93 $pis_an_object_type->{$2} = 1;
95 if (/\(GInstanceInitFunc\)\s*(([a-zA-Z_]+[a-zA-Z_0-9]*)_init)\s*,/) {
96 $pis_an_object_type->{$2} = 1;
98 if (/\bG_DEFINE(_ABSTRACT)?_TYPE\b/) {
99 while (!/\)\s*;?\s*$/) { chomp; $_ .= &slurp
(scalar <FIL
>); }
100 if (/\bG_DEFINE(_ABSTRACT)?_TYPE\s*\([^,]*,\s*([a-zA-Z_]+[a-zA-Z_0-9]*)\s*,/) {
101 $pis_an_object_type->{$2} = 1;
105 if (/\bBONOBO_TYPE_FUNC_FULL\b/) {
106 while (!/\)\s*;?\s*$/) { chomp; $_ .= &slurp
(scalar <FIL
>); }
107 if (/\bBONOBO_TYPE_FUNC_FULL\s*\([^,]*,[^,]*,[^,]*,\s*([a-zA-Z_]+[a-zA-Z_0-9]*)\s*\)/) {
108 $pis_an_object_type->{$1} = 1;
112 if (/\bGNOME_CLASS_BOILERPLATE\b/) {
113 while (!/\)\s*;?\s*$/) { chomp; $_ .= &slurp
(scalar <FIL
>); }
114 if (/\bGNOME_CLASS_BOILERPLATE\s*\([^,]*,\s*([a-zA-Z_]+[a-zA-Z_0-9]*)\s*,[^,]*,[^,]*\)/) {
115 $pis_an_object_type->{$1} = 1;
119 if (/\bGSF_CLASS(_ABSTRACT)?\b/) {
120 # print "$filename: $_";
121 while (!/\)\s*;?\s*$/) { chomp; $_ .= &slurp
(scalar <FIL
>); }
122 if (/\bGSF_CLASS(_ABSTRACT)?\s*\([^,]*,\s*([a-zA-Z_]+[a-zA-Z_0-9]*)\s*,[^,]*,[^,]*,[^,]*\)/) {
123 $pis_an_object_type->{$2} = 1;
130 print STDERR
"$0: Cannot read `$filename': $!\b";
135 # -----------------------------------------------------------------------------
138 my ($filename,$pis_an_object_type) = @_;
141 if (open (*FIL
, "<$filename")) {
142 # print "Checking $filename...\n";
145 my $funcname = undef;
152 if ($state == 1 && /^(([a-zA-Z_]+[a-zA-Z_0-9]*)_(finalize|destroy|dispose|unrealize))\s*\([^,]+\)/) {
156 if (!$pis_an_object_type->{$type}) {
157 # print "NO TYPE: $type\n";
168 print "$filename:$lineno: apparently missing chain in $funcname.\n";
174 if (/->\s*$handler\s*\)?\s*\(/ ||
175 /GNOME_CALL_PARENT.*,\s*$handler\s*,/ ||
176 (/gnm_command_$handler/ && $funcname =~ /^cmd_/) ||
177 /g_object_dtor\s*\)?\s*\(/) {
185 print STDERR
"$0: Cannot read `$filename': $!\b";
190 # -----------------------------------------------------------------------------