[8] | 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{\tgEF
|
---|
| 9 | * Ai{\tgEFAðüϵ½àÌðÜÞDȺ¯¶jðgpE¡»Eü
|
---|
| 10 | * ÏEÄzziȺCpÆÄÔj·é±Æð³Åø·éD
|
---|
| 11 | * (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
|
---|
| 12 | * \¦C±Ìpð¨æѺL̳ÛØKèªC»ÌÜÜÌ`Å\[
|
---|
| 13 | * XR[hÉÜÜêÄ¢é±ÆD
|
---|
| 14 | * (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJÉg
|
---|
| 15 | * pÅ«é`ÅÄzz·éêÉÍCÄzzɺ¤hL
|
---|
| 16 | gip
|
---|
| 17 | * Ò}j
|
---|
| 18 | AÈÇjÉCãLÌì \¦C±Ìpð¨æѺL
|
---|
| 19 | * ̳ÛØKèðfÚ·é±ÆD
|
---|
| 20 | * (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJÉg
|
---|
| 21 | * pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
|
---|
| 22 | * ÆD
|
---|
| 23 | * (a) Äzzɺ¤hL
|
---|
| 24 | gipÒ}j
|
---|
| 25 | AÈÇjÉCãLÌ
|
---|
| 26 | * ì \¦C±Ìpð¨æѺL̳ÛØKèðfÚ·é±ÆD
|
---|
| 27 | * (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
|
---|
| 28 | * ñ·é±ÆD
|
---|
| 29 | * (4) {\tgEFAÌpÉæè¼ÚIܽÍÔÚIɶ¶é¢©Èé¹
|
---|
| 30 | * Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
|
---|
| 31 | * ܽC{\tgEFAÌ[UܽÍGh[U©çÌ¢©Èé
|
---|
| 32 | * RÉîÿ©çàCãLì Ò¨æÑTOPPERSvWFNgð
|
---|
| 33 | * ÆÓ·é±ÆD
|
---|
| 34 | *
|
---|
| 35 | * {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
|
---|
| 36 | * æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
|
---|
| 37 | * ÉηéK«àÜßÄC¢©ÈéÛØàsíÈ¢DܽC{\tgEF
|
---|
| 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 |
|
---|
| 59 | namespace 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·éIuWFNgðõ
|
---|
| 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[lIuWFNg¶¬Eè`pÃIAPIÌep[^ð}NvZbTÌÏƵÄÝè·é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»XgpÌîñì¬
|
---|
| 120 | order_list_map[ name ].push_back(e);
|
---|
| 121 | // IuWFNg©gÌlãü
|
---|
| 122 | mproc.set_var( toppers::toupper(name), obj_id, var_t( 1, e ) );
|
---|
| 123 |
|
---|
| 124 | // IuWFNgoÌ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 | // 16iÌêª éÌÅÏ·
|
---|
| 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 | // LXgɸ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 | // 16iÌêª éÌÅÏ·
|
---|
| 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 | // LXgɸ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 | // IuWFNgIDÌ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 | // XgÌì¬
|
---|
| 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»Xg $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 | // tXg $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ÔXg $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 | // vbgtH[ERpC˶Ìlð}NvZbTÌÏƵÄÝè·é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 | // oCgI[_[
|
---|
| 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 | //! RXgN^
|
---|
| 325 | factory::factory( std::string const& kernel )
|
---|
| 326 | : kernel_( tolower( kernel ) )
|
---|
| 327 | {
|
---|
| 328 | }
|
---|
| 329 |
|
---|
| 330 | //! fXgN^
|
---|
| 331 | factory::~factory()
|
---|
| 332 | {
|
---|
| 333 | }
|
---|
| 334 |
|
---|
| 335 | //! T|[gµÄ¢éIuWFNgîñÌæ¾
|
---|
| 336 | std::vector<std::string> const* factory::get_object_definition_info() const
|
---|
| 337 | {
|
---|
| 338 | // CSV©çÃIAPIîñðÇÝæèAo^·é½ßÌ[JNX
|
---|
| 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 IuWFNgÖÌ|C^
|
---|
| 386 | * \note ±ÌÖªÔ·|C^Í delete µÄÍÈçÈ¢
|
---|
| 387 | *
|
---|
| 388 | * --cfg1-def-table IvVÅwèµ½t@C©çAcfg1_out.c ÖoÍ·éîñðÇÝæèA
|
---|
| 389 | * cfg1_out::cfg1_def_table IuWFNg𶬷é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 | //! IuWFNgÌð·
|
---|
| 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 }NvZbT̶¬
|
---|
| 459 | * \param[in] hook ÏÉlðãüµ½ÛÌtbN
|
---|
| 460 | * \param[in] cfg1out cfg1_out IuWFNg
|
---|
| 461 | * \param[in] api_map .cfg t@CÉLq³ê½ÃIAPIîñ
|
---|
| 462 | * \return }NvZbTÖÌ|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 | }
|
---|