Updated core
[LibreOffice.git] / autodoc / source / parser_i / idl / unoidl.cxx
blobbf213b1cf1d9adbe21181ba053b13bdd9f4d6e81
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <precomp.h>
21 #include <parser/unoidl.hxx>
24 // NOT FULLY DECLARED SERVICES
25 #include <stdlib.h>
26 #include <cosv/file.hxx>
27 #include <ary/ary.hxx>
28 #include <ary/idl/i_gate.hxx>
29 #include <ary/doc/d_oldidldocu.hxx>
30 #include <../parser/inc/x_docu.hxx>
31 #include <parser/parserinfo.hxx>
32 #include <tools/filecoll.hxx>
33 #include <tools/tkpchars.hxx>
34 #include <s2_luidl/tkp_uidl.hxx>
35 #include <s2_luidl/distrib.hxx>
36 #include <s2_luidl/pe_file2.hxx>
37 #include <s2_dsapi/cx_dsapi.hxx>
38 #include <adc_msg.hxx>
39 #include <x_parse2.hxx>
43 namespace autodoc
47 class FileParsePerformers
49 public:
50 FileParsePerformers(
51 ary::Repository &
52 io_rRepository,
53 ParserInfo & io_rParserInfo );
55 void ParseFile(
56 const char * i_sFullPath );
58 private:
59 CharacterSource aFileLoader;
60 Dyn<csi::uidl::TokenParser_Uidl>
61 pTokens;
62 csi::uidl::TokenDistributor
63 aDistributor;
64 Dyn<csi::uidl::PE_File>
65 pFileParseEnvironment;
66 ParserInfo & rParserInfo;
70 IdlParser::IdlParser( ary::Repository & io_rRepository )
71 : pRepository(&io_rRepository)
75 void
76 IdlParser::Run( const autodoc::FileCollector_Ifc & i_rFiles )
78 Dyn<FileParsePerformers>
79 pFileParsePerformers(
80 new FileParsePerformers(*pRepository,
81 static_cast< ParserInfo& >(*this)) );
83 FileCollector::const_iterator iEnd = i_rFiles.End();
84 for ( FileCollector::const_iterator iter = i_rFiles.Begin();
85 iter != iEnd;
86 ++iter )
88 Cout() << (*iter) << " ..."<< Endl();
90 try
92 pFileParsePerformers->ParseFile(*iter);
94 catch (const X_AutodocParser &)
96 /// Ignore and goon
97 TheMessages().Out_ParseError(CurFile(), CurLine());
98 pFileParsePerformers
99 = new FileParsePerformers(*pRepository,
100 static_cast< ParserInfo& >(*this));
102 catch (X_Docu & xd)
104 // Currently thic catches only wrong since tags, while since tags are
105 // transformed. In this case the program shall be terminated.
106 Cerr() << xd << Endl();
107 exit(1);
109 catch (...)
111 Cout() << "Unknown error." << Endl();
112 exit(0);
113 // pFileParsePerformers = new FileParsePerformers( *pRepository );
118 FileParsePerformers::FileParsePerformers( ary::Repository & io_rRepository,
119 ParserInfo & io_rParserInfo )
120 : pTokens(0),
121 aDistributor(io_rRepository, io_rParserInfo),
122 rParserInfo(io_rParserInfo)
124 DYN csi::dsapi::Context_Docu *
125 dpDocuContext
126 = new csi::dsapi::Context_Docu( aDistributor.DocuTokens_Receiver() );
127 pTokens = new csi::uidl::TokenParser_Uidl( aDistributor.CodeTokens_Receiver(), *dpDocuContext );
128 pFileParseEnvironment
129 = new csi::uidl::PE_File(aDistributor,rParserInfo);
131 aDistributor.SetTokenProvider(*pTokens);
132 aDistributor.SetTopParseEnvironment(*pFileParseEnvironment);
135 void
136 FileParsePerformers::ParseFile( const char * i_sFullPath )
138 csv::File aFile(i_sFullPath);
140 aFile.open( csv::CFM_READ );
141 csv_assert( aFile.is_open() );
142 aFileLoader.LoadText(aFile);
143 aFile.close();
145 rParserInfo.Set_CurFile(i_sFullPath, true); // true = count lines
146 pTokens->Start(aFileLoader);
147 aDistributor.Reset();
149 do {
150 aDistributor.TradeToken();
151 } while ( NOT aFileLoader.IsFinished() );
154 } // namespace autodoc
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */