1 package winapi_documentation;
9 sub check_documentation {
18 my $module16 = $function->module16;
19 my $module32 = $function->module32;
20 my $external_name16 = $function->external_name16;
21 my $external_name32 = $function->external_name32;
22 my $internal_name = $function->internal_name;
23 my $documentation = $function->documentation;
24 my $documentation_line = $function->documentation_line;
25 my @argument_documentations = @{$function->argument_documentations};
27 if($options->documentation_name ||
28 $options->documentation_ordinal ||
29 $options->documentation_pedantic)
31 my @winapis = ($win16api, $win32api);
32 my @modules = ($module16, $module32);
33 my @external_names = ($external_name16, $external_name32);
35 defined(my $winapi = shift @winapis) &&
36 defined(my $external_name = shift @external_names) &&
37 defined(my $module = shift @modules))
39 if($winapi->function_stub($internal_name)) { next; }
41 my @external_name = split(/\s*\&\s*/, $external_name);
42 my @modules = split(/\s*\&\s*/, $module);
43 my @ordinals = split(/\s*\&\s*/, $winapi->function_internal_ordinal($internal_name));
45 my $pedantic_failed = 0;
46 while(defined(my $external_name = shift @external_name) &&
47 defined(my $module = shift @modules) &&
48 defined(my $ordinal = shift @ordinals))
51 my $found_ordinal = 0;
52 foreach (split(/\n/, $documentation)) {
53 if(/^(\s*)\*(\s*)(\@|\S+)(\s*)([\(\[])(\w+)\.(\@|\d+)([\)\]])/) {
54 my $external_name2 = $3;
58 if(length($1) != 1 || length($2) < 1 ||
59 length($4) < 1 || $5 ne "(" || $8 ne ")")
64 if($external_name eq $external_name2) {
66 if("\U$module\E" eq $module2 &&
67 $ordinal eq $ordinal2)
74 if(($options->documentation_name && !$found_name) ||
75 ($options->documentation_ordinal && !$found_ordinal))
77 $output->write("documentation: expected $external_name (\U$module\E.$ordinal): \\\n$documentation\n");
81 if($options->documentation_pedantic && $pedantic_failed) {
82 $output->write("documentation: pedantic failed: \\\n$documentation\n");
87 if($options->documentation_wrong) {
88 foreach (split(/\n/, $documentation)) {
89 if(/^\s*\*\s*(\S+)\s*[\(\[]\s*(\w+)\s*\.\s*([^\s\)\]]*)\s*[\)\]].*?$/) {
90 my $external_name = $1;
95 foreach my $entry2 (winapi::get_all_module_internal_ordinal($internal_name)) {
96 (my $external_name2, my $module2, my $ordinal2) = @$entry2;
98 if($external_name eq $external_name2 &&
99 lc($module) eq $module2 &&
100 $ordinal eq $ordinal2)
106 $output->write("documentation: $external_name (\U$module\E.$ordinal) wrong\n");
112 if($options->documentation_comment_indent) {
113 if($documentation =~ /^ \*(\s*)\w+(\s*)([\(\[])\s*\w+\.\s*(?:\@|\d+)\s*([\)\]])/m) {
120 $indent = length($indent);
122 $spacing =~ s/\t/ /g;
123 $spacing = length($spacing);
125 $comment_indent{$indent}++;
127 $output->write("documentation: comment indent is $indent\n");
130 $comment_spacing{$spacing}++;
134 if($options->documentation_comment_width) {
135 if($documentation =~ /(^\/\*\*+)/) {
136 my $width = length($1);
138 $comment_width{$width}++;
139 if($width <= 65 || $width >= 81) {
140 $output->write("comment is $width columns wide\n");
145 if($options->documentation_arguments) {
147 for my $argument_documentation (@argument_documentations) {
149 if($argument_documentation ne "") {
150 if($argument_documentation !~ /^\/\*\s+\[(?:in|out|in\/out|\?\?\?)\].*?\*\/$/s) {
151 $output->write("argument $n documentation: \\\n$argument_documentation\n");
158 sub report_documentation {
162 if($options->documentation_comment_indent) {
163 foreach my $indent (sort(keys(%comment_indent))) {
164 my $count = $comment_indent{$indent};
165 $output->write("*.c: $count functions have comment that is indented $indent\n");
169 if($options->documentation_comment_width) {
170 foreach my $width (sort(keys(%comment_width))) {
171 my $count = $comment_width{$width};
172 $output->write("*.c: $count functions have comments of width $width\n");