winapi_check_options.pm 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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 base qw(options);
  20. use strict;
  21. use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
  22. require Exporter;
  23. @ISA = qw(Exporter);
  24. @EXPORT = qw();
  25. @EXPORT_OK = qw($options);
  26. use config qw($current_dir $wine_dir);
  27. use options qw($options parse_comma_list);
  28. my %options_long = (
  29. "debug" => { default => 0, description => "debug mode" },
  30. "help" => { default => 0, description => "help mode" },
  31. "verbose" => { default => 0, description => "verbose mode" },
  32. "progress" => { default => 1, description => "show progress" },
  33. "win16" => { default => 1, description => "Win16 checking" },
  34. "win32" => { default => 1, description => "Win32 checking" },
  35. "shared" => { default => 0, description => "show shared functions between Win16 and Win32" },
  36. "shared-segmented" => { default => 0, description => "segmented shared functions between Win16 and Win32 checking" },
  37. "config" => { default => 1, parent => "local", description => "check configuration include consistency" },
  38. "config-unnecessary" => { default => 0, parent => "config", description => "check for unnecessary #include \"config.h\"" },
  39. "spec-mismatch" => { default => 0, description => "spec file mismatch checking" },
  40. "local" => { default => 1, description => "local checking" },
  41. "module" => {
  42. default => { active => 1, filter => 0, hash => {} },
  43. parent => "local",
  44. parser => \&parse_comma_list,
  45. description => "module filter"
  46. },
  47. "argument" => { default => 1, parent => "local", description => "argument checking" },
  48. "argument-count" => { default => 1, parent => "argument", description => "argument count checking" },
  49. "argument-forbidden" => {
  50. default => { active => 1, filter => 0, hash => {} },
  51. parent => "argument",
  52. parser => \&parse_comma_list,
  53. description => "argument forbidden checking"
  54. },
  55. "argument-kind" => {
  56. default => { active => 1, filter => 1, hash => { double => 1 } },
  57. parent => "argument",
  58. parser => \&parse_comma_list,
  59. description => "argument kind checking"
  60. },
  61. "calling-convention" => { default => 1, parent => "local", description => "calling convention checking" },
  62. "calling-convention-win16" => { default => 0, parent => "calling-convention", description => "calling convention checking (Win16)" },
  63. "calling-convention-win32" => { default => 1, parent => "calling-convention", description => "calling convention checking (Win32)" },
  64. "misplaced" => { default => 1, parent => "local", description => "check for misplaced functions" },
  65. "statements" => { default => 0, parent => "local", description => "check for statements inconsistencies" },
  66. "cross-call" => { default => 0, parent => ["statements", "win16", "win32"], description => "check for cross calling functions" },
  67. "cross-call-win32-win16" => {
  68. default => 0, parent => "cross-call", description => "check for cross calls between win32 and win16"
  69. },
  70. "cross-call-unicode-ascii" => {
  71. default => 0, parent => "cross-call", description => "check for cross calls between Unicode and ASCII"
  72. },
  73. "debug-messages" => { default => 0, parent => "statements", description => "check for debug messages inconsistencies" },
  74. "comments" => {
  75. default => 1,
  76. parent => "local",
  77. description => "comments checking"
  78. },
  79. "comments-cplusplus" => {
  80. default => 1,
  81. parent => "comments",
  82. description => "C++ comments checking"
  83. },
  84. "documentation" => {
  85. default => 1,
  86. parent => "local",
  87. description => "check for documentation inconsistencies"
  88. },
  89. "documentation-pedantic" => {
  90. default => 0,
  91. parent => "documentation",
  92. description => "be pedantic when checking for documentation inconsistencies"
  93. },
  94. "documentation-arguments" => {
  95. default => 1,
  96. parent => "documentation",
  97. description => "check for arguments documentation inconsistencies\n"
  98. },
  99. "documentation-comment-indent" => {
  100. default => 0,
  101. parent => "documentation", description => "check for documentation comment indent inconsistencies"
  102. },
  103. "documentation-comment-width" => {
  104. default => 0,
  105. parent => "documentation", description => "check for documentation comment width inconsistencies"
  106. },
  107. "documentation-name" => {
  108. default => 1,
  109. parent => "documentation",
  110. description => "check for documentation name inconsistencies\n"
  111. },
  112. "documentation-ordinal" => {
  113. default => 1,
  114. parent => "documentation",
  115. description => "check for documentation ordinal inconsistencies\n"
  116. },
  117. "documentation-wrong" => {
  118. default => 1,
  119. parent => "documentation",
  120. description => "check for wrong documentation\n"
  121. },
  122. "prototype" => {default => 0, parent => ["local", "headers"], description => "prototype checking" },
  123. "global" => { default => 1, description => "global checking" },
  124. "declared" => { default => 1, parent => "global", description => "declared checking" },
  125. "implemented" => { default => 0, parent => "local", description => "implemented checking" },
  126. "implemented-win32" => { default => 0, parent => "implemented", description => "implemented as win32 checking" },
  127. "include" => { default => 1, parent => "global", description => "include checking" },
  128. "headers" => { default => 0, description => "headers checking" },
  129. "headers-duplicated" => { default => 0, parent => "headers", description => "duplicated function declarations checking" },
  130. "headers-misplaced" => { default => 0, parent => "headers", description => "misplaced function declarations checking" },
  131. "headers-needed" => { default => 1, parent => "headers", description => "headers needed checking" },
  132. "headers-unused" => { default => 0, parent => "headers", description => "headers unused checking" },
  133. );
  134. my %options_short = (
  135. "d" => "debug",
  136. "?" => "help",
  137. "v" => "verbose"
  138. );
  139. my $options_usage = "usage: winapi_check [--help] [<files>]\n";
  140. $options = '_winapi_check_options'->new(\%options_long, \%options_short, $options_usage);
  141. package _winapi_check_options;
  142. use base qw(_options);
  143. use strict;
  144. sub report_module($$) {
  145. my $self = shift;
  146. my $refvalue = $self->{MODULE};
  147. my $name = shift;
  148. if(defined($name)) {
  149. return $$refvalue->{active} && (!$$refvalue->{filter} || $$refvalue->{hash}->{$name});
  150. } else {
  151. return 0;
  152. }
  153. }
  154. sub report_argument_forbidden($$) {
  155. my $self = shift;
  156. my $refargument_forbidden = $self->{ARGUMENT_FORBIDDEN};
  157. my $type = shift;
  158. return $$refargument_forbidden->{active} && (!$$refargument_forbidden->{filter} || $$refargument_forbidden->{hash}->{$type});
  159. }
  160. sub report_argument_kind($$) {
  161. my $self = shift;
  162. my $refargument_kind = $self->{ARGUMENT_KIND};
  163. my $kind = shift;
  164. return $$refargument_kind->{active} && (!$$refargument_kind->{filter} || $$refargument_kind->{hash}->{$kind});
  165. }
  166. 1;