Bump for 3.6-28
[LibreOffice.git] / autodoc / source / parser_i / idl / unoidl.cxx
blob204e6c6c4249e7794bb5e239145c9bd08b38098a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include <precomp.h>
30 #include <parser/unoidl.hxx>
33 // NOT FULLY DECLARED SERVICES
34 #include <stdlib.h>
35 #include <cosv/file.hxx>
36 #include <ary/ary.hxx>
37 #include <ary/idl/i_gate.hxx>
38 #include <ary/doc/d_oldidldocu.hxx>
39 #include <../parser/inc/x_docu.hxx>
40 #include <parser/parserinfo.hxx>
41 #include <tools/filecoll.hxx>
42 #include <tools/tkpchars.hxx>
43 #include <s2_luidl/tkp_uidl.hxx>
44 #include <s2_luidl/distrib.hxx>
45 #include <s2_luidl/pe_file2.hxx>
46 #include <s2_dsapi/cx_dsapi.hxx>
47 #include <adc_msg.hxx>
48 #include <x_parse2.hxx>
52 namespace autodoc
56 class FileParsePerformers
58 public:
59 FileParsePerformers(
60 ary::Repository &
61 io_rRepository,
62 ParserInfo & io_rParserInfo );
64 void ParseFile(
65 const char * i_sFullPath );
67 private:
68 CharacterSource aFileLoader;
69 Dyn<csi::uidl::TokenParser_Uidl>
70 pTokens;
71 csi::uidl::TokenDistributor
72 aDistributor;
73 Dyn<csi::uidl::PE_File>
74 pFileParseEnvironment;
75 ary::Repository &
76 rRepository;
77 ParserInfo & rParserInfo;
81 IdlParser::IdlParser( ary::Repository & io_rRepository )
82 : pRepository(&io_rRepository)
86 void
87 IdlParser::Run( const autodoc::FileCollector_Ifc & i_rFiles )
89 Dyn<FileParsePerformers>
90 pFileParsePerformers(
91 new FileParsePerformers(*pRepository,
92 static_cast< ParserInfo& >(*this)) );
94 FileCollector::const_iterator iEnd = i_rFiles.End();
95 for ( FileCollector::const_iterator iter = i_rFiles.Begin();
96 iter != iEnd;
97 ++iter )
99 Cout() << (*iter) << " ..."<< Endl();
103 pFileParsePerformers->ParseFile(*iter);
105 catch (const X_AutodocParser &)
107 /// Ignore and goon
108 TheMessages().Out_ParseError(CurFile(), CurLine());
109 pFileParsePerformers
110 = new FileParsePerformers(*pRepository,
111 static_cast< ParserInfo& >(*this));
113 catch (X_Docu & xd)
115 // Currently thic catches only wrong since tags, while since tags are
116 // transformed. In this case the program shall be terminated.
117 Cerr() << xd << Endl();
118 exit(1);
120 catch (...)
122 Cout() << "Unknown error." << Endl();
123 exit(0);
124 // pFileParsePerformers = new FileParsePerformers( *pRepository );
129 FileParsePerformers::FileParsePerformers( ary::Repository & io_rRepository,
130 ParserInfo & io_rParserInfo )
131 : pTokens(0),
132 aDistributor(io_rRepository, io_rParserInfo),
133 rRepository( io_rRepository ),
134 rParserInfo(io_rParserInfo)
136 DYN csi::dsapi::Context_Docu *
137 dpDocuContext
138 = new csi::dsapi::Context_Docu( aDistributor.DocuTokens_Receiver() );
139 pTokens = new csi::uidl::TokenParser_Uidl( aDistributor.CodeTokens_Receiver(), *dpDocuContext );
140 pFileParseEnvironment
141 = new csi::uidl::PE_File(aDistributor,rParserInfo);
143 aDistributor.SetTokenProvider(*pTokens);
144 aDistributor.SetTopParseEnvironment(*pFileParseEnvironment);
147 void
148 FileParsePerformers::ParseFile( const char * i_sFullPath )
150 csv::File aFile(i_sFullPath);
152 aFile.open( csv::CFM_READ );
153 csv_assert( aFile.is_open() );
154 aFileLoader.LoadText(aFile);
155 aFile.close();
157 rParserInfo.Set_CurFile(i_sFullPath, true); // true = count lines
158 pTokens->Start(aFileLoader);
159 aDistributor.Reset();
161 do {
162 aDistributor.TradeToken();
163 } while ( NOT aFileLoader.IsFinished() );
166 } // namespace autodoc
168 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */