1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 #include <precomp.h> 23 #include "dsply_op.hxx" 24 25 26 // NOT FULLY DEFINED SERVICES 27 #include <cosv/tpl/tpltools.hxx> 28 #include <ary/cpp/c_funct.hxx> 29 #include <ary/cpp/c_gate.hxx> 30 #include <ary/loc/locp_le.hxx> 31 #include <udm/html/htmlitem.hxx> 32 #include "hd_docu.hxx" 33 #include "hdimpl.hxx" 34 #include "html_kit.hxx" 35 #include "opageenv.hxx" 36 #include "pagemake.hxx" 37 38 using namespace csi; 39 using namespace adcdisp; 40 41 42 43 44 OperationsDisplay::OperationsDisplay( OuputPage_Environment & io_rEnv ) 45 : // aMap_GlobalFunctionsDisplay, 46 // pClassMembersDisplay, 47 pEnv( &io_rEnv ), 48 pDocuShow( new Docu_Display(io_rEnv) ) 49 { 50 } 51 52 OperationsDisplay::~OperationsDisplay() 53 { 54 csv::erase_map_of_heap_ptrs( aMap_GlobalFunctionsDisplay ); 55 } 56 57 void 58 OperationsDisplay::PrepareForStdMembers() 59 { 60 csv::erase_map_of_heap_ptrs( aMap_GlobalFunctionsDisplay ); 61 62 pClassMembersDisplay = new PageDisplay(*pEnv); 63 const ary::cpp::Class * pClass = pEnv->CurClass(); 64 csv_assert( pClass != 0 ); 65 pClassMembersDisplay->Setup_OperationsFile_for(*pClass); 66 } 67 68 void 69 OperationsDisplay::PrepareForStaticMembers() 70 { 71 // Doesn't need to do anything yet. 72 } 73 74 void 75 OperationsDisplay::Create_Files() 76 { 77 if (pClassMembersDisplay) 78 pClassMembersDisplay->Create_File(); 79 else 80 { 81 for ( Map_FileId2PagePtr::const_iterator it = aMap_GlobalFunctionsDisplay.begin(); 82 it != aMap_GlobalFunctionsDisplay.end(); 83 ++it ) 84 { 85 (*it).second->Create_File(); 86 } 87 } 88 } 89 90 void 91 OperationsDisplay::do_Process( const ary::cpp::Function & i_rData ) 92 { 93 if ( Ce_IsInternal(i_rData) ) 94 return; 95 96 PageDisplay & rPage = FindPage_for( i_rData ); 97 98 csi::xml::Element & rOut = rPage.CurOut(); 99 Display_SglOperation( rOut, i_rData ); 100 } 101 102 const ary::cpp::Gate * 103 OperationsDisplay::inq_Get_ReFinder() const 104 { 105 return & pEnv->Gate(); 106 } 107 108 PageDisplay & 109 OperationsDisplay::FindPage_for( const ary::cpp::Function & i_rData ) 110 { 111 if ( pClassMembersDisplay ) 112 return *pClassMembersDisplay; 113 114 SourceFileId 115 nSourceFile = i_rData.Location(); 116 PageDisplay * 117 pFound = csv::value_from_map( aMap_GlobalFunctionsDisplay, nSourceFile, (PageDisplay*)0 ); 118 if ( pFound == 0 ) 119 { 120 pFound = new PageDisplay( *pEnv ); 121 const ary::loc::File & 122 rFile = pEnv->Gate().Locations().Find_File( nSourceFile ); 123 pFound->Setup_OperationsFile_for(rFile); 124 aMap_GlobalFunctionsDisplay[nSourceFile] = pFound; 125 } 126 127 return *pFound; 128 } 129 130 void 131 OperationsDisplay::Display_SglOperation( csi::xml::Element & rOut, 132 const ary::cpp::Function & i_rData ) 133 { 134 adcdisp::ExplanationList aDocu(rOut, true); 135 aDocu.AddEntry( 0 ); 136 137 138 adcdisp::OperationTitle fTitle; 139 fTitle( aDocu.Term(), 140 i_rData.LocalName(), 141 i_rData.CeId(), 142 pEnv->Gate() ); 143 144 // Syntax 145 adcdisp::ExplanationList aSyntaxHeader(aDocu.Def()); 146 aSyntaxHeader.AddEntry( 0, "simple" ); 147 csi::xml::Element & rHeader = aSyntaxHeader.Term(); 148 149 adcdisp::ParameterTable 150 aParams( aSyntaxHeader.Def() ); 151 152 if (i_rData.TemplateParameters().size() > 0) 153 { 154 TemplateClause fTemplateClause; 155 fTemplateClause( rHeader, i_rData.TemplateParameters() ); 156 rHeader << new html::LineBreak; 157 } 158 if ( i_rData.Flags().IsExternC() ) 159 { 160 rHeader 161 << "extern \"C\"" 162 << new html::LineBreak; 163 } 164 165 bool bConst = false; 166 bool bVolatile = false; 167 WriteOut_LinkedFunctionText( rHeader, aParams, i_rData, *pEnv, 168 &bConst, &bVolatile ); 169 aDocu.Def() << new html::LineBreak; 170 171 // Flags 172 aDocu.AddEntry_NoTerm(); 173 adcdisp::FlagTable 174 aFlags( aDocu.Def(), 8 ); 175 176 const ary::cpp::FunctionFlags & 177 rFFlags = i_rData.Flags(); 178 aFlags.SetColumn( 0, "virtual", 179 i_rData.Virtuality() != ary::cpp::VIRTUAL_none ); 180 aFlags.SetColumn( 1, "abstract", 181 i_rData.Virtuality() == ary::cpp::VIRTUAL_abstract ); 182 aFlags.SetColumn( 2, "const", bConst ); 183 aFlags.SetColumn( 3, "volatile", bVolatile ); 184 aFlags.SetColumn( 4, "template", 185 i_rData.TemplateParameters().size() > 0 ); 186 aFlags.SetColumn( 5, "static", 187 rFFlags.IsStaticLocal() OR rFFlags.IsStaticMember() ); 188 aFlags.SetColumn( 6, "inline", 189 rFFlags.IsInline() ); 190 aFlags.SetColumn( 7, "C-linkage", 191 rFFlags.IsExternC() ); 192 aDocu.Def() << new html::LineBreak; 193 194 // Docu 195 aDocu.AddEntry_NoTerm(); 196 pDocuShow->Assign_Out(aDocu.Def()); 197 pDocuShow->Process(i_rData.Docu()); 198 pDocuShow->Unassign_Out(); 199 200 rOut << new html::HorizontalLine; 201 } 202