Release 20000326.
[wine/gsoc-2012-control.git] / tools / winapi_check / nativeapi.pm
blob2eadf8ade57e1d23f8761460b686dec2e171b0d7
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 $output = \${$self->{OUTPUT}};
12 my $functions = \%{$self->{FUNCTIONS}};
13 my $conditionals = \%{$self->{CONDITIONALS}};
14 my $conditional_headers = \%{$self->{CONDITIONAL_HEADERS}};
15 my $conditional_functions = \%{$self->{CONDITIONAL_FUNCTIONS}};
17 $$output = shift;
18 my $api_file = shift;
19 my $configure_in_file = shift;
20 my $config_h_in_file = shift;
22 $api_file =~ s/^\.\///;
23 $configure_in_file =~ s/^\.\///;
24 $config_h_in_file =~ s/^\.\///;
26 $$output->progress("$api_file");
28 open(IN, "< $api_file");
29 $/ = "\n";
30 while(<IN>) {
31 s/^\s*?(.*?)\s*$/$1/; # remove whitespace at begin and end of line
32 s/^(.*?)\s*#.*$/$1/; # remove comments
33 /^$/ && next; # skip empty lines
35 $$functions{$_}++;
37 close(IN);
39 $$output->progress("$configure_in_file");
41 my $again = 0;
42 open(IN, "< $configure_in_file");
43 local $/ = "\n";
44 while($again || (defined($_ = <IN>))) {
45 $again = 0;
46 chomp;
47 if(/(.*)\\$/) {
48 my $line = <IN>;
49 if(defined($line)) {
50 $_ = $1 . " " . $line;
51 $again = 1;
52 next;
55 # remove leading and trailing whitespace
56 s/^\s*(.*?)\s*$/$1/;
58 if(/^AC_CHECK_HEADERS\(\s*(.*?)\)\s*$/) {
59 my @arguments = split(/,/,$1);
60 foreach my $name (split(/\s+/, $arguments[0])) {
61 $$conditional_headers{$name}++;
63 } elsif(/^AC_CHECK_FUNCS\(\s*(.*?)\)\s*$/) {
64 my @arguments = split(/,/,$1);
65 foreach my $name (split(/\s+/, $arguments[0])) {
66 $$conditional_functions{$name}++;
68 } elsif(/^AC_FUNC_ALLOCA/) {
69 $$conditional_headers{"alloca.h"}++;
73 close(IN);
75 $$output->progress("$config_h_in_file");
77 open(IN, "< $config_h_in_file");
78 local $/ = "\n";
79 while(<IN>) {
80 if(/^\#undef\s+(\S+)$/) {
81 $$conditionals{$1}++;
84 close(IN);
86 return $self;
89 sub is_function {
90 my $self = shift;
91 my $functions = \%{$self->{FUNCTIONS}};
93 my $name = shift;
95 return $$functions{$name};
98 sub is_conditional {
99 my $self = shift;
100 my $conditionals = \%{$self->{CONDITIONALS}};
102 my $name = shift;
104 return $$conditionals{$name};
107 sub is_conditional_header {
108 my $self = shift;
109 my $conditional_headers = \%{$self->{CONDITIONAL_HEADERS}};
111 my $name = shift;
113 return $$conditional_headers{$name};
116 sub is_conditional_function {
117 my $self = shift;
118 my $conditional_functions = \%{$self->{CONDITIONAL_FUNCTIONS}};
120 my $name = shift;
122 return $$conditional_functions{$name};