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

Alexandre Julliard julliard at winehq.org
Wed Apr 7 11:56:10 CDT 2010


Module: wine
Branch: master
Commit: 6b11a3c3f81d7db3794f3320eeaef8001cc99b74
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=6b11a3c3f81d7db3794f3320eeaef8001cc99b74

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Wed Apr  7 17:22:51 2010 +0200

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

---

 tools/winapi/c_type.pm   |    5 +++++
 tools/winapi/winapi_test |   27 +++++++++++++++++++++++----
 2 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/tools/winapi/c_type.pm b/tools/winapi/c_type.pm
index 4e54270..b00cf81 100644
--- a/tools/winapi/c_type.pm
+++ b/tools/winapi/c_type.pm
@@ -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}];
 }
 
diff --git a/tools/winapi/winapi_test b/tools/winapi/winapi_test
index cf3a2b6..cafbafb 100755
--- a/tools/winapi/winapi_test
+++ b/tools/winapi/winapi_test
@@ -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();
 




More information about the wine-cvs mailing list