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 for my $name (sort(keys(%options))) {
93 my $option = $options{$name};
97 my $refvalue = \
${$self->{$key}};
98 $$refvalue = $$option{default};
101 my $c_files = \@
{$self->{C_FILES
}};
102 my $h_files = \@
{$self->{H_FILES
}};
103 my $module = \
${$self->{MODULE
}};
104 my $global = \
${$self->{GLOBAL
}};
107 while(defined($_ = shift @ARGV)) {
108 if(/^-([^=]*)(=(.*))?$/) {
118 if($name =~ /^([^-].*)$/) {
119 $name = $short_options{$1};
121 $name =~ s/^-(.*)$/$1/;
125 if($name =~ /^no-(.*)$/) {
128 if(defined($value)) {
129 print STDERR
"<internal>: options with prefix 'no' can't take parameters\n";
134 my $option = $options{$name};
135 if(defined($option)) {
136 my $key = $$option{key
};
137 my $parser = $$option{parser
};
138 my $refvalue = \
${$self->{$key}};
140 if(defined($parser)) {
141 $$refvalue = &$parser($prefix,$value);
143 if(defined($value)) {
145 } elsif(!defined($prefix)) {
155 if(/^--module-dlls$/) {
156 my @dirs = `cd dlls && find ./ -type d ! -name CVS`;
158 for my $dir (@dirs) {
160 $dir =~ s/^\.\/(.*)$/$1/;
164 $$module = { active
=> 1, filter
=> 1, hash
=> \
%names };
167 print STDERR
"<internal>: unknown option: $&\n";
168 print STDERR
"<internal>: usage: winapi-check [--help] [<files>]\n";
176 if($#$c_files == -1) {
180 $c_paths = join(" ", @
$c_files);
183 my $h_paths = "$wine_dir/include $wine_dir/include/wine";
185 @
$c_files = sort(map {
192 } split(/\n/, `find $c_paths -name \\*.c`));
194 @
$h_files = sort(map {
197 } split(/\n/, `find $h_paths -name \\*.h`));
206 for my $name (sort(keys(%options))) {
207 if(length($name) > $maxname) {
208 $maxname = length($name);
212 print "usage: winapi-check [--help] [<files>]\n";
214 for my $name (sort(keys(%options))) {
215 my $option = $options{$name};
216 my $description = $$option{description
};
217 my $default = $$option{default};
220 if(ref($default) ne "HASH") {
222 $output = "--no-$name";
227 if($default->{active
}) {
228 $output = "--[no-]$name\[=<value>]";
230 $output = "--$name\[=<value>]";
235 for (0..(($maxname - length($name) + 14) - (length($output) - length($name) + 1))) { print " "; }
236 if(ref($default) ne "HASH") {
238 print "Disable $description\n";
240 print "Enable $description\n";
243 if($default->{active
}) {
244 print "(Disable) $description\n";
246 print "Enable $description\n";
257 my $name = $winapi_options::AUTOLOAD
;
258 $name =~ s/^.*::(.[^:]*)$/\U$1/;
260 my $refvalue = $self->{$name};
261 if(!defined($refvalue)) {
262 die "<internal>: winapi_options.pm: member $name does not exists\n";
267 sub c_files
{ my $self = shift; return @
{$self->{C_FILES
}}; }
269 sub h_files
{ my $self = shift; return @
{$self->{H_FILES
}}; }
273 my $module = $self->module;
278 return $module->{active
} && (!$module->{filter
} || $module->{hash
}->{$name});
284 sub report_argument_forbidden
{
286 my $argument_forbidden = $self->argument_forbidden;
290 return $argument_forbidden->{active
} && (!$argument_forbidden->{filter
} || $argument_forbidden->{hash
}->{$type});
293 sub report_argument_kind
{
295 my $argument_kind = $self->argument_kind;
299 return $argument_kind->{active
} && (!$argument_kind->{filter
} || $argument_kind->{hash
}->{$kind});