LCOV - code coverage report
Current view: top level - libreoffice/autodoc/source/parser_i/idl - unoidl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 36 42 85.7 %
Date: 2012-12-27 Functions: 7 7 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #include <precomp.h>
      21             : #include <parser/unoidl.hxx>
      22             : 
      23             : 
      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>
      40             : 
      41             : 
      42             : 
      43             : namespace autodoc
      44             : {
      45             : 
      46             : 
      47           3 : class FileParsePerformers
      48             : {
      49             :   public:
      50             :                         FileParsePerformers(
      51             :                             ary::Repository &
      52             :                                                 io_rRepository,
      53             :                             ParserInfo &        io_rParserInfo );
      54             : 
      55             :     void                ParseFile(
      56             :                             const char *        i_sFullPath );
      57             : 
      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;
      67             : };
      68             : 
      69             : 
      70           1 : IdlParser::IdlParser( ary::Repository & io_rRepository )
      71           1 :     :   pRepository(&io_rRepository)
      72             : {
      73           1 : }
      74             : 
      75             : void
      76           1 : IdlParser::Run( const autodoc::FileCollector_Ifc & i_rFiles )
      77             : {
      78             :     Dyn<FileParsePerformers>
      79             :         pFileParsePerformers(
      80             :             new FileParsePerformers(*pRepository,
      81           1 :                                     static_cast< ParserInfo& >(*this)) );
      82             : 
      83           1 :     FileCollector::const_iterator iEnd = i_rFiles.End();
      84        4138 :     for ( FileCollector::const_iterator iter = i_rFiles.Begin();
      85             :           iter != iEnd;
      86             :           ++iter )
      87             :     {
      88        4137 :         Cout() << (*iter) << " ..."<< Endl();
      89             : 
      90             :         try
      91             :         {
      92        4137 :             pFileParsePerformers->ParseFile(*iter);
      93             :         }
      94           4 :         catch (const X_AutodocParser &)
      95             :         {
      96             :             /// Ignore and goon
      97           2 :             TheMessages().Out_ParseError(CurFile(), CurLine());
      98             :             pFileParsePerformers
      99             :                 = new FileParsePerformers(*pRepository,
     100           2 :                                           static_cast< ParserInfo& >(*this));
     101             :         }
     102           0 :         catch (X_Docu & xd)
     103             :         {
     104             :             // Currently thic catches only wrong since tags, while since tags are
     105             :             // transformed. In this case the program shall be terminated.
     106           0 :             Cerr() << xd << Endl();
     107           0 :             exit(1);
     108             :         }
     109           0 :         catch (...)
     110             :         {
     111           0 :             Cout() << "Unknown error." << Endl();
     112           0 :             exit(0);
     113             : //          pFileParsePerformers = new FileParsePerformers( *pRepository );
     114             :         }
     115           1 :     }
     116           1 : }
     117             : 
     118           3 : FileParsePerformers::FileParsePerformers( ary::Repository & io_rRepository,
     119             :                                           ParserInfo &           io_rParserInfo )
     120             :     :   pTokens(0),
     121             :         aDistributor(io_rRepository, io_rParserInfo),
     122           3 :         rParserInfo(io_rParserInfo)
     123             : {
     124             :     DYN csi::dsapi::Context_Docu *
     125             :         dpDocuContext
     126           3 :             = new csi::dsapi::Context_Docu( aDistributor.DocuTokens_Receiver() );
     127           3 :     pTokens = new csi::uidl::TokenParser_Uidl( aDistributor.CodeTokens_Receiver(), *dpDocuContext );
     128             :     pFileParseEnvironment
     129           3 :             = new csi::uidl::PE_File(aDistributor,rParserInfo);
     130             : 
     131           3 :     aDistributor.SetTokenProvider(*pTokens);
     132           3 :     aDistributor.SetTopParseEnvironment(*pFileParseEnvironment);
     133           3 : }
     134             : 
     135             : void
     136        4137 : FileParsePerformers::ParseFile( const char * i_sFullPath )
     137             : {
     138        4137 :     csv::File aFile(i_sFullPath);
     139             : 
     140        4137 :     aFile.open( csv::CFM_READ );
     141             :     csv_assert( aFile.is_open() );
     142        4137 :     aFileLoader.LoadText(aFile);
     143        4137 :     aFile.close();
     144             : 
     145        4137 :     rParserInfo.Set_CurFile(i_sFullPath, true); // true = count lines
     146        4137 :     pTokens->Start(aFileLoader);
     147        4137 :     aDistributor.Reset();
     148             : 
     149      527001 :     do {
     150      527003 :         aDistributor.TradeToken();
     151      531138 :     } while ( NOT aFileLoader.IsFinished() );
     152        4135 : }
     153             : 
     154           3 : }   // namespace autodoc
     155             : 
     156             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10