winapi_check_options.pm 7.42 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_check_options;

use strict;
22 23 24
use warnings 'all';

use base qw(options);
25 26 27 28 29 30 31 32 33

use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
require Exporter;

@ISA = qw(Exporter);
@EXPORT = qw();
@EXPORT_OK = qw($options);

use config qw($current_dir $wine_dir);
34
use options qw($options parse_comma_list);
35 36 37 38 39 40 41 42 43 44 45 46 47 48

my %options_long = (
    "debug" => { default => 0, description => "debug mode" },
    "help" => { default => 0, description => "help mode" },
    "verbose" => { default => 0, description => "verbose mode" },

    "progress" => { default => 1, description => "show progress" },

    "win16" => { default => 1, description => "Win16 checking" },
    "win32" => { default => 1, description => "Win32 checking" },

    "shared" =>  { default => 0, description => "show shared functions between Win16 and Win32" },
    "shared-segmented" =>  { default => 0, description => "segmented shared functions between Win16 and Win32 checking" },

Francois Gouget's avatar
Francois Gouget committed
49 50
    "config" => { default => 1, parent => "local", description => "check configuration include consistency" },
    "config-unnecessary" => { default => 0, parent => "config", description => "check for unnecessary #include \"config.h\"" },
51 52 53 54

    "spec-mismatch" => { default => 0, description => "spec file mismatch checking" },

    "local" =>  { default => 1, description => "local checking" },
55
    "module" => {
56 57
	default => { active => 1, filter => 0, hash => {} },
	parent => "local",
58
	parser => \&parse_comma_list,
59 60 61 62 63 64 65 66
	description => "module filter"
    },

    "argument" => { default => 1, parent => "local", description => "argument checking" },
    "argument-count" => { default => 1, parent => "argument", description => "argument count checking" },
    "argument-forbidden" => {
	default => { active => 1, filter => 0, hash => {} },
	parent => "argument",
67
	parser => \&parse_comma_list,
68 69 70 71 72
	description => "argument forbidden checking"
    },
    "argument-kind" => {
	default => { active => 1, filter => 1, hash => { double => 1 } },
	parent => "argument",
73
	parser => \&parse_comma_list,
74 75 76 77 78 79
	description => "argument kind checking"
    },
    "calling-convention" => { default => 1, parent => "local", description => "calling convention checking" },
    "calling-convention-win16" => { default => 0, parent => "calling-convention", description => "calling convention checking (Win16)" },
    "calling-convention-win32" => { default => 1, parent => "calling-convention", description => "calling convention checking (Win32)" },
    "misplaced" => { default => 1, parent => "local", description => "check for misplaced functions" },
80
    "statements"  => { default => 0, parent => "local", description => "check for statements inconsistencies" },
Patrik Stridvall's avatar
Patrik Stridvall committed
81
    "cross-call" => { default => 0, parent => ["statements", "win16", "win32"],  description => "check for cross calling functions" },
82
    "cross-call-win32-win16" => {
83 84
	default => 0, parent => "cross-call", description => "check for cross calls between win32 and win16"
     },
85 86
    "cross-call-unicode-ascii" => {
	default => 0, parent => "cross-call", description => "check for cross calls between Unicode and ASCII"
87
    },
88
    "debug-messages" => { default => 0, parent => "statements", description => "check for debug messages inconsistencies" },
89

Patrik Stridvall's avatar
Patrik Stridvall committed
90 91 92 93 94 95 96 97 98 99 100
    "comments" => {
	default => 1,
	parent => "local",
	description => "comments checking"
	},
    "comments-cplusplus" => {
	default => 1,
	parent => "comments",
	description => "C++ comments checking"
	},

101 102
    "documentation" => {
	default => 1,
103
	parent => "local",
104
	description => "check for documentation inconsistencies"
105
	},
106 107 108
    "documentation-pedantic" => {
	default => 0,
	parent => "documentation",
109
	description => "be pedantic when checking for documentation inconsistencies"
110 111 112 113 114
	},

    "documentation-arguments" => {
	default => 1,
	parent => "documentation",
115
	description => "check for arguments documentation inconsistencies\n"
116 117
	},
    "documentation-comment-indent" => {
118
	default => 0,
119
	parent => "documentation", description => "check for documentation comment indent inconsistencies"
120 121
	},
    "documentation-comment-width" => {
122
	default => 0,
123
	parent => "documentation", description => "check for documentation comment width inconsistencies"
124 125 126 127
	},
    "documentation-name" => {
	default => 1,
	parent => "documentation",
128
	description => "check for documentation name inconsistencies\n"
129 130 131 132
	},
    "documentation-ordinal" => {
	default => 1,
	parent => "documentation",
133
	description => "check for documentation ordinal inconsistencies\n"
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
	},
    "documentation-wrong" => {
	default => 1,
	parent => "documentation",
	description => "check for wrong documentation\n"
	},

    "prototype" => {default => 0, parent => ["local", "headers"], description => "prototype checking" },
    "global" => { default => 1, description => "global checking" },
    "declared" => { default => 1, parent => "global", description => "declared checking" },
    "implemented" => { default => 0, parent => "local", description => "implemented checking" },
    "implemented-win32" => { default => 0, parent => "implemented", description => "implemented as win32 checking" },
    "include" => { default => 1, parent => "global", description => "include checking" },

    "headers" => { default => 0, description => "headers checking" },
    "headers-duplicated" => { default => 0, parent => "headers", description => "duplicated function declarations checking" },
    "headers-misplaced" => { default => 0, parent => "headers", description => "misplaced function declarations checking" },
    "headers-needed" => { default => 1, parent => "headers", description => "headers needed checking" },
    "headers-unused" => { default => 0, parent => "headers", description => "headers unused checking" },
);

my %options_short = (
    "d" => "debug",
    "?" => "help",
    "v" => "verbose"
);

161
my $options_usage = "usage: winapi_check [--help] [<files>]\n";
162 163 164 165 166 167

$options = '_winapi_check_options'->new(\%options_long, \%options_short, $options_usage);

package _winapi_check_options;

use strict;
168 169 170
use warnings 'all';

use base qw(_options);
171

172
sub report_module($$) {
173 174
    my $self = shift;
    my $refvalue = $self->{MODULE};
175

176 177 178
    my $name = shift;

    if(defined($name)) {
179
	return $$refvalue->{active} && (!$$refvalue->{filter} || $$refvalue->{hash}->{$name});
180 181
    } else {
	return 0;
182
    }
183 184
}

185
sub report_argument_forbidden($$) {
186
    my $self = shift;
187 188 189 190
    my $refargument_forbidden = $self->{ARGUMENT_FORBIDDEN};

    my $type = shift;

191
    return $$refargument_forbidden->{active} && (!$$refargument_forbidden->{filter} || $$refargument_forbidden->{hash}->{$type});
192 193
}

194
sub report_argument_kind($$) {
195 196 197 198 199
    my $self = shift;
    my $refargument_kind = $self->{ARGUMENT_KIND};

    my $kind = shift;

200
    return $$refargument_kind->{active} && (!$$refargument_kind->{filter} || $$refargument_kind->{hash}->{$kind});
201 202 203 204

}

1;