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;
46 use winapi_fixup_documentation qw(&fixup_documentation);
47 use winapi_fixup_editor
;
48 use winapi_fixup_statements
qw(&fixup_statements);
50 my @c_files = $options->c_files;
51 @c_files = files_skip
(@c_files);
52 @c_files = files_filter
("winelib", @c_files);
55 my $progress_current = 0;
56 my $progress_max = scalar(@c_files);
58 foreach my $file (@c_files) {
59 my $editor = new winapi_fixup_editor
($file);
62 $output->progress("$file (file $progress_current of $progress_max)");
63 $output->prefix("$file:");
75 while(s/^.*?\n//) { $max_line++; }
76 if($_) { $max_line++; }
79 my $parser = new c_parser
($file);
84 my $update_output = sub {
88 $progress .= "$file (file $progress_current of $progress_max)";
91 if(defined($function)) {
92 my $name = $function->name;
93 my $begin_line = $function->begin_line;
94 my $begin_column = $function->begin_column;
96 $progress .= ": function $name";
97 $prefix .= "$begin_line.$begin_column: function $name: ";
101 $progress .= ": line $line of $max_line";
104 $output->progress($progress);
105 $output->prefix($prefix);
108 my $found_preprocessor = sub {
109 my $begin_line = shift;
110 my $begin_column = shift;
111 my $preprocessor = shift;
113 # $output->write("$begin_line.$begin_column: preprocessor: $preprocessor\n");
118 $parser->set_found_preprocessor_callback($found_preprocessor);
120 my $found_comment = sub {
121 my $begin_line = shift;
122 my $begin_column = shift;
125 # $output->write("$begin_line.$begin_column: comment: $comment\n");
130 $parser->set_found_comment_callback($found_comment);
132 my $found_line = sub {
138 # $output->progress("$file: line $line of ?");
141 $parser->set_found_line_callback($found_line);
143 my $found_declaration = sub {
144 my $begin_line = shift;
145 my $begin_column = shift;
146 my $end_line = shift;
147 my $end_column = shift;
148 my $declaration = shift;
150 # $output->write("$begin_line.$begin_column-$end_line.$end_column: declaration: \\\n$declaration\n");
155 $parser->set_found_declaration_callback($found_declaration);
157 my $found_function = sub {
162 my $name = $function->name;
163 my $begin_line = $function->begin_line;
164 my $begin_column = $function->begin_column;
165 my $end_line = $function->end_line;
166 my $end_column = $function->end_column;
168 if($options->documentation) {
169 # fixup_documentation($function, $editor);
172 if($options->statements) {
173 fixup_statements
($function, $editor);
176 my $statements = $function->statements;
177 if(!defined($statements)) {
179 $output->prefix("$file: ");
181 # $output->write("$begin_line.$begin_column-$end_line.$end_column: function $name\n");
187 $parser->set_found_function_callback($found_function);
189 my $found_variable = sub {
190 my $begin_line = shift;
191 my $begin_column = shift;
196 # $output->write("$begin_line.$begin_column: $linkage $type $name = /* ... */\n");
201 $parser->set_found_variable_callback($found_variable);
203 my $found_function_call = sub {
204 my $begin_line = shift;
205 my $begin_column = shift;
206 my $end_line = shift;
207 my $end_column = shift;
209 my $arguments = shift;
211 $output->write("$begin_line.$begin_column-$end_line.$end_column: $name(" . join(", ", @
$arguments) . ")\n");
216 $parser->set_found_function_call_callback($found_function_call);
221 if(!$parser->parse_c_file(\
$_, \
$line, \
$column)) {
222 $output->write("can't parse file\n");