xref: /AOO41X/main/idlc/inc/idlc/errorhandler.hxx (revision f04bd1c41dbb33d4d3f057e7474795ed0a0da601)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _IDLC_ERRORHANDLER_HXX_
24 #define _IDLC_ERRORHANDLER_HXX_
25 
26 #include <idlc/astdeclaration.hxx>
27 #include <idlc/astexpression.hxx>
28 #include <idlc/astunion.hxx>
29 #include <idlc/astenum.hxx>
30 
31 enum ErrorCode
32 {
33     EIDL_NONE,              // No error
34     EIDL_SYNTAX_ERROR,      // Syntax error in IDL input
35                             // More details will be gleaned from examining
36                             // the parse state
37     EIDL_REDEF,             // Redefinition
38     EIDL_REDEF_SCOPE,       // Redefinition inside defining scope
39     EIDL_DEF_USE,           // Definition after use
40     EIDL_MULTIPLE_BRANCH,   // More than one union branch with this label
41     EIDL_COERCION_FAILURE,  // Coercion failure
42     EIDL_SCOPE_CONFLICT,    // Between fwd declare and full declare
43     EIDL_ONEWAY_CONFLICT,   // Between op decl and argument direction
44     EIDL_DISC_TYPE,         // Illegal discriminator type in union
45     EIDL_LABEL_TYPE,        // Mismatch with discriminator type in union
46     EIDL_ILLEGAL_ADD,       // Illegal add action
47     EIDL_ILLEGAL_USE,       // Illegal type used in expression
48     EIDL_ILLEGAL_RAISES,    // Error in "raises" clause
49     EIDL_CANT_INHERIT,      // Cannot inherit from non-interface
50     EIDL_LOOKUP_ERROR,      // Identifier not found
51     EIDL_INHERIT_FWD_ERROR, // Cannot inherit from fwd decl interface
52     EIDL_CONSTANT_EXPECTED, // We got something else..
53     EIDL_NAME_CASE_ERROR,   // Spelling differences found
54     EIDL_ENUM_VAL_EXPECTED, // Expected an enumerator
55     EIDL_ENUM_VAL_NOT_FOUND,    // Didnt find an enumerator with that name
56     EIDL_EVAL_ERROR,        // Error in evaluating expression
57     EIDL_AMBIGUOUS,         // Ambiguous name definition
58     EIDL_DECL_NOT_DEFINED,  // Forward declared but never defined
59     EIDL_FWD_DECL_LOOKUP,   // Tried to lookup in fwd declared intf
60     EIDL_RECURSIVE_TYPE,    // Illegal recursive use of type
61     EIDL_NONVOID_ONEWAY,    // Non-void return type in oneway operation
62     EIDL_NOT_A_TYPE,        // Not a type
63     EIDL_TYPE_NOT_VALID,    // Type is not valid in this context
64     EIDL_INTERFACEMEMBER_LOOKUP,    // interface is not defined or a fwd declaration not exists
65     EIDL_SERVICEMEMBER_LOOKUP,
66     EIDL_TYPE_IDENT_CONFLICT,   // type and identifier has equal names
67     EIDL_ONEWAY_RAISE_CONFLICT, // oneway function raised excpetion conflict
68     EIDL_WRONGATTRIBUTEFLAG,
69     EIDL_DEFINED_ATTRIBUTEFLAG,
70     EIDL_WRONGATTRIBUTEKEYWORD,
71     EIDL_MISSINGATTRIBUTEKEYWORD,
72     EIDL_BAD_ATTRIBUTE_FLAGS,
73     EIDL_OPTIONALEXPECTED,
74     EIDL_MIXED_INHERITANCE,
75     EIDL_DOUBLE_INHERITANCE,
76     EIDL_DOUBLE_MEMBER,
77     EIDL_CONSTRUCTOR_PARAMETER_NOT_IN,
78     EIDL_CONSTRUCTOR_REST_PARAMETER_NOT_FIRST,
79     EIDL_REST_PARAMETER_NOT_LAST,
80     EIDL_REST_PARAMETER_NOT_ANY,
81     EIDL_METHOD_HAS_REST_PARAMETER,
82     EIDL_READONLY_ATTRIBUTE_SET_EXCEPTIONS,
83     EIDL_UNSIGNED_TYPE_ARGUMENT,
84     EIDL_WRONG_NUMBER_OF_TYPE_ARGUMENTS,
85     EIDL_INSTANTIATED_STRUCT_TYPE_TYPEDEF,
86     EIDL_IDENTICAL_TYPE_PARAMETERS,
87     EIDL_STRUCT_TYPE_TEMPLATE_WITH_BASE,
88     EIDL_PUBLISHED_FORWARD,
89     EIDL_PUBLISHED_USES_UNPUBLISHED,
90     EIDL_SIMILAR_CONSTRUCTORS
91 };
92 
93 enum WarningCode
94 {
95     WIDL_EXPID_CONFLICT,        // exception id conflict
96     WIDL_REQID_CONFLICT,        // request id conflict
97     WIDL_INHERIT_IDCONFLICT,    // request id conflict inheritance tree
98     WIDL_TYPE_IDENT_CONFLICT,   // type and identifier has equal names
99     WIDL_WRONG_NAMING_CONV      // type or identifier doesn't fulfill the UNO naming convention
100 };
101 
102 class ErrorHandler
103 {
104 public:
105     // Report errors with varying numbers of arguments
106     void    error0(ErrorCode e);
107     void    error1(ErrorCode e, AstDeclaration const * d);
108     void    error2(
109         ErrorCode e, AstDeclaration const * d1, AstDeclaration const * d2);
110     void    error3(ErrorCode e, AstDeclaration* d1, AstDeclaration* d2, AstDeclaration* d3);
111 
112     // Warning
113     void    warning0(WarningCode e, const sal_Char* warningmsg);
114 
115     // Report a syntax error in IDL input
116     void    syntaxError(ParseState state, sal_Int32 lineNumber, const sal_Char* errmsg);
117 
118     // Report an unsuccesful coercion attempt
119     void    coercionError(AstExpression *pExpr, ExprType et);
120 
121     // Report a failed name lookup attempt
122     void    lookupError(const ::rtl::OString& n);
123     // Report a failed name lookup attempt
124     void    lookupError(ErrorCode e, const ::rtl::OString& n, AstDeclaration* pScope);
125 
126 
127     // Report a type error
128     void    noTypeError(AstDeclaration const * pDecl);
129 
130     void    inheritanceError(NodeType nodeType, const ::rtl::OString* name, AstDeclaration* pDecl);
131 
132     void    flagError(ErrorCode e, sal_uInt32 flag);
133 
134     void    forwardLookupError(AstDeclaration* pForward, const ::rtl::OString& name);
135 
136     void    constantExpected(AstDeclaration* pDecl, const ::rtl::OString& name);
137 
138     void    evalError(AstExpression* pExpr);
139 
140     // Report a situation where an enumerator was expected but we got
141     // something else instead. This occurs when a union with an enum
142     // discriminator is being parsed and one of the branch labels is
143     // not an enumerator in that enum
144     void    enumValExpected(AstUnion* pUnion);
145 
146     // Report a failed enumerator lookup in an enum
147     void    enumValLookupFailure(AstUnion* pUnion, AstEnum* pEnum, const ::rtl::OString& name);
148 
149     bool checkPublished(AstDeclaration const * decl, bool bOptiional=false);
150 };
151 
152 #endif // _IDLC_ERRORHANDLER_HXX_
153 
154