1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 29 #ifndef ADC_CPP_PE_VAFU_HXX 30 #define ADC_CPP_PE_VAFU_HXX 31 32 // BASE CLASSES 33 #include "cpp_pe.hxx" 34 // USED SERVICES 35 #include <semantic/callf.hxx> 36 #include <semantic/sub_peu.hxx> 37 #include <ary/cpp/c_types4cpp.hxx> 38 #include <ary/cpp/c_vfflag.hxx> 39 40 41 42 namespace cpp 43 { 44 45 class PE_Type; 46 class PE_Variable; 47 class PE_Function; 48 class PE_Ignore; 49 50 51 52 53 class PE_VarFunc : public Cpp_PE 54 { 55 public: 56 enum E_State 57 { 58 start, 59 expectCtor, 60 afterClassDecl, // Also used for after enum declaration. 61 expectName, 62 afterName, 63 afterName_inErraneousTemplate, 64 finished, 65 finishedIncludingFunctionImplementation, 66 size_of_states 67 }; 68 enum E_ResultType 69 { 70 result_unknown = 0, 71 result_ignore, /// Used for class and enum declarations and predeclarations and for extern variables and functions. 72 result_variable, 73 result_function 74 }; 75 76 typedef ary::cpp::E_Protection E_Protection; 77 78 79 PE_VarFunc( 80 Cpp_PE * i_pParent ); 81 ~PE_VarFunc(); 82 83 virtual void Call_Handler( 84 const cpp::Token & i_rTok ); 85 86 const std::vector<ary::cpp::Ce_id> & 87 Result_Ids() const; 88 ary::cpp::Type_id Result_FrontType() const; 89 const StringVector & 90 Result_Names() const; 91 E_ResultType Result_CeType() const; 92 93 private: 94 typedef SubPe< PE_VarFunc, PE_Type > SP_Type; 95 typedef SubPeUse< PE_VarFunc, PE_Type > SPU_Type; 96 typedef SubPe< PE_VarFunc, PE_Variable > SP_Variable; 97 typedef SubPeUse< PE_VarFunc, PE_Variable > SPU_Variable; 98 typedef SubPe< PE_VarFunc, PE_Function > SP_Function; 99 typedef SubPeUse< PE_VarFunc, PE_Function > SPU_Function; 100 typedef SubPe< PE_VarFunc, PE_Ignore > SP_Ignore; 101 typedef SubPeUse< PE_VarFunc, PE_Ignore > SPU_Ignore; 102 103 void Setup_StatusFunctions(); 104 virtual void InitData(); 105 virtual void TransferData(); 106 void Hdl_UnknownToken( const char *); 107 108 void SpInit_FunctionStd(); 109 void SpInit_FunctionCtor(); 110 void SpInit_FunctionDtor(); 111 void SpInit_FunctionCastOperator(); 112 void SpInit_FunctionNormalOperator(); 113 void SpReturn_Type(); 114 void SpReturn_Variable(); 115 void SpReturn_FunctionStd(); 116 void SpReturn_Ignore(); 117 118 void On_start_Identifier(const char * i_sText); 119 void On_start_operator(const char * i_sText); 120 void On_start_TypeKey(const char * i_sText); 121 void On_start_virtual(const char * i_sText); 122 void On_start_Tilde(const char * i_sText); 123 void On_start_const(const char * i_sText); 124 void On_start_volatile(const char * i_sText); 125 void On_start_extern(const char * i_sText); 126 void On_start_static(const char * i_sText); 127 void On_start_mutable(const char * i_sText); 128 void On_start_register(const char * i_sText); 129 void On_start_inline(const char * i_sText); 130 void On_start_explicit(const char * i_sText); 131 void On_start_Bracket_Right(const char * i_sText); 132 void On_start_typename(const char * i_sText); 133 134 void On_expectCtor_Bracket_Left(const char * i_sText); 135 136 void On_afterClassDecl_Semicolon(const char * i_sText); 137 138 void On_expectName_Identifier(const char * i_sText); 139 void On_expectName_operator(const char * i_sText); 140 void On_expectName_Bracket_Left(const char * i_sText); 141 142 void On_afterName_ArrayBracket_Left(const char * i_sText); 143 void On_afterName_Bracket_Left(const char * i_sText); 144 void On_afterName_DoubleColon(const char * i_sText); 145 void On_afterName_Semicolon(const char * i_sText); 146 void On_afterName_Comma(const char * i_sText); 147 void On_afterName_Assign(const char * i_sText); 148 void On_afterName_Less(const char * i_sText); 149 150 void On_afterName_inErraneousTemplate_Less(const char * i_sText); 151 void On_afterName_inErraneousTemplate_Greater(const char * i_sText); 152 void On_afterName_inErraneousTemplate_Default(const char * i_sText); 153 154 void On_finished_Semicolon(const char * i_sText); 155 void On_finished_Comma(const char * i_sText); 156 void On_finished_Default(const char * i_sText); 157 158 void On_finishedIncludingFunctionImplementation_Default(const char * i_sText); 159 160 ary::cpp::FunctionFlags 161 CreateFunctionFlags(); 162 163 // DATA 164 Dyn< PeStatusArray<PE_VarFunc> > 165 pStati; 166 167 Dyn<SP_Type> pSpType; 168 Dyn<SPU_Type> pSpuType; 169 Dyn<SP_Variable> pSpVariable; 170 Dyn<SPU_Variable> pSpuVariable; 171 Dyn<SP_Function> pSpFunction; 172 Dyn<SPU_Function> pSpuFunctionStd; 173 Dyn<SPU_Function> pSpuFunctionCtor; 174 Dyn<SPU_Function> pSpuFunctionDtor; 175 Dyn<SPU_Function> pSpuFunctionCastOperator; 176 Dyn<SPU_Function> pSpuFunctionNormalOperator; 177 Dyn<SP_Ignore> pSpIgnore; 178 Dyn<SPU_Ignore> pSpuIgnore; 179 180 intt nCounter_TemplateBrackets; 181 bool bInDestructor; 182 183 std::vector<ary::cpp::Ce_id> 184 aResultIds; 185 ary::cpp::Type_id nResultFrontType; 186 E_ResultType eResultType; 187 188 // Pre-Results 189 String sName; 190 191 bool bVirtual; 192 bool bStatic; 193 bool bExtern; 194 bool bExternC; 195 bool bMutable; 196 bool bInline; 197 bool bRegister; 198 bool bExplicit; 199 }; 200 201 202 203 // IMPLEMENTATION 204 205 inline const std::vector<ary::cpp::Ce_id> & 206 PE_VarFunc::Result_Ids() const 207 { return aResultIds; } 208 inline ary::cpp::Type_id 209 PE_VarFunc::Result_FrontType() const 210 { return nResultFrontType; } 211 inline PE_VarFunc::E_ResultType 212 PE_VarFunc::Result_CeType() const 213 { return eResultType; } 214 215 216 217 } // namespace cpp 218 219 220 221 222 #endif 223 224 225 /* // Overview of Stati 226 227 Undecided 228 --------- 229 230 start // vor und w�hrend storage class specifiern 231 any ->stay 232 operaator ->goto Function 233 234 ->Typ 235 236 expectName 237 Identifier ->stay 238 operator ->goto Function 239 240 afterName ->goto Variable or Function 241 242 243 244 245 Variable 246 -------- 247 248 start // vor und w�hrend storage class specifiern 249 250 ->Typ 251 252 expectName // Typ ist da -> im Falle von '(': notyetimplemented 253 afterName 254 255 expectSize // after [ 256 expectFinish 257 // vor ; oder , 258 expectNextVarName // anders als bei expectName kann hier auch * oder & kommen 259 260 261 262 263 264 Function 265 -------- 266 267 start // vor und w�hrend storage class specifiern 268 269 ->Typ 270 271 expectName // Typ ist da 272 expectBracket // Nach Name 273 expectParameter // nach ( oder , 274 -> Parameter 275 after Parameters // before const, volatile throw or = 0. 276 after throw // expect ( 277 expectException // after ( 278 after exceptions // = 0 oder ; oder , 279 280 281 expectNextVarName // anders als bei expectName kann hier auch * oder & kommen 282 283 284 285 286 287 288 289 */ 290