2002-10-01 20:10:54 +02:00
|
|
|
#!/usr/bin/perl -w
|
|
|
|
|
|
|
|
# Copyright 2002 Patrik Stridvall
|
|
|
|
#
|
|
|
|
# This library is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
|
|
# License as published by the Free Software Foundation; either
|
|
|
|
# version 2.1 of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This library is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
|
|
# License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-10-01 20:10:54 +02:00
|
|
|
#
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
BEGIN {
|
|
|
|
$0 =~ m%^(.*?/?tools)/winapi/winapi_test$%;
|
|
|
|
require "$1/winapi/setup.pm";
|
|
|
|
}
|
|
|
|
|
|
|
|
use config qw(
|
2004-10-26 02:12:21 +02:00
|
|
|
file_type files_skip files_filter
|
2005-05-04 12:43:00 +02:00
|
|
|
$current_dir $wine_dir $winapi_dir
|
2002-10-01 20:10:54 +02:00
|
|
|
);
|
|
|
|
use output qw($output);
|
|
|
|
use winapi_test_options qw($options);
|
|
|
|
|
|
|
|
if($options->progress) {
|
|
|
|
$output->enable_progress;
|
|
|
|
} else {
|
|
|
|
$output->disable_progress;
|
|
|
|
}
|
|
|
|
|
|
|
|
use c_parser;
|
|
|
|
use tests qw($tests);
|
|
|
|
use type;
|
|
|
|
use util qw(replace_file);
|
|
|
|
|
2010-04-07 17:22:51 +02:00
|
|
|
my $pointer_size = 4;
|
|
|
|
|
2002-10-01 20:10:54 +02:00
|
|
|
my @tests = ();
|
|
|
|
if ($options->pack) {
|
|
|
|
push @tests, "pack";
|
|
|
|
}
|
|
|
|
|
2009-05-17 13:26:16 +02:00
|
|
|
my @files;
|
2002-10-01 20:10:54 +02:00
|
|
|
{
|
2002-10-09 20:12:02 +02:00
|
|
|
my %files;
|
2002-10-01 20:10:54 +02:00
|
|
|
|
2009-05-17 13:26:16 +02:00
|
|
|
foreach my $test (@tests)
|
|
|
|
{
|
|
|
|
foreach my $test_dir ($tests->get_test_dirs($test))
|
|
|
|
{
|
|
|
|
foreach my $header ($tests->get_section($test_dir, $test, "header"))
|
|
|
|
{
|
|
|
|
if (!$files{$header})
|
|
|
|
{
|
2002-10-23 20:44:46 +02:00
|
|
|
push @files, "include/$header";
|
2009-05-17 13:26:16 +02:00
|
|
|
$files{$header} = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-10-01 20:10:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-11-04 23:40:13 +01:00
|
|
|
if (0) {
|
|
|
|
my $file = "tests.dat";
|
|
|
|
|
|
|
|
$file .= "2"; # FIXME: For tests
|
|
|
|
|
2006-08-08 12:19:31 +02:00
|
|
|
open(OUT, "> $winapi_dir/$file") || die "Error: Can't open $winapi_dir/$file: $!\n";
|
2002-11-04 23:40:13 +01:00
|
|
|
|
|
|
|
my $x = 0;
|
|
|
|
my @test_dirs = $tests->get_test_dirs();
|
|
|
|
foreach my $test_dir (@test_dirs) {
|
|
|
|
print OUT "\n" if $x++;
|
|
|
|
print OUT "%%%$test_dir\n";
|
|
|
|
print OUT "\n";
|
|
|
|
|
|
|
|
my $y = 0;
|
|
|
|
my @tests = $tests->get_tests($test_dir);
|
|
|
|
foreach my $test (@tests) {
|
|
|
|
print OUT "\n" if $y++;
|
|
|
|
print OUT "%%$test\n";
|
|
|
|
print OUT "\n";
|
|
|
|
|
|
|
|
my @types;
|
|
|
|
|
|
|
|
my $z = 0;
|
|
|
|
my @sections = $tests->get_sections($test_dir, $test);
|
|
|
|
foreach my $section (@sections) {
|
|
|
|
my @lines = $tests->get_section($test_dir, $test, $section);
|
|
|
|
|
|
|
|
if ($section =~ /^(?:struct|type)$/) {
|
|
|
|
foreach my $line (@lines) {
|
|
|
|
push @types, $line;
|
|
|
|
}
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
|
|
|
print OUT "\n" if $z++;
|
|
|
|
print OUT "%$section\n";
|
|
|
|
print OUT "\n";
|
|
|
|
foreach my $line (@lines) {
|
|
|
|
print OUT "$line\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@types = sort { $x = $a; $y = $b; $x =~ s/^!//; $y =~ s/^!//; $x cmp $y } @types;
|
|
|
|
|
|
|
|
print OUT "\n" if $z++;
|
|
|
|
print OUT "%type\n";
|
|
|
|
print OUT "\n";
|
|
|
|
foreach my $type (@types) {
|
|
|
|
print OUT "$type\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
close(OUT);
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-10-01 20:10:54 +02:00
|
|
|
my %file2types;
|
|
|
|
|
|
|
|
my $progress_output;
|
|
|
|
my $progress_current = 0;
|
|
|
|
my $progress_max = scalar(@files);
|
|
|
|
|
2002-10-09 20:12:02 +02:00
|
|
|
########################################################################
|
|
|
|
# find_type
|
|
|
|
|
|
|
|
my %type_name2type;
|
|
|
|
|
|
|
|
my %defines = (
|
|
|
|
"ANYSIZE_ARRAY" => 1,
|
|
|
|
"CCHDEVICENAME" => 32,
|
2004-08-16 21:46:09 +02:00
|
|
|
"CCHILDREN_TITLEBAR+1" => 6,
|
2002-10-09 20:12:02 +02:00
|
|
|
"ELF_VENDOR_SIZE" => 4,
|
|
|
|
"EXCEPTION_MAXIMUM_PARAMETERS" => 15,
|
|
|
|
"HW_PROFILE_GUIDLEN" => 39,
|
|
|
|
"IMAGE_NUMBEROF_DIRECTORY_ENTRIES" => 16,
|
|
|
|
"IMAGE_SIZEOF_SHORT_NAME" => 8,
|
|
|
|
"LF_FACESIZE" => 32,
|
|
|
|
"LF_FULLFACESIZE" => 64,
|
|
|
|
"MAXIMUM_SUPPORTED_EXTENSION" => 512,
|
2002-11-12 02:05:17 +01:00
|
|
|
"MAX_GOPHER_DISPLAY_TEXT + 1" => 129,
|
|
|
|
"MAX_GOPHER_LOCATOR_LENGTH + 1" => 654,
|
2002-10-09 20:12:02 +02:00
|
|
|
"MAX_PATH" => 260,
|
2004-08-16 21:46:09 +02:00
|
|
|
"MAX_PROFILE_LEN" => 80,
|
|
|
|
"NUM_POINTS" => 3,
|
2002-10-09 20:12:02 +02:00
|
|
|
"OFS_MAXPATHNAME" => 128,
|
|
|
|
"SIZE_OF_80387_REGISTERS" => 80,
|
2002-10-23 20:44:46 +02:00
|
|
|
"TOKEN_SOURCE_LENGTH" => 8,
|
2002-10-09 20:12:02 +02:00
|
|
|
);
|
|
|
|
|
2002-10-11 19:53:13 +02:00
|
|
|
my %align_kludge_reported = ("FILETIME" => 1, "LARGE_INTEGER" => 1);
|
2002-11-04 23:40:13 +01:00
|
|
|
my %size_kludge_reported = ("FILETIME" => 1, "LARGE_INTEGER" => 1);
|
|
|
|
my %size_parse_reported;
|
2002-10-11 19:53:13 +02:00
|
|
|
|
2004-10-26 02:12:21 +02:00
|
|
|
sub _find_align_kind_size($) {
|
2002-10-11 19:53:13 +02:00
|
|
|
my $type_name = shift;
|
|
|
|
|
|
|
|
local $_ = $type_name;
|
|
|
|
|
|
|
|
my $align;
|
2002-11-04 23:40:13 +01:00
|
|
|
my $kind;
|
|
|
|
my $size;
|
2009-04-20 15:08:33 +02:00
|
|
|
if (/\*+$/) {
|
2010-04-07 17:22:51 +02:00
|
|
|
$align = $pointer_size;
|
2002-11-04 23:40:13 +01:00
|
|
|
$kind = "pointer";
|
2010-04-07 17:22:51 +02:00
|
|
|
$size = $pointer_size;
|
2004-05-04 02:38:27 +02:00
|
|
|
} elsif(/^(?:(signed|unsigned)\s+)?(?:__int8|char|byte)$/) {
|
2002-10-11 19:53:13 +02:00
|
|
|
$align = 1;
|
2002-11-04 23:40:13 +01:00
|
|
|
$kind = defined($1) ? $1 : "signed";
|
|
|
|
$size = 1;
|
|
|
|
} elsif (/^(?:(signed|unsigned)\s+)?(?:__int16|short(?:\s+int)?)$/) {
|
2002-10-11 19:53:13 +02:00
|
|
|
$align = 2;
|
2002-11-04 23:40:13 +01:00
|
|
|
$kind = defined($1) ? $1 : "signed";
|
|
|
|
$size = 2;
|
2002-10-11 19:53:13 +02:00
|
|
|
} elsif (/^(?:wchar_t)$/) {
|
|
|
|
$align = 2;
|
2002-11-04 23:40:13 +01:00
|
|
|
$kind = "signed";
|
|
|
|
$size = 2;
|
2004-08-16 21:46:09 +02:00
|
|
|
} elsif (/^(signed|unsigned)$/) {
|
|
|
|
$align = 4;
|
|
|
|
$kind = defined($1) ? $1 : "signed";
|
|
|
|
$size = 4;
|
2010-04-07 17:22:51 +02:00
|
|
|
} elsif (/^(?:(signed|unsigned)\s+)?(?:__int32|int)$/) {
|
2002-10-11 19:53:13 +02:00
|
|
|
$align = 4;
|
2002-11-04 23:40:13 +01:00
|
|
|
$kind = defined($1) ? $1 : "signed";
|
|
|
|
$size = 4;
|
2010-04-07 17:22:51 +02:00
|
|
|
} elsif (/^(?:(signed|unsigned)\s+)?(?:long(?:\s+int)?)$/) {
|
|
|
|
$align = $pointer_size;
|
|
|
|
$kind = defined($1) ? $1 : "signed";
|
|
|
|
$size = $pointer_size;
|
2002-10-11 19:53:13 +02:00
|
|
|
} elsif (/^(?:float)$/) {
|
|
|
|
$align = 4;
|
2002-11-04 23:40:13 +01:00
|
|
|
$kind = "float";
|
|
|
|
$size = 4;
|
|
|
|
} elsif (/^(?:(signed|unsigned)\s+)?__int64$/) {
|
|
|
|
$align = 8;
|
|
|
|
$kind = defined($1) ? $1 : "signed";
|
|
|
|
$size = 8;
|
2004-08-16 21:46:09 +02:00
|
|
|
} elsif (/^(?:double|DOUBLE|DATE)$/) {
|
2004-05-04 02:38:27 +02:00
|
|
|
$align = 8;
|
2002-11-04 23:40:13 +01:00
|
|
|
$kind = "float";
|
|
|
|
$size = 8;
|
2002-10-11 19:53:13 +02:00
|
|
|
} elsif (/^(?:long\s+double)$/) {
|
|
|
|
$align = 4;
|
2002-11-04 23:40:13 +01:00
|
|
|
$kind = "float";
|
2003-10-22 01:48:13 +02:00
|
|
|
$size = 12;
|
2009-05-06 13:44:54 +02:00
|
|
|
} elsif (/^H(?:DC|BITMAP|BRUSH|ICON|INSTANCE|KEY|MENU|METAFILE|WND)$/) {
|
2010-04-07 17:22:51 +02:00
|
|
|
$align = $pointer_size;
|
2009-05-06 13:44:54 +02:00
|
|
|
$kind = "pointer";
|
2010-04-07 17:22:51 +02:00
|
|
|
$size = $pointer_size;
|
2004-05-04 02:38:27 +02:00
|
|
|
} elsif (/^LP(?:BYTE|CSTR|CWSTR|DWORD|STR|VOID|WSTR)$/) {
|
2010-04-07 17:22:51 +02:00
|
|
|
$align = $pointer_size;
|
2002-11-04 23:40:13 +01:00
|
|
|
$kind = "pointer";
|
2010-04-07 17:22:51 +02:00
|
|
|
$size = $pointer_size;
|
2002-11-04 23:40:13 +01:00
|
|
|
} elsif (/^(?:FILETIME)$/) {
|
2002-10-11 19:53:13 +02:00
|
|
|
$align = 4;
|
2002-11-04 23:40:13 +01:00
|
|
|
$kind = "struct";
|
|
|
|
$size = 8;
|
2009-01-08 00:18:27 +01:00
|
|
|
} elsif (/^GUID$/) {
|
|
|
|
$align = 4;
|
|
|
|
$kind = "struct";
|
|
|
|
$size = 16;
|
2004-05-04 02:38:27 +02:00
|
|
|
} elsif (/^(?:VOID)$/) {
|
2004-08-16 21:46:09 +02:00
|
|
|
$align = 4;
|
|
|
|
$kind = "signed";
|
|
|
|
$size = 4;
|
2004-05-04 02:38:27 +02:00
|
|
|
} elsif (/^(?:SHORT)$/) {
|
|
|
|
$align = 2;
|
|
|
|
$kind = "unsigned";
|
|
|
|
$size = 2;
|
|
|
|
} elsif (/^(?:BYTE)$/) {
|
|
|
|
$align = 1;
|
|
|
|
$kind = "unsigned";
|
|
|
|
$size = 1;
|
|
|
|
} elsif (/^(?:DWORD)$/) {
|
2002-11-04 23:40:13 +01:00
|
|
|
$align = 4;
|
2004-05-04 02:38:27 +02:00
|
|
|
$kind = "unsigned";
|
|
|
|
$size = 4;
|
|
|
|
} elsif (/^(?:WORD)$/) {
|
|
|
|
$align = 2;
|
|
|
|
$kind = "unsigned";
|
|
|
|
$size = 2;
|
2004-08-16 21:46:09 +02:00
|
|
|
} elsif (/^(?:INT64|LONG64|LONGLONG)$/) {
|
|
|
|
$align = 8;
|
|
|
|
$kind = "signed";
|
|
|
|
$size = 8;
|
|
|
|
} elsif (/^(?:UINT64|ULONG64|DWORD64|ULONGLONG|DWORDLONG)$/) {
|
|
|
|
$align = 8;
|
|
|
|
$kind = "unsigned";
|
|
|
|
$size = 8;
|
2004-05-04 02:38:27 +02:00
|
|
|
} elsif (/^(?:LARGE_INTEGER)$/) {
|
|
|
|
$align = 8;
|
|
|
|
$kind = "union";
|
2002-11-04 23:40:13 +01:00
|
|
|
$size = 8;
|
2006-10-10 20:35:46 +02:00
|
|
|
} elsif (/^(?:POINTS)$/) {
|
|
|
|
$align = 2;
|
|
|
|
$kind = "struct";
|
|
|
|
$size = 4;
|
2002-11-04 23:40:13 +01:00
|
|
|
} elsif (/^(struct|union)$/) {
|
|
|
|
$kind = $1;
|
|
|
|
if (!$size_parse_reported{$_}) {
|
|
|
|
$output->write("$type_name: can't parse type\n");
|
|
|
|
$size_parse_reported{$_} = 1;
|
|
|
|
}
|
2003-10-22 01:48:13 +02:00
|
|
|
} elsif (/^\w+\s*\((?:\s*CALLBACK|\s*NTAPI|\s*WINAPI)?\s*\*\s*\)\s*\(.*?\)$/) {
|
2010-04-07 17:22:51 +02:00
|
|
|
$align = $pointer_size;
|
2002-11-06 22:58:50 +01:00
|
|
|
$kind = "pointer";
|
2010-04-07 17:22:51 +02:00
|
|
|
$size = $pointer_size;
|
2002-10-11 19:53:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
my $align2;
|
2010-04-07 17:22:51 +02:00
|
|
|
if (defined(my $type = $type_name2type{$pointer_size}{$_})) {
|
2002-10-11 19:53:13 +02:00
|
|
|
$align2 = $type->align;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!defined($align)) {
|
|
|
|
$align = $align2;
|
|
|
|
} elsif (defined($align2) && !$align_kludge_reported{$_}) {
|
|
|
|
$align_kludge_reported{$_} = 1;
|
|
|
|
$output->write("$type_name: type needn't be kludged\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!defined($align)) {
|
|
|
|
# $output->write("$type_name: can't find type\n");
|
|
|
|
}
|
|
|
|
|
2002-10-09 20:12:02 +02:00
|
|
|
my $size2;
|
2010-04-07 17:22:51 +02:00
|
|
|
if (defined(my $type = $type_name2type{$pointer_size}{$_})) {
|
2002-10-09 20:12:02 +02:00
|
|
|
$size2 = $type->size;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!defined($size)) {
|
|
|
|
$size = $size2;
|
2002-10-11 19:53:13 +02:00
|
|
|
} elsif (defined($size2) && !$size_kludge_reported{$_}) {
|
|
|
|
$size_kludge_reported{$_} = 1;
|
2002-10-09 20:12:02 +02:00
|
|
|
$output->write("$type_name: type needn't be kludged\n");
|
|
|
|
}
|
|
|
|
|
2002-11-04 23:40:13 +01:00
|
|
|
return ($align, $kind, $size);
|
|
|
|
}
|
|
|
|
|
2004-10-26 02:12:21 +02:00
|
|
|
sub find_align($) {
|
2002-11-04 23:40:13 +01:00
|
|
|
my $type_name = shift;
|
|
|
|
(my $align, my $kind, my $size) = _find_align_kind_size($type_name);
|
|
|
|
return $align;
|
|
|
|
}
|
|
|
|
|
2004-10-26 02:12:21 +02:00
|
|
|
sub find_kind($) {
|
2002-11-04 23:40:13 +01:00
|
|
|
my $type_name = shift;
|
|
|
|
(my $align, my $kind, my $size) = _find_align_kind_size($type_name);
|
|
|
|
|
|
|
|
return $kind;
|
|
|
|
}
|
|
|
|
|
2004-10-26 02:12:21 +02:00
|
|
|
sub find_size($) {
|
2002-11-04 23:40:13 +01:00
|
|
|
my $type_name = shift;
|
|
|
|
(my $align, my $kind, my $size) = _find_align_kind_size($type_name);
|
2002-10-09 20:12:02 +02:00
|
|
|
return $size;
|
|
|
|
}
|
|
|
|
|
2004-10-26 02:12:21 +02:00
|
|
|
sub find_count($) {
|
2004-08-20 21:33:17 +02:00
|
|
|
my $count = shift;
|
|
|
|
return $defines{$count};
|
|
|
|
}
|
|
|
|
|
2002-10-01 20:10:54 +02:00
|
|
|
foreach my $file (@files) {
|
2010-04-07 17:22:51 +02:00
|
|
|
$progress_current++;
|
|
|
|
foreach my $ptr (4, 8) {
|
|
|
|
$pointer_size = $ptr;
|
2002-10-01 20:10:54 +02:00
|
|
|
|
|
|
|
{
|
2006-08-08 12:19:31 +02:00
|
|
|
open(IN, "< $wine_dir/$file") || die "Error: Can't open $wine_dir/$file: $!\n";
|
2002-10-01 20:10:54 +02:00
|
|
|
local $/ = undef;
|
|
|
|
$_ = <IN>;
|
|
|
|
close(IN);
|
|
|
|
}
|
|
|
|
|
|
|
|
my $max_line = 0;
|
|
|
|
{
|
|
|
|
local $_ = $_;
|
|
|
|
while(s/^.*?\n//) { $max_line++; }
|
|
|
|
if($_) { $max_line++; }
|
|
|
|
}
|
|
|
|
|
|
|
|
my $parser = new c_parser($file);
|
|
|
|
|
|
|
|
my $line;
|
|
|
|
my $type;
|
2010-04-07 17:22:51 +02:00
|
|
|
my @packs = ();
|
2010-04-07 17:22:51 +02:00
|
|
|
my @ifdefs = ();
|
2002-10-01 20:10:54 +02:00
|
|
|
|
|
|
|
my $update_output = sub {
|
|
|
|
my $progress = "";
|
|
|
|
my $prefix = "";
|
|
|
|
|
2010-04-07 17:22:51 +02:00
|
|
|
$progress .= "$file (file $progress_current of $progress_max" . sprintf ", %u-bit)", $pointer_size * 8;
|
2002-10-01 20:10:54 +02:00
|
|
|
$prefix .= "$file: ";
|
|
|
|
|
|
|
|
if(defined($line)) {
|
|
|
|
$progress .= ": line $line of $max_line";
|
|
|
|
}
|
|
|
|
|
|
|
|
$output->progress($progress);
|
|
|
|
$output->prefix($prefix);
|
|
|
|
};
|
|
|
|
|
|
|
|
&$update_output();
|
|
|
|
|
|
|
|
my $found_line = sub {
|
|
|
|
$line = shift;
|
|
|
|
|
|
|
|
&$update_output;
|
|
|
|
};
|
|
|
|
$parser->set_found_line_callback($found_line);
|
|
|
|
|
2002-10-02 21:54:14 +02:00
|
|
|
my $found_preprocessor = sub {
|
|
|
|
my $begin_line = shift;
|
|
|
|
my $begin_column = shift;
|
|
|
|
my $preprocessor = shift;
|
|
|
|
|
2003-10-22 01:48:13 +02:00
|
|
|
#print "found_preprocessor: $begin_line: [$_]\n";
|
|
|
|
if ($preprocessor =~ /^\#\s*include\s+[\"<]pshpack(\d+)\.h[\">]$/) {
|
2010-04-07 17:22:51 +02:00
|
|
|
push @packs, $1 unless @ifdefs && !$ifdefs[$#ifdefs];
|
2003-10-22 01:48:13 +02:00
|
|
|
#print "found pack $1 on line $begin_line\n";
|
|
|
|
} elsif($preprocessor =~ /^\#\s*include\s+[\"<]poppack\.h[\">]$/) {
|
2010-04-07 17:22:51 +02:00
|
|
|
pop @packs unless @ifdefs && !$ifdefs[$#ifdefs];
|
2003-10-22 01:48:13 +02:00
|
|
|
#print "found poppack on line $begin_line\n";
|
2010-04-07 17:22:51 +02:00
|
|
|
} elsif ($preprocessor =~ /^\#\s*ifdef\s+_WIN64/) {
|
2010-04-07 17:22:51 +02:00
|
|
|
push @ifdefs, ($pointer_size == 8);
|
2010-04-07 17:22:51 +02:00
|
|
|
} elsif ($preprocessor =~ /^\#\s*ifndef\s+_WIN64/) {
|
2010-04-07 17:22:51 +02:00
|
|
|
push @ifdefs, ($pointer_size == 4);
|
2010-04-07 17:22:51 +02:00
|
|
|
} elsif ($preprocessor =~ /^\#\s*elif\s+defined(_WIN64)/) {
|
2010-04-07 17:22:51 +02:00
|
|
|
$ifdefs[$#ifdefs] = ($pointer_size == 8);
|
2010-04-07 17:22:51 +02:00
|
|
|
} elsif ($preprocessor =~ /^\#\s*ifdef\s/) {
|
|
|
|
push @ifdefs, 2;
|
|
|
|
} elsif ($preprocessor =~ /^\#\s*ifndef\s/) {
|
|
|
|
push @ifdefs, 2;
|
|
|
|
} elsif ($preprocessor =~ /^\#\s*if/) {
|
|
|
|
push @ifdefs, 2;
|
|
|
|
} elsif ($preprocessor =~ /^\#\s*else/) {
|
|
|
|
$ifdefs[$#ifdefs] = $ifdefs[$#ifdefs] ^ 1;
|
|
|
|
} elsif ($preprocessor =~ /^\#\s*elif/) {
|
|
|
|
$ifdefs[$#ifdefs] = 2;
|
|
|
|
} elsif ($preprocessor =~ /^\#\s*endif/) {
|
|
|
|
pop @ifdefs;
|
|
|
|
}
|
2002-10-02 21:54:14 +02:00
|
|
|
return 1;
|
|
|
|
};
|
|
|
|
$parser->set_found_preprocessor_callback($found_preprocessor);
|
|
|
|
|
2002-10-01 20:10:54 +02:00
|
|
|
my $found_type = sub {
|
|
|
|
$type = shift;
|
2010-04-07 17:22:51 +02:00
|
|
|
return if @ifdefs && !$ifdefs[$#ifdefs];
|
2002-10-01 20:10:54 +02:00
|
|
|
|
2002-10-09 20:12:02 +02:00
|
|
|
&$update_output();
|
|
|
|
|
2002-10-01 20:10:54 +02:00
|
|
|
my $name = $type->name;
|
2010-04-07 17:22:51 +02:00
|
|
|
$file2types{$pointer_size}{$file}{$name} = $type;
|
2002-10-01 20:10:54 +02:00
|
|
|
|
2002-10-11 19:53:13 +02:00
|
|
|
$type->set_find_align_callback(\&find_align);
|
2002-11-04 23:40:13 +01:00
|
|
|
$type->set_find_kind_callback(\&find_kind);
|
2002-10-11 19:53:13 +02:00
|
|
|
$type->set_find_size_callback(\&find_size);
|
2004-08-20 21:33:17 +02:00
|
|
|
$type->set_find_count_callback(\&find_count);
|
2002-10-11 19:53:13 +02:00
|
|
|
|
|
|
|
my $pack = $packs[$#packs];
|
2002-11-04 23:40:13 +01:00
|
|
|
if (!defined($type->pack) && $type->kind =~ /^(?:struct|union)$/) {
|
2002-10-11 19:53:13 +02:00
|
|
|
$type->pack($pack);
|
|
|
|
}
|
|
|
|
my $size = $type->size();
|
2002-10-09 20:12:02 +02:00
|
|
|
if (defined($size)) {
|
2002-10-11 19:53:13 +02:00
|
|
|
my $max_field_base_size = 0;
|
|
|
|
|
|
|
|
foreach my $field ($type->fields()) {
|
2002-10-09 20:12:02 +02:00
|
|
|
my $field_type_name = $field->type_name;
|
|
|
|
my $field_name = $field->name;
|
|
|
|
my $field_size = $field->size;
|
2002-10-11 19:53:13 +02:00
|
|
|
my $field_base_size = $field->base_size;
|
2002-10-09 20:12:02 +02:00
|
|
|
my $field_offset = $field->offset;
|
2002-10-11 19:53:13 +02:00
|
|
|
my $field_align = $field->align;
|
2002-10-09 20:12:02 +02:00
|
|
|
|
2002-10-11 19:53:13 +02:00
|
|
|
# $output->write("$name: $field_type_name: $field_name: $field_offset: $field_size($field_base_size): $field_align\n");
|
2002-10-09 20:12:02 +02:00
|
|
|
}
|
|
|
|
# $output->write("$name: $size\n");
|
|
|
|
|
2010-04-07 17:22:51 +02:00
|
|
|
$type_name2type{$pointer_size}{$name} = $type;
|
2002-10-09 20:12:02 +02:00
|
|
|
} else {
|
|
|
|
# $output->write("$name: can't find size\n");
|
|
|
|
}
|
2002-10-01 20:10:54 +02:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
};
|
|
|
|
$parser->set_found_type_callback($found_type);
|
|
|
|
|
|
|
|
{
|
|
|
|
my $line = 1;
|
|
|
|
my $column = 0;
|
|
|
|
if(!$parser->parse_c_file(\$_, \$line, \$column)) {
|
|
|
|
$output->write("can't parse file\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$output->prefix("");
|
2010-04-07 17:22:51 +02:00
|
|
|
}
|
2002-10-01 20:10:54 +02:00
|
|
|
}
|
|
|
|
|
2002-10-02 21:54:14 +02:00
|
|
|
########################################################################
|
|
|
|
# output_header
|
|
|
|
|
2004-10-26 02:12:21 +02:00
|
|
|
sub output_header($$$) {
|
2002-10-01 20:10:54 +02:00
|
|
|
local *OUT = shift;
|
|
|
|
|
|
|
|
my $test_dir = shift;
|
2002-10-02 21:54:14 +02:00
|
|
|
my @tests = @{(shift)};
|
2002-10-01 20:10:54 +02:00
|
|
|
|
2008-06-17 07:57:45 +02:00
|
|
|
print OUT "/* File generated automatically from tools/winapi/tests.dat; do not edit! */\n";
|
2002-10-01 20:10:54 +02:00
|
|
|
print OUT "/* This file can be copied, modified and distributed without restriction. */\n";
|
|
|
|
print OUT "\n";
|
|
|
|
|
|
|
|
print OUT "/*\n";
|
2002-10-02 21:54:14 +02:00
|
|
|
foreach my $test (@tests) {
|
|
|
|
my @description = $tests->get_section($test_dir, $test, "description");
|
|
|
|
foreach my $description (@description) {
|
|
|
|
print OUT " * $description\n";
|
|
|
|
}
|
2002-10-01 20:10:54 +02:00
|
|
|
}
|
|
|
|
print OUT " */\n";
|
|
|
|
print OUT "\n";
|
2002-10-29 22:23:44 +01:00
|
|
|
|
2002-10-23 20:44:46 +02:00
|
|
|
print OUT "#define WINVER 0x0501\n";
|
2002-11-12 02:05:17 +01:00
|
|
|
print OUT "#define _WIN32_IE 0x0501\n";
|
2002-10-29 22:23:44 +01:00
|
|
|
print OUT "#define _WIN32_WINNT 0x0501\n";
|
|
|
|
print OUT "\n";
|
2002-10-23 20:44:46 +02:00
|
|
|
print OUT "#define WINE_NOWINSOCK\n";
|
2002-10-01 20:10:54 +02:00
|
|
|
print OUT "\n";
|
2002-10-02 21:54:14 +02:00
|
|
|
foreach my $test (@tests) {
|
|
|
|
my @includes = $tests->get_section($test_dir, $test, "include");
|
|
|
|
foreach my $include (@includes) {
|
2003-10-24 06:43:16 +02:00
|
|
|
print OUT "#include $include\n";
|
2002-10-02 21:54:14 +02:00
|
|
|
}
|
2002-10-01 20:10:54 +02:00
|
|
|
}
|
|
|
|
print OUT "\n";
|
2002-10-23 20:44:46 +02:00
|
|
|
print OUT "#include \"wine/test.h\"\n";
|
|
|
|
print OUT "\n";
|
2002-10-15 03:24:03 +02:00
|
|
|
|
2002-10-29 22:23:44 +01:00
|
|
|
print OUT "/***********************************************************************\n";
|
2008-01-16 12:17:40 +01:00
|
|
|
print OUT " * Compatibility macros\n";
|
2002-10-29 22:23:44 +01:00
|
|
|
print OUT " */\n";
|
|
|
|
print OUT "\n";
|
|
|
|
print OUT "#define DWORD_PTR UINT_PTR\n";
|
|
|
|
print OUT "#define LONG_PTR INT_PTR\n";
|
|
|
|
print OUT "#define ULONG_PTR UINT_PTR\n";
|
|
|
|
print OUT "\n";
|
|
|
|
|
2002-10-15 03:24:03 +02:00
|
|
|
print OUT "/***********************************************************************\n";
|
|
|
|
print OUT " * Windows API extension\n";
|
|
|
|
print OUT " */\n";
|
|
|
|
print OUT "\n";
|
2003-09-30 02:33:47 +02:00
|
|
|
print OUT "#if defined(_MSC_VER) && (_MSC_VER >= 1300) && defined(__cplusplus)\n";
|
2002-11-04 23:40:13 +01:00
|
|
|
print OUT "# define _TYPE_ALIGNMENT(type) __alignof(type)\n";
|
|
|
|
print OUT "#elif defined(__GNUC__)\n";
|
|
|
|
print OUT "# define _TYPE_ALIGNMENT(type) __alignof__(type)\n";
|
|
|
|
print OUT "#else\n";
|
|
|
|
print OUT "/*\n";
|
2009-01-08 00:18:48 +01:00
|
|
|
print OUT " * FIXME: May not be possible without a compiler extension\n";
|
|
|
|
print OUT " * (if type is not just a name that is, otherwise the normal\n";
|
2002-11-04 23:40:13 +01:00
|
|
|
print OUT " * TYPE_ALIGNMENT can be used)\n";
|
|
|
|
print OUT " */\n";
|
|
|
|
print OUT "#endif\n";
|
|
|
|
print OUT "\n";
|
2004-09-06 22:29:53 +02:00
|
|
|
print OUT "#if defined(TYPE_ALIGNMENT) && defined(_MSC_VER) && _MSC_VER >= 800 && !defined(__cplusplus)\n";
|
|
|
|
print OUT "#pragma warning(disable:4116)\n";
|
|
|
|
print OUT "#endif\n";
|
|
|
|
print OUT "\n";
|
2002-11-04 23:40:13 +01:00
|
|
|
print OUT "#if !defined(TYPE_ALIGNMENT) && defined(_TYPE_ALIGNMENT)\n";
|
|
|
|
print OUT "# define TYPE_ALIGNMENT _TYPE_ALIGNMENT\n";
|
|
|
|
print OUT "#endif\n";
|
|
|
|
print OUT "\n";
|
|
|
|
|
2002-10-15 03:24:03 +02:00
|
|
|
print OUT "/***********************************************************************\n";
|
|
|
|
print OUT " * Test helper macros\n";
|
|
|
|
print OUT " */\n";
|
|
|
|
print OUT "\n";
|
2010-04-07 17:22:51 +02:00
|
|
|
print OUT "#define TEST_TYPE_SIZE(type, size) C_ASSERT(sizeof(type) == size);\n";
|
2002-10-15 03:24:03 +02:00
|
|
|
print OUT "\n";
|
2010-04-07 17:22:51 +02:00
|
|
|
print OUT "#ifdef TYPE_ALIGNMENT\n";
|
|
|
|
print OUT "# define TEST_TYPE_ALIGN(type, align) C_ASSERT(TYPE_ALIGNMENT(type) == align);\n";
|
|
|
|
print OUT "#else\n";
|
2009-01-08 00:26:10 +01:00
|
|
|
print OUT "# define TEST_TYPE_ALIGN(type, align)\n";
|
2010-04-07 17:22:51 +02:00
|
|
|
print OUT "#endif\n";
|
2002-10-15 03:24:03 +02:00
|
|
|
print OUT "\n";
|
2010-04-07 17:22:51 +02:00
|
|
|
print OUT "#ifdef _TYPE_ALIGNMENT\n";
|
|
|
|
print OUT "# define TEST_TARGET_ALIGN(type, align) C_ASSERT(_TYPE_ALIGNMENT(*(type)0) == align);\n";
|
|
|
|
print OUT "# define TEST_FIELD_ALIGN(type, field, align) C_ASSERT(_TYPE_ALIGNMENT(((type*)0)->field) == align);\n";
|
2002-11-04 23:40:13 +01:00
|
|
|
print OUT "#else\n";
|
2010-04-07 17:22:51 +02:00
|
|
|
print OUT "# define TEST_TARGET_ALIGN(type, align)\n";
|
|
|
|
print OUT "# define TEST_FIELD_ALIGN(type, field, align)\n";
|
2009-01-08 00:26:10 +01:00
|
|
|
print OUT "#endif\n";
|
2002-11-04 23:40:13 +01:00
|
|
|
print OUT "\n";
|
2010-04-07 17:22:51 +02:00
|
|
|
print OUT "#define TEST_FIELD_OFFSET(type, field, offset) C_ASSERT(FIELD_OFFSET(type, field) == offset);\n";
|
|
|
|
print OUT "\n";
|
2009-01-08 00:26:10 +01:00
|
|
|
print OUT "#define TEST_TARGET_SIZE(type, size) TEST_TYPE_SIZE(*(type)0, size)\n";
|
|
|
|
print OUT "#define TEST_FIELD_SIZE(type, field, size) TEST_TYPE_SIZE((((type*)0)->field), size)\n";
|
|
|
|
print OUT "#define TEST_TYPE_SIGNED(type) C_ASSERT((type) -1 < 0);\n";
|
|
|
|
print OUT "#define TEST_TYPE_UNSIGNED(type) C_ASSERT((type) -1 > 0);\n";
|
2002-11-04 23:40:13 +01:00
|
|
|
print OUT "\n";
|
|
|
|
print OUT "\n";
|
2002-10-01 20:10:54 +02:00
|
|
|
}
|
|
|
|
|
2002-10-02 21:54:14 +02:00
|
|
|
########################################################################
|
|
|
|
# output_footer
|
|
|
|
|
2004-10-26 02:12:21 +02:00
|
|
|
sub output_footer($$$) {
|
2002-10-01 20:10:54 +02:00
|
|
|
local *OUT = shift;
|
|
|
|
|
|
|
|
my $test_dir = shift;
|
2002-10-02 21:54:14 +02:00
|
|
|
my @tests = @{(shift)};
|
2002-10-01 20:10:54 +02:00
|
|
|
|
2002-10-02 21:54:14 +02:00
|
|
|
print OUT "START_TEST(generated)\n";
|
|
|
|
print OUT "{\n";
|
|
|
|
foreach my $test (@tests) {
|
|
|
|
print OUT " test_$test();\n";
|
|
|
|
}
|
2002-10-01 20:10:54 +02:00
|
|
|
print OUT "}\n";
|
|
|
|
}
|
|
|
|
|
2002-10-29 22:23:44 +01:00
|
|
|
########################################################################
|
|
|
|
# output_test_pack_type
|
|
|
|
|
2004-10-26 02:12:21 +02:00
|
|
|
sub output_test_pack_type($$$$$$) {
|
2002-10-29 22:23:44 +01:00
|
|
|
local *OUT = shift;
|
|
|
|
|
2002-11-04 23:40:13 +01:00
|
|
|
my $type_name2type = shift;
|
|
|
|
my $type_name2optional = shift;
|
|
|
|
my $type_name2optional_fields = shift;
|
2002-10-29 22:23:44 +01:00
|
|
|
my $type_name = shift;
|
|
|
|
my $type = shift;
|
|
|
|
|
2002-11-04 23:40:13 +01:00
|
|
|
my $optional_fields = $$type_name2optional_fields{$type_name};
|
|
|
|
|
2002-10-29 22:23:44 +01:00
|
|
|
my $type_align = $type->align;
|
|
|
|
my $type_pack = $type->pack;
|
|
|
|
my $type_size = $type->size;
|
2002-11-04 23:40:13 +01:00
|
|
|
my $type_kind = $type->kind;
|
|
|
|
|
|
|
|
if (defined($type_pack)) {
|
|
|
|
print OUT " /* $type_name (pack $type_pack) */\n";
|
|
|
|
} else {
|
|
|
|
print OUT " /* $type_name */\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!scalar(keys(%$optional_fields)) && defined($type_align) && defined($type_size)) {
|
2009-01-08 00:26:10 +01:00
|
|
|
print OUT " TEST_TYPE_SIZE ($type_name, $type_size)\n";
|
|
|
|
print OUT " TEST_TYPE_ALIGN ($type_name, $type_align)\n";
|
2002-10-29 22:23:44 +01:00
|
|
|
}
|
2002-11-04 23:40:13 +01:00
|
|
|
|
|
|
|
if ($type_kind eq "float") {
|
|
|
|
# Nothing
|
|
|
|
} elsif ($type_kind eq "pointer") {
|
|
|
|
my $dereference_type;
|
|
|
|
$dereference_type = sub {
|
|
|
|
my $type = shift;
|
|
|
|
|
|
|
|
my @fields = $type->fields;
|
|
|
|
my $type_name2 =$fields[0]->type_name;
|
2003-10-22 01:48:13 +02:00
|
|
|
|
2002-11-04 23:40:13 +01:00
|
|
|
if ($type_name2 =~ s/\s*\*$//) {
|
|
|
|
my $type2 = $$type_name2type{$type_name2};
|
|
|
|
if (defined($type2)) {
|
|
|
|
return $type2;
|
|
|
|
} else {
|
2002-11-06 22:58:50 +01:00
|
|
|
if ($type_name2 !~ /^(?:PVOID|VOID|void)$/) {
|
|
|
|
$output->write("$type_name2: warning: type not found 1\n");
|
|
|
|
}
|
2002-11-04 23:40:13 +01:00
|
|
|
return undef;
|
|
|
|
}
|
2002-11-06 22:58:50 +01:00
|
|
|
} elsif ($type_name2 =~ /^\w+$/) {
|
2002-11-04 23:40:13 +01:00
|
|
|
my $type2 = $$type_name2type{$type_name2};
|
|
|
|
if (defined($type2)) {
|
|
|
|
return &$dereference_type($type2);
|
|
|
|
} else {
|
2002-11-06 22:58:50 +01:00
|
|
|
$output->write("$type_name2: warning: type not found\n");
|
2002-11-04 23:40:13 +01:00
|
|
|
return undef;
|
|
|
|
}
|
2002-11-06 22:58:50 +01:00
|
|
|
} elsif ($type_name2 =~ /^\w+\s*\((?:\s*CALLBACK|\s*NTAPI|\s*WINAPI)?\s*\*\s*\)\s*\(.*?\)$/) {
|
|
|
|
return undef;
|
|
|
|
} else {
|
|
|
|
$output->write("$type_name2: warning: type can't be parsed\n");
|
|
|
|
return undef;
|
2002-11-04 23:40:13 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
my $type2 = &$dereference_type($type);
|
|
|
|
if (defined($type2)) {
|
|
|
|
my $type_name2 = $type2->name;
|
|
|
|
my $type_align2 = $type2->align;
|
|
|
|
my $type_size2 = $type2->size;
|
|
|
|
|
|
|
|
my $optional = $$type_name2optional{$type_name};
|
|
|
|
my $optional_fields2 = $$type_name2optional_fields{$type_name2};
|
|
|
|
|
|
|
|
if (!$optional && !scalar(keys(%$optional_fields2)) && defined($type_align2) && defined($type_size2)) {
|
2009-01-08 00:26:10 +01:00
|
|
|
print OUT " TEST_TARGET_SIZE ($type_name, $type_size2)\n";
|
|
|
|
print OUT " TEST_TARGET_ALIGN($type_name, $type_align2)\n";
|
2002-11-04 23:40:13 +01:00
|
|
|
} else {
|
2002-11-06 22:58:50 +01:00
|
|
|
# $output->write("$type_name: warning: type size not found\n");
|
2002-11-04 23:40:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} elsif ($type_kind eq "signed") {
|
2009-01-08 00:26:10 +01:00
|
|
|
print OUT " TEST_TYPE_SIGNED($type_name)\n";
|
2002-11-04 23:40:13 +01:00
|
|
|
} elsif ($type_kind eq "unsigned") {
|
2009-01-08 00:26:10 +01:00
|
|
|
print OUT " TEST_TYPE_UNSIGNED($type_name)\n";
|
2002-11-04 23:40:13 +01:00
|
|
|
}
|
2002-10-29 22:23:44 +01:00
|
|
|
}
|
2003-10-22 01:48:13 +02:00
|
|
|
|
2004-10-26 02:12:21 +02:00
|
|
|
sub output_test_pack_fields($$$$$$$);
|
|
|
|
sub output_test_pack_fields($$$$$$$) {
|
2002-10-29 22:23:44 +01:00
|
|
|
local *OUT = shift;
|
|
|
|
|
2002-11-04 23:40:13 +01:00
|
|
|
my $type_name2type = shift;
|
|
|
|
my $type_name2optional = shift;
|
|
|
|
my $type_name2optional_fields = shift;
|
2002-10-29 22:23:44 +01:00
|
|
|
my $type_name = shift;
|
|
|
|
my $type = shift;
|
|
|
|
my $offset = shift;
|
2002-11-04 23:40:13 +01:00
|
|
|
|
|
|
|
my $optional_fields = $$type_name2optional_fields{$type_name};
|
2002-10-29 22:23:44 +01:00
|
|
|
|
|
|
|
foreach my $field ($type->fields()) {
|
|
|
|
my $field_type_name = $field->type_name;
|
2004-09-01 06:53:22 +02:00
|
|
|
$field_type_name =~ s/\s+DECLSPEC_ALIGN\(\d+\)//;
|
2002-10-29 22:23:44 +01:00
|
|
|
my $field_name = $field->name;
|
|
|
|
my $field_size = $field->size;
|
|
|
|
my $field_offset = $field->offset;
|
|
|
|
my $field_align = $field->align;
|
|
|
|
|
|
|
|
next if $field_name eq "" || (defined($field_size) && $field_size < 0);
|
2004-08-20 21:33:17 +02:00
|
|
|
# We cannot take the address of a bitfield with MSVC
|
|
|
|
next if ($field_type_name =~ /:/);
|
2002-10-29 22:23:44 +01:00
|
|
|
|
2002-11-04 23:40:13 +01:00
|
|
|
if ($$optional_fields{$field_name}) {
|
2002-10-29 22:23:44 +01:00
|
|
|
# Nothing
|
|
|
|
} elsif (defined($field_size) && defined($field_offset)) {
|
|
|
|
$field_offset += $offset;
|
|
|
|
if ($field_name eq "DUMMYSTRUCTNAME") {
|
|
|
|
print OUT "#ifdef NONAMELESSSTRUCT\n";
|
2009-01-08 00:26:10 +01:00
|
|
|
print OUT " TEST_TYPE_SIZE ($type_name.$field_name, $field_size)\n";
|
|
|
|
print OUT " TEST_FIELD_ALIGN ($type_name, $field_name, $field_align)\n";
|
|
|
|
print OUT " TEST_FIELD_OFFSET($type_name, $field_name, $field_offset)\n";
|
2002-10-29 22:23:44 +01:00
|
|
|
print OUT "#else\n";
|
2002-11-04 23:40:13 +01:00
|
|
|
output_test_pack_fields(\*OUT, $type_name2type, $type_name2optional, $type_name2optional_fields,
|
|
|
|
$type_name, $$type_name2type{$field_type_name}, $field_offset);
|
2002-10-29 22:23:44 +01:00
|
|
|
print OUT "#endif\n";
|
|
|
|
} else {
|
2009-01-08 00:26:10 +01:00
|
|
|
print OUT " TEST_FIELD_SIZE ($type_name, $field_name, $field_size)\n";
|
|
|
|
print OUT " TEST_FIELD_ALIGN ($type_name, $field_name, $field_align)\n";
|
|
|
|
print OUT " TEST_FIELD_OFFSET($type_name, $field_name, $field_offset)\n";
|
2002-10-29 22:23:44 +01:00
|
|
|
}
|
|
|
|
} else {
|
2002-11-04 23:40:13 +01:00
|
|
|
# $output->write("$type_name: $field_type_name: $field_name: test not generated (offset not defined)\n");
|
2002-10-29 22:23:44 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-01 20:10:54 +02:00
|
|
|
########################################################################
|
2002-10-02 21:54:14 +02:00
|
|
|
# output_test_pack
|
2002-10-01 20:10:54 +02:00
|
|
|
|
2004-10-26 02:12:21 +02:00
|
|
|
sub output_test_pack($$$$) {
|
2002-10-01 20:10:54 +02:00
|
|
|
local *OUT = shift;
|
|
|
|
|
|
|
|
my $test_dir = shift;
|
|
|
|
my $test = shift;
|
|
|
|
|
2002-11-06 22:58:50 +01:00
|
|
|
my $type_names_used = shift;
|
|
|
|
|
2002-11-04 23:40:13 +01:00
|
|
|
$output->prefix("$test_dir: $test: ");
|
|
|
|
|
2002-10-23 20:44:46 +02:00
|
|
|
my @headers = $tests->get_section($test_dir, $test, "header");
|
2002-11-04 23:40:13 +01:00
|
|
|
my @type_names = $tests->get_section($test_dir, $test, "type");
|
2002-10-02 21:54:14 +02:00
|
|
|
|
2002-11-04 23:40:13 +01:00
|
|
|
my %type_name2optional;
|
|
|
|
my %type_name2optional_fields;
|
2002-10-02 21:54:14 +02:00
|
|
|
|
2002-10-29 22:23:44 +01:00
|
|
|
foreach my $_type_name (@type_names) {
|
|
|
|
my $type_name = $_type_name;
|
|
|
|
|
2002-11-04 23:40:13 +01:00
|
|
|
if ($type_name =~ s/^!//) {
|
|
|
|
$type_name2optional{$type_name}++;
|
|
|
|
}
|
|
|
|
|
|
|
|
my $optional_fields = {};
|
|
|
|
if ($type_name =~ s/:\s*(.*?)$//) {
|
|
|
|
my @fields = split /\s+/, $1;
|
|
|
|
foreach my $field (@fields) {
|
|
|
|
if ($field =~ s/^!//) {
|
|
|
|
$$optional_fields{$field}++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$type_name2optional_fields{$type_name} = $optional_fields;
|
2002-10-02 21:54:14 +02:00
|
|
|
}
|
|
|
|
|
2002-10-23 20:44:46 +02:00
|
|
|
foreach my $header (@headers) {
|
2010-04-07 17:22:51 +02:00
|
|
|
my $type_name2type = $file2types{$pointer_size}{"include/$header"};
|
2002-10-01 20:10:54 +02:00
|
|
|
|
2002-10-29 22:23:44 +01:00
|
|
|
foreach my $_type_name (@type_names) {
|
|
|
|
my $type_name = $_type_name;
|
|
|
|
|
2002-11-06 22:58:50 +01:00
|
|
|
my $skip = ($type_name =~ s/^!//);
|
2002-11-04 23:40:13 +01:00
|
|
|
$type_name =~ s/:.*?$//;
|
|
|
|
my $type = $$type_name2type{$type_name};
|
2002-10-02 21:54:14 +02:00
|
|
|
if (!defined($type)) {
|
|
|
|
next;
|
|
|
|
}
|
2002-11-06 22:58:50 +01:00
|
|
|
$$type_names_used{$type_name} = $skip ? -1 : 1;
|
|
|
|
next if $skip;
|
|
|
|
|
|
|
|
print OUT "static void test_${test}_$type_name(void)\n";
|
|
|
|
print OUT "{\n";
|
|
|
|
output_test_pack_type(\*OUT, $type_name2type, \%type_name2optional, \%type_name2optional_fields,
|
|
|
|
$type_name, $type);
|
|
|
|
output_test_pack_fields(\*OUT, $type_name2type, \%type_name2optional, \%type_name2optional_fields,
|
|
|
|
$type_name, $type, 0);
|
|
|
|
print OUT "}\n";
|
2002-10-11 19:53:13 +02:00
|
|
|
print OUT "\n";
|
2002-10-01 20:10:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-02 21:54:14 +02:00
|
|
|
|
|
|
|
########################################################################
|
|
|
|
# output_file
|
|
|
|
|
2004-10-26 02:12:21 +02:00
|
|
|
sub output_file($$$$) {
|
2002-10-02 21:54:14 +02:00
|
|
|
local *OUT = shift;
|
|
|
|
|
|
|
|
my $test_dir = shift;
|
|
|
|
my @tests = @{(shift)};
|
|
|
|
|
2002-11-06 22:58:50 +01:00
|
|
|
my $type_names_used = shift;
|
|
|
|
|
2002-10-02 21:54:14 +02:00
|
|
|
output_header(\*OUT, $test_dir, \@tests);
|
|
|
|
|
|
|
|
foreach my $test (@tests) {
|
2002-11-06 22:58:50 +01:00
|
|
|
my %type_names_used2;
|
2002-11-04 23:40:13 +01:00
|
|
|
|
2002-10-02 21:54:14 +02:00
|
|
|
if ($test eq "pack") {
|
2010-04-07 17:22:51 +02:00
|
|
|
print OUT "#ifdef _WIN64\n\n";
|
|
|
|
$pointer_size = 8;
|
|
|
|
output_test_pack(\*OUT, $test_dir, $test, \%type_names_used2);
|
|
|
|
print OUT "#else /* _WIN64 */\n\n";
|
|
|
|
$pointer_size = 4;
|
|
|
|
output_test_pack(\*OUT, $test_dir, $test, \%type_names_used2);
|
|
|
|
print OUT "#endif /* _WIN64 */\n\n";
|
2002-10-02 21:54:14 +02:00
|
|
|
} else {
|
|
|
|
die "no such test ($test)\n";
|
|
|
|
}
|
|
|
|
|
2002-11-06 22:58:50 +01:00
|
|
|
print OUT "static void test_$test(void)\n";
|
|
|
|
print OUT "{\n";
|
|
|
|
foreach my $type_name (sort(keys(%type_names_used2))) {
|
|
|
|
$$type_names_used{$type_name} = $type_names_used2{$type_name};
|
|
|
|
if ($type_names_used2{$type_name} > 0) {
|
|
|
|
print OUT " test_${test}_$type_name();\n";
|
|
|
|
}
|
|
|
|
}
|
2002-10-02 21:54:14 +02:00
|
|
|
print OUT "}\n";
|
|
|
|
print OUT "\n";
|
2002-10-01 20:10:54 +02:00
|
|
|
}
|
2002-10-02 21:54:14 +02:00
|
|
|
|
|
|
|
output_footer(\*OUT, $test_dir, \@tests);
|
2002-10-29 22:23:44 +01:00
|
|
|
|
|
|
|
return 1;
|
2002-10-02 21:54:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
########################################################################
|
|
|
|
# main
|
|
|
|
|
2002-11-06 22:58:50 +01:00
|
|
|
my %type_names_used = ();
|
|
|
|
|
2002-10-02 21:54:14 +02:00
|
|
|
my @test_dirs = $tests->get_test_dirs();
|
|
|
|
foreach my $test_dir (@test_dirs) {
|
|
|
|
my $file = "$wine_dir/$test_dir/generated.c";
|
2002-11-06 22:58:50 +01:00
|
|
|
replace_file($file, \&output_file, $test_dir, \@tests, \%type_names_used);
|
|
|
|
}
|
|
|
|
|
2010-04-07 17:22:51 +02:00
|
|
|
foreach my $header (sort(keys(%{$file2types{$pointer_size}}))) {
|
2002-11-06 22:58:50 +01:00
|
|
|
$output->prefix("$header: ");
|
|
|
|
$header =~ s%^include/%%;
|
2010-04-07 17:22:51 +02:00
|
|
|
my $type_name2type = $file2types{$pointer_size}{"include/$header"};
|
2002-11-06 22:58:50 +01:00
|
|
|
foreach my $_type_name (sort(keys(%$type_name2type))) {
|
|
|
|
my $type_name = $_type_name;
|
|
|
|
|
|
|
|
if (!exists($type_names_used{$type_name})) {
|
|
|
|
$output->write("$type_name: type not used\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$output->prefix("$winapi_dir/tests.dat: ");
|
|
|
|
foreach my $type_name (sort(keys(%type_names_used))) {
|
|
|
|
my $found = 0;
|
2010-04-07 17:22:51 +02:00
|
|
|
foreach my $header (sort(keys(%{$file2types{$pointer_size}}))) {
|
|
|
|
my $type_name2type = $file2types{$pointer_size}{"include/$header"};
|
2002-11-06 22:58:50 +01:00
|
|
|
if (exists($type_name2type{$type_name})) {
|
|
|
|
$found = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$found) {
|
|
|
|
$output->write("$type_name: type not used\n");
|
|
|
|
}
|
2002-10-01 20:10:54 +02:00
|
|
|
}
|