twain_32/tests: Add a trailing '\n' to ok() calls.
[wine/gsoc-2012-control.git] / tools / winapi / winapi_fixup
blob334aa52a5d90215dc68a7931f58630bb35d922b9
1 #!/usr/bin/perl -w
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
20 use strict;
22 BEGIN {
23 $0 =~ m%^(.*?/?tools)/winapi/winapi_fixup$%;
24 require "$1/winapi/setup.pm";
27 use config qw(
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;
36 } else {
37 $output->disable_progress;
40 use winapi_c_parser;
41 use c_parser;
42 use type;
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);
52 my $progress_output;
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);
59 $progress_current++;
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";
65 local $/ = undef;
66 $_ = <IN>;
67 close(IN);
70 my $max_line = 0;
72 local $_ = $_;
73 while(s/^.*?\n//) { $max_line++; }
74 if($_) { $max_line++; }
77 my $parser;
78 if (1) {
79 $parser = new c_parser($file);
80 } else {
81 $parser = new winapi_c_parser($file);
84 my $function;
85 my $line;
87 my $update_output = sub {
88 my $progress = "";
89 my $prefix = "";
91 $progress .= "$file (file $progress_current of $progress_max)";
92 $prefix .= "$file:";
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: ";
103 if(defined($line)) {
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");
118 return 1;
121 $parser->set_found_preprocessor_callback($found_preprocessor);
123 my $found_comment = sub {
124 my $begin_line = shift;
125 my $begin_column = shift;
126 my $comment = shift;
128 # $output->write("$begin_line.$begin_column: comment: $comment\n");
130 return 1;
133 $parser->set_found_comment_callback($found_comment);
135 my $found_line = sub {
136 $line = shift;
137 # local $_ = shift;
139 &$update_output;
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");
155 return 1;
158 $parser->set_found_declaration_callback($found_declaration);
160 my $found_function = sub {
161 $function = shift;
163 &$update_output;
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)) {
181 $function = undef;
182 $output->prefix("$file: ");
183 } else {
184 # $output->write("$begin_line.$begin_column-$end_line.$end_column: function $name\n");
187 return 0;
190 $parser->set_found_function_callback($found_function);
192 my $found_variable = sub {
193 my $begin_line = shift;
194 my $begin_column = shift;
195 my $linkage = shift;
196 my $type = shift;
197 my $name = shift;
199 # $output->write("$begin_line.$begin_column: $linkage $type $name = /* ... */\n");
201 return 1;
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;
211 my $name = shift;
212 my $arguments = shift;
214 $output->write("$begin_line.$begin_column-$end_line.$end_column: $name(" . join(", ", @$arguments) . ")\n");
216 return 1;
219 $parser->set_found_function_call_callback($found_function_call);
222 my $line = 1;
223 my $column = 0;
224 if(!$parser->parse_c_file(\$_, \$line, \$column)) {
225 $output->write("can't parse file\n");
229 $output->prefix("");
231 $editor->flush;