winapi: Add some support for handling ifdefs, particularly ifdef _WIN64.

This commit is contained in:
Alexandre Julliard 2010-04-07 17:22:51 +02:00
parent 701dd23911
commit 6b11a3c3f8
2 changed files with 28 additions and 4 deletions

View File

@ -330,30 +330,35 @@ sub new($$$)
sub align($)
{
my ($self) = @_;
return undef unless defined $self->{TYPE}->field_aligns();
return $self->{TYPE}->field_aligns()->[$self->{NUMBER}];
}
sub base_size($)
{
my ($self) = @_;
return undef unless defined $self->{TYPE}->field_base_sizes();
return $self->{TYPE}->field_base_sizes()->[$self->{NUMBER}];
}
sub name($)
{
my ($self) = @_;
return undef unless defined $self->{TYPE}->field_names();
return $self->{TYPE}->field_names()->[$self->{NUMBER}];
}
sub offset($)
{
my ($self) = @_;
return undef unless defined $self->{TYPE}->field_offsets();
return $self->{TYPE}->field_offsets()->[$self->{NUMBER}];
}
sub size($)
{
my ($self) = @_;
return undef unless defined $self->{TYPE}->field_sizes();
return $self->{TYPE}->field_sizes()->[$self->{NUMBER}];
}

View File

@ -352,6 +352,7 @@ foreach my $file (@files) {
my $line;
my $type;
my @packs = (4);
my @ifdefs = ();
my $update_output = sub {
my $progress = "";
@ -384,19 +385,37 @@ foreach my $file (@files) {
#print "found_preprocessor: $begin_line: [$_]\n";
if ($preprocessor =~ /^\#\s*include\s+[\"<]pshpack(\d+)\.h[\">]$/) {
push @packs, $1;
push @packs, $1 unless @ifdefs && !$ifdefs[$#ifdefs];
#print "found pack $1 on line $begin_line\n";
} elsif($preprocessor =~ /^\#\s*include\s+[\"<]poppack\.h[\">]$/) {
pop @packs;
pop @packs unless @ifdefs && !$ifdefs[$#ifdefs];
#print "found poppack on line $begin_line\n";
} elsif ($preprocessor =~ /^\#\s*ifdef\s+_WIN64/) {
push @ifdefs, 0;
} elsif ($preprocessor =~ /^\#\s*ifndef\s+_WIN64/) {
push @ifdefs, 1;
} elsif ($preprocessor =~ /^\#\s*elif\s+defined(_WIN64)/) {
$ifdefs[$#ifdefs] = 0;
} 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;
}
return 1;
};
$parser->set_found_preprocessor_callback($found_preprocessor);
my $found_type = sub {
$type = shift;
return if @ifdefs && !$ifdefs[$#ifdefs];
&$update_output();