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 "spec-mismatch" => { default => 0, description
=> "spec file mismatch checking" },
39 "local" => { default => 1, description
=> "local checking" },
41 default => { active
=> 1, filter
=> 0, hash
=> {} },
43 parser
=> \
&parser_comma_list
,
44 description
=> "module filter"
47 "argument" => { default => 1, parent
=> "local", description
=> "argument checking" },
48 "argument-count" => { default => 1, parent
=> "argument", description
=> "argument count checking" },
49 "argument-forbidden" => {
50 default => { active
=> 1, filter
=> 0, hash
=> {} },
52 parser
=> \
&parser_comma_list
,
53 description
=> "argument forbidden checking"
56 default => { active
=> 0, filter
=> 0, hash
=> {} },
58 parser
=> \
&parser_comma_list
,
59 description
=> "argument kind checking"
61 "calling-convention" => { default => 0, parent
=> "local", description
=> "calling convention checking" },
62 "misplaced" => { default => 0, parent
=> "local", description
=> "check for misplaced functions" },
63 "cross-call" => { default => 0, parent
=> "local", description
=> "check for cross calling functions" },
64 "documentation" => { default => 1, parent
=> "local", description
=> "check for documentation inconsistances\n" },
65 "documentation-width" => { default => 0, parent
=> "documentation", description
=> "check for documentation width inconsistances\n" },
67 "global" => { default => 1, description
=> "global checking" },
68 "declared" => { default => 1, parent
=> "global", description
=> "declared checking" },
69 "implemented" => { default => 1, parent
=> "global", description
=> "implemented checking" },
70 "implemented-win32" => { default => 0, parent
=> "implemented", description
=> "implemented as win32 checking" },
71 "include" => { default => 1, parent
=> "global", description
=> "include checking" },
72 "headers" => { default => 0, parent
=> "global", description
=> "headers checking" },
73 "stubs" => { default => 0, parent
=> "global", description
=> "stubs checking" }
84 my $class = ref($proto) || $proto;
86 bless ($self, $class);
88 my $refarguments = shift;
89 my @ARGV = @
$refarguments;
92 $self->options_set("default");
94 my $c_files = \@
{$self->{C_FILES
}};
95 my $h_files = \@
{$self->{H_FILES
}};
96 my $module = \
${$self->{MODULE
}};
97 my $global = \
${$self->{GLOBAL
}};
99 while(defined($_ = shift @ARGV)) {
100 if(/^--(all|none)$/) {
101 $self->options_set("$1");
103 } elsif(/^-([^=]*)(=(.*))?$/) {
113 if($name =~ /^([^-].*)$/) {
114 $name = $short_options{$1};
116 $name =~ s/^-(.*)$/$1/;
120 if(defined($name) && $name =~ /^no-(.*)$/) {
123 if(defined($value)) {
124 print STDERR
"<internal>: options with prefix 'no' can't take parameters\n";
131 $option = $options{$name};
134 if(defined($option)) {
135 my $key = $$option{key
};
136 my $parser = $$option{parser
};
137 my $parent = $$option{parent
};
138 my $refvalue = \
${$self->{$key}};
140 if(defined($parser)) {
141 $$refvalue = &$parser($prefix,$value);
143 if(defined($value)) {
145 } elsif(!defined($prefix)) {
152 if((ref($$refvalue) eq "HASH" && $$refvalue->{active
}) || $$refvalue) {
153 while(defined($parent)) {
154 my $parentkey = $options{$parent}{key
};
155 my $refparentvalue = \
${$self->{$parentkey}};
157 $$refparentvalue = 1;
158 $parent = $options{$parent}{parent
};
165 if(/^--module-dlls$/) {
166 my @dirs = `cd dlls && find . -type d ! -name CVS`;
168 for my $dir (@dirs) {
170 $dir =~ s/^\.\/(.*)$/$1/;
174 $$module = { active
=> 1, filter
=> 1, hash
=> \
%names };
177 print STDERR
"<internal>: unknown option: $&\n";
178 print STDERR
"<internal>: usage: winapi-check [--help] [<files>]\n";
186 if($#$c_files == -1 || ($#$c_files == 0 && $$c_files[0] eq $wine_dir)) {
189 $c_paths = join(" ", @
$c_files);
193 my $h_paths = "$wine_dir/include $wine_dir/include/wine";
195 @
$c_files = sort(map {
202 } split(/\n/, `find $c_paths -name \\*.c`));
204 @
$h_files = sort(map {
207 } split(/\n/, `find $h_paths -name \\*.h`));
216 for my $name (sort(keys(%options))) {
217 my $option = $options{$name};
220 $$option{key
} = $key;
221 my $refvalue = \
${$self->{$key}};
224 $$refvalue = $$option{default};
226 if($name !~ /^help|debug|verbose|module$/) {
227 if(ref($$refvalue) ne "HASH") {
230 $$refvalue = { active
=> 1, filter
=> 0, hash
=> {} };
234 if($name !~ /^help|debug|verbose|module$/) {
235 if(ref($$refvalue) ne "HASH") {
238 $$refvalue = { active
=> 0, filter
=> 0, hash
=> {} };
249 for my $name (sort(keys(%options))) {
250 if(length($name) > $maxname) {
251 $maxname = length($name);
255 print "usage: winapi-check [--help] [<files>]\n";
257 for my $name (sort(keys(%options))) {
258 my $option = $options{$name};
259 my $description = $$option{description
};
260 my $default = $$option{default};
261 my $current = ${$self->{$$option{key
}}};
263 my $value = $current;
266 if(ref($value) ne "HASH") {
268 $output = "--no-$name";
273 if($value->{active
}) {
274 $output = "--[no-]$name\[=<value>]";
276 $output = "--$name\[=<value>]";
281 for (0..(($maxname - length($name) + 17) - (length($output) - length($name) + 1))) { print " "; }
282 if(ref($value) ne "HASH") {
289 if($value->{active
}) {
295 if($default == $current) {
296 print "$description (default)\n";
298 print "$description\n";
306 my $name = $winapi_options::AUTOLOAD
;
307 $name =~ s/^.*::(.[^:]*)$/\U$1/;
309 my $refvalue = $self->{$name};
310 if(!defined($refvalue)) {
311 die "<internal>: winapi_options.pm: member $name does not exists\n";
314 if(ref($$refvalue) ne "HASH") {
317 return $$refvalue->{active
};
321 sub c_files
{ my $self = shift; return @
{$self->{C_FILES
}}; }
323 sub h_files
{ my $self = shift; return @
{$self->{H_FILES
}}; }
327 my $refvalue = $self->{MODULE
};
332 return $$refvalue->{active
} && (!$$refvalue->{filter
} || $$refvalue->{hash
}->{$name});
338 sub report_argument_forbidden
{
340 my $refargument_forbidden = $self->{ARGUMENT_FORBIDDEN
};
344 return $$refargument_forbidden->{active
} && (!$$refargument_forbidden->{filter
} || $$refargument_forbidden->{hash
}->{$type});
347 sub report_argument_kind
{
349 my $refargument_kind = $self->{ARGUMENT_KIND
};
353 return $$refargument_kind->{active
} && (!$$refargument_kind->{filter
} || $$refargument_kind->{hash
}->{$kind});