xref: /trunk/main/autodoc/source/parser/cpp/pe_tydef.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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 #include <precomp.h>
29 #include "pe_tydef.hxx"
30 
31 
32 // NOT FULLY DECLARED SERVICES
33 #include <ary/cpp/c_gate.hxx>
34 #include <ary/cpp/c_type.hxx>
35 #include <ary/cpp/cp_ce.hxx>
36 #include <all_toks.hxx>
37 #include "pe_type.hxx"
38 
39 
40 namespace cpp {
41 
42 
43 PE_Typedef::PE_Typedef(Cpp_PE * i_pParent )
44     :   Cpp_PE(i_pParent),
45         pStati( new PeStatusArray<PE_Typedef> ),
46         // pSpType,
47         // pSpuType,
48         // sName
49         nType(0)
50 {
51     Setup_StatusFunctions();
52 
53     pSpType    = new SP_Type(*this);
54     pSpuType   = new SPU_Type(*pSpType, 0, &PE_Typedef::SpReturn_Type);
55 }
56 
57 PE_Typedef::~PE_Typedef()
58 {
59 }
60 
61 void
62 PE_Typedef::Call_Handler( const cpp::Token & i_rTok )
63 {
64     pStati->Cur().Call_Handler(i_rTok.TypeId(), i_rTok.Text());
65 }
66 
67 void
68 PE_Typedef::Setup_StatusFunctions()
69 {
70     typedef CallFunction<PE_Typedef>::F_Tok F_Tok;
71     static F_Tok stateF_start[] =       { &PE_Typedef::On_start_typedef };
72     static INT16 stateT_start[] =       { Tid_typedef };
73 
74     static F_Tok stateF_expectName[] =  { &PE_Typedef::On_expectName_Identifier };
75     static INT16 stateT_expectName[] =  { Tid_Identifier };
76 
77     static F_Tok stateF_afterName[] =   { &PE_Typedef::On_afterName_Semicolon };
78     static INT16 stateT_afterName[] =   { Tid_Semicolon };
79 
80     SEMPARSE_CREATE_STATUS(PE_Typedef, start, Hdl_SyntaxError);
81     SEMPARSE_CREATE_STATUS(PE_Typedef, expectName, Hdl_SyntaxError);
82     SEMPARSE_CREATE_STATUS(PE_Typedef, afterName, Hdl_SyntaxError);
83 }
84 
85 void
86 PE_Typedef::InitData()
87 {
88     pStati->SetCur(start);
89 
90     sName.clear();
91     nType = 0;
92 }
93 
94 void
95 PE_Typedef::TransferData()
96 {
97     pStati->SetCur(size_of_states);
98 
99     ary::cpp::Typedef &
100     rTypedef = Env().AryGate().Ces().Store_Typedef(
101                         Env().Context(), sName, nType );
102     Env().Event_Store_Typedef(rTypedef);
103 }
104 
105 void
106 PE_Typedef::Hdl_SyntaxError( const char * i_sText)
107 {
108     StdHandlingOfSyntaxError(i_sText);
109 }
110 
111 void
112 PE_Typedef::SpReturn_Type()
113 {
114     pStati->SetCur(expectName);
115 
116     nType = pSpuType->Child().Result_Type().Id();
117 }
118 
119 void
120 PE_Typedef::On_start_typedef( const char * )
121 {
122     pSpuType->Push(done);
123 }
124 
125 void
126 PE_Typedef::On_expectName_Identifier( const char * i_sText )
127 {
128     SetTokenResult(done, stay);
129     pStati->SetCur(afterName);
130 
131     sName = i_sText;
132 }
133 
134 void
135 PE_Typedef::On_afterName_Semicolon( const char * )
136 {
137     SetTokenResult(done, pop_success);
138 }
139 
140 }   // namespace cpp
141 
142 
143 
144