2020-07-22 00:10:10 +02:00
|
|
|
#!/usr/bin/perl
|
2001-06-13 21:38:29 +02:00
|
|
|
|
2002-10-15 04:15:35 +02:00
|
|
|
# Copyright 2002 Patrik Stridvall
|
2002-03-10 00:29:33 +01:00
|
|
|
#
|
|
|
|
# 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
|
|
|
#
|
2001-06-13 21:38:29 +02:00
|
|
|
|
|
|
|
use strict;
|
2020-07-22 00:10:10 +02:00
|
|
|
use warnings 'all';
|
2001-06-13 21:38:29 +02:00
|
|
|
|
|
|
|
BEGIN {
|
|
|
|
$0 =~ m%^(.*?/?tools)/winapi/winapi_extract$%;
|
|
|
|
require "$1/winapi/setup.pm";
|
|
|
|
}
|
|
|
|
|
|
|
|
use config qw(
|
2006-01-06 12:17:46 +01:00
|
|
|
files_skip files_filter get_spec_files
|
2005-05-04 12:43:00 +02:00
|
|
|
$current_dir $wine_dir $winapi_dir
|
2001-06-13 21:38:29 +02:00
|
|
|
);
|
2001-07-24 01:20:56 +02:00
|
|
|
use output qw($output);
|
2001-07-26 23:42:12 +02:00
|
|
|
use winapi_extract_options qw($options);
|
|
|
|
|
2001-08-22 20:09:15 +02:00
|
|
|
if($options->progress) {
|
|
|
|
$output->enable_progress;
|
|
|
|
} else {
|
|
|
|
$output->disable_progress;
|
|
|
|
}
|
|
|
|
|
2002-09-23 22:38:30 +02:00
|
|
|
use c_parser;
|
2001-07-26 23:42:12 +02:00
|
|
|
use function;
|
|
|
|
use type;
|
2002-09-23 22:38:30 +02:00
|
|
|
|
|
|
|
use winapi_function;
|
2001-06-13 21:38:29 +02:00
|
|
|
|
2002-10-01 20:10:54 +02:00
|
|
|
use vars qw($win16api $win32api @winapis);
|
2009-06-02 19:22:18 +02:00
|
|
|
if ($options->implemented || $options->stub_statistics || $options->winetest) {
|
2002-10-01 20:10:54 +02:00
|
|
|
require winapi;
|
|
|
|
import winapi qw($win16api $win32api @winapis);
|
|
|
|
}
|
|
|
|
|
2002-01-21 18:36:35 +01:00
|
|
|
my %module2entries;
|
2001-06-13 21:38:29 +02:00
|
|
|
my %module2spec_file;
|
2009-06-02 19:22:18 +02:00
|
|
|
if($options->winetest) {
|
2001-06-13 21:38:29 +02:00
|
|
|
local $_;
|
|
|
|
|
2001-07-18 22:09:12 +02:00
|
|
|
foreach my $spec_file (get_spec_files("winelib")) {
|
2002-01-21 18:36:35 +01:00
|
|
|
my $entries = [];
|
|
|
|
|
2002-07-20 22:06:13 +02:00
|
|
|
my $module = $spec_file;
|
|
|
|
$module =~ s/^.*?([^\/]*)\.spec$/$1/;
|
|
|
|
|
|
|
|
my $type = "win32";
|
2001-06-13 21:38:29 +02:00
|
|
|
|
2006-08-08 12:19:31 +02:00
|
|
|
open(IN, "< $wine_dir/$spec_file") || die "Error: Can't open $wine_dir/$spec_file: $!\n";
|
2002-01-21 18:36:35 +01:00
|
|
|
|
|
|
|
my $header = 1;
|
|
|
|
my $lookahead = 0;
|
|
|
|
while($lookahead || defined($_ = <IN>)) {
|
|
|
|
$lookahead = 0;
|
|
|
|
|
2005-12-02 16:15:09 +01:00
|
|
|
s/^\s*?(.*?)\s*$/$1/; # remove whitespace at beginning and end of line
|
2001-06-13 21:38:29 +02:00
|
|
|
s/^(.*?)\s*#.*$/$1/; # remove comments
|
|
|
|
/^$/ && next; # skip empty lines
|
|
|
|
|
2002-01-21 18:36:35 +01:00
|
|
|
if($header) {
|
2004-10-22 21:55:42 +02:00
|
|
|
if(/^(?:\d+|@)/) {
|
2002-01-21 18:36:35 +01:00
|
|
|
$header = 0;
|
2002-06-01 04:55:48 +02:00
|
|
|
$lookahead = 1;
|
2002-01-21 18:36:35 +01:00
|
|
|
}
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
2004-10-22 21:55:42 +02:00
|
|
|
if(/^(\d+|@)\s+stdcall\s+(\w+)\s*\(\s*([^\)]*)\s*\)/) {
|
2002-01-21 18:36:35 +01:00
|
|
|
my $ordinal = $1;
|
|
|
|
my $name = $2;
|
|
|
|
my @args = split(/\s+/, $3);
|
|
|
|
|
|
|
|
push @$entries, [$name, "undef", \@args];
|
2001-06-13 21:38:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
close(IN);
|
2002-01-21 18:36:35 +01:00
|
|
|
|
2002-07-20 22:06:13 +02:00
|
|
|
$module2spec_file{$module} = $spec_file;
|
2002-01-21 18:36:35 +01:00
|
|
|
$module2entries{$module} = $entries;
|
2001-06-13 21:38:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
my %specifications;
|
|
|
|
|
2004-10-26 02:12:21 +02:00
|
|
|
sub documentation_specifications($) {
|
2001-07-11 19:27:45 +02:00
|
|
|
my $function = shift;
|
|
|
|
|
|
|
|
my @debug_channels = @{$function->debug_channels};
|
|
|
|
my $documentation = $function->documentation;
|
|
|
|
my $documentation_line = $function->documentation_line;
|
|
|
|
my $return_type = $function->return_type;
|
|
|
|
my $linkage = $function->linkage;
|
|
|
|
my $internal_name = $function->internal_name;
|
|
|
|
|
|
|
|
if($linkage eq "static") {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
local $_;
|
|
|
|
foreach (split(/\n/, $documentation)) {
|
|
|
|
if(/^\s*\*\s*(\S+)\s*[\(\[]\s*(\w+)\s*\.\s*(\S+)\s*[\)\]]/) {
|
|
|
|
my $external_name = $1;
|
|
|
|
my $module = lc($2);
|
|
|
|
my $ordinal = $3;
|
|
|
|
|
|
|
|
if($ordinal eq "@") {
|
|
|
|
if(1 || !exists($specifications{$module}{unfixed}{$external_name})) {
|
|
|
|
$specifications{$module}{unfixed}{$external_name}{ordinal} = $ordinal;
|
|
|
|
$specifications{$module}{unfixed}{$external_name}{external_name} = $external_name;
|
|
|
|
$specifications{$module}{unfixed}{$external_name}{function} = $function;
|
|
|
|
} else {
|
|
|
|
$output->write("$external_name ($module.$ordinal) already exists\n");
|
|
|
|
}
|
|
|
|
} elsif($ordinal =~ /^\d+$/) {
|
|
|
|
if(1 || !exists($specifications{$module}{fixed}{$ordinal})) {
|
|
|
|
$specifications{$module}{fixed}{$ordinal}{ordinal} = $ordinal;
|
|
|
|
$specifications{$module}{fixed}{$ordinal}{external_name} = $external_name;
|
|
|
|
$specifications{$module}{fixed}{$ordinal}{function} = $function;
|
|
|
|
} else {
|
|
|
|
$output->write("$external_name ($module.$ordinal) already exists\n");
|
|
|
|
}
|
|
|
|
} elsif($ordinal eq "init") {
|
|
|
|
if(!exists($specifications{$module}{init})) {
|
|
|
|
$specifications{$module}{init}{function} = $function;
|
|
|
|
} else {
|
|
|
|
$output->write("$external_name ($module.$ordinal) already exists\n");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if(!exists($specifications{$module}{unknown}{$external_name})) {
|
|
|
|
$specifications{$module}{unknown}{$external_name}{ordinal} = $ordinal;
|
|
|
|
$specifications{$module}{unknown}{$external_name}{external_name} = $external_name;
|
|
|
|
$specifications{$module}{unknown}{$external_name}{function} = $function;
|
|
|
|
} else {
|
|
|
|
$output->write("$external_name ($module.$ordinal) already exists\n");
|
|
|
|
}
|
|
|
|
}
|
2002-06-01 04:55:48 +02:00
|
|
|
|
2001-07-11 19:27:45 +02:00
|
|
|
if($options->debug) {
|
|
|
|
$output->write("$external_name ($module.$ordinal)\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-07-22 22:37:30 +02:00
|
|
|
my %module_pseudo_stub;
|
2001-07-11 19:27:45 +02:00
|
|
|
|
2004-10-26 02:12:21 +02:00
|
|
|
sub statements_pseudo_stub($) {
|
2001-07-11 19:27:45 +02:00
|
|
|
my $function = shift;
|
|
|
|
|
2002-10-15 04:15:35 +02:00
|
|
|
my $pseudo_stub = 0;
|
2001-07-11 19:27:45 +02:00
|
|
|
my $statements = $function->statements;
|
|
|
|
if(defined($statements) && $statements =~ /FIXME[^;]*stub/s) {
|
|
|
|
if($options->win16) {
|
2002-07-22 22:37:30 +02:00
|
|
|
my $external_name16 = $function->external_name16;
|
2001-07-11 19:27:45 +02:00
|
|
|
foreach my $module16 ($function->modules16) {
|
2002-07-22 22:37:30 +02:00
|
|
|
$module_pseudo_stub{$module16}{$external_name16}++;
|
2002-10-15 04:15:35 +02:00
|
|
|
$pseudo_stub = 1;
|
2001-07-11 19:27:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if($options->win32) {
|
2002-07-22 22:37:30 +02:00
|
|
|
my $external_name32 = $function->external_name32;
|
2001-07-11 19:27:45 +02:00
|
|
|
foreach my $module32 ($function->modules32) {
|
2002-07-22 22:37:30 +02:00
|
|
|
$module_pseudo_stub{$module32}{$external_name32}++;
|
2002-10-15 04:15:35 +02:00
|
|
|
$pseudo_stub = 1;
|
2001-07-11 19:27:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-10-15 04:15:35 +02:00
|
|
|
|
|
|
|
return $pseudo_stub;
|
2001-07-11 19:27:45 +02:00
|
|
|
}
|
|
|
|
|
2002-09-23 22:38:30 +02:00
|
|
|
my @h_files = ();
|
|
|
|
if($options->headers) {
|
|
|
|
@h_files = $options->h_files;
|
|
|
|
@h_files = files_skip(@h_files);
|
|
|
|
@h_files = files_filter("winelib", @h_files);
|
|
|
|
}
|
|
|
|
|
2002-07-22 22:37:30 +02:00
|
|
|
my @c_files = ();
|
2009-06-02 19:22:18 +02:00
|
|
|
if($options->pseudo_implemented || $options->pseudo_stub_statistics) {
|
2002-07-22 22:37:30 +02:00
|
|
|
@c_files = $options->c_files;
|
|
|
|
@c_files = files_skip(@c_files);
|
|
|
|
@c_files = files_filter("winelib", @c_files);
|
|
|
|
}
|
2001-06-13 21:38:29 +02:00
|
|
|
|
|
|
|
my $progress_output;
|
|
|
|
my $progress_current = 0;
|
2002-09-23 22:38:30 +02:00
|
|
|
my $progress_max = scalar(@h_files) + scalar(@c_files);
|
2001-06-13 21:38:29 +02:00
|
|
|
|
2002-09-23 22:38:30 +02:00
|
|
|
foreach my $file (@h_files, @c_files) {
|
2001-07-11 19:27:45 +02:00
|
|
|
my %functions;
|
2001-06-13 21:38:29 +02:00
|
|
|
|
|
|
|
$progress_current++;
|
|
|
|
|
2002-09-23 22:38:30 +02:00
|
|
|
{
|
2006-08-08 12:19:31 +02:00
|
|
|
open(IN, "< $file") || die "Error: Can't open $file: $!\n";
|
2002-09-23 22:38:30 +02:00
|
|
|
local $/ = undef;
|
|
|
|
$_ = <IN>;
|
|
|
|
close(IN);
|
|
|
|
}
|
|
|
|
|
|
|
|
my $max_line = 0;
|
|
|
|
{
|
|
|
|
local $_ = $_;
|
|
|
|
while(s/^.*?\n//) { $max_line++; }
|
|
|
|
if($_) { $max_line++; }
|
|
|
|
}
|
|
|
|
|
2009-06-02 19:22:41 +02:00
|
|
|
my $parser = new c_parser($file);
|
2002-09-23 22:38:30 +02:00
|
|
|
|
|
|
|
my $function;
|
|
|
|
my $line;
|
|
|
|
|
|
|
|
my $update_output = sub {
|
|
|
|
my $progress = "";
|
|
|
|
my $prefix = "";
|
|
|
|
|
|
|
|
$progress .= "$file (file $progress_current of $progress_max)";
|
|
|
|
$prefix .= "$file:";
|
|
|
|
|
|
|
|
if(defined($function)) {
|
|
|
|
my $name = $function->name;
|
|
|
|
my $begin_line = $function->begin_line;
|
|
|
|
my $begin_column = $function->begin_column;
|
|
|
|
|
|
|
|
$progress .= ": function $name";
|
|
|
|
$prefix .= "$begin_line.$begin_column: function $name: ";
|
2001-07-26 23:42:12 +02:00
|
|
|
} else {
|
2002-09-23 22:38:30 +02:00
|
|
|
$prefix .= " ";
|
2001-07-26 23:42:12 +02:00
|
|
|
}
|
2002-09-23 22:38:30 +02:00
|
|
|
|
|
|
|
if(defined($line)) {
|
|
|
|
$progress .= ": line $line of $max_line";
|
|
|
|
}
|
|
|
|
|
|
|
|
$output->progress($progress);
|
|
|
|
$output->prefix($prefix);
|
2001-07-26 23:42:12 +02:00
|
|
|
};
|
|
|
|
|
2002-09-23 22:38:30 +02:00
|
|
|
&$update_output();
|
|
|
|
|
2001-06-13 21:38:29 +02:00
|
|
|
my $found_function = sub {
|
2002-09-23 22:38:30 +02:00
|
|
|
$function = shift;
|
|
|
|
|
|
|
|
my $name = $function->name;
|
|
|
|
$functions{$name} = $function;
|
|
|
|
|
2002-10-01 20:10:54 +02:00
|
|
|
if ($function->statements) {
|
|
|
|
&$update_output();
|
|
|
|
}
|
2002-09-23 22:38:30 +02:00
|
|
|
|
|
|
|
my $old_function;
|
2002-10-15 04:15:35 +02:00
|
|
|
if($options->implemented || $options->stub_statistics) {
|
2002-09-23 22:38:30 +02:00
|
|
|
$old_function = 'winapi_function'->new;
|
|
|
|
} else {
|
|
|
|
$old_function = 'function'->new;
|
|
|
|
}
|
2001-07-11 19:27:45 +02:00
|
|
|
|
2002-10-15 04:15:35 +02:00
|
|
|
$old_function->file($function->file);
|
2002-09-23 22:38:30 +02:00
|
|
|
$old_function->debug_channels([]); # FIXME: Not complete
|
2002-06-01 04:55:48 +02:00
|
|
|
|
2002-09-23 22:38:30 +02:00
|
|
|
$old_function->documentation_line(0); # FIXME: Not complete
|
|
|
|
$old_function->documentation(""); # FIXME: Not complete
|
2001-08-22 20:09:15 +02:00
|
|
|
|
2002-09-23 22:38:30 +02:00
|
|
|
$old_function->function_line($function->begin_line());
|
|
|
|
$old_function->linkage($function->linkage);
|
|
|
|
$old_function->return_type($function->return_type);
|
|
|
|
$old_function->calling_convention($function->calling_convention);
|
|
|
|
$old_function->internal_name($function->name);
|
|
|
|
if (defined($function->argument_types)) {
|
|
|
|
$old_function->argument_types([@{$function->argument_types}]);
|
|
|
|
}
|
|
|
|
if (defined($function->argument_names)) {
|
|
|
|
$old_function->argument_names([@{$function->argument_names}]);
|
|
|
|
}
|
|
|
|
$old_function->argument_documentations([]); # FIXME: Not complete
|
|
|
|
$old_function->statements_line($function->statements_line);
|
|
|
|
$old_function->statements($function->statements);
|
2001-07-11 19:27:45 +02:00
|
|
|
|
2009-06-02 19:22:18 +02:00
|
|
|
if($options->winetest) {
|
2002-09-23 22:38:30 +02:00
|
|
|
documentation_specifications($old_function);
|
2001-06-13 21:38:29 +02:00
|
|
|
}
|
|
|
|
|
2002-10-01 20:10:54 +02:00
|
|
|
if ($function->statements) {
|
|
|
|
$function = undef;
|
|
|
|
&$update_output();
|
|
|
|
} else {
|
|
|
|
$function = undef;
|
|
|
|
}
|
2002-10-15 04:15:35 +02:00
|
|
|
|
|
|
|
my $pseudo_stub = 0;
|
|
|
|
if ($options->pseudo_implemented || $options->pseudo_stub_statistics) {
|
|
|
|
$pseudo_stub = statements_pseudo_stub($old_function);
|
|
|
|
}
|
|
|
|
|
|
|
|
my $module = $old_function->module;
|
|
|
|
my $external_name = $old_function->external_name;
|
|
|
|
my $statements = $old_function->statements;
|
|
|
|
if ($options->pseudo_implemented && $module && $external_name && $statements) {
|
|
|
|
my @external_names = split(/\s*&\s*/, $external_name);
|
|
|
|
my @modules = split(/\s*&\s*/, $module);
|
|
|
|
|
|
|
|
my @external_names2;
|
|
|
|
while(defined(my $external_name = shift @external_names) &&
|
|
|
|
defined(my $module = shift @modules))
|
|
|
|
{
|
|
|
|
if ($pseudo_stub) {
|
|
|
|
$output->write("$module.$external_name: pseudo implemented\n");
|
|
|
|
} else {
|
|
|
|
$output->write("$module.$external_name: implemented\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-07-26 23:42:12 +02:00
|
|
|
};
|
2002-09-23 22:38:30 +02:00
|
|
|
$parser->set_found_function_callback($found_function);
|
2001-07-26 23:42:12 +02:00
|
|
|
|
2002-10-01 20:10:54 +02:00
|
|
|
my $found_line = sub {
|
|
|
|
$line = shift;
|
|
|
|
|
|
|
|
&$update_output;
|
|
|
|
};
|
|
|
|
$parser->set_found_line_callback($found_line);
|
|
|
|
|
2001-07-26 23:42:12 +02:00
|
|
|
my $found_type = sub {
|
|
|
|
my $type = shift;
|
|
|
|
|
2002-09-23 22:38:30 +02:00
|
|
|
&$update_output();
|
|
|
|
|
|
|
|
my $kind = $type->kind;
|
|
|
|
my $_name = $type->_name;
|
|
|
|
my $name = $type->name;
|
|
|
|
|
|
|
|
foreach my $field ($type->fields) {
|
2002-10-09 20:12:02 +02:00
|
|
|
my $field_type_name = $field->type_name;
|
|
|
|
my $field_name = $field->name;
|
2002-09-23 22:38:30 +02:00
|
|
|
|
2002-10-11 19:53:13 +02:00
|
|
|
if ($options->struct && $kind =~ /^(?:struct|union)$/) {
|
2002-09-23 22:38:30 +02:00
|
|
|
if ($name) {
|
2002-10-09 20:12:02 +02:00
|
|
|
$output->write("$name:$field_type_name:$field_name\n");
|
2002-09-23 22:38:30 +02:00
|
|
|
} else {
|
2002-10-09 20:12:02 +02:00
|
|
|
$output->write("$kind $_name:$field_type_name:$field_name\n");
|
2002-09-23 22:38:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
2001-06-13 21:38:29 +02:00
|
|
|
};
|
2002-09-23 22:38:30 +02:00
|
|
|
$parser->set_found_type_callback($found_type);
|
2001-06-13 21:38:29 +02:00
|
|
|
|
2002-09-23 22:38:30 +02:00
|
|
|
{
|
|
|
|
my $line = 1;
|
|
|
|
my $column = 0;
|
|
|
|
if(!$parser->parse_c_file(\$_, \$line, \$column)) {
|
|
|
|
$output->write("can't parse file\n");
|
|
|
|
}
|
2001-06-13 21:38:29 +02:00
|
|
|
}
|
2002-09-23 22:38:30 +02:00
|
|
|
|
|
|
|
$output->prefix("");
|
2001-06-13 21:38:29 +02:00
|
|
|
}
|
|
|
|
|
2002-10-15 04:15:35 +02:00
|
|
|
|
|
|
|
if($options->implemented && !$options->pseudo_implemented) {
|
|
|
|
foreach my $winapi (@winapis) {
|
|
|
|
my $type = $winapi->name;
|
|
|
|
|
|
|
|
if($type eq "win16" && !$options->win16) { next; }
|
|
|
|
if($type eq "win32" && !$options->win32) { next; }
|
|
|
|
|
|
|
|
foreach my $module ($winapi->all_modules) {
|
|
|
|
foreach my $external_name ($winapi->all_functions_in_module($module)) {
|
|
|
|
my $external_calling_convention =
|
|
|
|
$winapi->function_external_calling_convention_in_module($module, $external_name);
|
|
|
|
|
|
|
|
if($external_calling_convention eq "forward") {
|
|
|
|
(my $forward_module, my $forward_external_name) =
|
|
|
|
$winapi->function_forward_final_destination($module, $external_name);
|
|
|
|
|
|
|
|
my $forward_external_calling_convention =
|
|
|
|
$winapi->function_external_calling_convention_in_module($forward_module, $forward_external_name);
|
|
|
|
|
|
|
|
if(!defined($forward_external_calling_convention)) {
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
|
|
|
$external_calling_convention = $forward_external_calling_convention;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($external_calling_convention ne "stub") {
|
|
|
|
$output->write("*.spec: $module.$external_name: implemented\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-10-26 02:12:21 +02:00
|
|
|
sub output_function($$$$$) {
|
2001-06-13 21:38:29 +02:00
|
|
|
local *OUT = shift;
|
|
|
|
my $type = shift;
|
2001-07-11 19:27:45 +02:00
|
|
|
my $ordinal = shift;
|
|
|
|
my $external_name = shift;
|
2001-06-13 21:38:29 +02:00
|
|
|
my $function = shift;
|
|
|
|
|
2001-07-11 19:27:45 +02:00
|
|
|
my $internal_name = $function->internal_name;
|
2001-07-08 22:33:20 +02:00
|
|
|
|
|
|
|
my $return_kind;
|
|
|
|
my $calling_convention;
|
2001-07-24 01:20:56 +02:00
|
|
|
my $refargument_kinds;
|
2001-06-13 21:38:29 +02:00
|
|
|
if($type eq "win16") {
|
2001-07-11 19:27:45 +02:00
|
|
|
$return_kind = $function->return_kind16 || "undef";
|
|
|
|
$calling_convention = $function->calling_convention16 || "undef";
|
2001-07-24 01:20:56 +02:00
|
|
|
$refargument_kinds = $function->argument_kinds16;
|
2001-07-11 19:27:45 +02:00
|
|
|
} elsif($type eq "win32") {
|
|
|
|
$return_kind = $function->return_kind32 || "undef";
|
|
|
|
$calling_convention = $function->calling_convention32 || "undef";
|
2001-07-24 01:20:56 +02:00
|
|
|
$refargument_kinds = $function->argument_kinds32;
|
2001-06-13 21:38:29 +02:00
|
|
|
}
|
2001-07-08 22:33:20 +02:00
|
|
|
|
2001-07-24 01:20:56 +02:00
|
|
|
if(defined($refargument_kinds)) {
|
|
|
|
my @argument_kinds = map { $_ || "undef"; } @$refargument_kinds;
|
|
|
|
print OUT "$ordinal $calling_convention $external_name(@argument_kinds) $internal_name\n";
|
|
|
|
} else {
|
|
|
|
print OUT "$ordinal $calling_convention $external_name() $internal_name # FIXME: arguments undefined\n";
|
|
|
|
}
|
2001-06-13 21:38:29 +02:00
|
|
|
}
|
|
|
|
|
2001-07-11 19:27:45 +02:00
|
|
|
if($options->stub_statistics) {
|
|
|
|
foreach my $winapi (@winapis) {
|
2002-07-20 22:06:13 +02:00
|
|
|
my $type = $winapi->name;
|
|
|
|
|
|
|
|
if($type eq "win16" && !$options->win16) { next; }
|
|
|
|
if($type eq "win32" && !$options->win32) { next; }
|
2001-07-11 19:27:45 +02:00
|
|
|
|
2002-07-22 22:37:30 +02:00
|
|
|
my %module_counts;
|
|
|
|
foreach my $module ($winapi->all_modules) {
|
|
|
|
foreach my $external_name ($winapi->all_functions_in_module($module)) {
|
|
|
|
my $external_calling_convention =
|
|
|
|
$winapi->function_external_calling_convention_in_module($module, $external_name);
|
2004-10-22 21:55:42 +02:00
|
|
|
if($external_calling_convention !~ /^(?:forward|stub)$/) {
|
2002-07-22 22:37:30 +02:00
|
|
|
if($module_pseudo_stub{$module}{$external_name}) {
|
|
|
|
$external_calling_convention = "pseudo_stub";
|
|
|
|
}
|
|
|
|
} elsif($external_calling_convention eq "forward") {
|
|
|
|
(my $forward_module, my $forward_external_name) =
|
|
|
|
$winapi->function_forward_final_destination($module, $external_name);
|
|
|
|
|
|
|
|
my $forward_external_calling_convention =
|
|
|
|
$winapi->function_external_calling_convention_in_module($forward_module, $forward_external_name);
|
|
|
|
|
|
|
|
if(!defined($forward_external_calling_convention)) {
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
|
|
|
if($forward_external_calling_convention ne "stub" &&
|
|
|
|
$module_pseudo_stub{$forward_module}{$forward_external_name})
|
|
|
|
{
|
|
|
|
$forward_external_calling_convention = "pseudo_stub";
|
|
|
|
}
|
|
|
|
|
|
|
|
$external_calling_convention = "forward_$forward_external_calling_convention";
|
|
|
|
}
|
|
|
|
|
|
|
|
$module_counts{$module}{$external_calling_convention}++;
|
|
|
|
}
|
|
|
|
}
|
2001-07-11 19:27:45 +02:00
|
|
|
|
|
|
|
foreach my $module ($winapi->all_modules) {
|
2002-07-22 22:37:30 +02:00
|
|
|
my $pseudo_stubs = $module_counts{$module}{pseudo_stub} || 0;
|
|
|
|
my $real_stubs = $module_counts{$module}{stub} || 0;
|
|
|
|
my $forward_pseudo_stubs = $module_counts{$module}{forward_pseudo_stub} || 0;
|
|
|
|
my $forward_real_stubs = $module_counts{$module}{forward_stub} || 0;
|
|
|
|
|
|
|
|
my $forwards = 0;
|
|
|
|
my $total = 0;
|
|
|
|
foreach my $calling_convention (keys(%{$module_counts{$module}})) {
|
|
|
|
my $count = $module_counts{$module}{$calling_convention};
|
|
|
|
if($calling_convention =~ /^forward/) {
|
|
|
|
$forwards += $count;
|
|
|
|
}
|
|
|
|
$total += $count;
|
2001-07-11 19:27:45 +02:00
|
|
|
}
|
|
|
|
|
2002-07-22 22:37:30 +02:00
|
|
|
if($total > 0) {
|
|
|
|
my $stubs = $real_stubs + $pseudo_stubs;
|
2001-07-11 19:27:45 +02:00
|
|
|
|
2002-07-22 22:37:30 +02:00
|
|
|
$output->write("*.c: $module: ");
|
|
|
|
$output->write("$stubs of $total functions are stubs ($real_stubs real, $pseudo_stubs pseudo) " .
|
|
|
|
"and $forwards are forwards\n");
|
|
|
|
}
|
2001-07-11 19:27:45 +02:00
|
|
|
|
2002-07-22 22:37:30 +02:00
|
|
|
if($forwards > 0) {
|
|
|
|
my $forward_stubs = $forward_real_stubs + $forward_pseudo_stubs;
|
2002-06-01 04:55:48 +02:00
|
|
|
|
2002-07-22 22:37:30 +02:00
|
|
|
$output->write("*.c: $module: ");
|
|
|
|
$output->write("$forward_stubs of $forwards forwarded functions are stubs " .
|
|
|
|
"($forward_real_stubs real, $forward_pseudo_stubs pseudo)\n");
|
|
|
|
}
|
2001-07-11 19:27:45 +02:00
|
|
|
}
|
2002-06-01 04:55:48 +02:00
|
|
|
}
|
2001-07-11 19:27:45 +02:00
|
|
|
}
|
|
|
|
|
2002-01-21 18:36:35 +01:00
|
|
|
if($options->winetest) {
|
2002-07-20 22:06:13 +02:00
|
|
|
foreach my $module ($win32api->all_modules) {
|
|
|
|
my $type = "win32";
|
2002-01-21 18:36:35 +01:00
|
|
|
|
2002-07-20 22:06:13 +02:00
|
|
|
my $package = $module;
|
|
|
|
$package =~ s/\.dll$//;
|
|
|
|
$package =~ s/\./_/g;
|
2002-01-21 18:36:35 +01:00
|
|
|
|
|
|
|
my @entries;
|
|
|
|
|
|
|
|
foreach my $external_name (sort(keys(%{$specifications{$module}{unknown}}))) {
|
|
|
|
my $entry = $specifications{$module}{unknown}{$external_name};
|
|
|
|
push @entries, $entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach my $ordinal (sort {$a <=> $b} keys(%{$specifications{$module}{fixed}})) {
|
|
|
|
my $entry = $specifications{$module}{fixed}{$ordinal};
|
|
|
|
push @entries, $entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach my $external_name (sort(keys(%{$specifications{$module}{unfixed}}))) {
|
|
|
|
my $entry = $specifications{$module}{unfixed}{$external_name};
|
|
|
|
push @entries, $entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
my $n = 0;
|
|
|
|
foreach my $entry (@entries) {
|
2002-06-01 04:55:48 +02:00
|
|
|
my $external_name = $entry->{external_name};
|
|
|
|
my $ordinal = $entry->{ordinal};
|
|
|
|
my $function = $entry->{function};
|
2002-01-21 18:36:35 +01:00
|
|
|
|
2002-07-20 22:06:13 +02:00
|
|
|
my $return_kind = $function->return_kind32 || "undef";
|
|
|
|
my $calling_convention = $function->calling_convention32 || "undef";
|
|
|
|
my $refargument_kinds = $function->argument_kinds32;
|
2002-01-21 18:36:35 +01:00
|
|
|
|
|
|
|
my @argument_kinds;
|
|
|
|
if(defined($refargument_kinds)) {
|
|
|
|
@argument_kinds = map { $_ || "undef"; } @$refargument_kinds;
|
|
|
|
}
|
|
|
|
|
|
|
|
next if $calling_convention ne "stdcall";
|
|
|
|
next if $external_name eq "\@";
|
|
|
|
|
|
|
|
if($n == 0) {
|
2006-08-08 12:19:31 +02:00
|
|
|
open(OUT, "> $wine_dir/programs/winetest/include/${package}.pm") || die "Error: Can't open $wine_dir/programs/winetest/include/${package}.pm: $!\n";
|
2002-01-21 18:36:35 +01:00
|
|
|
|
2002-07-20 22:06:13 +02:00
|
|
|
print OUT "package ${package};\n";
|
2002-01-21 18:36:35 +01:00
|
|
|
print OUT "\n";
|
|
|
|
|
|
|
|
print OUT "use strict;\n";
|
|
|
|
print OUT "\n";
|
|
|
|
|
|
|
|
print OUT "require Exporter;\n";
|
|
|
|
print OUT "\n";
|
|
|
|
|
|
|
|
print OUT "use wine;\n";
|
|
|
|
print OUT "use vars qw(\@ISA \@EXPORT \@EXPORT_OK);\n";
|
|
|
|
print OUT "\n";
|
|
|
|
|
|
|
|
print OUT "\@ISA = qw(Exporter);\n";
|
|
|
|
print OUT "\@EXPORT = qw();\n";
|
|
|
|
print OUT "\@EXPORT_OK = qw();\n";
|
|
|
|
print OUT "\n";
|
|
|
|
|
|
|
|
print OUT "my \$module_declarations = {\n";
|
|
|
|
} elsif($n > 0) {
|
|
|
|
print OUT ",\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
print OUT " \"\Q$external_name\E\" => [\"$return_kind\", [";
|
|
|
|
my $m = 0;
|
|
|
|
foreach my $argument_kind (@argument_kinds) {
|
|
|
|
if($m > 0) {
|
|
|
|
print OUT ", ";
|
|
|
|
}
|
|
|
|
print OUT "\"$argument_kind\"";
|
|
|
|
$m++;
|
|
|
|
}
|
|
|
|
print OUT "]]";
|
|
|
|
$n++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if($n > 0) {
|
|
|
|
print OUT "\n";
|
|
|
|
print OUT "};\n";
|
|
|
|
print OUT "\n";
|
2002-07-20 22:06:13 +02:00
|
|
|
print OUT "&wine::declare(\"$module\",\%\$module_declarations);\n";
|
2002-01-21 18:36:35 +01:00
|
|
|
print OUT "push \@EXPORT, map { \"&\" . \$_; } sort(keys(\%\$module_declarations));\n";
|
|
|
|
print OUT "1;\n";
|
|
|
|
close(OUT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|