xref: /AOO41X/main/autodoc/source/ary/idl/i2s_calculator.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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 "i2s_calculator.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir // NOT FULLY DEFINED SERVICES
33*cdf0e10cSrcweir #include <algorithm>
34*cdf0e10cSrcweir #include <string.h>
35*cdf0e10cSrcweir #include <cosv/file.hxx>
36*cdf0e10cSrcweir //#include <adc_manager.hxx>
37*cdf0e10cSrcweir //#include <adc_options.hxx>
38*cdf0e10cSrcweir #include <ary/qualiname.hxx>
39*cdf0e10cSrcweir #include <ary/idl/i_enum.hxx>
40*cdf0e10cSrcweir #include <ary/idl/i_exception.hxx>
41*cdf0e10cSrcweir #include <ary/idl/i_function.hxx>
42*cdf0e10cSrcweir #include <ary/idl/i_gate.hxx>
43*cdf0e10cSrcweir #include <ary/idl/i_interface.hxx>
44*cdf0e10cSrcweir #include <ary/idl/ik_interface.hxx>
45*cdf0e10cSrcweir #include <ary/idl/i_module.hxx>
46*cdf0e10cSrcweir #include <ary/idl/i_property.hxx>
47*cdf0e10cSrcweir #include <ary/idl/i_service.hxx>
48*cdf0e10cSrcweir #include <ary/idl/i_singleton.hxx>
49*cdf0e10cSrcweir #include <ary/idl/i_siservice.hxx>
50*cdf0e10cSrcweir #include <ary/idl/i_sisingleton.hxx>
51*cdf0e10cSrcweir #include <ary/idl/i_struct.hxx>
52*cdf0e10cSrcweir #include <ary/idl/i_structelem.hxx>
53*cdf0e10cSrcweir #include <ary/idl/i_typedef.hxx>
54*cdf0e10cSrcweir #include <ary/idl/ip_ce.hxx>
55*cdf0e10cSrcweir #include <ary/idl/ip_type.hxx>
56*cdf0e10cSrcweir #include <ary/namesort.hxx>
57*cdf0e10cSrcweir #include <nametreenode.hxx>
58*cdf0e10cSrcweir #include "i_nnfinder.hxx"
59*cdf0e10cSrcweir #include "ia_ce.hxx"
60*cdf0e10cSrcweir #include "ia_type.hxx"
61*cdf0e10cSrcweir #include "is_ce.hxx"
62*cdf0e10cSrcweir #include "is_type.hxx"
63*cdf0e10cSrcweir #include "it_ce.hxx"
64*cdf0e10cSrcweir #include "it_explicit.hxx"
65*cdf0e10cSrcweir #include "it_sequence.hxx"
66*cdf0e10cSrcweir #include "it_xnameroom.hxx"
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir namespace ary
71*cdf0e10cSrcweir {
72*cdf0e10cSrcweir namespace idl
73*cdf0e10cSrcweir {
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir template <class DEST>
76*cdf0e10cSrcweir DEST *
77*cdf0e10cSrcweir SecondariesCalculator::SearchCe4Type(Type_id i_type)
78*cdf0e10cSrcweir {
79*cdf0e10cSrcweir     Ce_id
80*cdf0e10cSrcweir         ce = lhf_Search_CeFromTypeId(i_type);
81*cdf0e10cSrcweir     if (ce.IsValid())
82*cdf0e10cSrcweir         return ary_cast<DEST>(& my_CeStorage()[ce]);
83*cdf0e10cSrcweir     return 0;
84*cdf0e10cSrcweir }
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir typedef stg::const_iterator<CodeEntity> stg_citerator;
88*cdf0e10cSrcweir typedef stg::iterator<CodeEntity>       stg_iterator;
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir typedef stg::filter_iterator<CodeEntity,Interface>
91*cdf0e10cSrcweir                                         interface_iterator;
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir typedef stg::filter_iterator<Type,ExplicitType>
94*cdf0e10cSrcweir                                         explicittype_iterator;
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir typedef ary::stg::const_filter_iterator<CodeEntity,Typedef>
97*cdf0e10cSrcweir                                         typedef_citerator;
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir inline Service *
101*cdf0e10cSrcweir SecondariesCalculator::lhf_SearchService( Type_id i_nType )
102*cdf0e10cSrcweir {
103*cdf0e10cSrcweir     return SearchCe4Type<Service>(i_nType);
104*cdf0e10cSrcweir }
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir inline Interface *
107*cdf0e10cSrcweir SecondariesCalculator::lhf_SearchInterface( Type_id i_nType )
108*cdf0e10cSrcweir {
109*cdf0e10cSrcweir     return SearchCe4Type<Interface>(i_nType);
110*cdf0e10cSrcweir }
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir inline Struct *
113*cdf0e10cSrcweir SecondariesCalculator::lhf_SearchStruct( Type_id i_nType )
114*cdf0e10cSrcweir {
115*cdf0e10cSrcweir     return SearchCe4Type<Struct>(i_nType);
116*cdf0e10cSrcweir }
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir inline Exception *
119*cdf0e10cSrcweir SecondariesCalculator::lhf_SearchException( Type_id i_nType )
120*cdf0e10cSrcweir {
121*cdf0e10cSrcweir     return SearchCe4Type<Exception>(i_nType);
122*cdf0e10cSrcweir }
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir inline const Ce_Storage &
125*cdf0e10cSrcweir SecondariesCalculator::my_CeStorage() const
126*cdf0e10cSrcweir {
127*cdf0e10cSrcweir     csv_assert(pCes != 0);
128*cdf0e10cSrcweir     return pCes->Storage();
129*cdf0e10cSrcweir }
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir inline const Type_Storage &
132*cdf0e10cSrcweir SecondariesCalculator::my_TypeStorage() const
133*cdf0e10cSrcweir {
134*cdf0e10cSrcweir     csv_assert(pTypes != 0);
135*cdf0e10cSrcweir     return pTypes->Storage();
136*cdf0e10cSrcweir }
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir inline Ce_Storage &
139*cdf0e10cSrcweir SecondariesCalculator::my_CeStorage()
140*cdf0e10cSrcweir {
141*cdf0e10cSrcweir     csv_assert(pCes != 0);
142*cdf0e10cSrcweir     return pCes->Storage();
143*cdf0e10cSrcweir }
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir inline Type_Storage &
146*cdf0e10cSrcweir SecondariesCalculator::my_TypeStorage()
147*cdf0e10cSrcweir {
148*cdf0e10cSrcweir     csv_assert(pTypes != 0);
149*cdf0e10cSrcweir     return pTypes->Storage();
150*cdf0e10cSrcweir }
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir inline void
153*cdf0e10cSrcweir SecondariesCalculator::insert_into2sList( CodeEntity &        o_out,
154*cdf0e10cSrcweir                                           int                 i_listIndex,
155*cdf0e10cSrcweir                                           Ce_id               i_nCe )
156*cdf0e10cSrcweir     { o_out.Secondaries().Access_List(i_listIndex).push_back(i_nCe); }
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir SecondariesCalculator::SecondariesCalculator( CeAdmin &      i_ces,
160*cdf0e10cSrcweir                                               TypeAdmin &    i_types )
161*cdf0e10cSrcweir     :   pCes(&i_ces),
162*cdf0e10cSrcweir         pTypes(&i_types)
163*cdf0e10cSrcweir {
164*cdf0e10cSrcweir }
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir SecondariesCalculator::~SecondariesCalculator()
167*cdf0e10cSrcweir {
168*cdf0e10cSrcweir }
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir void
172*cdf0e10cSrcweir SecondariesCalculator::CheckAllInterfaceBases()
173*cdf0e10cSrcweir {
174*cdf0e10cSrcweir     Module &
175*cdf0e10cSrcweir         rGlobalNamespace = pCes->GlobalNamespace();
176*cdf0e10cSrcweir     QualifiedName
177*cdf0e10cSrcweir         aXInterface("::com::sun::star::uno::XInterface","::");
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir     const Type &
180*cdf0e10cSrcweir         rType = pTypes->CheckIn_Type(   aXInterface,
181*cdf0e10cSrcweir                                         0,
182*cdf0e10cSrcweir                                         rGlobalNamespace.CeId(),
183*cdf0e10cSrcweir                                         0 );
184*cdf0e10cSrcweir     Type_id
185*cdf0e10cSrcweir         nTypeXInterface = rType.TypeId();
186*cdf0e10cSrcweir     const ExplicitType &
187*cdf0e10cSrcweir         rExplType = ary_cast<ExplicitType>(rType);
188*cdf0e10cSrcweir     Ce_id
189*cdf0e10cSrcweir         nCeXInterface = lhf_Search_CeForType(rExplType);
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir     interface_iterator itEnd( my_CeStorage().End() );
192*cdf0e10cSrcweir     for ( interface_iterator it( my_CeStorage().BeginUnreserved() );
193*cdf0e10cSrcweir           it != itEnd;
194*cdf0e10cSrcweir           ++it )
195*cdf0e10cSrcweir     {
196*cdf0e10cSrcweir         if (NOT it.IsValid())
197*cdf0e10cSrcweir             continue;
198*cdf0e10cSrcweir 
199*cdf0e10cSrcweir         Interface &
200*cdf0e10cSrcweir             rInterface = *it;
201*cdf0e10cSrcweir         if (     NOT rInterface.HasBase()               // According to UNO IDL syntax, an interface without base has com::sun::star::uno::XInterface as base.
202*cdf0e10cSrcweir              AND rInterface.CeId() != nCeXInterface )   // XInterface must not be base of itself.
203*cdf0e10cSrcweir         {
204*cdf0e10cSrcweir             rInterface.Add_Base(nTypeXInterface, 0);
205*cdf0e10cSrcweir         }
206*cdf0e10cSrcweir     }   // end for
207*cdf0e10cSrcweir }
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir void
210*cdf0e10cSrcweir SecondariesCalculator::Connect_Types2Ces()
211*cdf0e10cSrcweir {
212*cdf0e10cSrcweir     explicittype_iterator itEnd( my_TypeStorage().End() );
213*cdf0e10cSrcweir     for ( explicittype_iterator it( my_TypeStorage().BeginUnreserved() );
214*cdf0e10cSrcweir           it != itEnd;
215*cdf0e10cSrcweir           ++it )
216*cdf0e10cSrcweir     {
217*cdf0e10cSrcweir         if (NOT it.IsValid())
218*cdf0e10cSrcweir             continue;
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir         ExplicitType &
221*cdf0e10cSrcweir             rType = ary_cast<ExplicitType>(*it);
222*cdf0e10cSrcweir         Ce_id
223*cdf0e10cSrcweir             nRelatedCe = lhf_Search_CeForType(rType);
224*cdf0e10cSrcweir         if (nRelatedCe.IsValid())
225*cdf0e10cSrcweir         {
226*cdf0e10cSrcweir             Ce_Type *
227*cdf0e10cSrcweir                 pNew = new Ce_Type(nRelatedCe, rType.TemplateParameters());
228*cdf0e10cSrcweir             my_TypeStorage().Replace_Entity( rType.TypeId(),
229*cdf0e10cSrcweir                                              *pNew );
230*cdf0e10cSrcweir         }
231*cdf0e10cSrcweir     }   // end for
232*cdf0e10cSrcweir }
233*cdf0e10cSrcweir 
234*cdf0e10cSrcweir void
235*cdf0e10cSrcweir SecondariesCalculator::Gather_CrossReferences()
236*cdf0e10cSrcweir {
237*cdf0e10cSrcweir     gather_Synonyms();
238*cdf0e10cSrcweir 
239*cdf0e10cSrcweir     for ( stg_iterator it = my_CeStorage().Begin();
240*cdf0e10cSrcweir           it != my_CeStorage().End();
241*cdf0e10cSrcweir           ++it )
242*cdf0e10cSrcweir     {
243*cdf0e10cSrcweir         (*it).Accept( static_cast< SPInst_asHost& >(*this) );
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir     }   // end for
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir     sort_All2s();
248*cdf0e10cSrcweir }
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir void
251*cdf0e10cSrcweir SecondariesCalculator::Make_Links2DeveloperManual(
252*cdf0e10cSrcweir                                 const String &      i_devman_reffilepath )
253*cdf0e10cSrcweir {
254*cdf0e10cSrcweir //    const autodoc::Options &
255*cdf0e10cSrcweir //        rOptions = TheAutodocManager().TheOptions();
256*cdf0e10cSrcweir //
257*cdf0e10cSrcweir //    const String &
258*cdf0e10cSrcweir //        rDeveloperManual_URL
259*cdf0e10cSrcweir //            = rOptions.Get_Extra(autodoc::OPT_developer_guide);
260*cdf0e10cSrcweir //    const String
261*cdf0e10cSrcweir //        rDeveloperManual_ReferenceFile
262*cdf0e10cSrcweir //            = rOptions.Get_Extra(autodoc::OPT_developer_guide_refs_file);
263*cdf0e10cSrcweir 
264*cdf0e10cSrcweir //    if ( rDeveloperManual_URL.length() == 0
265*cdf0e10cSrcweir //         OR
266*cdf0e10cSrcweir //         rDeveloperManual_ReferenceFile.length() == 0 )
267*cdf0e10cSrcweir //    {
268*cdf0e10cSrcweir //        return;
269*cdf0e10cSrcweir //    }
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir     csv::File
272*cdf0e10cSrcweir         aFile(i_devman_reffilepath, csv::CFM_READ);
273*cdf0e10cSrcweir     csv::OpenCloseGuard
274*cdf0e10cSrcweir         aFileOpener(aFile);
275*cdf0e10cSrcweir     if (aFileOpener)
276*cdf0e10cSrcweir     {
277*cdf0e10cSrcweir         Read_Links2DevManual(aFile);
278*cdf0e10cSrcweir     }
279*cdf0e10cSrcweir }
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir namespace
282*cdf0e10cSrcweir {
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir enum E_LinkMode
285*cdf0e10cSrcweir {
286*cdf0e10cSrcweir     link2descr,
287*cdf0e10cSrcweir     link2ref
288*cdf0e10cSrcweir };
289*cdf0e10cSrcweir 
290*cdf0e10cSrcweir struct OrderCeIdsByName
291*cdf0e10cSrcweir {
292*cdf0e10cSrcweir                         OrderCeIdsByName(
293*cdf0e10cSrcweir                             const Ce_Storage &      i_storage )
294*cdf0e10cSrcweir                                 :   rStorage(i_storage),
295*cdf0e10cSrcweir                                     aNameComparison() {}
296*cdf0e10cSrcweir     bool                operator()(
297*cdf0e10cSrcweir                             Ce_id                   i_ce1,
298*cdf0e10cSrcweir                             Ce_id                   i_ce2 ) const
299*cdf0e10cSrcweir     {
300*cdf0e10cSrcweir         return aNameComparison( rStorage[i_ce1].LocalName(),
301*cdf0e10cSrcweir                                 rStorage[i_ce2].LocalName() );
302*cdf0e10cSrcweir     }
303*cdf0e10cSrcweir 
304*cdf0e10cSrcweir   private:
305*cdf0e10cSrcweir     const Ce_Storage &  rStorage;
306*cdf0e10cSrcweir     LesserName          aNameComparison;
307*cdf0e10cSrcweir };
308*cdf0e10cSrcweir 
309*cdf0e10cSrcweir 
310*cdf0e10cSrcweir }
311*cdf0e10cSrcweir 
312*cdf0e10cSrcweir 
313*cdf0e10cSrcweir 
314*cdf0e10cSrcweir void
315*cdf0e10cSrcweir SecondariesCalculator::do_Process( const Service & i_rData )
316*cdf0e10cSrcweir {
317*cdf0e10cSrcweir     const Service &
318*cdf0e10cSrcweir         rService = ary_cast<Service>(i_rData);
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir     // Interfaces:
321*cdf0e10cSrcweir     assignImplementation_toAServicesInterfaces( rService.CeId(),
322*cdf0e10cSrcweir 												rService.CeId(),
323*cdf0e10cSrcweir 												interface_2s_ExportingServices );
324*cdf0e10cSrcweir     // Services and their interfaces:
325*cdf0e10cSrcweir     recursive_AssignIncludingService(rService.CeId(), rService);
326*cdf0e10cSrcweir }
327*cdf0e10cSrcweir 
328*cdf0e10cSrcweir void
329*cdf0e10cSrcweir SecondariesCalculator::do_Process( const Interface & i_rData )
330*cdf0e10cSrcweir {
331*cdf0e10cSrcweir     assign_AsDerivedInterface( ary_cast<Interface>(i_rData) );
332*cdf0e10cSrcweir }
333*cdf0e10cSrcweir 
334*cdf0e10cSrcweir void
335*cdf0e10cSrcweir SecondariesCalculator::do_Process( const Struct &  i_rData )
336*cdf0e10cSrcweir {
337*cdf0e10cSrcweir     assign_AsDerivedStruct( ary_cast<Struct>(i_rData) );
338*cdf0e10cSrcweir }
339*cdf0e10cSrcweir 
340*cdf0e10cSrcweir void
341*cdf0e10cSrcweir SecondariesCalculator::do_Process( const Exception &  i_rData )
342*cdf0e10cSrcweir {
343*cdf0e10cSrcweir     assign_AsDerivedException( ary_cast<Exception>(i_rData) );
344*cdf0e10cSrcweir }
345*cdf0e10cSrcweir 
346*cdf0e10cSrcweir void
347*cdf0e10cSrcweir SecondariesCalculator::do_Process( const Typedef &  )
348*cdf0e10cSrcweir {
349*cdf0e10cSrcweir     // KORR_FUTURE
350*cdf0e10cSrcweir     // Find out what was meant here ???
351*cdf0e10cSrcweir 
352*cdf0e10cSrcweir //    const Typedef &
353*cdf0e10cSrcweir //        rTypedef = ary_cast<Typedef>(i_rData);
354*cdf0e10cSrcweir }
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir void
357*cdf0e10cSrcweir SecondariesCalculator::do_Process( const Singleton &  i_rData )
358*cdf0e10cSrcweir {
359*cdf0e10cSrcweir     const Singleton &
360*cdf0e10cSrcweir         rSingleton = ary_cast<Singleton>(i_rData);
361*cdf0e10cSrcweir 
362*cdf0e10cSrcweir     Service *
363*cdf0e10cSrcweir         pServ = lhf_SearchService(rSingleton.AssociatedService());
364*cdf0e10cSrcweir     if (pServ != 0)
365*cdf0e10cSrcweir     {
366*cdf0e10cSrcweir         insert_into2sUnique( *pServ,
367*cdf0e10cSrcweir 							 service_2s_InstantiatingSingletons,
368*cdf0e10cSrcweir 							 rSingleton.CeId() );
369*cdf0e10cSrcweir     }
370*cdf0e10cSrcweir 
371*cdf0e10cSrcweir     // Interfaces:
372*cdf0e10cSrcweir     assignImplementation_toAServicesInterfaces( rSingleton.CeId(),
373*cdf0e10cSrcweir 												lhf_Search_CeFromTypeId(rSingleton.AssociatedService()),
374*cdf0e10cSrcweir 												interface_2s_ExportingSingletons );
375*cdf0e10cSrcweir }
376*cdf0e10cSrcweir 
377*cdf0e10cSrcweir void
378*cdf0e10cSrcweir SecondariesCalculator::do_Process( const SglIfcService &  i_rData )
379*cdf0e10cSrcweir {
380*cdf0e10cSrcweir     const SglIfcService &
381*cdf0e10cSrcweir         rSglIfcService = ary_cast<SglIfcService>(i_rData);
382*cdf0e10cSrcweir 
383*cdf0e10cSrcweir     assignImplementation_toAServicesInterfaces( rSglIfcService.CeId(),
384*cdf0e10cSrcweir 												rSglIfcService.CeId(),
385*cdf0e10cSrcweir 												interface_2s_ExportingServices );
386*cdf0e10cSrcweir }
387*cdf0e10cSrcweir 
388*cdf0e10cSrcweir void
389*cdf0e10cSrcweir SecondariesCalculator::do_Process( const SglIfcSingleton &  i_rData )
390*cdf0e10cSrcweir {
391*cdf0e10cSrcweir     const SglIfcSingleton &
392*cdf0e10cSrcweir         rSglIfcSingleton = ary_cast<SglIfcSingleton>(i_rData);
393*cdf0e10cSrcweir 
394*cdf0e10cSrcweir     Type_id nBase = rSglIfcSingleton.BaseInterface();
395*cdf0e10cSrcweir     recursive_AssignImplementation_toExportedInterface( rSglIfcSingleton.CeId(),
396*cdf0e10cSrcweir 														nBase,
397*cdf0e10cSrcweir 														interface_2s_ExportingSingletons );
398*cdf0e10cSrcweir }
399*cdf0e10cSrcweir 
400*cdf0e10cSrcweir void
401*cdf0e10cSrcweir SecondariesCalculator::do_Process( const Function & i_rData )
402*cdf0e10cSrcweir {
403*cdf0e10cSrcweir     const Function &
404*cdf0e10cSrcweir         rFunction = ary_cast<Function>(i_rData);
405*cdf0e10cSrcweir 
406*cdf0e10cSrcweir     recursive_AssignFunction_toCeAsReturn(rFunction.CeId(), rFunction.ReturnType());
407*cdf0e10cSrcweir 
408*cdf0e10cSrcweir     for ( Function::ParamList::const_iterator itp = rFunction.Parameters().begin();
409*cdf0e10cSrcweir           itp != rFunction.Parameters().end();
410*cdf0e10cSrcweir           ++itp )
411*cdf0e10cSrcweir     {
412*cdf0e10cSrcweir         recursive_AssignFunction_toCeAsParameter(rFunction.CeId(), (*itp).Type());
413*cdf0e10cSrcweir     }   // end for (itp)
414*cdf0e10cSrcweir 
415*cdf0e10cSrcweir     for ( Function::ExceptionList::const_iterator itx = rFunction.Exceptions().begin();
416*cdf0e10cSrcweir           itx != rFunction.Exceptions().end();
417*cdf0e10cSrcweir           ++itx )
418*cdf0e10cSrcweir     {
419*cdf0e10cSrcweir         Exception *
420*cdf0e10cSrcweir             pX = lhf_SearchException(*itx);
421*cdf0e10cSrcweir         if (pX != 0)
422*cdf0e10cSrcweir         {
423*cdf0e10cSrcweir             insert_into2sUnique(*pX, exception_2s_RaisingFunctions, rFunction.CeId());
424*cdf0e10cSrcweir         }
425*cdf0e10cSrcweir     }   // end for (itx)
426*cdf0e10cSrcweir }
427*cdf0e10cSrcweir 
428*cdf0e10cSrcweir void
429*cdf0e10cSrcweir SecondariesCalculator::do_Process( const StructElement & i_rData )
430*cdf0e10cSrcweir {
431*cdf0e10cSrcweir     const StructElement &
432*cdf0e10cSrcweir         rStructElement = ary_cast<StructElement>(i_rData);
433*cdf0e10cSrcweir 
434*cdf0e10cSrcweir     recursive_AssignStructElement_toCeAsDataType(rStructElement.CeId(), rStructElement.Type());
435*cdf0e10cSrcweir }
436*cdf0e10cSrcweir 
437*cdf0e10cSrcweir void
438*cdf0e10cSrcweir SecondariesCalculator::do_Process( const Property & i_rData )
439*cdf0e10cSrcweir {
440*cdf0e10cSrcweir     const Property &
441*cdf0e10cSrcweir         rProperty = ary_cast<Property>(i_rData);
442*cdf0e10cSrcweir 
443*cdf0e10cSrcweir     recursive_AssignStructElement_toCeAsDataType(rProperty.CeId(), rProperty.Type());
444*cdf0e10cSrcweir }
445*cdf0e10cSrcweir 
446*cdf0e10cSrcweir Ce_id
447*cdf0e10cSrcweir SecondariesCalculator::lhf_Search_CeForType( const ExplicitType & i_rType ) const
448*cdf0e10cSrcweir {
449*cdf0e10cSrcweir     const ExplicitNameRoom &
450*cdf0e10cSrcweir         rExplicitNameRoom = ary_cast<ExplicitNameRoom>(
451*cdf0e10cSrcweir                                 my_TypeStorage()[i_rType.NameRoom()] );
452*cdf0e10cSrcweir     Find_ModuleNode
453*cdf0e10cSrcweir         rNodeFinder( my_CeStorage(),
454*cdf0e10cSrcweir                      rExplicitNameRoom.NameChain_Begin(),
455*cdf0e10cSrcweir                      rExplicitNameRoom.NameChain_End(),
456*cdf0e10cSrcweir                      i_rType.Name() );
457*cdf0e10cSrcweir 
458*cdf0e10cSrcweir     if ( rExplicitNameRoom.IsAbsolute() )
459*cdf0e10cSrcweir     {
460*cdf0e10cSrcweir         const Module &
461*cdf0e10cSrcweir             rGlobalNamespace = ary_cast<Module>(
462*cdf0e10cSrcweir                                 my_CeStorage()[predefined::ce_GlobalNamespace]);
463*cdf0e10cSrcweir         return Search_SubTree(  rGlobalNamespace,
464*cdf0e10cSrcweir                                 rNodeFinder );
465*cdf0e10cSrcweir     }
466*cdf0e10cSrcweir     else
467*cdf0e10cSrcweir     {
468*cdf0e10cSrcweir         const Module &
469*cdf0e10cSrcweir             rStartModule = ary_cast<Module>(
470*cdf0e10cSrcweir                                 my_CeStorage()[i_rType.ModuleOfOccurrence()]);
471*cdf0e10cSrcweir         Ce_id ret = Search_SubTree_UpTillRoot( rStartModule,
472*cdf0e10cSrcweir 											   rNodeFinder );
473*cdf0e10cSrcweir 		return ret;
474*cdf0e10cSrcweir     }   // endif (rExplicitNameRoom.IsAbsolute()) else
475*cdf0e10cSrcweir }
476*cdf0e10cSrcweir 
477*cdf0e10cSrcweir Ce_id
478*cdf0e10cSrcweir SecondariesCalculator::lhf_Search_CeFromTypeId( Type_id i_nType ) const
479*cdf0e10cSrcweir {
480*cdf0e10cSrcweir     if (NOT i_nType.IsValid())
481*cdf0e10cSrcweir         return Ce_id(0);
482*cdf0e10cSrcweir     const Ce_Type *
483*cdf0e10cSrcweir         pType = ary_cast<Ce_Type>( & my_TypeStorage()[i_nType] );
484*cdf0e10cSrcweir     return pType != 0
485*cdf0e10cSrcweir                 ?   pType->RelatedCe()
486*cdf0e10cSrcweir                 :   Ce_id_Null();
487*cdf0e10cSrcweir }
488*cdf0e10cSrcweir 
489*cdf0e10cSrcweir void
490*cdf0e10cSrcweir SecondariesCalculator::assign_CurLink( char *              i_text,
491*cdf0e10cSrcweir                                        const String &      i_link,
492*cdf0e10cSrcweir                                        const String &      i_linkUI,
493*cdf0e10cSrcweir                                        bool                i_isDescr,
494*cdf0e10cSrcweir                                        int                 i_lineCount )
495*cdf0e10cSrcweir {
496*cdf0e10cSrcweir     csv_assert(i_text != 0);
497*cdf0e10cSrcweir 
498*cdf0e10cSrcweir     const ary::idl::Module *
499*cdf0e10cSrcweir         pModule = & ary_cast<Module>(
500*cdf0e10cSrcweir                         my_CeStorage()[predefined::ce_GlobalNamespace]);
501*cdf0e10cSrcweir 
502*cdf0e10cSrcweir     char * pPastNext = 0;
503*cdf0e10cSrcweir     char * pNext = i_text;
504*cdf0e10cSrcweir     for ( ;
505*cdf0e10cSrcweir           (pPastNext = strstr(pNext,".")) != 0;
506*cdf0e10cSrcweir           pNext = pPastNext + 1 )
507*cdf0e10cSrcweir     {
508*cdf0e10cSrcweir         String sNext(pNext, pPastNext-pNext);
509*cdf0e10cSrcweir         Ce_id nModule = pModule->Search_Name(sNext);
510*cdf0e10cSrcweir         if (nModule.IsValid())
511*cdf0e10cSrcweir         {
512*cdf0e10cSrcweir             pModule = ary_cast<Module>( & my_CeStorage()[nModule] );
513*cdf0e10cSrcweir         }
514*cdf0e10cSrcweir         else
515*cdf0e10cSrcweir         {
516*cdf0e10cSrcweir             pModule = 0;
517*cdf0e10cSrcweir         }
518*cdf0e10cSrcweir 
519*cdf0e10cSrcweir         if (pModule == 0)
520*cdf0e10cSrcweir         {
521*cdf0e10cSrcweir             Cerr() << "Warning: Invalid line nr. "
522*cdf0e10cSrcweir                    << i_lineCount
523*cdf0e10cSrcweir                    << " in DevelopersGuide reference file:\n"
524*cdf0e10cSrcweir                    << reinterpret_cast< const char* >(i_text)
525*cdf0e10cSrcweir                    << "\n"
526*cdf0e10cSrcweir                    << Endl();
527*cdf0e10cSrcweir             return;
528*cdf0e10cSrcweir         }
529*cdf0e10cSrcweir     }   // end for
530*cdf0e10cSrcweir 
531*cdf0e10cSrcweir     pPastNext = strchr(pNext,':');
532*cdf0e10cSrcweir     bool bMember = pPastNext != 0;
533*cdf0e10cSrcweir     String sCe( pNext, (bMember ? csv::str::size(pPastNext-pNext) : csv::str::maxsize) );
534*cdf0e10cSrcweir 
535*cdf0e10cSrcweir //  KORR_FUTURE
536*cdf0e10cSrcweir //  String sMember(bMember ? pPastNext+1, "");
537*cdf0e10cSrcweir 
538*cdf0e10cSrcweir     Ce_id nCe = pModule->Search_Name(sCe);
539*cdf0e10cSrcweir     if (NOT nCe.IsValid())
540*cdf0e10cSrcweir     {
541*cdf0e10cSrcweir         Cerr() << "Warning: Invalid line nr. "
542*cdf0e10cSrcweir                << i_lineCount
543*cdf0e10cSrcweir                << " in DevelopersGuide reference file:\n"
544*cdf0e10cSrcweir                << reinterpret_cast< const char* >(i_text)
545*cdf0e10cSrcweir                << "\n"
546*cdf0e10cSrcweir                << Endl();
547*cdf0e10cSrcweir         return;
548*cdf0e10cSrcweir     }
549*cdf0e10cSrcweir 
550*cdf0e10cSrcweir     CodeEntity &
551*cdf0e10cSrcweir         rCe = my_CeStorage()[nCe];
552*cdf0e10cSrcweir     if (NOT bMember)
553*cdf0e10cSrcweir     {
554*cdf0e10cSrcweir         if (i_isDescr)
555*cdf0e10cSrcweir             rCe.Secondaries().Add_Link2DescriptionInManual(i_link, i_linkUI);
556*cdf0e10cSrcweir         else
557*cdf0e10cSrcweir             rCe.Secondaries().Add_Link2RefInManual(i_link, i_linkUI);
558*cdf0e10cSrcweir         return;
559*cdf0e10cSrcweir     }
560*cdf0e10cSrcweir     else
561*cdf0e10cSrcweir     {
562*cdf0e10cSrcweir     // KORR_FUTURE
563*cdf0e10cSrcweir     //   Provisorial just doing nothing (or may be
564*cdf0e10cSrcweir     //   adding a link at main Ces lists).
565*cdf0e10cSrcweir //    if (i_isDescr)
566*cdf0e10cSrcweir //        rCe.Secondaries().Add_Link2DescriptionInManual(i_link);
567*cdf0e10cSrcweir //    else
568*cdf0e10cSrcweir //        rCe.Secondaries().Add_Link2RefInManual(i_link);
569*cdf0e10cSrcweir     }
570*cdf0e10cSrcweir }
571*cdf0e10cSrcweir 
572*cdf0e10cSrcweir void
573*cdf0e10cSrcweir SecondariesCalculator::gather_Synonyms()
574*cdf0e10cSrcweir {
575*cdf0e10cSrcweir     const Ce_Storage &
576*cdf0e10cSrcweir         cstrg = my_CeStorage();
577*cdf0e10cSrcweir     typedef_citerator itEnd(cstrg.End());
578*cdf0e10cSrcweir     for ( typedef_citerator it(cstrg.Begin());
579*cdf0e10cSrcweir           it != itEnd;
580*cdf0e10cSrcweir           ++it )
581*cdf0e10cSrcweir     {
582*cdf0e10cSrcweir         if (NOT it.IsValid())
583*cdf0e10cSrcweir             continue;
584*cdf0e10cSrcweir 
585*cdf0e10cSrcweir         const Typedef &
586*cdf0e10cSrcweir             rTypedef = *it;
587*cdf0e10cSrcweir         recursive_AssignAsSynonym(rTypedef.CeId(), rTypedef);
588*cdf0e10cSrcweir     }   // end for (itTd)
589*cdf0e10cSrcweir }
590*cdf0e10cSrcweir 
591*cdf0e10cSrcweir void
592*cdf0e10cSrcweir SecondariesCalculator::recursive_AssignAsSynonym( Ce_id               i_synonymousTypedefsId,
593*cdf0e10cSrcweir                                                   const Typedef &     i_TypedefToCheck )
594*cdf0e10cSrcweir {
595*cdf0e10cSrcweir     Ce_id
596*cdf0e10cSrcweir         nCe = lhf_Search_CeFromTypeId(i_TypedefToCheck.DefiningType());
597*cdf0e10cSrcweir     if (NOT nCe.IsValid())
598*cdf0e10cSrcweir         return;
599*cdf0e10cSrcweir     CodeEntity &
600*cdf0e10cSrcweir         rCe = my_CeStorage()[nCe];
601*cdf0e10cSrcweir 
602*cdf0e10cSrcweir     switch (rCe.AryClass())  // KORR_FUTURE: make this faster, remove switch.
603*cdf0e10cSrcweir     {
604*cdf0e10cSrcweir         case Interface::class_id:
605*cdf0e10cSrcweir                     insert_into2sList( rCe,
606*cdf0e10cSrcweir 									   interface_2s_SynonymTypedefs,
607*cdf0e10cSrcweir 									   i_synonymousTypedefsId );
608*cdf0e10cSrcweir                     break;
609*cdf0e10cSrcweir         case Struct::class_id:
610*cdf0e10cSrcweir                     insert_into2sList( rCe,
611*cdf0e10cSrcweir 									   struct_2s_SynonymTypedefs,
612*cdf0e10cSrcweir 									   i_synonymousTypedefsId );
613*cdf0e10cSrcweir                     break;
614*cdf0e10cSrcweir         case Enum::class_id:
615*cdf0e10cSrcweir                     insert_into2sList( rCe,
616*cdf0e10cSrcweir 									   enum_2s_SynonymTypedefs,
617*cdf0e10cSrcweir 									   i_synonymousTypedefsId );
618*cdf0e10cSrcweir                     break;
619*cdf0e10cSrcweir         case Typedef::class_id:
620*cdf0e10cSrcweir                     insert_into2sList( rCe,
621*cdf0e10cSrcweir 									   typedef_2s_SynonymTypedefs,
622*cdf0e10cSrcweir 									   i_synonymousTypedefsId );
623*cdf0e10cSrcweir                     recursive_AssignAsSynonym( i_synonymousTypedefsId,
624*cdf0e10cSrcweir                                                static_cast< Typedef& >(rCe) );
625*cdf0e10cSrcweir                     break;
626*cdf0e10cSrcweir                 // default: do nothing.
627*cdf0e10cSrcweir     }
628*cdf0e10cSrcweir }
629*cdf0e10cSrcweir 
630*cdf0e10cSrcweir void
631*cdf0e10cSrcweir SecondariesCalculator::recursive_AssignIncludingService( Ce_id               i_includingServicesId,
632*cdf0e10cSrcweir                                                          const Service &     i_ServiceToCheckItsIncludes )
633*cdf0e10cSrcweir {
634*cdf0e10cSrcweir     Dyn_StdConstIterator<CommentedRelation>
635*cdf0e10cSrcweir         pIncludedServices;
636*cdf0e10cSrcweir     i_ServiceToCheckItsIncludes.Get_IncludedServices(pIncludedServices);
637*cdf0e10cSrcweir 
638*cdf0e10cSrcweir     for ( StdConstIterator<CommentedRelation> &
639*cdf0e10cSrcweir                 itServ = *pIncludedServices;
640*cdf0e10cSrcweir           itServ;
641*cdf0e10cSrcweir           ++itServ )
642*cdf0e10cSrcweir     {
643*cdf0e10cSrcweir         Service *
644*cdf0e10cSrcweir             pServ = lhf_SearchService((*itServ).Type());
645*cdf0e10cSrcweir         if (pServ != 0)
646*cdf0e10cSrcweir         {
647*cdf0e10cSrcweir             insert_into2sUnique( *pServ,
648*cdf0e10cSrcweir 								 service_2s_IncludingServices,
649*cdf0e10cSrcweir 								 i_includingServicesId
650*cdf0e10cSrcweir 							   );
651*cdf0e10cSrcweir             recursive_AssignIncludingService(i_includingServicesId, *pServ);
652*cdf0e10cSrcweir 
653*cdf0e10cSrcweir         }   // end if
654*cdf0e10cSrcweir 
655*cdf0e10cSrcweir         assignImplementation_toAServicesInterfaces( i_includingServicesId,
656*cdf0e10cSrcweir 													lhf_Search_CeFromTypeId( (*itServ).Type() ),
657*cdf0e10cSrcweir 													interface_2s_ExportingServices );
658*cdf0e10cSrcweir     }   // end for
659*cdf0e10cSrcweir }
660*cdf0e10cSrcweir 
661*cdf0e10cSrcweir void
662*cdf0e10cSrcweir SecondariesCalculator::assign_AsDerivedInterface( const Interface & i_rDerived )
663*cdf0e10cSrcweir {
664*cdf0e10cSrcweir     ary::Dyn_StdConstIterator<ary::idl::CommentedRelation>
665*cdf0e10cSrcweir         pHelp;
666*cdf0e10cSrcweir     ary::idl::ifc_interface::attr::Get_Bases(pHelp, i_rDerived);
667*cdf0e10cSrcweir 
668*cdf0e10cSrcweir     for ( ary::StdConstIterator<ary::idl::CommentedRelation> & it = *pHelp;
669*cdf0e10cSrcweir           it.operator bool();
670*cdf0e10cSrcweir           ++it )
671*cdf0e10cSrcweir     {
672*cdf0e10cSrcweir         Interface *
673*cdf0e10cSrcweir             pIfc = lhf_SearchInterface( (*it).Type() );
674*cdf0e10cSrcweir         if (pIfc == 0)
675*cdf0e10cSrcweir             continue;
676*cdf0e10cSrcweir 
677*cdf0e10cSrcweir         insert_into2sList( *pIfc,
678*cdf0e10cSrcweir                            interface_2s_Derivations,
679*cdf0e10cSrcweir 						   i_rDerived.CeId() );
680*cdf0e10cSrcweir     }   // end for
681*cdf0e10cSrcweir }
682*cdf0e10cSrcweir 
683*cdf0e10cSrcweir void
684*cdf0e10cSrcweir SecondariesCalculator::assign_AsDerivedStruct( const Struct &   i_rDerived )
685*cdf0e10cSrcweir {
686*cdf0e10cSrcweir     Type_id
687*cdf0e10cSrcweir         nBase = i_rDerived.Base();
688*cdf0e10cSrcweir     if (nBase.IsValid())
689*cdf0e10cSrcweir     {
690*cdf0e10cSrcweir         Struct *
691*cdf0e10cSrcweir             pParent = lhf_SearchStruct(nBase);
692*cdf0e10cSrcweir         if (pParent != 0)
693*cdf0e10cSrcweir         {
694*cdf0e10cSrcweir             insert_into2sList( *pParent,
695*cdf0e10cSrcweir 							   struct_2s_Derivations,
696*cdf0e10cSrcweir 							   i_rDerived.CeId() );
697*cdf0e10cSrcweir         }
698*cdf0e10cSrcweir     }
699*cdf0e10cSrcweir }
700*cdf0e10cSrcweir 
701*cdf0e10cSrcweir void
702*cdf0e10cSrcweir SecondariesCalculator::assign_AsDerivedException( const Exception &   i_rDerived )
703*cdf0e10cSrcweir {
704*cdf0e10cSrcweir     Type_id
705*cdf0e10cSrcweir         nBase = i_rDerived.Base();
706*cdf0e10cSrcweir     if (nBase.IsValid())
707*cdf0e10cSrcweir     {
708*cdf0e10cSrcweir         Exception *
709*cdf0e10cSrcweir             pParent = lhf_SearchException(nBase);
710*cdf0e10cSrcweir         if (pParent != 0)
711*cdf0e10cSrcweir         {
712*cdf0e10cSrcweir             insert_into2sList( *pParent,
713*cdf0e10cSrcweir 							   exception_2s_Derivations,
714*cdf0e10cSrcweir 							   i_rDerived.CeId() );
715*cdf0e10cSrcweir         }   // end if
716*cdf0e10cSrcweir     }   // end if
717*cdf0e10cSrcweir }
718*cdf0e10cSrcweir 
719*cdf0e10cSrcweir void
720*cdf0e10cSrcweir SecondariesCalculator::assignImplementation_toAServicesInterfaces(
721*cdf0e10cSrcweir                                                     Ce_id               i_nImpl,
722*cdf0e10cSrcweir                                                     Ce_id               i_nService,
723*cdf0e10cSrcweir                                                     E_2s_of_Interface   i_eList )
724*cdf0e10cSrcweir {
725*cdf0e10cSrcweir     if (NOT i_nService.IsValid())
726*cdf0e10cSrcweir         return;
727*cdf0e10cSrcweir     Service *
728*cdf0e10cSrcweir         pService = ary_cast<Service>( & my_CeStorage()[i_nService] );
729*cdf0e10cSrcweir     SglIfcService *
730*cdf0e10cSrcweir         pSglIfcService = ary_cast<SglIfcService>( & my_CeStorage()[i_nService] );
731*cdf0e10cSrcweir 
732*cdf0e10cSrcweir     if (pService != 0)
733*cdf0e10cSrcweir     {
734*cdf0e10cSrcweir         Dyn_StdConstIterator<CommentedRelation>
735*cdf0e10cSrcweir             pSupportedInterfaces;
736*cdf0e10cSrcweir         pService->Get_SupportedInterfaces(pSupportedInterfaces);
737*cdf0e10cSrcweir 
738*cdf0e10cSrcweir         for ( StdConstIterator<CommentedRelation> &
739*cdf0e10cSrcweir                     itInfc = *pSupportedInterfaces;
740*cdf0e10cSrcweir               itInfc.operator bool();
741*cdf0e10cSrcweir 			  ++itInfc )
742*cdf0e10cSrcweir         {
743*cdf0e10cSrcweir             recursive_AssignImplementation_toExportedInterface( i_nImpl,
744*cdf0e10cSrcweir 																(*itInfc).Type(),
745*cdf0e10cSrcweir 																i_eList );
746*cdf0e10cSrcweir         }   // end for
747*cdf0e10cSrcweir     }
748*cdf0e10cSrcweir     else if (pSglIfcService != 0)
749*cdf0e10cSrcweir     {
750*cdf0e10cSrcweir         Type_id nBase = pSglIfcService->BaseInterface();
751*cdf0e10cSrcweir         recursive_AssignImplementation_toExportedInterface( i_nImpl,
752*cdf0e10cSrcweir 															nBase,
753*cdf0e10cSrcweir 															i_eList );
754*cdf0e10cSrcweir     }   // end if
755*cdf0e10cSrcweir }
756*cdf0e10cSrcweir 
757*cdf0e10cSrcweir void
758*cdf0e10cSrcweir SecondariesCalculator::recursive_AssignImplementation_toExportedInterface(
759*cdf0e10cSrcweir                                                     Ce_id               i_nService,
760*cdf0e10cSrcweir 													Type_id             i_nExportedInterface,
761*cdf0e10cSrcweir 													E_2s_of_Interface   i_eList )
762*cdf0e10cSrcweir {
763*cdf0e10cSrcweir     Interface *
764*cdf0e10cSrcweir         pIfc = lhf_SearchInterface(i_nExportedInterface);
765*cdf0e10cSrcweir     if (pIfc == 0)
766*cdf0e10cSrcweir         return;
767*cdf0e10cSrcweir 
768*cdf0e10cSrcweir     insert_into2sUnique( *pIfc,
769*cdf0e10cSrcweir 						 i_eList,
770*cdf0e10cSrcweir 						 i_nService );
771*cdf0e10cSrcweir     Dyn_StdConstIterator<CommentedRelation>
772*cdf0e10cSrcweir         pBases;
773*cdf0e10cSrcweir     ary::idl::ifc_interface::attr::Get_Bases(pBases, *pIfc);
774*cdf0e10cSrcweir     for ( StdConstIterator<CommentedRelation> & it = *pBases;
775*cdf0e10cSrcweir           it.operator bool();
776*cdf0e10cSrcweir           ++it )
777*cdf0e10cSrcweir     {
778*cdf0e10cSrcweir         recursive_AssignImplementation_toExportedInterface(i_nService, (*it).Type(), i_eList);
779*cdf0e10cSrcweir     }
780*cdf0e10cSrcweir }
781*cdf0e10cSrcweir 
782*cdf0e10cSrcweir void
783*cdf0e10cSrcweir SecondariesCalculator::recursive_AssignFunction_toCeAsReturn( Ce_id         i_nFunction,
784*cdf0e10cSrcweir                                                               Type_id       i_nReturnType )
785*cdf0e10cSrcweir {
786*cdf0e10cSrcweir     Ce_id
787*cdf0e10cSrcweir         nCe = lhf_Search_CeFromTypeId(i_nReturnType);
788*cdf0e10cSrcweir     if (NOT nCe.IsValid())
789*cdf0e10cSrcweir         return;
790*cdf0e10cSrcweir 
791*cdf0e10cSrcweir     CodeEntity &
792*cdf0e10cSrcweir         rCe = my_CeStorage()[nCe];
793*cdf0e10cSrcweir     switch (rCe.AryClass())  // KORR_FUTURE: make this faster, remove switch.
794*cdf0e10cSrcweir     {
795*cdf0e10cSrcweir         case Interface::class_id:
796*cdf0e10cSrcweir                     insert_into2sList( rCe,
797*cdf0e10cSrcweir 									   interface_2s_AsReturns,
798*cdf0e10cSrcweir 									   i_nFunction );
799*cdf0e10cSrcweir                     break;
800*cdf0e10cSrcweir         case Struct::class_id:
801*cdf0e10cSrcweir                     insert_into2sList( rCe,
802*cdf0e10cSrcweir 									   struct_2s_AsReturns,
803*cdf0e10cSrcweir 									   i_nFunction );
804*cdf0e10cSrcweir                     break;
805*cdf0e10cSrcweir         case Enum::class_id:
806*cdf0e10cSrcweir                     insert_into2sList( rCe,
807*cdf0e10cSrcweir 									   enum_2s_AsReturns,
808*cdf0e10cSrcweir 									   i_nFunction );
809*cdf0e10cSrcweir                     break;
810*cdf0e10cSrcweir         case Typedef::class_id:
811*cdf0e10cSrcweir                     insert_into2sList( rCe,
812*cdf0e10cSrcweir 									   typedef_2s_AsReturns,
813*cdf0e10cSrcweir 									   i_nFunction );
814*cdf0e10cSrcweir                     recursive_AssignFunction_toCeAsReturn( i_nFunction,
815*cdf0e10cSrcweir                                                            static_cast< Typedef& >(rCe).DefiningType() );
816*cdf0e10cSrcweir                     break;
817*cdf0e10cSrcweir         // default: do nothing.
818*cdf0e10cSrcweir     }
819*cdf0e10cSrcweir }
820*cdf0e10cSrcweir 
821*cdf0e10cSrcweir void
822*cdf0e10cSrcweir SecondariesCalculator::recursive_AssignFunction_toCeAsParameter( Ce_id      i_nFunction,
823*cdf0e10cSrcweir                                                                  Type_id    i_nParameterType )
824*cdf0e10cSrcweir {
825*cdf0e10cSrcweir     Ce_id
826*cdf0e10cSrcweir         nCe = lhf_Search_CeFromTypeId(i_nParameterType);
827*cdf0e10cSrcweir     if (NOT nCe.IsValid())
828*cdf0e10cSrcweir         return;
829*cdf0e10cSrcweir 
830*cdf0e10cSrcweir     CodeEntity &
831*cdf0e10cSrcweir         rCe = my_CeStorage()[nCe];
832*cdf0e10cSrcweir     switch (rCe.AryClass())  // KORR_FUTURE: make this faster, remove switch.
833*cdf0e10cSrcweir     {
834*cdf0e10cSrcweir         case Interface::class_id:
835*cdf0e10cSrcweir                     insert_into2sList( rCe,
836*cdf0e10cSrcweir 									   interface_2s_AsParameters,
837*cdf0e10cSrcweir 									   i_nFunction );
838*cdf0e10cSrcweir                     break;
839*cdf0e10cSrcweir         case Struct::class_id:
840*cdf0e10cSrcweir                     insert_into2sList( rCe,
841*cdf0e10cSrcweir 									   struct_2s_AsParameters,
842*cdf0e10cSrcweir 									   i_nFunction );
843*cdf0e10cSrcweir                     break;
844*cdf0e10cSrcweir         case Enum::class_id:
845*cdf0e10cSrcweir                     insert_into2sList( rCe,
846*cdf0e10cSrcweir 									   enum_2s_AsParameters,
847*cdf0e10cSrcweir 									   i_nFunction );
848*cdf0e10cSrcweir                     break;
849*cdf0e10cSrcweir         case Typedef::class_id:
850*cdf0e10cSrcweir                     insert_into2sList( rCe,
851*cdf0e10cSrcweir 									   typedef_2s_AsParameters,
852*cdf0e10cSrcweir 									   i_nFunction );
853*cdf0e10cSrcweir                     recursive_AssignFunction_toCeAsParameter( i_nFunction,
854*cdf0e10cSrcweir                                                               static_cast< Typedef& >(rCe).DefiningType() );
855*cdf0e10cSrcweir                     break;
856*cdf0e10cSrcweir         // default: do nothing.
857*cdf0e10cSrcweir     }
858*cdf0e10cSrcweir }
859*cdf0e10cSrcweir 
860*cdf0e10cSrcweir void
861*cdf0e10cSrcweir SecondariesCalculator::recursive_AssignStructElement_toCeAsDataType( Ce_id   i_nDataElement,
862*cdf0e10cSrcweir                                                                      Type_id i_nDataType )
863*cdf0e10cSrcweir {
864*cdf0e10cSrcweir     Ce_id
865*cdf0e10cSrcweir         nCe = lhf_Search_CeFromTypeId(i_nDataType);
866*cdf0e10cSrcweir     if (NOT nCe.IsValid())
867*cdf0e10cSrcweir         return;
868*cdf0e10cSrcweir 
869*cdf0e10cSrcweir     CodeEntity &
870*cdf0e10cSrcweir         rCe = my_CeStorage()[nCe];
871*cdf0e10cSrcweir     switch (rCe.AryClass())  // KORR_FUTURE: make this faster, remove switch.
872*cdf0e10cSrcweir     {
873*cdf0e10cSrcweir         case Interface::class_id:
874*cdf0e10cSrcweir                     insert_into2sList( rCe,
875*cdf0e10cSrcweir 									   interface_2s_AsDataTypes,
876*cdf0e10cSrcweir 									   i_nDataElement );
877*cdf0e10cSrcweir                     break;
878*cdf0e10cSrcweir         case Struct::class_id:
879*cdf0e10cSrcweir                     insert_into2sList( rCe,
880*cdf0e10cSrcweir 									   struct_2s_AsDataTypes,
881*cdf0e10cSrcweir 									   i_nDataElement );
882*cdf0e10cSrcweir                     break;
883*cdf0e10cSrcweir         case Enum::class_id:
884*cdf0e10cSrcweir                     insert_into2sList( rCe,
885*cdf0e10cSrcweir 									   enum_2s_AsDataTypes,
886*cdf0e10cSrcweir 									   i_nDataElement );
887*cdf0e10cSrcweir                     break;
888*cdf0e10cSrcweir         case Typedef::class_id:
889*cdf0e10cSrcweir                     insert_into2sList( rCe,
890*cdf0e10cSrcweir 									   typedef_2s_AsDataTypes,
891*cdf0e10cSrcweir 									   i_nDataElement );
892*cdf0e10cSrcweir                     recursive_AssignFunction_toCeAsParameter( i_nDataElement,
893*cdf0e10cSrcweir                                                               static_cast< Typedef& >(rCe).DefiningType() );
894*cdf0e10cSrcweir                     break;
895*cdf0e10cSrcweir         // default: do nothing.
896*cdf0e10cSrcweir     }   // end switch
897*cdf0e10cSrcweir }
898*cdf0e10cSrcweir 
899*cdf0e10cSrcweir void
900*cdf0e10cSrcweir SecondariesCalculator::insert_into2sUnique( CodeEntity &        o_out,
901*cdf0e10cSrcweir 											int                 i_listIndex,
902*cdf0e10cSrcweir 											Ce_id               i_nCe )
903*cdf0e10cSrcweir {
904*cdf0e10cSrcweir     std::vector<Ce_id> &
905*cdf0e10cSrcweir         rOut = o_out.Secondaries().Access_List(i_listIndex);
906*cdf0e10cSrcweir     if (std::find(rOut.begin(),rOut.end(),i_nCe) != rOut.end())
907*cdf0e10cSrcweir         return;
908*cdf0e10cSrcweir     rOut.push_back(i_nCe);
909*cdf0e10cSrcweir }
910*cdf0e10cSrcweir 
911*cdf0e10cSrcweir void
912*cdf0e10cSrcweir SecondariesCalculator::sort_All2s()
913*cdf0e10cSrcweir {
914*cdf0e10cSrcweir     OrderCeIdsByName
915*cdf0e10cSrcweir         aIdOrdering(my_CeStorage());
916*cdf0e10cSrcweir 
917*cdf0e10cSrcweir     for ( stg_iterator it = my_CeStorage().Begin();
918*cdf0e10cSrcweir           it != my_CeStorage().End();
919*cdf0e10cSrcweir           ++it )
920*cdf0e10cSrcweir     {
921*cdf0e10cSrcweir         Ce_2s &
922*cdf0e10cSrcweir             r2s = (*it).Secondaries();
923*cdf0e10cSrcweir         int iCount = r2s.CountXrefLists();
924*cdf0e10cSrcweir         for (int i = 0; i < iCount; ++i)
925*cdf0e10cSrcweir         {
926*cdf0e10cSrcweir             std::sort( r2s.Access_List(i).begin(),
927*cdf0e10cSrcweir                        r2s.Access_List(i).end(),
928*cdf0e10cSrcweir                        aIdOrdering );
929*cdf0e10cSrcweir         }   // end for (i)
930*cdf0e10cSrcweir     }   // end for (it)
931*cdf0e10cSrcweir }
932*cdf0e10cSrcweir 
933*cdf0e10cSrcweir void
934*cdf0e10cSrcweir SecondariesCalculator::Read_Links2DevManual( csv::bstream & i_file )
935*cdf0e10cSrcweir {
936*cdf0e10cSrcweir     StreamLock  aLine(300);
937*cdf0e10cSrcweir     StreamStr & rLine = aLine();
938*cdf0e10cSrcweir 
939*cdf0e10cSrcweir 
940*cdf0e10cSrcweir     String      sCurLink;
941*cdf0e10cSrcweir     String      sCurLinkUI;
942*cdf0e10cSrcweir     E_LinkMode  eCurMode = link2ref;
943*cdf0e10cSrcweir 
944*cdf0e10cSrcweir 	int lineCount = 0;
945*cdf0e10cSrcweir     const char * sLink = "LINK:";
946*cdf0e10cSrcweir     const char * sDescr = "DESCR:";
947*cdf0e10cSrcweir     const char * sTopic = "TOPIC:";
948*cdf0e10cSrcweir     const char * sRef = "REF:";
949*cdf0e10cSrcweir     const UINT8  cMaxASCIINumWhiteSpace = 32;
950*cdf0e10cSrcweir 
951*cdf0e10cSrcweir     while (NOT i_file.eod())
952*cdf0e10cSrcweir     {
953*cdf0e10cSrcweir 		++lineCount;
954*cdf0e10cSrcweir 
955*cdf0e10cSrcweir         rLine.reset();
956*cdf0e10cSrcweir         rLine.operator_read_line(i_file);
957*cdf0e10cSrcweir 
958*cdf0e10cSrcweir         if ( *rLine.c_str() >= 'a' )
959*cdf0e10cSrcweir         {
960*cdf0e10cSrcweir             assign_CurLink(rLine.begin(), sCurLink, sCurLinkUI, eCurMode == link2descr, lineCount);
961*cdf0e10cSrcweir         }
962*cdf0e10cSrcweir         else if ( strncmp(rLine.c_str(), sLink, strlen(sLink)) == 0 )
963*cdf0e10cSrcweir         {
964*cdf0e10cSrcweir             sCurLink = rLine.c_str()+5;
965*cdf0e10cSrcweir             sCurLinkUI.clear();
966*cdf0e10cSrcweir         }
967*cdf0e10cSrcweir         else if ( strncmp(rLine.c_str(), sDescr, strlen(sDescr)) == 0 )
968*cdf0e10cSrcweir         {
969*cdf0e10cSrcweir             sCurLinkUI = rLine.c_str()+6;
970*cdf0e10cSrcweir         }
971*cdf0e10cSrcweir         else if ( strncmp(rLine.c_str(), sTopic, strlen(sTopic)) == 0 )
972*cdf0e10cSrcweir         {
973*cdf0e10cSrcweir             eCurMode = link2descr;
974*cdf0e10cSrcweir         }
975*cdf0e10cSrcweir         else if ( strncmp(rLine.c_str(), sRef, strlen(sRef)) == 0 )
976*cdf0e10cSrcweir         {
977*cdf0e10cSrcweir             eCurMode = link2ref;
978*cdf0e10cSrcweir         }
979*cdf0e10cSrcweir         else if (static_cast<UINT8>(*rLine.c_str()) > cMaxASCIINumWhiteSpace)
980*cdf0e10cSrcweir         {
981*cdf0e10cSrcweir             assign_CurLink(rLine.begin(), sCurLink, sCurLinkUI, eCurMode == link2descr, lineCount);
982*cdf0e10cSrcweir         }
983*cdf0e10cSrcweir      // else
984*cdf0e10cSrcweir         //  Ignore empty line.
985*cdf0e10cSrcweir 
986*cdf0e10cSrcweir     }   // end while
987*cdf0e10cSrcweir }
988*cdf0e10cSrcweir 
989*cdf0e10cSrcweir 
990*cdf0e10cSrcweir 
991*cdf0e10cSrcweir }   // namespace idl
992*cdf0e10cSrcweir }   // namespace ary
993