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, write to the Free Software
19 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 # Author: Morten Welinder <terra@gnome.org>
29 warn "$0: should be run from top-level directory.\n"
30 unless -r
"configure.ac" && -r
'ChangeLog';
40 open (*FIND
, "find . '(' -type f -name '*.c' -print ')' -o '(' -type d '(' -name intl -o -name macros -o -name .git -o -name win32 ')' -prune ')' |")
41 or die "$0: cannot execute find: $!\n";
43 foreach my $filename (<FIND
>) {
45 $filename =~ s
|^\
./||;
47 next if $exceptions{$filename};
48 my $basename = $filename;
49 $basename =~ s
|^.*/||;
50 next if $base_exceptions{$basename};
52 my %is_an_object_type = ();
53 my $err = &pass1
($filename, \
%is_an_object_type);
58 $exitcode ||= &pass2
($filename, \
%is_an_object_type);
65 # -----------------------------------------------------------------------------
70 while ($s =~ m{(/\*|//)}) {
74 ($s =~ s{/\*.*\*/}{}) or ($s =~ s{/\*.*}{});
82 # -----------------------------------------------------------------------------
85 my ($filename,$pis_an_object_type) = @_;
88 if (open (*FIL
, "<$filename")) {
90 if (/^(([a-zA-Z_]+[a-zA-Z_0-9]*)_get_type)\s*\(/) {
91 $pis_an_object_type->{$2} = 1;
93 if (/\(GClassInitFunc\)\s*(([a-zA-Z_]+[a-zA-Z_0-9]*)_class_init)\s*,/) {
94 $pis_an_object_type->{$2} = 1;
96 if (/\(GInstanceInitFunc\)\s*(([a-zA-Z_]+[a-zA-Z_0-9]*)_init)\s*,/) {
97 $pis_an_object_type->{$2} = 1;
99 if (/\bG_DEFINE(_ABSTRACT)?_TYPE\b/) {
100 while (!/\)\s*;?\s*$/) { chomp; $_ .= &slurp
(scalar <FIL
>); }
101 if (/\bG_DEFINE(_ABSTRACT)?_TYPE\s*\([^,]*,\s*([a-zA-Z_]+[a-zA-Z_0-9]*)\s*,/) {
102 $pis_an_object_type->{$2} = 1;
106 if (/\bBONOBO_TYPE_FUNC_FULL\b/) {
107 while (!/\)\s*;?\s*$/) { chomp; $_ .= &slurp
(scalar <FIL
>); }
108 if (/\bBONOBO_TYPE_FUNC_FULL\s*\([^,]*,[^,]*,[^,]*,\s*([a-zA-Z_]+[a-zA-Z_0-9]*)\s*\)/) {
109 $pis_an_object_type->{$1} = 1;
113 if (/\bGNOME_CLASS_BOILERPLATE\b/) {
114 while (!/\)\s*;?\s*$/) { chomp; $_ .= &slurp
(scalar <FIL
>); }
115 if (/\bGNOME_CLASS_BOILERPLATE\s*\([^,]*,\s*([a-zA-Z_]+[a-zA-Z_0-9]*)\s*,[^,]*,[^,]*\)/) {
116 $pis_an_object_type->{$1} = 1;
120 if (/\bGSF_CLASS(_ABSTRACT)?\b/) {
121 # print "$filename: $_";
122 while (!/\)\s*;?\s*$/) { chomp; $_ .= &slurp
(scalar <FIL
>); }
123 if (/\bGSF_CLASS(_ABSTRACT)?\s*\([^,]*,\s*([a-zA-Z_]+[a-zA-Z_0-9]*)\s*,[^,]*,[^,]*,[^,]*\)/) {
124 $pis_an_object_type->{$2} = 1;
131 print STDERR
"$0: Cannot read `$filename': $!\b";
136 # -----------------------------------------------------------------------------
139 my ($filename,$pis_an_object_type) = @_;
142 if (open (*FIL
, "<$filename")) {
143 # print "Checking $filename...\n";
146 my $funcname = undef;
153 if ($state == 1 && /^(([a-zA-Z_]+[a-zA-Z_0-9]*)_(finalize|destroy|dispose|unrealize))\s*\([^,]+\)/) {
157 if (!$pis_an_object_type->{$type}) {
158 # print "NO TYPE: $type\n";
169 print "$filename:$lineno: apparently missing chain in $funcname.\n";
175 if (/->\s*$handler\s*\)?\s*\(/ ||
176 /GNOME_CALL_PARENT.*,\s*$handler\s*,/ ||
177 (/gnm_command_$handler/ && $funcname =~ /^cmd_/) ||
178 /g_object_dtor\s*\)?\s*\(/) {
186 print STDERR
"$0: Cannot read `$filename': $!\b";
191 # -----------------------------------------------------------------------------