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 : #ifndef _IDLC_IDLCTYPES_HXX_
20 : #define _IDLC_IDLCTYPES_HXX_
21 :
22 : #include <stdio.h>
23 :
24 : #include <boost/unordered_map.hpp>
25 : #include <list>
26 : #include <vector>
27 : #include <string>
28 : #include <set>
29 :
30 : #include <sal/types.h>
31 : #include <rtl/ustring.hxx>
32 :
33 : struct EqualString
34 : {
35 52249 : sal_Bool operator()(const ::rtl::OString& str1, const ::rtl::OString& str2) const
36 : {
37 52249 : return (str1 == str2);
38 : }
39 : };
40 :
41 : struct HashString
42 : {
43 64551 : sal_Int32 operator()(const ::rtl::OString& str) const
44 : {
45 64551 : return str.hashCode();
46 : }
47 : };
48 :
49 : struct LessString
50 : {
51 681604 : sal_Bool operator()(const ::rtl::OString& str1, const ::rtl::OString& str2) const
52 : {
53 681604 : return (str1 < str2);
54 : }
55 : };
56 :
57 : typedef ::std::list< ::rtl::OString > StringList;
58 : typedef ::std::vector< ::rtl::OString > StringVector;
59 : typedef ::std::set< ::rtl::OString, LessString > StringSet;
60 :
61 : class AstExpression;
62 : typedef ::std::list< AstExpression* > ExprList;
63 :
64 : class AstUnionLabel;
65 : typedef ::std::list< AstUnionLabel* > LabelList;
66 :
67 : class AstDeclaration;
68 :
69 : typedef ::boost::unordered_map< ::rtl::OString, AstDeclaration*, HashString, EqualString > DeclMap;
70 : typedef ::std::list< AstDeclaration* > DeclList;
71 :
72 : class AstScope;
73 : AstDeclaration* SAL_CALL scopeAsDecl(AstScope* pScope);
74 : AstScope* SAL_CALL declAsScope(AstDeclaration* pDecl);
75 :
76 : #ifdef _MSC_VER
77 : #pragma warning( disable : 4541 )
78 : #endif
79 :
80 : // flags used for attributes, properties and services
81 : #define AF_INVALID 0x0000
82 : #define AF_READONLY 0x0001
83 : #define AF_OPTIONAL 0x0002
84 : #define AF_MAYBEVOID 0x0004
85 : #define AF_BOUND 0x0008
86 : #define AF_CONSTRAINED 0x0010
87 : #define AF_TRANSIENT 0x0020
88 : #define AF_MAYBEAMBIGUOUS 0x0040
89 : #define AF_MAYBEDEFAULT 0x0080
90 : #define AF_REMOVEABLE 0x0100
91 : #define AF_ATTRIBUTE 0x0200
92 : #define AF_PROPERTY 0x0400
93 :
94 : enum ParseState
95 : {
96 : PS_NoState,
97 : PS_TypeDeclSeen, // Seen complete typedef declaration
98 : PS_ConstantDeclSeen, // Seen complete const declaration
99 : PS_ExceptionDeclSeen, // Seen complete exception declaration
100 : PS_InterfaceDeclSeen, // Seen complete interface declaration
101 : PS_ServiceDeclSeen, // Seen complete service declaration
102 : PS_SingletonDeclSeen, // Seen complete singleton declaration
103 : PS_ModuleDeclSeen, // Seen complete module declaration
104 : PS_AttributeDeclSeen, // Seen complete attribute declaration
105 : PS_PropertyDeclSeen, // Seen complete property declaration
106 : PS_OperationDeclSeen, // Seen complete operation declaration
107 : PS_InterfaceInheritanceDeclSeen, // Seen complete interface inheritance decl
108 : PS_ConstantsDeclSeen, // Seen complete constants declaration
109 :
110 : PS_ServiceSeen, // Seen a SERVICE keyword
111 : PS_ServiceIDSeen, // Seen the service ID
112 : PS_ServiceSqSeen, // '{' seen for service
113 : PS_ServiceQsSeen, // '}' seen for service
114 : PS_ServiceBodySeen, // Seen complete service body
115 : PS_ServiceMemberSeen, // Seen a service member
116 : PS_ServiceIFHeadSeen, // Seen an interface member header
117 : PS_ServiceSHeadSeen, // Seen an service member header
118 :
119 : PS_SingletonSeen, // Seen a SINGLETON keyword
120 : PS_SingletonIDSeen, // Seen the singleton ID
121 : PS_SingletonSqSeen, // '{' seen for singleton
122 : PS_SingletonQsSeen, // '}' seen for singleton
123 : PS_SingletonBodySeen, // Seen complete singleton body
124 : PS_SingletonMemberSeen, // Seen a singleton member
125 :
126 : PS_ModuleSeen, // Seen a MODULE keyword
127 : PS_ModuleIDSeen, // Seen the module ID
128 : PS_ModuleSqSeen, // '{' seen for module
129 : PS_ModuleQsSeen, // '}' seen for module
130 : PS_ModuleBodySeen, // Seen complete module body
131 :
132 : PS_ConstantsSeen, // Seen a CONSTANTS keyword
133 : PS_ConstantsIDSeen, // Seen the constants ID
134 : PS_ConstantsSqSeen, // '{' seen for constants
135 : PS_ConstantsQsSeen, // '}' seen for constants
136 : PS_ConstantsBodySeen, // Seen complete constants body
137 :
138 : PS_InterfaceSeen, // Seen an INTERFACE keyword
139 : PS_InterfaceIDSeen, // Seen the interface ID
140 : PS_InterfaceHeadSeen, // Seen the interface head
141 : PS_InheritSpecSeen, // Seen a complete inheritance spec
142 : PS_ForwardDeclSeen, // Forward interface decl seen
143 : PS_InterfaceSqSeen, // '{' seen for interface
144 : PS_InterfaceQsSeen, // '}' seen for interface
145 : PS_InterfaceBodySeen, // Seen an interface body
146 : PS_InheritColonSeen, // Seen ':' in inheritance list
147 :
148 : PS_SNListCommaSeen, // Seen ',' in list of scoped names
149 : PS_ScopedNameSeen, // Seen a complete scoped name
150 : PS_SN_IDSeen, // Seen an identifier as part of a scoped name
151 : PS_ScopeDelimSeen, // Seen a scope delim as party of a scoped name
152 :
153 : PS_ConstSeen, // Seen a CONST keyword
154 : PS_ConstTypeSeen, // Parsed the type of a constant
155 : PS_ConstIDSeen, // Seen the constant ID
156 : PS_ConstAssignSeen, // Seen the '='
157 : PS_ConstExprSeen, // Seen the constant value expression
158 :
159 : PS_TypedefSeen, // Seen a TYPEDEF keyword
160 : PS_TypeSpecSeen, // Seen a complete type specification
161 : PS_DeclaratorsSeen, // Seen a complete list of declarators
162 :
163 : PS_StructSeen, // Seen a STRUCT keyword
164 : PS_StructHeaderSeen, // Seen struct header
165 : PS_StructIDSeen, // Seen the struct ID
166 : PS_StructSqSeen, // '{' seen for struct
167 : PS_StructQsSeen, // '}' seen for struct
168 : PS_StructBodySeen, // Seen complete body of struct decl
169 :
170 : PS_MemberTypeSeen, // Seen type of struct or except member
171 : PS_MemberDeclsSeen, // Seen decls of struct or except members
172 : PS_MemberDeclsCompleted,// Completed one struct or except member to ';'
173 :
174 : PS_UnionSeen, // Seen a UNION keyword
175 : PS_UnionIDSeen, // Seen the union ID
176 : PS_SwitchSeen, // Seen the SWITCH keyword
177 : PS_SwitchOpenParSeen, // Seen the switch open par.
178 : PS_SwitchTypeSeen, // Seen the switch type spec
179 : PS_SwitchCloseParSeen, // Seen the switch close par.
180 : PS_UnionSqSeen, // '{' seen for union
181 : PS_UnionQsSeen, // '}' seen for union
182 : PS_DefaultSeen, // Seen DEFAULT keyword
183 : PS_UnionLabelSeen, // Seen label of union element
184 : PS_LabelColonSeen, // Seen ':' of union branch label
185 : PS_LabelExprSeen, // Seen expression of union branch label
186 : PS_UnionElemSeen, // Seen a union element
187 : PS_UnionElemCompleted, // Completed one union member up to ';'
188 : PS_CaseSeen, // Seen a CASE keyword
189 : PS_UnionElemTypeSeen, // Seen type spec for union element
190 : PS_UnionElemDeclSeen, // Seen declarator for union element
191 : PS_UnionBodySeen, // Seen completed union body
192 :
193 : PS_EnumSeen, // Seen an ENUM keyword
194 : PS_EnumIDSeen, // Seen the enum ID
195 : PS_EnumSqSeen, // Seen '{' for enum
196 : PS_EnumQsSeen, // Seen '}' for enum
197 : PS_EnumBodySeen, // Seen complete enum body
198 : PS_EnumCommaSeen, // Seen ',' in list of enumerators
199 :
200 : PS_SequenceSeen, // Seen a SEQUENCE keyword
201 : PS_SequenceSqSeen, // Seen '<' for sequence
202 : PS_SequenceQsSeen, // Seen '>' for sequence
203 : PS_SequenceTypeSeen, // Seen type decl for sequence
204 :
205 : PS_ArrayIDSeen, // Seen array ID
206 : PS_ArrayTypeSeen, // Seen array type
207 : PS_ArrayCompleted, // Seen completed array declaration
208 : PS_DimSqSeen, // Seen '[' for array dimension
209 : PS_DimQsSeen, // Seen ']' for array dimension
210 : PS_DimExprSeen, // Seen size expression for array dimension
211 :
212 :
213 : PS_FlagHeaderSeen, // Seen the attribute|property|interface member head
214 : PS_AttrSeen, // Seen ATTRIBUTE keyword
215 : PS_AttrTypeSeen, // Seen type decl for attribute
216 : PS_AttrCompleted, // Seen complete attribute declaration
217 : PS_ReadOnlySeen, // Seen READONLY keyword
218 : PS_OptionalSeen, // Seen OPTIONAL keyword
219 : PS_MayBeVoidSeen, // Seen MAYBEVOID yword
220 : PS_BoundSeen, // Seen BOUND keyword
221 : PS_ConstrainedSeen, // Seen CONSTRAINED keyword
222 : PS_TransientSeen, // Seen TRANSIENT keyword
223 : PS_MayBeAmbigiousSeen, // Seen MAYBEAMBIGIOUS keyword
224 : PS_MayBeDefaultSeen, // Seen MAYBEDEFAULT keyword
225 : PS_RemoveableSeen, // Seen REMOVEABLE keyword
226 :
227 : PS_PropertySeen, // Seen PROPERTY keyword
228 : PS_PropertyTypeSeen, // Seen type decl for property
229 : PS_PropertyCompleted, // Seen complete property declaration
230 :
231 : PS_ExceptSeen, // Seen EXCEPTION keyword
232 : PS_ExceptHeaderSeen, // Seen exception header keyword
233 : PS_ExceptIDSeen, // Seen exception identifier
234 : PS_ExceptSqSeen, // Seen '{' for exception
235 : PS_ExceptQsSeen, // Seen '}' for exception
236 : PS_ExceptBodySeen, // Seen complete exception body
237 :
238 : PS_OpTypeSeen, // Seen operation return type
239 : PS_OpIDSeen, // Seen operation ID
240 : PS_OpParsCompleted, // Completed operation param list
241 : PS_OpCompleted, // Completed operation statement
242 : PS_OpSqSeen, // Seen '(' for operation
243 : PS_OpQsSeen, // Seen ')' for operation
244 : PS_OpParCommaSeen, // Seen ',' in list of op params
245 : PS_OpParDirSeen, // Seen parameter direction
246 : PS_OpParTypeSeen, // Seen parameter type
247 : PS_OpParDeclSeen, // Seen parameter declaration
248 :
249 : PS_RaiseSeen, // Seen RAISES keyword
250 : PS_RaiseSqSeen, // Seen '(' for RAISES
251 : PS_RaiseQsSeen, // Seen ')' for RAISES
252 :
253 : PS_DeclsCommaSeen, // Seen ',' in declarators list
254 : PS_DeclsDeclSeen // Seen complete decl in decls list
255 : };
256 :
257 : #endif // _IDLC_IDLCTYPES_HXX_
258 :
259 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|