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 "hi_ary.hxx" 24cdf0e10cSrcweir 25cdf0e10cSrcweir 26cdf0e10cSrcweir // NOT FULLY DEFINED SERVICES 27cdf0e10cSrcweir #include <cosv/ploc_dir.hxx> 28cdf0e10cSrcweir #include <ary/idl/i_gate.hxx> 29cdf0e10cSrcweir #include <ary/idl/i_module.hxx> 30cdf0e10cSrcweir #include <ary/idl/i_ce.hxx> 31cdf0e10cSrcweir #include <ary/idl/i_type.hxx> 32cdf0e10cSrcweir #include <ary/idl/ip_ce.hxx> 33cdf0e10cSrcweir #include <ary/idl/ip_type.hxx> 34cdf0e10cSrcweir 35cdf0e10cSrcweir 36cdf0e10cSrcweir inline const ary::idl::Gate & 37cdf0e10cSrcweir AryAccess::gate() const 38cdf0e10cSrcweir { return rGate; } 39cdf0e10cSrcweir 40cdf0e10cSrcweir inline const ary::idl::CePilot & 41cdf0e10cSrcweir AryAccess::ces() const 42cdf0e10cSrcweir { return rGate.Ces(); } 43cdf0e10cSrcweir 44cdf0e10cSrcweir inline const ary::idl::TypePilot & 45cdf0e10cSrcweir AryAccess::types() const 46cdf0e10cSrcweir { return rGate.Types(); } 47cdf0e10cSrcweir 48cdf0e10cSrcweir inline const ary::idl::Module * 49cdf0e10cSrcweir AryAccess::find_SubModule( const ary::idl::Module & i_parent, 50cdf0e10cSrcweir const String & i_name ) const 51cdf0e10cSrcweir { 52cdf0e10cSrcweir ary::idl::Ce_id 53cdf0e10cSrcweir nModule = i_parent.Search_Name(i_name); 54cdf0e10cSrcweir return ces().Search_Module(nModule); 55cdf0e10cSrcweir } 56cdf0e10cSrcweir 57cdf0e10cSrcweir bool 58cdf0e10cSrcweir AryAccess::nextName( const char * & io_TextPtr, 59cdf0e10cSrcweir String & o_name ) const 60cdf0e10cSrcweir { 61cdf0e10cSrcweir if ( strncmp(io_TextPtr,"::", 2) == 0 ) 62cdf0e10cSrcweir io_TextPtr += 2; 63cdf0e10cSrcweir 64cdf0e10cSrcweir const char * pEnd = strchr(io_TextPtr,':'); 65cdf0e10cSrcweir size_t nLen = pEnd == 0 66cdf0e10cSrcweir ? strlen(io_TextPtr) 67cdf0e10cSrcweir : pEnd - io_TextPtr; 68cdf0e10cSrcweir o_name.assign(io_TextPtr, nLen); 69cdf0e10cSrcweir io_TextPtr += nLen; 70cdf0e10cSrcweir 71cdf0e10cSrcweir return nLen > 0; 72cdf0e10cSrcweir } 73cdf0e10cSrcweir 74cdf0e10cSrcweir 75cdf0e10cSrcweir 76cdf0e10cSrcweir AryAccess::AryAccess( const ary::idl::Gate & i_rGate ) 77cdf0e10cSrcweir : rGate(i_rGate) 78cdf0e10cSrcweir { 79cdf0e10cSrcweir } 80cdf0e10cSrcweir 81cdf0e10cSrcweir const ary::idl::Module & 82cdf0e10cSrcweir AryAccess::GlobalNamespace() const 83cdf0e10cSrcweir { 84cdf0e10cSrcweir return ces().GlobalNamespace(); 85cdf0e10cSrcweir } 86cdf0e10cSrcweir 87cdf0e10cSrcweir const ary::idl::Module & 88cdf0e10cSrcweir AryAccess::Find_Module( ary::idl::Ce_id i_ce ) const 89cdf0e10cSrcweir { 90cdf0e10cSrcweir return ces().Find_Module(i_ce); 91cdf0e10cSrcweir } 92cdf0e10cSrcweir 93cdf0e10cSrcweir 94cdf0e10cSrcweir const ary::idl::CodeEntity & 95cdf0e10cSrcweir AryAccess::Find_Ce( ary::idl::Ce_id i_ce ) const 96cdf0e10cSrcweir { 97cdf0e10cSrcweir return ces().Find_Ce(i_ce); 98cdf0e10cSrcweir } 99cdf0e10cSrcweir 100cdf0e10cSrcweir const ary::idl::Type & 101cdf0e10cSrcweir AryAccess::Find_Type( ary::idl::Type_id i_type ) const 102cdf0e10cSrcweir { 103cdf0e10cSrcweir return types().Find_Type(i_type); 104cdf0e10cSrcweir } 105cdf0e10cSrcweir 106cdf0e10cSrcweir ary::idl::Ce_id 107cdf0e10cSrcweir AryAccess::CeFromType( ary::idl::Type_id i_type ) const 108cdf0e10cSrcweir { 109cdf0e10cSrcweir return types().Search_CeRelatedTo(i_type); 110cdf0e10cSrcweir } 111cdf0e10cSrcweir 112cdf0e10cSrcweir bool 113cdf0e10cSrcweir AryAccess::IsBuiltInOrRelated( const ary::idl::Type & i_type ) const 114cdf0e10cSrcweir { 115cdf0e10cSrcweir return types().IsBuiltInOrRelated(i_type); 116cdf0e10cSrcweir } 117cdf0e10cSrcweir 118cdf0e10cSrcweir bool 119cdf0e10cSrcweir AryAccess::Search_Ce( StringVector & o_module, 120cdf0e10cSrcweir String & o_mainEntity, 121cdf0e10cSrcweir String & o_memberEntity, 122cdf0e10cSrcweir const char * i_sText, 123cdf0e10cSrcweir const ary::idl::Module & i_referingScope ) const 124cdf0e10cSrcweir { 125cdf0e10cSrcweir o_module.erase(o_module.begin(),o_module.end()); 126cdf0e10cSrcweir o_mainEntity = String::Null_(); 127cdf0e10cSrcweir o_memberEntity = String::Null_(); 128cdf0e10cSrcweir 129cdf0e10cSrcweir const ary::idl::Module * pModule = 0; 130cdf0e10cSrcweir 131cdf0e10cSrcweir if ( strncmp(i_sText, "::", 2) == 0 132cdf0e10cSrcweir OR strncmp(i_sText, "com::sun::star", 14) == 0 ) 133cdf0e10cSrcweir pModule = &GlobalNamespace(); 134cdf0e10cSrcweir else 135cdf0e10cSrcweir { 136cdf0e10cSrcweir pModule = &i_referingScope; 137cdf0e10cSrcweir ces().Get_Text(o_module, o_mainEntity, o_memberEntity, *pModule); 138cdf0e10cSrcweir } 139cdf0e10cSrcweir 140cdf0e10cSrcweir const char * pNext = i_sText; 141cdf0e10cSrcweir String sNextName; 142cdf0e10cSrcweir 143cdf0e10cSrcweir // Find Module: 144cdf0e10cSrcweir while ( nextName(pNext, sNextName) ) 145cdf0e10cSrcweir { 146cdf0e10cSrcweir const ary::idl::Module * 147cdf0e10cSrcweir pSub = find_SubModule(*pModule, sNextName); 148cdf0e10cSrcweir if (pSub != 0) 149cdf0e10cSrcweir { 150cdf0e10cSrcweir pModule = pSub; 151cdf0e10cSrcweir o_module.push_back(sNextName); 152cdf0e10cSrcweir } 153cdf0e10cSrcweir else 154cdf0e10cSrcweir break; 155cdf0e10cSrcweir } 156cdf0e10cSrcweir 157cdf0e10cSrcweir // Find main CodeEntity: 158cdf0e10cSrcweir if ( sNextName.length() == 0 ) 159cdf0e10cSrcweir return true; 160cdf0e10cSrcweir const ary::idl::Ce_id 161cdf0e10cSrcweir nCe = pModule->Search_Name(sNextName); 162cdf0e10cSrcweir if (NOT nCe.IsValid()) 163cdf0e10cSrcweir return false; 164cdf0e10cSrcweir o_mainEntity = sNextName; 165cdf0e10cSrcweir 166cdf0e10cSrcweir // Find member: 167cdf0e10cSrcweir if ( *pNext == 0 ) 168cdf0e10cSrcweir return true; 169cdf0e10cSrcweir nextName(pNext, o_memberEntity); 170cdf0e10cSrcweir if (strchr(o_memberEntity,':') != 0) 171cdf0e10cSrcweir return false; // This must not happen in IDL 172cdf0e10cSrcweir 173cdf0e10cSrcweir #if 0 174cdf0e10cSrcweir // The following code avoids false links, but is rather expensive 175cdf0e10cSrcweir // in runtime time consumation. 176cdf0e10cSrcweir 177cdf0e10cSrcweir const ary::idl::CodeEntity * 178cdf0e10cSrcweir pCe = Find_Ce(nCe); 179cdf0e10cSrcweir if (pCe == 0) 180cdf0e10cSrcweir return false; 181cdf0e10cSrcweir 182cdf0e10cSrcweir if ( NOT ary::idl::ifc_ce::attr::Search_Member(*pCe,o_memberEntity) ) 183cdf0e10cSrcweir return false; 184cdf0e10cSrcweir #endif 185cdf0e10cSrcweir 186cdf0e10cSrcweir return true; 187cdf0e10cSrcweir } 188cdf0e10cSrcweir 189cdf0e10cSrcweir bool 190cdf0e10cSrcweir AryAccess::Search_CesModule( StringVector & o_module, 191cdf0e10cSrcweir const String & i_scope, 192cdf0e10cSrcweir const String & i_ce, 193cdf0e10cSrcweir const ary::idl::Module & i_referingScope ) const 194cdf0e10cSrcweir { 195cdf0e10cSrcweir o_module.erase(o_module.begin(),o_module.end()); 196cdf0e10cSrcweir 197cdf0e10cSrcweir const ary::idl::Module * 198cdf0e10cSrcweir pModule = 0; 199cdf0e10cSrcweir 200cdf0e10cSrcweir if ( strncmp(i_scope, "::", 2) == 0 201cdf0e10cSrcweir OR strncmp(i_scope, "com::sun::star", 14) == 0 ) 202cdf0e10cSrcweir pModule = &GlobalNamespace(); 203cdf0e10cSrcweir else 204cdf0e10cSrcweir { 205cdf0e10cSrcweir pModule = &i_referingScope; 206cdf0e10cSrcweir static String Dummy1; 207cdf0e10cSrcweir static String Dummy2; 208cdf0e10cSrcweir ces().Get_Text(o_module, Dummy1, Dummy2, *pModule); 209cdf0e10cSrcweir } 210cdf0e10cSrcweir 211cdf0e10cSrcweir const char * pNext = i_scope; 212cdf0e10cSrcweir String sNextName; 213cdf0e10cSrcweir 214cdf0e10cSrcweir // Find Module: 215cdf0e10cSrcweir while ( nextName(pNext, sNextName) ) 216cdf0e10cSrcweir { 217cdf0e10cSrcweir const ary::idl::Module * 218cdf0e10cSrcweir pSub = find_SubModule(*pModule, sNextName); 219cdf0e10cSrcweir if (pSub != 0) 220cdf0e10cSrcweir { 221cdf0e10cSrcweir pModule = pSub; 222cdf0e10cSrcweir o_module.push_back(sNextName); 223cdf0e10cSrcweir } 224cdf0e10cSrcweir else 225cdf0e10cSrcweir return false; 226cdf0e10cSrcweir } // end while 227cdf0e10cSrcweir return pModule->Search_Name(i_ce).IsValid(); 228cdf0e10cSrcweir } 229cdf0e10cSrcweir 230cdf0e10cSrcweir const ary::idl::Module * 231cdf0e10cSrcweir AryAccess::Search_Module( const StringVector & i_nameChain ) const 232cdf0e10cSrcweir { 233cdf0e10cSrcweir const ary::idl::Module * ret = 234cdf0e10cSrcweir &GlobalNamespace(); 235cdf0e10cSrcweir for ( StringVector::const_iterator it = i_nameChain.begin(); 236cdf0e10cSrcweir it != i_nameChain.end(); 237cdf0e10cSrcweir ++it ) 238cdf0e10cSrcweir { 239cdf0e10cSrcweir ret = find_SubModule(*ret, *it); 240cdf0e10cSrcweir if (ret == 0) 241cdf0e10cSrcweir break; 242cdf0e10cSrcweir } // end for 243cdf0e10cSrcweir return ret; 244cdf0e10cSrcweir } 245cdf0e10cSrcweir 246cdf0e10cSrcweir void 247cdf0e10cSrcweir AryAccess::Get_CeText( StringVector & o_module, 248cdf0e10cSrcweir String & o_ce, 249cdf0e10cSrcweir String & o_member, 250cdf0e10cSrcweir const ary::idl::CodeEntity & i_ce ) const 251cdf0e10cSrcweir { 252cdf0e10cSrcweir ces().Get_Text(o_module, o_ce, o_member, i_ce); 253cdf0e10cSrcweir } 254cdf0e10cSrcweir 255cdf0e10cSrcweir void 256cdf0e10cSrcweir AryAccess::Get_TypeText( StringVector & o_module, 257cdf0e10cSrcweir String & o_sCe, 258cdf0e10cSrcweir ary::idl::Ce_id & o_nCe, 259cdf0e10cSrcweir int & o_sequenceCount, 260cdf0e10cSrcweir const ary::idl::Type & i_type ) const 261cdf0e10cSrcweir { 262cdf0e10cSrcweir i_type.Get_Text(o_module, o_sCe, o_nCe, o_sequenceCount, gate()); 263cdf0e10cSrcweir } 264cdf0e10cSrcweir 265cdf0e10cSrcweir void 266cdf0e10cSrcweir AryAccess::Get_IndexData( std::vector<ary::idl::Ce_id> & o_data, 267cdf0e10cSrcweir ary::idl::alphabetical_index::E_Letter i_letter ) const 268cdf0e10cSrcweir { 269cdf0e10cSrcweir rGate.Ces().Get_AlphabeticalIndex(o_data, i_letter); 270cdf0e10cSrcweir } 271cdf0e10cSrcweir 272cdf0e10cSrcweir 273cdf0e10cSrcweir const ary::idl::CePilot & 274cdf0e10cSrcweir AryAccess::Ces() const 275cdf0e10cSrcweir { 276cdf0e10cSrcweir return rGate.Ces(); 277cdf0e10cSrcweir } 278