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($$) { ...@@ -293,7 +293,10 @@ sub parse_spec_file($$) {
$flags =~ s/\s+/ /g; $flags =~ s/\s+/ /g;
$internal_name = $external_name if !$internal_name; if (!$internal_name)
{
$internal_name = ($flags =~ /-register/ ? "__regs_" : "") . $external_name;
}
if($flags =~ /-noname/) { if($flags =~ /-noname/) {
# $external_name = "@"; # $external_name = "@";
...@@ -304,6 +307,9 @@ sub parse_spec_file($$) { ...@@ -304,6 +307,9 @@ sub parse_spec_file($$) {
$arguments .= "ptr"; $arguments .= "ptr";
$calling_convention .= " -register"; $calling_convention .= " -register";
} }
if($flags =~ /(?:-i386)/) {
$calling_convention .= " -i386";
}
if ($internal_name =~ /^(.*?)\.(.*?)$/) { if ($internal_name =~ /^(.*?)\.(.*?)$/) {
my $forward_module = lc($1); my $forward_module = lc($1);
......
...@@ -117,11 +117,9 @@ sub _check_function($$$$$$) { ...@@ -117,11 +117,9 @@ sub _check_function($$$$$$) {
my $declared_calling_convention = $winapi->function_internal_calling_convention($internal_name) || ""; 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_argument_kinds = split(/\s+/, $winapi->function_internal_arguments($internal_name));
my $declared_register = 0; my $declared_register = ($declared_calling_convention =~ / -register\b/);
if ($declared_calling_convention =~ /^(\w+) -register$/) { my $declared_i386 = ($declared_calling_convention =~ /(?:^pascal| -i386)\b/);
$declared_register = 1; $declared_calling_convention =~ s/ .*$//;
$declared_calling_convention = $1;
}
if(!$declared_register && if(!$declared_register &&
$implemented_calling_convention ne $declared_calling_convention && $implemented_calling_convention ne $declared_calling_convention &&
...@@ -158,12 +156,6 @@ sub _check_function($$$$$$) { ...@@ -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 if($internal_name =~ /^(?:NTDLL__ftol|NTDLL__CIpow)$/) { # FIXME: Kludge
# ignore # ignore
} else { } else {
...@@ -172,7 +164,9 @@ sub _check_function($$$$$$) { ...@@ -172,7 +164,9 @@ sub _check_function($$$$$$) {
my $type = $_; my $type = $_;
my $kind = "unknown"; my $kind = "unknown";
$winapi->type_used_in_module($type,$module); $winapi->type_used_in_module($type,$module);
if($type eq "CONTEXT86 *") { if($type eq "CONTEXT *") {
$kind = "context";
} elsif($type eq "CONTEXT86 *") {
$kind = "context86"; $kind = "context86";
} elsif(!defined($kind = $winapi->translate_argument($type))) { } elsif(!defined($kind = $winapi->translate_argument($type))) {
$winapi->declare_argument($type, "unknown"); $winapi->declare_argument($type, "unknown");
...@@ -200,9 +194,16 @@ sub _check_function($$$$$$) { ...@@ -200,9 +194,16 @@ sub _check_function($$$$$$) {
} }
} @argument_types; } @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"); $output->write("function declared as register, but CONTEXT86 * is not last argument\n");
} }
}
for my $n (0..$#argument_kinds) { for my $n (0..$#argument_kinds) {
if(!defined($argument_kinds[$n]) || !defined($declared_argument_kinds[$n])) { next; } if(!defined($argument_kinds[$n]) || !defined($declared_argument_kinds[$n])) { next; }
...@@ -218,7 +219,7 @@ sub _check_function($$$$$$) { ...@@ -218,7 +219,7 @@ sub _check_function($$$$$$) {
$argument_types[$n] = ""; $argument_types[$n] = "";
} }
if($argument_kinds[$n] eq "context86") { if($argument_kinds[$n] =~ /^context(?:86)?$/) {
# Nothing # Nothing
} elsif(!$winapi->is_allowed_kind($argument_kinds[$n]) || } elsif(!$winapi->is_allowed_kind($argument_kinds[$n]) ||
!$winapi->is_allowed_type_in_module($argument_types[$n], $module)) !$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