merge the formfield patch from ooo-build
[ooovba.git] / autodoc / source / ary / idl / i2s_calculator.cxx
blob0069b0dff0ace92ab3a0a4f94a49d36a70a534a4
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: i2s_calculator.cxx,v $
10 * $Revision: 1.4 $
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 "i2s_calculator.hxx"
35 // NOT FULLY DEFINED SERVICES
36 #include <algorithm>
37 #include <string.h>
38 #include <cosv/file.hxx>
39 //#include <adc_manager.hxx>
40 //#include <adc_options.hxx>
41 #include <ary/qualiname.hxx>
42 #include <ary/idl/i_enum.hxx>
43 #include <ary/idl/i_exception.hxx>
44 #include <ary/idl/i_function.hxx>
45 #include <ary/idl/i_gate.hxx>
46 #include <ary/idl/i_interface.hxx>
47 #include <ary/idl/ik_interface.hxx>
48 #include <ary/idl/i_module.hxx>
49 #include <ary/idl/i_property.hxx>
50 #include <ary/idl/i_service.hxx>
51 #include <ary/idl/i_singleton.hxx>
52 #include <ary/idl/i_siservice.hxx>
53 #include <ary/idl/i_sisingleton.hxx>
54 #include <ary/idl/i_struct.hxx>
55 #include <ary/idl/i_structelem.hxx>
56 #include <ary/idl/i_typedef.hxx>
57 #include <ary/idl/ip_ce.hxx>
58 #include <ary/idl/ip_type.hxx>
59 #include <ary/namesort.hxx>
60 #include <nametreenode.hxx>
61 #include "i_nnfinder.hxx"
62 #include "ia_ce.hxx"
63 #include "ia_type.hxx"
64 #include "is_ce.hxx"
65 #include "is_type.hxx"
66 #include "it_ce.hxx"
67 #include "it_explicit.hxx"
68 #include "it_sequence.hxx"
69 #include "it_xnameroom.hxx"
73 namespace ary
75 namespace idl
78 template <class DEST>
79 DEST *
80 SecondariesCalculator::SearchCe4Type(Type_id i_type)
82 Ce_id
83 ce = lhf_Search_CeFromTypeId(i_type);
84 if (ce.IsValid())
85 return ary_cast<DEST>(& my_CeStorage()[ce]);
86 return 0;
90 typedef stg::const_iterator<CodeEntity> stg_citerator;
91 typedef stg::iterator<CodeEntity> stg_iterator;
93 typedef stg::filter_iterator<CodeEntity,Interface>
94 interface_iterator;
96 typedef stg::filter_iterator<Type,ExplicitType>
97 explicittype_iterator;
99 typedef ary::stg::const_filter_iterator<CodeEntity,Typedef>
100 typedef_citerator;
103 inline Service *
104 SecondariesCalculator::lhf_SearchService( Type_id i_nType )
106 return SearchCe4Type<Service>(i_nType);
109 inline Interface *
110 SecondariesCalculator::lhf_SearchInterface( Type_id i_nType )
112 return SearchCe4Type<Interface>(i_nType);
115 inline Struct *
116 SecondariesCalculator::lhf_SearchStruct( Type_id i_nType )
118 return SearchCe4Type<Struct>(i_nType);
121 inline Exception *
122 SecondariesCalculator::lhf_SearchException( Type_id i_nType )
124 return SearchCe4Type<Exception>(i_nType);
127 inline const Ce_Storage &
128 SecondariesCalculator::my_CeStorage() const
130 csv_assert(pCes != 0);
131 return pCes->Storage();
134 inline const Type_Storage &
135 SecondariesCalculator::my_TypeStorage() const
137 csv_assert(pTypes != 0);
138 return pTypes->Storage();
141 inline Ce_Storage &
142 SecondariesCalculator::my_CeStorage()
144 csv_assert(pCes != 0);
145 return pCes->Storage();
148 inline Type_Storage &
149 SecondariesCalculator::my_TypeStorage()
151 csv_assert(pTypes != 0);
152 return pTypes->Storage();
155 inline void
156 SecondariesCalculator::insert_into2sList( CodeEntity & o_out,
157 int i_listIndex,
158 Ce_id i_nCe )
159 { o_out.Secondaries().Access_List(i_listIndex).push_back(i_nCe); }
162 SecondariesCalculator::SecondariesCalculator( CeAdmin & i_ces,
163 TypeAdmin & i_types )
164 : pCes(&i_ces),
165 pTypes(&i_types)
169 SecondariesCalculator::~SecondariesCalculator()
174 void
175 SecondariesCalculator::CheckAllInterfaceBases()
177 Module &
178 rGlobalNamespace = pCes->GlobalNamespace();
179 QualifiedName
180 aXInterface("::com::sun::star::uno::XInterface","::");
182 const Type &
183 rType = pTypes->CheckIn_Type( aXInterface,
185 rGlobalNamespace.CeId(),
186 0 );
187 Type_id
188 nTypeXInterface = rType.TypeId();
189 const ExplicitType &
190 rExplType = ary_cast<ExplicitType>(rType);
191 Ce_id
192 nCeXInterface = lhf_Search_CeForType(rExplType);
194 interface_iterator itEnd( my_CeStorage().End() );
195 for ( interface_iterator it( my_CeStorage().BeginUnreserved() );
196 it != itEnd;
197 ++it )
199 if (NOT it.IsValid())
200 continue;
202 Interface &
203 rInterface = *it;
204 if ( NOT rInterface.HasBase() // According to UNO IDL syntax, an interface without base has com::sun::star::uno::XInterface as base.
205 AND rInterface.CeId() != nCeXInterface ) // XInterface must not be base of itself.
207 rInterface.Add_Base(nTypeXInterface, 0);
209 } // end for
212 void
213 SecondariesCalculator::Connect_Types2Ces()
215 explicittype_iterator itEnd( my_TypeStorage().End() );
216 for ( explicittype_iterator it( my_TypeStorage().BeginUnreserved() );
217 it != itEnd;
218 ++it )
220 if (NOT it.IsValid())
221 continue;
223 ExplicitType &
224 rType = ary_cast<ExplicitType>(*it);
225 Ce_id
226 nRelatedCe = lhf_Search_CeForType(rType);
227 if (nRelatedCe.IsValid())
229 Ce_Type *
230 pNew = new Ce_Type(nRelatedCe, rType.TemplateParameters());
231 my_TypeStorage().Replace_Entity( rType.TypeId(),
232 *pNew );
234 } // end for
237 void
238 SecondariesCalculator::Gather_CrossReferences()
240 gather_Synonyms();
242 for ( stg_iterator it = my_CeStorage().Begin();
243 it != my_CeStorage().End();
244 ++it )
246 (*it).Accept( static_cast< SPInst_asHost& >(*this) );
248 } // end for
250 sort_All2s();
253 void
254 SecondariesCalculator::Make_Links2DeveloperManual(
255 const String & i_devman_reffilepath )
257 // const autodoc::Options &
258 // rOptions = TheAutodocManager().TheOptions();
260 // const String &
261 // rDeveloperManual_URL
262 // = rOptions.Get_Extra(autodoc::OPT_developer_guide);
263 // const String
264 // rDeveloperManual_ReferenceFile
265 // = rOptions.Get_Extra(autodoc::OPT_developer_guide_refs_file);
267 // if ( rDeveloperManual_URL.length() == 0
268 // OR
269 // rDeveloperManual_ReferenceFile.length() == 0 )
270 // {
271 // return;
272 // }
274 csv::File
275 aFile(i_devman_reffilepath, csv::CFM_READ);
276 csv::OpenCloseGuard
277 aFileOpener(aFile);
278 if (aFileOpener)
280 Read_Links2DevManual(aFile);
284 namespace
287 enum E_LinkMode
289 link2descr,
290 link2ref
293 struct OrderCeIdsByName
295 OrderCeIdsByName(
296 const Ce_Storage & i_storage )
297 : rStorage(i_storage),
298 aNameComparison() {}
299 bool operator()(
300 Ce_id i_ce1,
301 Ce_id i_ce2 ) const
303 return aNameComparison( rStorage[i_ce1].LocalName(),
304 rStorage[i_ce2].LocalName() );
307 private:
308 const Ce_Storage & rStorage;
309 LesserName aNameComparison;
317 void
318 SecondariesCalculator::do_Process( const Service & i_rData )
320 const Service &
321 rService = ary_cast<Service>(i_rData);
323 // Interfaces:
324 assignImplementation_toAServicesInterfaces( rService.CeId(),
325 rService.CeId(),
326 interface_2s_ExportingServices );
327 // Services and their interfaces:
328 recursive_AssignIncludingService(rService.CeId(), rService);
331 void
332 SecondariesCalculator::do_Process( const Interface & i_rData )
334 assign_AsDerivedInterface( ary_cast<Interface>(i_rData) );
337 void
338 SecondariesCalculator::do_Process( const Struct & i_rData )
340 assign_AsDerivedStruct( ary_cast<Struct>(i_rData) );
343 void
344 SecondariesCalculator::do_Process( const Exception & i_rData )
346 assign_AsDerivedException( ary_cast<Exception>(i_rData) );
349 void
350 SecondariesCalculator::do_Process( const Typedef & )
352 // KORR_FUTURE
353 // Find out what was meant here ???
355 // const Typedef &
356 // rTypedef = ary_cast<Typedef>(i_rData);
359 void
360 SecondariesCalculator::do_Process( const Singleton & i_rData )
362 const Singleton &
363 rSingleton = ary_cast<Singleton>(i_rData);
365 Service *
366 pServ = lhf_SearchService(rSingleton.AssociatedService());
367 if (pServ != 0)
369 insert_into2sUnique( *pServ,
370 service_2s_InstantiatingSingletons,
371 rSingleton.CeId() );
374 // Interfaces:
375 assignImplementation_toAServicesInterfaces( rSingleton.CeId(),
376 lhf_Search_CeFromTypeId(rSingleton.AssociatedService()),
377 interface_2s_ExportingSingletons );
380 void
381 SecondariesCalculator::do_Process( const SglIfcService & i_rData )
383 const SglIfcService &
384 rSglIfcService = ary_cast<SglIfcService>(i_rData);
386 assignImplementation_toAServicesInterfaces( rSglIfcService.CeId(),
387 rSglIfcService.CeId(),
388 interface_2s_ExportingServices );
391 void
392 SecondariesCalculator::do_Process( const SglIfcSingleton & i_rData )
394 const SglIfcSingleton &
395 rSglIfcSingleton = ary_cast<SglIfcSingleton>(i_rData);
397 Type_id nBase = rSglIfcSingleton.BaseInterface();
398 recursive_AssignImplementation_toExportedInterface( rSglIfcSingleton.CeId(),
399 nBase,
400 interface_2s_ExportingSingletons );
403 void
404 SecondariesCalculator::do_Process( const Function & i_rData )
406 const Function &
407 rFunction = ary_cast<Function>(i_rData);
409 recursive_AssignFunction_toCeAsReturn(rFunction.CeId(), rFunction.ReturnType());
411 for ( Function::ParamList::const_iterator itp = rFunction.Parameters().begin();
412 itp != rFunction.Parameters().end();
413 ++itp )
415 recursive_AssignFunction_toCeAsParameter(rFunction.CeId(), (*itp).Type());
416 } // end for (itp)
418 for ( Function::ExceptionList::const_iterator itx = rFunction.Exceptions().begin();
419 itx != rFunction.Exceptions().end();
420 ++itx )
422 Exception *
423 pX = lhf_SearchException(*itx);
424 if (pX != 0)
426 insert_into2sUnique(*pX, exception_2s_RaisingFunctions, rFunction.CeId());
428 } // end for (itx)
431 void
432 SecondariesCalculator::do_Process( const StructElement & i_rData )
434 const StructElement &
435 rStructElement = ary_cast<StructElement>(i_rData);
437 recursive_AssignStructElement_toCeAsDataType(rStructElement.CeId(), rStructElement.Type());
440 void
441 SecondariesCalculator::do_Process( const Property & i_rData )
443 const Property &
444 rProperty = ary_cast<Property>(i_rData);
446 recursive_AssignStructElement_toCeAsDataType(rProperty.CeId(), rProperty.Type());
449 Ce_id
450 SecondariesCalculator::lhf_Search_CeForType( const ExplicitType & i_rType ) const
452 const ExplicitNameRoom &
453 rExplicitNameRoom = ary_cast<ExplicitNameRoom>(
454 my_TypeStorage()[i_rType.NameRoom()] );
455 Find_ModuleNode
456 rNodeFinder( my_CeStorage(),
457 rExplicitNameRoom.NameChain_Begin(),
458 rExplicitNameRoom.NameChain_End(),
459 i_rType.Name() );
461 if ( rExplicitNameRoom.IsAbsolute() )
463 const Module &
464 rGlobalNamespace = ary_cast<Module>(
465 my_CeStorage()[predefined::ce_GlobalNamespace]);
466 return Search_SubTree( rGlobalNamespace,
467 rNodeFinder );
469 else
471 const Module &
472 rStartModule = ary_cast<Module>(
473 my_CeStorage()[i_rType.ModuleOfOccurrence()]);
474 Ce_id ret = Search_SubTree_UpTillRoot( rStartModule,
475 rNodeFinder );
476 return ret;
477 } // endif (rExplicitNameRoom.IsAbsolute()) else
480 Ce_id
481 SecondariesCalculator::lhf_Search_CeFromTypeId( Type_id i_nType ) const
483 if (NOT i_nType.IsValid())
484 return Ce_id(0);
485 const Ce_Type *
486 pType = ary_cast<Ce_Type>( & my_TypeStorage()[i_nType] );
487 return pType != 0
488 ? pType->RelatedCe()
489 : Ce_id_Null();
492 void
493 SecondariesCalculator::assign_CurLink( char * i_text,
494 const String & i_link,
495 const String & i_linkUI,
496 bool i_isDescr,
497 int i_lineCount )
499 csv_assert(i_text != 0);
501 const ary::idl::Module *
502 pModule = & ary_cast<Module>(
503 my_CeStorage()[predefined::ce_GlobalNamespace]);
505 char * pPastNext = 0;
506 char * pNext = i_text;
507 for ( ;
508 (pPastNext = strstr(pNext,".")) != 0;
509 pNext = pPastNext + 1 )
511 String sNext(pNext, pPastNext-pNext);
512 Ce_id nModule = pModule->Search_Name(sNext);
513 if (nModule.IsValid())
515 pModule = ary_cast<Module>( & my_CeStorage()[nModule] );
517 else
519 pModule = 0;
522 if (pModule == 0)
524 Cerr() << "Warning: Invalid line nr. "
525 << i_lineCount
526 << " in DevelopersGuide reference file:\n"
527 << reinterpret_cast< const char* >(i_text)
528 << "\n"
529 << Endl();
530 return;
532 } // end for
534 pPastNext = strchr(pNext,':');
535 bool bMember = pPastNext != 0;
536 String sCe( pNext, (bMember ? csv::str::size(pPastNext-pNext) : csv::str::maxsize) );
538 // KORR_FUTURE
539 // String sMember(bMember ? pPastNext+1, "");
541 Ce_id nCe = pModule->Search_Name(sCe);
542 if (NOT nCe.IsValid())
544 Cerr() << "Warning: Invalid line nr. "
545 << i_lineCount
546 << " in DevelopersGuide reference file:\n"
547 << reinterpret_cast< const char* >(i_text)
548 << "\n"
549 << Endl();
550 return;
553 CodeEntity &
554 rCe = my_CeStorage()[nCe];
555 if (NOT bMember)
557 if (i_isDescr)
558 rCe.Secondaries().Add_Link2DescriptionInManual(i_link, i_linkUI);
559 else
560 rCe.Secondaries().Add_Link2RefInManual(i_link, i_linkUI);
561 return;
563 else
565 // KORR_FUTURE
566 // Provisorial just doing nothing (or may be
567 // adding a link at main Ces lists).
568 // if (i_isDescr)
569 // rCe.Secondaries().Add_Link2DescriptionInManual(i_link);
570 // else
571 // rCe.Secondaries().Add_Link2RefInManual(i_link);
575 void
576 SecondariesCalculator::gather_Synonyms()
578 const Ce_Storage &
579 cstrg = my_CeStorage();
580 typedef_citerator itEnd(cstrg.End());
581 for ( typedef_citerator it(cstrg.Begin());
582 it != itEnd;
583 ++it )
585 if (NOT it.IsValid())
586 continue;
588 const Typedef &
589 rTypedef = *it;
590 recursive_AssignAsSynonym(rTypedef.CeId(), rTypedef);
591 } // end for (itTd)
594 void
595 SecondariesCalculator::recursive_AssignAsSynonym( Ce_id i_synonymousTypedefsId,
596 const Typedef & i_TypedefToCheck )
598 Ce_id
599 nCe = lhf_Search_CeFromTypeId(i_TypedefToCheck.DefiningType());
600 if (NOT nCe.IsValid())
601 return;
602 CodeEntity &
603 rCe = my_CeStorage()[nCe];
605 switch (rCe.AryClass()) // KORR_FUTURE: make this faster, remove switch.
607 case Interface::class_id:
608 insert_into2sList( rCe,
609 interface_2s_SynonymTypedefs,
610 i_synonymousTypedefsId );
611 break;
612 case Struct::class_id:
613 insert_into2sList( rCe,
614 struct_2s_SynonymTypedefs,
615 i_synonymousTypedefsId );
616 break;
617 case Enum::class_id:
618 insert_into2sList( rCe,
619 enum_2s_SynonymTypedefs,
620 i_synonymousTypedefsId );
621 break;
622 case Typedef::class_id:
623 insert_into2sList( rCe,
624 typedef_2s_SynonymTypedefs,
625 i_synonymousTypedefsId );
626 recursive_AssignAsSynonym( i_synonymousTypedefsId,
627 static_cast< Typedef& >(rCe) );
628 break;
629 // default: do nothing.
633 void
634 SecondariesCalculator::recursive_AssignIncludingService( Ce_id i_includingServicesId,
635 const Service & i_ServiceToCheckItsIncludes )
637 Dyn_StdConstIterator<CommentedRelation>
638 pIncludedServices;
639 i_ServiceToCheckItsIncludes.Get_IncludedServices(pIncludedServices);
641 for ( StdConstIterator<CommentedRelation> &
642 itServ = *pIncludedServices;
643 itServ;
644 ++itServ )
646 Service *
647 pServ = lhf_SearchService((*itServ).Type());
648 if (pServ != 0)
650 insert_into2sUnique( *pServ,
651 service_2s_IncludingServices,
652 i_includingServicesId
654 recursive_AssignIncludingService(i_includingServicesId, *pServ);
656 } // end if
658 assignImplementation_toAServicesInterfaces( i_includingServicesId,
659 lhf_Search_CeFromTypeId( (*itServ).Type() ),
660 interface_2s_ExportingServices );
661 } // end for
664 void
665 SecondariesCalculator::assign_AsDerivedInterface( const Interface & i_rDerived )
667 ary::Dyn_StdConstIterator<ary::idl::CommentedRelation>
668 pHelp;
669 ary::idl::ifc_interface::attr::Get_Bases(pHelp, i_rDerived);
671 for ( ary::StdConstIterator<ary::idl::CommentedRelation> & it = *pHelp;
672 it.operator bool();
673 ++it )
675 Interface *
676 pIfc = lhf_SearchInterface( (*it).Type() );
677 if (pIfc == 0)
678 continue;
680 insert_into2sList( *pIfc,
681 interface_2s_Derivations,
682 i_rDerived.CeId() );
683 } // end for
686 void
687 SecondariesCalculator::assign_AsDerivedStruct( const Struct & i_rDerived )
689 Type_id
690 nBase = i_rDerived.Base();
691 if (nBase.IsValid())
693 Struct *
694 pParent = lhf_SearchStruct(nBase);
695 if (pParent != 0)
697 insert_into2sList( *pParent,
698 struct_2s_Derivations,
699 i_rDerived.CeId() );
704 void
705 SecondariesCalculator::assign_AsDerivedException( const Exception & i_rDerived )
707 Type_id
708 nBase = i_rDerived.Base();
709 if (nBase.IsValid())
711 Exception *
712 pParent = lhf_SearchException(nBase);
713 if (pParent != 0)
715 insert_into2sList( *pParent,
716 exception_2s_Derivations,
717 i_rDerived.CeId() );
718 } // end if
719 } // end if
722 void
723 SecondariesCalculator::assignImplementation_toAServicesInterfaces(
724 Ce_id i_nImpl,
725 Ce_id i_nService,
726 E_2s_of_Interface i_eList )
728 if (NOT i_nService.IsValid())
729 return;
730 Service *
731 pService = ary_cast<Service>( & my_CeStorage()[i_nService] );
732 SglIfcService *
733 pSglIfcService = ary_cast<SglIfcService>( & my_CeStorage()[i_nService] );
735 if (pService != 0)
737 Dyn_StdConstIterator<CommentedRelation>
738 pSupportedInterfaces;
739 pService->Get_SupportedInterfaces(pSupportedInterfaces);
741 for ( StdConstIterator<CommentedRelation> &
742 itInfc = *pSupportedInterfaces;
743 itInfc.operator bool();
744 ++itInfc )
746 recursive_AssignImplementation_toExportedInterface( i_nImpl,
747 (*itInfc).Type(),
748 i_eList );
749 } // end for
751 else if (pSglIfcService != 0)
753 Type_id nBase = pSglIfcService->BaseInterface();
754 recursive_AssignImplementation_toExportedInterface( i_nImpl,
755 nBase,
756 i_eList );
757 } // end if
760 void
761 SecondariesCalculator::recursive_AssignImplementation_toExportedInterface(
762 Ce_id i_nService,
763 Type_id i_nExportedInterface,
764 E_2s_of_Interface i_eList )
766 Interface *
767 pIfc = lhf_SearchInterface(i_nExportedInterface);
768 if (pIfc == 0)
769 return;
771 insert_into2sUnique( *pIfc,
772 i_eList,
773 i_nService );
774 Dyn_StdConstIterator<CommentedRelation>
775 pBases;
776 ary::idl::ifc_interface::attr::Get_Bases(pBases, *pIfc);
777 for ( StdConstIterator<CommentedRelation> & it = *pBases;
778 it.operator bool();
779 ++it )
781 recursive_AssignImplementation_toExportedInterface(i_nService, (*it).Type(), i_eList);
785 void
786 SecondariesCalculator::recursive_AssignFunction_toCeAsReturn( Ce_id i_nFunction,
787 Type_id i_nReturnType )
789 Ce_id
790 nCe = lhf_Search_CeFromTypeId(i_nReturnType);
791 if (NOT nCe.IsValid())
792 return;
794 CodeEntity &
795 rCe = my_CeStorage()[nCe];
796 switch (rCe.AryClass()) // KORR_FUTURE: make this faster, remove switch.
798 case Interface::class_id:
799 insert_into2sList( rCe,
800 interface_2s_AsReturns,
801 i_nFunction );
802 break;
803 case Struct::class_id:
804 insert_into2sList( rCe,
805 struct_2s_AsReturns,
806 i_nFunction );
807 break;
808 case Enum::class_id:
809 insert_into2sList( rCe,
810 enum_2s_AsReturns,
811 i_nFunction );
812 break;
813 case Typedef::class_id:
814 insert_into2sList( rCe,
815 typedef_2s_AsReturns,
816 i_nFunction );
817 recursive_AssignFunction_toCeAsReturn( i_nFunction,
818 static_cast< Typedef& >(rCe).DefiningType() );
819 break;
820 // default: do nothing.
824 void
825 SecondariesCalculator::recursive_AssignFunction_toCeAsParameter( Ce_id i_nFunction,
826 Type_id i_nParameterType )
828 Ce_id
829 nCe = lhf_Search_CeFromTypeId(i_nParameterType);
830 if (NOT nCe.IsValid())
831 return;
833 CodeEntity &
834 rCe = my_CeStorage()[nCe];
835 switch (rCe.AryClass()) // KORR_FUTURE: make this faster, remove switch.
837 case Interface::class_id:
838 insert_into2sList( rCe,
839 interface_2s_AsParameters,
840 i_nFunction );
841 break;
842 case Struct::class_id:
843 insert_into2sList( rCe,
844 struct_2s_AsParameters,
845 i_nFunction );
846 break;
847 case Enum::class_id:
848 insert_into2sList( rCe,
849 enum_2s_AsParameters,
850 i_nFunction );
851 break;
852 case Typedef::class_id:
853 insert_into2sList( rCe,
854 typedef_2s_AsParameters,
855 i_nFunction );
856 recursive_AssignFunction_toCeAsParameter( i_nFunction,
857 static_cast< Typedef& >(rCe).DefiningType() );
858 break;
859 // default: do nothing.
863 void
864 SecondariesCalculator::recursive_AssignStructElement_toCeAsDataType( Ce_id i_nDataElement,
865 Type_id i_nDataType )
867 Ce_id
868 nCe = lhf_Search_CeFromTypeId(i_nDataType);
869 if (NOT nCe.IsValid())
870 return;
872 CodeEntity &
873 rCe = my_CeStorage()[nCe];
874 switch (rCe.AryClass()) // KORR_FUTURE: make this faster, remove switch.
876 case Interface::class_id:
877 insert_into2sList( rCe,
878 interface_2s_AsDataTypes,
879 i_nDataElement );
880 break;
881 case Struct::class_id:
882 insert_into2sList( rCe,
883 struct_2s_AsDataTypes,
884 i_nDataElement );
885 break;
886 case Enum::class_id:
887 insert_into2sList( rCe,
888 enum_2s_AsDataTypes,
889 i_nDataElement );
890 break;
891 case Typedef::class_id:
892 insert_into2sList( rCe,
893 typedef_2s_AsDataTypes,
894 i_nDataElement );
895 recursive_AssignFunction_toCeAsParameter( i_nDataElement,
896 static_cast< Typedef& >(rCe).DefiningType() );
897 break;
898 // default: do nothing.
899 } // end switch
902 void
903 SecondariesCalculator::insert_into2sUnique( CodeEntity & o_out,
904 int i_listIndex,
905 Ce_id i_nCe )
907 std::vector<Ce_id> &
908 rOut = o_out.Secondaries().Access_List(i_listIndex);
909 if (std::find(rOut.begin(),rOut.end(),i_nCe) != rOut.end())
910 return;
911 rOut.push_back(i_nCe);
914 void
915 SecondariesCalculator::sort_All2s()
917 OrderCeIdsByName
918 aIdOrdering(my_CeStorage());
920 for ( stg_iterator it = my_CeStorage().Begin();
921 it != my_CeStorage().End();
922 ++it )
924 Ce_2s &
925 r2s = (*it).Secondaries();
926 int iCount = r2s.CountXrefLists();
927 for (int i = 0; i < iCount; ++i)
929 std::sort( r2s.Access_List(i).begin(),
930 r2s.Access_List(i).end(),
931 aIdOrdering );
932 } // end for (i)
933 } // end for (it)
936 void
937 SecondariesCalculator::Read_Links2DevManual( csv::bstream & i_file )
939 StreamLock aLine(300);
940 StreamStr & rLine = aLine();
943 String sCurLink;
944 String sCurLinkUI;
945 E_LinkMode eCurMode = link2ref;
947 int lineCount = 0;
948 const char * sLink = "LINK:";
949 const char * sDescr = "DESCR:";
950 const char * sTopic = "TOPIC:";
951 const char * sRef = "REF:";
952 const UINT8 cMaxASCIINumWhiteSpace = 32;
954 while (NOT i_file.eod())
956 ++lineCount;
958 rLine.reset();
959 rLine.operator_read_line(i_file);
961 if ( *rLine.c_str() >= 'a' )
963 assign_CurLink(rLine.begin(), sCurLink, sCurLinkUI, eCurMode == link2descr, lineCount);
965 else if ( strncmp(rLine.c_str(), sLink, strlen(sLink)) == 0 )
967 sCurLink = rLine.c_str()+5;
968 sCurLinkUI.clear();
970 else if ( strncmp(rLine.c_str(), sDescr, strlen(sDescr)) == 0 )
972 sCurLinkUI = rLine.c_str()+6;
974 else if ( strncmp(rLine.c_str(), sTopic, strlen(sTopic)) == 0 )
976 eCurMode = link2descr;
978 else if ( strncmp(rLine.c_str(), sRef, strlen(sRef)) == 0 )
980 eCurMode = link2ref;
982 else if (static_cast<UINT8>(*rLine.c_str()) > cMaxASCIINumWhiteSpace)
984 assign_CurLink(rLine.begin(), sCurLink, sCurLinkUI, eCurMode == link2descr, lineCount);
986 // else
987 // Ignore empty line.
989 } // end while
994 } // namespace idl
995 } // namespace ary