Commit c56ed505 authored by Patrik Stridvall's avatar Patrik Stridvall Committed by Alexandre Julliard

- API files update.

- Fixed parser to handle C/C++ comments in strings. - Report if C++ comments are used.
parent 4c692b9b
......@@ -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
......@@ -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 *
......
%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,8 +622,16 @@ 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) {
$output->write("$file: include2info config.h but do not use any conditionals\n");
......
......@@ -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);
push @comment_lines, $.;
push @comments, $2;
if($#lines <= 0) {
$_ = "$1 $4";
if(s/^([^\"\/]*?(?:\"[^\"]*?\"[^\"]*?)*?)(?=\/\*)//s) {
my $prefix = $1;
if(s/^(\/\*.*?\*\/)//s) {
my @lines = split(/\n/, $1);
push @comment_lines, $.;
push @comments, $1;
&$c_comment_found_callback($. - $#lines, $., $1);
if($#lines <= 0) {
$_ = "$prefix $_";
} else {
$_ = $prefix . ("\n" x $#lines) . $_;
}
$again = 1;
} else {
$_ = $1 . ("\n" x $#lines) . $4;
$_ = "$prefix$_";
$lookahead = 1;
}
$again = 1;
next;
}
if(/^(.*?)\/\*/s) {
$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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment