xref: /trunk/main/autodoc/source/parser/cpp/pe_class.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef ADC_CPP_PE_CLASS_HXX
29*cdf0e10cSrcweir #define ADC_CPP_PE_CLASS_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir // USED SERVICES
34*cdf0e10cSrcweir     // BASE CLASSES
35*cdf0e10cSrcweir #include "cpp_pe.hxx"
36*cdf0e10cSrcweir     // OTHER
37*cdf0e10cSrcweir #include <semantic/callf.hxx>
38*cdf0e10cSrcweir #include <semantic/sub_peu.hxx>
39*cdf0e10cSrcweir #include <ary/cpp/c_types4cpp.hxx>
40*cdf0e10cSrcweir #include <ary/cpp/c_slntry.hxx>
41*cdf0e10cSrcweir #include "all_toks.hxx"
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir namespace ary
44*cdf0e10cSrcweir {
45*cdf0e10cSrcweir namespace cpp
46*cdf0e10cSrcweir {
47*cdf0e10cSrcweir     class Class;
48*cdf0e10cSrcweir }
49*cdf0e10cSrcweir }
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir namespace cpp
53*cdf0e10cSrcweir {
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir using ary::cpp::E_Protection;
57*cdf0e10cSrcweir using ary::cpp::E_Virtuality;
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir class PE_Base;
61*cdf0e10cSrcweir class PE_Enum;
62*cdf0e10cSrcweir class PE_Typedef;
63*cdf0e10cSrcweir class PE_VarFunc;
64*cdf0e10cSrcweir class PE_Ignore;
65*cdf0e10cSrcweir class PE_Defines;
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir class PE_Class : public cpp::Cpp_PE
69*cdf0e10cSrcweir {
70*cdf0e10cSrcweir   public:
71*cdf0e10cSrcweir     enum E_State
72*cdf0e10cSrcweir     {
73*cdf0e10cSrcweir         start,              /// before class, struct or union
74*cdf0e10cSrcweir         expectName,         /// after class, struct or union
75*cdf0e10cSrcweir         gotName,            /// after name, before : or {
76*cdf0e10cSrcweir         bodyStd,            /// after {
77*cdf0e10cSrcweir         inProtection,       /// after public, protected or private and before ":"
78*cdf0e10cSrcweir         afterDecl,          /// after ending }
79*cdf0e10cSrcweir         size_of_states
80*cdf0e10cSrcweir     };
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir     enum E_KindOfResult
83*cdf0e10cSrcweir     {
84*cdf0e10cSrcweir         is_declaration,             // normal
85*cdf0e10cSrcweir         is_implicit_declaration,    // like in: class Abc { public int n; } aAbc;
86*cdf0e10cSrcweir         is_predeclaration,          // like:    class Abc;
87*cdf0e10cSrcweir         is_qualified_typename       // like in: class Abc * fx();
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir     };
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir                         PE_Class(
92*cdf0e10cSrcweir                             Cpp_PE *            i_pParent );
93*cdf0e10cSrcweir                         ~PE_Class();
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir     virtual void        Call_Handler(
96*cdf0e10cSrcweir                             const cpp::Token &  i_rTok );
97*cdf0e10cSrcweir     virtual Cpp_PE *    Handle_ChildFailure();
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir     E_KindOfResult      Result_KindOf() const;
100*cdf0e10cSrcweir     const String  &     Result_LocalName() const;
101*cdf0e10cSrcweir     const String  &     Result_FirstNameSegment() const;
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir   private:
104*cdf0e10cSrcweir     typedef SubPe< PE_Class, PE_Base >          SP_Base;
105*cdf0e10cSrcweir //  typedef SubPe< PE_Class, PE_Enum>           SP_Enum;
106*cdf0e10cSrcweir     typedef SubPe< PE_Class, PE_Typedef>        SP_Typedef;
107*cdf0e10cSrcweir     typedef SubPe< PE_Class, PE_VarFunc>        SP_VarFunc;
108*cdf0e10cSrcweir     typedef SubPe< PE_Class, PE_Ignore >        SP_Ignore;
109*cdf0e10cSrcweir     typedef SubPe< PE_Class, PE_Defines>        SP_Defines;
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir     typedef SubPeUse< PE_Class, PE_Base>        SPU_Base;
112*cdf0e10cSrcweir //  typedef SubPeUse< PE_Class, PE_Enum>            SPU_Enum;
113*cdf0e10cSrcweir     typedef SubPeUse< PE_Class, PE_Typedef>     SPU_Typedef;
114*cdf0e10cSrcweir     typedef SubPeUse< PE_Class, PE_VarFunc>     SPU_VarFunc;
115*cdf0e10cSrcweir     typedef SubPeUse< PE_Class, PE_Ignore>      SPU_Ignore;
116*cdf0e10cSrcweir     typedef SubPeUse< PE_Class, PE_Defines>     SPU_Defines;
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir     typedef ary::cpp::List_Bases                BaseList;
119*cdf0e10cSrcweir     typedef ary::cpp::S_Classes_Base            Base;
120*cdf0e10cSrcweir     typedef ary::cpp::E_Protection              E_Protection;
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir     void                Setup_StatusFunctions();
123*cdf0e10cSrcweir     virtual void        InitData();
124*cdf0e10cSrcweir     virtual void        TransferData();
125*cdf0e10cSrcweir     void                Hdl_SyntaxError( const char *);
126*cdf0e10cSrcweir     void                Init_CurObject();
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir     void                SpReturn_Base();
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir     void                On_start_class( const char * );
131*cdf0e10cSrcweir     void                On_start_struct( const char * );
132*cdf0e10cSrcweir     void                On_start_union( const char * );
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir     void                On_expectName_Identifier( const char * );
135*cdf0e10cSrcweir     void                On_expectName_SwBracket_Left( const char * );
136*cdf0e10cSrcweir     void                On_expectName_Colon( const char * );
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir     void                On_gotName_SwBracket_Left( const char * );
139*cdf0e10cSrcweir     void                On_gotName_Semicolon( const char * );
140*cdf0e10cSrcweir     void                On_gotName_Colon( const char * );
141*cdf0e10cSrcweir     void                On_gotName_Return2Type( const char * );
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir     void                On_bodyStd_VarFunc( const char * );
144*cdf0e10cSrcweir     void                On_bodyStd_ClassKey( const char * );
145*cdf0e10cSrcweir     void                On_bodyStd_enum( const char * );
146*cdf0e10cSrcweir     void                On_bodyStd_typedef( const char * );
147*cdf0e10cSrcweir     void                On_bodyStd_public( const char * );
148*cdf0e10cSrcweir     void                On_bodyStd_protected( const char * );
149*cdf0e10cSrcweir     void                On_bodyStd_private( const char * );
150*cdf0e10cSrcweir     void                On_bodyStd_template( const char * );
151*cdf0e10cSrcweir     void                On_bodyStd_friend( const char * );
152*cdf0e10cSrcweir     void                On_bodyStd_using( const char * );
153*cdf0e10cSrcweir     void                On_bodyStd_SwBracket_Right( const char * );
154*cdf0e10cSrcweir     void                On_bodyStd_DefineName(const char * );
155*cdf0e10cSrcweir     void                On_bodyStd_MacroName(const char * );
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir     void                On_inProtection_Colon( const char * );
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir     void                On_afterDecl_Semicolon( const char * );
160*cdf0e10cSrcweir     void                On_afterDecl_Return2Type( const char * );
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir     // DATA
163*cdf0e10cSrcweir     Dyn< PeStatusArray<PE_Class> >
164*cdf0e10cSrcweir                         pStati;
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir     Dyn<SP_Base>        pSpBase;
167*cdf0e10cSrcweir //  Dyn<SP_Enum>        pSpEnum;
168*cdf0e10cSrcweir     Dyn<SP_Typedef>     pSpTypedef;
169*cdf0e10cSrcweir     Dyn<SP_VarFunc>     pSpVarFunc;
170*cdf0e10cSrcweir     Dyn<SP_Ignore>      pSpIgnore;
171*cdf0e10cSrcweir     Dyn<SP_Defines>     pSpDefs;
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir     Dyn<SPU_Base>       pSpuBase;
174*cdf0e10cSrcweir //  Dyn<SPU_Enum>       pSpuEnum;
175*cdf0e10cSrcweir     Dyn<SPU_Typedef>    pSpuTypedef;
176*cdf0e10cSrcweir     Dyn<SPU_VarFunc>    pSpuVarFunc;
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir     Dyn<SPU_Ignore>     pSpuTemplate;
179*cdf0e10cSrcweir     Dyn<SPU_Ignore>     pSpuUsing;
180*cdf0e10cSrcweir     Dyn<SPU_Ignore>     pSpuIgnoreFailure;
181*cdf0e10cSrcweir     Dyn<SPU_Defines>    pSpuDefs;
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir     String              sLocalName;
186*cdf0e10cSrcweir     ary::cpp::E_ClassKey
187*cdf0e10cSrcweir                         eClassKey;
188*cdf0e10cSrcweir     ary::cpp::Class *   pCurObject;
189*cdf0e10cSrcweir     BaseList            aBases;
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir     E_KindOfResult      eResult_KindOf;
192*cdf0e10cSrcweir };
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir // IMPLEMENTATION
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir inline PE_Class::E_KindOfResult
199*cdf0e10cSrcweir PE_Class::Result_KindOf() const
200*cdf0e10cSrcweir {
201*cdf0e10cSrcweir     return eResult_KindOf;
202*cdf0e10cSrcweir }
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir inline const String  &
205*cdf0e10cSrcweir PE_Class::Result_LocalName() const
206*cdf0e10cSrcweir {
207*cdf0e10cSrcweir     return sLocalName;
208*cdf0e10cSrcweir }
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir inline const String  &
211*cdf0e10cSrcweir PE_Class::Result_FirstNameSegment() const
212*cdf0e10cSrcweir {
213*cdf0e10cSrcweir     return sLocalName;
214*cdf0e10cSrcweir }
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir }   // namespace cpp
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir 
222*cdf0e10cSrcweir #if 0   // Branches
223*cdf0e10cSrcweir 
224*cdf0e10cSrcweir class struct union
225*cdf0e10cSrcweir     -> Class
226*cdf0e10cSrcweir     -> Predeclaration
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir typedef
229*cdf0e10cSrcweir     -> Typedef
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir enum
232*cdf0e10cSrcweir     -> Enum
233*cdf0e10cSrcweir 
234*cdf0e10cSrcweir TypeDeclaration
235*cdf0e10cSrcweir     -> Function In Class
236*cdf0e10cSrcweir     -> Variable
237*cdf0e10cSrcweir 
238*cdf0e10cSrcweir public, protected, private
239*cdf0e10cSrcweir     -> Protection declaration
240*cdf0e10cSrcweir 
241*cdf0e10cSrcweir friend
242*cdf0e10cSrcweir     ->  Friend Class
243*cdf0e10cSrcweir     ->  Friend Function
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir virtual
246*cdf0e10cSrcweir     -> Function In Class
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir using
249*cdf0e10cSrcweir     -> Using Declaration
250*cdf0e10cSrcweir 
251*cdf0e10cSrcweir 
252*cdf0e10cSrcweir #endif // 0
253*cdf0e10cSrcweir 
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir #endif
256*cdf0e10cSrcweir 
257