1*78bc99aaSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*78bc99aaSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*78bc99aaSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*78bc99aaSAndrew Rist * distributed with this work for additional information 6*78bc99aaSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*78bc99aaSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*78bc99aaSAndrew Rist * "License"); you may not use this file except in compliance 9*78bc99aaSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*78bc99aaSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*78bc99aaSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*78bc99aaSAndrew Rist * software distributed under the License is distributed on an 15*78bc99aaSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*78bc99aaSAndrew Rist * KIND, either express or implied. See the License for the 17*78bc99aaSAndrew Rist * specific language governing permissions and limitations 18*78bc99aaSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*78bc99aaSAndrew Rist *************************************************************/ 21cdf0e10cSrcweir 22cdf0e10cSrcweir #include <precomp.h> 23cdf0e10cSrcweir #include "c_dealer.hxx" 24cdf0e10cSrcweir 25cdf0e10cSrcweir 26cdf0e10cSrcweir // NOT FULLY DECLARED SERVICES 27cdf0e10cSrcweir #include <ary/cpp/c_gate.hxx> 28cdf0e10cSrcweir #include <ary/loc/locp_le.hxx> 29cdf0e10cSrcweir #include <ary/loc/loc_root.hxx> 30cdf0e10cSrcweir #include <ary/loc/loc_file.hxx> 31cdf0e10cSrcweir //#include <ary/docu.hxx> 32cdf0e10cSrcweir #include <adoc/a_rdocu.hxx> 33cdf0e10cSrcweir #include "all_toks.hxx" 34cdf0e10cSrcweir #include "c_rcode.hxx" 35cdf0e10cSrcweir 36cdf0e10cSrcweir 37cdf0e10cSrcweir namespace ary 38cdf0e10cSrcweir { 39cdf0e10cSrcweir namespace loc 40cdf0e10cSrcweir { 41cdf0e10cSrcweir class Root; 42cdf0e10cSrcweir } 43cdf0e10cSrcweir } 44cdf0e10cSrcweir 45cdf0e10cSrcweir 46cdf0e10cSrcweir 47cdf0e10cSrcweir 48cdf0e10cSrcweir namespace cpp 49cdf0e10cSrcweir { 50cdf0e10cSrcweir 51cdf0e10cSrcweir Distributor::Distributor( ary::cpp::Gate & io_rAryGate ) 52cdf0e10cSrcweir : aCppPreProcessor(), 53cdf0e10cSrcweir aCodeExplorer(io_rAryGate), 54cdf0e10cSrcweir aDocuExplorer(), 55cdf0e10cSrcweir pGate(&io_rAryGate), 56cdf0e10cSrcweir pFileEventHandler(0), 57cdf0e10cSrcweir pDocuDistributor(0) 58cdf0e10cSrcweir { 59cdf0e10cSrcweir pFileEventHandler = & aCodeExplorer.FileEventHandler(); 60cdf0e10cSrcweir pDocuDistributor = & aCodeExplorer.DocuDistributor(); 61cdf0e10cSrcweir } 62cdf0e10cSrcweir 63cdf0e10cSrcweir void 64cdf0e10cSrcweir Distributor::AssignPartners( CharacterSource & io_rSourceText, 65cdf0e10cSrcweir const MacroMap & i_rValidMacros ) 66cdf0e10cSrcweir { 67cdf0e10cSrcweir aCppPreProcessor.AssignPartners(aCodeExplorer, io_rSourceText, i_rValidMacros); 68cdf0e10cSrcweir } 69cdf0e10cSrcweir 70cdf0e10cSrcweir Distributor::~Distributor() 71cdf0e10cSrcweir { 72cdf0e10cSrcweir } 73cdf0e10cSrcweir 74cdf0e10cSrcweir void 75cdf0e10cSrcweir Distributor::StartNewFile( const csv::ploc::Path & i_file ) 76cdf0e10cSrcweir { 77cdf0e10cSrcweir const csv::ploc::Root & 78cdf0e10cSrcweir root_dir = i_file.RootDir(); 79cdf0e10cSrcweir StreamLock 80cdf0e10cSrcweir sl(700); 81cdf0e10cSrcweir root_dir.Get(sl()); 82cdf0e10cSrcweir csv::ploc::Path 83cdf0e10cSrcweir root_path( sl().c_str(), true ); 84cdf0e10cSrcweir ary::loc::Le_id 85cdf0e10cSrcweir root_id = pGate->Locations().CheckIn_Root(root_path).LeId(); 86cdf0e10cSrcweir ary::loc::File & 87cdf0e10cSrcweir rFile = pGate->Locations().CheckIn_File( 88cdf0e10cSrcweir i_file.File(), 89cdf0e10cSrcweir i_file.DirChain(), 90cdf0e10cSrcweir root_id ); 91cdf0e10cSrcweir pFileEventHandler->SetCurFile(rFile); 92cdf0e10cSrcweir 93cdf0e10cSrcweir aCodeExplorer.StartNewFile(); 94cdf0e10cSrcweir 95cdf0e10cSrcweir csv_assert( pDocuDistributor != 0 ); 96cdf0e10cSrcweir aDocuExplorer.StartNewFile(*pDocuDistributor); 97cdf0e10cSrcweir } 98cdf0e10cSrcweir 99cdf0e10cSrcweir 100cdf0e10cSrcweir void 101cdf0e10cSrcweir Distributor::Deal_Eol() 102cdf0e10cSrcweir { 103cdf0e10cSrcweir pFileEventHandler->Event_IncrLineCount(); 104cdf0e10cSrcweir } 105cdf0e10cSrcweir 106cdf0e10cSrcweir void 107cdf0e10cSrcweir Distributor::Deal_Eof() 108cdf0e10cSrcweir { 109cdf0e10cSrcweir // Do nothing yet. 110cdf0e10cSrcweir } 111cdf0e10cSrcweir 112cdf0e10cSrcweir void 113cdf0e10cSrcweir Distributor::Deal_Cpp_UnblockMacro( Tok_UnblockMacro & let_drToken ) 114cdf0e10cSrcweir { 115cdf0e10cSrcweir aCppPreProcessor.UnblockMacro(let_drToken.Text()); 116cdf0e10cSrcweir delete &let_drToken; 117cdf0e10cSrcweir } 118cdf0e10cSrcweir 119cdf0e10cSrcweir void 120cdf0e10cSrcweir Distributor::Deal_CppCode( cpp::Token & let_drToken ) 121cdf0e10cSrcweir { 122cdf0e10cSrcweir aCppPreProcessor.Process_Token(let_drToken); 123cdf0e10cSrcweir } 124cdf0e10cSrcweir 125cdf0e10cSrcweir void 126cdf0e10cSrcweir Distributor::Deal_AdcDocu( adoc::Token & let_drToken ) 127cdf0e10cSrcweir { 128cdf0e10cSrcweir aDocuExplorer.Process_Token(let_drToken); 129cdf0e10cSrcweir } 130cdf0e10cSrcweir 131cdf0e10cSrcweir Distributor * 132cdf0e10cSrcweir Distributor::AsDistributor() 133cdf0e10cSrcweir { 134cdf0e10cSrcweir return this; 135cdf0e10cSrcweir } 136cdf0e10cSrcweir 137cdf0e10cSrcweir 138cdf0e10cSrcweir 139cdf0e10cSrcweir 140cdf0e10cSrcweir 141cdf0e10cSrcweir } // namespace cpp 142cdf0e10cSrcweir 143cdf0e10cSrcweir 144