winapi_global.pm 2.45 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#
# 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
16
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 18
#

19 20 21
package winapi_global;

use strict;
22

Patrik Stridvall's avatar
Patrik Stridvall committed
23
use modules qw($modules);
24 25 26
use nativeapi qw($nativeapi);
use options qw($options);
use output qw($output);
Patrik Stridvall's avatar
Patrik Stridvall committed
27
use winapi qw(@winapis);
28

29
sub check_modules($$) {
Patrik Stridvall's avatar
Patrik Stridvall committed
30 31
    my $complete_module = shift;
    my $module2functions = shift;
32

Patrik Stridvall's avatar
Patrik Stridvall committed
33
    my @complete_modules = sort(keys(%$complete_module));
34

Patrik Stridvall's avatar
Patrik Stridvall committed
35 36 37 38 39 40
    if($options->declared) {
	foreach my $module (@complete_modules) {
	    foreach my $winapi (@winapis) {
		if(!$winapi->is_module($module)) { next; }
		my $functions = $$module2functions{$module};
		foreach my $internal_name ($winapi->all_internal_functions_in_module($module)) {
Patrik Stridvall's avatar
Patrik Stridvall committed
41
		    next if $internal_name =~ /\./;
Patrik Stridvall's avatar
Patrik Stridvall committed
42
		    my $function = $functions->{$internal_name};
43
		    if(!defined($function) && !$nativeapi->is_function($internal_name))
Patrik Stridvall's avatar
Patrik Stridvall committed
44 45 46 47 48 49 50
		    {
			$output->write("*.c: $module: $internal_name: " .
				       "function declared but not implemented or declared external\n");
		    }
		}
	    }
	}
51
    }
52

Patrik Stridvall's avatar
Patrik Stridvall committed
53 54 55 56 57 58 59 60
    if($options->argument && $options->argument_forbidden) {
	foreach my $winapi (@winapis) {
	    my $types_not_used = $winapi->types_not_used;
	    foreach my $module (sort(keys(%$types_not_used))) {
		if(!$$complete_module{$module}) { next; }
		foreach my $type (sort(keys(%{$$types_not_used{$module}}))) {
		    $output->write("*.c: $module: type ($type) not used\n");
		}
61 62 63
	    }
	}
    }
Patrik Stridvall's avatar
Patrik Stridvall committed
64
}
65

66
sub check_all_modules($) {
Patrik Stridvall's avatar
Patrik Stridvall committed
67
    my $include2info = shift;
Patrik Stridvall's avatar
Patrik Stridvall committed
68

69 70
    winapi_documentation::report_documentation();

Patrik Stridvall's avatar
Patrik Stridvall committed
71 72 73 74
    if($options->headers_unused && $options->include) {
	foreach my $name (sort(keys(%$include2info))) {
	    if(!$$include2info{$name}{used}) {
		$output->write("*.c: $name: include file is never used\n");
Patrik Stridvall's avatar
Patrik Stridvall committed
75 76
	    }
	}
77
    }
Patrik Stridvall's avatar
Patrik Stridvall committed
78 79 80
    
    $modules->global_report;
    $nativeapi->global_report;
81 82 83
}

1;