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
10*d291ea28SAndrew Rist *
11*d291ea28SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*d291ea28SAndrew Rist *
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.
19*d291ea28SAndrew Rist *
20*d291ea28SAndrew Rist *************************************************************/
21cdf0e10cSrcweir
22cdf0e10cSrcweir #include <precomp.h>
23cdf0e10cSrcweir #include <idl/hi_display.hxx>
24cdf0e10cSrcweir
25cdf0e10cSrcweir
26cdf0e10cSrcweir // NOT FULLY DEFINED SERVICES
27cdf0e10cSrcweir #include <cosv/file.hxx>
28cdf0e10cSrcweir #include <ary/idl/i_ce.hxx>
29cdf0e10cSrcweir #include <ary/idl/i_module.hxx>
30cdf0e10cSrcweir #include <ary/getncast.hxx>
31cdf0e10cSrcweir #include <toolkit/out_tree.hxx>
32cdf0e10cSrcweir #include <cfrstd.hxx>
33cdf0e10cSrcweir #include "hi_ary.hxx"
34cdf0e10cSrcweir #include "hi_env.hxx"
35cdf0e10cSrcweir #include "hi_main.hxx"
36cdf0e10cSrcweir
37cdf0e10cSrcweir
38cdf0e10cSrcweir extern const String C_sCssFilename_Idl;
39cdf0e10cSrcweir
40cdf0e10cSrcweir
41cdf0e10cSrcweir inline bool
IsModule(const ary::idl::CodeEntity & i_ce) const42cdf0e10cSrcweir HtmlDisplay_Idl::IsModule( const ary::idl::CodeEntity & i_ce ) const
43cdf0e10cSrcweir {
44cdf0e10cSrcweir return ary::is_type<ary::idl::Module>(i_ce);
45cdf0e10cSrcweir }
46cdf0e10cSrcweir
47cdf0e10cSrcweir inline const ary::idl::Module &
Module_Cast(const ary::idl::CodeEntity & i_ce) const48cdf0e10cSrcweir HtmlDisplay_Idl::Module_Cast( const ary::idl::CodeEntity & i_ce ) const
49cdf0e10cSrcweir {
50cdf0e10cSrcweir return ary::ary_cast<ary::idl::Module>(i_ce);
51cdf0e10cSrcweir }
52cdf0e10cSrcweir
53cdf0e10cSrcweir
54cdf0e10cSrcweir
55cdf0e10cSrcweir
HtmlDisplay_Idl()56cdf0e10cSrcweir HtmlDisplay_Idl::HtmlDisplay_Idl()
57cdf0e10cSrcweir : pCurPageEnv(),
58cdf0e10cSrcweir pMainDisplay()
59cdf0e10cSrcweir {
60cdf0e10cSrcweir }
61cdf0e10cSrcweir
~HtmlDisplay_Idl()62cdf0e10cSrcweir HtmlDisplay_Idl::~HtmlDisplay_Idl()
63cdf0e10cSrcweir {
64cdf0e10cSrcweir }
65cdf0e10cSrcweir
66cdf0e10cSrcweir void
do_Run(const char * i_sOutputDirectory,const ary::idl::Gate & i_rAryGate,const display::CorporateFrame & i_rLayout)67cdf0e10cSrcweir HtmlDisplay_Idl::do_Run( const char * i_sOutputDirectory,
68cdf0e10cSrcweir const ary::idl::Gate & i_rAryGate,
69cdf0e10cSrcweir const display::CorporateFrame & i_rLayout )
70cdf0e10cSrcweir {
71cdf0e10cSrcweir SetRunData( i_sOutputDirectory, i_rAryGate, i_rLayout );
72cdf0e10cSrcweir
73cdf0e10cSrcweir Create_StartFile();
74cdf0e10cSrcweir Create_CssFile();
75cdf0e10cSrcweir Create_FilesInNameTree();
76cdf0e10cSrcweir Create_IndexFiles();
77cdf0e10cSrcweir Create_FilesInProjectTree();
78cdf0e10cSrcweir Create_PackageList();
79cdf0e10cSrcweir Create_HelpFile();
80cdf0e10cSrcweir }
81cdf0e10cSrcweir
82cdf0e10cSrcweir void
SetRunData(const char * i_sOutputDirectory,const ary::idl::Gate & i_rAryGate,const display::CorporateFrame & i_rLayout)83cdf0e10cSrcweir HtmlDisplay_Idl::SetRunData( const char * i_sOutputDirectory,
84cdf0e10cSrcweir const ary::idl::Gate & i_rAryGate,
85cdf0e10cSrcweir const display::CorporateFrame & i_rLayout )
86cdf0e10cSrcweir {
87cdf0e10cSrcweir csv::ploc::Path aOutputDir( i_sOutputDirectory, true );
88cdf0e10cSrcweir pCurPageEnv = new HtmlEnvironment_Idl( aOutputDir, i_rAryGate, i_rLayout );
89cdf0e10cSrcweir pMainDisplay = new MainDisplay_Idl(*pCurPageEnv);
90cdf0e10cSrcweir }
91cdf0e10cSrcweir
92cdf0e10cSrcweir void
Create_StartFile()93cdf0e10cSrcweir HtmlDisplay_Idl::Create_StartFile()
94cdf0e10cSrcweir {
95cdf0e10cSrcweir }
96cdf0e10cSrcweir
97cdf0e10cSrcweir void
Create_FilesInNameTree()98cdf0e10cSrcweir HtmlDisplay_Idl::Create_FilesInNameTree()
99cdf0e10cSrcweir {
100cdf0e10cSrcweir Cout() << "\nCreate files in subtree namespaces ..." << Endl();
101cdf0e10cSrcweir
102cdf0e10cSrcweir const ary::idl::Module &
103cdf0e10cSrcweir rGlobalNamespace = pCurPageEnv->Data().GlobalNamespace();
104cdf0e10cSrcweir pCurPageEnv->Goto_Directory( pCurPageEnv->OutputTree().NamesRoot(), true );
105cdf0e10cSrcweir
106cdf0e10cSrcweir RecursiveDisplay_Module(rGlobalNamespace);
107cdf0e10cSrcweir
108cdf0e10cSrcweir Cout() << "... done." << Endl();
109cdf0e10cSrcweir }
110cdf0e10cSrcweir
111cdf0e10cSrcweir void
Create_IndexFiles()112cdf0e10cSrcweir HtmlDisplay_Idl::Create_IndexFiles()
113cdf0e10cSrcweir {
114cdf0e10cSrcweir Cout() << "\nCreate files in subtree index ..." << Endl();
115cdf0e10cSrcweir pCurPageEnv->Goto_Directory( pCurPageEnv->OutputTree().IndexRoot(), true );
116cdf0e10cSrcweir pMainDisplay->WriteGlobalIndices();
117cdf0e10cSrcweir Cout() << "... done.\n" << Endl();
118cdf0e10cSrcweir }
119cdf0e10cSrcweir
120cdf0e10cSrcweir typedef ary::Dyn_StdConstIterator<ary::idl::Ce_id> Dyn_CeIterator;
121cdf0e10cSrcweir typedef ary::StdConstIterator<ary::idl::Ce_id> CeIterator;
122cdf0e10cSrcweir
123cdf0e10cSrcweir void
RecursiveDisplay_Module(const ary::idl::Module & i_module)124cdf0e10cSrcweir HtmlDisplay_Idl::RecursiveDisplay_Module( const ary::idl::Module & i_module )
125cdf0e10cSrcweir {
126cdf0e10cSrcweir i_module.Accept(*pMainDisplay);
127cdf0e10cSrcweir
128cdf0e10cSrcweir Dyn_CeIterator
129cdf0e10cSrcweir aMembers;
130cdf0e10cSrcweir i_module.Get_Names(aMembers);
131cdf0e10cSrcweir
132cdf0e10cSrcweir for ( CeIterator & iter = *aMembers;
133cdf0e10cSrcweir iter;
134cdf0e10cSrcweir ++iter )
135cdf0e10cSrcweir {
136cdf0e10cSrcweir const ary::idl::CodeEntity &
137cdf0e10cSrcweir rCe = pCurPageEnv->Data().Find_Ce(*iter);
138cdf0e10cSrcweir
139cdf0e10cSrcweir if ( NOT IsModule(rCe) )
140cdf0e10cSrcweir rCe.Accept(*pMainDisplay);
141cdf0e10cSrcweir else
142cdf0e10cSrcweir {
143cdf0e10cSrcweir pCurPageEnv->Goto_DirectoryLevelDown( rCe.LocalName(), true );
144cdf0e10cSrcweir RecursiveDisplay_Module( Module_Cast(rCe) );
145cdf0e10cSrcweir pCurPageEnv->Goto_DirectoryLevelUp();
146cdf0e10cSrcweir }
147cdf0e10cSrcweir } // end for
148cdf0e10cSrcweir }
149cdf0e10cSrcweir
150cdf0e10cSrcweir void
Create_FilesInProjectTree()151cdf0e10cSrcweir HtmlDisplay_Idl::Create_FilesInProjectTree()
152cdf0e10cSrcweir {
153cdf0e10cSrcweir }
154cdf0e10cSrcweir
155cdf0e10cSrcweir void
Create_PackageList()156cdf0e10cSrcweir HtmlDisplay_Idl::Create_PackageList()
157cdf0e10cSrcweir {
158cdf0e10cSrcweir #if 0
159cdf0e10cSrcweir Cout() << "\nCreate package list ..." << std::flush;
160cdf0e10cSrcweir
161cdf0e10cSrcweir pCurPageEnv->CurPosition() = pCurPageEnv->OutputTree().Root();
162cdf0e10cSrcweir
163cdf0e10cSrcweir // KORR
164cdf0e10cSrcweir // ...
165cdf0e10cSrcweir
166cdf0e10cSrcweir Cout() << " done." << Endl();
167cdf0e10cSrcweir #endif // 0
168cdf0e10cSrcweir }
169cdf0e10cSrcweir
170cdf0e10cSrcweir void
Create_HelpFile()171cdf0e10cSrcweir HtmlDisplay_Idl::Create_HelpFile()
172cdf0e10cSrcweir {
173cdf0e10cSrcweir }
174cdf0e10cSrcweir
175cdf0e10cSrcweir void
Create_CssFile()176cdf0e10cSrcweir HtmlDisplay_Idl::Create_CssFile()
177cdf0e10cSrcweir {
178cdf0e10cSrcweir Cout() << "\nCreate css file ..." << Endl();
179cdf0e10cSrcweir
180cdf0e10cSrcweir pCurPageEnv->Goto_Directory( pCurPageEnv->OutputTree().Root(), true );
181cdf0e10cSrcweir pCurPageEnv->Set_CurFile( C_sCssFilename_Idl );
182cdf0e10cSrcweir
183cdf0e10cSrcweir StreamLock
184cdf0e10cSrcweir slCurFilePath(700);
185cdf0e10cSrcweir pCurPageEnv->Get_CurFilePath(slCurFilePath());
186cdf0e10cSrcweir
187cdf0e10cSrcweir csv::File
188cdf0e10cSrcweir aCssFile(slCurFilePath().c_str(), csv::CFM_CREATE);
189cdf0e10cSrcweir csv::OpenCloseGuard
190cdf0e10cSrcweir aOpenGuard(aCssFile);
191cdf0e10cSrcweir if (NOT aOpenGuard)
192cdf0e10cSrcweir {
193cdf0e10cSrcweir Cerr() << "Can't create file " << slCurFilePath().c_str() << "." << Endl();
194cdf0e10cSrcweir return;
195cdf0e10cSrcweir }
196cdf0e10cSrcweir
197cdf0e10cSrcweir aCssFile.write("/* Autodoc css file for IDL documentation */\n\n\n");
198cdf0e10cSrcweir aCssFile.write(pCurPageEnv->Layout().CssStyle());
199cdf0e10cSrcweir aCssFile.write("\n\n\n");
200cdf0e10cSrcweir aCssFile.write(pCurPageEnv->Layout().CssStylesExplanation());
201cdf0e10cSrcweir }
202