1*0841af79SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*0841af79SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*0841af79SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*0841af79SAndrew Rist * distributed with this work for additional information 6*0841af79SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*0841af79SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*0841af79SAndrew Rist * "License"); you may not use this file except in compliance 9*0841af79SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*0841af79SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*0841af79SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*0841af79SAndrew Rist * software distributed under the License is distributed on an 15*0841af79SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*0841af79SAndrew Rist * KIND, either express or implied. See the License for the 17*0841af79SAndrew Rist * specific language governing permissions and limitations 18*0841af79SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*0841af79SAndrew Rist *************************************************************/ 21cdf0e10cSrcweir 22cdf0e10cSrcweir #include <precomp.h> 23cdf0e10cSrcweir #include "cre_link.hxx" 24cdf0e10cSrcweir 25cdf0e10cSrcweir 26cdf0e10cSrcweir // NOT FULLY DEFINED SERVICES 27cdf0e10cSrcweir #include <ary/cpp/c_class.hxx> 28cdf0e10cSrcweir #include <ary/cpp/c_define.hxx> 29cdf0e10cSrcweir #include <ary/cpp/c_enum.hxx> 30cdf0e10cSrcweir #include <ary/cpp/c_enuval.hxx> 31cdf0e10cSrcweir #include <ary/cpp/c_funct.hxx> 32cdf0e10cSrcweir #include <ary/cpp/c_gate.hxx> 33cdf0e10cSrcweir #include <ary/cpp/c_macro.hxx> 34cdf0e10cSrcweir #include <ary/cpp/c_namesp.hxx> 35cdf0e10cSrcweir #include <ary/cpp/c_tydef.hxx> 36cdf0e10cSrcweir #include <ary/cpp/c_vari.hxx> 37cdf0e10cSrcweir #include <ary/cpp/cp_ce.hxx> 38cdf0e10cSrcweir #include <ary/loc/loc_file.hxx> 39cdf0e10cSrcweir #include <ary/loc/locp_le.hxx> 40cdf0e10cSrcweir #include "hdimpl.hxx" 41cdf0e10cSrcweir #include "opageenv.hxx" 42cdf0e10cSrcweir #include "strconst.hxx" 43cdf0e10cSrcweir 44cdf0e10cSrcweir 45cdf0e10cSrcweir 46cdf0e10cSrcweir 47cdf0e10cSrcweir 48cdf0e10cSrcweir LinkCreator::LinkCreator( char * o_rOutput, 49cdf0e10cSrcweir uintt i_nOutputSize ) 50cdf0e10cSrcweir : pOut(o_rOutput), 51cdf0e10cSrcweir nOutMaxSize(i_nOutputSize), 52cdf0e10cSrcweir pEnv(0) 53cdf0e10cSrcweir { 54cdf0e10cSrcweir } 55cdf0e10cSrcweir 56cdf0e10cSrcweir LinkCreator::~LinkCreator() 57cdf0e10cSrcweir { 58cdf0e10cSrcweir } 59cdf0e10cSrcweir 60cdf0e10cSrcweir void 61cdf0e10cSrcweir LinkCreator::do_Process( const ary::cpp::Namespace & i_rData ) 62cdf0e10cSrcweir { 63cdf0e10cSrcweir Create_PrePath( i_rData ); 64cdf0e10cSrcweir strcat( pOut, "index.html" ); // KORR_FUTURE // SAFE STRCAT (#100211# - checked) 65cdf0e10cSrcweir } 66cdf0e10cSrcweir 67cdf0e10cSrcweir void 68cdf0e10cSrcweir LinkCreator::do_Process( const ary::cpp::Class & i_rData ) 69cdf0e10cSrcweir { 70cdf0e10cSrcweir Create_PrePath( i_rData ); 71cdf0e10cSrcweir strcat( pOut, ClassFileName(i_rData.LocalName().c_str()) ); // SAFE STRCAT (#100211# - checked) 72cdf0e10cSrcweir } 73cdf0e10cSrcweir 74cdf0e10cSrcweir void 75cdf0e10cSrcweir LinkCreator::do_Process( const ary::cpp::Enum & i_rData ) 76cdf0e10cSrcweir { 77cdf0e10cSrcweir Create_PrePath( i_rData ); 78cdf0e10cSrcweir strcat( pOut, EnumFileName(i_rData.LocalName().c_str()) ); // SAFE STRCAT (#100211# - checked) 79cdf0e10cSrcweir } 80cdf0e10cSrcweir 81cdf0e10cSrcweir void 82cdf0e10cSrcweir LinkCreator::do_Process( const ary::cpp::Typedef & i_rData ) 83cdf0e10cSrcweir { 84cdf0e10cSrcweir Create_PrePath( i_rData ); 85cdf0e10cSrcweir strcat( pOut, TypedefFileName(i_rData.LocalName().c_str()) ); // SAFE STRCAT (#100211# - checked) 86cdf0e10cSrcweir } 87cdf0e10cSrcweir 88cdf0e10cSrcweir void 89cdf0e10cSrcweir LinkCreator::do_Process( const ary::cpp::Function & i_rData ) 90cdf0e10cSrcweir { 91cdf0e10cSrcweir Create_PrePath( i_rData ); 92cdf0e10cSrcweir 93cdf0e10cSrcweir if ( i_rData.Protection() != ary::cpp::PROTECT_global ) 94cdf0e10cSrcweir { 95cdf0e10cSrcweir strcat( pOut, "o.html" ); // SAFE STRCAT (#100211# - checked) 96cdf0e10cSrcweir } 97cdf0e10cSrcweir else 98cdf0e10cSrcweir { 99cdf0e10cSrcweir csv_assert(i_rData.Location().IsValid()); 100cdf0e10cSrcweir const ary::loc::File & 101cdf0e10cSrcweir rFile = pEnv->Gate().Locations().Find_File(i_rData.Location()); 102cdf0e10cSrcweir strcat( pOut, HtmlFileName("o-", rFile.LocalName().c_str()) ); // SAFE STRCAT (#100211# - checked) 103cdf0e10cSrcweir } 104cdf0e10cSrcweir 105cdf0e10cSrcweir csv_assert(pEnv != 0); 106cdf0e10cSrcweir strcat( pOut, OperationLink(pEnv->Gate(), i_rData.LocalName(), i_rData.CeId()) ); // SAFE STRCAT (#100211# - checked) 107cdf0e10cSrcweir } 108cdf0e10cSrcweir 109cdf0e10cSrcweir void 110cdf0e10cSrcweir LinkCreator::do_Process( const ary::cpp::Variable & i_rData ) 111cdf0e10cSrcweir { 112cdf0e10cSrcweir Create_PrePath( i_rData ); 113cdf0e10cSrcweir 114cdf0e10cSrcweir if ( i_rData.Protection() != ary::cpp::PROTECT_global ) 115cdf0e10cSrcweir { 116cdf0e10cSrcweir strcat( pOut, "d.html" ); // SAFE STRCAT (#100211# - checked) 117cdf0e10cSrcweir } 118cdf0e10cSrcweir else 119cdf0e10cSrcweir { 120cdf0e10cSrcweir csv_assert(i_rData.Location().IsValid()); 121cdf0e10cSrcweir const ary::loc::File & 122cdf0e10cSrcweir rFile = pEnv->Gate().Locations().Find_File(i_rData.Location()); 123cdf0e10cSrcweir strcat( pOut, HtmlFileName("d-", rFile.LocalName().c_str()) ); // SAFE STRCAT (#100211# - checked) 124cdf0e10cSrcweir } 125cdf0e10cSrcweir 126cdf0e10cSrcweir strcat( pOut, DataLink(i_rData.LocalName()) ); // SAFE STRCAT (#100211# - checked) 127cdf0e10cSrcweir } 128cdf0e10cSrcweir 129cdf0e10cSrcweir void 130cdf0e10cSrcweir LinkCreator::do_Process( const ary::cpp::EnumValue & i_rData ) 131cdf0e10cSrcweir { 132cdf0e10cSrcweir const ary::cpp::CodeEntity * 133cdf0e10cSrcweir pEnum = pEnv->Gate().Ces().Search_Ce(i_rData.Owner()); 134cdf0e10cSrcweir if (pEnum == 0) 135cdf0e10cSrcweir return; 136cdf0e10cSrcweir 137cdf0e10cSrcweir pEnum->Accept(*this); 138cdf0e10cSrcweir strcat(pOut, "#"); // SAFE STRCAT (#100211# - checked) 139cdf0e10cSrcweir strcat(pOut, i_rData.LocalName().c_str()); // SAFE STRCAT (#100211# - checked) 140cdf0e10cSrcweir } 141cdf0e10cSrcweir 142cdf0e10cSrcweir void 143cdf0e10cSrcweir LinkCreator::do_Process( const ary::cpp::Define & i_rData ) 144cdf0e10cSrcweir { 145cdf0e10cSrcweir // KORR_FUTURE 146cdf0e10cSrcweir // Only valid from Index: 147cdf0e10cSrcweir 148cdf0e10cSrcweir *pOut = '\0'; 149cdf0e10cSrcweir strcat(pOut, "../def-all.html#"); // SAFE STRCAT (#100211# - checked) 150cdf0e10cSrcweir strcat(pOut, i_rData.LocalName().c_str()); // SAFE STRCAT (#100211# - checked) 151cdf0e10cSrcweir } 152cdf0e10cSrcweir 153cdf0e10cSrcweir void 154cdf0e10cSrcweir LinkCreator::do_Process( const ary::cpp::Macro & i_rData ) 155cdf0e10cSrcweir { 156cdf0e10cSrcweir // KORR_FUTURE 157cdf0e10cSrcweir // Only valid from Index: 158cdf0e10cSrcweir 159cdf0e10cSrcweir *pOut = '\0'; 160cdf0e10cSrcweir strcat(pOut, "../def-all.html#"); // SAFE STRCAT (#100211# - checked) 161cdf0e10cSrcweir strcat(pOut, i_rData.LocalName().c_str()); // SAFE STRCAT (#100211# - checked) 162cdf0e10cSrcweir } 163cdf0e10cSrcweir 164cdf0e10cSrcweir 165cdf0e10cSrcweir namespace 166cdf0e10cSrcweir { 167cdf0e10cSrcweir 168cdf0e10cSrcweir class NameScope_const_iterator 169cdf0e10cSrcweir { 170cdf0e10cSrcweir public: 171cdf0e10cSrcweir NameScope_const_iterator( 172cdf0e10cSrcweir ary::cpp::Ce_id i_nId, 173cdf0e10cSrcweir const ary::cpp::Gate & 174cdf0e10cSrcweir i_rGate ); 175cdf0e10cSrcweir 176cdf0e10cSrcweir operator bool() const { return pCe != 0; } 177cdf0e10cSrcweir const String & operator*() const; 178cdf0e10cSrcweir 179cdf0e10cSrcweir void go_up(); 180cdf0e10cSrcweir 181cdf0e10cSrcweir private: 182cdf0e10cSrcweir const ary::cpp::CodeEntity * 183cdf0e10cSrcweir pCe; 184cdf0e10cSrcweir const ary::cpp::Gate * 185cdf0e10cSrcweir pGate; 186cdf0e10cSrcweir }; 187cdf0e10cSrcweir 188cdf0e10cSrcweir 189cdf0e10cSrcweir NameScope_const_iterator::NameScope_const_iterator( 190cdf0e10cSrcweir ary::cpp::Ce_id i_nId, 191cdf0e10cSrcweir const ary::cpp::Gate & i_rGate ) 192cdf0e10cSrcweir : pCe(i_rGate.Ces().Search_Ce(i_nId)), 193cdf0e10cSrcweir pGate(&i_rGate) 194cdf0e10cSrcweir { 195cdf0e10cSrcweir } 196cdf0e10cSrcweir 197cdf0e10cSrcweir const String & 198cdf0e10cSrcweir NameScope_const_iterator::operator*() const 199cdf0e10cSrcweir { 200cdf0e10cSrcweir return pCe ? pCe->LocalName() 201cdf0e10cSrcweir : String::Null_(); 202cdf0e10cSrcweir } 203cdf0e10cSrcweir 204cdf0e10cSrcweir void 205cdf0e10cSrcweir NameScope_const_iterator::go_up() 206cdf0e10cSrcweir { 207cdf0e10cSrcweir if (pCe == 0) 208cdf0e10cSrcweir return; 209cdf0e10cSrcweir pCe = pGate->Ces().Search_Ce(pCe->Owner()); 210cdf0e10cSrcweir } 211cdf0e10cSrcweir 212cdf0e10cSrcweir 213cdf0e10cSrcweir void Recursive_CreatePath( 214cdf0e10cSrcweir char * o_pOut, 215cdf0e10cSrcweir const NameScope_const_iterator & 216cdf0e10cSrcweir i_it ); 217cdf0e10cSrcweir 218cdf0e10cSrcweir void 219cdf0e10cSrcweir Recursive_CreatePath( char * o_pOut, 220cdf0e10cSrcweir const NameScope_const_iterator & i_it ) 221cdf0e10cSrcweir { 222cdf0e10cSrcweir if (NOT i_it) 223cdf0e10cSrcweir return; 224cdf0e10cSrcweir 225cdf0e10cSrcweir NameScope_const_iterator it( i_it ); 226cdf0e10cSrcweir it.go_up(); 227cdf0e10cSrcweir if (NOT it) 228cdf0e10cSrcweir return; // Global Namespace 229cdf0e10cSrcweir Recursive_CreatePath( o_pOut, it ); 230cdf0e10cSrcweir 231cdf0e10cSrcweir strcat( o_pOut, (*i_it).c_str() ); // SAFE STRCAT (#100211# - checked) 232cdf0e10cSrcweir strcat( o_pOut, "/" ); // SAFE STRCAT (#100211# - checked) 233cdf0e10cSrcweir } 234cdf0e10cSrcweir 235cdf0e10cSrcweir 236cdf0e10cSrcweir } // anonymous namespace 237cdf0e10cSrcweir 238cdf0e10cSrcweir 239cdf0e10cSrcweir 240cdf0e10cSrcweir 241cdf0e10cSrcweir 242cdf0e10cSrcweir void 243cdf0e10cSrcweir LinkCreator::Create_PrePath( const ary::cpp::CodeEntity & i_rData ) 244cdf0e10cSrcweir { 245cdf0e10cSrcweir *pOut = NULCH; 246cdf0e10cSrcweir 247cdf0e10cSrcweir if ( pEnv->CurNamespace() != 0 ) 248cdf0e10cSrcweir { 249cdf0e10cSrcweir if ( pEnv->CurClass() 250cdf0e10cSrcweir ? pEnv->CurClass()->CeId() == i_rData.Owner() 251cdf0e10cSrcweir : pEnv->CurNamespace()->CeId() == i_rData.Owner() ) 252cdf0e10cSrcweir return; 253cdf0e10cSrcweir 254cdf0e10cSrcweir strcat( pOut, PathUp(pEnv->Depth() - 1) ); // SAFE STRCAT (#100211# - checked) 255cdf0e10cSrcweir } 256cdf0e10cSrcweir else 257cdf0e10cSrcweir { // Within Index 258cdf0e10cSrcweir strcat( pOut, "../names/" ); // SAFE STRCAT (#100211# - checked) 259cdf0e10cSrcweir } 260cdf0e10cSrcweir 261cdf0e10cSrcweir NameScope_const_iterator it( i_rData.Owner(), pEnv->Gate() ); 262cdf0e10cSrcweir Recursive_CreatePath( pOut, it ); 263cdf0e10cSrcweir } 264