Fix handle conversions.
[wine/wine64.git] / tools / winapi_check / winapi_c_parser.pm
blobefeb73e4a755625fbb72de4915af3d519778c37a
2 # Copyright 1999, 2000, 2001 Patrik Stridvall
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.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 package winapi_c_parser;
21 use strict;
23 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
24 require Exporter;
26 @ISA = qw(Exporter);
27 @EXPORT = qw();
28 @EXPORT_OK = qw();
30 use options qw($options);
31 use output qw($output);
33 use c_function;
34 use c_type;
35 use function;
36 use winapi_function;
37 use winapi_parser;
39 ########################################################################
40 # new
42 sub new {
43 my $proto = shift;
44 my $class = ref($proto) || $proto;
45 my $self = {};
46 bless ($self, $class);
48 my $file = \${$self->{FILE}};
49 my $create_function = \${$self->{CREATE_FUNCTION}};
50 my $create_type = \${$self->{CREATE_TYPE}};
51 my $found_comment = \${$self->{FOUND_COMMENT}};
52 my $found_declaration = \${$self->{FOUND_DECLARATION}};
53 my $found_function = \${$self->{FOUND_FUNCTION}};
54 my $found_function_call = \${$self->{FOUND_FUNCTION_CALL}};
55 my $found_line = \${$self->{FOUND_LINE}};
56 my $found_preprocessor = \${$self->{FOUND_PREPROCESSOR}};
57 my $found_statement = \${$self->{FOUND_STATEMENT}};
58 my $found_type = \${$self->{FOUND_TYPE}};
59 my $found_variable = \${$self->{FOUND_VARIABLE}};
61 $$file = shift;
63 $$create_function = sub { return new c_function; };
64 $$create_type = sub { return new c_type; };
65 $$found_comment = sub { return 1; };
66 $$found_declaration = sub { return 1; };
67 $$found_function = sub { return 1; };
68 $$found_function_call = sub { return 1; };
69 $$found_line = sub { return 1; };
70 $$found_preprocessor = sub { return 1; };
71 $$found_statement = sub { return 1; };
72 $$found_type = sub { return 1; };
73 $$found_variable = sub { return 1; };
75 return $self;
78 ########################################################################
79 # set_found_comment_callback
81 sub set_found_comment_callback {
82 my $self = shift;
84 my $found_comment = \${$self->{FOUND_COMMENT}};
86 $$found_comment = shift;
89 ########################################################################
90 # set_found_declaration_callback
92 sub set_found_declaration_callback {
93 my $self = shift;
95 my $found_declaration = \${$self->{FOUND_DECLARATION}};
97 $$found_declaration = shift;
100 ########################################################################
101 # set_found_function_callback
103 sub set_found_function_callback {
104 my $self = shift;
106 my $found_function = \${$self->{FOUND_FUNCTION}};
108 $$found_function = shift;
111 ########################################################################
112 # set_found_function_call_callback
114 sub set_found_function_call_callback {
115 my $self = shift;
117 my $found_function_call = \${$self->{FOUND_FUNCTION_CALL}};
119 $$found_function_call = shift;
122 ########################################################################
123 # set_found_line_callback
125 sub set_found_line_callback {
126 my $self = shift;
128 my $found_line = \${$self->{FOUND_LINE}};
130 $$found_line = shift;
133 ########################################################################
134 # set_found_preprocessor_callback
136 sub set_found_preprocessor_callback {
137 my $self = shift;
139 my $found_preprocessor = \${$self->{FOUND_PREPROCESSOR}};
141 $$found_preprocessor = shift;
144 ########################################################################
145 # set_found_statement_callback
147 sub set_found_statement_callback {
148 my $self = shift;
150 my $found_statement = \${$self->{FOUND_STATEMENT}};
152 $$found_statement = shift;
155 ########################################################################
156 # set_found_type_callback
158 sub set_found_type_callback {
159 my $self = shift;
161 my $found_type = \${$self->{FOUND_TYPE}};
163 $$found_type = shift;
166 ########################################################################
167 # set_found_variable_callback
169 sub set_found_variable_callback {
170 my $self = shift;
172 my $found_variable = \${$self->{FOUND_VARIABLE}};
174 $$found_variable = shift;
177 ########################################################################
178 # parse_c_file
180 sub parse_c_file {
181 my $self = shift;
183 my $file = \${$self->{FILE}};
185 my $found_comment = \${$self->{FOUND_COMMENT}};
186 my $found_declaration = \${$self->{FOUND_DECLARATION}};
187 my $create_function = \${$self->{CREATE_FUNCTION}};
188 my $found_function = \${$self->{FOUND_FUNCTION}};
189 my $found_function_call = \${$self->{FOUND_FUNCTION_CALL}};
190 my $found_line = \${$self->{FOUND_LINE}};
191 my $found_preprocessor = \${$self->{FOUND_PREPROCESSOR}};
192 my $found_statement = \${$self->{FOUND_STATEMENT}};
193 my $found_variable = \${$self->{FOUND_VARIABLE}};
195 my $refcurrent = shift;
196 my $refline = shift;
197 my $refcolumn = shift;
199 my $_create_function = sub {
200 return 'function'->new;
203 my $_create_type = sub {
204 return 'type'->new;
207 my $_found_function = sub {
208 my $old_function = shift;
210 my $function = new c_function;
212 $function->begin_line($old_function->function_line);
213 $function->begin_column(0);
214 $function->end_line($old_function->function_line);
215 $function->end_column(0);
217 $function->linkage($old_function->linkage);
218 $function->return_type($old_function->return_type);
219 $function->calling_convention($old_function->calling_convention);
220 $function->name($old_function->internal_name);
222 &$$found_function($function);
225 my $_found_preprocessor = sub {
226 my $directive = shift;
227 my $argument = shift;
229 my $begin_line = 0;
230 my $begin_column = 0;
231 my $preprocessor = "#$directive $argument";
233 &$$found_preprocessor($begin_line, $begin_column, $preprocessor);
236 my $_found_type = sub {
237 my $type = shift;
240 &winapi_parser::parse_c_file($$file, {
241 # c_comment_found => $found_c_comment,
242 # cplusplus_comment_found => $found_cplusplus_comment,
243 function_create => $_create_function,
244 function_found => $_found_function,
245 preprocessor_found => $_found_preprocessor,
246 type_create => $_create_type,
247 type_found => $_found_type,