1 | /*
|
---|
2 | * TOPPERS Software
|
---|
3 | * Toyohashi Open Platform for Embedded Real-Time Systems
|
---|
4 | *
|
---|
5 | * Copyright (C) 2007-2008 by TAKAGI Nobuhisa
|
---|
6 | *
|
---|
7 | * 上記著作権者は,以下の(1)〜(4)の条件を満たす場合に限り,本ソフトウェ
|
---|
8 | * ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
|
---|
9 | * 変・再配布(以下,利用と呼ぶ)することを無償で許諾する.
|
---|
10 | * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
|
---|
11 | * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
|
---|
12 | * スコード中に含まれていること.
|
---|
13 | * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
|
---|
14 | * 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
|
---|
15 | * 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
|
---|
16 | * の無保証規定を掲載すること.
|
---|
17 | * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
|
---|
18 | * 用できない形で再配布する場合には,次のいずれかの条件を満たすこ
|
---|
19 | * と.
|
---|
20 | * (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
|
---|
21 | * 作権表示,この利用条件および下記の無保証規定を掲載すること.
|
---|
22 | * (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
|
---|
23 | * 報告すること.
|
---|
24 | * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
|
---|
25 | * 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
|
---|
26 | * また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理
|
---|
27 | * 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
|
---|
28 | * 免責すること.
|
---|
29 | *
|
---|
30 | * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
|
---|
31 | * よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
|
---|
32 | * に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
|
---|
33 | * アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
|
---|
34 | * の責任を負わない.
|
---|
35 | *
|
---|
36 | */
|
---|
37 | /*!
|
---|
38 | * \file toppers/oil/cfg1_out.hpp
|
---|
39 | * \brief cfg1_out.c/.srec ファイルを扱うための宣言定義
|
---|
40 | *
|
---|
41 | * このファイルで定義されるクラス
|
---|
42 | * \code
|
---|
43 | * class cfg1_out;
|
---|
44 | * \endcode
|
---|
45 | */
|
---|
46 | #ifndef TOPPERS_OIL_CFG1_OUT_HPP_
|
---|
47 | #define TOPPERS_OIL_CFG1_OUT_HPP_
|
---|
48 |
|
---|
49 | #include <string>
|
---|
50 | #include <vector>
|
---|
51 | #include <map>
|
---|
52 | #include "toppers/workaround.hpp"
|
---|
53 | #include "toppers/codeset.hpp"
|
---|
54 | #include "toppers/oil/oil_object.hpp"
|
---|
55 |
|
---|
56 | namespace toppers
|
---|
57 | {
|
---|
58 |
|
---|
59 | class macro_processor;
|
---|
60 | class s_record;
|
---|
61 | class nm_symbol;
|
---|
62 |
|
---|
63 | namespace oil
|
---|
64 | {
|
---|
65 | using namespace toppers::oil::oil_definition;
|
---|
66 |
|
---|
67 | /*!
|
---|
68 | * \class cfg1_out cfg1_out.hpp "toppers/oil/cfg1_out.hpp"
|
---|
69 | * \brief cfg1_out.c/.srec ファイル管理クラス
|
---|
70 | */
|
---|
71 | class cfg1_out
|
---|
72 | {
|
---|
73 | public:
|
---|
74 | struct cfg1_def_t
|
---|
75 | {
|
---|
76 | bool is_signed;
|
---|
77 | std::string name;
|
---|
78 | std::string expression;
|
---|
79 | std::string value1;
|
---|
80 | std::string value2;
|
---|
81 | };
|
---|
82 | typedef std::map< std::string, std::vector< object_definition* > > cfg_obj_map;
|
---|
83 | typedef std::vector< cfg1_def_t > cfg1_def_table;
|
---|
84 |
|
---|
85 | explicit cfg1_out( std::string const& filename, cfg1_def_table const* def_table = 0 );
|
---|
86 | cfg1_out( cfg1_out const& other );
|
---|
87 | virtual ~cfg1_out();
|
---|
88 | cfg1_out& operator = ( cfg1_out const& other )
|
---|
89 | {
|
---|
90 | cfg1_out t( other );
|
---|
91 | swap( t );
|
---|
92 | return *this;
|
---|
93 | }
|
---|
94 |
|
---|
95 | void load_cfg( std::string const& input_file, codeset_t codeset, std::vector<std::string> const* obj_info );
|
---|
96 | void generate( char const* type = 0 ) const;
|
---|
97 | std::string const& get_includes() const;
|
---|
98 |
|
---|
99 | void load_srec();
|
---|
100 | std::tr1::shared_ptr< s_record > get_srec() const;
|
---|
101 | std::tr1::shared_ptr< nm_symbol > get_syms() const;
|
---|
102 | cfg1_def_table const* get_def_table() const;
|
---|
103 | cfg_obj_map merge(void) const;
|
---|
104 | bool is_little_endian() const;
|
---|
105 |
|
---|
106 | void swap( cfg1_out& other )
|
---|
107 | {
|
---|
108 | implementation* t = pimpl_;
|
---|
109 | pimpl_ = other.pimpl_;
|
---|
110 | other.pimpl_ = t;
|
---|
111 | }
|
---|
112 | void swap(cfg_obj_map& other)
|
---|
113 | {
|
---|
114 |
|
---|
115 | }
|
---|
116 |
|
---|
117 | static std::tr1::int32_t make_signed( std::tr1::uint32_t value )
|
---|
118 | {
|
---|
119 | std::tr1::int32_t result;
|
---|
120 | if ( ( value >> 31 ) != 0 )
|
---|
121 | {
|
---|
122 | result = -static_cast< std::tr1::int32_t >( ( value ^ 0xffffffff ) + 1 ); // 2の補数表現にしか対応しない
|
---|
123 | }
|
---|
124 | else
|
---|
125 | {
|
---|
126 | result = static_cast< std::tr1::int32_t >( value );
|
---|
127 | }
|
---|
128 | return result;
|
---|
129 | }
|
---|
130 |
|
---|
131 | static void load_id_input_file( std::map< std::string, std::pair< long, bool > >& id_map );
|
---|
132 |
|
---|
133 | protected:
|
---|
134 | struct implementation;
|
---|
135 | explicit cfg1_out( implementation* pimpl ) : pimpl_( pimpl ) {}
|
---|
136 | private:
|
---|
137 | implementation* pimpl_;
|
---|
138 | };
|
---|
139 |
|
---|
140 | }
|
---|
141 | }
|
---|
142 |
|
---|
143 | #endif // ! TOPPERS_OIL_CFG1_OUT_HPP_
|
---|