'volatile' is valid everywhere where 'const' is valid. This fixes parsing of the new InterlockedExchange() prototype.
diff --git a/tools/winapi/winapi_module_user.pm b/tools/winapi/winapi_module_user.pm index 90b35a3..3290e92 100644 --- a/tools/winapi/winapi_module_user.pm +++ b/tools/winapi/winapi_module_user.pm
@@ -738,7 +738,7 @@ $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 @@ 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 @@ (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 @@ 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: '$_'";
diff --git a/tools/winapi/winapi_parser.pm b/tools/winapi/winapi_parser.pm index 32d760d..db1f429 100644 --- a/tools/winapi/winapi_parser.pm +++ b/tools/winapi/winapi_parser.pm
@@ -426,14 +426,14 @@ $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 @@ } 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 @@ } 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 @@ 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 @@ } &$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 @@ &$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*