Changeset 24540
- Timestamp:
- 11/21/08 05:45:07 (4 years ago)
- Location:
- lang/cplusplus/i3/trunk
- Files:
-
- 8 modified
-
po/i3.pot (modified) (2 diffs)
-
scripts/astyle.sh (modified) (1 diff)
-
src/Common.h (modified) (1 diff)
-
src/Config.cpp (modified) (7 diffs)
-
src/Config.h (modified) (2 diffs)
-
src/os-unix/Os.h (modified) (2 diffs)
-
src/os-windows/Os.cpp (modified) (14 diffs)
-
windows/dist.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lang/cplusplus/i3/trunk/po/i3.pot
r23617 r24540 8 8 "Project-Id-Version: i3 1.0\n" 9 9 "Report-Msgid-Bugs-To: dyob@lunaport.net\n" 10 "POT-Creation-Date: 2008-11- 13 02:39-0800\n"10 "POT-Creation-Date: 2008-11-21 04:37-0800\n" 11 11 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 12 12 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" … … 15 15 "Content-Type: text/plain; charset=CHARSET\n" 16 16 "Content-Transfer-Encoding: 8bit\n" 17 18 #: src/gui-fltk/Gui.cpp:12 19 msgid "alert: " 20 msgstr "" 17 21 18 22 #: src/gui-fltk/InputWindowCore.cpp:27 src/gui-qt/Gui.cpp:27 -
lang/cplusplus/i3/trunk/scripts/astyle.sh
r18135 r24540 1 1 astyle="astyle --style=ansi" #XXX mazimenikangaeru 2 2 3 find src -type f -name "*.cpp" | xargs ${astyle} 3 find src -type f -name "*.h" | grep -v "xbyak" | xargs ${astyle}4 4 5 find src -type f -name "*.h" | \ 6 grep -v "xbyak" | \ 7 grep -v "iconv.h" | \ 8 grep -v "libintl.h" | \ 9 xargs ${astyle} -
lang/cplusplus/i3/trunk/src/Common.h
r24497 r24540 230 230 const char* portname = poptGetArg(optCon); 231 231 232 if ((portname == NULL) || !(poptPeekArg(optCon) == NULL)) { 232 if ((portname == NULL) || !(poptPeekArg(optCon) == NULL)) 233 { 233 234 usage(optCon, 1, "Specify a single port", ".e.g., /dev/cua0", fp); 234 235 } -
lang/cplusplus/i3/trunk/src/Config.cpp
r23850 r24540 4 4 #include "Config.h" 5 5 6 namespace i3 { 7 namespace config { 8 using namespace std; 9 using namespace boost::spirit; 10 struct ConfigTemp { 11 ////MACRO WILL BE EXPANDED 12 //boost::int32_t i; 13 //TCHAR* s; 14 //std::list<boost::int32_t> ia; 15 //std::list<TCHAR*> sa; 16 17 #define I3_CONFIG_MACRO_TEMP(r, data, elem) \ 18 BOOST_PP_IF(BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(3, 0, elem), i3_config_integer) , boost::int32_t, \ 19 BOOST_PP_IF(BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(3, 0, elem), i3_config_string) , TCHAR*, \ 20 BOOST_PP_IF(BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(3, 0, elem), i3_config_integer_array) , std::list<boost::int32_t>, std::list<TCHAR*>))) \ 6 namespace i3 7 { 8 namespace config 9 { 10 using namespace std; 11 using namespace boost::spirit; 12 struct ConfigTemp 13 { 14 ////MACRO WILL BE EXPANDED 15 //boost::int32_t i; 16 //TCHAR* s; 17 //std::list<boost::int32_t> ia; 18 //std::list<TCHAR*> sa; 19 20 #define I3_CONFIG_MACRO_TEMP(r, data, elem) \ 21 BOOST_PP_IF(BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(3, 0, elem), I3_CONFIG_integer) , boost::int32_t, \ 22 BOOST_PP_IF(BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(3, 0, elem), I3_CONFIG_string) , TCHAR*, \ 23 BOOST_PP_IF(BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(3, 0, elem), I3_CONFIG_integer_array) , std::list<boost::int32_t>, std::list<TCHAR*>))) \ 21 24 BOOST_PP_TUPLE_ELEM(3, 1, elem); 22 25 23 BOOST_PP_SEQ_FOR_EACH(I3_CONFIG_MACRO_TEMP, data, CONFIG_MEMBERS) 24 }; 25 26 struct integer_list { 27 boost::int32_t value; 28 size_t length; 29 integer_list* prev; 30 integer_list* tail; 31 integer_list() : value(0), length(0), prev(NULL), tail(this) {} 32 ~integer_list() { 33 for (integer_list* current = tail; current->prev != NULL;) { 34 integer_list* prev = current->prev; 35 free(current); 36 current = prev; 37 } 38 } 39 }; 40 struct string_list { 41 TCHAR* value; 42 size_t length; 43 string_list* prev; 44 string_list* tail; 45 string_list() : value(NULL), length(0), prev(NULL), tail(this) {} 46 ~string_list() { 47 for (string_list* current = tail; current->prev != NULL;) { 48 string_list* prev = current->prev; 49 free(current); 50 current = prev; 51 } 52 } 53 }; 54 struct integer_array { 55 boost::int32_t* data; 56 size_t length; 57 integer_array operator=(integer_list& list) { 58 length = list.length; 59 if (length == 0) { 60 data = NULL; 61 return *this; 62 } 63 data = (boost::int32_t*)malloc(sizeof(*data)*length); 64 if (data == NULL) { 26 BOOST_PP_SEQ_FOR_EACH(I3_CONFIG_MACRO_TEMP, data, CONFIG_MEMBERS) 27 }; 28 29 /* 30 struct integer_list 31 { 32 boost::int32_t value; 33 size_t length; 34 integer_list* prev; 35 integer_list* tail; 36 integer_list() : value(0), length(0), prev(NULL), tail(this) {} 37 ~integer_list() 38 { 39 for (integer_list* current = tail; current->prev != NULL;) 40 { 41 integer_list* prev = current->prev; 42 free(current); 43 current = prev; 44 } 45 } 46 }; 47 struct string_list 48 { 49 TCHAR* value; 50 size_t length; 51 string_list* prev; 52 string_list* tail; 53 string_list() : value(NULL), length(0), prev(NULL), tail(this) {} 54 ~string_list() 55 { 56 for (string_list* current = tail; current->prev != NULL;) 57 { 58 string_list* prev = current->prev; 59 free(current); 60 current = prev; 61 } 62 } 63 }; 64 struct integer_array 65 { 66 boost::int32_t* data; 67 size_t length; 68 integer_array operator=(integer_list& list) 69 { 70 length = list.length; 71 if (length == 0) 72 { 73 data = NULL; 74 return *this; 75 } 76 data = (boost::int32_t*)malloc(sizeof(*data)*length); 77 if (data == NULL) 78 { 79 abort(); 80 } 81 size_t written = 0; 82 for (integer_list* current = list.tail; written < length && current->prev != NULL; current = current->prev, written++) 83 { 84 data[written] = current->value; 85 } 86 return *this; 87 } 88 }; 89 struct string_array 90 { 91 TCHAR** data; 92 size_t length; 93 string_array& operator=(string_list& list) 94 { 95 length = list.length; 96 if (length == 0) 97 { 98 data = NULL; 99 return *this; 100 } 101 data = (TCHAR**)malloc(sizeof(*data)*length); 102 if (data == NULL) 103 { 104 abort(); 105 } 106 size_t written = 0; 107 for (string_list* current = list.tail; written < length && current->prev != NULL; current = current->prev, written++) 108 { 109 data[written] = current->value; 110 } 111 return *this; 112 } 113 }; 114 */ 115 struct MyIniLoader : public grammar<MyIniLoader> 116 { 117 struct integer_value 118 { 119 boost::int32_t& data; 120 integer_value(boost::int32_t& data) : data(data) {} 121 void operator()(int value) const 122 { 123 data = value; 124 } 125 }; 126 struct integer_array_value 127 { 128 //integer_list& data; 129 //integer_array_value(integer_list& data) : data(data) {} 130 //void operator()(boost::int32_t value) const { 131 // integer_list* got = (integer_list*)malloc(sizeof(integer_list)); 132 // if (!got) { 133 // abort(); 134 // } 135 // got->value = value; 136 // got->prev = data.tail; 137 // data.tail = got; 138 // data.length++; 139 //} 140 list<boost::int32_t>& data; 141 integer_array_value(list<boost::int32_t>& data) : data(data) {} 142 void operator()(int value) const 143 { 144 try 145 { 146 data.push_back(value); 147 } 148 catch (exception&) 149 { 65 150 abort(); 66 151 } 67 size_t written = 0; 68 for (integer_list* current = list.tail; written < length && current->prev != NULL; current = current->prev, written++) { 69 data[written] = current->value; 70 } 71 return *this; 72 } 73 }; 74 struct string_array { 75 TCHAR** data; 76 size_t length; 77 string_array& operator=(string_list& list) { 78 length = list.length; 79 if (length == 0) { 80 data = NULL; 81 return *this; 82 } 83 data = (TCHAR**)malloc(sizeof(*data)*length); 84 if (data == NULL) { 152 } 153 }; 154 struct string_value 155 { 156 TCHAR*& data; 157 string_value(TCHAR*& data) : data(data) {} 158 void operator()(const TCHAR* first, const TCHAR* last) const 159 { 160 ptrdiff_t bytes = (const char*)last - (const char*)first; 161 data = (TCHAR*)calloc(bytes + sizeof(TCHAR), 1); 162 if (!data) 163 { 85 164 abort(); 86 165 } 87 size_t written = 0; 88 for (string_list* current = list.tail; written < length && current->prev != NULL; current = current->prev, written++) { 89 data[written] = current->value; 90 } 91 return *this; 92 } 93 }; 94 95 struct MyIniLoader : public grammar<MyIniLoader> 96 { 97 struct integer_value { 98 boost::int32_t& data; 99 integer_value(boost::int32_t& data) : data(data) {} 100 void operator()(int value) const { 101 data = value; 102 } 103 }; 104 struct integer_array_value { 105 //integer_list& data; 106 //integer_array_value(integer_list& data) : data(data) {} 107 //void operator()(boost::int32_t value) const { 108 // integer_list* got = (integer_list*)malloc(sizeof(integer_list)); 109 // if (!got) { 110 // abort(); 111 // } 112 // got->value = value; 113 // got->prev = data.tail; 114 // data.tail = got; 115 // data.length++; 116 //} 117 list<boost::int32_t>& data; 118 integer_array_value(list<boost::int32_t>& data) : data(data) {} 119 void operator()(int value) const { 120 try { 121 data.push_back(value); 122 } catch (exception&) { 123 abort(); 124 } 125 } 126 }; 127 struct string_value { 128 TCHAR*& data; 129 string_value(TCHAR*& data) : data(data) {} 130 void operator()(const TCHAR* first, const TCHAR* last) const { 131 ptrdiff_t bytes = (const char*)last - (const char*)first; 132 data = (TCHAR*)calloc(bytes + sizeof(TCHAR), 1); 133 if (!data) { 134 abort(); 135 } 136 memcpy(data, first, bytes); 137 } 138 }; 139 struct string_array_value { 140 //string_list& data; 141 //string_array_value(string_list& data) : data(data) {} 142 //void operator()(const TCHAR* first, const TCHAR* last) const { 143 // ptrdiff_t bytes = (char*)last - (char*)first; 144 // string_list* got = (string_list*)malloc(sizeof(string_list)); 145 // if (!got) { 146 // abort(); 147 // } 148 // got->value = (TCHAR*)calloc(bytes + sizeof(TCHAR), 1); 149 // if (!got->value) { 150 // abort(); 151 // } 152 // memcpy(got->value, first, bytes); 153 // got->prev = data.tail; 154 // data.tail = got; 155 // data.length++; 156 //} 157 list<TCHAR*>& data; 158 string_array_value(list<TCHAR*>& data) : data(data) {} 159 void operator()(const TCHAR* first, const TCHAR* last) const { 160 ptrdiff_t bytes = (const char*)last - (const char*)first; 161 TCHAR* value = (TCHAR*)calloc(bytes + sizeof(TCHAR), 1); 162 if (!value) { 163 abort(); 164 } 165 memcpy(value, first, bytes); 166 try { 167 data.push_back(value); 168 } catch (exception&) { 169 abort(); 170 } 171 } 172 }; 173 174 ////MACRO WILL BE EXPANDED 175 //integer_value i; 176 //string_value s; 177 //integer_array_value ia; 178 //string_array_value sa; 179 180 #define I3_CONFIG_MACRO_PARSER(r, data, elem) \ 181 BOOST_PP_IF(BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(3, 0, elem), i3_config_integer) , integer_value, \ 182 BOOST_PP_IF(BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(3, 0, elem), i3_config_string) , string_value, \ 183 BOOST_PP_IF(BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(3, 0, elem), i3_config_integer_array) , integer_array_value, string_array_value))) \ 166 memcpy(data, first, bytes); 167 } 168 }; 169 struct string_array_value 170 { 171 //string_list& data; 172 //string_array_value(string_list& data) : data(data) {} 173 //void operator()(const TCHAR* first, const TCHAR* last) const { 174 // ptrdiff_t bytes = (char*)last - (char*)first; 175 // string_list* got = (string_list*)malloc(sizeof(string_list)); 176 // if (!got) { 177 // abort(); 178 // } 179 // got->value = (TCHAR*)calloc(bytes + sizeof(TCHAR), 1); 180 // if (!got->value) { 181 // abort(); 182 // } 183 // memcpy(got->value, first, bytes); 184 // got->prev = data.tail; 185 // data.tail = got; 186 // data.length++; 187 //} 188 list<TCHAR*>& data; 189 string_array_value(list<TCHAR*>& data) : data(data) {} 190 void operator()(const TCHAR* first, const TCHAR* last) const 191 { 192 ptrdiff_t bytes = (const char*)last - (const char*)first; 193 TCHAR* value = (TCHAR*)calloc(bytes + sizeof(TCHAR), 1); 194 if (!value) 195 { 196 abort(); 197 } 198 memcpy(value, first, bytes); 199 try 200 { 201 data.push_back(value); 202 } 203 catch (exception&) 204 { 205 abort(); 206 } 207 } 208 }; 209 210 ////MACRO WILL BE EXPANDED 211 //integer_value i; 212 //string_value s; 213 //integer_array_value ia; 214 //string_array_value sa; 215 216 #define I3_CONFIG_MACRO_PARSER(r, data, elem) \ 217 BOOST_PP_IF(BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(3, 0, elem), I3_CONFIG_integer) , integer_value, \ 218 BOOST_PP_IF(BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(3, 0, elem), I3_CONFIG_string) , string_value, \ 219 BOOST_PP_IF(BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(3, 0, elem), I3_CONFIG_integer_array) , integer_array_value, string_array_value))) \ 184 220 BOOST_PP_TUPLE_ELEM(3, 1, elem); 185 221 186 BOOST_PP_SEQ_FOR_EACH(I3_CONFIG_MACRO_PARSER, data, CONFIG_MEMBERS)187 188 i3::config::ConfigTemp& config;189 MyIniLoader(i3::config::ConfigTemp& config) : config(config)222 BOOST_PP_SEQ_FOR_EACH(I3_CONFIG_MACRO_PARSER, data, CONFIG_MEMBERS) 223 224 i3::config::ConfigTemp& config; 225 MyIniLoader(i3::config::ConfigTemp& config) : config(config) 190 226 ////MACRO WILL BE EXPANDED 191 227 //, i(config.i) … … 193 229 //, s(config.s) 194 230 //, sa(config.sa) 195 #define I3_CONFIG_MACRO_INITIALIZER(r, data, elem) \231 #define I3_CONFIG_MACRO_INITIALIZER(r, data, elem) \ 196 232 BOOST_PP_COMMA() BOOST_PP_TUPLE_ELEM(3, 1, elem) (config.BOOST_PP_TUPLE_ELEM(3, 1, elem)) 197 233 198 BOOST_PP_SEQ_FOR_EACH(I3_CONFIG_MACRO_INITIALIZER, data, CONFIG_MEMBERS)199 200 201 {}202 203 template<typename S> struct definition204 {205 rule<S> expr;206 rule<S> line_ending;207 definition(const MyIniLoader& self)208 {209 using namespace boost;210 211 int_parser<int32_t, 10, integer_traits<int32_t>::const_max, integer_traits<int32_t>::const_min> boost_int32_t_p;212 213 line_ending = str_p(_T("\r\n")) | ch_p(_T('\r')) | ch_p(_T('\n')) | end_p;214 expr = (215 ////MACRO WILL BE EXPANDED216 //(*blank_p >> str_p(_T("Integer")) >> +blank_p >> str_p(_T("i")) >> *blank_p >> _T("=") >> *blank_p >> int_p[self.i] >> *blank_p) |217 //(*blank_p >> str_p(_T("Integer[]")) >> +blank_p >> str_p(_T("ia")) >> *blank_p >> _T("=") >> *blank_p >> int_p[self.ia] >> *blank_p) |218 //(*blank_p >> str_p(_T("String")) >> +blank_p >> str_p(_T("s")) >> *blank_p >> _T("=") >> *blank_p >> (*(anychar_p - line_ending))[self.s]) |219 //(*blank_p >> str_p(_T("String[]")) >> +blank_p >> str_p(_T("sa")) >> *blank_p >> _T("=") >> *blank_p >> (*(anychar_p - line_ending))[self.sa]) |220 221 222 #define I3_CONFIG_MACRO_SPIRIT(r, data, elem) \234 BOOST_PP_SEQ_FOR_EACH(I3_CONFIG_MACRO_INITIALIZER, data, CONFIG_MEMBERS) 235 236 237 {} 238 239 template<typename S> struct definition 240 { 241 rule<S> expr; 242 rule<S> line_ending; 243 definition(const MyIniLoader& self) 244 { 245 using namespace boost; 246 247 int_parser<int32_t, 10, integer_traits<int32_t>::const_max, integer_traits<int32_t>::const_min> boost_int32_t_p; 248 249 line_ending = str_p(_T("\r\n")) | ch_p(_T('\r')) | ch_p(_T('\n')) | end_p; 250 expr = ( 251 ////MACRO WILL BE EXPANDED 252 //(*blank_p >> str_p(_T("Integer")) >> +blank_p >> str_p(_T("i")) >> *blank_p >> _T("=") >> *blank_p >> int_p[self.i] >> *blank_p) | 253 //(*blank_p >> str_p(_T("Integer[]")) >> +blank_p >> str_p(_T("ia")) >> *blank_p >> _T("=") >> *blank_p >> int_p[self.ia] >> *blank_p) | 254 //(*blank_p >> str_p(_T("String")) >> +blank_p >> str_p(_T("s")) >> *blank_p >> _T("=") >> *blank_p >> (*(anychar_p - line_ending))[self.s]) | 255 //(*blank_p >> str_p(_T("String[]")) >> +blank_p >> str_p(_T("sa")) >> *blank_p >> _T("=") >> *blank_p >> (*(anychar_p - line_ending))[self.sa]) | 256 257 258 #define I3_CONFIG_MACRO_SPIRIT(r, data, elem) \ 223 259 \ 224 260 (*blank_p >> str_p( \ 225 261 \ 226 BOOST_PP_IF(BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(3, 0, elem), i3_config_integer) , _T("Integer"), \227 BOOST_PP_IF(BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(3, 0, elem), i3_config_string) , _T("String"), \228 BOOST_PP_IF(BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(3, 0, elem), i3_config_integer_array) , _T("Integer[]"), _T("String[]")))) \262 BOOST_PP_IF(BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(3, 0, elem), I3_CONFIG_integer) , _T("Integer"), \ 263 BOOST_PP_IF(BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(3, 0, elem), I3_CONFIG_string) , _T("String"), \ 264 BOOST_PP_IF(BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(3, 0, elem), I3_CONFIG_integer_array) , _T("Integer[]"), _T("String[]")))) \ 229 265 \ 230 266 ) >> +blank_p >> str_p(_T( BOOST_PP_TUPLE_ELEM(3, 2, elem) )) >> *blank_p >> _T("=") >> *blank_p >> \ … … 232 268 BOOST_PP_IF( \ 233 269 BOOST_PP_OR( \ 234 BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(3, 0, elem), i3_config_integer), \235 BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(3, 0, elem), i3_config_integer_array ) \270 BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(3, 0, elem), I3_CONFIG_integer), \ 271 BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(3, 0, elem), I3_CONFIG_integer_array ) \ 236 272 ) \ 237 273 , boost_int32_t_p[self.BOOST_PP_TUPLE_ELEM(3, 1, elem)] >> *blank_p \ 238 274 , (*(anychar_p - line_ending))[self.BOOST_PP_TUPLE_ELEM(3, 1, elem)] \ 239 275 ) \ 240 ) | 241 242 BOOST_PP_SEQ_FOR_EACH(I3_CONFIG_MACRO_SPIRIT, data, CONFIG_MEMBERS) 243 244 *blank_p 245 ) 246 >> (end_p | (line_ending >> expr)); 247 } 248 const rule<S>& start() const { return expr; } 249 }; 250 }; 276 ) | 277 278 BOOST_PP_SEQ_FOR_EACH(I3_CONFIG_MACRO_SPIRIT, data, CONFIG_MEMBERS) 279 280 *blank_p 281 ) 282 >> (end_p | (line_ending >> expr)); 283 } 284 const rule<S>& start() const 285 { 286 return expr; 287 } 288 }; 289 }; 251 290 } 252 291 253 void copy_config(Config& destination, const Config& source) { 254 #define I3_CONFIG_MACRO_OPERATOR_EQ(r, data, elem) \ 292 void copy_config(Config& destination, const Config& source) 293 { 294 #define I3_CONFIG_MACRO_OPERATOR_EQ(r, data, elem) \ 255 295 destination.BOOST_PP_TUPLE_ELEM(3, 1, elem) = \ 256 296 source.BOOST_PP_TUPLE_ELEM(3, 1, elem); 257 297 258 BOOST_PP_SEQ_FOR_EACH(I3_CONFIG_MACRO_OPERATOR_EQ, data, CONFIG_MEMBERS)298 BOOST_PP_SEQ_FOR_EACH(I3_CONFIG_MACRO_OPERATOR_EQ, data, CONFIG_MEMBERS) 259 299 } 260 300 261 void load_config(Config& destination, const TCHAR* str) { 301 void load_config(Config& destination, const TCHAR* str) 302 { 262 303 using namespace i3::config; 263 304 using namespace boost::spirit; 264 305 i3::config::ConfigTemp c; 265 306 266 307 MyIniLoader i(c); 267 //const TCHAR aaa[] = 308 //const TCHAR aaa[] = 268 309 // _T("Integer[] ia = 1 \n") 269 310 // _T("String s= fooobar \r") … … 278 319 // _T("\r\r"); 279 320 280 //i3::string str = 321 //i3::string str = 281 322 // _T("Integer[] ia = 1 \n") 282 323 // _T("String s= fooobar \r") … … 291 332 // _T("\r\r"); 292 333 parse_info<const TCHAR* const> r = parse<TCHAR>(str, i); 293 try { 334 try 335 { 294 336 ////MACRO WILL BE EXPANDED 295 337 //c2.i = c.i; … … 298 340 //c2.sa.resize(c.sa.size()); std::copy(c.sa.begin(), c.sa.end(), c2.sa.begin()); 299 341 300 #define I3_CONFIG_MACRO_COPY(r, data, elem) \342 #define I3_CONFIG_MACRO_COPY(r, data, elem) \ 301 343 BOOST_PP_IF( \ 302 344 BOOST_PP_OR( \ 303 BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(3, 0, elem), i3_config_integer), \304 BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(3, 0, elem), i3_config_string ) \345 BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(3, 0, elem), I3_CONFIG_integer), \ 346 BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(3, 0, elem), I3_CONFIG_string ) \ 305 347 ) \ 306 348 , destination.BOOST_PP_TUPLE_ELEM(3, 1, elem) = c.BOOST_PP_TUPLE_ELEM(3, 1, elem) \ … … 311 353 312 354 313 } catch (std::exception&) { 355 } 356 catch (std::exception&) 357 { 314 358 abort(); 315 359 } -
lang/cplusplus/i3/trunk/src/Config.h
r23850 r24540 7 7 #include <boost/cstdint.hpp> 8 8 9 #define i3_config_integer 010 #define i3_config_string 111 #define i3_config_integer_array 212 #define i3_config_string_array 39 #define I3_CONFIG_integer 0 10 #define I3_CONFIG_string 1 11 #define I3_CONFIG_integer_array 2 12 #define I3_CONFIG_string_array 3 13 13 14 #define CONFIG_MEMBER(type, name) (( type, name, #name))14 #define CONFIG_MEMBER(type, name) ((I3_CONFIG_##type, name, #name)) 15 15 16 16 #define CONFIG_MEMBERS \ 17 CONFIG_MEMBER(i 3_config_integer, integer_key) \18 CONFIG_MEMBER( i3_config_string , string_key) \19 CONFIG_MEMBER(i 3_config_integer_array, integer_array_key) \20 CONFIG_MEMBER( i3_config_string_array, string_array_key)17 CONFIG_MEMBER(integer, integer_key) \ 18 CONFIG_MEMBER(string , string_key) \ 19 CONFIG_MEMBER(integer_array, integer_array_key) \ 20 CONFIG_MEMBER(string_array, string_array_key) 21 21 22 namespace i3 { 22 namespace i3 23 { 23 24 24 struct Config { 25 struct Config 26 { 25 27 ////MACRO WILL BE EXPANDED 26 28 //boost::int32_t i; … … 29 31 //std::vector<TCHAR*> sa; 30 32 31 #define I3_CONFIG_MACRO(r, data, elem) \32 BOOST_PP_IF(BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(3, 0, elem), i3_config_integer) , boost::int32_t, \33 BOOST_PP_IF(BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(3, 0, elem), i3_config_string) , TCHAR*, \34 BOOST_PP_IF(BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(3, 0, elem), i3_config_integer_array) , std::vector<boost::int32_t>, std::vector<TCHAR*>))) \33 #define I3_CONFIG_MACRO(r, data, elem) \ 34 BOOST_PP_IF(BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(3, 0, elem), I3_CONFIG_integer) , boost::int32_t, \ 35 BOOST_PP_IF(BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(3, 0, elem), I3_CONFIG_string) , TCHAR*, \ 36 BOOST_PP_IF(BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(3, 0, elem), I3_CONFIG_integer_array) , std::vector<boost::int32_t>, std::vector<TCHAR*>))) \ 35 37 BOOST_PP_TUPLE_ELEM(3, 1, elem); 36 38 -
lang/cplusplus/i3/trunk/src/os-unix/Os.h
r23627 r24540 15 15 # if !defined(_TCHAR_DEFINED) && !defined(TCHAR) 16 16 # define _TCHAR_DEFINED 17 namespace i3 { 18 typedef wchar_t TCHAR; 17 namespace i3 18 { 19 typedef wchar_t TCHAR; 19 20 } 20 21 # endif … … 29 30 # if !defined(_TCHAR_DEFINED) && !defined(TCHAR) 30 31 # define _TCHAR_DEFINED 31 namespace i3 { 32 typedef char TCHAR; 32 namespace i3 33 { 34 typedef char TCHAR; 33 35 } 34 36 # endif -
lang/cplusplus/i3/trunk/src/os-windows/Os.cpp
r24539 r24540 23 23 } 24 24 25 if (SHGetPathFromIDList(pidl, config_dir_path) != TRUE )25 if (SHGetPathFromIDList(pidl, config_dir_path) != TRUE) 26 26 { 27 27 // error … … 145 145 using namespace boost::spirit; 146 146 147 namespace i3 { 148 namespace windows_execute_argtable { 147 namespace i3 148 { 149 namespace windows_execute_argtable 150 { 149 151 150 152 template <int Mode, typename Result> … … 154 156 calc(Result& data) : data(data) {} 155 157 void operator()(const char* first, const char* last) const; 156 template<typename S> struct definition157 {158 rule<S> args, raw, quated;159 definition(const calc<Mode, Result>& self)160 {158 template<typename S> struct definition 159 { 160 rule<S> args, raw, quated; 161 definition(const calc<Mode, Result>& self) 162 { 161 163 args = (*space_p) >> (+(quated | raw))[self] >> (+space_p) >> args; 162 164 quated = ch_p('"') >> (*((ch_p('\\') >> (anychar_p | str_p("\r\n"))) | (anychar_p - ch_p('"') ))) >> (ch_p('"') | end_p); 163 165 raw = (+((ch_p('\\') >> (anychar_p | str_p("\r\n"))) | (anychar_p - ch_p('"') - space_p))); 164 } 165 const rule<S>& start() const { return args; } 166 }; 166 } 167 const rule<S>& start() const 168 { 169 return args; 170 } 171 }; 167 172 }; 168 173 … … 180 185 } 181 186 182 struct calc2 : public grammar<calc2> { 187 struct calc2 : public grammar<calc2> 188 { 183 189 char*& data; 184 190 calc2(char*& data) : data(data) {} 185 void operator()(char c) const { 191 void operator()(char c) const 192 { 186 193 *data = c; 187 194 data++; 188 195 } 189 template<typename S> struct definition { 190 rule<S> args; 191 definition(const calc2& self) { 196 template<typename S> struct definition 197 { 198 rule<S> args; 199 definition(const calc2& self) 200 { 192 201 args = (+((ch_p("\\") >> anychar_p[self]) | ch_p('"') | anychar_p[self])); 193 } 194 const rule<S>& start() const { return args; } 195 }; 202 } 203 const rule<S>& start() const 204 { 205 return args; 206 } 207 }; 196 208 }; 197 209 198 void calc2_helper(char* got, char* cleaned) { 210 void calc2_helper(char* got, char* cleaned) 211 { 199 212 calc2 c(cleaned); 200 213 parse_info<> r = boost::spirit::parse(got, c); … … 210 223 memset((void*)(*data), 0, buf_size); 211 224 212 if (buf_size > _ALLOCA_S_THRESHOLD) { 225 if (buf_size > _ALLOCA_S_THRESHOLD) 226 { 213 227 data++; 214 228 return; 215 229 } 216 230 217 __try { 231 __try 232 { 218 233 got = (char*)alloca(buf_size); 219 234 } __except (GetExceptionCode() == STATUS_STACK_OVERFLOW ? 220 EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) { 235 EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) 236 { 221 237 data++; 222 238 return; 223 239 } 224 240 225 __try { 241 __try 242 { 226 243 cleaned = (char*)alloca(buf_size); 227 244 } __except (GetExceptionCode() == STATUS_STACK_OVERFLOW ? 228 EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) { 245 EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) 246 { 229 247 data++; 230 248 return; … … 242 260 } 243 261 244 size_t get_argc(const char* line) { 262 size_t get_argc(const char* line) 263 { 245 264 size_t argc = 0; // must zero. 246 265 calc<0, size_t> c(argc); … … 252 271 void get_size_list(const char* line, 253 272 size_t* size_list, 254 size_t argc) { 273 size_t argc) 274 { 255 275 256 276 calc<1, size_t*> c(size_list); … … 260 280 void get_argv(const char* line, 261 281 const size_t* size_list, 262 char** argv, size_t argc) { 282 char** argv, size_t argc) 283 { 263 284 264 285 calc<2, char**> c(argv); … … 266 287 } 267 288 268 struct fp_func { 269 Utf8ToUtf16Stream& s; 270 FILE* operator()() { 271 return s.get(); 272 } 289 struct fp_func 290 { 291 Utf8ToUtf16Stream& s; 292 FILE* operator()() 293 { 294 return s.get(); 295 } 273 296 }; 274 297 275 exit_status check_args2(int argc, char** argv) { 298 exit_status check_args2(int argc, char** argv) 299 { 276 300 #if !(defined(UNICODE) || defined(_UNICODE)) 277 301 const char* codeset = bind_textdomain_codeset(PACKAGE_NAME,NULL); … … 295 319 } 296 320 297 exit_status check_args() { 321 exit_status check_args() 322 { 298 323 using namespace i3::windows_execute_argtable; 299 324 … … 302 327 size_t argc = 0; 303 328 UTF16LE_TO_UTF8_ALLOCA(GetCommandLine(), line); 304 if (!line) { 329 if (!line) 330 { 305 331 return 1; 306 332 } 307 333 { 308 334 argc = get_argc(line); 309 if (argc == 0 || argc == 1) { 335 if (argc == 0 || argc == 1) 336 { 310 337 return 0; 311 338 } … … 317 344 { 318 345 const size_t size_list_bytes = argc*sizeof(size_t); 319 if (size_list_bytes > _ALLOCA_S_THRESHOLD) { 320 return 1; 321 } 322 __try { 346 if (size_list_bytes > _ALLOCA_S_THRESHOLD) 347 { 348 return 1; 349 } 350 __try 351 { 323 352 size_list = (size_t*)alloca(size_list_bytes); 324 353 } __except (GetExceptionCode() == STATUS_STACK_OVERFLOW ? 325 EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) { 354 EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) 355 { 326 356 return 1; 327 357 } … … 334 364 get_size_list(line, size_list, argc); 335 365 const size_t argv_bytes = argc*sizeof(char*); 336 if (argv_bytes > _ALLOCA_S_THRESHOLD) { 337 return 1; 338 } 339 __try { 366 if (argv_bytes > _ALLOCA_S_THRESHOLD) 367 { 368 return 1; 369 } 370 __try 371 { 340 372 argv = (char**)alloca(argv_bytes); 341 373 } __except (GetExceptionCode() == STATUS_STACK_OVERFLOW ? 342 EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) { 374 EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) 375 { 343 376 return 1; 344 377 } … … 349 382 { 350 383 size_t argv_total_bytes = 0; 351 for (size_t i = 0; i < argc; i++) { 384 for (size_t i = 0; i < argc; i++) 385 { 352 386 argv_total_bytes += size_list[i]; 353 387 } 354 if (argv_total_bytes > _ALLOCA_S_THRESHOLD) { 388 if (argv_total_bytes > _ALLOCA_S_THRESHOLD) 389 { 355 390 return 1; 356 391 } 357 392 char* argv_pool = NULL; 358 __try { 393 __try 394 { 359 395 argv_pool = (char*)alloca(argv_total_bytes); 360 396 } __except (GetExceptionCode() == STATUS_STACK_OVERFLOW ? 361 EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) { 362 return 1; 363 } 364 for (size_t i = 0; i < argc; i++) { 397 EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) 398 { 399 return 1; 400 } 401 for (size_t i = 0; i < argc; i++) 402 { 365 403 argv[i] = argv_pool; 366 404 argv_pool += size_list[i]; -
lang/cplusplus/i3/trunk/windows/dist.rb
r23268 r24540 32 32 cp windows/fakecygpty.exe #{DIR}/misc 33 33 cp windows/Readme.libintl.txt #{DIR}/doc 34 cp po/i3.pot #{DIR}/misc 34 35 #{CRLF} AUTHORS > #{DIR}/doc/Authors.txt 35 36 #{CRLF} ChangeLog > #{DIR}/doc/ChangeLog.txt
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)