Make child processes inherit command-line options through the
[wine.git] / tools / winapi_check / nativeapi.pm
blobfae13919679db659592e2d9f92ff6f5e5d95f49f
1 package nativeapi;
3 use strict;
5 sub new {
6 my $proto = shift;
7 my $class = ref($proto) || $proto;
8 my $self = {};
9 bless ($self, $class);
11 my $options = \${$self->{OPTIONS}};
12 my $output = \${$self->{OUTPUT}};
13 my $functions = \%{$self->{FUNCTIONS}};
14 my $conditionals = \%{$self->{CONDITIONALS}};
15 my $conditional_headers = \%{$self->{CONDITIONAL_HEADERS}};
16 my $conditional_functions = \%{$self->{CONDITIONAL_FUNCTIONS}};
18 $$options = shift;
19 $$output = shift;
20 my $api_file = shift;
21 my $configure_in_file = shift;
22 my $config_h_in_file = shift;
24 $api_file =~ s/^\.\///;
25 $configure_in_file =~ s/^\.\///;
26 $config_h_in_file =~ s/^\.\///;
28 if($$options->progress) {
29 $$output->progress("$api_file");
32 open(IN, "< $api_file");
33 local $/ = "\n";
34 while(<IN>) {
35 s/^\s*?(.*?)\s*$/$1/; # remove whitespace at begin and end of line
36 s/^(.*?)\s*#.*$/$1/; # remove comments
37 /^$/ && next; # skip empty lines
39 $$functions{$_}++;
41 close(IN);
43 if($$options->progress) {
44 $$output->progress("$configure_in_file");
47 my $again = 0;
48 open(IN, "< $configure_in_file");
49 local $/ = "\n";
50 while($again || (defined($_ = <IN>))) {
51 $again = 0;
52 chomp;
53 if(/(.*)\\$/) {
54 my $line = <IN>;
55 if(defined($line)) {
56 $_ = $1 . " " . $line;
57 $again = 1;
58 next;
61 # remove leading and trailing whitespace
62 s/^\s*(.*?)\s*$/$1/;
64 if(/^AC_CHECK_HEADERS\(\s*(.*?)\)\s*$/) {
65 my @arguments = split(/,/,$1);
66 foreach my $name (split(/\s+/, $arguments[0])) {
67 $$conditional_headers{$name}++;
69 } elsif(/^AC_CHECK_FUNCS\(\s*(.*?)\)\s*$/) {
70 my @arguments = split(/,/,$1);
71 foreach my $name (split(/\s+/, $arguments[0])) {
72 $$conditional_functions{$name}++;
74 } elsif(/^AC_FUNC_ALLOCA/) {
75 $$conditional_headers{"alloca.h"}++;
79 close(IN);
81 if($$options->progress) {
82 $$output->progress("$config_h_in_file");
85 open(IN, "< $config_h_in_file");
86 local $/ = "\n";
87 while(<IN>) {
88 if(/^\#undef\s+(\S+)$/) {
89 $$conditionals{$1}++;
92 close(IN);
94 return $self;
97 sub is_function {
98 my $self = shift;
99 my $functions = \%{$self->{FUNCTIONS}};
101 my $name = shift;
103 return $$functions{$name};
106 sub is_conditional {
107 my $self = shift;
108 my $conditionals = \%{$self->{CONDITIONALS}};
110 my $name = shift;
112 return $$conditionals{$name};
115 sub is_conditional_header {
116 my $self = shift;
117 my $conditional_headers = \%{$self->{CONDITIONAL_HEADERS}};
119 my $name = shift;
121 return $$conditional_headers{$name};
124 sub is_conditional_function {
125 my $self = shift;
126 my $conditional_functions = \%{$self->{CONDITIONAL_FUNCTIONS}};
128 my $name = shift;
130 return $$conditional_functions{$name};