Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #include <idlc/errorhandler.hxx>
21 : : #include <idlc/astinterface.hxx>
22 : :
23 : : using namespace ::rtl;
24 : :
25 : 0 : static const sal_Char* errorCodeToMessage(ErrorCode eCode)
26 : : {
27 [ # # # # : 0 : switch (eCode)
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # ]
28 : : {
29 : : case EIDL_NONE:
30 : 0 : return "all is fine ";
31 : : case EIDL_SYNTAX_ERROR:
32 : 0 : return "";
33 : : case EIDL_REDEF:
34 : 0 : return "illegal redefinition ";
35 : : case EIDL_REDEF_SCOPE:
36 : 0 : return "illegal redefinition in scope ";
37 : : case EIDL_DEF_USE:
38 : 0 : return "redefinition after use, ";
39 : : case EIDL_MULTIPLE_BRANCH:
40 : 0 : return "union with duplicate branch label ";
41 : : case EIDL_COERCION_FAILURE:
42 : 0 : return "coercion failure ";
43 : : case EIDL_SCOPE_CONFLICT:
44 : 0 : return "definition scope is different than fwd declare scope, ";
45 : : case EIDL_ONEWAY_CONFLICT:
46 : 0 : return "oneway operation with OUT|INOUT parameters or raises exceptions, ";
47 : : case EIDL_DISC_TYPE:
48 : 0 : return "union with illegal discriminator type, ";
49 : : case EIDL_LABEL_TYPE:
50 : 0 : return "label type incompatible with union discriminator type, ";
51 : : case EIDL_ILLEGAL_ADD:
52 : 0 : return "illegal add operation, ";
53 : : case EIDL_ILLEGAL_USE:
54 : 0 : return "illegal type used in expression, ";
55 : : case EIDL_ILLEGAL_RAISES:
56 : 0 : return "non-exception type in raises(..) clause, ";
57 : : case EIDL_CANT_INHERIT:
58 : 0 : return "cannot inherit ";
59 : : case EIDL_LOOKUP_ERROR:
60 : 0 : return "error in lookup of symbol: ";
61 : : case EIDL_INHERIT_FWD_ERROR:
62 : 0 : return "";
63 : : case EIDL_CONSTANT_EXPECTED:
64 : 0 : return "constant expected: ";
65 : : case EIDL_NAME_CASE_ERROR:
66 : 0 : return "identifier used with two differing spellings: ";
67 : : case EIDL_ENUM_VAL_EXPECTED:
68 : 0 : return "enumerator expected: ";
69 : : case EIDL_ENUM_VAL_NOT_FOUND:
70 : 0 : return "enumerator by this name not defined: ";
71 : : case EIDL_EVAL_ERROR:
72 : 0 : return "expression evaluation error: ";
73 : : case EIDL_AMBIGUOUS:
74 : 0 : return "ambiguous definition: ";
75 : : case EIDL_DECL_NOT_DEFINED:
76 : 0 : return "forward declared but never defined: ";
77 : : case EIDL_FWD_DECL_LOOKUP:
78 : 0 : return "";
79 : : case EIDL_RECURSIVE_TYPE:
80 : 0 : return "illegal recursive use of type: ";
81 : : case EIDL_NONVOID_ONEWAY:
82 : 0 : return "non-void return type in oneway operation: ";
83 : : case EIDL_NOT_A_TYPE:
84 : 0 : return "specified symbol is not a type: ";
85 : : case EIDL_TYPE_NOT_VALID:
86 : 0 : return "specified type is not valid in this context: ";
87 : : case EIDL_INTERFACEMEMBER_LOOKUP:
88 : 0 : return "error in lookup of symbol, expected interface is not defined and no forward exists: ";
89 : : case EIDL_SERVICEMEMBER_LOOKUP:
90 : 0 : return "error in lookup of symbol, expected service is not defined: ";
91 : : case EIDL_TYPE_IDENT_CONFLICT:
92 : 0 : return "type and parameter/member name are equal: ";
93 : : case EIDL_ONEWAY_RAISE_CONFLICT:
94 : 0 : return "oneway operation cannot raises exceptions: ";
95 : : case EIDL_WRONGATTRIBUTEFLAG:
96 : 0 : return "the used flag is not valid in this context: ";
97 : : case EIDL_DEFINED_ATTRIBUTEFLAG:
98 : 0 : return "flag is already set: ";
99 : : case EIDL_WRONGATTRIBUTEKEYWORD:
100 : 0 : return "keyword not allowed: ";
101 : : case EIDL_MISSINGATTRIBUTEKEYWORD:
102 : 0 : return "missing keyword: ";
103 : : case EIDL_BAD_ATTRIBUTE_FLAGS:
104 : : return
105 : : "the 'attribute' flag is mandatory, and only the 'bound' and"
106 : 0 : " 'readonly' optional flags are accepted: ";
107 : : case EIDL_OPTIONALEXPECTED:
108 : 0 : return "only the 'optional' flag is accepted: ";
109 : : case EIDL_MIXED_INHERITANCE:
110 : : return "interface inheritance declarations cannot appear in both an"
111 : 0 : " interface's header and its body";
112 : : case EIDL_DOUBLE_INHERITANCE:
113 : : return
114 : 0 : "interface is (directly or indirectly) inherited more than once: ";
115 : : case EIDL_DOUBLE_MEMBER:
116 : : return
117 : 0 : "member is (directly or indirectly) declared more than once: ";
118 : : case EIDL_CONSTRUCTOR_PARAMETER_NOT_IN:
119 : : return
120 : : "a service constructor parameter may not be an out or inout"
121 : 0 : " parameter";
122 : : case EIDL_CONSTRUCTOR_REST_PARAMETER_NOT_FIRST:
123 : : return
124 : : "no parameters may precede a rest parameter in a service"
125 : 0 : " constructor";
126 : : case EIDL_REST_PARAMETER_NOT_LAST:
127 : 0 : return "no parameters may follow a rest parameter";
128 : : case EIDL_REST_PARAMETER_NOT_ANY:
129 : 0 : return "a rest parameter must be of type any";
130 : : case EIDL_METHOD_HAS_REST_PARAMETER:
131 : 0 : return "a rest parameter may not be used on an interface method";
132 : : case EIDL_READONLY_ATTRIBUTE_SET_EXCEPTIONS:
133 : 0 : return "a readonly attribute may not have a setter raises clause";
134 : : case EIDL_UNSIGNED_TYPE_ARGUMENT:
135 : 0 : return "an unsigned type cannot be used as a type argument";
136 : : case EIDL_WRONG_NUMBER_OF_TYPE_ARGUMENTS:
137 : : return
138 : : "the number of given type arguments does not match the expected"
139 : 0 : " number of type parameters";
140 : : case EIDL_INSTANTIATED_STRUCT_TYPE_TYPEDEF:
141 : : return
142 : : "an instantiated polymorphic struct type cannot be used in a"
143 : 0 : " typedef";
144 : : case EIDL_IDENTICAL_TYPE_PARAMETERS:
145 : 0 : return "two type parameters have the same name";
146 : : case EIDL_STRUCT_TYPE_TEMPLATE_WITH_BASE:
147 : 0 : return "a polymorphic struct type template may not have a base type";
148 : : case EIDL_PUBLISHED_FORWARD:
149 : : return
150 : : "a published forward declaration of an interface type cannot be"
151 : 0 : " followed by an unpublished declaration of that type";
152 : : case EIDL_PUBLISHED_USES_UNPUBLISHED:
153 : : return
154 : : "an unpublished entity cannot be used in the declaration of a"
155 : 0 : " published entity: ";
156 : : case EIDL_SIMILAR_CONSTRUCTORS:
157 : 0 : return "two constructors have identical lists of parameter types";
158 : : }
159 : 0 : return "unknown errror";
160 : : }
161 : :
162 : 0 : static const sal_Char* warningCodeToMessage(WarningCode wCode)
163 : : {
164 [ # # # # : 0 : switch (wCode)
# # ]
165 : : {
166 : : case WIDL_EXPID_CONFLICT:
167 : 0 : return "exception id conflict: ";
168 : : case WIDL_REQID_CONFLICT:
169 : 0 : return "request id conflict: ";
170 : : case WIDL_INHERIT_IDCONFLICT:
171 : 0 : return "request id conflict in inheritance tree: ";
172 : : case WIDL_TYPE_IDENT_CONFLICT:
173 : 0 : return "type and parameter|member name are equal: ";
174 : : case WIDL_WRONG_NAMING_CONV:
175 : 0 : return "type or identifier doesn't fulfill the UNO naming convention: ";
176 : : }
177 : 0 : return "unkown warning";
178 : : }
179 : :
180 : 0 : static const sal_Char* parseStateToMessage(ParseState state)
181 : : {
182 [ # # # # : 0 : switch (state)
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # ]
183 : : {
184 : : case PS_NoState:
185 : 0 : return "Statement can not be parsed";
186 : : case PS_TypeDeclSeen:
187 : 0 : return "Malformed type declaration";
188 : : case PS_ConstantDeclSeen:
189 : 0 : return "Malformed const declaration";
190 : : case PS_ExceptionDeclSeen:
191 : 0 : return "Malformed exception declaration";
192 : : case PS_InterfaceDeclSeen:
193 : 0 : return "Malformed interface declaration";
194 : : case PS_ServiceDeclSeen:
195 : 0 : return "Malformed servicve declaration";
196 : : case PS_ModuleDeclSeen:
197 : 0 : return "Malformed module declaration";
198 : : case PS_AttributeDeclSeen:
199 : 0 : return "Malformed attribute declaration";
200 : : case PS_PropertyDeclSeen:
201 : 0 : return "Malformed property declaration";
202 : : case PS_OperationDeclSeen:
203 : 0 : return "Malformed operation declaration";
204 : : case PS_InterfaceInheritanceDeclSeen:
205 : 0 : return "Malformed interface inheritance declaration";
206 : : case PS_ConstantsDeclSeen:
207 : 0 : return "Malformed constants declaration";
208 : : case PS_ServiceSeen:
209 : 0 : return "Missing service identifier following SERVICE keyword";
210 : : case PS_ServiceIDSeen:
211 : 0 : return "Missing '{' or illegal syntax following service identifier";
212 : : case PS_ServiceSqSeen:
213 : 0 : return "Illegal syntax following service '{' opener";
214 : : case PS_ServiceBodySeen:
215 : 0 : return "Illegal syntax following service '}' closer";
216 : : case PS_ServiceMemberSeen:
217 : 0 : return "Illegal syntax following service member declaration";
218 : : case PS_ServiceIFHeadSeen:
219 : 0 : return "Illegal syntax following header of an interface member";
220 : : case PS_ServiceSHeadSeen:
221 : 0 : return "Illegal syntax following header of an service member";
222 : : case PS_ModuleSeen:
223 : 0 : return "Missing module identifier following MODULE keyword";
224 : : case PS_ModuleIDSeen:
225 : 0 : return "Missing '{' or illegal syntax following module identifier";
226 : : case PS_ModuleSqSeen:
227 : 0 : return "Illegal syntax following module '{' opener";
228 : : case PS_ModuleQsSeen:
229 : 0 : return "Illegal syntax following module '}' closer";
230 : : case PS_ModuleBodySeen:
231 : 0 : return "Illegal syntax following module export(s)";
232 : : case PS_ConstantsSeen:
233 : 0 : return "Missing constants identifier following CONSTANTS keyword";
234 : : case PS_ConstantsIDSeen:
235 : 0 : return "Missing '{' or illegal syntax following constants identifier";
236 : : case PS_ConstantsSqSeen:
237 : 0 : return "Illegal syntax following module '{' opener";
238 : : case PS_ConstantsQsSeen:
239 : 0 : return "Illegal syntax following module '}' closer";
240 : : case PS_ConstantsBodySeen:
241 : 0 : return "Illegal syntax following constants export(s)";
242 : : case PS_InterfaceSeen:
243 : 0 : return "Missing interface identifier following INTERFACE keyword";
244 : : case PS_InterfaceIDSeen:
245 : 0 : return "Illegal syntax following interface identifier";
246 : : case PS_InterfaceHeadSeen:
247 : 0 : return "Illegal syntax following interface head";
248 : : case PS_InheritSpecSeen:
249 : 0 : return "Missing '{' or illegal syntax following inheritance spec";
250 : : case PS_ForwardDeclSeen:
251 : 0 : return "Missing ';' following forward interface declaration";
252 : : case PS_InterfaceSqSeen:
253 : 0 : return "Illegal syntax following interface '{' opener";
254 : : case PS_InterfaceQsSeen:
255 : 0 : return "Illegal syntax following interface '}' closer";
256 : : case PS_InterfaceBodySeen:
257 : 0 : return "Illegal syntax following interface export(s)";
258 : : case PS_InheritColonSeen:
259 : 0 : return "Illegal syntax following ':' starting inheritance list";
260 : : case PS_SNListCommaSeen:
261 : 0 : return "Found illegal scoped name in scoped name list";
262 : : case PS_ScopedNameSeen:
263 : 0 : return "Missing ',' following scoped name in scoped name list";
264 : : case PS_SN_IDSeen:
265 : 0 : return "Illegal component in scoped name";
266 : : case PS_ScopeDelimSeen:
267 : 0 : return "Illegal component in scoped name following '::'";
268 : : case PS_ConstSeen:
269 : 0 : return "Missing type or illegal syntax following CONST keyword";
270 : : case PS_ConstTypeSeen:
271 : 0 : return "Missing identifier or illegal syntax following const type";
272 : : case PS_ConstIDSeen:
273 : 0 : return "Missing '=' or illegal syntax after const identifier";
274 : : case PS_ConstAssignSeen:
275 : 0 : return "Missing value expr or illegal syntax following '='";
276 : : case PS_ConstExprSeen:
277 : 0 : return "Missing ';' or illegal syntax following value expr in const";
278 : : case PS_TypedefSeen:
279 : 0 : return "Missing type or illegal syntax following TYPEDEF keyword";
280 : : case PS_TypeSpecSeen:
281 : 0 : return "Missing declarators or illegal syntax following type spec";
282 : : case PS_DeclaratorsSeen:
283 : 0 : return "Illegal syntax following declarators in TYPEDEF declaration";
284 : : case PS_StructSeen:
285 : 0 : return "Missing struct identifier following STRUCT keyword";
286 : : case PS_StructHeaderSeen:
287 : 0 : return "Missing '{' or illegal syntax following struct inheritance spec";
288 : : case PS_StructIDSeen:
289 : 0 : return "Missing '{' or illegal syntax following struct identifier";
290 : : case PS_StructSqSeen:
291 : 0 : return "Illegal syntax following struct '{' opener";
292 : : case PS_StructQsSeen:
293 : 0 : return "Illegal syntax following struct '}' closer";
294 : : case PS_StructBodySeen:
295 : 0 : return "Illegal syntax following struct member(s)";
296 : : case PS_MemberTypeSeen:
297 : 0 : return "Illegal syntax or missing identifier following member type";
298 : : case PS_MemberDeclsSeen:
299 : 0 : return "Illegal syntax following member declarator(s)";
300 : : case PS_MemberDeclsCompleted:
301 : 0 : return "Missing ',' between member decls of same type(?)";
302 : : case PS_UnionSeen:
303 : 0 : return "Missing identifier following UNION keyword";
304 : : case PS_UnionIDSeen:
305 : 0 : return "Illegal syntax following union identifier";
306 : : case PS_SwitchSeen:
307 : 0 : return "Illegal syntax following SWITCH keyword";
308 : : case PS_SwitchOpenParSeen:
309 : 0 : return "Illegal syntax following '(' in switch in union";
310 : : case PS_SwitchTypeSeen:
311 : 0 : return "Illegal syntax following type decl in switch in union";
312 : : case PS_SwitchCloseParSeen:
313 : 0 : return "Missing union '{' opener";
314 : : case PS_UnionSqSeen:
315 : 0 : return "Illegal syntax following union '{' opener";
316 : : case PS_UnionQsSeen:
317 : 0 : return "Illegal syntax following union '}' closer";
318 : : case PS_DefaultSeen:
319 : 0 : return "Illegal syntax or missing ':' following DEFAULT keyword";
320 : : case PS_UnionLabelSeen:
321 : 0 : return "Illegal syntax following branch label in union";
322 : : case PS_LabelColonSeen:
323 : 0 : return "Illegal syntax following ':' in branch label in union";
324 : : case PS_LabelExprSeen:
325 : 0 : return "Illegal syntax following label expression in union";
326 : : case PS_UnionElemSeen:
327 : : case PS_UnionElemCompleted:
328 : 0 : return "Illegal syntax following union element";
329 : : case PS_CaseSeen:
330 : 0 : return "Illegal syntax following CASE keyword in union";
331 : : case PS_UnionElemTypeSeen:
332 : 0 : return "Illegal syntax following type decl in union element";
333 : : case PS_UnionElemDeclSeen:
334 : 0 : return "Illegal syntax following declarator in union element";
335 : : case PS_UnionBodySeen:
336 : 0 : return "Illegal syntax following union body statement(s)";
337 : : case PS_EnumSeen:
338 : 0 : return "Illegal syntax or missing identifier following ENUM keyword";
339 : : case PS_EnumIDSeen:
340 : 0 : return "Illegal syntax or missing '{' following enum identifier";
341 : : case PS_EnumSqSeen:
342 : 0 : return "Illegal syntax following enum '{' opener";
343 : : case PS_EnumQsSeen:
344 : 0 : return "Illegal syntax following enum '}' closer";
345 : : case PS_EnumBodySeen:
346 : 0 : return "Illegal syntax following enum enumerator(s)";
347 : : case PS_EnumCommaSeen:
348 : 0 : return "Illegal syntax or missing identifier following ',' in enum";
349 : : case PS_SequenceSeen:
350 : 0 : return "Illegal syntax or missing '<' following SEQUENCE keyword";
351 : : case PS_SequenceSqSeen:
352 : 0 : return "Illegal syntax or missing type following '<' in sequence";
353 : : case PS_SequenceQsSeen:
354 : 0 : return "Illegal syntax following '>' in sequence";
355 : : case PS_SequenceTypeSeen:
356 : 0 : return "Illegal syntax following sequence type declaration";
357 : : case PS_ArrayIDSeen:
358 : 0 : return "Illegal syntax or missing dimensions after array identifier";
359 : : case PS_ArrayCompleted:
360 : 0 : return "Illegal syntax after array declaration";
361 : : case PS_DimSqSeen:
362 : 0 : return "Illegal syntax or missing size expr after '[' in array declaration";
363 : : case PS_DimQsSeen:
364 : 0 : return "Illegal syntax after ']' in array declaration";
365 : : case PS_DimExprSeen:
366 : 0 : return "Illegal syntax or missing ']' after size expr in array declaration";
367 : : case PS_FlagHeaderSeen:
368 : 0 : return "Illegal syntax after flags";
369 : : case PS_AttrSeen:
370 : 0 : return "Illegal syntax after ATTRIBUTE keyword";
371 : : case PS_AttrTypeSeen:
372 : 0 : return "Illegal syntax after type in attribute declaration";
373 : : case PS_AttrCompleted:
374 : 0 : return "Illegal syntax after attribute declaration";
375 : : case PS_ReadOnlySeen:
376 : 0 : return "Illegal syntax after READONLY keyword";
377 : : case PS_OptionalSeen:
378 : 0 : return "Illegal syntax after OPTIONAL keyword";
379 : : case PS_MayBeVoidSeen:
380 : 0 : return "Illegal syntax after MAYBEVOID keyword";
381 : : case PS_BoundSeen:
382 : 0 : return "Illegal syntax after BOUND keyword";
383 : : case PS_ConstrainedSeen:
384 : 0 : return "Illegal syntax after CONSTRAINED keyword";
385 : : case PS_TransientSeen:
386 : 0 : return "Illegal syntax after TRANSIENT keyword";
387 : : case PS_MayBeAmbigiousSeen:
388 : 0 : return "Illegal syntax after MAYBEAMBIGIOUS keyword";
389 : : case PS_MayBeDefaultSeen:
390 : 0 : return "Illegal syntax after MAYBEDEFAULT keyword";
391 : : case PS_RemoveableSeen:
392 : 0 : return "Illegal syntax after REMOVEABLE keyword";
393 : : case PS_PropertySeen:
394 : 0 : return "Illegal syntax after PROPERTY keyword";
395 : : case PS_PropertyTypeSeen:
396 : 0 : return "Illegal syntax after type in property declaration";
397 : : case PS_PropertyCompleted:
398 : 0 : return "Illegal syntax after property declaration";
399 : : case PS_ExceptSeen:
400 : 0 : return "Illegal syntax or missing identifier after EXCEPTION keyword";
401 : : case PS_ExceptHeaderSeen:
402 : 0 : return "Missing '{' or illegal syntax following exception inheritance spec";
403 : : case PS_ExceptIDSeen:
404 : 0 : return "Illegal syntax or missing '{' after exception identifier";
405 : : case PS_ExceptSqSeen:
406 : 0 : return "Illegal syntax after exception '{' opener";
407 : : case PS_ExceptQsSeen:
408 : 0 : return "Illegal syntax after exception '}' closer";
409 : : case PS_ExceptBodySeen:
410 : 0 : return "Illegal syntax after exception member(s)";
411 : : case PS_OpHeadSeen:
412 : 0 : return "Illegasl syntax after operation header";
413 : : case PS_OpTypeSeen:
414 : 0 : return "Illegal syntax or missing identifier after operation type";
415 : : case PS_OpIDSeen:
416 : 0 : return "Illegal syntax or missing '(' after operation identifier";
417 : : case PS_OpParsCompleted:
418 : 0 : return "Illegal syntax after operation parameter list";
419 : : case PS_OpCompleted:
420 : 0 : return "Illegal syntax after operation declaration";
421 : : case PS_OpSqSeen:
422 : 0 : return "Illegal syntax after operation parameter list '(' opener";
423 : : case PS_OpQsSeen:
424 : 0 : return "Illegal syntax after operation parameter list ')' closer";
425 : : case PS_OpParCommaSeen:
426 : 0 : return "Illegal syntax or missing direction in parameter declaration";
427 : : case PS_OpParDirSeen:
428 : 0 : return "Illegal syntax or missing type in parameter declaration";
429 : : case PS_OpParTypeSeen:
430 : 0 : return "Illegal syntax or missing declarator in parameter declaration";
431 : : case PS_OpParDeclSeen:
432 : 0 : return "Illegal syntax following parameter declarator";
433 : : case PS_OpOnewaySeen:
434 : 0 : return "Illegal syntax after ONEWAY keyword";
435 : : case PS_RaiseSeen:
436 : 0 : return "Illegal syntax or missing '(' after RAISES keyword";
437 : : case PS_RaiseSqSeen:
438 : 0 : return "Illegal syntax after RAISES '(' opener";
439 : : case PS_RaiseQsSeen:
440 : 0 : return "Illegal syntax after RAISES ')' closer";
441 : : case PS_DeclsCommaSeen:
442 : 0 : return "Illegal syntax after ',' in declarators list";
443 : : case PS_DeclsDeclSeen:
444 : 0 : return "Illegal syntax after declarator in declarators list";
445 : : default:
446 : 0 : return "no wider described syntax error";
447 : : }
448 : : }
449 : :
450 : 0 : static OString flagToString(sal_uInt32 flag)
451 : : {
452 : 0 : OString flagStr;
453 [ # # ]: 0 : if ( (flag & AF_READONLY) == AF_READONLY )
454 : 0 : flagStr += "'readonly'";
455 [ # # ]: 0 : if ( (flag & AF_OPTIONAL) == AF_OPTIONAL )
456 : 0 : flagStr += "'optional'";
457 [ # # ]: 0 : if ( (flag & AF_MAYBEVOID) == AF_MAYBEVOID )
458 : 0 : flagStr += "'maybevoid'";
459 [ # # ]: 0 : if ( (flag & AF_BOUND) == AF_BOUND )
460 : 0 : flagStr += "'bound'";
461 [ # # ]: 0 : if ( (flag & AF_CONSTRAINED) == AF_CONSTRAINED )
462 : 0 : flagStr += "'constrained'";
463 [ # # ]: 0 : if ( (flag & AF_TRANSIENT) == AF_TRANSIENT )
464 : 0 : flagStr += "'transient'";
465 [ # # ]: 0 : if ( (flag & AF_MAYBEAMBIGUOUS) == AF_MAYBEAMBIGUOUS )
466 : 0 : flagStr += "'maybeambiguous'";
467 [ # # ]: 0 : if ( (flag & AF_MAYBEDEFAULT) == AF_MAYBEDEFAULT )
468 : 0 : flagStr += "'maybedefault'";
469 [ # # ]: 0 : if ( (flag & AF_REMOVEABLE) == AF_REMOVEABLE )
470 : 0 : flagStr += "'removeable'";
471 [ # # ]: 0 : if ( (flag & AF_ATTRIBUTE) == AF_ATTRIBUTE )
472 : 0 : flagStr += "'attribute'";
473 [ # # ]: 0 : if ( (flag & AF_PROPERTY) == AF_PROPERTY )
474 : 0 : flagStr += "'property'";
475 [ # # ]: 0 : if ( flagStr.isEmpty() )
476 : 0 : flagStr += "'unknown'";
477 : :
478 : 0 : return flagStr;
479 : : }
480 : :
481 : 0 : static void errorHeader(ErrorCode eCode, sal_Int32 lineNumber, sal_uInt32 start, sal_uInt32 end)
482 : : {
483 : 0 : OString file;
484 [ # # ][ # # ]: 0 : if ( idlc()->getFileName() == idlc()->getRealFileName() )
[ # # ]
485 [ # # ]: 0 : file = idlc()->getMainFileName();
486 : : else
487 [ # # ]: 0 : file = idlc()->getFileName();
488 : :
489 : : fprintf(stderr, "%s:%lu [%lu:%lu] : %s", file.getStr(),
490 : : sal::static_int_cast< unsigned long >(lineNumber),
491 : : sal::static_int_cast< unsigned long >(start),
492 : : sal::static_int_cast< unsigned long >(end),
493 [ # # ]: 0 : errorCodeToMessage(eCode));
494 : 0 : }
495 : :
496 : 0 : static void errorHeader(ErrorCode eCode, sal_uInt32 lineNumber)
497 : : {
498 : : errorHeader(eCode, lineNumber,
499 : 0 : idlc()->getOffsetStart(), idlc()->getOffsetEnd());
500 : 0 : }
501 : :
502 : 0 : static void errorHeader(ErrorCode eCode)
503 : : {
504 : 0 : errorHeader(eCode, idlc()->getLineNumber(),
505 : 0 : idlc()->getOffsetStart(), idlc()->getOffsetEnd());
506 : 0 : }
507 : :
508 : 0 : static void warningHeader(WarningCode wCode)
509 : : {
510 : 0 : OString file;
511 [ # # ][ # # ]: 0 : if ( idlc()->getFileName() == idlc()->getRealFileName() )
[ # # ]
512 [ # # ]: 0 : file = idlc()->getMainFileName();
513 : : else
514 [ # # ]: 0 : file = idlc()->getFileName();
515 : :
516 : : fprintf(stderr, "%s(%lu) : WARNING, %s", file.getStr(),
517 : : sal::static_int_cast< unsigned long >(idlc()->getLineNumber()),
518 [ # # ][ # # ]: 0 : warningCodeToMessage(wCode));
519 : 0 : }
520 : :
521 : 0 : void ErrorHandler::error0(ErrorCode e)
522 : : {
523 : 0 : errorHeader(e);
524 : 0 : fprintf(stderr, "\n");
525 : 0 : idlc()->incErrorCount();
526 : 0 : }
527 : :
528 : 0 : void ErrorHandler::error1(ErrorCode e, AstDeclaration const * d)
529 : : {
530 : 0 : errorHeader(e);
531 : 0 : fprintf(stderr, "'%s'\n", d->getScopedName().getStr());
532 : 0 : idlc()->incErrorCount();
533 : 0 : }
534 : :
535 : 0 : void ErrorHandler::error2(
536 : : ErrorCode e, AstDeclaration const * d1, AstDeclaration const * d2)
537 : : {
538 : 0 : errorHeader(e);
539 : 0 : fprintf(stderr, "'%s', '%s'\n", d1->getScopedName().getStr(),
540 : 0 : d2->getScopedName().getStr());
541 : 0 : idlc()->incErrorCount();
542 : 0 : }
543 : :
544 : 0 : void ErrorHandler::error3(ErrorCode e, AstDeclaration* d1, AstDeclaration* d2, AstDeclaration* d3)
545 : : {
546 : 0 : errorHeader(e);
547 : 0 : fprintf(stderr, "'%s', '%s', '%s'\n", d1->getScopedName().getStr(),
548 : 0 : d2->getScopedName().getStr(), d3->getScopedName().getStr());
549 : 0 : idlc()->incErrorCount();
550 : 0 : }
551 : :
552 : 762 : void ErrorHandler::warning0(WarningCode w, const sal_Char* warningmsg)
553 : : {
554 [ + - ][ + - ]: 762 : if ( idlc()->getOptions()->isValid("-w") || idlc()->getOptions()->isValid("-we") ) {
[ + - ][ + - ]
[ + - ][ - + ]
[ + - ][ + - ]
[ + - ][ + - ]
[ - + # #
# # # # #
# ]
555 : 0 : warningHeader(w);
556 : 0 : fprintf(stderr, "%s\n", warningmsg);
557 : : }
558 : :
559 [ + - ][ + - ]: 762 : if ( idlc()->getOptions()->isValid("-we") )
[ - + ]
560 : 0 : idlc()->incErrorCount();
561 : : else
562 : 762 : idlc()->incWarningCount();
563 : 762 : }
564 : :
565 : 0 : void ErrorHandler::syntaxError(ParseState ps, sal_Int32 lineNumber, const sal_Char* errmsg)
566 : : {
567 : 0 : errorHeader(EIDL_SYNTAX_ERROR, lineNumber);
568 : 0 : fprintf(stderr, "%s: %s\n", parseStateToMessage(ps), errmsg);
569 : 0 : idlc()->incErrorCount();
570 : 0 : }
571 : :
572 : 0 : void ErrorHandler::coercionError(AstExpression *pExpr, ExprType et)
573 : : {
574 : 0 : errorHeader(EIDL_COERCION_FAILURE);
575 : : fprintf(stderr, "'%s' to '%s'\n", pExpr->toString().getStr(),
576 [ # # ]: 0 : exprTypeToString(et));
577 : 0 : idlc()->incErrorCount();
578 : 0 : }
579 : :
580 : 0 : void ErrorHandler::lookupError(const ::rtl::OString& n)
581 : : {
582 : 0 : errorHeader(EIDL_LOOKUP_ERROR);
583 : 0 : fprintf(stderr, "'%s'\n", n.getStr());
584 : 0 : idlc()->incErrorCount();
585 : 0 : }
586 : :
587 : 0 : void ErrorHandler::lookupError(ErrorCode e, const ::rtl::OString& n, AstDeclaration* pScope)
588 : : {
589 : 0 : errorHeader(e);
590 : 0 : fprintf(stderr, "'%s' in '%s'\n", n.getStr(), pScope->getFullName().getStr());
591 : 0 : idlc()->incErrorCount();
592 : 0 : }
593 : :
594 : 0 : void ErrorHandler::flagError(ErrorCode e, sal_uInt32 flag)
595 : : {
596 : 0 : errorHeader(e);
597 [ # # ]: 0 : fprintf(stderr, "'%s'\n", flagToString(flag).getStr());
598 : 0 : idlc()->incErrorCount();
599 : 0 : }
600 : :
601 : 0 : void ErrorHandler::noTypeError(AstDeclaration const * pDecl)
602 : : {
603 : 0 : errorHeader(EIDL_NOT_A_TYPE);
604 : 0 : fprintf(stderr, "'%s'\n", pDecl->getScopedName().getStr());
605 : 0 : idlc()->incErrorCount();
606 : 0 : }
607 : :
608 : : namespace {
609 : :
610 : 0 : char const * nodeTypeName(NodeType nodeType) {
611 [ # # # # ]: 0 : switch (nodeType) {
612 : : case NT_interface:
613 : 0 : return "interface";
614 : :
615 : : case NT_exception:
616 : 0 : return "exception";
617 : :
618 : : case NT_struct:
619 : 0 : return "struct";
620 : :
621 : : default:
622 : 0 : return "";
623 : : }
624 : : }
625 : :
626 : : }
627 : :
628 : 0 : void ErrorHandler::inheritanceError(NodeType nodeType, const OString* name, AstDeclaration* pDecl)
629 : : {
630 [ # # # # : 0 : if ( nodeType == NT_interface &&
# # ][ # # ]
631 : 0 : (pDecl->getNodeType() == NT_interface) &&
632 : 0 : !((AstInterface*)pDecl)->isDefined() )
633 : : {
634 : 0 : errorHeader(EIDL_INHERIT_FWD_ERROR);
635 : : fprintf(stderr, "interface '%s' cannot inherit from forward declared interface '%s'\n",
636 : 0 : name->getStr(), pDecl->getScopedName().getStr());
637 : : } else
638 : : {
639 : 0 : errorHeader(EIDL_CANT_INHERIT);
640 : : fprintf(stderr, "%s '%s' from '%s'\n",
641 : : nodeTypeName(nodeType), name->getStr(),
642 : 0 : pDecl->getScopedName().getStr());
643 : : }
644 : 0 : idlc()->incErrorCount();
645 : 0 : }
646 : :
647 : 0 : void ErrorHandler::forwardLookupError(AstDeclaration* pForward,
648 : : const ::rtl::OString& name)
649 : : {
650 : 0 : errorHeader(EIDL_FWD_DECL_LOOKUP);
651 : : fprintf(stderr, "trying to look up '%s' in undefined forward declared interface '%s'\n",
652 : 0 : pForward->getScopedName().getStr(), name.getStr());
653 : 0 : idlc()->incErrorCount();
654 : 0 : }
655 : :
656 : 0 : void ErrorHandler::constantExpected(AstDeclaration* pDecl,
657 : : const ::rtl::OString& name)
658 : : {
659 : 0 : errorHeader(EIDL_CONSTANT_EXPECTED);
660 : 0 : fprintf(stderr, "'%s' is bound to '%s'\n", name.getStr(), pDecl->getScopedName().getStr());
661 : 0 : idlc()->incErrorCount();
662 : 0 : }
663 : :
664 : 0 : void ErrorHandler::evalError(AstExpression* pExpr)
665 : : {
666 : 0 : errorHeader(EIDL_EVAL_ERROR);
667 [ # # ]: 0 : fprintf(stderr, "'%s'\n", pExpr->toString().getStr());
668 : 0 : idlc()->incErrorCount();
669 : 0 : }
670 : :
671 : 0 : void ErrorHandler::enumValExpected(AstUnion* pUnion)
672 : : {
673 : 0 : errorHeader(EIDL_ENUM_VAL_EXPECTED);
674 : 0 : fprintf(stderr, " union %s\n", pUnion->getLocalName().getStr());
675 : 0 : idlc()->incErrorCount();
676 : 0 : }
677 : :
678 : 0 : void ErrorHandler::enumValLookupFailure(AstUnion* pUnion, AstEnum* pEnum, const ::rtl::OString& name)
679 : : {
680 : 0 : errorHeader(EIDL_ENUM_VAL_NOT_FOUND);
681 : : fprintf(stderr, " union %s, enum %s, enumerator %s\n",
682 : 0 : pUnion->getLocalName().getStr(),
683 : 0 : pEnum->getLocalName().getStr(), name.getStr());
684 : 0 : idlc()->incErrorCount();
685 : 0 : }
686 : :
687 : 188102 : bool ErrorHandler::checkPublished(AstDeclaration const * decl, bool bOptional) {
688 [ + + ][ + + ]: 188102 : if (idlc()->isPublished() && !decl->isPublished() && !bOptional) {
[ - + ][ - + ]
689 : 0 : error1(EIDL_PUBLISHED_USES_UNPUBLISHED, decl);
690 : 0 : return false;
691 : : } else {
692 : 188102 : return true;
693 : : }
694 : : }
695 : :
696 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|