1*78bc99aaSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*78bc99aaSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*78bc99aaSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*78bc99aaSAndrew Rist  * distributed with this work for additional information
6*78bc99aaSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*78bc99aaSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*78bc99aaSAndrew Rist  * "License"); you may not use this file except in compliance
9*78bc99aaSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*78bc99aaSAndrew Rist  *
11*78bc99aaSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*78bc99aaSAndrew Rist  *
13*78bc99aaSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*78bc99aaSAndrew Rist  * software distributed under the License is distributed on an
15*78bc99aaSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*78bc99aaSAndrew Rist  * KIND, either express or implied.  See the License for the
17*78bc99aaSAndrew Rist  * specific language governing permissions and limitations
18*78bc99aaSAndrew Rist  * under the License.
19*78bc99aaSAndrew Rist  *
20*78bc99aaSAndrew Rist  *************************************************************/
21cdf0e10cSrcweir 
22cdf0e10cSrcweir #include <precomp.h>
23cdf0e10cSrcweir #include <s2_luidl/pe_selem.hxx>
24cdf0e10cSrcweir 
25cdf0e10cSrcweir // NOT FULLY DECLARED SERVICES
26cdf0e10cSrcweir #include <ary/idl/i_gate.hxx>
27cdf0e10cSrcweir #include <ary/idl/i_struct.hxx>
28cdf0e10cSrcweir #include <ary/idl/i_structelem.hxx>
29cdf0e10cSrcweir #include <ary/idl/ip_ce.hxx>
30cdf0e10cSrcweir #include <ary/doc/d_oldidldocu.hxx>
31cdf0e10cSrcweir #include <s2_luidl/pe_type2.hxx>
32cdf0e10cSrcweir #include <s2_luidl/tk_ident.hxx>
33cdf0e10cSrcweir #include <s2_luidl/tk_punct.hxx>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir 
36cdf0e10cSrcweir namespace csi
37cdf0e10cSrcweir {
38cdf0e10cSrcweir namespace uidl
39cdf0e10cSrcweir {
40cdf0e10cSrcweir 
41cdf0e10cSrcweir namespace
42cdf0e10cSrcweir {
43cdf0e10cSrcweir     const String  C_sNone;
44cdf0e10cSrcweir }
45cdf0e10cSrcweir 
PE_StructElement(RStructElement & o_rResult,const RStruct & i_rCurStruct,const String & i_rCurStructTemplateParam)46cdf0e10cSrcweir PE_StructElement::PE_StructElement( RStructElement &	o_rResult,
47cdf0e10cSrcweir 									const RStruct &		i_rCurStruct,
48cdf0e10cSrcweir 							        const String &      i_rCurStructTemplateParam )
49cdf0e10cSrcweir 	:	eState(e_none),
50cdf0e10cSrcweir 		pResult(&o_rResult),
51cdf0e10cSrcweir 		pCurStruct(&i_rCurStruct),
52cdf0e10cSrcweir 		bIsExceptionElement(false),
53cdf0e10cSrcweir 		pPE_Type(0),
54cdf0e10cSrcweir 		nType(0),
55cdf0e10cSrcweir 		sName(),
56cdf0e10cSrcweir 		pCurStructTemplateParam(&i_rCurStructTemplateParam)
57cdf0e10cSrcweir {
58cdf0e10cSrcweir 	pPE_Type = new PE_Type(nType);
59cdf0e10cSrcweir }
60cdf0e10cSrcweir 
PE_StructElement(RStructElement & o_rResult,const RStruct & i_rCurExc)61cdf0e10cSrcweir PE_StructElement::PE_StructElement( RStructElement &	o_rResult,
62cdf0e10cSrcweir 							        const RStruct &		i_rCurExc )
63cdf0e10cSrcweir 	:	eState(e_none),
64cdf0e10cSrcweir 		pResult(&o_rResult),
65cdf0e10cSrcweir 		pCurStruct(&i_rCurExc),
66cdf0e10cSrcweir 		bIsExceptionElement(true),
67cdf0e10cSrcweir 		pPE_Type(0),
68cdf0e10cSrcweir 		nType(0),
69cdf0e10cSrcweir 		sName(),
70cdf0e10cSrcweir 		pCurStructTemplateParam(&C_sNone)
71cdf0e10cSrcweir {
72cdf0e10cSrcweir 	pPE_Type = new PE_Type(nType);
73cdf0e10cSrcweir }
74cdf0e10cSrcweir 
75cdf0e10cSrcweir void
EstablishContacts(UnoIDL_PE * io_pParentPE,ary::Repository & io_rRepository,TokenProcessing_Result & o_rResult)76cdf0e10cSrcweir PE_StructElement::EstablishContacts( UnoIDL_PE *				io_pParentPE,
77cdf0e10cSrcweir 									 ary::Repository &		io_rRepository,
78cdf0e10cSrcweir 							         TokenProcessing_Result & 	o_rResult )
79cdf0e10cSrcweir {
80cdf0e10cSrcweir 	UnoIDL_PE::EstablishContacts(io_pParentPE,io_rRepository,o_rResult);
81cdf0e10cSrcweir 	pPE_Type->EstablishContacts(this,io_rRepository,o_rResult);
82cdf0e10cSrcweir }
83cdf0e10cSrcweir 
~PE_StructElement()84cdf0e10cSrcweir PE_StructElement::~PE_StructElement()
85cdf0e10cSrcweir {
86cdf0e10cSrcweir }
87cdf0e10cSrcweir 
88cdf0e10cSrcweir void
ProcessToken(const Token & i_rToken)89cdf0e10cSrcweir PE_StructElement::ProcessToken( const Token & i_rToken )
90cdf0e10cSrcweir {
91cdf0e10cSrcweir 	i_rToken.Trigger(*this);
92cdf0e10cSrcweir }
93cdf0e10cSrcweir 
94cdf0e10cSrcweir void
Process_Default()95cdf0e10cSrcweir PE_StructElement::Process_Default()
96cdf0e10cSrcweir {
97cdf0e10cSrcweir 	if (eState == expect_type)
98cdf0e10cSrcweir 	{
99cdf0e10cSrcweir 		SetResult( not_done, push_sure, pPE_Type.Ptr() );
100cdf0e10cSrcweir 		eState = expect_name;
101cdf0e10cSrcweir 	}
102cdf0e10cSrcweir 	else {
103cdf0e10cSrcweir 		csv_assert(false);
104cdf0e10cSrcweir     }
105cdf0e10cSrcweir }
106cdf0e10cSrcweir 
107cdf0e10cSrcweir void
Process_Identifier(const TokIdentifier & i_rToken)108cdf0e10cSrcweir PE_StructElement::Process_Identifier( const TokIdentifier & i_rToken )
109cdf0e10cSrcweir {
110cdf0e10cSrcweir     csv_assert(*i_rToken.Text() != 0);
111cdf0e10cSrcweir 
112cdf0e10cSrcweir 	if (eState == expect_type)
113cdf0e10cSrcweir 	{
114cdf0e10cSrcweir 	    if ( *pCurStructTemplateParam == i_rToken.Text() )
115cdf0e10cSrcweir 	    {
116cdf0e10cSrcweir             nType = lhf_FindTemplateParamType();
117cdf0e10cSrcweir        		SetResult( done, stay );
118cdf0e10cSrcweir         	eState = expect_name;
119cdf0e10cSrcweir 	    }
120cdf0e10cSrcweir 	    else    // No template parameter type existing, or not matching:
121cdf0e10cSrcweir 	    {
122cdf0e10cSrcweir        		SetResult( not_done, push_sure, pPE_Type.Ptr() );
123cdf0e10cSrcweir         	eState = expect_name;
124cdf0e10cSrcweir 	    }
125cdf0e10cSrcweir 	}
126cdf0e10cSrcweir 	else if (eState == expect_name)
127cdf0e10cSrcweir 	{
128cdf0e10cSrcweir 		sName = i_rToken.Text();
129cdf0e10cSrcweir 		SetResult( done, stay );
130cdf0e10cSrcweir         eState = expect_finish;
131cdf0e10cSrcweir 	}
132cdf0e10cSrcweir 	else {
133cdf0e10cSrcweir 		csv_assert(false);
134cdf0e10cSrcweir     }
135cdf0e10cSrcweir }
136cdf0e10cSrcweir 
137cdf0e10cSrcweir void
Process_Punctuation(const TokPunctuation &)138cdf0e10cSrcweir PE_StructElement::Process_Punctuation( const TokPunctuation &)
139cdf0e10cSrcweir {
140cdf0e10cSrcweir     csv_assert(eState == expect_finish);
141cdf0e10cSrcweir 
142cdf0e10cSrcweir 	SetResult( done, pop_success );
143cdf0e10cSrcweir }
144cdf0e10cSrcweir 
145cdf0e10cSrcweir void
InitData()146cdf0e10cSrcweir PE_StructElement::InitData()
147cdf0e10cSrcweir {
148cdf0e10cSrcweir 	eState = expect_type;
149cdf0e10cSrcweir 
150cdf0e10cSrcweir 	nType = 0;
151cdf0e10cSrcweir 	sName = "";
152cdf0e10cSrcweir }
153cdf0e10cSrcweir 
154cdf0e10cSrcweir void
TransferData()155cdf0e10cSrcweir PE_StructElement::TransferData()
156cdf0e10cSrcweir {
157cdf0e10cSrcweir 	csv_assert(pResult != 0 AND pCurStruct != 0);
158cdf0e10cSrcweir 
159cdf0e10cSrcweir     ary::idl::StructElement *
160cdf0e10cSrcweir         pCe = 0;
161cdf0e10cSrcweir     if (bIsExceptionElement)
162cdf0e10cSrcweir     {
163cdf0e10cSrcweir         pCe = & Gate().Ces().Store_ExceptionMember(
164cdf0e10cSrcweir                                             *pCurStruct,
165cdf0e10cSrcweir                                             sName,
166cdf0e10cSrcweir                                             nType );
167cdf0e10cSrcweir     }
168cdf0e10cSrcweir     else
169cdf0e10cSrcweir     {
170cdf0e10cSrcweir         pCe = & Gate().Ces().Store_StructMember(
171cdf0e10cSrcweir                                             *pCurStruct,
172cdf0e10cSrcweir                                             sName,
173cdf0e10cSrcweir                                             nType );
174cdf0e10cSrcweir     }
175cdf0e10cSrcweir 	*pResult = pCe->CeId();
176cdf0e10cSrcweir 	PassDocuAt(*pCe);
177cdf0e10cSrcweir 
178cdf0e10cSrcweir 	eState = e_none;
179cdf0e10cSrcweir }
180cdf0e10cSrcweir 
181cdf0e10cSrcweir UnoIDL_PE &
MyPE()182cdf0e10cSrcweir PE_StructElement::MyPE()
183cdf0e10cSrcweir {
184cdf0e10cSrcweir 	return *this;
185cdf0e10cSrcweir }
186cdf0e10cSrcweir 
187cdf0e10cSrcweir ary::idl::Type_id
lhf_FindTemplateParamType() const188cdf0e10cSrcweir PE_StructElement::lhf_FindTemplateParamType() const
189cdf0e10cSrcweir {
190cdf0e10cSrcweir     const ary::idl::CodeEntity &
191cdf0e10cSrcweir         rCe = Gate().Ces().Find_Ce(*pCurStruct);
192cdf0e10cSrcweir     const ary::idl::Struct &
193cdf0e10cSrcweir         rStruct = static_cast< const ary::idl::Struct& >(rCe);
194cdf0e10cSrcweir     return rStruct.TemplateParameterType();
195cdf0e10cSrcweir }
196cdf0e10cSrcweir 
197cdf0e10cSrcweir 
198cdf0e10cSrcweir }   // namespace uidl
199cdf0e10cSrcweir }   // namespace csi
200