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