3 # Copyright 2001 Patrik Stridvall
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 $0 =~ m
%^(.*?
/?tools)/winapi
/winapi_fixup
$%;
24 require "$1/winapi/setup.pm";
28 files_filter files_skip
29 $current_dir $wine_dir $winapi_dir
31 use output qw($output);
32 use winapi_fixup_options qw($options);
34 if($options->progress) {
35 $output->enable_progress;
37 $output->disable_progress;
44 use winapi_fixup_documentation qw(fixup_documentation);
45 use winapi_fixup_editor
;
46 use winapi_fixup_statements
qw(fixup_statements);
48 my @c_files = $options->c_files;
49 @c_files = files_skip
(@c_files);
50 @c_files = files_filter
("winelib", @c_files);
53 my $progress_current = 0;
54 my $progress_max = scalar(@c_files);
56 foreach my $file (@c_files) {
57 my $editor = new winapi_fixup_editor
($file);
60 $output->progress("$file (file $progress_current of $progress_max)");
61 $output->prefix("$file:");
64 open(IN
, "< $file") || die "Error: Can't open $file: $!\n";
73 while(s/^.*?\n//) { $max_line++; }
74 if($_) { $max_line++; }
79 $parser = new c_parser
($file);
81 $parser = new winapi_c_parser
($file);
87 my $update_output = sub {
91 $progress .= "$file (file $progress_current of $progress_max)";
94 if(defined($function)) {
95 my $name = $function->name;
96 my $begin_line = $function->begin_line;
97 my $begin_column = $function->begin_column;
99 $progress .= ": function $name";
100 $prefix .= "$begin_line.$begin_column: function $name: ";
104 $progress .= ": line $line of $max_line";
107 $output->progress($progress);
108 $output->prefix($prefix);
111 my $found_preprocessor = sub {
112 my $begin_line = shift;
113 my $begin_column = shift;
114 my $preprocessor = shift;
116 # $output->write("$begin_line.$begin_column: preprocessor: $preprocessor\n");
121 $parser->set_found_preprocessor_callback($found_preprocessor);
123 my $found_comment = sub {
124 my $begin_line = shift;
125 my $begin_column = shift;
128 # $output->write("$begin_line.$begin_column: comment: $comment\n");
133 $parser->set_found_comment_callback($found_comment);
135 my $found_line = sub {
141 # $output->progress("$file: line $line of ?");
144 $parser->set_found_line_callback($found_line);
146 my $found_declaration = sub {
147 my $begin_line = shift;
148 my $begin_column = shift;
149 my $end_line = shift;
150 my $end_column = shift;
151 my $declaration = shift;
153 # $output->write("$begin_line.$begin_column-$end_line.$end_column: declaration: \\\n$declaration\n");
158 $parser->set_found_declaration_callback($found_declaration);
160 my $found_function = sub {
165 my $name = $function->name;
166 my $begin_line = $function->begin_line;
167 my $begin_column = $function->begin_column;
168 my $end_line = $function->end_line;
169 my $end_column = $function->end_column;
171 if($options->documentation) {
172 # fixup_documentation($function, $editor);
175 if($options->statements) {
176 fixup_statements
($function, $editor);
179 my $statements = $function->statements;
180 if(!defined($statements)) {
182 $output->prefix("$file: ");
184 # $output->write("$begin_line.$begin_column-$end_line.$end_column: function $name\n");
190 $parser->set_found_function_callback($found_function);
192 my $found_variable = sub {
193 my $begin_line = shift;
194 my $begin_column = shift;
199 # $output->write("$begin_line.$begin_column: $linkage $type $name = /* ... */\n");
204 $parser->set_found_variable_callback($found_variable);
206 my $found_function_call = sub {
207 my $begin_line = shift;
208 my $begin_column = shift;
209 my $end_line = shift;
210 my $end_column = shift;
212 my $arguments = shift;
214 $output->write("$begin_line.$begin_column-$end_line.$end_column: $name(" . join(", ", @
$arguments) . ")\n");
219 $parser->set_found_function_call_callback($found_function_call);
224 if(!$parser->parse_c_file(\
$_, \
$line, \
$column)) {
225 $output->write("can't parse file\n");