• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright David Abrahams 2004. Distributed under the Boost
2 // Software License, Version 1.0. (See accompanying
3 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
4 #include <boost/python/converter/arg_from_python.hpp>
5 #include <boost/python/type_id.hpp>
6 #include <iostream>
7 
8 // gcc 2.95.x, MIPSpro 7.3.1.3 and IBM XL for Linux linker seem to demand this definition
9 #if (defined(__GNUC__) && (__GNUC__ < 3)) \
10  || (defined(__sgi) && defined(__EDG_VERSION__) && (__EDG_VERSION__ == 238)) \
11  || (defined(__IBMCPP__) && defined(__linux__))
12 namespace boost { namespace python {
handle_exception_impl(function0<void>)13 BOOST_PYTHON_DECL bool handle_exception_impl(function0<void>)
14 {
15     return true;
16 }
17 }}
18 #endif
19 
20 int result;
21 
22 #define ASSERT_SAME(T1,T2) \
23        if (!is_same< T1, T2 >::value) { \
24              std::cout << "*********************\n"; \
25              std::cout << python::type_id< T1 >() << " != " << python::type_id< T2 >() << "\n"; \
26              std::cout << "*********************\n"; \
27              result = 1; \
28        }
29 
main()30 int main()
31 {
32     using namespace boost::python::converter;
33     using namespace boost;
34 
35 
36     ASSERT_SAME(
37         select_arg_from_python<int>::type, arg_rvalue_from_python<int>
38         );
39 
40     ASSERT_SAME(
41         select_arg_from_python<int const>::type, arg_rvalue_from_python<int const>
42         );
43 
44     ASSERT_SAME(
45         select_arg_from_python<int volatile>::type, arg_rvalue_from_python<int volatile>
46         );
47 
48     ASSERT_SAME(
49         select_arg_from_python<int const volatile>::type, arg_rvalue_from_python<int const volatile>
50         );
51 
52 
53 
54     ASSERT_SAME(
55         select_arg_from_python<int*>::type, pointer_arg_from_python<int*>
56         );
57 
58     ASSERT_SAME(
59         select_arg_from_python<int const*>::type, pointer_arg_from_python<int const*>
60         );
61 
62     ASSERT_SAME(
63         select_arg_from_python<int volatile*>::type, pointer_arg_from_python<int volatile*>
64         );
65 
66     ASSERT_SAME(
67         select_arg_from_python<int const volatile*>::type, pointer_arg_from_python<int const volatile*>
68         );
69 
70 
71 
72 
73     ASSERT_SAME(
74         select_arg_from_python<int&>::type, reference_arg_from_python<int&>
75         );
76 
77     ASSERT_SAME(
78         select_arg_from_python<int const&>::type, arg_rvalue_from_python<int const&>
79         );
80 
81     ASSERT_SAME(
82         select_arg_from_python<int volatile&>::type, reference_arg_from_python<int volatile&>
83         );
84 
85     ASSERT_SAME(
86         select_arg_from_python<int const volatile&>::type, reference_arg_from_python<int const volatile&>
87         );
88 
89 
90 
91     ASSERT_SAME(
92         select_arg_from_python<int*&>::type, reference_arg_from_python<int*&>
93         );
94 
95     ASSERT_SAME(
96         select_arg_from_python<int const*&>::type, reference_arg_from_python<int const*&>
97         );
98 
99     ASSERT_SAME(
100         select_arg_from_python<int volatile*&>::type, reference_arg_from_python<int volatile*&>
101         );
102 
103     ASSERT_SAME(
104         select_arg_from_python<int const volatile*&>::type, reference_arg_from_python<int const volatile*&>
105         );
106 
107 
108 
109     ASSERT_SAME(
110         select_arg_from_python<int* const&>::type, pointer_cref_arg_from_python<int*const&>
111         );
112 
113     ASSERT_SAME(
114         select_arg_from_python<int const* const&>::type, pointer_cref_arg_from_python<int const*const&>
115         );
116 
117     ASSERT_SAME(
118         select_arg_from_python<int volatile* const&>::type, pointer_cref_arg_from_python<int volatile*const&>
119         );
120 
121     ASSERT_SAME(
122         select_arg_from_python<int const volatile* const&>::type, pointer_cref_arg_from_python<int const volatile*const&>
123         );
124 
125 
126 
127     ASSERT_SAME(
128         select_arg_from_python<int*volatile&>::type, reference_arg_from_python<int*volatile&>
129         );
130 
131     ASSERT_SAME(
132         select_arg_from_python<int const*volatile&>::type, reference_arg_from_python<int const*volatile&>
133         );
134 
135     ASSERT_SAME(
136         select_arg_from_python<int volatile*volatile&>::type, reference_arg_from_python<int volatile*volatile&>
137         );
138 
139     ASSERT_SAME(
140         select_arg_from_python<int const volatile*volatile&>::type, reference_arg_from_python<int const volatile*volatile&>
141         );
142 
143 
144 
145     ASSERT_SAME(
146         select_arg_from_python<int*const volatile&>::type, reference_arg_from_python<int*const volatile&>
147         );
148 
149     ASSERT_SAME(
150         select_arg_from_python<int const*const volatile&>::type, reference_arg_from_python<int const*const volatile&>
151         );
152 
153     ASSERT_SAME(
154         select_arg_from_python<int volatile*const volatile&>::type, reference_arg_from_python<int volatile*const volatile&>
155         );
156 
157     ASSERT_SAME(
158         select_arg_from_python<int const volatile*const volatile&>::type, reference_arg_from_python<int const volatile*const volatile&>
159         );
160     return result;
161 }
162