comparison lib-src/make-mswin-unicode.pl @ 4873:50861fea97f6

regenerate intl-auto-encap-win32.c, now possible from Cygwin /usr/include/w32api headers
author Ben Wing <ben@xemacs.org>
date Tue, 12 Jan 2010 01:19:01 -0600
parents 23ef20edf6ba
children 49de55c09f18
comparison
equal deleted inserted replaced
4872:9873ea104ef6 4873:50861fea97f6
100 my $slurp; 100 my $slurp;
101 101
102 my ($cout, $hout, $dir) = ($options{"c-output"}, 102 my ($cout, $hout, $dir) = ($options{"c-output"},
103 $options{"h-output"}, 103 $options{"h-output"},
104 $options{"includedir"}); 104 $options{"includedir"});
105
106 $dir = '/usr/include/w32api' if !$dir && -f '/usr/include/w32api/windows.h';
107
105 if (!$dir) 108 if (!$dir)
106 { 109 {
107 for my $sdkroot (("WindowsSdkDir", "MSSdk", "MSVCDIR")) 110 for my $sdkroot (("WindowsSdkDir", "MSSdk", "MSVCDIR"))
108 { 111 {
109 if (defined $ENV{$sdkroot}) { 112 if (defined $ENV{$sdkroot}) {
113 } 116 }
114 unless (defined $dir) 117 unless (defined $dir)
115 { 118 {
116 die "Can't find the Windows SDK headers; run vcvars32.bat from your MSVC installation, or setenv.cmd from the Platform SDK installation"; 119 die "Can't find the Windows SDK headers; run vcvars32.bat from your MSVC installation, or setenv.cmd from the Platform SDK installation";
117 } 120 }
118 $dir.='/include';
119 } 121 }
122 $dir.='/include' if ((-f $dir.'/include/WINDOWS.H') ||
123 (-f $dir.'/include/windows.h'));
120 die "Can't find MSVC include files in \"$dir\"" unless ((-f $dir.'/WINDOWS.H') || (-f $dir.'/windows.h')); 124 die "Can't find MSVC include files in \"$dir\"" unless ((-f $dir.'/WINDOWS.H') || (-f $dir.'/windows.h'));
121 125
122 open (COUT, ">$cout") or die "Can't open C output file $cout: $!"; 126 open (COUT, ">$cout") or die "Can't open C output file $cout: $!";
123 open (HOUT, ">$hout") or die "Can't open C output file $hout: $!"; 127 open (HOUT, ">$hout") or die "Can't open C output file $hout: $!";
124 128
242 # one excludes the words "X" and "Y" from type 246 # one excludes the words "X" and "Y" from type
243 # words, since they appear as parameter names in 247 # words, since they appear as parameter names in
244 # CreateWindowEx; the second prevents "void 248 # CreateWindowEx; the second prevents "void
245 # *Argument" from being parsed as a type "void *A" 249 # *Argument" from being parsed as a type "void *A"
246 # followed by a parameter "rgument". 250 # followed by a parameter "rgument".
247 "(?:(?!(?:X\\b|Y\\b))(?:unsigned|int|long|short|va_list|[A-Z_0-9]+)(?!${tok_ch}))"; 251 "(?:(?!(?:X\\b|Y\\b))(?:unsigned|int|long|const|short|va_list|[A-Z_0-9]+)(?!${tok_ch}))";
248 my $typetoken_re = "(?:$typeword_re$ws_re\\**$ws_re)"; 252 my $typetoken_re = "(?:$typeword_re$ws_re\\**$ws_re)";
249 my $arg_re = "(?:($typetoken_re+)(${tok_ch}+)?(?: OPTIONAL)?)"; 253 my $arg_re = "(?:($typetoken_re+)(${tok_ch}+)?(?: OPTIONAL)?)";
250 my $fun_re = "(SHSTDAPI_\\(${tok_ch}+\\)|${tok_ch}" . "[A-Za-z_0-9 \t\n\r\f]*?${tok_ch})${ws_re}(${tok_ch}+)W${ws_re}\\(((${ws_re}${arg_re}${ws_re},)*${ws_re}${arg_re}${ws_re})\\);"; 254 my $fun_re = "(SHSTDAPI_\\(${tok_ch}+\\)|${tok_ch}" . "[A-Za-z_0-9 \t\n\r\f]*?${tok_ch})${ws_re}(${tok_ch}+)W${ws_re}\\(((${ws_re}${arg_re}${ws_re},)*${ws_re}${arg_re}${ws_re})\\);";
251 255
252 # print "regexp: $fun_re\n"; 256 # print "regexp: $fun_re\n";
253 while ($slurp =~ /$fun_re/g) 257 while ($slurp =~ /$fun_re/g)
254 { 258 {
255 my ($rettype, $fun, $args) = ($1, $2, $3); 259 my ($rettype, $fun, $args) = ($1, $2, $3);
260
261 if ($processed{$fun})
262 {
263 print "Warning: Function $fun already seen\n";
264 next;
265 }
266
256 $processed{$fun} = 1; 267 $processed{$fun} = 1;
268
257 print "Processing: $fun"; 269 print "Processing: $fun";
258 270
259 my ($command, $reason) = ($files{$file}{$fun}[0], $files{$file}{$fun}[1]); 271 my ($command, $reason) = ($files{$file}{$fun}[0], $files{$file}{$fun}[1]);
260 if (!defined ($command)) 272 if (!defined ($command))
261 { 273 {
332 } 344 }
333 push @args, $argname; 345 push @args, $argname;
334 } 346 }
335 $rettype =~ s/\bSHSTDAPI_\((.*)\)/$1/; 347 $rettype =~ s/\bSHSTDAPI_\((.*)\)/$1/;
336 $rettype =~ s/\s*WIN\w*?API\s*//g; 348 $rettype =~ s/\s*WIN\w*?API\s*//g;
337 $rettype =~ s/\bAPIENTRY\b//; 349 $rettype =~ s/\bAPIENTRY\b\s*//;
338 $rettype =~ s/\bSHSTDAPI\b/HRESULT/; 350 $rettype =~ s/\bSHSTDAPI\b/HRESULT/;
351 $rettype =~ s/\bextern\b\s*//;
339 if ($rettype =~ /LPC?WSTR/) 352 if ($rettype =~ /LPC?WSTR/)
340 { 353 {
341 $split_rettype = 1; 354 $split_rettype = 1;
342 $rettype =~ s/\bLPWSTR\b/Extbyte */; 355 $rettype =~ s/\bLPWSTR\b/Extbyte */;
343 $rettype =~ s/\bLPCWSTR\b/const Extbyte */; 356 $rettype =~ s/\bLPCWSTR\b/const Extbyte */;