1 package winapi_options
;
5 sub parser_comma_list
{
8 if(defined($prefix) && $prefix eq "no") {
9 return { active
=> 0, filter
=> 0, hash
=> {} };
10 } elsif(defined($value)) {
12 for my $name (split /,/, $value) {
15 return { active
=> 1, filter
=> 1, hash
=> \
%names };
17 return { active
=> 1, filter
=> 0, hash
=> {} };
22 "debug" => { default => 0, description
=> "debug mode" },
23 "help" => { default => 0, description
=> "help mode" },
24 "verbose" => { default => 0, description
=> "verbose mode" },
26 "progress" => { default => 1, description
=> "show progress" },
28 "win16" => { default => 1, description
=> "Win16 checking" },
29 "win32" => { default => 1, description
=> "Win32 checking" },
31 "shared" => { default => 0, description
=> "show shared functions between Win16 and Win32" },
32 "shared-segmented" => { default => 0, description
=> "segmented shared functions between Win16 and Win32 checking" },
34 "config" => { default => 1, description
=> "check configuration include consistancy" },
35 "config-unnessary" => { default => 0, parent
=> "config", description
=> "check for unnessary #include \"config.h\"" },
37 "local" => { default => 1, description
=> "local checking" },
39 default => { active
=> 1, filter
=> 0, hash
=> {} },
41 parser
=> \
&parser_comma_list
,
42 description
=> "module filter"
45 "argument" => { default => 1, parent
=> "local", description
=> "argument checking" },
46 "argument-count" => { default => 1, parent
=> "argument", description
=> "argument count checking" },
47 "argument-forbidden" => {
48 default => { active
=> 1, filter
=> 0, hash
=> {} },
50 parser
=> \
&parser_comma_list
,
51 description
=> "argument forbidden checking"
54 default => { active
=> 0, filter
=> 0, hash
=> {} },
56 parser
=> \
&parser_comma_list
,
57 description
=> "argument kind checking"
59 "calling-convention" => { default => 0, parent
=> "local", description
=> "calling convention checking" },
60 "misplaced" => { default => 0, parent
=> "local", description
=> "check for misplaced functions" },
61 "cross-call" => { default => 0, parent
=> "local", description
=> "check for cross calling functions" },
62 "documentation" => { default => 0, parent
=> "local", description
=> "check for documentation inconsistances\n" },
64 "global" => { default => 1, description
=> "global checking" },
65 "declared" => { default => 1, parent
=> "global", description
=> "declared checking" },
66 "implemented" => { default => 1, parent
=> "global", description
=> "implemented checking" },
67 "implemented-win32" => { default => 0, parent
=> "implemented", description
=> "implemented as win32 checking" },
68 "include" => { default => 1, parent
=> "global", description
=> "include checking" }
79 my $class = ref($proto) || $proto;
81 bless ($self, $class);
83 my $refarguments = shift;
84 my @ARGV = @
$refarguments;
86 for my $name (sort(keys(%options))) {
87 my $option = $options{$name};
91 my $refvalue = \
${$self->{$key}};
92 $$refvalue = $$option{default};
95 my $files = \@
{$self->{FILES
}};
96 my $module = \
${$self->{MODULE
}};
97 my $global = \
${$self->{GLOBAL
}};
100 while(defined($_ = shift @ARGV)) {
101 if(/^-([^=]*)(=(.*))?$/) {
111 if($name =~ /^([^-].*)$/) {
112 $name = $short_options{$1};
114 $name =~ s/^-(.*)$/$1/;
118 if($name =~ /^no-(.*)$/) {
121 if(defined($value)) {
122 print STDERR
"<internal>: options with prefix 'no' can't take parameters\n";
127 my $option = $options{$name};
128 if(defined($option)) {
129 my $key = $$option{key
};
130 my $parser = $$option{parser
};
131 my $refvalue = \
${$self->{$key}};
133 if(defined($parser)) {
134 $$refvalue = &$parser($prefix,$value);
136 if(defined($value)) {
138 } elsif(!defined($prefix)) {
148 if(/^--module-dlls$/) {
149 my @dirs = `cd dlls && find ./ -type d ! -name CVS`;
151 for my $dir (@dirs) {
153 $dir =~ s/^\.\/(.*)$/$1/;
157 $$module = { active
=> 1, filter
=> 1, hash
=> \
%names };
160 print STDERR
"<internal>: unknown option: $&\n";
161 print STDERR
"<internal>: usage: winapi-check [--help] [<files>]\n";
173 $paths = join(" ",@
$files);
183 } split(/\n/, `find $paths -name \\*.c`);
192 for my $name (sort(keys(%options))) {
193 if(length($name) > $maxname) {
194 $maxname = length($name);
198 print "usage: winapi-check [--help] [<files>]\n";
200 for my $name (sort(keys(%options))) {
201 my $option = $options{$name};
202 my $description = $$option{description
};
203 my $default = $$option{default};
206 if(ref($default) ne "HASH") {
208 $output = "--no-$name";
213 if($default->{active
}) {
214 $output = "--[no-]$name\[=<value>]";
216 $output = "--$name\[=<value>]";
221 for (0..(($maxname - length($name) + 14) - (length($output) - length($name) + 1))) { print " "; }
222 if(ref($default) ne "HASH") {
224 print "Disable $description\n";
226 print "Enable $description\n";
229 if($default->{active
}) {
230 print "(Disable) $description\n";
232 print "Enable $description\n";
243 my $name = $winapi_options::AUTOLOAD
;
244 $name =~ s/^.*::(.[^:]*)$/\U$1/;
246 my $refvalue = $self->{$name};
247 if(!defined($refvalue)) {
248 die "<internal>: winapi_options.pm: member $name does not exists\n";
253 sub files
{ my $self = shift; return @
{$self->{FILES
}}; }
257 my $module = $self->module;
262 return $module->{active
} && (!$module->{filter
} || $module->{hash
}->{$name});
268 sub report_argument_forbidden
{
270 my $argument_forbidden = $self->argument_forbidden;
274 return $argument_forbidden->{active
} && (!$argument_forbidden->{filter
} || $argument_forbidden->{hash
}->{$type});
277 sub report_argument_kind
{
279 my $argument_kind = $self->argument_kind;
283 return $argument_kind->{active
} && (!$argument_kind->{filter
} || $argument_kind->{hash
}->{$kind});