- Continued on the new C parser.

- More reorganizations and fixes.
- API files update.
This commit is contained in:
Patrik Stridvall 2001-08-22 18:09:15 +00:00 committed by Alexandre Julliard
parent 615c0e0ca5
commit aeb023f352
20 changed files with 1844 additions and 275 deletions

168
tools/winapi/c_function.pm Normal file
View File

@ -0,0 +1,168 @@
package c_function;
use strict;
sub new {
my $proto = shift;
my $class = ref($proto) || $proto;
my $self = {};
bless ($self, $class);
return $self;
}
sub file {
my $self = shift;
my $file = \${$self->{FILE}};
local $_ = shift;
if(defined($_)) { $$file = $_; }
return $$file;
}
sub begin_line {
my $self = shift;
my $begin_line = \${$self->{BEGIN_LINE}};
local $_ = shift;
if(defined($_)) { $$begin_line = $_; }
return $$begin_line;
}
sub begin_column {
my $self = shift;
my $begin_column = \${$self->{BEGIN_COLUMN}};
local $_ = shift;
if(defined($_)) { $$begin_column = $_; }
return $$begin_column;
}
sub end_line {
my $self = shift;
my $end_line = \${$self->{END_LINE}};
local $_ = shift;
if(defined($_)) { $$end_line = $_; }
return $$end_line;
}
sub end_column {
my $self = shift;
my $end_column = \${$self->{END_COLUMN}};
local $_ = shift;
if(defined($_)) { $$end_column = $_; }
return $$end_column;
}
sub linkage {
my $self = shift;
my $linkage = \${$self->{LINKAGE}};
local $_ = shift;
if(defined($_)) { $$linkage = $_; }
return $$linkage;
}
sub return_type {
my $self = shift;
my $return_type = \${$self->{RETURN_TYPE}};
local $_ = shift;
if(defined($_)) { $$return_type = $_; }
return $$return_type;
}
sub calling_convention {
my $self = shift;
my $calling_convention = \${$self->{CALLING_CONVENTION}};
local $_ = shift;
if(defined($_)) { $$calling_convention = $_; }
return $$calling_convention;
}
sub name {
my $self = shift;
my $name = \${$self->{NAME}};
local $_ = shift;
if(defined($_)) { $$name = $_; }
return $$name;
}
sub argument_types {
my $self = shift;
my $argument_types = \${$self->{ARGUMENT_TYPES}};
local $_ = shift;
if(defined($_)) { $$argument_types = $_; }
return $$argument_types;
}
sub argument_names {
my $self = shift;
my $argument_names = \${$self->{ARGUMENT_NAMES}};
local $_ = shift;
if(defined($_)) { $$argument_names = $_; }
return $$argument_names;
}
sub statements_line {
my $self = shift;
my $statements_line = \${$self->{STATEMENTS_LINE}};
local $_ = shift;
if(defined($_)) { $$statements_line = $_; }
return $$statements_line;
}
sub statements_column {
my $self = shift;
my $statements_column = \${$self->{STATEMENTS_COLUMN}};
local $_ = shift;
if(defined($_)) { $$statements_column = $_; }
return $$statements_column;
}
sub statements {
my $self = shift;
my $statements = \${$self->{STATEMENTS}};
local $_ = shift;
if(defined($_)) { $$statements = $_; }
return $$statements;
}
1;

File diff suppressed because it is too large Load Diff

View File

@ -51,9 +51,9 @@ sub error {
}
if(defined($tool)) {
$output->write("make_filter: $context: can't parse output: '$current'\n");
$output->write("$directory: $context: can't parse output: '$current'\n");
} else {
$output->write("make_filter: $context: can't parse output: '$current'\n");
$output->write("$directory: $context: can't parse output: '$current'\n");
}
exit 1;
}
@ -133,8 +133,12 @@ sub line {
# Nothing
} elsif($tool eq "gcc" && /^(?:In file included |\s*)from (.+?):(\d+)[,:]$/) {
# Nothing
} elsif($tool =~ /^gcc|ld$/ && s/^(.+?\.o(?:\(.*?\))?):\s*//) {
ld_output($1, $_)
} elsif($tool =~ /^gcc|ld$/ && s/^(.+?\.s?o)(?:\(.*?\))?:\s*//) {
$tool = "ld";
ld_output($1, $_);
} elsif($tool =~ /^gcc|ld$/ && s/^collect2:\s*//) {
$tool = "ld";
ld_output("collect2", $_);
} elsif($tool eq "gcc" && s/^(.+?\.[chly]):\s*//) {
gcc_output($1, $_);
} elsif($tool eq "winebuild" && s/^(.+?\.spec):\s*//) {
@ -427,13 +431,13 @@ sub gcc_output {
# Nothing
} elsif(/^((?:signed |unsigned )?(?:int|long)) format, (different type|\S+) arg \(arg (\d+)\)$/) {
my $type = $2;
if($type =~ /^
HACCEL|HANDLE|HBITMAP|HBRUSH|HCALL|HCURSOR|HDC|HDRVR|HDESK|
HGDIOBJ|HKL|HGLOBAL|HINSTANCE|HKEY|
if($type =~ /^(?:
HACCEL|HACMDRIVER|HANDLE|HBITMAP|HBRUSH|HCALL|HCURSOR|HDC|HDRVR|HDESK|HDRAWDIB
HGDIOBJ|HKL|HGLOBAL|HIMC|HINSTANCE|HKEY|HLOCAL|
HMENU|HMIDISTRM|HMIDIIN|HMIDIOUT|HMIXER|HMIXEROBJ|HMMIO|HMODULE|
HLINE|HPHONE|HPHONEAPP|
HRASCONN|HRGN|HRSRC|HWAVEIN|HWAVEOUT|HWINSTA|HWND|WSAEVENT|
handle_t|pointer$/x)
HLINE|HPEN|HPHONE|HPHONEAPP|
HRASCONN|HRGN|HRSRC|HWAVEIN|HWAVEOUT|HWINSTA|HWND|
SC_HANDLE|WSAEVENT|handle_t|pointer)$/x)
{
$supress = 1;
} else {
@ -580,8 +584,14 @@ sub ld_output {
$file = shift;
local $_ = shift;
if(/^the use of \`(.+?)\' is dangerous, better use \`(.+?)\'$/) {
# nothing
if(0) {
# Nothing
} elsif(/^In function \`(.*?)\':$/) {
$function = $1;
} elsif(0 && /^the use of \`(.+?)\' is dangerous, better use \`(.+?)\'$/) {
# Nothing
} else {
$message = "$_";
}
}

View File

@ -162,8 +162,13 @@ sub prefix {
my $prefix = \${$self->{PREFIX}};
my $prefix_callback = \${$self->{PREFIX_CALLBACK}};
$$prefix = shift;
my $new_prefix = shift;
if(defined($new_prefix)) {
$$prefix = $new_prefix;
$$prefix_callback = undef;
} else {
return $$prefix;
}
}
sub prefix_callback {

View File

@ -16,6 +16,12 @@ use config qw(
use output qw($output);
use winapi_extract_options qw($options);
if($options->progress) {
$output->enable_progress;
} else {
$output->disable_progress;
}
use function;
use type;
use winapi_function;
@ -144,9 +150,7 @@ foreach my $file (@c_files) {
my %functions;
$progress_current++;
if($options->progress) {
$output->progress("$file: file $progress_current of $progress_max");
}
$output->progress("$file (file $progress_current of $progress_max)");
my $create_function = sub {
if($options->stub_statistics) {
@ -159,19 +163,20 @@ foreach my $file (@c_files) {
my $found_function = sub {
my $function = shift;
my $internal_name = $function->internal_name;
$functions{$internal_name} = $function;
$output->progress("$file (file $progress_current of $progress_max): $internal_name");
$output->prefix_callback(sub { return $function->prefix; });
my $documentation_line = $function->documentation_line;
my $documentation = $function->documentation;
my $function_line = $function->function_line;
my $linkage = $function->linkage;
my $return_type = $function->return_type;
my $calling_convention = $function->calling_convention;
my $internal_name = $function->internal_name;
my $statements = $function->statements;
$functions{$internal_name} = $function;
$output->prefix_callback(sub { return $function->prefix; });
if($options->spec_files) {
documentation_specifications($function);
}

View File

@ -19,9 +19,14 @@ use config qw(
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_function;
use winapi_parser;
use winapi_fixup_documentation qw(&fixup_documentation);
use winapi_fixup_editor;
@ -39,50 +44,109 @@ foreach my $file (@c_files) {
my $editor = new winapi_fixup_editor($file);
$progress_current++;
if($options->progress) {
$output->progress("$file (file $progress_current of $progress_max)");
$output->prefix("$file:");
{
open(IN, "< $file");
local $/ = undef;
$_ = <IN>;
close(IN);
}
my $create_function = sub {
return 'winapi_function'->new;
my $parser = new c_parser($file);
my $found_preprocessor = sub {
my $begin_line = shift;
my $begin_column = shift;
my $preprocessor = shift;
# $output->write("$begin_line.$begin_column: preprocessor: $preprocessor\n");
return 1;
};
$parser->set_found_preprocessor_callback($found_preprocessor);
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;
};
$parser->set_found_declaration_callback($found_declaration);
my $function;
my $found_function = sub {
my $function = shift;
$function = shift;
my $internal_name = $function->internal_name;
if($options->progress) {
$output->progress("$file (file $progress_current of $progress_max): $internal_name");
}
my $name = $function->name;
my $begin_line = $function->begin_line;
my $begin_column = $function->begin_column;
$output->prefix_callback(sub { return $function->prefix; });
$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);
# fixup_documentation($function, $editor);
}
if($options->statements) {
fixup_statements($function, $editor);
}
$output->prefix("");
my $statements = $function->statements;
if(!defined($statements)) {
$function = undef;
$output->prefix("$file: ");
}
return 0;
};
my $create_type = sub {
return 'type'->new;
};
$parser->set_found_function_callback($found_function);
my $found_type = sub {
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;
};
my $found_preprocessor = sub {
my $directive = shift;
my $argument = shift;
};
$parser->set_found_variable_callback($found_variable);
&winapi_parser::parse_c_file($file, $create_function, $found_function, $create_type, $found_type, $found_preprocessor);
my $line = 1;
my $column = 0;
if(!$parser->parse_c_file(\$_, \$line, \$column)) {
$output->write("can't parse file\n");
}
$output->prefix("");
$editor->flush;
}

View File

@ -29,7 +29,7 @@ my %options_long = (
"documentation-ordinal" => { default => 1, parent => "documentation", description => "documentation ordinal fixup" },
"documentation-wrong" => { default => 1, parent => "documentation", description => "documentation wrong fixup" },
"statements" => { default => 1, parent => "local", description => "statements fixup" },
"statements-windowsx" => { default => 1, parent => "local", description => "statements windowsx fixup" },
"statements-windowsx" => { default => 0, parent => "local", description => "statements windowsx fixup" },
"stub" => { default => 0, parent => "local", description => "stub fixup" },
"global" => { default => 1, description => "global fixup" },

View File

@ -9,10 +9,19 @@ require Exporter;
@EXPORT = qw();
@EXPORT_OK = qw(&fixup_statements);
use config qw($wine_dir);
use options qw($options);
use output qw($output);
use c_parser;
use winapi_module_user qw(
&get_message_result_kind
&get_message_wparam_kind
&get_message_lparam_kind
);
########################################################################
# fixup_function_call
sub fixup_function_call {
my $name = shift;
@ -21,37 +30,58 @@ sub fixup_function_call {
return "$name(" . join(", ", @arguments) . ")";
}
########################################################################
# _parse_makelong
sub _parse_makelong {
my $value = shift;
local $_ = shift;
my $low;
my $high;
if($value =~ /^
(?:\(\w+\)\s*)?
MAKE(?:LONG|LPARAM|LRESULT|WPARAM)\s*
\(\s*(.*?)\s*,\s*(.*?)\s*\)$/sx)
my $name;
my @arguments;
my @argument_lines;
my @argument_columns;
my $parser = new c_parser;
my $line = 1;
my $column = 0;
if($parser->parse_c_function_call(\$_, \$line, \$column, \$name, \@arguments, \@argument_lines, \@argument_columns) &&
$name =~ /^MAKE(?:LONG|LPARAM|LRESULT|WPARAM)$/)
{
$low = $1;
$high = $2;
} elsif($value =~ /^(?:\(\w+\)\s*)?0L?$/) {
$low = $arguments[0];
$high = $arguments[1];
} elsif(/^(?:\(\w+\)\s*)?0L?$/) {
$low = "0";
$high = "0";
} else {
$low = "($value) & 0xffff";
$high = "($value) << 16";
$low = "($_) & 0xffff";
$high = "($_) << 16";
}
$low =~ s/^\s*(.*?)\s*$/$1/;
$high =~ s/^\s*(.*?)\s*$/$1/;
return ($low, $high);
}
sub fixup_function_call_2_forward_wm_call {
########################################################################
# fixup_function_call_2_windowsx
sub fixup_user_message_2_windowsx {
my $name = shift;
(my $hwnd, my $msg, my $wparam, my $lparam) = @{(shift)};
if($msg =~ /^(?:WM_BEGINDRAG|WM_ENTERMENULOOP|WM_EXITMENULOOP|WM_HELP|
if($msg !~ /^WM_/) {
return undef;
} elsif($msg =~ /^(?:WM_BEGINDRAG|WM_ENTERMENULOOP|WM_EXITMENULOOP|WM_HELP|
WM_ISACTIVEICON|WM_LBTRACKPOINT|WM_NEXTMENU)$/x)
{
return undef;
} elsif($msg =~ /^WM_(?:GET|SET)TEXT$/) {
return undef;
}
my $suffix;
@ -62,8 +92,8 @@ sub fixup_function_call_2_forward_wm_call {
$suffix = "";
}
$wparam =~ s/^\(WPARAM\)//;
$lparam =~ s/^\(LPARAM\)//;
$wparam =~ s/^\(WPARAM\)\s*//;
$lparam =~ s/^\(LPARAM\)\s*//;
my @arguments;
if(0) {
@ -131,22 +161,119 @@ sub fixup_function_call_2_forward_wm_call {
return "FORWARD_" . $msg . "(" . join(", ", @arguments) . ", $name)";
}
########################################################################
# _fixup_user_message
sub _get_messages {
local $_ = shift;
if(/^WM_\w+$/) {
return ($_)
} elsif(/^(.*?)\s*\?\s*(WM_\w+)\s*:\s*(WM_\w+)$/) {
return ($2, $3);
} elsif(/^\w+$/) {
return ();
} else {
$output->write("_fixup_user_message: '$_'\n");
exit 1;
}
}
########################################################################
# _fixup_user_message
sub _fixup_user_message {
my $name = shift;
(my $hwnd, my $msg, my $wparam, my $lparam) = @{(shift)};
my $modified = 0;
my $wkind;
my $lkind;
foreach my $msg (_get_messages($msg)) {
my $new_wkind = &get_message_wparam_kind($msg);
if(defined($wkind) && $new_wkind ne $wkind) {
$output->write("messsages used together do not have the same type\n");
} else {
$wkind = $new_wkind;
}
my $new_lkind = &get_message_lparam_kind($msg);
if(defined($lkind) && $new_lkind ne $lkind) {
$output->write("messsages used together do not have the same type\n");
} else {
$lkind = $new_lkind;
}
}
my @entries = (
[ \$wparam, $wkind, "W", "w" ],
[ \$lparam, $lkind, "L", "l" ]
);
foreach my $entry (@entries) {
(my $refparam, my $kind, my $upper, my $lower) = @$entry;
if(!defined($kind)) {
if($msg =~ /^WM_/) {
$output->write("messsage $msg not defined\n");
}
} elsif($kind eq "ptr") {
if($$refparam =~ /^(\(${upper}PARAM\))?\s*($lower[pP]aram)$/) {
if(defined($1)) {
$$refparam = $2;
$modified = 1;
}
} elsif($$refparam =~ /^(\(${upper}PARAM\))?\s*0$/) {
$$refparam = "(${upper}PARAM) NULL";
$modified = 1;
} elsif($$refparam !~ /^\(${upper}PARAM\)\s*/) {
$$refparam = "(${upper}PARAM) $$refparam";
$modified = 1;
}
} elsif($kind eq "long") {
if($$refparam =~ s/^\(${upper}PARAM\)\s*//) {
$modified = 1;
}
}
}
if($modified) {
my @arguments = ($hwnd, $msg, $wparam, $lparam);
return "$name(" . join(", ", @arguments) . ")";
} else {
return undef;
}
}
########################################################################
# fixup_statements
sub fixup_statements {
my $function = shift;
my $editor = shift;
my $file = $function->file;
my $linkage = $function->linkage;
my $internal_name = $function->internal_name;
my $name = $function->name;
my $statements_line = $function->statements_line;
my $statements_column = $function->statements_column;
my $statements = $function->statements;
if(($linkage eq "extern" && !defined($statements)) ||
($linkage eq "" && !defined($statements)))
{
if(!defined($statements)) {
return;
}
if($options->statements_windowsx && defined($statements)) {
if(0 && $statements_line > 490) {
$output->write("$statements_line: \\\n");
my $line = $statements_line;
foreach my $statement (split(/\n/, $statements)) {
$output->write("$line: $statement\n");
$line++;
}
}
my $parser = new c_parser($file);
my $found_function_call = sub {
my $begin_line = shift;
my $begin_column = shift;
@ -159,40 +286,37 @@ sub fixup_statements {
$argument =~ s/^\s*(.*?)\s*$/$1/;
}
if($options->statements_windowsx &&
$name =~ /^(?:DefWindowProc|SendMessage)[AW]$/ &&
$$arguments[1] =~ /^WM_\w+$/)
my $fixup_function_call;
if($name =~ /^(?:DefWindowProc|SendMessage)[AW]$/)
{
fixup_replace(\&fixup_function_call_2_forward_wm_call, $editor,
$begin_line, $begin_column, $end_line, $end_column,
$name, $arguments);
} elsif(0) {
$output->write("$begin_line.$begin_column-$end_line.$end_column: " .
"$name(" . join(", ", @$arguments) . ")\n");
}
};
my $line = $statements_line;
my $column = 1;
if(!&c_parser::parse_c_statements(\$statements, \$line, \$column, $found_function_call)) {
$output->write("error: can't parse statements\n");
if($options->statements_windowsx) {
$fixup_function_call = \&fixup_user_message_2_windowsx;
} else {
$fixup_function_call = \&_fixup_user_message;
}
}
}
sub fixup_replace {
my $function = shift;
my $editor = shift;
my $begin_line = shift;
my $begin_column = shift;
my $end_line = shift;
my $end_column = shift;
my $replace = &$function(@_);
if(defined($fixup_function_call)) {
my $replace = &$fixup_function_call($name, $arguments);
if(defined($replace)) {
$editor->replace($begin_line, $begin_column, $end_line, $end_column, $replace);
}
} elsif(0 || $options->debug) {
$output->write("$begin_line.$begin_column-$end_line.$end_column: " .
"$name(" . join(", ", @$arguments) . ")\n");
}
return 0;
};
$parser->set_found_function_call_callback($found_function_call);
my $line = $statements_line;
my $column = 0;
if(!$parser->parse_c_statements(\$statements, \$line, \$column)) {
$output->write("error: can't parse statements\n");
}
}
1;

View File

@ -0,0 +1,445 @@
package winapi_module_user;
use strict;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw();
@EXPORT_OK = qw(
&is_user_function
&get_message_result_type
&get_message_result_kind
&get_message_wparam_type
&get_message_wparam_kind
&get_message_lparam_type
&get_message_lparam_kind
);
use config qw($wine_dir);
use options qw($options);
use output qw($output);
use c_parser;
########################################################################
my $message;
########################################################################
# is_user_function
sub is_user_function {
my $name = shift;
if($name =~ /^(?:DefWindowProc|SendMessage)[AW]?$/) {
}
}
########################################################################
# $message
$message = {
WM_ACTIVATE => {
id => 0, result => "void", wparam => ["", ""], lparam => "HWND" },
WM_ACTIVATEAPP => {
id => 0, result => "void", wparam => "BOOL", lparam => "LPARAM" },
WM_BEGINDRAG => {
id => 0, result => "", wparam => "", lparam => "" },
WM_CANCELMODE => {
id => 0, result => "void", wparam => "void", lparam => "void" },
WM_CHAR => {
id => 0, result => "void", wparam => "TCHAR", lparam => ["", ""] },
WM_CHARTOITEM => {
id => 0x002f, result => "void", wparam => ["UINT", "int"], lparam => "HWND" },
WM_CLOSE => {
id => 0, result => "void", wparam => "void", lparam => "void" },
WM_COMMAND => {
id => 0, result => "void", wparam => ["int", "UINT"], lparam => "HWND" },
WM_COPY => {
id => 0x0301, result => "void", wparam => "void", lparam => "void" },
WM_COMPACTING => {
id => 0, result => "void", wparam => "UINT", lparam => "void" },
WM_COMPAREITEM => {
id => 0, result => "int", wparam => "UINT", lparam => "const COMPAREITEMSTRUCT *" },
WM_CREATE => {
id => 0, result => "BOOL", wparam => "void", lparam => "LPCREATESTRUCT" },
WM_CTLCOLORBTN => {
id => 0x0135, result => "HBRUSH", wparam => "HDC", lparam => "HWND" },
WM_CTLCOLORDLG => {
id => 0x136, result => "HBRUSH", wparam => "HDC", lparam => "HWND" },
WM_CTLCOLOREDIT => {
id => 0x133, result => "HBRUSH", wparam => "HDC", lparam => "HWND" },
WM_CTLCOLORLISTBOX => {
id => 0x134, result => "HBRUSH", wparam => "HDC", lparam => "HWND" },
WM_CTLCOLORMSGBOX => {
id => 0x132, result => "HBRUSH", wparam => "HDC", lparam => "HWND" },
WM_CTLCOLORSCROLLBAR => {
id => 0x137, result => "HBRUSH", wparam => "HDC", lparam => "HWND" },
WM_CTLCOLORSTATIC => {
id => 0x138, result => "HBRUSH", wparam => "HDC", lparam => "HWND" },
WM_CUT => {
id => 0, result => "void", wparam => "void", lparam => "void" },
WM_DEADCHAR => {
id => 0, result => "void", wparam => "TCHAR", lparam => ["", ""] },
WM_DELETEITEM => {
id => 0, result => "void", wparam => "UINT", lparam => "const DELETEITEMSTRUCT *" },
WM_DEVMODECHANGE => {
id => 0, result => "void", wparam => "void", lparam => "LPCTSTR" },
WM_DESTROY => {
id => 0, result => "void", wparam => "void", lparam => "void" },
WM_DRAWITEM => {
id => 0, result => "void", wparam => "void", lparam => "const DRAWITEMSTRUCT *" },
WM_DROPFILES => {
id => 0, result => "void", wparam => "HDROP", lparam => "void" },
WM_ENABLE => {
id => 0, result => "void", wparam => "BOOL", lparam => "void" },
WM_ENDSESSION => {
id => 0, result => "void", wparam => "BOOL", lparam => "void" },
WM_ENTERIDLE => {
id => 0x0121, result => "void", wparam => "UINT", lparam => "HWND" },
WM_ENTERMENULOOP => {
id => 0x0211, result => "", wparam => "", lparam => "" },
WM_ERASEBKGND => {
id => 0, result => "BOOL", wparam => "HDC", lparam => "void" },
WM_EXITMENULOOP => {
id => 0x0212, result => "", wparam => "", lparam => "" },
WM_FONTCHANGE => {
id => 0, result => "void", wparam => "void", lparam => "void" },
WM_GETTEXT => {
id => 0, result => "int", wparam => "int", lparam => "LPTSTR" },
WM_GETTEXTLENGTH => {
id => 0, result => "int", wparam => "void", lparam => "void" },
WM_HELP => {
id => 0x0053, result => "", wparam => "", lparam => "" },
WM_HSCROLL => {
id => 0, result => "void", wparam => ["UINT", "int"], lparam => "HWND" },
WM_ICONERASEBKGND => {
id => 0, result => "BOOL", wparam => "HDC", lparam => "void" },
WM_INITMENU => {
id => 0, result => "void", wparam => "HMENU", lparam => "void" },
WM_INITMENUPOPUP => {
id => 0, result => "void", wparam => "HMENU", lparam => ["UINT", "BOOL"] },
WM_ISACTIVEICON => {
id => 0, result => "", wparam => "", lparam => "" },
WM_KEYDOWN => {
id => 0, result => "void", wparam => "UINT", lparam => ["", ""] },
WM_KEYUP => {
id => 0, result => "void", wparam => "UINT", lparam => ["", ""] },
WM_KILLFOCUS => {
id => 0, result => "void", wparam => "HWND", lparam => "void" },
WM_LBTRACKPOINT => {
id => 0, result => "", wparam => "", lparam => "" },
WM_LBUTTONDBLCLK => {
id => 0, result => "void", wparam => "UINT", lparam => ["", ""] },
WM_LBUTTONDOWN => {
id => 0, result => "void", wparam => "UINT", lparam => ["", ""] },
WM_LBUTTONUP => {
id => 0, result => "void", wparam => "UINT", lparam => ["", ""] },
WM_MBUTTONDBLCLK => {
id => 0, result => "void", wparam => "UINT", lparam => ["", ""] },
WM_MBUTTONDOWN => {
id => 0, result => "void", wparam => "UINT", lparam => ["", ""] },
WM_MBUTTONUP => {
id => 0, result => "void", wparam => "UINT", lparam => ["", ""] },
WM_MEASUREITEM => {
id => 0, result => "void", wparam => "UINT", lparam => "MEASUREITEMSTRUCT *" },
WM_MENUSELECT => {
id => 0, result => "void", wparam => ["", ""], lparam => "HMENU" },
WM_MENUCHAR => {
id => 0, result => "DWORD", wparam => ["", ""], lparam => "HMENU" },
WM_MOUSEACTIVATE => {
id => 0, result => "int", wparam => "HWND", lparam => ["", ""] },
WM_MOUSEMOVE => {
id => 0, result => "void", wparam => "UINT", lparam => ["", ""] },
WM_MOVE => {
id => 0, result => "void", wparam => "void", lparam => ["", ""] },
WM_NCACTIVATE => {
id => 0, result => "BOOL", wparam => "BOOL", lparam => "void" },
WM_NCLBUTTONDBLCLK => {
id => 0, result => "void", wparam => "UINT", lparam => ["", ""] },
WM_NCLBUTTONDOWN => {
id => 0, result => "void", wparam => "UINT", lparam => ["", ""] },
WM_NCLBUTTONUP => {
id => 0, result => "void", wparam => "UINT", lparam => ["", ""] },
WM_NCMOUSEMOVE => {
id => 0, result => "void", wparam => "UINT", lparam => ["", ""] },
WM_NCMBUTTONDBLCLK => {
id => 0, result => "void", wparam => "UINT", lparam => ["", ""] },
WM_NCMBUTTONDOWN => {
id => 0, result => "void", wparam => "UINT", lparam => ["", ""] },
WM_NCMBUTTONUP => {
id => 0, result => "void", wparam => "UINT", lparam => ["", ""] },
WM_NCRBUTTONDBLCLK => {
id => 0, result => "void", wparam => "UINT", lparam => ["", ""] },
WM_NCRBUTTONDOWN => {
id => 0, result => "void", wparam => "UINT", lparam => ["", ""] },
WM_NCRBUTTONUP => {
id => 0, result => "void", wparam => "UINT", lparam => ["", ""] },
WM_NCCALCSIZE => {
id => 0, result => "UINT", wparam => "void", lparam => "LPARAM" },
WM_NCCREATE => {
id => 0, result => "BOOL", wparam => "void", lparam => "LPCREATESTRUCT" },
WM_NCDESTROY => {
id => 0, result => "void", wparam => "void", lparam => "void" },
WM_NCPAINT => {
id => 0, result => "void", wparam => "HRGN", lparam => "void" },
WM_NEXTMENU => {
id => 0x0213, result => "", wparam => "", lparam => "" },
WM_NOTIFY => {
id => 0x004e, result => "LRESULT", wparam => "int", lparam => "NMHDR *" },
WM_PALETTEISCHANGING => {
id => 0, result => "void", wparam => "HWND", lparam => "void" },
WM_PALETTECHANGED => {
id => 0, result => "void", wparam => "HWND", lparam => "void" },
WM_PAINT => {
id => 0, result => "void", wparam => "void", lparam => "void" },
WM_PASTE => {
id => 0x0302, result => "void", wparam => "void", lparam => "void" },
WM_POWER => {
id => 0, result => "void", wparam => "int", lparam => "void" },
WM_QUERYDRAGICON => {
id => 0, result => "HICON", wparam => "void", lparam => "void" },
WM_QUERYENDSESSION => {
id => 0, result => "BOOL", wparam => "void", lparam => "void" },
WM_QUERYNEWPALETTE => {
id => 0, result => "BOOL", wparam => "void", lparam => "void" },
WM_QUERYOPEN => {
id => 0, result => "BOOL", wparam => "void", lparam => "void" },
WM_QUIT => {
id => 0, result => "void", wparam => "WPARAM", lparam => "void" },
WM_RBUTTONDBLCLK => {
id => 0, result => "void", wparam => "UINT", lparam => ["", ""] },
WM_RBUTTONDOWN => {
id => 0, result => "void", wparam => "UINT", lparam => ["", ""] },
WM_RBUTTONUP => {
id => 0, result => "void", wparam => "UINT", lparam => ["", ""] },
WM_SETCURSOR => {
id => 0x0020, result => "", wparam => "HWND", lparam => ["UINT", "UINT"] },
WM_SETFOCUS => {
id => 0, result => "void", wparam => "HWND", lparam => "void" },
WM_SETFONT => {
id => 0x0030, result => "void", wparam => "HFONT", lparam => "BOOL" },
WM_SETREDRAW => {
id => 0, result => "void", wparam => "BOOL", lparam => "void" },
WM_SETTEXT => {
id => 0, result => "void", wparam => "void", lparam => "LPCTSTR" },
WM_SHOWWINDOW => {
id => 0, result => "void", wparam => "BOOL", lparam => "UINT" },
WM_SIZE => {
id => 0, result => "void", wparam => "UINT", lparam => ["", ""] },
WM_SPOOLERSTATUS => {
id => 0, result => "void", wparam => "WPARAM", lparam => ["", ""] },
WM_SYSCHAR => {
id => 0, result => "void", wparam => "TCHAR", lparam => ["", ""] },
WM_SYSCOLORCHANGE => {
id => 0, result => "void", wparam => "void", lparam => "void" },
WM_SYSDEADCHAR => {
id => 0, result => "void", wparam => "TCHAR", lparam => ["", ""] },
WM_SYSKEYDOWN => {
id => 0, result => "void", wparam => "UINT", lparam => ["", ""] },
WM_SYSKEYUP => {
id => 0, result => "void", wparam => "UINT", lparam => ["", ""] },
WM_TIMECHANGE => {
id => 0, result => "void", wparam => "void", lparam => "void" },
WM_VKEYTOITEM => {
id => 0x002e, result => "void", wparam => ["UINT", "int"], lparam => "HWND" },
WM_VSCROLL => {
id => 0, result => "void", wparam => ["UINT", "int"], lparam => "HWND" },
WM_WINDOWPOSCHANGING => {
id => 0, result => "BOOL", wparam => "void", lparam => "LPWINDOWPOS" },
WM_WINDOWPOSCHANGED => {
id => 0, result => "void", wparam => "void", lparam => "LPARAM" },
WM_WININICHANGE => {
id => 0, result => "void", wparam => "void", lparam => "LPCTSTR" }
};
########################################################################
# _get_kind
sub _get_kind {
local $_ = shift;
if(!defined($_)) {
return undef;
} elsif(/^(?:HBRUSH|HDC|HFONT|HMENU|HRGN|HWND)$/ || /\*$/ ||
/^LP(?!ARAM)/)
{
return "ptr";
} else {
return "long";
}
}
########################################################################
# get_message_result_type
sub get_message_result_type {
my $name = shift;
return $$message{$name}{result};
}
########################################################################
# get_message_result_kind
sub get_message_result_kind {
return _get_kind(get_message_result_type(@_));
}
########################################################################
# get_message_wparam_type
sub get_message_wparam_type {
my $name = shift;
return $$message{$name}{wparam};
}
########################################################################
# get_message_wparam_kind
sub get_message_wparam_kind {
return _get_kind(get_message_wparam_type(@_));
}
########################################################################
# get_message_lparam_type
sub get_message_lparam_type {
my $name = shift;
return $$message{$name}{lparam};
}
########################################################################
# get_message_lparam_kind
sub get_message_lparam_kind {
return _get_kind(get_message_lparam_type(@_));
}
########################################################################
# _parse_windowsx_h
sub _parse_windowsx_h {
my $file = "$wine_dir/include/windowsx.h";
{
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;
local $_ = shift;
if(!s/^\#\s*define\s*// || !/^FORWARD_WM_/) {
return 1;
}
my $msg;
if(s/^FORWARD_(\w+)\([^\)]*\)\s*(.*?)\s*$/$2/s) {
$msg = $1;
}
if($msg eq "WM_SYSTEMERROR") {
return 1;
}
my $return_type;
if(s/^\(\s*(\w+)\s*\)(?:\(\s*\w+\s*\))*\(\s*\w+\s*\)\(\s*(?:hwnd|\(hwnd\))\s*,\s*(.*?)\s*\)$/$2/) {
$return_type = $1;
} else {
die "$msg: '$_'";
}
my @msgs = ();
if(s/^$msg\s*,\s*//) {
@msgs = $msg;
} elsif(s/^\(\w+\)\s*\?\s*(\w+)\s*:\s*(\w+)\s*,\s*//s) {
@msgs = ($1, $2);
} else {
die "$msg: '$_'";
}
my $wparam;
if(s/^\(WPARAM\)(?:\(\s*(\w+)\s*\))*\((.*?)\)\s*,\s*//) {
if(defined($1)) {
$wparam = $1;
} else {
$wparam = "WPARAM";
}
} elsif(s/^MAKEWPARAM\(\s*(.*?)\s*,\s*(.*?)\s*\)\s*,\s*//) {
$wparam = "(,)"; # "($1, $2)";
} elsif(s/^\((.*?)\)$//) {
$wparam = "WPARAM";
} elsif(s/^0L\s*,\s*//) {
$wparam = "void";
} else {
die "$msg: '$_'";
}
my $lparam;
if(s/^\(LPARAM\)(?:\(\s*(\w+)\s*\))*\((.*?)\)$//) {
if(defined($1)) {
$lparam = $1;
} else {
$lparam = "LPARAM";
}
} elsif(s/^MAKELPARAM\(\s*(.*?)\s*,\s*(.*?)\s*\)$//) {
$lparam = "(,)"; # "($1, $2)";
} elsif(s/^\((.*?)\)$//) {
$lparam = "LPARAM";
} elsif(s/^0L$//) {
$lparam = "void";
} else {
die "$msg: '$_'";
}
foreach my $msg (@msgs) {
$output->write("$msg => { result => \"$return_type\", wparam => \"$wparam\", lparam => \"$lparam\" },\n");
}
return 1;
};
$parser->set_found_preprocessor_callback($found_preprocessor);
my $line = 1;
my $column = 0;
my $old_prefix = $output->prefix;
$output->progress("$file");
$output->prefix("$file: ");
if(!$parser->parse_c_file(\$_, \$line, \$column)) {
$output->write("can't parse file\n");
}
$output->prefix($old_prefix);
}

View File

@ -70,9 +70,7 @@ sub new {
my $module_file = "$winapi_check_dir/modules.dat";
if($options->progress) {
$output->progress("modules.dat");
}
my %spec_file_found;
my $allowed_dir;

View File

@ -36,9 +36,7 @@ sub new {
$configure_in_file =~ s/^\.\///;
$config_h_in_file =~ s/^\.\///;
if($options->progress) {
$output->progress("$api_file");
}
open(IN, "< $api_file");
local $/ = "\n";
@ -51,9 +49,7 @@ sub new {
}
close(IN);
if($options->progress) {
$output->progress("$configure_in_file");
}
my $again = 0;
open(IN, "< $configure_in_file");
@ -102,9 +98,7 @@ sub new {
}
close(IN);
if($options->progress) {
$output->progress("$config_h_in_file");
}
open(IN, "< $config_h_in_file");
local $/ = "\n";

View File

@ -136,8 +136,6 @@ PLARGE_INTEGER
PLONG
PTIMERAPCROUTINE
PULARGE_INTEGER
PVOID
PVOID *
SECURITY_ATTRIBUTES *
SYSLEVEL *
SYSLEVEL **

View File

@ -66,10 +66,12 @@ LPFONTDESC
LPOCPFIPARAMS
LPPICTDESC
LPSTREAM
LPSYSTEMTIME
LPUNKNOWN
LPUNKNOWN *
LPVOID
LPVOID *
NUMPARSE *
OLECHAR *
OLECHAR **
REFCLSID
@ -78,6 +80,7 @@ REFIID
SAFEARRAY *
SAFEARRAY **
SAFEARRAYBOUND *
UDATE *
UINT *
ULONG *
USHORT *

View File

@ -1,6 +1,5 @@
%long
DWORD
HRESULT
%ptr

View File

@ -6,6 +6,7 @@ DWORD
HANDLE
HBITMAP
HDROP
HGLOBAL
HMENU
HICON
HINSTANCE

View File

@ -43,7 +43,7 @@ POINT *
RECT *
WINDOWPOS *
struct tagCURSORICONINFO *
struct tagWND *
void *
%str

View File

@ -53,7 +53,6 @@ POINT *
RECT *
TEXTMETRICW *
WINDOWPOS *
WND *
void *
%str

View File

@ -105,9 +105,7 @@ sub parse_api_file {
my $extension = 0;
my $forbidden = 0;
if($options->progress) {
$output->lazy_progress("$file");
}
open(IN, "< $wine_dir/$file") || die "$wine_dir/$file: $!\n";
$/ = "\n";
@ -217,9 +215,7 @@ sub parse_spec_file {
my $module;
my $module_file;
if($options->progress) {
$output->lazy_progress("$file");
}
open(IN, "< $file") || die "$file: $!\n";
$/ = "\n";

View File

@ -26,6 +26,13 @@ use config qw(
);
use output qw($output);
use winapi_check_options qw($options);
if($options->progress) {
$output->enable_progress;
} else {
$output->disable_progress;
}
use modules qw($modules);
use nativeapi qw($nativeapi);
use winapi qw($win16api $win32api @winapis);
@ -50,9 +57,7 @@ my %include2info;
foreach my $file (@files) {
$progress_current++;
if($options->progress) {
$output->lazy_progress("$file: file $progress_current of $progress_max");
}
my $file_dir = $file;
if(!($file_dir =~ s%(.*?)/[^/]+$%$1%)) {
@ -128,9 +133,7 @@ if($options->headers) {
my %functions;
$progress_current++;
if($options->progress) {
$output->progress("$file: file $progress_current of $progress_max");
}
my $create_function = sub {
return 'winapi_function'->new;
@ -139,11 +142,13 @@ if($options->headers) {
my $found_function = sub {
my $function = shift;
my $internal_name = $function->internal_name;
$output->progress("$file (file $progress_current of $progress_max): $internal_name");
$output->prefix_callback(sub { return $function->prefix; });
my $function_line = $function->function_line;
my $linkage = $function->linkage;
my $internal_name = $function->internal_name;
my $external_name = $function->external_name;
my $statements = $function->statements;
@ -200,9 +205,7 @@ foreach my $file (@c_files) {
my $file_module32 = $modules->allowed_modules_in_file("$current_dir/$file");
$progress_current++;
if($options->progress) {
$output->progress("$file: file $progress_current of $progress_max");
}
$output->progress("$file (file $progress_current of $progress_max)");
my $file_dir = $file;
if(!($file_dir =~ s/(.*?)\/[^\/]*$/$1/)) {
@ -216,11 +219,12 @@ foreach my $file (@c_files) {
my $found_function = sub {
my $function = shift;
$output->prefix_callback(sub { return $function->prefix; });
my $internal_name = $function->internal_name;
$functions{$internal_name} = $function;
$output->progress("$file (file $progress_current of $progress_max): $internal_name");
$output->prefix_callback(sub { return $function->prefix; });
my $declared_function = $declared_functions{$internal_name};
my $documentation_line = $function->documentation_line;