1 package winapi_documentation;
9 sub check_documentation {
16 my $module16 = $function->module16;
17 my $module32 = $function->module32;
18 my $external_name16 = $function->external_name16;
19 my $external_name32 = $function->external_name32;
20 my $internal_name = $function->internal_name;
21 my $documentation = $function->documentation;
22 my @argument_documentations = @{$function->argument_documentations};
28 if(defined($module16) && !defined($module32)) {
29 my @uc_modules16 = split(/\s*\&\s*/, uc($module16));
30 push @uc_modules16, "WIN16";
32 $name1 = $internal_name;
33 foreach my $uc_module16 (@uc_modules16) {
34 if($name1 =~ s/^$uc_module16\_//) { last; }
38 $name2 =~ s/(?:_)?16$//;
39 $name2 =~ s/16_fn/16_/;
41 $external_name = $external_name16;
42 } elsif(!defined($module16) && defined($module32)) {
43 my @uc_modules32 = split(/\s*\&\s*/, uc($module32));
44 push @uc_modules32, "wine";
46 foreach my $uc_module32 (@uc_modules32) {
47 if($uc_module32 =~ /^WS2_32$/) {
48 push @uc_modules32, "WSOCK32";
52 $name1 = $internal_name;
53 foreach my $uc_module32 (@uc_modules32) {
54 if($name1 =~ s/^$uc_module32\_//) { last; }
60 $external_name = $external_name32;
62 my @uc_modules = split(/\s*\&\s*/, uc($module16));
63 push @uc_modules, split(/\s*\&\s*/, uc($module32));
65 $name1 = $internal_name;
66 foreach my $uc_module (@uc_modules) {
67 if($name1 =~ s/^$uc_module\_//) { last; }
71 $external_name = $external_name32;
74 if(!defined($external_name)) {
75 $external_name = $internal_name;
78 if($options->documentation_name) {
80 if((++$n && defined($module16) && defined($external_name16) &&
81 $external_name16 ne "@" && $documentation !~ /\b\Q$external_name16\E\b/) ||
82 (++$n && defined($module16) && defined($external_name16) &&
83 $external_name16 eq "@" && $documentation !~ /\@/) ||
84 (++$n && defined($module32) && defined($external_name32) &&
85 $external_name32 ne "@" && $documentation !~ /\b\Q$external_name32\E\b/) ||
86 (++$n && defined($module32) && defined($external_name32) &&
87 $external_name32 eq "@" && $documentation !~ /\@/))
89 my $external_name = ($external_name16, $external_name32)[($n-1)/2];
90 if($options->documentation_pedantic || $documentation !~ /\b(?:$internal_name|$name1|$name2)\b/) {
91 $output->write("documentation: wrong or missing name ($external_name) \\\n$documentation\n");
96 if($options->documentation_ordinal) {
97 if(defined($module16)) {
98 my $ordinal16 = $win16api->function_internal_ordinal($internal_name);
100 if(!defined($ordinal16)) {
101 $output->write("function have no ordinal\n");
103 my @uc_modules16 = split(/\s*\&\s*/, uc($module16));
104 foreach my $uc_module16 (@uc_modules16) {
105 if($documentation !~ /\b$uc_module16\.\Q$ordinal16\E/) {
106 $output->write("documentation: wrong or missing ordinal " .
107 "expected ($uc_module16.$ordinal16) \\\n$documentation\n");
112 if(defined($module32)) {
113 my $ordinal32 = $win32api->function_internal_ordinal($internal_name);
115 if(!defined($ordinal32)) {
116 $output->write("function have no ordinal\n");
118 my @uc_modules32 = split(/\s*\&\s*/, uc($module32));
119 foreach my $uc_module32 (@uc_modules32) {
120 if($documentation !~ /\b$uc_module32\.\Q$ordinal32\E/) {
121 $output->write("documentation: wrong or missing ordinal " .
122 "expected ($uc_module32.$ordinal32) \\\n$documentation\n");
129 if($options->documentation_pedantic) {
130 my $ordinal = $win16api->function_internal_ordinal($internal_name);
131 if(defined($ordinal) && $documentation !~ /^ \*\s+(?:\@|\w+)(?:\s+[\(\[]\w+\.(?:\@|\d+)[\)\]])+/m) {
132 $output->write("documentation: pedantic check failed \\\n$documentation\n");
136 if($options->documentation_comment_indent) {
137 if($documentation =~ /^ \*(\s*)\w+(\s*)([\(\[])\s*\w+\.\s*(?:\@|\d+)\s*([\)\]])/m) {
144 $indent = length($indent);
146 $spacing =~ s/\t/ /g;
147 $spacing = length($spacing);
149 $comment_indent{$indent}++;
151 $output->write("documentation: comment indent is $indent\n");
154 $comment_spacing{$spacing}++;
158 if($options->documentation_comment_width) {
159 if($documentation =~ /(^\/\*\*+)/) {
160 my $width = length($1);
162 $comment_width{$width}++;
163 if($width <= 65 || $width >= 81) {
164 $output->write("comment is $width columns wide\n");
169 if($options->documentation_arguments) {
171 for my $argument_documentation (@argument_documentations) {
173 if($argument_documentation ne "") {
174 if($argument_documentation !~ /^\/\*\s+\[(?:in|out|in\/out|\?\?\?)\].*?\*\/$/s) {
175 $output->write("argument $n documentation: \\\n$argument_documentation\n");
182 sub report_documentation {
186 if($options->documentation_comment_indent) {
187 foreach my $indent (sort(keys(%comment_indent))) {
188 my $count = $comment_indent{$indent};
189 $output->write("*.c: $count functions have comment that is indented $indent\n");
193 if($options->documentation_comment_width) {
194 foreach my $width (sort(keys(%comment_width))) {
195 my $count = $comment_width{$width};
196 $output->write("*.c: $count functions have comments of width $width\n");