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