source: cfg_oil/trunk/toppers/oil/factory.cpp@ 8

Last change on this file since 8 was 8, checked in by msugi, 13 years ago

ディレクトリ構造の作成,ソース一式とReleaseビルドのコミット.

File size: 16.4 KB
Line 
1/*
2 * TOPPERS Software
3 * Toyohashi Open Platform for Embedded Real-Time Systems
4 *
5 * Copyright (C) 2007-2008 by TAKAGI Nobuhisa
6 * Copyright (C) 2010 by Meika Sugimoto
7 *
8 * ã‹L’˜ìŒ ŽÒ‚́CˆÈ‰º‚Ì(1)`(4)‚ÌðŒ‚ð–ž‚½‚·ê‡‚ÉŒÀ‚èC–{ƒ\ƒtƒgƒEƒF
9 * ƒAi–{ƒ\ƒtƒgƒEƒFƒA‚ð‰ü•Ï‚µ‚½‚à‚Ì‚ðŠÜ‚ށDˆÈ‰º“¯‚¶j‚ðŽg—pE•¡»E‰ü
10 * •ÏEÄ”z•ziˆÈ‰ºC—˜—p‚ƌĂԁj‚·‚邱‚Ƃ𖳏ž‚Å‹–‘ø‚·‚éD
11 * (1) –{ƒ\ƒtƒgƒEƒFƒA‚ðƒ\[ƒXƒR[ƒh‚ÌŒ`‚Å—˜—p‚·‚éê‡‚ɂ́Cã‹L‚Ì’˜ì
12 * Œ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’肪C‚»‚Ì‚Ü‚Ü‚ÌŒ`‚Ń\[
13 * ƒXƒR[ƒh’†‚ÉŠÜ‚Ü‚ê‚Ä‚¢‚邱‚ƁD
14 * (2) –{ƒ\ƒtƒgƒEƒFƒA‚ðCƒ‰ƒCƒuƒ‰ƒŠŒ`Ž®‚ȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
15 * —p‚Å‚«‚éŒ`‚ōĔz•z‚·‚éê‡‚ɂ́CÄ”z•z‚É”º‚¤ƒhƒLƒ…
16ƒƒ“ƒgi—˜—p
17 * ŽÒƒ}ƒjƒ…
18ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L
19 * ‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
20 * (3) –{ƒ\ƒtƒgƒEƒFƒA‚ðC‹@Ší‚É‘g‚ݍž‚ނȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
21 * —p‚Å‚«‚È‚¢Œ`‚ōĔz•z‚·‚éê‡‚ɂ́CŽŸ‚Ì‚¢‚¸‚ê‚©‚ÌðŒ‚ð–ž‚½‚·‚±
22 * ‚ƁD
23 * (a) Ä”z•z‚É”º‚¤ƒhƒLƒ…
24ƒƒ“ƒgi—˜—pŽÒƒ}ƒjƒ…
25ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜
26 * ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
27 * (b) Ä”z•z‚ÌŒ`‘Ô‚ðC•Ê‚É’è‚ß‚é•û–@‚É‚æ‚Á‚āCTOPPERSƒvƒƒWƒFƒNƒg‚É
28 * •ñ‚·‚邱‚ƁD
29 * (4) –{ƒ\ƒtƒgƒEƒFƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚é‚¢‚©‚Ȃ鑹
30 * ŠQ‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð–Ɛӂ·‚邱‚ƁD
31 * ‚Ü‚½C–{ƒ\ƒtƒgƒEƒFƒA‚̃†[ƒU‚Ü‚½‚̓Gƒ“ƒhƒ†[ƒU‚©‚ç‚Ì‚¢‚©‚Ȃ闝
32 * —R‚ÉŠî‚­¿‹‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð
33 * –Ɛӂ·‚邱‚ƁD
34 *
35 * –{ƒ\ƒtƒgƒEƒFƒA‚́C–³•ÛØ‚Å’ñ‹Ÿ‚³‚ê‚Ä‚¢‚é‚à‚Ì‚Å‚ ‚éDã‹L’˜ìŒ ŽÒ‚¨
36 * ‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚́C–{ƒ\ƒtƒgƒEƒFƒA‚ÉŠÖ‚µ‚āC“Á’è‚ÌŽg—p–Ú“I
37 * ‚ɑ΂·‚é“K‡«‚àŠÜ‚߂āC‚¢‚©‚È‚é•ÛØ‚às‚í‚È‚¢D‚Ü‚½C–{ƒ\ƒtƒgƒEƒF
38 * ƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚½‚¢‚©‚Ȃ鑹ŠQ‚ÉŠÖ‚µ‚Ä‚àC‚»
39 * ‚̐ӔC‚𕉂í‚È‚¢D
40 *
41 */
42#include <cstring>
43#include <cstdlib>
44#include <fstream>
45#include <boost/lexical_cast.hpp>
46#include <boost/spirit.hpp>
47#include "toppers/misc.hpp"
48#include "toppers/global.hpp"
49#include "toppers/csv.hpp"
50#include "toppers/nm_symbol.hpp"
51#include "toppers/s_record.hpp"
52#include "toppers/diagnostics.hpp"
53#include "toppers/macro_processor.hpp"
54#include "toppers/io.hpp"
55#include "toppers/cpp.hpp"
56#include "toppers/oil/factory.hpp"
57#include "toppers/oil/cfg1_out.hpp"
58
59namespace toppers
60{
61 namespace oil
62 {
63 namespace
64 {
65
66 object_definition* find_object(string name , cfg1_out::cfg_obj_map const& obj_def_map)
67 {
68 std::map< std::string, std::vector<object_definition*>>::const_iterator p;
69 std::vector<object_definition*>::const_iterator q;
70
71 // –¼‘O‚ªˆê’v‚·‚éƒIƒuƒWƒFƒNƒg‚ðŒŸõ
72 for(p = obj_def_map.begin() ; p != obj_def_map.end() ; p++)
73 {
74 for(q = (*p).second.begin() ; q != (*p).second.end() ; q++)
75 {
76 if((*q)->get_name() == name)
77 {
78 return (*q);
79 }
80 }
81 }
82 return NULL;
83 }
84
85 // ƒJ[ƒlƒ‹ƒIƒuƒWƒFƒNƒg¶¬E’è‹`—pÃ“IAPI‚ÌŠeƒpƒ‰ƒ[ƒ^‚ðƒ}ƒNƒƒvƒƒZƒbƒT‚̕ϐ”‚Æ‚µ‚Đݒ肷‚éB
86 void set_object_vars( cfg1_out::cfg_obj_map const& obj_def_map, macro_processor& mproc )
87 {
88 typedef macro_processor::element element;
89 typedef macro_processor::var_t var_t;
90 std::map< std::string, var_t > order_list_map , obj_parameter;
91 std::map< std::string, long > id_map;
92
93 using namespace toppers::oil::oil_definition;
94 std::map< std::string, std::vector<object_definition*>>::const_iterator p;
95 std::vector<object_definition*>::const_iterator q;
96 std::vector<object_parameter_def*>::const_iterator r;
97
98 for ( p = obj_def_map.begin() ; p != obj_def_map.end() ; p++)
99 {
100 element e;
101 var_t t;
102 string name;
103 long obj_id;
104 long param_id;
105
106 // ƒpƒ‰ƒ[ƒ^‚Ì’l‘ã“ü
107 for(q = (*p).second.begin() ; q != (*p).second.end() ; q++)
108 {
109 std::map< std::string, var_t > obj_parameter;
110 std::map< std::string, var_t >::iterator s;
111 obj_id = (*q)->get_id();
112 name = (*p).first;
113 std::map<std::string , long> id_count;
114 std::map<std::string , long>::iterator id_iter;
115
116 // ’l‚ÌŽæ‚èo‚µ
117 e.i = (*q)->get_id();
118 e.s = (*q)->get_name();
119 // oŒ»‡ƒŠƒXƒg—p‚̏î•ñì¬
120 order_list_map[ name ].push_back(e);
121 // ƒIƒuƒWƒFƒNƒgŽ©g‚Ì’l‘ã“ü
122 mproc.set_var( toppers::toupper(name), obj_id, var_t( 1, e ) );
123
124 // ƒIƒuƒWƒFƒNƒgƒƒ“ƒo‚Ì’l‘ã“ü
125 for(r = (*q)->get_params()->begin() ; r != (*q)->get_params()->end() ; r++)
126 {
127 name = (*p).first+ string(".") + (*r)->get_parameter_name();
128 e.s = (*r)->get_value();
129
130 if(e.s == string(""))
131 {
132 continue;
133 }
134
135 // ƒƒ“ƒo‚ÌID‚ðŒŸõ
136 id_iter = id_count.find(name);
137 if(id_iter == id_count.end())
138 {
139 id_count[name] = 0;
140 param_id = 0;
141 }
142 else
143 {
144 param_id = (*id_iter).second + 1;
145 id_count[name] = (*id_iter).second + 1;
146 }
147
148 if((*r)->get_type() == oil::TYPE_UINT)
149 {
150 string value_str(((*r)->get_value()));
151 try
152 {
153 e.i = boost::lexical_cast<unsigned __int64>((*r)->get_value());
154 }
155 catch( std::exception& exception)
156 {
157 unsigned __int64 temp;
158 // 16i‚̏ꍇ‚ª‚ ‚é‚Ì‚Å•ÏŠ·
159 /// ‚«‚ê‚¢‚¶‚á‚È‚¢‚Ì‚Å‚È‚ñ‚Æ‚©‚µ‚½‚¢
160 if(value_str.find("0x") == 0)
161 {
162 sscanf_s(value_str.c_str() , "0x%I64x" , &temp);
163 e.i = temp;
164 }
165 else if(value_str.find("0X") == 0)
166 {
167 sscanf_s(value_str.c_str() , "0X%I64x" , &temp);
168 e.i = temp;
169 }
170 else
171 {
172 // ƒLƒƒƒXƒg‚ÉŽ¸”s‚µ‚½‚ç0‚É‚µ‚Ä‚¨‚­
173 e.i = 0;
174 }
175
176 }
177 }
178 else if((*r)->get_type() == oil::TYPE_INT)
179 {
180 string value_str(((*r)->get_value()));
181 try
182 {
183 e.i = boost::lexical_cast<__int64>(value_str);
184 }
185 catch(std::exception& exception)
186 {
187 __int64 temp;
188 // 16i‚̏ꍇ‚ª‚ ‚é‚Ì‚Å•ÏŠ·
189 /// ‚«‚ê‚¢‚¶‚á‚È‚¢‚Ì‚Å‚È‚ñ‚Æ‚©‚µ‚½‚¢
190 if(value_str.find("0x") == 0)
191 {
192 sscanf_s(value_str.c_str() , "0x%I64x" , &temp);
193 e.i = temp;
194 }
195 else if(value_str.find("0X") == 0)
196 {
197 sscanf_s(value_str.c_str() , "0X%I64x" , &temp);
198 e.i = temp;
199 }
200 else
201 {
202 // ƒLƒƒƒXƒg‚ÉŽ¸”s‚µ‚½‚ç0‚É‚µ‚Ä‚¨‚­
203 e.i = 0;
204 }
205 }
206 }
207 else if((*r)->get_type() == oil::TYPE_REF)
208 {
209 object_definition *obj;
210 string refefence_obj_type;
211
212 // ƒIƒuƒWƒFƒNƒgID‚Ì’Tõ
213 e.i = 0;
214 obj = find_object((*r)->get_value() , obj_def_map);
215 if(obj != NULL)
216 {
217 e.i = obj->get_id();
218 }
219 }
220 else
221 {
222 e.i = 0;
223 }
224 obj_parameter[name].push_back(e);
225 }
226
227 for(s = obj_parameter.begin() ; s != obj_parameter.end() ; s++)
228 {
229 mproc.set_var((*s).first , obj_id , (*s).second );
230 }
231 }
232
233 }
234 // ‡˜ƒŠƒXƒg‚̍쐬
235 for ( std::map< std::string, var_t >::const_iterator iter( order_list_map.begin() ), last( order_list_map.end() );
236 iter != last;
237 ++iter )
238 {
239 // oŒ»‡ƒŠƒXƒg $OBJ.ORDER_LIST$ -- ID”ԍ†‚Ì•À‚Ñ
240 mproc.set_var( toppers::toupper( iter->first + ".order_list" ), iter->second );
241 var_t rorder_list( iter->second );
242
243 // ‹t‡ƒŠƒXƒg $OBJ.RORDER_LIST$ -- ID”ԍ†‚Ì•À‚Ñ
244 std::reverse( rorder_list.begin(), rorder_list.end() );
245 mproc.set_var( toppers::toupper( iter->first + ".rorder_list" ), rorder_list );
246
247 // ID”ԍ†ƒŠƒXƒg $OBJ.ID_LIST$ -- ID”ԍ†‚Ì•À‚Ñ
248 var_t id_list( iter->second );
249 std::sort( id_list.begin(), id_list.end() );
250 mproc.set_var( toppers::toupper( iter->first + ".id_list" ), id_list );
251 }
252 }
253
254
255 // ƒvƒ‰ƒbƒgƒtƒH[ƒ€EƒRƒ“ƒpƒCƒ‰ˆË‘¶‚Ì’l‚ðƒ}ƒNƒƒvƒƒZƒbƒT‚̕ϐ”‚Æ‚µ‚Đݒ肷‚éB
256 void set_platform_vars( cfg1_out const& cfg1out, macro_processor& mproc )
257 {
258 typedef macro_processor::element element;
259 typedef macro_processor::var_t var_t;
260
261 cfg1_out::cfg1_def_table const* def_table = cfg1out.get_def_table();
262 std::size_t sizeof_signed_t;
263
264 static cfg1_out::cfg1_def_t const limit_defs[] =
265 {
266 { false, "TOPPERS_cfg_CHAR_BIT", "CHAR_BIT" },
267 { false, "TOPPERS_cfg_CHAR_MAX", "CHAR_MAX" },
268 { true, "TOPPERS_cfg_CHAR_MIN", "CHAR_MIN" },
269 { false, "TOPPERS_cfg_SCHAR_MAX", "SCHAR_MAX" }, // –{—ˆ‚Í•„†•t‚«‚¾‚ªA•‰‚ɂȂ邱‚Æ‚Í‚È‚¢
270 { false, "TOPPERS_cfg_SHRT_MAX", "SHRT_MAX" }, // –{—ˆ‚Í•„†•t‚«‚¾‚ªA•‰‚ɂȂ邱‚Æ‚Í‚È‚¢
271 { false, "TOPPERS_cfg_INT_MAX", "INT_MAX" }, // –{—ˆ‚Í•„†•t‚«‚¾‚ªA•‰‚ɂȂ邱‚Æ‚Í‚È‚¢
272 { false, "TOPPERS_cfg_LONG_MAX", "LONG_MAX" }, // –{—ˆ‚Í•„†•t‚«‚¾‚ªA•‰‚ɂȂ邱‚Æ‚Í‚È‚¢
273 };
274
275 nm_symbol::entry nm_entry = cfg1out.get_syms()->find( "TOPPERS_cfg_sizeof_signed_t" );
276 sizeof_signed_t = static_cast< std::size_t >( cfg1out.get_srec()->get_value( nm_entry.address, 4, cfg1out.is_little_endian() ) );
277
278 for ( std::size_t i = 0; i < sizeof limit_defs / sizeof limit_defs[ 0 ]; ++i )
279 {
280 element e;
281 e.s = limit_defs[ i ].expression;
282 nm_entry = cfg1out.get_syms()->find( limit_defs[ i ].name );
283 std::tr1::int64_t value = cfg1out.get_srec()->get_value( nm_entry.address, sizeof_signed_t, cfg1out.is_little_endian() );
284 if ( sizeof_signed_t < 8 && limit_defs[ i ].is_signed )
285 {
286 value = cfg1_out::make_signed( static_cast< std::tr1::uint32_t >( value ) );
287 }
288 mproc.set_var( e.s, var_t( 1, e ) );
289 }
290
291 for ( cfg1_out::cfg1_def_table::const_iterator iter( def_table->begin() ), last( def_table->end() );
292 iter != last;
293 ++iter )
294 {
295 element e;
296 e.s = iter->expression;
297 nm_entry = cfg1out.get_syms()->find( "TOPPERS_cfg_" + iter->name );
298 if ( nm_entry.type >= 0 )
299 {
300 std::tr1::int64_t value = cfg1out.get_srec()->get_value( nm_entry.address, sizeof_signed_t, cfg1out.is_little_endian() );
301 if ( sizeof_signed_t < 8 && iter->is_signed )
302 {
303 value = cfg1_out::make_signed( static_cast< std::tr1::uint32_t >( value ) );
304 }
305 e.i = value;
306 mproc.set_var( iter->name, var_t( 1, e ) );
307 }
308 }
309
310 // ƒoƒCƒgƒI[ƒ_[
311 {
312 bool little_endian = cfg1out.is_little_endian();
313 element e;
314 e.i = little_endian;
315 mproc.set_var( "LITTLE_ENDIAN", var_t( 1, e ) );
316
317 e.i = !little_endian;
318 mproc.set_var( "BIG_ENDIAN", var_t( 1, e ) );
319 }
320 }
321
322 }
323
324 //! ƒRƒ“ƒXƒgƒ‰ƒNƒ^
325 factory::factory( std::string const& kernel )
326 : kernel_( tolower( kernel ) )
327 {
328 }
329
330 //! ƒfƒXƒgƒ‰ƒNƒ^
331 factory::~factory()
332 {
333 }
334
335 //! ƒTƒ|[ƒg‚µ‚Ä‚¢‚éƒIƒuƒWƒFƒNƒgî•ñ‚̎擾
336 std::vector<std::string> const* factory::get_object_definition_info() const
337 {
338 // CSV‚©‚çÃ“IAPIî•ñ‚ð“Ç‚ÝŽæ‚èA“o˜^‚·‚邽‚߂̃[ƒJƒ‹ƒNƒ‰ƒX
339 struct init_t
340 {
341 init_t()
342 {
343 boost::any t = global( "api-table" );
344 if ( !t.empty() )
345 {
346 std::vector< std::string > api_tables( boost::any_cast< std::vector< std::string >& >( t ) );
347 for ( std::vector< std::string >::const_iterator iter( api_tables.begin() ), last( api_tables.end() );
348 iter != last;
349 ++iter )
350 {
351 std::string buf;
352 read( iter->c_str(), buf );
353 csv data( buf.begin(), buf.end() );
354 for ( csv::const_iterator d_iter( data.begin() ), d_last( data.end() );
355 d_iter != d_last;
356 ++d_iter )
357 {
358 unsigned int i;
359 for(i = 0 ; i < d_iter->size() ; i++)
360 {
361 volatile int x = 1;
362 object_definition_table.push_back((*d_iter)[i].c_str());
363 }
364 }
365
366 }
367 }
368 }
369
370 ~init_t()
371 {
372
373
374 }
375
376 std::vector<std::string> object_definition_table;
377 };
378 static init_t init;
379 std::vector<std::string> const* result = &init.object_definition_table;
380 return result;
381 }
382
383 /*!
384 * \brief cfg1_out.c ‚ւ̏o—͏î•ñƒe[ƒuƒ‹‚̐¶¬
385 * \return ¶¬‚µ‚½ cfg1_out::cfg1_def_table ƒIƒuƒWƒFƒNƒg‚ւ̃|ƒCƒ“ƒ^
386 * \note ‚±‚̊֐”‚ª•Ô‚·ƒ|ƒCƒ“ƒ^‚Í delete ‚µ‚Ä‚Í‚È‚ç‚È‚¢
387 *
388 * --cfg1-def-table ƒIƒvƒVƒ‡ƒ“‚ÅŽw’肵‚½ƒtƒ@ƒCƒ‹‚©‚çAcfg1_out.c ‚֏o—Í‚·‚éî•ñ‚ð“Ç‚ÝŽæ‚èA
389 * cfg1_out::cfg1_def_table ƒIƒuƒWƒFƒNƒg‚𐶐¬‚·‚éB
390 *
391 * CSV ‚ÌŒ`Ž®‚͈ȉº‚Ì’Ê‚è
392 *
393 * ƒVƒ“ƒ{ƒ‹–¼,Ž®[,s|signed]
394 *
395 * ––”ö‚Ì s ‚Ü‚½‚Í signed ‚͏ȗª‰Â”\BÈ—ªŽž‚Í•„†–³‚µ®”‚Æ‚Ý‚È‚·Bs ‚Ü‚½‚Í signed Žw’莞‚Í
396 * •„†•t‚«®”‚Æ‚Ý‚È‚·B\n
397 * uŽ®v‚̍ŏ‰‚É # ‚ª‚ ‚ê‚ΑOˆ—Ž®‚Æ‚Ý‚È‚·B
398 */
399 cfg1_out::cfg1_def_table const* factory::get_cfg1_def_table() const
400 {
401 struct init_t
402 {
403 init_t()
404 {
405 boost::any t = global( "cfg1-def-table" );
406 if ( !t.empty() )
407 {
408 std::vector< std::string > cfg1_def_table = boost::any_cast< std::vector< std::string >& >( t );
409 for ( std::vector< std::string >::const_iterator iter( cfg1_def_table.begin() ), last( cfg1_def_table.end() );
410 iter != last;
411 ++iter )
412 {
413 std::string buf;
414 read( iter->c_str(), buf );
415 csv data( buf.begin(), buf.end() );
416 for ( csv::const_iterator d_iter( data.begin() ), d_last( data.end() );
417 d_iter != d_last;
418 ++d_iter )
419 {
420 csv::size_type len = d_iter->size();
421 if ( len < 2 )
422 {
423 toppers::fatal( _( "too little fields in `%1%\'" ), *iter );
424 }
425 cfg1_out::cfg1_def_t def = { 0 };
426 def.name = ( *d_iter )[ 0 ];
427 def.expression = ( *d_iter )[ 1 ];
428 if ( len >= 3 )
429 {
430 std::string is_signed( ( *d_iter )[ 2 ] );
431 def.is_signed = ( is_signed == "s" || is_signed == "signed" );
432 }
433 cfg1_def_table_.push_back( def );
434 }
435 }
436 }
437 }
438 cfg1_out::cfg1_def_table cfg1_def_table_;
439 };
440 static init_t init;
441 cfg1_out::cfg1_def_table const* result = &init.cfg1_def_table_;
442 return result;
443 }
444
445 //! ƒIƒuƒWƒFƒNƒg‚ÌŒðŠ·
446 void factory::do_swap( factory& other )
447 {
448 kernel_.swap( other.kernel_ );
449 }
450
451 macro_processor::hook_t factory::do_get_hook_on_assign() const
452 {
453// return &hook_on_assign;
454 return 0;
455 }
456
457 /*!
458 * \brief ƒ}ƒNƒƒvƒƒZƒbƒT‚̐¶¬
459 * \param[in] hook •Ï”‚É’l‚ð‘ã“ü‚µ‚½Û‚̃tƒbƒNˆ—
460 * \param[in] cfg1out cfg1_out ƒIƒuƒWƒFƒNƒg
461 * \param[in] api_map .cfg ƒtƒ@ƒCƒ‹‚É‹Lq‚³‚ꂽÃ“IAPIî•ñ
462 * \return ƒ}ƒNƒƒvƒƒZƒbƒT‚ւ̃|ƒCƒ“ƒ^
463 */
464 std::auto_ptr< macro_processor > factory::do_create_macro_processor( macro_processor::hook_t hook, cfg1_out const& cfg1out, cfg1_out::cfg_obj_map const& obj_def_map ) const
465 {
466 typedef macro_processor::element element;
467 typedef macro_processor::var_t var_t;
468 std::auto_ptr< macro_processor > mproc( new macro_processor( hook ) );
469 element e;
470
471 e.s = " "; mproc->set_var( "SPC", var_t( 1, e ) ); // $SPC$
472 e.s = "\t"; mproc->set_var( "TAB", var_t( 1, e ) ); // $TAB$
473 e.s = "\n"; mproc->set_var( "NL", var_t( 1, e ) ); // $NL$
474
475 // ƒo[ƒWƒ‡ƒ“î•ñ
476 e.s = toppers::get_global< std::string >( "version" );
477 e.i = toppers::get_global< std::tr1::int64_t >( "timestamp" );
478 mproc->set_var( "CFG_VERSION", var_t( 1, e ) ); // $CFG_VERSION$
479
480 // ‚»‚Ì‘¼‚Ì‘g‚ݍž‚ݕϐ”‚̐ݒè
481 set_object_vars( obj_def_map, *mproc );
482 set_platform_vars( cfg1out, *mproc );
483 return mproc;
484 }
485
486 std::auto_ptr< cfg1_out > factory::do_create_cfg1_out( std::string const& filename ) const
487 {
488 return std::auto_ptr< oil::cfg1_out >( new cfg1_out( filename, get_cfg1_def_table() ) );
489 }
490
491 }
492}
Note: See TracBrowser for help on using the repository browser.