winapi: Fix handling of volatile

Francois Gouget fgouget at free.fr
Mon Sep 5 04:44:10 CDT 2005


According to 'The C++ Programming Language' by Bjarne Stroustrup, 
volatile is valid everywhere where const is valid. It's not very clear 
whether they can be used together though. It does not seem it would make 
much sense so I assumed not.

Changelog:

  * tools/winapi/winapi_module_user.pm
    tools/winapi/winapi_parser.pm

    Francois Gouget <fgouget at free.fr>
    'volatile' is valid everywhere where 'const' is valid.
    This fixes parsing of the new InterlockedExchange() prototype.

-- 
Francois Gouget         fgouget at free.fr        http://fgouget.free.fr/
         War doesn't determine who's right.  War determines who's left.
-------------- next part --------------
Index: tools/winapi/winapi_module_user.pm
===================================================================
RCS file: /var/cvs/wine/tools/winapi/winapi_module_user.pm,v
retrieving revision 1.5
diff -u -p -r1.5 winapi_module_user.pm
--- tools/winapi/winapi_module_user.pm	26 Oct 2004 00:12:21 -0000	1.5
+++ tools/winapi/winapi_module_user.pm	4 Sep 2005 16:05:07 -0000
@@ -738,7 +738,7 @@ sub _parse_windowsx_h($$$) {
 		$output->write("message $name: result type mismatch '$result' != '$result2'\n");
 	    }
 	    foreach (split(/\s*,\s*/)) {
-		if(/^((?:const\s+)?\w+(?:\s*\*\s*|\s+)?)(\w+)$/) {
+		if(/^((?:const\s+|volatile\s+)?\w+(?:\s*\*\s*|\s+)?)(\w+)$/) {
 		    my $type = $1;
 		    my $name = $2;
 
@@ -756,7 +756,7 @@ sub _parse_windowsx_h($$$) {
 
 	my $find_inner_cast = sub {
 	    local $_ = shift;
-	    if(/^(?:\(\s*((?:const\s+)?\w+(?:\s*\*)?)\s*\))*\(.*?\)$/) {
+	    if(/^(?:\(\s*((?:const\s+|volatile\s+)?\w+(?:\s*\*)?)\s*\))*\(.*?\)$/) {
 		if(defined($1)) {
 		    return $1;
 		} else {
@@ -774,7 +774,7 @@ sub _parse_windowsx_h($$$) {
 	    (my $refparam, my $upper, my $lower) = @$entry;
 
 	    local $_ = $$refparam;
-	    if(s/^\(\s*$upper(?:)PARAM\s*\)\s*(?:\(\s*((?:const\s+)?\w+(?:\s*\*)?)\s*\))*\(\s*(.*?)\s*\)$/$2/) {
+	    if(s/^\(\s*$upper(?:)PARAM\s*\)\s*(?:\(\s*((?:const\s+|volatile\s+)?\w+(?:\s*\*)?)\s*\))*\(\s*(.*?)\s*\)$/$2/) {
 		if(defined($1)) {
 		    $$refparam = $1;
 		} else {
@@ -792,7 +792,7 @@ sub _parse_windowsx_h($$$) {
 			    last;
 			}
 		    }
-		} elsif(/^\(\((?:const\s+)?\w+\s*(?:\*\s*)?\)\s*(?:\(\s*\w+\s*\)|\w+)\s*\)\s*\->\s*\w+$/) {
+		} elsif(/^\(\((?:const\s+|volatile\s+)?\w+\s*(?:\*\s*)?\)\s*(?:\(\s*\w+\s*\)|\w+)\s*\)\s*\->\s*\w+$/) {
 		    $$refparam = "UINT";
 		} else {
 		    die "$name: '$_'";
Index: tools/winapi/winapi_parser.pm
===================================================================
RCS file: /var/cvs/wine/tools/winapi/winapi_parser.pm,v
retrieving revision 1.4
diff -u -p -r1.4 winapi_parser.pm
--- tools/winapi/winapi_parser.pm	8 Aug 2005 11:06:24 -0000	1.4
+++ tools/winapi/winapi_parser.pm	4 Sep 2005 16:03:50 -0000
@@ -426,14 +426,14 @@ sub parse_c_file($$) {
 		$argument =~ s/^\s*(.*?)\s*$/$1/;
 		# print "  " . ($n + 1) . ": '$argument'\n";
 		$argument =~ s/^(IN OUT(?=\s)|IN(?=\s)|OUT(?=\s)|\s*)\s*//;
-		$argument =~ s/^(const(?=\s)|CONST(?=\s)|\s*)\s*//;
+		$argument =~ s/^(const(?=\s)|CONST(?=\s)|volatile(?=\s)|\s*)\s*//;
 		if($argument =~ /^\.\.\.$/) {
 		    $argument_type = "...";
 		    $argument_name = "...";
 		} elsif($argument =~ /^
 			((?:struct\s+|union\s+|enum\s+|register\s+|(?:signed\s+|unsigned\s+)
 			  (?:short\s+(?=int)|long\s+(?=int))?)?(?:\w+|ElfW\(\w+\)|WS\(\w+\)))\s*
-			((?:__RPC_FAR|const|CONST)?\s*(?:\*\s*(?:__RPC_FAR|const|CONST)?\s*?)*)\s*
+			((?:__RPC_FAR|const|CONST|volatile)?\s*(?:\*\s*(?:__RPC_FAR|const|CONST|volatile)?\s*?)*)\s*
 			(\w*)\s*(\[\])?(?:\s+OPTIONAL)?$/x)
 		{
 		    $argument_type = $1;
@@ -447,7 +447,7 @@ sub parse_c_file($$) {
 		} elsif ($argument =~ /^
 			((?:struct\s+|union\s+|enum\s+|register\s+|(?:signed\s+|unsigned\s+)
 			  (?:short\s+(?=int)|long\s+(?=int))?)?\w+)\s*
-			((?:const)?\s*(?:\*\s*(?:const)?\s*?)*)\s*
+			((?:const|volatile)?\s*(?:\*\s*(?:const|volatile)?\s*?)*)\s*
 			(?:__cdecl\s+|__stdcall\s+|CALLBACK\s+|CDECL\s+|NET_API_FUNCTION\s+|RPC_ENTRY\s+|STDMETHODCALLTYPE\s+|VFWAPIV\s+|VFWAPI\s+|WINAPIV\s+|WINAPI\s+)?
 			\(\s*(?:__cdecl|__stdcall|CALLBACK|CDECL|NET_API_FUNCTION|RPC_ENTRY|STDMETHODCALLTYPE|VFWAPIV|VFWAPI|WINAPIV|WINAPI)?\s*\*\s*((?:\w+)?)\s*\)\s*
 			\(\s*(.*?)\s*\)$/x) 
@@ -466,7 +466,7 @@ sub parse_c_file($$) {
 		} elsif ($argument =~ /^
 			((?:struct\s+|union\s+|enum\s+|register\s+|(?:signed\s+|unsigned\s+)
 			  (?:short\s+(?=int)|long\s+(?=int))?)?\w+)\s*
-			((?:const)?\s*(?:\*\s*(?:const)?\s*?)*)\s*
+			((?:const|volatile)?\s*(?:\*\s*(?:const|volatile)?\s*?)*)\s*
 			(\w+)\s*\[\s*(.*?)\s*\](?:\[\s*(.*?)\s*\])?$/x)
 		{
 		    my $return_type = $1;
@@ -486,7 +486,7 @@ sub parse_c_file($$) {
 		    die "$file: $.: syntax error: '$argument'\n";
 		}
 
-		$argument_type =~ s/\s*const\s*/ /g; # Remove const
+		$argument_type =~ s/\s*(?:const|volatile)\s*/ /g; # Remove const/volatile
 		$argument_type =~ s/([^\*\(\s])\*/$1 \*/g; # Assure whitespace between non-* and *
 		$argument_type =~ s/,([^\s])/, $1/g; # Assure whitespace after ,
 		$argument_type =~ s/\*\s+\*/\*\*/g; # Remove whitespace between * and *
@@ -556,9 +556,9 @@ sub parse_c_file($$) {
 	    }
 	    &$type_begin($type);
 	} elsif(/typedef\s+
-		((?:const\s+|CONST\s+|enum\s+|long\s+|signed\s+|short\s+|struct\s+|union\s+|unsigned\s+)*?)
+		((?:const\s+|CONST\s+|enum\s+|long\s+|signed\s+|short\s+|struct\s+|union\s+|unsigned\s+|volatile\s+)*?)
 		(\w+)
-		(?:\s+const)?
+		(?:\s+const|\s+volatile)?
 		((?:\s*(?:(?:FAR|__RPC_FAR|TW_HUGE)?\s*)?\*+\s*|\s+)(?:volatile\s+|DECLSPEC_ALIGN\(\d+\)\s+)?\w+\s*(?:\[[^\]]*\])*
 		(?:\s*,\s*(?:\s*(?:(?:FAR|__RPC_FAR|TW_HUGE)?\s*)?\*+\s*|\s+)\w+\s*(?:\[[^\]]*\])?)*)
 		\s*;/sx)
@@ -584,7 +584,7 @@ sub parse_c_file($$) {
 	    &$type_begin($type);
 	    &$type_end([@names]);
 	} elsif(/typedef\s+
-		(?:(?:const\s+|enum\s+|long\s+|signed\s+|short\s+|struct\s+|union\s+|unsigned\s+)*?)
+		(?:(?:const\s+|enum\s+|long\s+|signed\s+|short\s+|struct\s+|union\s+|unsigned\s+|volatile\s+)*?)
 		(\w+(?:\s*\*+\s*)?)\s*
 		(?:(\w+)\s*)?
 		\((?:(\w+)\s*)?\s*(?:\*\s*(\w+)|_ATL_CATMAPFUNC)\s*\)\s*


More information about the wine-patches mailing list