Skip to content

Commit 0bbfa9b

Browse files
committed
removed signature<...> and updated defaults.cpp test
[SVN r15071]
1 parent 2cad1b3 commit 0bbfa9b

File tree

2 files changed

+44
-251
lines changed

2 files changed

+44
-251
lines changed

include/boost/python/signature.hpp

Lines changed: 32 additions & 239 deletions
Original file line numberDiff line numberDiff line change
@@ -21,68 +21,27 @@
2121
#include <boost/mpl/type_list.hpp>
2222

2323
///////////////////////////////////////////////////////////////////////////////
24-
namespace boost { namespace python {
25-
26-
///////////////////////////////////////////////////////////////////////////////
27-
//
28-
// signature
29-
//
30-
// This template struct acts as a type holder for the signature of a
31-
// function or member function. This struct is used to pass in the
32-
// return type, class (for member functions) and arguments of a
33-
// function or member function. Examples:
34-
//
35-
// signature<int(*)(int)> int foo(int)
36-
// signature<void(*)(int, int)> void foo(int, int)
37-
// signature<void(C::*)(int)> void C::foo(int, int)
38-
// signature<void(C::*)(int) const> void C::foo(int, int) const
39-
//
40-
///////////////////////////////////////////////////////////////////////////////
41-
template <typename T>
42-
struct signature {};
43-
44-
namespace detail {
24+
namespace boost { namespace python { namespace detail {
4525

4626
///////////////////////////////////////////////////////////////////////////////
4727
//
4828
// The following macros generate expansions for:
4929
//
50-
// template <typename RT, typename T0... typename TN>
51-
// inline boost::mpl::type_list<RT, T0...TN>
52-
// get_signature(signature<RT(*)(T0...TN)>)
53-
// {
54-
// return boost::mpl::type_list<RT, T0...TN>();
55-
// }
56-
//
57-
// template <typename RT, typename T0... typename TN>
30+
// template <class RT, class T0... class TN>
5831
// inline boost::mpl::type_list<RT, T0...TN>
5932
// get_signature(RT(*)(T0...TN))
6033
// {
6134
// return boost::mpl::type_list<RT, T0...TN>();
6235
// }
6336
//
64-
// template <typename RT, typename ClassT, typename T0... typename TN>
65-
// inline boost::mpl::type_list<RT, ClassT, T0...TN>
66-
// get_signature(signature<RT(ClassT::*)(T0...TN))>)
67-
// {
68-
// return boost::mpl::type_list<RT, ClassT, T0...TN>();
69-
// }
70-
//
71-
// template <typename RT, typename ClassT, typename T0... typename TN>
72-
// inline boost::mpl::type_list<RT, ClassT, T0...TN>
73-
// get_signature(signature<RT(ClassT::*)(T0...TN) const)>)
74-
// {
75-
// return boost::mpl::type_list<RT, ClassT const, T0...TN>();
76-
// }
77-
//
78-
// template <typename RT, typename ClassT, typename T0... typename TN>
37+
// template <class RT, class ClassT, class T0... class TN>
7938
// inline boost::mpl::type_list<RT, ClassT, T0...TN>
8039
// get_signature(RT(ClassT::*)(T0...TN)))
8140
// {
8241
// return boost::mpl::type_list<RT, ClassT, T0...TN>();
8342
// }
8443
//
85-
// template <typename RT, typename ClassT, typename T0... typename TN>
44+
// template <class RT, class ClassT, class T0... class TN>
8645
// inline boost::mpl::type_list<RT, ClassT, T0...TN>
8746
// get_signature(RT(ClassT::*)(T0...TN) const))
8847
// {
@@ -93,14 +52,14 @@ namespace detail {
9352
// and arguments of the input signature and stuffs them in an mpl::type_list.
9453
//
9554
///////////////////////////////////////////////////////////////////////////////
96-
#define BPL_IMPL_TEMPLATE_GEN(INDEX, DATA) typename BOOST_PP_CAT(T, INDEX)
55+
#define BOOST_PYTHON_TEMPLATE_GEN(INDEX, DATA) class BOOST_PP_CAT(T, INDEX)
9756

9857
///////////////////////////////////////////////////////////////////////////////
9958
#define BOOST_PP_ITERATION_PARAMS_1 \
10059
(3, (0, BOOST_PYTHON_MAX_ARITY-1, <boost/python/signature.hpp>))
10160

10261
#include BOOST_PP_ITERATE()
103-
#undef BPL_IMPL_TEMPLATE_GEN
62+
#undef BOOST_PYTHON_TEMPLATE_GEN
10463

10564
}
10665

@@ -109,218 +68,52 @@ namespace detail {
10968
///////////////////////////////////////////////////////////////////////////////
11069
#endif // SIGNATURE_JDG20020813_HPP
11170

112-
11371
#else // defined(BOOST_PP_IS_ITERATING)
11472
// PP vertical iteration code
11573

11674
///////////////////////////////////////////////////////////////////////////////
117-
#if !(defined(BOOST_MSVC) && (BOOST_MSVC <= 1200))
118-
119-
template
120-
<
121-
typename RT BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
122-
BOOST_PP_ENUM
123-
(
124-
BOOST_PP_ITERATION(),
125-
BPL_IMPL_TEMPLATE_GEN,
126-
BOOST_PP_EMPTY
127-
)
128-
>
129-
inline boost::mpl::type_list
130-
<
131-
RT BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
132-
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)
133-
>
134-
get_signature
135-
(signature<RT(*)(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T))>)
136-
{
137-
return boost::mpl::type_list
138-
<
139-
RT BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
140-
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)
141-
>();
142-
}
143-
144-
#endif // !(defined(BOOST_MSVC) && (BOOST_MSVC <= 1200))
145-
146-
///////////////////////////////////////
147-
#if !(defined(BOOST_MSVC) && (BOOST_MSVC <= 1300))
148-
149-
# if defined(__MWERKS__) && __MWERKS__ <= 0x3002 && BOOST_PP_ITERATION() == 0
150-
template <typename RT>
151-
inline boost::mpl::type_list<RT>
152-
get_signature(signature<RT(void)>)
153-
{
154-
return boost::mpl::type_list<RT>();
155-
}
156-
# else
157-
template
158-
<
159-
typename RT BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
160-
BOOST_PP_ENUM
161-
(
162-
BOOST_PP_ITERATION(),
163-
BPL_IMPL_TEMPLATE_GEN,
164-
BOOST_PP_EMPTY
165-
)
166-
>
167-
inline boost::mpl::type_list
168-
<
75+
template <
76+
class RT BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
77+
BOOST_PP_ENUM(BOOST_PP_ITERATION(), BOOST_PYTHON_TEMPLATE_GEN, BOOST_PP_EMPTY)>
78+
inline boost::mpl::type_list<
16979
RT BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
170-
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)
171-
>
172-
get_signature(
173-
signature<
174-
RT(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T))
175-
>)
80+
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)>
81+
get_signature(RT(*)(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)))
17682
{
177-
return boost::mpl::type_list
178-
<
83+
return boost::mpl::type_list<
17984
RT BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
180-
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)
181-
>();
182-
}
183-
# endif
184-
185-
#endif // !(defined(BOOST_MSVC) && (BOOST_MSVC <= 1300))
186-
187-
///////////////////////////////////////
188-
template
189-
<
190-
typename RT BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
191-
BOOST_PP_ENUM
192-
(
193-
BOOST_PP_ITERATION(),
194-
BPL_IMPL_TEMPLATE_GEN,
195-
BOOST_PP_EMPTY
196-
)
197-
>
198-
inline boost::mpl::type_list
199-
<
200-
RT BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
201-
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)
202-
>
203-
get_signature
204-
(RT(*)(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)))
205-
{
206-
return boost::mpl::type_list
207-
<
208-
RT BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
209-
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)
210-
>();
85+
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)>();
21186
}
21287

21388
///////////////////////////////////////////////////////////////////////////////
21489
#if BOOST_PP_ITERATION() <= (BOOST_PYTHON_MAX_ARITY - 2)
21590

216-
#if !(defined(BOOST_MSVC) && (BOOST_MSVC <= 1200))
217-
218-
template
219-
<
220-
typename RT, typename ClassT BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
221-
BOOST_PP_ENUM
222-
(
223-
BOOST_PP_ITERATION(),
224-
BPL_IMPL_TEMPLATE_GEN,
225-
BOOST_PP_EMPTY
226-
)
227-
>
228-
inline boost::mpl::type_list
229-
<
91+
template <
92+
class RT, class ClassT BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
93+
BOOST_PP_ENUM(BOOST_PP_ITERATION(), BOOST_PYTHON_TEMPLATE_GEN, BOOST_PP_EMPTY)>
94+
inline boost::mpl::type_list<
23095
RT, ClassT BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
231-
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)
232-
>
233-
get_signature
234-
(signature<RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T))>)
96+
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)>
97+
get_signature(RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)))
23598
{
236-
return boost::mpl::type_list
237-
<
99+
return boost::mpl::type_list<
238100
RT, ClassT BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
239-
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)>
240-
();
101+
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)>();
241102
}
242103

243104
///////////////////////////////////////
244-
template
245-
<
246-
typename RT, typename ClassT BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
247-
BOOST_PP_ENUM
248-
(
249-
BOOST_PP_ITERATION(),
250-
BPL_IMPL_TEMPLATE_GEN,
251-
BOOST_PP_EMPTY
252-
)
253-
>
254-
inline boost::mpl::type_list
255-
<
105+
template <
106+
class RT, class ClassT BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
107+
BOOST_PP_ENUM(BOOST_PP_ITERATION(), BOOST_PYTHON_TEMPLATE_GEN, BOOST_PP_EMPTY)>
108+
inline boost::mpl::type_list<
256109
RT, ClassT const BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
257-
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)
258-
>
259-
get_signature
260-
(signature<RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)) const>)
261-
{
262-
return boost::mpl::type_list
263-
<
264-
RT, ClassT const
265-
BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
266-
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)
267-
>();
268-
}
269-
270-
#endif // !(defined(BOOST_MSVC) && (BOOST_MSVC <= 1200))
271-
272-
///////////////////////////////////////
273-
template
274-
<
275-
typename RT, typename ClassT BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
276-
BOOST_PP_ENUM
277-
(
278-
BOOST_PP_ITERATION(),
279-
BPL_IMPL_TEMPLATE_GEN,
280-
BOOST_PP_EMPTY
281-
)
282-
>
283-
inline boost::mpl::type_list
284-
<
285-
RT, ClassT BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
286-
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)
287-
>
288-
get_signature
289-
(RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)))
290-
{
291-
return boost::mpl::type_list
292-
<
293-
RT, ClassT BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
294-
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)
295-
>();
296-
}
297-
298-
///////////////////////////////////////
299-
template
300-
<
301-
typename RT, typename ClassT BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
302-
BOOST_PP_ENUM
303-
(
304-
BOOST_PP_ITERATION(),
305-
BPL_IMPL_TEMPLATE_GEN,
306-
BOOST_PP_EMPTY
307-
)
308-
>
309-
inline boost::mpl::type_list
310-
<
311-
RT, ClassT const
312-
BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
313-
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)
314-
>
315-
get_signature
316-
(RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)) const)
110+
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)>
111+
get_signature(RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)) const)
317112
{
318-
return boost::mpl::type_list
319-
<
320-
RT, ClassT const
321-
BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
322-
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)
323-
>();
113+
return boost::mpl::type_list<
114+
RT, ClassT const
115+
BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
116+
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)>();
324117
}
325118

326119
#endif // BOOST_PP_ITERATION() < (BOOST_PYTHON_MAX_ARITY - 2)

test/defaults.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ using namespace std;
1717

1818
char const* const format = "int(%s); char(%s); string(%s); double(%s); ";
1919

20+
///////////////////////////////////////////////////////////////////////////////
21+
//
22+
// Overloaded functions
23+
//
2024
///////////////////////////////////////////////////////////////////////////////
2125
object
2226
bar(int a, char b, std::string c, double d)
@@ -44,6 +48,10 @@ bar(int a)
4448

4549
BOOST_PYTHON_FUNCTION_GENERATOR(bar_stubs, bar, 1, 4)
4650

51+
///////////////////////////////////////////////////////////////////////////////
52+
//
53+
// Functions with default arguments
54+
//
4755
///////////////////////////////////////////////////////////////////////////////
4856
object
4957
foo(int a, char b = 'D', std::string c = "default", double d = 0.0)
@@ -54,7 +62,10 @@ foo(int a, char b = 'D', std::string c = "default", double d = 0.0)
5462
BOOST_PYTHON_FUNCTION_GENERATOR(foo_stubs, foo, 1, 4)
5563

5664
///////////////////////////////////////////////////////////////////////////////
57-
65+
//
66+
// Overloaded member functions with default arguments
67+
//
68+
///////////////////////////////////////////////////////////////////////////////
5869
struct X {
5970

6071
object
@@ -92,24 +103,13 @@ BOOST_PYTHON_MODULE_INIT(defaults_ext)
92103
{
93104
module("defaults_ext")
94105
.def("foo", foo, foo_stubs())
95-
96-
#if !(defined(BOOST_MSVC) && (BOOST_MSVC <= 1200))
97-
.def("bar", signature<object(*)(int, char, std::string, double)>(), bar_stubs())
98-
#else // signature does not work on VC6 only (VC7 is ok)
99106
.def("bar", (object(*)(int, char, std::string, double))0, bar_stubs())
100-
#endif
101107
;
102108

103109
class_<X>("X")
104110
.def("bar", &X::bar, X_bar_stubs())
105111
.def("foo", (object(X::*)(std::string, bool) const)0, X_foo_2_stubs())
106-
107-
#if !(defined(BOOST_MSVC) && (BOOST_MSVC <= 1200))
108-
.def("foo", signature<object(X::*)(int, bool) const>(), X_foo_2_stubs())
109-
#else // signature does not work on VC6 only (VC7 is ok)
110112
.def("foo", (object(X::*)(int, bool) const)0, X_foo_2_stubs())
111-
#endif
112-
113113
.def("foo", (object(X::*)(list, list, bool) const)0, X_foo_3_stubs())
114114
;
115115
}

0 commit comments

Comments
 (0)