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 #include <precomp.h>
29*cdf0e10cSrcweir #include <s2_luidl/pe_selem.hxx>
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir // NOT FULLY DECLARED SERVICES
32*cdf0e10cSrcweir #include <ary/idl/i_gate.hxx>
33*cdf0e10cSrcweir #include <ary/idl/i_struct.hxx>
34*cdf0e10cSrcweir #include <ary/idl/i_structelem.hxx>
35*cdf0e10cSrcweir #include <ary/idl/ip_ce.hxx>
36*cdf0e10cSrcweir #include <ary/doc/d_oldidldocu.hxx>
37*cdf0e10cSrcweir #include <s2_luidl/pe_type2.hxx>
38*cdf0e10cSrcweir #include <s2_luidl/tk_ident.hxx>
39*cdf0e10cSrcweir #include <s2_luidl/tk_punct.hxx>
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir namespace csi
43*cdf0e10cSrcweir {
44*cdf0e10cSrcweir namespace uidl
45*cdf0e10cSrcweir {
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir namespace
48*cdf0e10cSrcweir {
49*cdf0e10cSrcweir     const String  C_sNone;
50*cdf0e10cSrcweir }
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir PE_StructElement::PE_StructElement( RStructElement &	o_rResult,
53*cdf0e10cSrcweir 									const RStruct &		i_rCurStruct,
54*cdf0e10cSrcweir 							        const String &      i_rCurStructTemplateParam )
55*cdf0e10cSrcweir 	:	eState(e_none),
56*cdf0e10cSrcweir 		pResult(&o_rResult),
57*cdf0e10cSrcweir 		pCurStruct(&i_rCurStruct),
58*cdf0e10cSrcweir 		bIsExceptionElement(false),
59*cdf0e10cSrcweir 		pPE_Type(0),
60*cdf0e10cSrcweir 		nType(0),
61*cdf0e10cSrcweir 		sName(),
62*cdf0e10cSrcweir 		pCurStructTemplateParam(&i_rCurStructTemplateParam)
63*cdf0e10cSrcweir {
64*cdf0e10cSrcweir 	pPE_Type = new PE_Type(nType);
65*cdf0e10cSrcweir }
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir PE_StructElement::PE_StructElement( RStructElement &	o_rResult,
68*cdf0e10cSrcweir 							        const RStruct &		i_rCurExc )
69*cdf0e10cSrcweir 	:	eState(e_none),
70*cdf0e10cSrcweir 		pResult(&o_rResult),
71*cdf0e10cSrcweir 		pCurStruct(&i_rCurExc),
72*cdf0e10cSrcweir 		bIsExceptionElement(true),
73*cdf0e10cSrcweir 		pPE_Type(0),
74*cdf0e10cSrcweir 		nType(0),
75*cdf0e10cSrcweir 		sName(),
76*cdf0e10cSrcweir 		pCurStructTemplateParam(&C_sNone)
77*cdf0e10cSrcweir {
78*cdf0e10cSrcweir 	pPE_Type = new PE_Type(nType);
79*cdf0e10cSrcweir }
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir void
82*cdf0e10cSrcweir PE_StructElement::EstablishContacts( UnoIDL_PE *				io_pParentPE,
83*cdf0e10cSrcweir 									 ary::Repository &		io_rRepository,
84*cdf0e10cSrcweir 							         TokenProcessing_Result & 	o_rResult )
85*cdf0e10cSrcweir {
86*cdf0e10cSrcweir 	UnoIDL_PE::EstablishContacts(io_pParentPE,io_rRepository,o_rResult);
87*cdf0e10cSrcweir 	pPE_Type->EstablishContacts(this,io_rRepository,o_rResult);
88*cdf0e10cSrcweir }
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir PE_StructElement::~PE_StructElement()
91*cdf0e10cSrcweir {
92*cdf0e10cSrcweir }
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir void
95*cdf0e10cSrcweir PE_StructElement::ProcessToken( const Token & i_rToken )
96*cdf0e10cSrcweir {
97*cdf0e10cSrcweir 	i_rToken.Trigger(*this);
98*cdf0e10cSrcweir }
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir void
101*cdf0e10cSrcweir PE_StructElement::Process_Default()
102*cdf0e10cSrcweir {
103*cdf0e10cSrcweir 	if (eState == expect_type)
104*cdf0e10cSrcweir 	{
105*cdf0e10cSrcweir 		SetResult( not_done, push_sure, pPE_Type.Ptr() );
106*cdf0e10cSrcweir 		eState = expect_name;
107*cdf0e10cSrcweir 	}
108*cdf0e10cSrcweir 	else {
109*cdf0e10cSrcweir 		csv_assert(false);
110*cdf0e10cSrcweir     }
111*cdf0e10cSrcweir }
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir void
114*cdf0e10cSrcweir PE_StructElement::Process_Identifier( const TokIdentifier & i_rToken )
115*cdf0e10cSrcweir {
116*cdf0e10cSrcweir     csv_assert(*i_rToken.Text() != 0);
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir 	if (eState == expect_type)
119*cdf0e10cSrcweir 	{
120*cdf0e10cSrcweir 	    if ( *pCurStructTemplateParam == i_rToken.Text() )
121*cdf0e10cSrcweir 	    {
122*cdf0e10cSrcweir             nType = lhf_FindTemplateParamType();
123*cdf0e10cSrcweir        		SetResult( done, stay );
124*cdf0e10cSrcweir         	eState = expect_name;
125*cdf0e10cSrcweir 	    }
126*cdf0e10cSrcweir 	    else    // No template parameter type existing, or not matching:
127*cdf0e10cSrcweir 	    {
128*cdf0e10cSrcweir        		SetResult( not_done, push_sure, pPE_Type.Ptr() );
129*cdf0e10cSrcweir         	eState = expect_name;
130*cdf0e10cSrcweir 	    }
131*cdf0e10cSrcweir 	}
132*cdf0e10cSrcweir 	else if (eState == expect_name)
133*cdf0e10cSrcweir 	{
134*cdf0e10cSrcweir 		sName = i_rToken.Text();
135*cdf0e10cSrcweir 		SetResult( done, stay );
136*cdf0e10cSrcweir         eState = expect_finish;
137*cdf0e10cSrcweir 	}
138*cdf0e10cSrcweir 	else {
139*cdf0e10cSrcweir 		csv_assert(false);
140*cdf0e10cSrcweir     }
141*cdf0e10cSrcweir }
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir void
144*cdf0e10cSrcweir PE_StructElement::Process_Punctuation( const TokPunctuation &)
145*cdf0e10cSrcweir {
146*cdf0e10cSrcweir     csv_assert(eState == expect_finish);
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir 	SetResult( done, pop_success );
149*cdf0e10cSrcweir }
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir void
152*cdf0e10cSrcweir PE_StructElement::InitData()
153*cdf0e10cSrcweir {
154*cdf0e10cSrcweir 	eState = expect_type;
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir 	nType = 0;
157*cdf0e10cSrcweir 	sName = "";
158*cdf0e10cSrcweir }
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir void
161*cdf0e10cSrcweir PE_StructElement::TransferData()
162*cdf0e10cSrcweir {
163*cdf0e10cSrcweir 	csv_assert(pResult != 0 AND pCurStruct != 0);
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir     ary::idl::StructElement *
166*cdf0e10cSrcweir         pCe = 0;
167*cdf0e10cSrcweir     if (bIsExceptionElement)
168*cdf0e10cSrcweir     {
169*cdf0e10cSrcweir         pCe = & Gate().Ces().Store_ExceptionMember(
170*cdf0e10cSrcweir                                             *pCurStruct,
171*cdf0e10cSrcweir                                             sName,
172*cdf0e10cSrcweir                                             nType );
173*cdf0e10cSrcweir     }
174*cdf0e10cSrcweir     else
175*cdf0e10cSrcweir     {
176*cdf0e10cSrcweir         pCe = & Gate().Ces().Store_StructMember(
177*cdf0e10cSrcweir                                             *pCurStruct,
178*cdf0e10cSrcweir                                             sName,
179*cdf0e10cSrcweir                                             nType );
180*cdf0e10cSrcweir     }
181*cdf0e10cSrcweir 	*pResult = pCe->CeId();
182*cdf0e10cSrcweir 	PassDocuAt(*pCe);
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir 	eState = e_none;
185*cdf0e10cSrcweir }
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir UnoIDL_PE &
188*cdf0e10cSrcweir PE_StructElement::MyPE()
189*cdf0e10cSrcweir {
190*cdf0e10cSrcweir 	return *this;
191*cdf0e10cSrcweir }
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir ary::idl::Type_id
194*cdf0e10cSrcweir PE_StructElement::lhf_FindTemplateParamType() const
195*cdf0e10cSrcweir {
196*cdf0e10cSrcweir     const ary::idl::CodeEntity &
197*cdf0e10cSrcweir         rCe = Gate().Ces().Find_Ce(*pCurStruct);
198*cdf0e10cSrcweir     const ary::idl::Struct &
199*cdf0e10cSrcweir         rStruct = static_cast< const ary::idl::Struct& >(rCe);
200*cdf0e10cSrcweir     return rStruct.TemplateParameterType();
201*cdf0e10cSrcweir }
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir }   // namespace uidl
205*cdf0e10cSrcweir }   // namespace csi
206