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