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 #ifndef ADC_CPP_PE_CLASS_HXX 29 #define ADC_CPP_PE_CLASS_HXX 30 31 32 33 // USED SERVICES 34 // BASE CLASSES 35 #include "cpp_pe.hxx" 36 // OTHER 37 #include <semantic/callf.hxx> 38 #include <semantic/sub_peu.hxx> 39 #include <ary/cpp/c_types4cpp.hxx> 40 #include <ary/cpp/c_slntry.hxx> 41 #include "all_toks.hxx" 42 43 namespace ary 44 { 45 namespace cpp 46 { 47 class Class; 48 } 49 } 50 51 52 namespace cpp 53 { 54 55 56 using ary::cpp::E_Protection; 57 using ary::cpp::E_Virtuality; 58 59 60 class PE_Base; 61 class PE_Enum; 62 class PE_Typedef; 63 class PE_VarFunc; 64 class PE_Ignore; 65 class PE_Defines; 66 67 68 class PE_Class : public cpp::Cpp_PE 69 { 70 public: 71 enum E_State 72 { 73 start, /// before class, struct or union 74 expectName, /// after class, struct or union 75 gotName, /// after name, before : or { 76 bodyStd, /// after { 77 inProtection, /// after public, protected or private and before ":" 78 afterDecl, /// after ending } 79 size_of_states 80 }; 81 82 enum E_KindOfResult 83 { 84 is_declaration, // normal 85 is_implicit_declaration, // like in: class Abc { public int n; } aAbc; 86 is_predeclaration, // like: class Abc; 87 is_qualified_typename // like in: class Abc * fx(); 88 89 }; 90 91 PE_Class( 92 Cpp_PE * i_pParent ); 93 ~PE_Class(); 94 95 virtual void Call_Handler( 96 const cpp::Token & i_rTok ); 97 virtual Cpp_PE * Handle_ChildFailure(); 98 99 E_KindOfResult Result_KindOf() const; 100 const String & Result_LocalName() const; 101 const String & Result_FirstNameSegment() const; 102 103 private: 104 typedef SubPe< PE_Class, PE_Base > SP_Base; 105 // typedef SubPe< PE_Class, PE_Enum> SP_Enum; 106 typedef SubPe< PE_Class, PE_Typedef> SP_Typedef; 107 typedef SubPe< PE_Class, PE_VarFunc> SP_VarFunc; 108 typedef SubPe< PE_Class, PE_Ignore > SP_Ignore; 109 typedef SubPe< PE_Class, PE_Defines> SP_Defines; 110 111 typedef SubPeUse< PE_Class, PE_Base> SPU_Base; 112 // typedef SubPeUse< PE_Class, PE_Enum> SPU_Enum; 113 typedef SubPeUse< PE_Class, PE_Typedef> SPU_Typedef; 114 typedef SubPeUse< PE_Class, PE_VarFunc> SPU_VarFunc; 115 typedef SubPeUse< PE_Class, PE_Ignore> SPU_Ignore; 116 typedef SubPeUse< PE_Class, PE_Defines> SPU_Defines; 117 118 typedef ary::cpp::List_Bases BaseList; 119 typedef ary::cpp::S_Classes_Base Base; 120 typedef ary::cpp::E_Protection E_Protection; 121 122 void Setup_StatusFunctions(); 123 virtual void InitData(); 124 virtual void TransferData(); 125 void Hdl_SyntaxError( const char *); 126 void Init_CurObject(); 127 128 void SpReturn_Base(); 129 130 void On_start_class( const char * ); 131 void On_start_struct( const char * ); 132 void On_start_union( const char * ); 133 134 void On_expectName_Identifier( const char * ); 135 void On_expectName_SwBracket_Left( const char * ); 136 void On_expectName_Colon( const char * ); 137 138 void On_gotName_SwBracket_Left( const char * ); 139 void On_gotName_Semicolon( const char * ); 140 void On_gotName_Colon( const char * ); 141 void On_gotName_Return2Type( const char * ); 142 143 void On_bodyStd_VarFunc( const char * ); 144 void On_bodyStd_ClassKey( const char * ); 145 void On_bodyStd_enum( const char * ); 146 void On_bodyStd_typedef( const char * ); 147 void On_bodyStd_public( const char * ); 148 void On_bodyStd_protected( const char * ); 149 void On_bodyStd_private( const char * ); 150 void On_bodyStd_template( const char * ); 151 void On_bodyStd_friend( const char * ); 152 void On_bodyStd_using( const char * ); 153 void On_bodyStd_SwBracket_Right( const char * ); 154 void On_bodyStd_DefineName(const char * ); 155 void On_bodyStd_MacroName(const char * ); 156 157 void On_inProtection_Colon( const char * ); 158 159 void On_afterDecl_Semicolon( const char * ); 160 void On_afterDecl_Return2Type( const char * ); 161 162 // DATA 163 Dyn< PeStatusArray<PE_Class> > 164 pStati; 165 166 Dyn<SP_Base> pSpBase; 167 // Dyn<SP_Enum> pSpEnum; 168 Dyn<SP_Typedef> pSpTypedef; 169 Dyn<SP_VarFunc> pSpVarFunc; 170 Dyn<SP_Ignore> pSpIgnore; 171 Dyn<SP_Defines> pSpDefs; 172 173 Dyn<SPU_Base> pSpuBase; 174 // Dyn<SPU_Enum> pSpuEnum; 175 Dyn<SPU_Typedef> pSpuTypedef; 176 Dyn<SPU_VarFunc> pSpuVarFunc; 177 178 Dyn<SPU_Ignore> pSpuTemplate; 179 Dyn<SPU_Ignore> pSpuUsing; 180 Dyn<SPU_Ignore> pSpuIgnoreFailure; 181 Dyn<SPU_Defines> pSpuDefs; 182 183 184 185 String sLocalName; 186 ary::cpp::E_ClassKey 187 eClassKey; 188 ary::cpp::Class * pCurObject; 189 BaseList aBases; 190 191 E_KindOfResult eResult_KindOf; 192 }; 193 194 195 196 // IMPLEMENTATION 197 198 inline PE_Class::E_KindOfResult 199 PE_Class::Result_KindOf() const 200 { 201 return eResult_KindOf; 202 } 203 204 inline const String & 205 PE_Class::Result_LocalName() const 206 { 207 return sLocalName; 208 } 209 210 inline const String & 211 PE_Class::Result_FirstNameSegment() const 212 { 213 return sLocalName; 214 } 215 216 217 218 219 } // namespace cpp 220 221 222 #if 0 // Branches 223 224 class struct union 225 -> Class 226 -> Predeclaration 227 228 typedef 229 -> Typedef 230 231 enum 232 -> Enum 233 234 TypeDeclaration 235 -> Function In Class 236 -> Variable 237 238 public, protected, private 239 -> Protection declaration 240 241 friend 242 -> Friend Class 243 -> Friend Function 244 245 virtual 246 -> Function In Class 247 248 using 249 -> Using Declaration 250 251 252 #endif // 0 253 254 255 #endif 256 257