Sweden-Number/tools/winapi/winapi_fixup

153 lines
3.3 KiB
Plaintext
Raw Normal View History

#!/usr/bin/perl -w
# Copyright 2001 Patrik Stridvall
use strict;
BEGIN {
$0 =~ m%^(.*?/?tools)/winapi/winapi_fixup$%;
require "$1/winapi/setup.pm";
}
use config qw(
2001-06-21 00:53:21 +02:00
&file_type &files_filter
&file_skip &files_skip
&file_normalize
2001-06-19 05:34:39 +02:00
&get_spec_files
$current_dir $wine_dir $winapi_dir $winapi_check_dir
);
use output qw($output);
use winapi_fixup_options qw($options);
if($options->progress) {
$output->enable_progress;
} else {
$output->disable_progress;
}
use c_parser;
use type;
use winapi_fixup_documentation qw(&fixup_documentation);
use winapi_fixup_editor;
use winapi_fixup_statements qw(&fixup_statements);
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);
my $progress_output;
my $progress_current = 0;
my $progress_max = scalar(@c_files);
foreach my $file (@c_files) {
my $editor = new winapi_fixup_editor($file);
2001-06-19 05:34:39 +02:00
$progress_current++;
$output->progress("$file (file $progress_current of $progress_max)");
$output->prefix("$file:");
{
open(IN, "< $file");
local $/ = undef;
$_ = <IN>;
close(IN);
}
my $parser = new c_parser($file);
my $found_preprocessor = sub {
my $begin_line = shift;
my $begin_column = shift;
my $preprocessor = shift;
2001-06-21 00:53:21 +02:00
# $output->write("$begin_line.$begin_column: preprocessor: $preprocessor\n");
return 1;
};
$parser->set_found_preprocessor_callback($found_preprocessor);
2001-07-02 03:21:48 +02:00
my $found_comment = sub {
my $begin_line = shift;
my $begin_column = shift;
my $comment = shift;
# $output->write("$begin_line.$begin_column: comment: $comment\n");
return 1;
};
$parser->set_found_comment_callback($found_comment);
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
$parser->set_found_declaration_callback($found_declaration);
my $function;
my $found_function = sub {
$function = shift;
my $name = $function->name;
my $begin_line = $function->begin_line;
my $begin_column = $function->begin_column;
$output->progress("$file (file $progress_current of $progress_max): $name");
$output->prefix("$file:$begin_line: function $name: ");
# $output->prefix_callback(sub { return $function->prefix; });
if($options->documentation) {
# fixup_documentation($function, $editor);
2001-07-08 22:33:20 +02:00
}
if($options->statements) {
fixup_statements($function, $editor);
}
my $statements = $function->statements;
if(!defined($statements)) {
$function = undef;
$output->prefix("$file: ");
}
2001-06-19 05:34:39 +02:00
return 0;
};
$parser->set_found_function_callback($found_function);
my $found_variable = sub {
my $begin_line = shift;
my $begin_column = shift;
my $linkage = shift;
my $type = shift;
my $name = shift;
# $output->write("$begin_line.$begin_column: $linkage $type $name\n");
return 1;
};
$parser->set_found_variable_callback($found_variable);
my $line = 1;
my $column = 0;
if(!$parser->parse_c_file(\$_, \$line, \$column)) {
$output->write("can't parse file\n");
}
$output->prefix("");
$editor->flush;
}