Francois Gouget : winapi_check: Fix handling of the -register functions.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Feb 9 08:22:12 CST 2007


Module: wine
Branch: master
Commit: fe7873912804cd7200e11c1551fb7804464b66c7
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=fe7873912804cd7200e11c1551fb7804464b66c7

Author: Francois Gouget <fgouget at free.fr>
Date:   Fri Feb  9 12:31:57 2007 +0100

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.

---

 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))




More information about the wine-cvs mailing list