winapi_check_options.pm 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. #
  2. # Copyright 1999, 2000, 2001 Patrik Stridvall
  3. #
  4. # This library is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU Lesser General Public
  6. # License as published by the Free Software Foundation; either
  7. # version 2.1 of the License, or (at your option) any later version.
  8. #
  9. # This library is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. # Lesser General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU Lesser General Public
  15. # License along with this library; if not, write to the Free Software
  16. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  17. #
  18. package winapi_check_options;
  19. use strict;
  20. use warnings 'all';
  21. use base qw(options);
  22. use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
  23. require Exporter;
  24. @ISA = qw(Exporter);
  25. @EXPORT = qw();
  26. @EXPORT_OK = qw($options);
  27. use config qw($current_dir $wine_dir);
  28. use options qw($options parse_comma_list);
  29. my %options_long = (
  30. "debug" => { default => 0, description => "debug mode" },
  31. "help" => { default => 0, description => "help mode" },
  32. "verbose" => { default => 0, description => "verbose mode" },
  33. "progress" => { default => 1, description => "show progress" },
  34. "win16" => { default => 1, description => "Win16 checking" },
  35. "win32" => { default => 1, description => "Win32 checking" },
  36. "shared" => { default => 0, description => "show shared functions between Win16 and Win32" },
  37. "shared-segmented" => { default => 0, description => "segmented shared functions between Win16 and Win32 checking" },
  38. "config" => { default => 1, parent => "local", description => "check configuration include consistency" },
  39. "config-unnecessary" => { default => 0, parent => "config", description => "check for unnecessary #include \"config.h\"" },
  40. "spec-mismatch" => { default => 0, description => "spec file mismatch checking" },
  41. "local" => { default => 1, description => "local checking" },
  42. "module" => {
  43. default => { active => 1, filter => 0, hash => {} },
  44. parent => "local",
  45. parser => \&parse_comma_list,
  46. description => "module filter"
  47. },
  48. "argument" => { default => 1, parent => "local", description => "argument checking" },
  49. "argument-count" => { default => 1, parent => "argument", description => "argument count checking" },
  50. "argument-forbidden" => {
  51. default => { active => 1, filter => 0, hash => {} },
  52. parent => "argument",
  53. parser => \&parse_comma_list,
  54. description => "argument forbidden checking"
  55. },
  56. "argument-kind" => {
  57. default => { active => 1, filter => 1, hash => { double => 1 } },
  58. parent => "argument",
  59. parser => \&parse_comma_list,
  60. description => "argument kind checking"
  61. },
  62. "calling-convention" => { default => 1, parent => "local", description => "calling convention checking" },
  63. "calling-convention-win16" => { default => 0, parent => "calling-convention", description => "calling convention checking (Win16)" },
  64. "calling-convention-win32" => { default => 1, parent => "calling-convention", description => "calling convention checking (Win32)" },
  65. "misplaced" => { default => 1, parent => "local", description => "check for misplaced functions" },
  66. "statements" => { default => 0, parent => "local", description => "check for statements inconsistencies" },
  67. "cross-call" => { default => 0, parent => ["statements", "win16", "win32"], description => "check for cross calling functions" },
  68. "cross-call-win32-win16" => {
  69. default => 0, parent => "cross-call", description => "check for cross calls between win32 and win16"
  70. },
  71. "cross-call-unicode-ascii" => {
  72. default => 0, parent => "cross-call", description => "check for cross calls between Unicode and ASCII"
  73. },
  74. "debug-messages" => { default => 0, parent => "statements", description => "check for debug messages inconsistencies" },
  75. "comments" => {
  76. default => 1,
  77. parent => "local",
  78. description => "comments checking"
  79. },
  80. "comments-cplusplus" => {
  81. default => 1,
  82. parent => "comments",
  83. description => "C++ comments checking"
  84. },
  85. "documentation" => {
  86. default => 1,
  87. parent => "local",
  88. description => "check for documentation inconsistencies"
  89. },
  90. "documentation-pedantic" => {
  91. default => 0,
  92. parent => "documentation",
  93. description => "be pedantic when checking for documentation inconsistencies"
  94. },
  95. "documentation-arguments" => {
  96. default => 1,
  97. parent => "documentation",
  98. description => "check for arguments documentation inconsistencies\n"
  99. },
  100. "documentation-comment-indent" => {
  101. default => 0,
  102. parent => "documentation", description => "check for documentation comment indent inconsistencies"
  103. },
  104. "documentation-comment-width" => {
  105. default => 0,
  106. parent => "documentation", description => "check for documentation comment width inconsistencies"
  107. },
  108. "documentation-name" => {
  109. default => 1,
  110. parent => "documentation",
  111. description => "check for documentation name inconsistencies\n"
  112. },
  113. "documentation-ordinal" => {
  114. default => 1,
  115. parent => "documentation",
  116. description => "check for documentation ordinal inconsistencies\n"
  117. },
  118. "documentation-wrong" => {
  119. default => 1,
  120. parent => "documentation",
  121. description => "check for wrong documentation\n"
  122. },
  123. "prototype" => {default => 0, parent => ["local", "headers"], description => "prototype checking" },
  124. "global" => { default => 1, description => "global checking" },
  125. "declared" => { default => 1, parent => "global", description => "declared checking" },
  126. "implemented" => { default => 0, parent => "local", description => "implemented checking" },
  127. "implemented-win32" => { default => 0, parent => "implemented", description => "implemented as win32 checking" },
  128. "include" => { default => 1, parent => "global", description => "include checking" },
  129. "headers" => { default => 0, description => "headers checking" },
  130. "headers-duplicated" => { default => 0, parent => "headers", description => "duplicated function declarations checking" },
  131. "headers-misplaced" => { default => 0, parent => "headers", description => "misplaced function declarations checking" },
  132. "headers-needed" => { default => 1, parent => "headers", description => "headers needed checking" },
  133. "headers-unused" => { default => 0, parent => "headers", description => "headers unused checking" },
  134. );
  135. my %options_short = (
  136. "d" => "debug",
  137. "?" => "help",
  138. "v" => "verbose"
  139. );
  140. my $options_usage = "usage: winapi_check [--help] [<files>]\n";
  141. $options = '_winapi_check_options'->new(\%options_long, \%options_short, $options_usage);
  142. package _winapi_check_options;
  143. use strict;
  144. use warnings 'all';
  145. use base qw(_options);
  146. sub report_module($$) {
  147. my $self = shift;
  148. my $refvalue = $self->{MODULE};
  149. my $name = shift;
  150. if(defined($name)) {
  151. return $$refvalue->{active} && (!$$refvalue->{filter} || $$refvalue->{hash}->{$name});
  152. } else {
  153. return 0;
  154. }
  155. }
  156. sub report_argument_forbidden($$) {
  157. my $self = shift;
  158. my $refargument_forbidden = $self->{ARGUMENT_FORBIDDEN};
  159. my $type = shift;
  160. return $$refargument_forbidden->{active} && (!$$refargument_forbidden->{filter} || $$refargument_forbidden->{hash}->{$type});
  161. }
  162. sub report_argument_kind($$) {
  163. my $self = shift;
  164. my $refargument_kind = $self->{ARGUMENT_KIND};
  165. my $kind = shift;
  166. return $$refargument_kind->{active} && (!$$refargument_kind->{filter} || $$refargument_kind->{hash}->{$kind});
  167. }
  168. 1;