Changeset 23721 for lang/cplusplus

Show
Ignore:
Timestamp:
11/14/08 23:47:09 (5 years ago)
Author:
saturday06
Message:

とおった

Location:
lang/cplusplus/i3/trunk/src
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lang/cplusplus/i3/trunk/src/Common.h

    r23714 r23721  
    2121#include <libintl.h> 
    2222//#include <argtable2.h> 
    23 #ifdef MOL_OS_unix 
     23#ifdef MOL_OS_UNIX 
    2424#include <popt.h> 
    2525#endif 
     
    143143#undef WINDOWS_SEH_EXCEPT 
    144144 
    145 #ifdef MOL_OS_unix 
     145#ifdef MOL_OS_UNIX 
    146146 
    147147namespace i3 
     
    333333 
    334334#endif 
    335  
  • lang/cplusplus/i3/trunk/src/Test2.cpp

    r23617 r23721  
    1010#include <boost/preprocessor/seq/for_each.hpp> 
    1111 
    12 #define CONFIG_NAMES (a)(b)(x)(y) 
     12#include <boost/preprocessor/control/if.hpp> 
    1313 
    14 #define MACRO_DEFINE_MEMBERS(r, data, elem) uintptr_t elem; 
     14int BOOST_PP_IF(10, a, b); // expands to a 
     15int BOOST_PP_IF(0, c, d); // expands to b 
     16 
     17//#define CONFIG_NAMES (a)(b)(x)(y) 
     18//#define MACRO_DEFINE_MEMBERS(r, data, elem) uintptr_t elem; 
     19 
     20#define pp_integer       0 
     21#define pp_string        1 
     22#define pp_integer_array 2 
     23#define pp_string_array  3 
     24 
     25#define CONFIG_NAMES (( \ 
     26    pp_integer       , a ))(( \ 
     27    pp_string        , b ))(( \ 
     28    pp_integer_array , x ))(( \ 
     29    pp_string_array  , y ))(( \ 
     30    pp_integer       , dummy )) 
     31 
     32#define MACRO_DEFINE_MEMBERS(r, data, elem) \ 
     33            BOOST_PP_IF(BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(2, 0, elem), pp_integer) , int, \ 
     34                    BOOST_PP_IF(BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(2, 0, elem), pp_string) , char*, \ 
     35                        BOOST_PP_IF(BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(2, 0, elem), pp_integer_array) , int*, char**))) \ 
     36            BOOST_PP_TUPLE_ELEM(2, 1, elem); 
     37 
     38#define MACRO_DEFINE_SIZE_MEMBERS(r, data, elem) \ 
     39            BOOST_PP_IF( \ 
     40                BOOST_PP_OR( \ 
     41                    BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(2, 0, elem), pp_integer_array), \ 
     42                    BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(2, 0, elem), pp_string_array ) \ 
     43                ) \ 
     44                , size_t BOOST_PP_TUPLE_ELEM(2, 1, elem);,  ) 
    1545 
    1646namespace i3 { 
    1747struct Config { 
    1848BOOST_PP_SEQ_FOR_EACH(MACRO_DEFINE_MEMBERS, data, CONFIG_NAMES) 
     49}; 
     50struct ConfigArrayLength { 
     51BOOST_PP_SEQ_FOR_EACH(MACRO_DEFINE_SIZE_MEMBERS, data, CONFIG_NAMES) 
    1952}; 
    2053} 
     
    2457    Config c; 
    2558    c.a = 12345; 
    26  
    27     c.b = reinterpret_cast<decltype(c.b)>(&c); 
    28  
    29     BOOST_CHECK((Config*)(decltype(c.b))(&c) == &c); 
     59    char d = 'c'; 
     60    c.b = &d; 
     61    c.x = &c.a; 
     62    c.y = &c.b; 
     63    //c.b = reinterpret_cast<decltype(c.b)>(&c); 
     64    //BOOST_CHECK((Config*)(decltype(c.b))(&c) == &c); 
    3065 
    3166    using namespace std;