Commit fe787391 authored by Francois Gouget's avatar Francois Gouget Committed by Alexandre Julliard

winapi_check: Fix handling of the -register functions.

Unless specified otherwise they are implemented by a '__regs_' function. Keep track of the '-i386' flag so we can detect CONTEXT* vs. CONTEXT86* mismatches. Remove an unneeded and broken hack meant to fudge the number of parameters.
parent 30131979
......@@ -293,7 +293,10 @@ sub parse_spec_file($$) {
$flags =~ s/\s+/ /g;
$internal_name = $external_name if !$internal_name;
if (!$internal_name)
{
$internal_name = ($flags =~ /-register/ ? "__regs_" : "") . $external_name;
}
if($flags =~ /-noname/) {
# $external_name = "@";
......@@ -304,6 +307,9 @@ sub parse_spec_file($$) {
$arguments .= "ptr";
$calling_convention .= " -register";
}
if($flags =~ /(?:-i386)/) {
$calling_convention .= " -i386";
}
if ($internal_name =~ /^(.*?)\.(.*?)$/) {
my $forward_module = lc($1);
......
......@@ -117,11 +117,9 @@ sub _check_function($$$$$$) {
my $declared_calling_convention = $winapi->function_internal_calling_convention($internal_name) || "";
my @declared_argument_kinds = split(/\s+/, $winapi->function_internal_arguments($internal_name));
my $declared_register = 0;
if ($declared_calling_convention =~ /^(\w+) -register$/) {
$declared_register = 1;
$declared_calling_convention = $1;
}
my $declared_register = ($declared_calling_convention =~ / -register\b/);
my $declared_i386 = ($declared_calling_convention =~ /(?:^pascal| -i386)\b/);
$declared_calling_convention =~ s/ .*$//;
if(!$declared_register &&
$implemented_calling_convention ne $declared_calling_convention &&
......@@ -158,12 +156,6 @@ sub _check_function($$$$$$) {
}
}
if($#argument_types != -1 && $argument_types[$#argument_types] eq "CONTEXT *" &&
$internal_name =~ /^(?:RtlRaiseException|RtlUnwind|NtRaiseException)$/) # FIXME: Kludge
{
$#argument_types--;
}
if($internal_name =~ /^(?:NTDLL__ftol|NTDLL__CIpow)$/) { # FIXME: Kludge
# ignore
} else {
......@@ -172,7 +164,9 @@ sub _check_function($$$$$$) {
my $type = $_;
my $kind = "unknown";
$winapi->type_used_in_module($type,$module);
if($type eq "CONTEXT86 *") {
if($type eq "CONTEXT *") {
$kind = "context";
} elsif($type eq "CONTEXT86 *") {
$kind = "context86";
} elsif(!defined($kind = $winapi->translate_argument($type))) {
$winapi->declare_argument($type, "unknown");
......@@ -200,9 +194,16 @@ sub _check_function($$$$$$) {
}
} @argument_types;
if ($declared_register && $argument_kinds[$#argument_kinds] ne "context86") {
if ($declared_register)
{
if (!$declared_i386 &&
$argument_kinds[$#argument_kinds] ne "context") {
$output->write("function declared as register, but CONTEXT * is not last argument\n");
} elsif ($declared_i386 &&
$argument_kinds[$#argument_kinds] ne "context86") {
$output->write("function declared as register, but CONTEXT86 * is not last argument\n");
}
}
for my $n (0..$#argument_kinds) {
if(!defined($argument_kinds[$n]) || !defined($declared_argument_kinds[$n])) { next; }
......@@ -218,7 +219,7 @@ sub _check_function($$$$$$) {
$argument_types[$n] = "";
}
if($argument_kinds[$n] eq "context86") {
if($argument_kinds[$n] =~ /^context(?:86)?$/) {
# Nothing
} elsif(!$winapi->is_allowed_kind($argument_kinds[$n]) ||
!$winapi->is_allowed_type_in_module($argument_types[$n], $module))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment