1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #include <precomp.h> 29*cdf0e10cSrcweir #include "aryattrs.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir // NOT FULLY DEFINED SERVICES 33*cdf0e10cSrcweir #include <ary/getncast.hxx> 34*cdf0e10cSrcweir #include <ary/cpp/c_class.hxx> 35*cdf0e10cSrcweir #include <ary/cpp/c_enum.hxx> 36*cdf0e10cSrcweir #include <ary/cpp/c_funct.hxx> 37*cdf0e10cSrcweir #include <ary/cpp/c_gate.hxx> 38*cdf0e10cSrcweir #include <ary/cpp/c_namesp.hxx> 39*cdf0e10cSrcweir #include <ary/cpp/cp_ce.hxx> 40*cdf0e10cSrcweir #include <ary/cpp/cp_type.hxx> 41*cdf0e10cSrcweir #include "strconst.hxx" 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir //******************** HtmlDisplay_Impl *********************// 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir const char * 49*cdf0e10cSrcweir Get_ClassTypeKey( const ary::cpp::Class & i_rClass ) 50*cdf0e10cSrcweir { 51*cdf0e10cSrcweir return i_rClass.ClassKey() == ary::cpp::CK_class 52*cdf0e10cSrcweir ? C_sHFTypeTitle_Class 53*cdf0e10cSrcweir : i_rClass.ClassKey() == ary::cpp::CK_struct 54*cdf0e10cSrcweir ? C_sHFTypeTitle_Struct 55*cdf0e10cSrcweir : C_sHFTypeTitle_Union; 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir } 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir const char * 60*cdf0e10cSrcweir Get_TypeKey( const ary::cpp::CodeEntity & i_rCe ) 61*cdf0e10cSrcweir { 62*cdf0e10cSrcweir if ( ary::is_type<ary::cpp::Class>(i_rCe) ) 63*cdf0e10cSrcweir { 64*cdf0e10cSrcweir return Get_ClassTypeKey( 65*cdf0e10cSrcweir ary::ary_cast<ary::cpp::Class>(i_rCe) ); 66*cdf0e10cSrcweir } 67*cdf0e10cSrcweir if ( ary::is_type<ary::cpp::Enum>(i_rCe) ) 68*cdf0e10cSrcweir { 69*cdf0e10cSrcweir return "enum"; 70*cdf0e10cSrcweir } 71*cdf0e10cSrcweir return ""; 72*cdf0e10cSrcweir } 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir bool 75*cdf0e10cSrcweir Ce_IsInternal( const ary::cpp::CodeEntity & i_rCe ) 76*cdf0e10cSrcweir { 77*cdf0e10cSrcweir return NOT i_rCe.IsVisible(); 78*cdf0e10cSrcweir } 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir const char * 81*cdf0e10cSrcweir SyntaxText_PreName( const ary::cpp::Function & i_rFunction, 82*cdf0e10cSrcweir const ary::cpp::Gate & i_rAryGate ) 83*cdf0e10cSrcweir { 84*cdf0e10cSrcweir static StreamStr sResult( 150 ); 85*cdf0e10cSrcweir sResult.seekp(0); 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir // write pre-name: 88*cdf0e10cSrcweir const ary::cpp::FunctionFlags & rFlags = i_rFunction.Flags(); 89*cdf0e10cSrcweir if ( rFlags.IsStaticLocal() OR rFlags.IsStaticMember() ) 90*cdf0e10cSrcweir sResult << "static "; 91*cdf0e10cSrcweir if ( rFlags.IsExplicit() ) 92*cdf0e10cSrcweir sResult << "explicit "; 93*cdf0e10cSrcweir if ( rFlags.IsMutable() ) 94*cdf0e10cSrcweir sResult << "mutable "; 95*cdf0e10cSrcweir if ( i_rFunction.Virtuality() != ary::cpp::VIRTUAL_none ) 96*cdf0e10cSrcweir sResult << "virtual "; 97*cdf0e10cSrcweir i_rAryGate.Types().Get_TypeText( sResult, i_rFunction.ReturnType() ); 98*cdf0e10cSrcweir sResult << " "; 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir return sResult.c_str(); 101*cdf0e10cSrcweir } 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir const char * 104*cdf0e10cSrcweir SyntaxText_PostName( const ary::cpp::Function & i_rFunction, 105*cdf0e10cSrcweir const ary::cpp::Gate & i_rAryGate ) 106*cdf0e10cSrcweir { 107*cdf0e10cSrcweir static StreamStr sResult( 850 ); 108*cdf0e10cSrcweir sResult.seekp(0); 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir // parameters and con_vol 111*cdf0e10cSrcweir i_rAryGate.Ces().Get_SignatureText( sResult, i_rFunction.Signature(), &i_rFunction.ParamInfos() ); 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir // write Exceptions: 114*cdf0e10cSrcweir const std::vector< ary::cpp::Type_id > * 115*cdf0e10cSrcweir pThrow = i_rFunction.Exceptions(); 116*cdf0e10cSrcweir if ( pThrow) 117*cdf0e10cSrcweir { 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir std::vector< ary::cpp::Type_id >::const_iterator 120*cdf0e10cSrcweir it = pThrow->begin(); 121*cdf0e10cSrcweir std::vector< ary::cpp::Type_id >::const_iterator 122*cdf0e10cSrcweir it_end = pThrow->end(); 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir if (it != it_end) 125*cdf0e10cSrcweir { 126*cdf0e10cSrcweir sResult << " throw( "; 127*cdf0e10cSrcweir i_rAryGate.Types().Get_TypeText(sResult, *it); 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir for ( ++it; it != it_end; ++it ) 130*cdf0e10cSrcweir { 131*cdf0e10cSrcweir sResult << ", "; 132*cdf0e10cSrcweir i_rAryGate.Types().Get_TypeText(sResult, *it); 133*cdf0e10cSrcweir } 134*cdf0e10cSrcweir sResult << " )"; 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir else 137*cdf0e10cSrcweir { 138*cdf0e10cSrcweir sResult << " throw( )"; 139*cdf0e10cSrcweir } 140*cdf0e10cSrcweir } // endif // pThrow 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir // abstractness: 143*cdf0e10cSrcweir if ( i_rFunction.Virtuality() == ary::cpp::VIRTUAL_abstract ) 144*cdf0e10cSrcweir sResult << " = 0"; 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir // finish: 147*cdf0e10cSrcweir sResult << ";"; 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir return sResult.c_str(); 150*cdf0e10cSrcweir } 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir bool 153*cdf0e10cSrcweir Get_TypeText( const char * & o_rPreName, 154*cdf0e10cSrcweir const char * & o_rName, 155*cdf0e10cSrcweir const char * & o_rPostName, 156*cdf0e10cSrcweir ary::cpp::Type_id i_nTypeid, 157*cdf0e10cSrcweir const ary::cpp::Gate & i_rAryGate ) 158*cdf0e10cSrcweir { 159*cdf0e10cSrcweir static StreamStr sResult_PreName(250); 160*cdf0e10cSrcweir static StreamStr sResult_Name(250); 161*cdf0e10cSrcweir static StreamStr sResult_PostName(250); 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir sResult_PreName.seekp(0); 164*cdf0e10cSrcweir sResult_Name.seekp(0); 165*cdf0e10cSrcweir sResult_PostName.seekp(0); 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir bool ret = i_rAryGate.Types().Get_TypeText( 168*cdf0e10cSrcweir sResult_PreName, 169*cdf0e10cSrcweir sResult_Name, 170*cdf0e10cSrcweir sResult_PostName, 171*cdf0e10cSrcweir i_nTypeid ); 172*cdf0e10cSrcweir if ( sResult_PreName.tellp() > 0 ) 173*cdf0e10cSrcweir { 174*cdf0e10cSrcweir char cLast = *( sResult_PreName.c_str() + (sResult_PreName.tellp() - 1) ); 175*cdf0e10cSrcweir if (cLast != ':' AND cLast != ' ') 176*cdf0e10cSrcweir sResult_PreName << " "; 177*cdf0e10cSrcweir } 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir if (ret) 181*cdf0e10cSrcweir { 182*cdf0e10cSrcweir o_rPreName = sResult_PreName.c_str(); 183*cdf0e10cSrcweir o_rName = sResult_Name.c_str(); 184*cdf0e10cSrcweir o_rPostName = sResult_PostName.c_str(); 185*cdf0e10cSrcweir } 186*cdf0e10cSrcweir else 187*cdf0e10cSrcweir { 188*cdf0e10cSrcweir o_rPreName = o_rName = o_rPostName = ""; 189*cdf0e10cSrcweir } 190*cdf0e10cSrcweir return ret; 191*cdf0e10cSrcweir } 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir //********************* FunctionParam_Iterator *****************// 197*cdf0e10cSrcweir 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir FunctionParam_Iterator::FunctionParam_Iterator() 200*cdf0e10cSrcweir : // itTypes 201*cdf0e10cSrcweir // itTypes_end 202*cdf0e10cSrcweir // itNames_andMore 203*cdf0e10cSrcweir // itNames_andMore_end 204*cdf0e10cSrcweir eConVol(ary::cpp::CONVOL_none) 205*cdf0e10cSrcweir { 206*cdf0e10cSrcweir static std::vector<ary::cpp::Type_id> aTypesNull_; 207*cdf0e10cSrcweir static StringVector aNamesNull_; 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir itTypes = itTypes_end = aTypesNull_.end(); 210*cdf0e10cSrcweir itNames_andMore = itNames_andMore_end = aNamesNull_.end(); 211*cdf0e10cSrcweir } 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir FunctionParam_Iterator::~FunctionParam_Iterator() 214*cdf0e10cSrcweir { 215*cdf0e10cSrcweir } 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir FunctionParam_Iterator & 218*cdf0e10cSrcweir FunctionParam_Iterator::operator++() 219*cdf0e10cSrcweir { 220*cdf0e10cSrcweir if ( IsValid() ) 221*cdf0e10cSrcweir { 222*cdf0e10cSrcweir ++itTypes; 223*cdf0e10cSrcweir ++itNames_andMore; 224*cdf0e10cSrcweir } 225*cdf0e10cSrcweir return *this; 226*cdf0e10cSrcweir } 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir void 229*cdf0e10cSrcweir FunctionParam_Iterator::Assign( const ary::cpp::Function & i_rFunction ) 230*cdf0e10cSrcweir { 231*cdf0e10cSrcweir const ary::cpp::OperationSignature & 232*cdf0e10cSrcweir rSigna = i_rFunction.Signature(); 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir const std::vector<ary::cpp::Type_id> & 235*cdf0e10cSrcweir rTypes = rSigna.Parameters(); 236*cdf0e10cSrcweir const StringVector & 237*cdf0e10cSrcweir rNames = i_rFunction.ParamInfos(); 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir if ( rTypes.size() != rNames.size() OR rTypes.size() == 0 ) 240*cdf0e10cSrcweir return; 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir itTypes = rTypes.begin(); 243*cdf0e10cSrcweir itTypes_end = rTypes.end(); 244*cdf0e10cSrcweir itNames_andMore = rNames.begin(); 245*cdf0e10cSrcweir itNames_andMore_end = rNames.end(); 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir eConVol = rSigna.ConVol(); 248*cdf0e10cSrcweir } 249