1*d291ea28SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*d291ea28SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*d291ea28SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*d291ea28SAndrew Rist * distributed with this work for additional information 6*d291ea28SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*d291ea28SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*d291ea28SAndrew Rist * "License"); you may not use this file except in compliance 9*d291ea28SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*d291ea28SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*d291ea28SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*d291ea28SAndrew Rist * software distributed under the License is distributed on an 15*d291ea28SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*d291ea28SAndrew Rist * KIND, either express or implied. See the License for the 17*d291ea28SAndrew Rist * specific language governing permissions and limitations 18*d291ea28SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*d291ea28SAndrew Rist *************************************************************/ 21cdf0e10cSrcweir 22cdf0e10cSrcweir #include <precomp.h> 23cdf0e10cSrcweir #include "ia_ce.hxx" 24cdf0e10cSrcweir 25cdf0e10cSrcweir 26cdf0e10cSrcweir // NOT FULLY DEFINED SERVICES 27cdf0e10cSrcweir #include <algorithm> 28cdf0e10cSrcweir #include <cosv/tpl/tpltools.hxx> 29cdf0e10cSrcweir #include <ary/idl/i_attribute.hxx> 30cdf0e10cSrcweir #include <ary/idl/i_constant.hxx> 31cdf0e10cSrcweir #include <ary/idl/i_constgroup.hxx> 32cdf0e10cSrcweir #include <ary/idl/i_enum.hxx> 33cdf0e10cSrcweir #include <ary/idl/i_enumvalue.hxx> 34cdf0e10cSrcweir #include <ary/idl/i_exception.hxx> 35cdf0e10cSrcweir #include <ary/idl/i_function.hxx> 36cdf0e10cSrcweir #include <ary/idl/i_interface.hxx> 37cdf0e10cSrcweir #include <ary/idl/i_module.hxx> 38cdf0e10cSrcweir #include <ary/idl/i_namelookup.hxx> 39cdf0e10cSrcweir #include <ary/idl/i_property.hxx> 40cdf0e10cSrcweir #include <ary/idl/i_service.hxx> 41cdf0e10cSrcweir #include <ary/idl/i_singleton.hxx> 42cdf0e10cSrcweir #include <ary/idl/i_siservice.hxx> 43cdf0e10cSrcweir #include <ary/idl/i_sisingleton.hxx> 44cdf0e10cSrcweir #include <ary/idl/i_struct.hxx> 45cdf0e10cSrcweir #include <ary/idl/i_structelem.hxx> 46cdf0e10cSrcweir #include <ary/idl/i_traits.hxx> 47cdf0e10cSrcweir #include <ary/idl/i_typedef.hxx> 48cdf0e10cSrcweir #include <idsort.hxx> 49cdf0e10cSrcweir #include "ia_type.hxx" 50cdf0e10cSrcweir #include "is_ce.hxx" 51cdf0e10cSrcweir #include "it_tplparam.hxx" 52cdf0e10cSrcweir 53cdf0e10cSrcweir 54cdf0e10cSrcweir 55cdf0e10cSrcweir 56cdf0e10cSrcweir namespace ary 57cdf0e10cSrcweir { 58cdf0e10cSrcweir namespace idl 59cdf0e10cSrcweir { 60cdf0e10cSrcweir 61cdf0e10cSrcweir inline Module & 62cdf0e10cSrcweir CeAdmin::lhf_Access_Module( Ce_id i_nId ) 63cdf0e10cSrcweir { return ary_cast<Module>(Storage()[i_nId]); } 64cdf0e10cSrcweir 65cdf0e10cSrcweir inline void 66cdf0e10cSrcweir CeAdmin::lhf_Put2Storage_and_AssignId( CodeEntity & pass_io_rCe ) 67cdf0e10cSrcweir { // This also assigns an ID to pass_io_rCe: 68cdf0e10cSrcweir Storage().Store_Entity(pass_io_rCe); 69cdf0e10cSrcweir my_NameDictionary().Add_Name( pass_io_rCe.LocalName(), 70cdf0e10cSrcweir pass_io_rCe.CeId(), 71cdf0e10cSrcweir pass_io_rCe.AryClass(), 72cdf0e10cSrcweir pass_io_rCe.Owner() ); 73cdf0e10cSrcweir } 74cdf0e10cSrcweir 75cdf0e10cSrcweir inline void 76cdf0e10cSrcweir CeAdmin::lhf_Store_NewEntity( DYN CodeEntity & pass_io_rCe, 77cdf0e10cSrcweir Module & i_rOwner ) 78cdf0e10cSrcweir { 79cdf0e10cSrcweir lhf_Put2Storage_and_AssignId(pass_io_rCe); 80cdf0e10cSrcweir i_rOwner.Add_Name(pass_io_rCe.LocalName(), pass_io_rCe.CeId()); 81cdf0e10cSrcweir } 82cdf0e10cSrcweir 83cdf0e10cSrcweir inline void 84cdf0e10cSrcweir CeAdmin::lhf_Store_NewEntity( DYN CodeEntity & pass_io_rCe, 85cdf0e10cSrcweir Ce_id i_nOwnerModule ) 86cdf0e10cSrcweir { 87cdf0e10cSrcweir lhf_Store_NewEntity(pass_io_rCe, lhf_Access_Module(i_nOwnerModule)); 88cdf0e10cSrcweir } 89cdf0e10cSrcweir 90cdf0e10cSrcweir 91cdf0e10cSrcweir 92cdf0e10cSrcweir CeAdmin::CeAdmin( NameLookup & io_rNameDictionary, 93cdf0e10cSrcweir TypeAdmin & io_rTypePilot ) 94cdf0e10cSrcweir : pStorage(new Ce_Storage), 95cdf0e10cSrcweir pGlobalNamespace(0), 96cdf0e10cSrcweir pNameDictionary(&io_rNameDictionary), 97cdf0e10cSrcweir pTypePilot(&io_rTypePilot) 98cdf0e10cSrcweir { 99cdf0e10cSrcweir Storage().Set_Reserved( 100cdf0e10cSrcweir predefined::ce_GlobalNamespace, 101cdf0e10cSrcweir *new Module ); 102cdf0e10cSrcweir pGlobalNamespace = &lhf_Access_Module(Ce_id(predefined::ce_GlobalNamespace)); 103cdf0e10cSrcweir } 104cdf0e10cSrcweir 105cdf0e10cSrcweir CeAdmin::~CeAdmin() 106cdf0e10cSrcweir { 107cdf0e10cSrcweir } 108cdf0e10cSrcweir 109cdf0e10cSrcweir 110cdf0e10cSrcweir 111cdf0e10cSrcweir Module & 112cdf0e10cSrcweir CeAdmin::CheckIn_Module( Ce_id i_nParentId, 113cdf0e10cSrcweir const String & i_sName ) 114cdf0e10cSrcweir { 115cdf0e10cSrcweir Module & rOwner = lhf_Access_Module(i_nParentId); 116cdf0e10cSrcweir Ce_id nId = rOwner.Search_Name(i_sName); 117cdf0e10cSrcweir if (nId.IsValid()) 118cdf0e10cSrcweir { 119cdf0e10cSrcweir return lhf_Access_Module(nId); 120cdf0e10cSrcweir } 121cdf0e10cSrcweir 122cdf0e10cSrcweir Module & ret = *new Module( i_sName, 123cdf0e10cSrcweir rOwner ); 124cdf0e10cSrcweir lhf_Store_NewEntity(ret, rOwner); 125cdf0e10cSrcweir return ret; 126cdf0e10cSrcweir } 127cdf0e10cSrcweir 128cdf0e10cSrcweir Service & 129cdf0e10cSrcweir CeAdmin::Store_Service( Ce_id i_nOwner, 130cdf0e10cSrcweir const String & i_sName ) 131cdf0e10cSrcweir { 132cdf0e10cSrcweir Service & ret = *new Service( i_sName, 133cdf0e10cSrcweir i_nOwner ); 134cdf0e10cSrcweir lhf_Store_NewEntity(ret, i_nOwner); 135cdf0e10cSrcweir return ret; 136cdf0e10cSrcweir } 137cdf0e10cSrcweir 138cdf0e10cSrcweir SglIfcService & 139cdf0e10cSrcweir CeAdmin::Store_SglIfcService( Ce_id i_nOwner, 140cdf0e10cSrcweir const String & i_sName, 141cdf0e10cSrcweir Type_id i_nBaseInterface ) 142cdf0e10cSrcweir { 143cdf0e10cSrcweir SglIfcService & 144cdf0e10cSrcweir ret = *new SglIfcService( i_sName, 145cdf0e10cSrcweir i_nOwner, 146cdf0e10cSrcweir i_nBaseInterface ); 147cdf0e10cSrcweir lhf_Store_NewEntity(ret, i_nOwner); 148cdf0e10cSrcweir return ret; 149cdf0e10cSrcweir } 150cdf0e10cSrcweir 151cdf0e10cSrcweir Interface & 152cdf0e10cSrcweir CeAdmin::Store_Interface( Ce_id i_nOwner, 153cdf0e10cSrcweir const String & i_sName, 154cdf0e10cSrcweir Type_id i_nBase ) 155cdf0e10cSrcweir { 156cdf0e10cSrcweir Interface & ret = *new Interface( i_sName, 157cdf0e10cSrcweir i_nOwner ); 158cdf0e10cSrcweir lhf_Store_NewEntity(ret, i_nOwner); 159cdf0e10cSrcweir if (i_nBase.IsValid()) 160cdf0e10cSrcweir ret.Add_Base(i_nBase, 0); 161cdf0e10cSrcweir return ret; 162cdf0e10cSrcweir } 163cdf0e10cSrcweir 164cdf0e10cSrcweir Struct & 165cdf0e10cSrcweir CeAdmin::Store_Struct( Ce_id i_nOwner, 166cdf0e10cSrcweir const String & i_sName, 167cdf0e10cSrcweir Type_id i_nBase, 168cdf0e10cSrcweir const String & i_sTemplateParam ) 169cdf0e10cSrcweir { 170cdf0e10cSrcweir if (NOT i_sTemplateParam.empty()) 171cdf0e10cSrcweir { 172cdf0e10cSrcweir return lhf_Store_TplStruct( i_nOwner, 173cdf0e10cSrcweir i_sName, 174cdf0e10cSrcweir i_nBase, 175cdf0e10cSrcweir i_sTemplateParam ); 176cdf0e10cSrcweir } 177cdf0e10cSrcweir 178cdf0e10cSrcweir Struct & ret = *new Struct( i_sName, 179cdf0e10cSrcweir i_nOwner, 180cdf0e10cSrcweir i_nBase, 181cdf0e10cSrcweir String::Null_(), 182cdf0e10cSrcweir Type_id::Null_() ); 183cdf0e10cSrcweir lhf_Store_NewEntity(ret, i_nOwner); 184cdf0e10cSrcweir 185cdf0e10cSrcweir return ret; 186cdf0e10cSrcweir } 187cdf0e10cSrcweir 188cdf0e10cSrcweir Exception & 189cdf0e10cSrcweir CeAdmin::Store_Exception( Ce_id i_nOwner, 190cdf0e10cSrcweir const String & i_sName, 191cdf0e10cSrcweir Type_id i_nBase ) 192cdf0e10cSrcweir { 193cdf0e10cSrcweir Exception & ret = *new Exception( i_sName, 194cdf0e10cSrcweir i_nOwner, 195cdf0e10cSrcweir i_nBase ); 196cdf0e10cSrcweir lhf_Store_NewEntity(ret, i_nOwner); 197cdf0e10cSrcweir return ret; 198cdf0e10cSrcweir } 199cdf0e10cSrcweir 200cdf0e10cSrcweir Enum & 201cdf0e10cSrcweir CeAdmin::Store_Enum( Ce_id i_nOwner, 202cdf0e10cSrcweir const String & i_sName ) 203cdf0e10cSrcweir { 204cdf0e10cSrcweir Enum & ret = *new Enum( i_sName, 205cdf0e10cSrcweir i_nOwner ); 206cdf0e10cSrcweir lhf_Store_NewEntity(ret, i_nOwner); 207cdf0e10cSrcweir return ret; 208cdf0e10cSrcweir } 209cdf0e10cSrcweir 210cdf0e10cSrcweir Typedef & 211cdf0e10cSrcweir CeAdmin::Store_Typedef( Ce_id i_nOwner, 212cdf0e10cSrcweir const String & i_sName, 213cdf0e10cSrcweir Type_id i_nDefiningType ) 214cdf0e10cSrcweir { 215cdf0e10cSrcweir Typedef & ret = *new Typedef( i_sName, 216cdf0e10cSrcweir i_nOwner, 217cdf0e10cSrcweir i_nDefiningType ); 218cdf0e10cSrcweir lhf_Store_NewEntity(ret, i_nOwner); 219cdf0e10cSrcweir return ret; 220cdf0e10cSrcweir } 221cdf0e10cSrcweir 222cdf0e10cSrcweir 223cdf0e10cSrcweir ConstantsGroup & 224cdf0e10cSrcweir CeAdmin::Store_ConstantsGroup( Ce_id i_nOwner, 225cdf0e10cSrcweir const String & i_sName ) 226cdf0e10cSrcweir { 227cdf0e10cSrcweir ConstantsGroup & ret = *new ConstantsGroup( i_sName, 228cdf0e10cSrcweir i_nOwner ); 229cdf0e10cSrcweir lhf_Store_NewEntity(ret, i_nOwner); 230cdf0e10cSrcweir return ret; 231cdf0e10cSrcweir } 232cdf0e10cSrcweir 233cdf0e10cSrcweir Singleton & 234cdf0e10cSrcweir CeAdmin::Store_Singleton( Ce_id i_nOwner, 235cdf0e10cSrcweir const String & i_sName ) 236cdf0e10cSrcweir { 237cdf0e10cSrcweir Singleton & ret = *new Singleton( i_sName, 238cdf0e10cSrcweir i_nOwner ); 239cdf0e10cSrcweir lhf_Store_NewEntity(ret, i_nOwner); 240cdf0e10cSrcweir return ret; 241cdf0e10cSrcweir } 242cdf0e10cSrcweir 243cdf0e10cSrcweir SglIfcSingleton & 244cdf0e10cSrcweir CeAdmin::Store_SglIfcSingleton( Ce_id i_nOwner, 245cdf0e10cSrcweir const String & i_sName, 246cdf0e10cSrcweir Type_id i_nBaseInterface ) 247cdf0e10cSrcweir { 248cdf0e10cSrcweir SglIfcSingleton & 249cdf0e10cSrcweir ret = *new SglIfcSingleton( i_sName, 250cdf0e10cSrcweir i_nOwner, 251cdf0e10cSrcweir i_nBaseInterface ); 252cdf0e10cSrcweir lhf_Store_NewEntity(ret, i_nOwner); 253cdf0e10cSrcweir return ret; 254cdf0e10cSrcweir } 255cdf0e10cSrcweir 256cdf0e10cSrcweir Constant & 257cdf0e10cSrcweir CeAdmin::Store_Constant( Ce_id i_nOwner, 258cdf0e10cSrcweir const String & i_sName, 259cdf0e10cSrcweir Type_id i_nType, 260cdf0e10cSrcweir const String & i_sValue ) 261cdf0e10cSrcweir { 262cdf0e10cSrcweir ConstantsGroup & 263cdf0e10cSrcweir rOwner = ary_cast<ConstantsGroup>(Storage()[i_nOwner]); 264cdf0e10cSrcweir Constant & ret = *new Constant( i_sName, 265cdf0e10cSrcweir i_nOwner, 266cdf0e10cSrcweir rOwner.NameRoom(), 267cdf0e10cSrcweir i_nType, 268cdf0e10cSrcweir i_sValue ); 269cdf0e10cSrcweir lhf_Put2Storage_and_AssignId(ret); 270cdf0e10cSrcweir rOwner.Add_Constant(ret.CeId()); 271cdf0e10cSrcweir return ret; 272cdf0e10cSrcweir } 273cdf0e10cSrcweir 274cdf0e10cSrcweir Property & 275cdf0e10cSrcweir CeAdmin::Store_Property( Ce_id i_nOwner, 276cdf0e10cSrcweir const String & i_sName, 277cdf0e10cSrcweir Type_id i_nType, 278cdf0e10cSrcweir Property::Stereotypes i_stereotypes ) 279cdf0e10cSrcweir { 280cdf0e10cSrcweir Service & 281cdf0e10cSrcweir rOwner = ary_cast<Service>(Storage()[i_nOwner]); 282cdf0e10cSrcweir Property & ret = *new Property( i_sName, 283cdf0e10cSrcweir i_nOwner, 284cdf0e10cSrcweir rOwner.NameRoom(), 285cdf0e10cSrcweir i_nType, 286cdf0e10cSrcweir i_stereotypes ); 287cdf0e10cSrcweir lhf_Put2Storage_and_AssignId(ret); 288cdf0e10cSrcweir rOwner.Add_Property(ret.CeId()); 289cdf0e10cSrcweir return ret; 290cdf0e10cSrcweir } 291cdf0e10cSrcweir 292cdf0e10cSrcweir Function & 293cdf0e10cSrcweir CeAdmin::Store_Function( Ce_id i_nOwner, 294cdf0e10cSrcweir const String & i_sName, 295cdf0e10cSrcweir Type_id i_nReturnType, 296cdf0e10cSrcweir bool i_bOneWay ) 297cdf0e10cSrcweir { 298cdf0e10cSrcweir Interface & 299cdf0e10cSrcweir rOwner = ary_cast<Interface>(Storage()[i_nOwner]); 300cdf0e10cSrcweir Function & ret = *new Function( i_sName, 301cdf0e10cSrcweir i_nOwner, 302cdf0e10cSrcweir rOwner.NameRoom(), 303cdf0e10cSrcweir i_nReturnType, 304cdf0e10cSrcweir i_bOneWay); 305cdf0e10cSrcweir lhf_Put2Storage_and_AssignId(ret); 306cdf0e10cSrcweir rOwner.Add_Function(ret.CeId()); 307cdf0e10cSrcweir return ret; 308cdf0e10cSrcweir } 309cdf0e10cSrcweir 310cdf0e10cSrcweir Function & 311cdf0e10cSrcweir CeAdmin::Store_ServiceConstructor( Ce_id i_nOwner, 312cdf0e10cSrcweir const String & i_sName ) 313cdf0e10cSrcweir { 314cdf0e10cSrcweir SglIfcService & 315cdf0e10cSrcweir rOwner = ary_cast<SglIfcService>(Storage()[i_nOwner]); 316cdf0e10cSrcweir Function & ret = *new Function( i_sName, 317cdf0e10cSrcweir i_nOwner, 318cdf0e10cSrcweir rOwner.NameRoom() ); 319cdf0e10cSrcweir lhf_Put2Storage_and_AssignId(ret); 320cdf0e10cSrcweir rOwner.Add_Constructor(ret.CeId()); 321cdf0e10cSrcweir return ret; 322cdf0e10cSrcweir } 323cdf0e10cSrcweir 324cdf0e10cSrcweir StructElement & 325cdf0e10cSrcweir CeAdmin::Store_StructMember( Ce_id i_nOwner, 326cdf0e10cSrcweir const String & i_sName, 327cdf0e10cSrcweir Type_id i_nType ) 328cdf0e10cSrcweir { 329cdf0e10cSrcweir Struct & 330cdf0e10cSrcweir rOwner = ary_cast<Struct>(Storage()[i_nOwner]); 331cdf0e10cSrcweir StructElement & ret = *new StructElement( i_sName, 332cdf0e10cSrcweir i_nOwner, 333cdf0e10cSrcweir rOwner.NameRoom(), 334cdf0e10cSrcweir i_nType ); 335cdf0e10cSrcweir lhf_Put2Storage_and_AssignId(ret); 336cdf0e10cSrcweir rOwner.Add_Member(ret.CeId()); 337cdf0e10cSrcweir return ret; 338cdf0e10cSrcweir } 339cdf0e10cSrcweir 340cdf0e10cSrcweir StructElement & 341cdf0e10cSrcweir CeAdmin::Store_ExceptionMember( Ce_id i_nOwner, 342cdf0e10cSrcweir const String & i_sName, 343cdf0e10cSrcweir Type_id i_nType ) 344cdf0e10cSrcweir { 345cdf0e10cSrcweir Exception & 346cdf0e10cSrcweir rOwner = ary_cast<Exception>(Storage()[i_nOwner]); 347cdf0e10cSrcweir StructElement & ret = *new StructElement( i_sName, 348cdf0e10cSrcweir i_nOwner, 349cdf0e10cSrcweir rOwner.NameRoom(), 350cdf0e10cSrcweir i_nType ); 351cdf0e10cSrcweir lhf_Put2Storage_and_AssignId(ret); 352cdf0e10cSrcweir rOwner.Add_Member(ret.CeId()); 353cdf0e10cSrcweir return ret; 354cdf0e10cSrcweir } 355cdf0e10cSrcweir 356cdf0e10cSrcweir EnumValue & 357cdf0e10cSrcweir CeAdmin::Store_EnumValue( Ce_id i_nOwner, 358cdf0e10cSrcweir const String & i_sName, 359cdf0e10cSrcweir const String & i_sValue ) 360cdf0e10cSrcweir { 361cdf0e10cSrcweir Enum & 362cdf0e10cSrcweir rOwner = ary_cast<Enum>(Storage()[i_nOwner]); 363cdf0e10cSrcweir EnumValue & ret = *new EnumValue( i_sName, 364cdf0e10cSrcweir i_nOwner, 365cdf0e10cSrcweir rOwner.NameRoom(), 366cdf0e10cSrcweir i_sValue ); 367cdf0e10cSrcweir lhf_Put2Storage_and_AssignId(ret); 368cdf0e10cSrcweir rOwner.Add_Value(ret.CeId()); 369cdf0e10cSrcweir return ret; 370cdf0e10cSrcweir } 371cdf0e10cSrcweir 372cdf0e10cSrcweir Attribute & 373cdf0e10cSrcweir CeAdmin::Store_Attribute( Ce_id i_nOwner, 374cdf0e10cSrcweir const String & i_sName, 375cdf0e10cSrcweir Type_id i_nType, 376cdf0e10cSrcweir bool i_bReadOnly, 377cdf0e10cSrcweir bool i_bBound ) 378cdf0e10cSrcweir { 379cdf0e10cSrcweir Interface & 380cdf0e10cSrcweir rOwner = ary_cast<Interface>(Storage()[i_nOwner]); 381cdf0e10cSrcweir 382cdf0e10cSrcweir Attribute & ret = *new Attribute ( i_sName, 383cdf0e10cSrcweir i_nOwner, 384cdf0e10cSrcweir rOwner.NameRoom(), 385cdf0e10cSrcweir i_nType, 386cdf0e10cSrcweir i_bReadOnly, 387cdf0e10cSrcweir i_bBound ); 388cdf0e10cSrcweir lhf_Put2Storage_and_AssignId(ret); 389cdf0e10cSrcweir rOwner.Add_Attribute(ret.CeId()); 390cdf0e10cSrcweir return ret; 391cdf0e10cSrcweir } 392cdf0e10cSrcweir 393cdf0e10cSrcweir const Module & 394cdf0e10cSrcweir CeAdmin::GlobalNamespace() const 395cdf0e10cSrcweir { 396cdf0e10cSrcweir csv_assert(pGlobalNamespace); 397cdf0e10cSrcweir return *pGlobalNamespace; 398cdf0e10cSrcweir } 399cdf0e10cSrcweir 400cdf0e10cSrcweir const CodeEntity & 401cdf0e10cSrcweir CeAdmin::Find_Ce( Ce_id i_nId ) const 402cdf0e10cSrcweir { 403cdf0e10cSrcweir return Storage()[i_nId]; 404cdf0e10cSrcweir 405cdf0e10cSrcweir } 406cdf0e10cSrcweir 407cdf0e10cSrcweir const Module & 408cdf0e10cSrcweir CeAdmin::Find_Module( Ce_id i_nId ) const 409cdf0e10cSrcweir { 410cdf0e10cSrcweir return ary_cast<Module>(Storage()[i_nId]); 411cdf0e10cSrcweir } 412cdf0e10cSrcweir 413cdf0e10cSrcweir const Module * 414cdf0e10cSrcweir CeAdmin::Search_Module( Ce_id i_nId ) const 415cdf0e10cSrcweir { 416cdf0e10cSrcweir if (NOT i_nId.IsValid()) 417cdf0e10cSrcweir return 0; 418cdf0e10cSrcweir return ary_cast<Module>( & Storage()[i_nId] ); 419cdf0e10cSrcweir } 420cdf0e10cSrcweir 421cdf0e10cSrcweir const Function & 422cdf0e10cSrcweir CeAdmin::Find_Function( Ce_id i_nId ) const 423cdf0e10cSrcweir { 424cdf0e10cSrcweir return ary_cast<Function>(Storage()[i_nId]); 425cdf0e10cSrcweir } 426cdf0e10cSrcweir 427cdf0e10cSrcweir const Property & 428cdf0e10cSrcweir CeAdmin::Find_Property( Ce_id i_nId ) const 429cdf0e10cSrcweir { 430cdf0e10cSrcweir return ary_cast<Property>(Storage()[i_nId]); 431cdf0e10cSrcweir } 432cdf0e10cSrcweir 433cdf0e10cSrcweir const EnumValue & 434cdf0e10cSrcweir CeAdmin::Find_EnumValue( Ce_id i_nId ) const 435cdf0e10cSrcweir { 436cdf0e10cSrcweir return ary_cast<EnumValue>(Storage()[i_nId]); 437cdf0e10cSrcweir } 438cdf0e10cSrcweir 439cdf0e10cSrcweir const Constant & 440cdf0e10cSrcweir CeAdmin::Find_Constant( Ce_id i_nId ) const 441cdf0e10cSrcweir { 442cdf0e10cSrcweir return ary_cast<Constant>(Storage()[i_nId]); 443cdf0e10cSrcweir } 444cdf0e10cSrcweir 445cdf0e10cSrcweir const StructElement & 446cdf0e10cSrcweir CeAdmin::Find_StructElement( Ce_id i_nId ) const 447cdf0e10cSrcweir { 448cdf0e10cSrcweir return ary_cast<StructElement>(Storage()[i_nId]); 449cdf0e10cSrcweir } 450cdf0e10cSrcweir 451cdf0e10cSrcweir void 452cdf0e10cSrcweir CeAdmin::Get_Text( StringVector & o_module, 453cdf0e10cSrcweir String & o_ce, 454cdf0e10cSrcweir String & o_member, 455cdf0e10cSrcweir const CodeEntity & i_ce ) const 456cdf0e10cSrcweir { 457cdf0e10cSrcweir const CodeEntity * pCe = &i_ce; 458cdf0e10cSrcweir csv::erase_container(o_module); 459cdf0e10cSrcweir o_ce.clear(); 460cdf0e10cSrcweir o_member.clear(); 461cdf0e10cSrcweir 462cdf0e10cSrcweir switch ( pCe->SightLevel() ) 463cdf0e10cSrcweir { 464cdf0e10cSrcweir // Here are intentionally no breaks! 465cdf0e10cSrcweir case sl_Member: 466cdf0e10cSrcweir if ( is_type<Function>(*pCe) ) 467cdf0e10cSrcweir o_member = StreamLock(200)() 468cdf0e10cSrcweir << pCe->LocalName() 469cdf0e10cSrcweir << "()" 470cdf0e10cSrcweir << c_str; 471cdf0e10cSrcweir else 472cdf0e10cSrcweir o_member = pCe->LocalName(); 473cdf0e10cSrcweir pCe = & Storage()[pCe->Owner()]; 474cdf0e10cSrcweir case sl_File: 475cdf0e10cSrcweir o_ce = pCe->LocalName(); 476cdf0e10cSrcweir pCe = & Storage()[pCe->NameRoom()]; 477cdf0e10cSrcweir case sl_Module: 478cdf0e10cSrcweir get_ModuleText(o_module,*pCe); 479cdf0e10cSrcweir break; 480cdf0e10cSrcweir default: 481cdf0e10cSrcweir csv_assert(false); 482cdf0e10cSrcweir } // end switch 483cdf0e10cSrcweir } 484cdf0e10cSrcweir 485cdf0e10cSrcweir const NameLookup & 486cdf0e10cSrcweir CeAdmin::NameDictionary() const 487cdf0e10cSrcweir { 488cdf0e10cSrcweir return *pNameDictionary; 489cdf0e10cSrcweir } 490cdf0e10cSrcweir 491cdf0e10cSrcweir 492cdf0e10cSrcweir void 493cdf0e10cSrcweir CeAdmin::Get_AlphabeticalIndex( std::vector<Ce_id> & o_rResult, 494cdf0e10cSrcweir alphabetical_index::E_Letter i_cLetter ) const 495cdf0e10cSrcweir { 496cdf0e10cSrcweir const int C_nLowerUpperDiff = 'a'-'A'; 497cdf0e10cSrcweir 498cdf0e10cSrcweir // Establishing filter: 499cdf0e10cSrcweir UINT8 filter[256]; 500cdf0e10cSrcweir 501cdf0e10cSrcweir UINT8 nLetter = static_cast<UINT8>(i_cLetter); 502cdf0e10cSrcweir memset(filter, 0, 256); 503cdf0e10cSrcweir filter[nLetter] = 1; 504cdf0e10cSrcweir if ( i_cLetter != alphabetical_index::non_alpha ) 505cdf0e10cSrcweir filter[nLetter - C_nLowerUpperDiff] = 1; 506cdf0e10cSrcweir 507cdf0e10cSrcweir // Gather entities which start with i_cLetter: 508cdf0e10cSrcweir o_rResult.reserve(1000); 509cdf0e10cSrcweir idl::Ce_Storage::c_iter 510cdf0e10cSrcweir itEnd = Storage().End(); 511cdf0e10cSrcweir for ( idl::Ce_Storage::c_iter it = Storage().BeginUnreserved(); 512cdf0e10cSrcweir it != itEnd; 513cdf0e10cSrcweir ++it ) 514cdf0e10cSrcweir { 515cdf0e10cSrcweir if ( filter[ static_cast<UINT8>(*(*it).LocalName().c_str()) ] == 1 ) 516cdf0e10cSrcweir o_rResult.push_back( (*it).CeId() ); 517cdf0e10cSrcweir } 518cdf0e10cSrcweir 519cdf0e10cSrcweir std::sort( o_rResult.begin(), 520cdf0e10cSrcweir o_rResult.end(), 521cdf0e10cSrcweir IdSorter<Ce_Compare>() ); 522cdf0e10cSrcweir } 523cdf0e10cSrcweir 524cdf0e10cSrcweir 525cdf0e10cSrcweir Module & 526cdf0e10cSrcweir CeAdmin::GlobalNamespace() 527cdf0e10cSrcweir { 528cdf0e10cSrcweir csv_assert(pGlobalNamespace); 529cdf0e10cSrcweir return *pGlobalNamespace; 530cdf0e10cSrcweir } 531cdf0e10cSrcweir 532cdf0e10cSrcweir CodeEntity & 533cdf0e10cSrcweir CeAdmin::Find_Ce( Ce_id i_nId ) 534cdf0e10cSrcweir { 535cdf0e10cSrcweir return Storage()[i_nId]; 536cdf0e10cSrcweir } 537cdf0e10cSrcweir 538cdf0e10cSrcweir void 539cdf0e10cSrcweir CeAdmin::get_ModuleText( StringVector & o_module, 540cdf0e10cSrcweir const CodeEntity & i_ce ) const 541cdf0e10cSrcweir { 542cdf0e10cSrcweir if (i_ce.NameRoom().IsValid()) 543cdf0e10cSrcweir { 544cdf0e10cSrcweir const CodeEntity & 545cdf0e10cSrcweir rParent = Storage()[i_ce.NameRoom()]; 546cdf0e10cSrcweir get_ModuleText(o_module, rParent); 547cdf0e10cSrcweir o_module.push_back(i_ce.LocalName()); 548cdf0e10cSrcweir } 549cdf0e10cSrcweir } 550cdf0e10cSrcweir 551cdf0e10cSrcweir Struct & 552cdf0e10cSrcweir CeAdmin::lhf_Store_TplStruct( Ce_id i_nOwner, 553cdf0e10cSrcweir const String & i_sName, 554cdf0e10cSrcweir Type_id i_nBase, 555cdf0e10cSrcweir const String & i_sTemplateParam ) 556cdf0e10cSrcweir { 557cdf0e10cSrcweir csv_assert(NOT i_sTemplateParam.empty()); 558cdf0e10cSrcweir 559cdf0e10cSrcweir TemplateParamType & 560cdf0e10cSrcweir rTpt = pTypePilot->Store_TemplateParamType(i_sTemplateParam); 561cdf0e10cSrcweir 562cdf0e10cSrcweir Struct & ret = *new Struct( i_sName, 563cdf0e10cSrcweir i_nOwner, 564cdf0e10cSrcweir i_nBase, 565cdf0e10cSrcweir i_sTemplateParam, 566cdf0e10cSrcweir rTpt.TypeId() ); 567cdf0e10cSrcweir lhf_Store_NewEntity(ret, i_nOwner); 568cdf0e10cSrcweir rTpt.Set_StructId(ret.CeId()); 569cdf0e10cSrcweir 570cdf0e10cSrcweir return ret; 571cdf0e10cSrcweir } 572cdf0e10cSrcweir 573cdf0e10cSrcweir 574cdf0e10cSrcweir } // namespace idl 575cdf0e10cSrcweir } // namespace ary 576