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