2002-03-10 00:29:33 +01:00
|
|
|
#
|
|
|
|
# Copyright 1999, 2000, 2001 Patrik Stridvall
|
|
|
|
#
|
|
|
|
# This library is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
|
|
# License as published by the Free Software Foundation; either
|
|
|
|
# version 2.1 of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This library is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
|
|
# License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-03-10 00:29:33 +01:00
|
|
|
#
|
|
|
|
|
1999-09-23 17:14:20 +02:00
|
|
|
package nativeapi;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
2001-07-14 02:48:41 +02:00
|
|
|
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
|
|
|
|
require Exporter;
|
|
|
|
|
|
|
|
@ISA = qw(Exporter);
|
|
|
|
@EXPORT = qw();
|
|
|
|
@EXPORT_OK = qw($nativeapi);
|
|
|
|
|
|
|
|
use vars qw($nativeapi);
|
|
|
|
|
2005-05-04 12:43:00 +02:00
|
|
|
use config qw(file_type $current_dir $wine_dir $winapi_dir);
|
2001-07-26 23:42:12 +02:00
|
|
|
use options qw($options);
|
|
|
|
use output qw($output);
|
|
|
|
|
|
|
|
$nativeapi = 'nativeapi'->new;
|
|
|
|
|
2004-10-07 20:53:56 +02:00
|
|
|
sub new($) {
|
1999-09-23 17:14:20 +02:00
|
|
|
my $proto = shift;
|
|
|
|
my $class = ref($proto) || $proto;
|
|
|
|
my $self = {};
|
|
|
|
bless ($self, $class);
|
|
|
|
|
|
|
|
my $functions = \%{$self->{FUNCTIONS}};
|
1999-10-24 23:45:39 +02:00
|
|
|
my $conditionals = \%{$self->{CONDITIONALS}};
|
|
|
|
my $conditional_headers = \%{$self->{CONDITIONAL_HEADERS}};
|
1999-10-31 03:08:38 +01:00
|
|
|
my $conditional_functions = \%{$self->{CONDITIONAL_FUNCTIONS}};
|
1999-09-23 17:14:20 +02:00
|
|
|
|
2005-05-04 12:43:00 +02:00
|
|
|
my $api_file = "$winapi_dir/nativeapi.dat";
|
2002-03-11 02:17:04 +01:00
|
|
|
my $configure_ac_file = "$wine_dir/configure.ac";
|
2001-07-26 23:42:12 +02:00
|
|
|
my $config_h_in_file = "$wine_dir/include/config.h.in";
|
1999-09-23 17:14:20 +02:00
|
|
|
|
1999-11-08 00:35:03 +01:00
|
|
|
$api_file =~ s/^\.\///;
|
2002-03-11 02:17:04 +01:00
|
|
|
$configure_ac_file =~ s/^\.\///;
|
1999-11-08 00:35:03 +01:00
|
|
|
$config_h_in_file =~ s/^\.\///;
|
|
|
|
|
2003-08-08 23:04:17 +02:00
|
|
|
|
|
|
|
$$conditional_headers{"config.h"}++;
|
|
|
|
|
2001-08-22 20:09:15 +02:00
|
|
|
$output->progress("$api_file");
|
1999-10-31 03:08:38 +01:00
|
|
|
|
1999-10-24 23:45:39 +02:00
|
|
|
open(IN, "< $api_file");
|
2000-04-15 22:39:55 +02:00
|
|
|
local $/ = "\n";
|
1999-09-23 17:14:20 +02:00
|
|
|
while(<IN>) {
|
2001-07-14 02:48:41 +02:00
|
|
|
s/^\s*(.*?)\s*$/$1/; # remove whitespace at begin and end of line
|
|
|
|
s/^(.*?)\s*#.*$/$1/; # remove comments
|
2002-06-01 04:55:48 +02:00
|
|
|
/^$/ && next; # skip empty lines
|
2001-07-14 02:48:41 +02:00
|
|
|
|
1999-10-24 23:45:39 +02:00
|
|
|
$$functions{$_}++;
|
|
|
|
}
|
|
|
|
close(IN);
|
|
|
|
|
2002-03-11 02:17:04 +01:00
|
|
|
$output->progress("$configure_ac_file");
|
1999-10-31 03:08:38 +01:00
|
|
|
|
1999-10-24 23:45:39 +02:00
|
|
|
my $again = 0;
|
2002-06-01 04:55:48 +02:00
|
|
|
open(IN, "< $configure_ac_file");
|
1999-10-24 23:45:39 +02:00
|
|
|
local $/ = "\n";
|
|
|
|
while($again || (defined($_ = <IN>))) {
|
|
|
|
$again = 0;
|
|
|
|
chomp;
|
2000-09-04 22:20:47 +02:00
|
|
|
if(/^(.*?)\\$/) {
|
|
|
|
my $current = $1;
|
|
|
|
my $next = <IN>;
|
|
|
|
if(defined($next)) {
|
|
|
|
# remove trailing whitespace
|
|
|
|
$current =~ s/\s+$//;
|
|
|
|
|
|
|
|
# remove leading whitespace
|
|
|
|
$next =~ s/^\s+//;
|
|
|
|
|
|
|
|
$_ = $current . " " . $next;
|
|
|
|
|
1999-10-24 23:45:39 +02:00
|
|
|
$again = 1;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
}
|
2000-09-04 22:20:47 +02:00
|
|
|
|
1999-10-24 23:45:39 +02:00
|
|
|
# remove leading and trailing whitespace
|
|
|
|
s/^\s*(.*?)\s*$/$1/;
|
|
|
|
|
2000-09-04 22:20:47 +02:00
|
|
|
# skip emty lines
|
|
|
|
if(/^$/) { next; }
|
|
|
|
|
|
|
|
# skip comments
|
|
|
|
if(/^dnl/) { next; }
|
|
|
|
|
2003-08-08 23:04:17 +02:00
|
|
|
if(/AC_CHECK_HEADERS\(\s*([^,\)]*)(?:,|\))?/) {
|
|
|
|
my $headers = $1;
|
|
|
|
$headers =~ s/^\s*\[\s*(.*?)\s*\]\s*$/$1/;
|
|
|
|
foreach my $name (split(/\s+/, $headers)) {
|
1999-10-31 03:08:38 +01:00
|
|
|
$$conditional_headers{$name}++;
|
|
|
|
}
|
2005-05-06 18:22:54 +02:00
|
|
|
} elsif(/AC_HEADER_STAT\(\)/) {
|
|
|
|
# This checks for a bunch of standard headers
|
|
|
|
# There's stdlib.h, string.h and sys/types.h too but we don't
|
|
|
|
# want to force ifdefs for those at this point.
|
|
|
|
foreach my $name ("sys/stat.h", "memory.h", "strings.h",
|
|
|
|
"inttypes.h", "stdint.h", "unistd.h") {
|
|
|
|
$$conditional_headers{$name}++;
|
|
|
|
}
|
2003-08-08 23:04:17 +02:00
|
|
|
} elsif(/AC_CHECK_FUNCS\(\s*([^,\)]*)(?:,|\))?/) {
|
|
|
|
my $funcs = $1;
|
|
|
|
$funcs =~ s/^\s*\[\s*(.*?)\s*\]\s*$/$1/;
|
|
|
|
foreach my $name (split(/\s+/, $funcs)) {
|
1999-10-31 03:08:38 +01:00
|
|
|
$$conditional_functions{$name}++;
|
1999-10-24 23:45:39 +02:00
|
|
|
}
|
2003-08-08 23:04:17 +02:00
|
|
|
} elsif(/AC_FUNC_ALLOCA/) {
|
1999-10-24 23:45:39 +02:00
|
|
|
$$conditional_headers{"alloca.h"}++;
|
2003-08-08 23:04:17 +02:00
|
|
|
} elsif (/AC_DEFINE\(\s*HAVE_(.*?)_H/) {
|
|
|
|
my $name = lc($1);
|
|
|
|
$name =~ s/_/\//;
|
|
|
|
$name .= ".h";
|
|
|
|
|
|
|
|
next if $name =~ m%correct/%;
|
|
|
|
|
|
|
|
$$conditional_headers{$name}++;
|
1999-10-24 23:45:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
close(IN);
|
|
|
|
|
2001-08-22 20:09:15 +02:00
|
|
|
$output->progress("$config_h_in_file");
|
1999-10-31 03:08:38 +01:00
|
|
|
|
1999-10-24 23:45:39 +02:00
|
|
|
open(IN, "< $config_h_in_file");
|
|
|
|
local $/ = "\n";
|
|
|
|
while(<IN>) {
|
2000-09-04 22:20:47 +02:00
|
|
|
# remove leading and trailing whitespace
|
|
|
|
s/^\s*(.*?)\s*$/$1/;
|
|
|
|
|
|
|
|
# skip emty lines
|
|
|
|
if(/^$/) { next; }
|
|
|
|
|
|
|
|
if(/^\#undef\s+(\S+)$/) {
|
1999-10-24 23:45:39 +02:00
|
|
|
$$conditionals{$1}++;
|
|
|
|
}
|
1999-09-23 17:14:20 +02:00
|
|
|
}
|
|
|
|
close(IN);
|
|
|
|
|
2001-07-14 02:48:41 +02:00
|
|
|
$nativeapi = $self;
|
|
|
|
|
1999-09-23 17:14:20 +02:00
|
|
|
return $self;
|
|
|
|
}
|
|
|
|
|
2004-10-07 20:53:56 +02:00
|
|
|
sub is_function($$) {
|
1999-09-23 17:14:20 +02:00
|
|
|
my $self = shift;
|
|
|
|
my $functions = \%{$self->{FUNCTIONS}};
|
|
|
|
|
|
|
|
my $name = shift;
|
|
|
|
|
2003-01-03 04:05:41 +01:00
|
|
|
return ($$functions{$name} || 0);
|
1999-09-23 17:14:20 +02:00
|
|
|
}
|
|
|
|
|
2004-10-07 20:53:56 +02:00
|
|
|
sub is_conditional($$) {
|
1999-10-24 23:45:39 +02:00
|
|
|
my $self = shift;
|
|
|
|
my $conditionals = \%{$self->{CONDITIONALS}};
|
|
|
|
|
|
|
|
my $name = shift;
|
|
|
|
|
2003-01-03 04:05:41 +01:00
|
|
|
return ($$conditionals{$name} || 0);
|
1999-10-24 23:45:39 +02:00
|
|
|
}
|
|
|
|
|
2004-10-07 20:53:56 +02:00
|
|
|
sub found_conditional($$) {
|
2000-09-04 22:20:47 +02:00
|
|
|
my $self = shift;
|
|
|
|
my $conditional_found = \%{$self->{CONDITIONAL_FOUND}};
|
|
|
|
|
|
|
|
my $name = shift;
|
|
|
|
|
|
|
|
$$conditional_found{$name}++;
|
|
|
|
}
|
|
|
|
|
2004-10-07 20:53:56 +02:00
|
|
|
sub is_conditional_header($$) {
|
1999-10-24 23:45:39 +02:00
|
|
|
my $self = shift;
|
|
|
|
my $conditional_headers = \%{$self->{CONDITIONAL_HEADERS}};
|
|
|
|
|
|
|
|
my $name = shift;
|
|
|
|
|
2003-01-03 04:05:41 +01:00
|
|
|
return ($$conditional_headers{$name} || 0);
|
1999-10-24 23:45:39 +02:00
|
|
|
}
|
|
|
|
|
2004-10-07 20:53:56 +02:00
|
|
|
sub is_conditional_function($$) {
|
1999-10-31 03:08:38 +01:00
|
|
|
my $self = shift;
|
|
|
|
my $conditional_functions = \%{$self->{CONDITIONAL_FUNCTIONS}};
|
|
|
|
|
|
|
|
my $name = shift;
|
|
|
|
|
2003-01-03 04:05:41 +01:00
|
|
|
return ($$conditional_functions{$name} || 0);
|
1999-10-31 03:08:38 +01:00
|
|
|
}
|
|
|
|
|
2004-10-07 20:53:56 +02:00
|
|
|
sub global_report($) {
|
2000-09-04 22:20:47 +02:00
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
my $output = \${$self->{OUTPUT}};
|
|
|
|
my $conditional_found = \%{$self->{CONDITIONAL_FOUND}};
|
|
|
|
my $conditionals = \%{$self->{CONDITIONALS}};
|
|
|
|
|
|
|
|
my @messages;
|
|
|
|
foreach my $name (sort(keys(%$conditionals))) {
|
2004-10-22 21:55:42 +02:00
|
|
|
if($name =~ /^(?:const|inline|size_t)$/) { next; }
|
2000-09-04 22:20:47 +02:00
|
|
|
|
|
|
|
if(0 && !$$conditional_found{$name}) {
|
|
|
|
push @messages, "config.h.in: conditional $name not used\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach my $message (sort(@messages)) {
|
2001-07-26 23:42:12 +02:00
|
|
|
$output->write($message);
|
2000-09-04 22:20:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-09-23 17:14:20 +02:00
|
|
|
1;
|