winapi: Add some support for handling ifdefs, particularly ifdef _WIN64.
This commit is contained in:
parent
701dd23911
commit
6b11a3c3f8
|
@ -330,30 +330,35 @@ sub new($$$)
|
||||||
sub align($)
|
sub align($)
|
||||||
{
|
{
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
return undef unless defined $self->{TYPE}->field_aligns();
|
||||||
return $self->{TYPE}->field_aligns()->[$self->{NUMBER}];
|
return $self->{TYPE}->field_aligns()->[$self->{NUMBER}];
|
||||||
}
|
}
|
||||||
|
|
||||||
sub base_size($)
|
sub base_size($)
|
||||||
{
|
{
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
return undef unless defined $self->{TYPE}->field_base_sizes();
|
||||||
return $self->{TYPE}->field_base_sizes()->[$self->{NUMBER}];
|
return $self->{TYPE}->field_base_sizes()->[$self->{NUMBER}];
|
||||||
}
|
}
|
||||||
|
|
||||||
sub name($)
|
sub name($)
|
||||||
{
|
{
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
return undef unless defined $self->{TYPE}->field_names();
|
||||||
return $self->{TYPE}->field_names()->[$self->{NUMBER}];
|
return $self->{TYPE}->field_names()->[$self->{NUMBER}];
|
||||||
}
|
}
|
||||||
|
|
||||||
sub offset($)
|
sub offset($)
|
||||||
{
|
{
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
return undef unless defined $self->{TYPE}->field_offsets();
|
||||||
return $self->{TYPE}->field_offsets()->[$self->{NUMBER}];
|
return $self->{TYPE}->field_offsets()->[$self->{NUMBER}];
|
||||||
}
|
}
|
||||||
|
|
||||||
sub size($)
|
sub size($)
|
||||||
{
|
{
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
return undef unless defined $self->{TYPE}->field_sizes();
|
||||||
return $self->{TYPE}->field_sizes()->[$self->{NUMBER}];
|
return $self->{TYPE}->field_sizes()->[$self->{NUMBER}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -352,6 +352,7 @@ foreach my $file (@files) {
|
||||||
my $line;
|
my $line;
|
||||||
my $type;
|
my $type;
|
||||||
my @packs = (4);
|
my @packs = (4);
|
||||||
|
my @ifdefs = ();
|
||||||
|
|
||||||
my $update_output = sub {
|
my $update_output = sub {
|
||||||
my $progress = "";
|
my $progress = "";
|
||||||
|
@ -384,19 +385,37 @@ foreach my $file (@files) {
|
||||||
|
|
||||||
#print "found_preprocessor: $begin_line: [$_]\n";
|
#print "found_preprocessor: $begin_line: [$_]\n";
|
||||||
if ($preprocessor =~ /^\#\s*include\s+[\"<]pshpack(\d+)\.h[\">]$/) {
|
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";
|
#print "found pack $1 on line $begin_line\n";
|
||||||
} elsif($preprocessor =~ /^\#\s*include\s+[\"<]poppack\.h[\">]$/) {
|
} elsif($preprocessor =~ /^\#\s*include\s+[\"<]poppack\.h[\">]$/) {
|
||||||
pop @packs;
|
pop @packs unless @ifdefs && !$ifdefs[$#ifdefs];
|
||||||
#print "found poppack on line $begin_line\n";
|
#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;
|
return 1;
|
||||||
};
|
};
|
||||||
$parser->set_found_preprocessor_callback($found_preprocessor);
|
$parser->set_found_preprocessor_callback($found_preprocessor);
|
||||||
|
|
||||||
my $found_type = sub {
|
my $found_type = sub {
|
||||||
$type = shift;
|
$type = shift;
|
||||||
|
return if @ifdefs && !$ifdefs[$#ifdefs];
|
||||||
|
|
||||||
&$update_output();
|
&$update_output();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue