winapi_check: Fix handling of the -register functions.
Francois Gouget
fgouget at free.fr
Fri Feb 9 05:31:57 CST 2007
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.
---
This fixes a couple of winapi_check warnings about RtlUnwind() and
RtlRaiseException() that happen to have non-register implementations
too which were confusing winapi_check.
In this patch I also assume that if a function is declared -register but
is not pascal or -i386, then it is not x86-specific and thus should use
CONTEXT* rather than the i386-specific CONTEXT86*. And reciprocally
x86-specific functions are expected to use CONTEXT86* because otherwise
they're presumably not x86-specific. Currently there's no exception to
this rule.
tools/winapi/winapi.pm | 8 +++++++-
tools/winapi/winapi_local.pm | 31 ++++++++++++++++---------------
2 files changed, 23 insertions(+), 16 deletions(-)
diff --git a/tools/winapi/winapi.pm b/tools/winapi/winapi.pm
index e5ed445..eb85d08 100644
--- a/tools/winapi/winapi.pm
+++ b/tools/winapi/winapi.pm
@@ -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);
diff --git a/tools/winapi/winapi_local.pm b/tools/winapi/winapi_local.pm
index 01c8ab9..f46d1ec 100644
--- a/tools/winapi/winapi_local.pm
+++ b/tools/winapi/winapi_local.pm
@@ -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,8 +194,15 @@ sub _check_function($$$$$$) {
}
} @argument_types;
- if ($declared_register && $argument_kinds[$#argument_kinds] ne "context86") {
- $output->write("function declared as register, but CONTEXT86 * is not last argument\n");
+ 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) {
@@ -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))
--
1.4.4.3
More information about the wine-patches
mailing list