Update ooo320-m1
[ooovba.git] / autodoc / source / parser_i / idl / pe_selem.cxx
blobaccd8efecc2f9b0ad56f05a0895973d986436529
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pe_selem.cxx,v $
10 * $Revision: 1.10 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include <precomp.h>
32 #include <s2_luidl/pe_selem.hxx>
34 // NOT FULLY DECLARED SERVICES
35 #include <ary/idl/i_gate.hxx>
36 #include <ary/idl/i_struct.hxx>
37 #include <ary/idl/i_structelem.hxx>
38 #include <ary/idl/ip_ce.hxx>
39 #include <ary/doc/d_oldidldocu.hxx>
40 #include <s2_luidl/pe_type2.hxx>
41 #include <s2_luidl/tk_ident.hxx>
42 #include <s2_luidl/tk_punct.hxx>
45 namespace csi
47 namespace uidl
50 namespace
52 const String C_sNone;
55 PE_StructElement::PE_StructElement( RStructElement & o_rResult,
56 const RStruct & i_rCurStruct,
57 const String & i_rCurStructTemplateParam )
58 : eState(e_none),
59 pResult(&o_rResult),
60 pCurStruct(&i_rCurStruct),
61 bIsExceptionElement(false),
62 pPE_Type(0),
63 nType(0),
64 sName(),
65 pCurStructTemplateParam(&i_rCurStructTemplateParam)
67 pPE_Type = new PE_Type(nType);
70 PE_StructElement::PE_StructElement( RStructElement & o_rResult,
71 const RStruct & i_rCurExc )
72 : eState(e_none),
73 pResult(&o_rResult),
74 pCurStruct(&i_rCurExc),
75 bIsExceptionElement(true),
76 pPE_Type(0),
77 nType(0),
78 sName(),
79 pCurStructTemplateParam(&C_sNone)
81 pPE_Type = new PE_Type(nType);
84 void
85 PE_StructElement::EstablishContacts( UnoIDL_PE * io_pParentPE,
86 ary::Repository & io_rRepository,
87 TokenProcessing_Result & o_rResult )
89 UnoIDL_PE::EstablishContacts(io_pParentPE,io_rRepository,o_rResult);
90 pPE_Type->EstablishContacts(this,io_rRepository,o_rResult);
93 PE_StructElement::~PE_StructElement()
97 void
98 PE_StructElement::ProcessToken( const Token & i_rToken )
100 i_rToken.Trigger(*this);
103 void
104 PE_StructElement::Process_Default()
106 if (eState == expect_type)
108 SetResult( not_done, push_sure, pPE_Type.Ptr() );
109 eState = expect_name;
111 else {
112 csv_assert(false);
116 void
117 PE_StructElement::Process_Identifier( const TokIdentifier & i_rToken )
119 csv_assert(*i_rToken.Text() != 0);
121 if (eState == expect_type)
123 if ( *pCurStructTemplateParam == i_rToken.Text() )
125 nType = lhf_FindTemplateParamType();
126 SetResult( done, stay );
127 eState = expect_name;
129 else // No template parameter type existing, or not matching:
131 SetResult( not_done, push_sure, pPE_Type.Ptr() );
132 eState = expect_name;
135 else if (eState == expect_name)
137 sName = i_rToken.Text();
138 SetResult( done, stay );
139 eState = expect_finish;
141 else {
142 csv_assert(false);
146 void
147 PE_StructElement::Process_Punctuation( const TokPunctuation &)
149 csv_assert(eState == expect_finish);
151 SetResult( done, pop_success );
154 void
155 PE_StructElement::InitData()
157 eState = expect_type;
159 nType = 0;
160 sName = "";
163 void
164 PE_StructElement::TransferData()
166 csv_assert(pResult != 0 AND pCurStruct != 0);
168 ary::idl::StructElement *
169 pCe = 0;
170 if (bIsExceptionElement)
172 pCe = & Gate().Ces().Store_ExceptionMember(
173 *pCurStruct,
174 sName,
175 nType );
177 else
179 pCe = & Gate().Ces().Store_StructMember(
180 *pCurStruct,
181 sName,
182 nType );
184 *pResult = pCe->CeId();
185 PassDocuAt(*pCe);
187 eState = e_none;
190 UnoIDL_PE &
191 PE_StructElement::MyPE()
193 return *this;
196 ary::idl::Type_id
197 PE_StructElement::lhf_FindTemplateParamType() const
199 const ary::idl::CodeEntity &
200 rCe = Gate().Ces().Find_Ce(*pCurStruct);
201 const ary::idl::Struct &
202 rStruct = static_cast< const ary::idl::Struct& >(rCe);
203 return rStruct.TemplateParameterType();
207 } // namespace uidl
208 } // namespace csi