- API files update.
- Fixed parser to handle C/C++ comments in strings. - Report if C++ comments are used.
This commit is contained in:
parent
4c692b9b9f
commit
c56ed505f3
|
@ -85,6 +85,17 @@ my %options_long = (
|
|||
},
|
||||
"debug-messages" => { default => 0, parent => "statements", description => "check for debug messages inconsistances" },
|
||||
|
||||
"comments" => {
|
||||
default => 1,
|
||||
parent => "local",
|
||||
description => "comments checking"
|
||||
},
|
||||
"comments-cplusplus" => {
|
||||
default => 1,
|
||||
parent => "comments",
|
||||
description => "C++ comments checking"
|
||||
},
|
||||
|
||||
"documentation" => {
|
||||
default => 1,
|
||||
parent => "local",
|
||||
|
|
|
@ -34,6 +34,8 @@ dlls/crtdll
|
|||
|
||||
% dlls/crypt32/crypt32.spec
|
||||
|
||||
dlls/crypt32
|
||||
|
||||
% dlls/dciman32/dciman32.spec
|
||||
|
||||
dlls/dciman32
|
||||
|
@ -140,6 +142,10 @@ dlls/mapi32
|
|||
|
||||
dlls/msimg32
|
||||
|
||||
% dlls/msisys/msisys.ocx.spec
|
||||
|
||||
dlls/msisys
|
||||
|
||||
% dlls/msrle32/msrle32.spec
|
||||
|
||||
dlls/msrle32
|
||||
|
@ -359,6 +365,10 @@ dlls/shdocvw
|
|||
|
||||
dlls/shlwapi
|
||||
|
||||
% dlls/snmpapi/snmpapi.spec
|
||||
|
||||
dlls/snmpapi
|
||||
|
||||
% dlls/tapi32/tapi32.spec
|
||||
|
||||
dlls/tapi32
|
||||
|
|
|
@ -85,3 +85,4 @@ LPWSTR
|
|||
%void
|
||||
|
||||
VOID
|
||||
void
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
%long
|
||||
|
||||
BOOL
|
||||
DWORD
|
|
@ -28,6 +28,9 @@ WORD
|
|||
|
||||
HDC16
|
||||
HMETAFILE16
|
||||
HPJOB16
|
||||
INT16
|
||||
int
|
||||
|
||||
%ptr
|
||||
|
||||
|
@ -89,6 +92,7 @@ LPRGNDATA
|
|||
LPSIZE
|
||||
LPVOID
|
||||
LPVOID *
|
||||
LPWORD
|
||||
LPXFORM
|
||||
MAT2 *
|
||||
METAFILEPICT *
|
||||
|
@ -105,6 +109,7 @@ RGBQUAD *
|
|||
RGNDATA *
|
||||
TEXTMETRICA *
|
||||
TEXTMETRICW *
|
||||
WORD *
|
||||
XFORM *
|
||||
void *
|
||||
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
%long
|
||||
|
||||
HRESULT
|
||||
|
||||
%ptr
|
||||
|
||||
CLSID *
|
||||
IID *
|
||||
void **
|
|
@ -3,27 +3,47 @@
|
|||
BOOL
|
||||
DWORD
|
||||
HRESULT
|
||||
UINT
|
||||
long
|
||||
|
||||
%ptr
|
||||
|
||||
BINDINFO *
|
||||
CLIPFORMAT *
|
||||
CLSID *
|
||||
DWORD *
|
||||
FORMATETC *
|
||||
HIT_LOGGING_INFO *
|
||||
IBindCtx *
|
||||
IBindCtx **
|
||||
IBindStatusCallback *
|
||||
IBindStatusCallback **
|
||||
IEnumFORMATETC *
|
||||
IEnumFORMATETC **
|
||||
IID *
|
||||
IMoniker *
|
||||
IMoniker **
|
||||
IStream **
|
||||
IUnknown *
|
||||
LPCSTR *
|
||||
LPVOID
|
||||
LPVOID *
|
||||
REFCLSID
|
||||
REFIID
|
||||
LPWSTR *
|
||||
SOFTDISTINFO *
|
||||
ULONG *
|
||||
void *
|
||||
void **
|
||||
|
||||
%str
|
||||
|
||||
LPCSTR
|
||||
LPSTR
|
||||
|
||||
%wstr
|
||||
|
||||
LPCWSTR
|
||||
LPWSTR
|
||||
|
||||
%void
|
||||
|
||||
void
|
||||
|
|
|
@ -24,6 +24,7 @@ LPCONDITIONPROC
|
|||
LPDWORD
|
||||
LPGUID
|
||||
LPINT
|
||||
LPQOS
|
||||
LPVOID
|
||||
LPWPUPOSTMESSAGE
|
||||
LPWSABUF
|
||||
|
|
|
@ -150,6 +150,29 @@ if($options->headers) {
|
|||
$progress_current++;
|
||||
$output->progress("$file: file $progress_current of $progress_max");
|
||||
|
||||
my $found_c_comment = sub {
|
||||
my $begin_line = shift;
|
||||
my $end_line = shift;
|
||||
my $comment = shift;
|
||||
|
||||
if(0) {
|
||||
if($begin_line == $end_line) {
|
||||
$output->write("$file:$begin_line: $comment\n");
|
||||
} else {
|
||||
$output->write("$file:$begin_line-$end_line: \\\n$comment\n");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
my $found_cplusplus_comment = sub {
|
||||
my $line = shift;
|
||||
my $comment = shift;
|
||||
|
||||
if($options->comments_cplusplus) {
|
||||
$output->write("$file:$line: C++ comments not allowed: $comment\n");
|
||||
}
|
||||
};
|
||||
|
||||
my $create_function = sub {
|
||||
return 'winapi_function'->new;
|
||||
};
|
||||
|
@ -205,7 +228,15 @@ if($options->headers) {
|
|||
my $argument = shift;
|
||||
};
|
||||
|
||||
&winapi_parser::parse_c_file($file, $create_function, $found_function, $create_type, $found_type, $found_preprocessor);
|
||||
&winapi_parser::parse_c_file($file, {
|
||||
c_comment_found => $found_c_comment,
|
||||
cplusplus_comment_found => $found_cplusplus_comment,
|
||||
function_create => $create_function,
|
||||
function_found => $found_function,
|
||||
type_create => $create_type,
|
||||
type_found => $found_type,
|
||||
preprocessor_found => $found_preprocessor
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -229,6 +260,29 @@ foreach my $file (@c_files) {
|
|||
$file_dir = ".";
|
||||
}
|
||||
|
||||
my $found_c_comment = sub {
|
||||
my $begin_line = shift;
|
||||
my $end_line = shift;
|
||||
my $comment = shift;
|
||||
|
||||
if(0) {
|
||||
if($begin_line == $end_line) {
|
||||
$output->write("$file:$begin_line: $comment\n");
|
||||
} else {
|
||||
$output->write("$file:$begin_line-$end_line: \\\n$comment\n");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
my $found_cplusplus_comment = sub {
|
||||
my $line = shift;
|
||||
my $comment = shift;
|
||||
|
||||
if($options->comments_cplusplus) {
|
||||
$output->write("$file:$line: C++ comments not allowed: $comment\n");
|
||||
}
|
||||
};
|
||||
|
||||
my $create_function = sub {
|
||||
return 'winapi_function'->new;
|
||||
};
|
||||
|
@ -568,7 +622,15 @@ foreach my $file (@c_files) {
|
|||
}
|
||||
};
|
||||
|
||||
&winapi_parser::parse_c_file($file, $create_function, $found_function, $create_type, $found_type, $found_preprocessor);
|
||||
&winapi_parser::parse_c_file($file, {
|
||||
c_comment_found => $found_c_comment,
|
||||
cplusplus_comment_found => $found_cplusplus_comment,
|
||||
function_create => $create_function,
|
||||
function_found => $found_function,
|
||||
type_create => $create_type,
|
||||
type_found => $found_type,
|
||||
preprocessor_found => $found_preprocessor
|
||||
});
|
||||
|
||||
if($options->config_unnessary) {
|
||||
if($config && $conditional == 0) {
|
||||
|
|
|
@ -1,511 +0,0 @@
|
|||
#
|
||||
# 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
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
package winapi_options;
|
||||
|
||||
use strict;
|
||||
|
||||
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
|
||||
require Exporter;
|
||||
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(&parse_comma_list);
|
||||
@EXPORT_OK = qw($options);
|
||||
|
||||
use vars qw($options);
|
||||
|
||||
use config qw($current_dir $wine_dir);
|
||||
use output qw($output);
|
||||
|
||||
sub parser_comma_list {
|
||||
my $prefix = shift;
|
||||
my $value = shift;
|
||||
if(defined($prefix) && $prefix eq "no") {
|
||||
return { active => 0, filter => 0, hash => {} };
|
||||
} elsif(defined($value)) {
|
||||
my %names;
|
||||
for my $name (split /,/, $value) {
|
||||
$names{$name} = 1;
|
||||
}
|
||||
return { active => 1, filter => 1, hash => \%names };
|
||||
} else {
|
||||
return { active => 1, filter => 0, hash => {} };
|
||||
}
|
||||
}
|
||||
|
||||
my %options = (
|
||||
"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" },
|
||||
|
||||
"config" => { default => 1, parent => "local", description => "check configuration include consistancy" },
|
||||
"config-unnessary" => { default => 0, parent => "config", description => "check for unnessary #include \"config.h\"" },
|
||||
|
||||
"spec-mismatch" => { default => 0, description => "spec file mismatch checking" },
|
||||
|
||||
"local" => { default => 1, description => "local checking" },
|
||||
"module" => {
|
||||
default => { active => 1, filter => 0, hash => {} },
|
||||
parent => "local",
|
||||
parser => \&parser_comma_list,
|
||||
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",
|
||||
parser => \&parser_comma_list,
|
||||
description => "argument forbidden checking"
|
||||
},
|
||||
"argument-kind" => {
|
||||
default => { active => 1, filter => 1, hash => { double => 1 } },
|
||||
parent => "argument",
|
||||
parser => \&parser_comma_list,
|
||||
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" },
|
||||
"statements" => { default => 0, parent => "local", description => "check for statements inconsistances" },
|
||||
"cross-call" => { default => 0, parent => "statements", description => "check for cross calling functions" },
|
||||
"cross-call-win32-win16" => {
|
||||
default => 0, parent => "cross-call", description => "check for cross calls between win32 and win16"
|
||||
},
|
||||
"cross-call-unicode-ascii" => {
|
||||
default => 0, parent => "cross-call", description => "check for cross calls between Unicode and ASCII"
|
||||
},
|
||||
"debug-messages" => { default => 0, parent => "statements", description => "check for debug messages inconsistances" },
|
||||
|
||||
"documentation" => {
|
||||
default => 1,
|
||||
parent => "local",
|
||||
description => "check for documentation inconsistances"
|
||||
},
|
||||
"documentation-pedantic" => {
|
||||
default => 0,
|
||||
parent => "documentation",
|
||||
description => "be pendantic when checking for documentation inconsistances"
|
||||
},
|
||||
|
||||
"documentation-arguments" => {
|
||||
default => 1,
|
||||
parent => "documentation",
|
||||
description => "check for arguments documentation inconsistances\n"
|
||||
},
|
||||
"documentation-comment-indent" => {
|
||||
default => 0,
|
||||
parent => "documentation", description => "check for documentation comment indent inconsistances"
|
||||
},
|
||||
"documentation-comment-width" => {
|
||||
default => 0,
|
||||
parent => "documentation", description => "check for documentation comment width inconsistances"
|
||||
},
|
||||
"documentation-name" => {
|
||||
default => 1,
|
||||
parent => "documentation",
|
||||
description => "check for documentation name inconsistances\n"
|
||||
},
|
||||
"documentation-ordinal" => {
|
||||
default => 1,
|
||||
parent => "documentation",
|
||||
description => "check for documentation ordinal inconsistances\n"
|
||||
},
|
||||
"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 %short_options = (
|
||||
"d" => "debug",
|
||||
"?" => "help",
|
||||
"v" => "verbose"
|
||||
);
|
||||
|
||||
sub new {
|
||||
my $proto = shift;
|
||||
my $class = ref($proto) || $proto;
|
||||
my $self = {};
|
||||
bless ($self, $class);
|
||||
|
||||
$self->options_set("default");
|
||||
|
||||
my $c_files = \@{$self->{C_FILES}};
|
||||
my $h_files = \@{$self->{H_FILES}};
|
||||
my $module = \${$self->{MODULE}};
|
||||
my $global = \${$self->{GLOBAL}};
|
||||
my $headers = \${$self->{HEADERS}};
|
||||
|
||||
my @files;
|
||||
|
||||
if($wine_dir eq ".") {
|
||||
$$global = 1;
|
||||
} else {
|
||||
$$global = 0;
|
||||
}
|
||||
|
||||
while(defined($_ = shift @ARGV)) {
|
||||
if(/^--(all|none)$/) {
|
||||
$self->options_set("$1");
|
||||
next;
|
||||
} elsif(/^-([^=]*)(=(.*))?$/) {
|
||||
my $name;
|
||||
my $value;
|
||||
if(defined($2)) {
|
||||
$name = $1;
|
||||
$value = $3;
|
||||
} else {
|
||||
$name = $1;
|
||||
}
|
||||
|
||||
if($name =~ /^([^-].*)$/) {
|
||||
$name = $short_options{$1};
|
||||
} else {
|
||||
$name =~ s/^-(.*)$/$1/;
|
||||
}
|
||||
|
||||
my $prefix;
|
||||
if(defined($name) && $name =~ /^no-(.*)$/) {
|
||||
$name = $1;
|
||||
$prefix = "no";
|
||||
if(defined($value)) {
|
||||
$output->write("options with prefix 'no' can't take parameters\n");
|
||||
|
||||
return undef;
|
||||
}
|
||||
}
|
||||
|
||||
my $option;
|
||||
if(defined($name)) {
|
||||
$option = $options{$name};
|
||||
}
|
||||
|
||||
if(defined($option)) {
|
||||
my $key = $$option{key};
|
||||
my $parser = $$option{parser};
|
||||
my $refvalue = \${$self->{$key}};
|
||||
my @parents = ();
|
||||
|
||||
if(defined($$option{parent})) {
|
||||
if(ref($$option{parent}) eq "ARRAY") {
|
||||
@parents = @{$$option{parent}};
|
||||
} else {
|
||||
@parents = $$option{parent};
|
||||
}
|
||||
}
|
||||
|
||||
if(defined($parser)) {
|
||||
$$refvalue = &$parser($prefix,$value);
|
||||
} else {
|
||||
if(defined($value)) {
|
||||
$$refvalue = $value;
|
||||
} elsif(!defined($prefix)) {
|
||||
$$refvalue = 1;
|
||||
} else {
|
||||
$$refvalue = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if((ref($$refvalue) eq "HASH" && $$refvalue->{active}) || $$refvalue) {
|
||||
while($#parents >= 0) {
|
||||
my @old_parents = @parents;
|
||||
@parents = ();
|
||||
foreach my $parent (@old_parents) {
|
||||
my $parentkey = $options{$parent}{key};
|
||||
my $refparentvalue = \${$self->{$parentkey}};
|
||||
|
||||
$$refparentvalue = 1;
|
||||
|
||||
if(defined($options{$parent}{parent})) {
|
||||
if(ref($options{$parent}{parent}) eq "ARRAY") {
|
||||
push @parents, @{$options{$parent}{parent}};
|
||||
} else {
|
||||
push @parents, $options{$parent}{parent};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
next;
|
||||
}
|
||||
}
|
||||
|
||||
if(/^--module-dlls$/) {
|
||||
my @dirs = `cd dlls && find . -type d ! -name CVS`;
|
||||
my %names;
|
||||
for my $dir (@dirs) {
|
||||
chomp $dir;
|
||||
$dir =~ s/^\.\/(.*)$/$1/;
|
||||
next if $dir eq "";
|
||||
$names{$dir} = 1;
|
||||
}
|
||||
$$module = { active => 1, filter => 1, hash => \%names };
|
||||
}
|
||||
elsif(/^-(.*)$/) {
|
||||
$output->write("unknown option: $_\n");
|
||||
|
||||
return undef;
|
||||
} else {
|
||||
if(!-e $_) {
|
||||
$output->write("$_: no such file or directory\n");
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
push @files, $_;
|
||||
}
|
||||
}
|
||||
|
||||
if($self->help) {
|
||||
return $self;
|
||||
}
|
||||
|
||||
my @paths = ();
|
||||
my @c_files = ();
|
||||
my @h_files = ();
|
||||
foreach my $file (@files) {
|
||||
if($file =~ /\.c$/) {
|
||||
push @c_files, $file;
|
||||
} elsif($file =~ /\.h$/) {
|
||||
push @h_files, $file;
|
||||
} else {
|
||||
push @paths, $file;
|
||||
}
|
||||
}
|
||||
|
||||
if($#h_files >= 0) {
|
||||
$$headers = 1;
|
||||
}
|
||||
|
||||
if($#c_files == -1 && $#h_files == -1 &&
|
||||
($#paths == -1 || ($#paths == 0 && $paths[0] eq $wine_dir)))
|
||||
{
|
||||
@paths = ".";
|
||||
} else {
|
||||
$$global = 0;
|
||||
}
|
||||
|
||||
if($#paths != -1 || $#c_files != -1) {
|
||||
my $c_command = "find " . join(" ", @paths, @c_files) . " -name \\*.c";
|
||||
my %found;
|
||||
@$c_files = sort(map {
|
||||
s/^\.\/(.*)$/$1/;
|
||||
if(defined($found{$_}) || /glue\.c|spec\.c$/) {
|
||||
();
|
||||
} else {
|
||||
$found{$_}++;
|
||||
$_;
|
||||
}
|
||||
} split(/\n/, `$c_command`));
|
||||
}
|
||||
|
||||
if($#paths != -1 || $#h_files != -1) {
|
||||
my $h_command = "find " . join(" ", @paths, @h_files) . " -name \\*.h";
|
||||
my %found;
|
||||
|
||||
@$h_files = sort(map {
|
||||
s/^\.\/(.*)$/$1/;
|
||||
if(defined($found{$_})) {
|
||||
();
|
||||
} else {
|
||||
$found{$_}++;
|
||||
$_;
|
||||
}
|
||||
} split(/\n/, `$h_command`));
|
||||
}
|
||||
|
||||
$options = $self;
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub DESTROY {
|
||||
}
|
||||
|
||||
sub options_set {
|
||||
my $self = shift;
|
||||
|
||||
local $_ = shift;
|
||||
for my $name (sort(keys(%options))) {
|
||||
my $option = $options{$name};
|
||||
my $key = uc($name);
|
||||
$key =~ tr/-/_/;
|
||||
$$option{key} = $key;
|
||||
my $refvalue = \${$self->{$key}};
|
||||
|
||||
if(/^default$/) {
|
||||
$$refvalue = $$option{default};
|
||||
} elsif(/^all$/) {
|
||||
if($name !~ /^help|debug|verbose|module$/) {
|
||||
if(ref($$refvalue) ne "HASH") {
|
||||
$$refvalue = 1;
|
||||
} else {
|
||||
$$refvalue = { active => 1, filter => 0, hash => {} };
|
||||
}
|
||||
}
|
||||
} elsif(/^none$/) {
|
||||
if($name !~ /^help|debug|verbose|module$/) {
|
||||
if(ref($$refvalue) ne "HASH") {
|
||||
$$refvalue = 0;
|
||||
} else {
|
||||
$$refvalue = { active => 0, filter => 0, hash => {} };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub show_help {
|
||||
my $self = shift;
|
||||
|
||||
my $maxname = 0;
|
||||
for my $name (sort(keys(%options))) {
|
||||
if(length($name) > $maxname) {
|
||||
$maxname = length($name);
|
||||
}
|
||||
}
|
||||
|
||||
print "usage: winapi-check [--help] [<files>]\n";
|
||||
print "\n";
|
||||
for my $name (sort(keys(%options))) {
|
||||
my $option = $options{$name};
|
||||
my $description = $$option{description};
|
||||
my $default = $$option{default};
|
||||
my $current = ${$self->{$$option{key}}};
|
||||
|
||||
my $value = $current;
|
||||
|
||||
my $output;
|
||||
if(ref($value) ne "HASH") {
|
||||
if($value) {
|
||||
$output = "--no-$name";
|
||||
} else {
|
||||
$output = "--$name";
|
||||
}
|
||||
} else {
|
||||
if($value->{active}) {
|
||||
$output = "--[no-]$name\[=<value>]";
|
||||
} else {
|
||||
$output = "--$name\[=<value>]";
|
||||
}
|
||||
}
|
||||
|
||||
print "$output";
|
||||
for (0..(($maxname - length($name) + 17) - (length($output) - length($name) + 1))) { print " "; }
|
||||
if(ref($value) ne "HASH") {
|
||||
if($value) {
|
||||
print "Disable ";
|
||||
} else {
|
||||
print "Enable ";
|
||||
}
|
||||
} else {
|
||||
if($value->{active}) {
|
||||
print "(Disable) ";
|
||||
} else {
|
||||
print "Enable ";
|
||||
}
|
||||
}
|
||||
if($default == $current) {
|
||||
print "$description (default)\n";
|
||||
} else {
|
||||
print "$description\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub AUTOLOAD {
|
||||
my $self = shift;
|
||||
|
||||
my $name = $winapi_options::AUTOLOAD;
|
||||
$name =~ s/^.*::(.[^:]*)$/\U$1/;
|
||||
|
||||
my $refvalue = $self->{$name};
|
||||
if(!defined($refvalue)) {
|
||||
die "<internal>: winapi_options.pm: member $name does not exists\n";
|
||||
}
|
||||
|
||||
if(ref($$refvalue) ne "HASH") {
|
||||
return $$refvalue;
|
||||
} else {
|
||||
return $$refvalue->{active};
|
||||
}
|
||||
}
|
||||
|
||||
sub c_files { my $self = shift; return @{$self->{C_FILES}}; }
|
||||
|
||||
sub h_files { my $self = shift; return @{$self->{H_FILES}}; }
|
||||
|
||||
sub report_module {
|
||||
my $self = shift;
|
||||
my $refvalue = $self->{MODULE};
|
||||
|
||||
my $name = shift;
|
||||
|
||||
if(defined($name)) {
|
||||
return $$refvalue->{active} && (!$$refvalue->{filter} || $$refvalue->{hash}->{$name});
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
sub report_argument_forbidden {
|
||||
my $self = shift;
|
||||
my $refargument_forbidden = $self->{ARGUMENT_FORBIDDEN};
|
||||
|
||||
my $type = shift;
|
||||
|
||||
return $$refargument_forbidden->{active} && (!$$refargument_forbidden->{filter} || $$refargument_forbidden->{hash}->{$type});
|
||||
}
|
||||
|
||||
sub report_argument_kind {
|
||||
my $self = shift;
|
||||
my $refargument_kind = $self->{ARGUMENT_KIND};
|
||||
|
||||
my $kind = shift;
|
||||
|
||||
return $$refargument_kind->{active} && (!$$refargument_kind->{filter} || $$refargument_kind->{hash}->{$kind});
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
@ -25,11 +25,17 @@ use options qw($options);
|
|||
|
||||
sub parse_c_file {
|
||||
my $file = shift;
|
||||
my $function_create_callback = shift;
|
||||
my $function_found_callback = shift;
|
||||
my $type_create_callback = shift;
|
||||
my $type_found_callback = shift;
|
||||
my $preprocessor_found_callback = shift;
|
||||
my $callbacks = shift;
|
||||
|
||||
my $empty_callback = sub { };
|
||||
|
||||
my $c_comment_found_callback = $$callbacks{c_comment_found} || $empty_callback;
|
||||
my $cplusplus_comment_found_callback = $$callbacks{cplusplus_comment_found} || $empty_callback;
|
||||
my $function_create_callback = $$callbacks{function_create} || $empty_callback;
|
||||
my $function_found_callback = $$callbacks{function_found} || $empty_callback;
|
||||
my $type_create_callback = $$callbacks{type_create} || $empty_callback;
|
||||
my $type_found_callback = $$callbacks{type_found} || $empty_callback;
|
||||
my $preprocessor_found_callback = $$callbacks{preprocessor_found} || $empty_callback;
|
||||
|
||||
# global
|
||||
my $debug_channels = [];
|
||||
|
@ -185,25 +191,31 @@ sub parse_c_file {
|
|||
}
|
||||
|
||||
# remove C comments
|
||||
if(/^(.*?)(\/\*(.*?)\*\/)(.*)$/s) {
|
||||
my @lines = split(/\n/, $2);
|
||||
if(s/^([^\"\/]*?(?:\"[^\"]*?\"[^\"]*?)*?)(?=\/\*)//s) {
|
||||
my $prefix = $1;
|
||||
if(s/^(\/\*.*?\*\/)//s) {
|
||||
my @lines = split(/\n/, $1);
|
||||
push @comment_lines, $.;
|
||||
push @comments, $2;
|
||||
push @comments, $1;
|
||||
&$c_comment_found_callback($. - $#lines, $., $1);
|
||||
if($#lines <= 0) {
|
||||
$_ = "$1 $4";
|
||||
$_ = "$prefix $_";
|
||||
} else {
|
||||
$_ = $1 . ("\n" x $#lines) . $4;
|
||||
$_ = $prefix . ("\n" x $#lines) . $_;
|
||||
}
|
||||
$again = 1;
|
||||
next;
|
||||
}
|
||||
if(/^(.*?)\/\*/s) {
|
||||
} else {
|
||||
$_ = "$prefix$_";
|
||||
$lookahead = 1;
|
||||
}
|
||||
next;
|
||||
}
|
||||
|
||||
# remove C++ comments
|
||||
while(s/^(.*?)\/\/.*?$/$1/s) { $again = 1 }
|
||||
while(s/^([^\"\/]*?(?:\"[^\"]*?\"[^\"]*?)*?)(\/\/.*?)$/$1/s) {
|
||||
&$cplusplus_comment_found_callback($., $2);
|
||||
$again = 1;
|
||||
}
|
||||
if($again) { next; }
|
||||
|
||||
# remove preprocessor directives
|
||||
|
|
Loading…
Reference in New Issue