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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 $0 =~ m
%^(.*?
/?tools)/winapi
/winapi_fixup
$%;
24 require "$1/winapi/setup.pm";
28 &file_type &files_filter
29 &file_skip &files_skip
32 $current_dir $wine_dir $winapi_dir $winapi_check_dir
34 use output qw($output);
35 use winapi_fixup_options qw($options);
37 if($options->progress) {
38 $output->enable_progress;
40 $output->disable_progress;
47 use winapi_fixup_documentation qw(&fixup_documentation);
48 use winapi_fixup_editor
;
49 use winapi_fixup_statements
qw(&fixup_statements);
51 my @c_files = $options->c_files;
52 @c_files = files_skip
(@c_files);
53 @c_files = files_filter
("winelib", @c_files);
56 my $progress_current = 0;
57 my $progress_max = scalar(@c_files);
59 foreach my $file (@c_files) {
60 my $editor = new winapi_fixup_editor
($file);
63 $output->progress("$file (file $progress_current of $progress_max)");
64 $output->prefix("$file:");
76 while(s/^.*?\n//) { $max_line++; }
77 if($_) { $max_line++; }
82 $parser = new c_parser
($file);
84 $parser = new winapi_c_parser
($file);
90 my $update_output = sub {
94 $progress .= "$file (file $progress_current of $progress_max)";
97 if(defined($function)) {
98 my $name = $function->name;
99 my $begin_line = $function->begin_line;
100 my $begin_column = $function->begin_column;
102 $progress .= ": function $name";
103 $prefix .= "$begin_line.$begin_column: function $name: ";
107 $progress .= ": line $line of $max_line";
110 $output->progress($progress);
111 $output->prefix($prefix);
114 my $found_preprocessor = sub {
115 my $begin_line = shift;
116 my $begin_column = shift;
117 my $preprocessor = shift;
119 # $output->write("$begin_line.$begin_column: preprocessor: $preprocessor\n");
124 $parser->set_found_preprocessor_callback($found_preprocessor);
126 my $found_comment = sub {
127 my $begin_line = shift;
128 my $begin_column = shift;
131 # $output->write("$begin_line.$begin_column: comment: $comment\n");
136 $parser->set_found_comment_callback($found_comment);
138 my $found_line = sub {
144 # $output->progress("$file: line $line of ?");
147 $parser->set_found_line_callback($found_line);
149 my $found_declaration = sub {
150 my $begin_line = shift;
151 my $begin_column = shift;
152 my $end_line = shift;
153 my $end_column = shift;
154 my $declaration = shift;
156 # $output->write("$begin_line.$begin_column-$end_line.$end_column: declaration: \\\n$declaration\n");
161 $parser->set_found_declaration_callback($found_declaration);
163 my $found_function = sub {
168 my $name = $function->name;
169 my $begin_line = $function->begin_line;
170 my $begin_column = $function->begin_column;
171 my $end_line = $function->end_line;
172 my $end_column = $function->end_column;
174 if($options->documentation) {
175 # fixup_documentation($function, $editor);
178 if($options->statements) {
179 fixup_statements
($function, $editor);
182 my $statements = $function->statements;
183 if(!defined($statements)) {
185 $output->prefix("$file: ");
187 # $output->write("$begin_line.$begin_column-$end_line.$end_column: function $name\n");
193 $parser->set_found_function_callback($found_function);
195 my $found_variable = sub {
196 my $begin_line = shift;
197 my $begin_column = shift;
202 # $output->write("$begin_line.$begin_column: $linkage $type $name = /* ... */\n");
207 $parser->set_found_variable_callback($found_variable);
209 my $found_function_call = sub {
210 my $begin_line = shift;
211 my $begin_column = shift;
212 my $end_line = shift;
213 my $end_column = shift;
215 my $arguments = shift;
217 $output->write("$begin_line.$begin_column-$end_line.$end_column: $name(" . join(", ", @
$arguments) . ")\n");
222 $parser->set_found_function_call_callback($found_function_call);
227 if(!$parser->parse_c_file(\
$_, \
$line, \
$column)) {
228 $output->write("can't parse file\n");