2001-06-13 21:38:29 +02:00
|
|
|
#!/usr/bin/perl -w
|
|
|
|
|
|
|
|
# Copyright 2001 Patrik Stridvall
|
2002-03-10 00:29:33 +01:00
|
|
|
#
|
|
|
|
# This library is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
|
|
# License as published by the Free Software Foundation; either
|
|
|
|
# version 2.1 of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This library is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
|
|
# License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-03-10 00:29:33 +01:00
|
|
|
#
|
2001-06-13 21:38:29 +02:00
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
BEGIN {
|
|
|
|
$0 =~ m%^(.*?/?tools)/winapi/winapi_fixup$%;
|
|
|
|
require "$1/winapi/setup.pm";
|
|
|
|
}
|
|
|
|
|
|
|
|
use config qw(
|
2006-01-06 12:17:46 +01:00
|
|
|
files_filter files_skip
|
2005-05-04 12:43:00 +02:00
|
|
|
$current_dir $wine_dir $winapi_dir
|
2001-06-13 21:38:29 +02:00
|
|
|
);
|
2001-07-24 01:20:56 +02:00
|
|
|
use output qw($output);
|
|
|
|
use winapi_fixup_options qw($options);
|
2001-06-13 21:38:29 +02:00
|
|
|
|
2001-08-22 20:09:15 +02:00
|
|
|
if($options->progress) {
|
|
|
|
$output->enable_progress;
|
|
|
|
} else {
|
|
|
|
$output->disable_progress;
|
|
|
|
}
|
|
|
|
|
2002-09-23 22:38:30 +02:00
|
|
|
use winapi_c_parser;
|
2001-08-22 20:09:15 +02:00
|
|
|
use c_parser;
|
2001-07-26 23:42:12 +02:00
|
|
|
use type;
|
2001-06-13 21:38:29 +02:00
|
|
|
|
2004-10-26 02:12:21 +02:00
|
|
|
use winapi_fixup_documentation qw(fixup_documentation);
|
2001-08-09 23:35:38 +02:00
|
|
|
use winapi_fixup_editor;
|
2004-10-26 02:12:21 +02:00
|
|
|
use winapi_fixup_statements qw(fixup_statements);
|
2001-08-09 23:35:38 +02:00
|
|
|
|
2001-07-11 19:27:45 +02:00
|
|
|
my @c_files = $options->c_files;
|
2001-06-21 00:53:21 +02:00
|
|
|
@c_files = files_skip(@c_files);
|
|
|
|
@c_files = files_filter("winelib", @c_files);
|
2001-06-13 21:38:29 +02:00
|
|
|
|
|
|
|
my $progress_output;
|
|
|
|
my $progress_current = 0;
|
|
|
|
my $progress_max = scalar(@c_files);
|
|
|
|
|
|
|
|
foreach my $file (@c_files) {
|
2001-08-09 23:35:38 +02:00
|
|
|
my $editor = new winapi_fixup_editor($file);
|
2001-06-19 05:34:39 +02:00
|
|
|
|
2001-06-13 21:38:29 +02:00
|
|
|
$progress_current++;
|
2001-08-22 20:09:15 +02:00
|
|
|
$output->progress("$file (file $progress_current of $progress_max)");
|
|
|
|
$output->prefix("$file:");
|
|
|
|
|
|
|
|
{
|
|
|
|
open(IN, "< $file");
|
|
|
|
local $/ = undef;
|
|
|
|
$_ = <IN>;
|
|
|
|
close(IN);
|
2001-06-13 21:38:29 +02:00
|
|
|
}
|
2002-06-01 04:55:48 +02:00
|
|
|
|
2001-09-11 01:16:05 +02:00
|
|
|
my $max_line = 0;
|
2002-06-01 04:55:48 +02:00
|
|
|
{
|
2001-09-11 01:16:05 +02:00
|
|
|
local $_ = $_;
|
|
|
|
while(s/^.*?\n//) { $max_line++; }
|
|
|
|
if($_) { $max_line++; }
|
|
|
|
}
|
|
|
|
|
2002-09-23 22:38:30 +02:00
|
|
|
my $parser;
|
|
|
|
if (1) {
|
|
|
|
$parser = new c_parser($file);
|
|
|
|
} else {
|
|
|
|
$parser = new winapi_c_parser($file);
|
|
|
|
}
|
2001-08-22 20:09:15 +02:00
|
|
|
|
2001-09-11 01:16:05 +02:00
|
|
|
my $function;
|
|
|
|
my $line;
|
|
|
|
|
|
|
|
my $update_output = sub {
|
|
|
|
my $progress = "";
|
|
|
|
my $prefix = "";
|
|
|
|
|
|
|
|
$progress .= "$file (file $progress_current of $progress_max)";
|
|
|
|
$prefix .= "$file:";
|
|
|
|
|
|
|
|
if(defined($function)) {
|
|
|
|
my $name = $function->name;
|
|
|
|
my $begin_line = $function->begin_line;
|
|
|
|
my $begin_column = $function->begin_column;
|
|
|
|
|
|
|
|
$progress .= ": function $name";
|
|
|
|
$prefix .= "$begin_line.$begin_column: function $name: ";
|
|
|
|
}
|
|
|
|
|
|
|
|
if(defined($line)) {
|
|
|
|
$progress .= ": line $line of $max_line";
|
|
|
|
}
|
|
|
|
|
|
|
|
$output->progress($progress);
|
|
|
|
$output->prefix($prefix);
|
|
|
|
};
|
|
|
|
|
2001-08-22 20:09:15 +02:00
|
|
|
my $found_preprocessor = sub {
|
|
|
|
my $begin_line = shift;
|
|
|
|
my $begin_column = shift;
|
|
|
|
my $preprocessor = shift;
|
2001-06-21 00:53:21 +02:00
|
|
|
|
2001-08-22 20:09:15 +02:00
|
|
|
# $output->write("$begin_line.$begin_column: preprocessor: $preprocessor\n");
|
|
|
|
|
|
|
|
return 1;
|
2001-07-26 23:42:12 +02:00
|
|
|
};
|
|
|
|
|
2002-06-01 04:55:48 +02:00
|
|
|
$parser->set_found_preprocessor_callback($found_preprocessor);
|
2001-07-02 03:21:48 +02:00
|
|
|
|
2001-08-22 20:09:15 +02:00
|
|
|
my $found_comment = sub {
|
|
|
|
my $begin_line = shift;
|
|
|
|
my $begin_column = shift;
|
|
|
|
my $comment = shift;
|
2001-06-13 21:38:29 +02:00
|
|
|
|
2001-08-22 20:09:15 +02:00
|
|
|
# $output->write("$begin_line.$begin_column: comment: $comment\n");
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
};
|
|
|
|
|
2002-06-01 04:55:48 +02:00
|
|
|
$parser->set_found_comment_callback($found_comment);
|
2001-08-22 20:09:15 +02:00
|
|
|
|
2001-09-11 01:16:05 +02:00
|
|
|
my $found_line = sub {
|
|
|
|
$line = shift;
|
|
|
|
# local $_ = shift;
|
|
|
|
|
|
|
|
&$update_output;
|
|
|
|
|
|
|
|
# $output->progress("$file: line $line of ?");
|
|
|
|
};
|
|
|
|
|
|
|
|
$parser->set_found_line_callback($found_line);
|
|
|
|
|
2001-08-22 20:09:15 +02:00
|
|
|
my $found_declaration = sub {
|
|
|
|
my $begin_line = shift;
|
|
|
|
my $begin_column = shift;
|
|
|
|
my $end_line = shift;
|
|
|
|
my $end_column = shift;
|
|
|
|
my $declaration = shift;
|
|
|
|
|
|
|
|
# $output->write("$begin_line.$begin_column-$end_line.$end_column: declaration: \\\n$declaration\n");
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
};
|
2001-06-19 05:34:39 +02:00
|
|
|
|
2002-06-01 04:55:48 +02:00
|
|
|
$parser->set_found_declaration_callback($found_declaration);
|
2001-08-22 20:09:15 +02:00
|
|
|
|
|
|
|
my $found_function = sub {
|
|
|
|
$function = shift;
|
2001-09-11 01:16:05 +02:00
|
|
|
|
|
|
|
&$update_output;
|
|
|
|
|
2001-08-22 20:09:15 +02:00
|
|
|
my $name = $function->name;
|
|
|
|
my $begin_line = $function->begin_line;
|
|
|
|
my $begin_column = $function->begin_column;
|
2001-09-11 01:16:05 +02:00
|
|
|
my $end_line = $function->end_line;
|
|
|
|
my $end_column = $function->end_column;
|
|
|
|
|
2001-08-09 23:35:38 +02:00
|
|
|
if($options->documentation) {
|
2001-08-22 20:09:15 +02:00
|
|
|
# fixup_documentation($function, $editor);
|
2001-07-08 22:33:20 +02:00
|
|
|
}
|
2002-06-01 04:55:48 +02:00
|
|
|
|
2001-08-09 23:35:38 +02:00
|
|
|
if($options->statements) {
|
|
|
|
fixup_statements($function, $editor);
|
2001-06-13 21:38:29 +02:00
|
|
|
}
|
2002-06-01 04:55:48 +02:00
|
|
|
|
2001-08-22 20:09:15 +02:00
|
|
|
my $statements = $function->statements;
|
|
|
|
if(!defined($statements)) {
|
|
|
|
$function = undef;
|
|
|
|
$output->prefix("$file: ");
|
2001-09-11 01:16:05 +02:00
|
|
|
} else {
|
|
|
|
# $output->write("$begin_line.$begin_column-$end_line.$end_column: function $name\n");
|
2001-08-22 20:09:15 +02:00
|
|
|
}
|
2001-06-19 05:34:39 +02:00
|
|
|
|
2001-08-22 20:09:15 +02:00
|
|
|
return 0;
|
2001-07-26 23:42:12 +02:00
|
|
|
};
|
2002-06-01 04:55:48 +02:00
|
|
|
|
2001-08-22 20:09:15 +02:00
|
|
|
$parser->set_found_function_callback($found_function);
|
2001-07-26 23:42:12 +02:00
|
|
|
|
2001-08-22 20:09:15 +02:00
|
|
|
my $found_variable = sub {
|
|
|
|
my $begin_line = shift;
|
|
|
|
my $begin_column = shift;
|
|
|
|
my $linkage = shift;
|
2001-07-26 23:42:12 +02:00
|
|
|
my $type = shift;
|
2001-08-22 20:09:15 +02:00
|
|
|
my $name = shift;
|
2001-07-26 23:42:12 +02:00
|
|
|
|
2001-09-11 01:16:05 +02:00
|
|
|
# $output->write("$begin_line.$begin_column: $linkage $type $name = /* ... */\n");
|
2002-06-01 04:55:48 +02:00
|
|
|
|
2001-08-22 20:09:15 +02:00
|
|
|
return 1;
|
2001-06-13 21:38:29 +02:00
|
|
|
};
|
|
|
|
|
2002-06-01 04:55:48 +02:00
|
|
|
$parser->set_found_variable_callback($found_variable);
|
2001-08-22 20:09:15 +02:00
|
|
|
|
2001-09-11 01:16:05 +02:00
|
|
|
my $found_function_call = sub {
|
|
|
|
my $begin_line = shift;
|
|
|
|
my $begin_column = shift;
|
|
|
|
my $end_line = shift;
|
|
|
|
my $end_column = shift;
|
|
|
|
my $name = shift;
|
|
|
|
my $arguments = shift;
|
|
|
|
|
|
|
|
$output->write("$begin_line.$begin_column-$end_line.$end_column: $name(" . join(", ", @$arguments) . ")\n");
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
};
|
|
|
|
|
|
|
|
$parser->set_found_function_call_callback($found_function_call);
|
|
|
|
|
|
|
|
{
|
|
|
|
my $line = 1;
|
|
|
|
my $column = 0;
|
|
|
|
if(!$parser->parse_c_file(\$_, \$line, \$column)) {
|
|
|
|
$output->write("can't parse file\n");
|
|
|
|
}
|
2001-08-22 20:09:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$output->prefix("");
|
2001-06-13 21:38:29 +02:00
|
|
|
|
2001-08-09 23:35:38 +02:00
|
|
|
$editor->flush;
|
2001-06-13 21:38:29 +02:00
|
|
|
}
|