Skip to content

Commit 0133bdf

Browse files
committed
Removed unused ConverterGenerators arguments.
Updated arg_from_python<T> so that its operator() is nullary -- it already gets everything it needs in its constructor. [SVN r19948]
1 parent e563def commit 0133bdf

File tree

12 files changed

+72
-211
lines changed

12 files changed

+72
-211
lines changed

include/boost/python/arg_from_python.hpp

Lines changed: 9 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -26,51 +26,25 @@ struct arg_from_python<PyObject*>
2626
{
2727
typedef PyObject* result_type;
2828

29-
arg_from_python(PyObject*) {}
29+
arg_from_python(PyObject* p) : m_source(p) {}
3030
bool convertible() const { return true; }
31-
PyObject* operator()(PyObject* source) const { return source; }
31+
PyObject* operator()() const { return m_source; }
32+
private:
33+
PyObject* m_source;
3234
};
3335

3436
template <>
3537
struct arg_from_python<PyObject* const&>
3638
{
3739
typedef PyObject* const& result_type;
38-
arg_from_python(PyObject*) {}
40+
41+
arg_from_python(PyObject* p) : m_source(p) {}
3942
bool convertible() const { return true; }
40-
PyObject*const& operator()(PyObject*const& source) const { return source; }
43+
PyObject*const& operator()() const { return m_source; }
44+
private:
45+
PyObject* m_source;
4146
};
4247

43-
namespace detail
44-
{
45-
//
46-
// Meta-iterators for use with caller<>
47-
//
48-
49-
// temporary hack
50-
template <class T> struct nullary : T
51-
{
52-
nullary(PyObject* x) : T(x), m_p(x) {}
53-
typename T::result_type operator()() { return this->T::operator()(m_p); }
54-
PyObject* m_p;
55-
};
56-
57-
// An MPL metafunction class which returns arg_from_python<ArgType>
58-
struct gen_arg_from_python
59-
{
60-
template <class ArgType> struct apply
61-
{
62-
typedef nullary<arg_from_python<ArgType> > type;
63-
};
64-
};
65-
66-
// An MPL iterator over an endless sequence of gen_arg_from_python
67-
struct args_from_python
68-
{
69-
typedef gen_arg_from_python type;
70-
typedef args_from_python next;
71-
};
72-
}
73-
7448
//
7549
// implementations
7650
//

include/boost/python/converter/arg_from_python.hpp

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ struct pointer_cref_arg_from_python
4444
typedef T result_type;
4545

4646
pointer_cref_arg_from_python(PyObject*);
47-
T operator()(PyObject*) const;
47+
T operator()() const;
4848
bool convertible() const;
4949

5050
private: // storage for a U*
@@ -74,7 +74,7 @@ struct pointer_arg_from_python : arg_lvalue_from_python_base
7474
typedef T result_type;
7575

7676
pointer_arg_from_python(PyObject*);
77-
T operator()(PyObject*) const;
77+
T operator()() const;
7878
};
7979

8080
// Used when T == U& and (T != V const& or T == W volatile&)
@@ -84,7 +84,7 @@ struct reference_arg_from_python : arg_lvalue_from_python_base
8484
typedef T result_type;
8585

8686
reference_arg_from_python(PyObject*);
87-
T operator()(PyObject*) const;
87+
T operator()() const;
8888
};
8989

9090
// ===================
@@ -114,10 +114,11 @@ struct arg_rvalue_from_python
114114
# if BOOST_MSVC < 1301 || _MSC_FULL_VER > 13102196
115115
typename arg_rvalue_from_python<T>::
116116
# endif
117-
result_type operator()(PyObject*);
117+
result_type operator()();
118118

119119
private:
120120
rvalue_from_python_data<result_type> m_data;
121+
PyObject* m_source;
121122
};
122123

123124

@@ -132,9 +133,10 @@ struct back_reference_arg_from_python
132133
typedef T result_type;
133134

134135
back_reference_arg_from_python(PyObject*);
135-
T operator()(PyObject*);
136+
T operator()();
136137
private:
137138
typedef boost::python::arg_from_python<typename T::type> base;
139+
PyObject* m_source;
138140
};
139141

140142

@@ -259,9 +261,9 @@ inline bool pointer_cref_arg_from_python<T>::convertible() const
259261
return python::detail::void_ptr_to_reference(m_result.bytes, (T(*)())0) != 0;
260262
}
261263
template <class T>
262-
inline T pointer_cref_arg_from_python<T>::operator()(PyObject* p) const
264+
inline T pointer_cref_arg_from_python<T>::operator()() const
263265
{
264-
return (p == Py_None) // None ==> 0
266+
return (*(void**)m_result.bytes == Py_None) // None ==> 0
265267
? detail::null_ptr_reference((T(*)())0)
266268
// Otherwise, return a U*const& to the m_result storage.
267269
: python::detail::void_ptr_to_reference(m_result.bytes, (T(*)())0);
@@ -277,9 +279,9 @@ inline pointer_arg_from_python<T>::pointer_arg_from_python(PyObject* p)
277279
}
278280

279281
template <class T>
280-
inline T pointer_arg_from_python<T>::operator()(PyObject* p) const
282+
inline T pointer_arg_from_python<T>::operator()() const
281283
{
282-
return (p == Py_None) ? 0 : T(result());
284+
return (result() == Py_None) ? 0 : T(result());
283285
}
284286

285287
// reference_arg_from_python
@@ -291,7 +293,7 @@ inline reference_arg_from_python<T>::reference_arg_from_python(PyObject* p)
291293
}
292294

293295
template <class T>
294-
inline T reference_arg_from_python<T>::operator()(PyObject*) const
296+
inline T reference_arg_from_python<T>::operator()() const
295297
{
296298
return python::detail::void_ptr_to_reference(result(), (T(*)())0);
297299
}
@@ -302,6 +304,7 @@ inline T reference_arg_from_python<T>::operator()(PyObject*) const
302304
template <class T>
303305
inline arg_rvalue_from_python<T>::arg_rvalue_from_python(PyObject* obj)
304306
: m_data(converter::rvalue_from_python_stage1(obj, registered<T>::converters))
307+
, m_source(obj)
305308
{
306309
}
307310

@@ -313,10 +316,10 @@ inline bool arg_rvalue_from_python<T>::convertible() const
313316

314317
template <class T>
315318
inline typename arg_rvalue_from_python<T>::result_type
316-
arg_rvalue_from_python<T>::operator()(PyObject* p)
319+
arg_rvalue_from_python<T>::operator()()
317320
{
318321
if (m_data.stage1.construct != 0)
319-
m_data.stage1.construct(p, &m_data.stage1);
322+
m_data.stage1.construct(m_source, &m_data.stage1);
320323

321324
return python::detail::void_ptr_to_reference(m_data.stage1.convertible, (result_type(*)())0);
322325
}
@@ -325,15 +328,15 @@ arg_rvalue_from_python<T>::operator()(PyObject* p)
325328
//
326329
template <class T>
327330
back_reference_arg_from_python<T>::back_reference_arg_from_python(PyObject* x)
328-
: base(x)
331+
: base(x), m_source(x)
329332
{
330333
}
331334

332335
template <class T>
333336
inline T
334-
back_reference_arg_from_python<T>::operator()(PyObject* x)
337+
back_reference_arg_from_python<T>::operator()()
335338
{
336-
return T(x, base::operator()(x));
339+
return T(m_source, base::operator()());
337340
}
338341

339342
}}} // namespace boost::python::converter

include/boost/python/converter/obj_mgr_arg_from_python.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ struct object_manager_value_arg_from_python
2727

2828
object_manager_value_arg_from_python(PyObject*);
2929
bool convertible() const;
30-
T operator()(PyObject*) const;
30+
T operator()() const;
3131
private:
3232
PyObject* m_source;
3333
};
@@ -48,7 +48,7 @@ struct object_manager_ref_arg_from_python
4848

4949
object_manager_ref_arg_from_python(PyObject*);
5050
bool convertible() const;
51-
Ref operator()(PyObject*) const;
51+
Ref operator()() const;
5252
~object_manager_ref_arg_from_python();
5353
private:
5454
typename python::detail::referent_storage<Ref>::type m_result;
@@ -71,9 +71,9 @@ inline bool object_manager_value_arg_from_python<T>::convertible() const
7171
}
7272

7373
template <class T>
74-
inline T object_manager_value_arg_from_python<T>::operator()(PyObject* x) const
74+
inline T object_manager_value_arg_from_python<T>::operator()() const
7575
{
76-
return T(python::detail::borrowed_reference(x));
76+
return T(python::detail::borrowed_reference(m_source));
7777
}
7878

7979
template <class Ref>
@@ -111,7 +111,7 @@ inline bool object_manager_ref_arg_from_python<Ref>::convertible() const
111111
}
112112

113113
template <class Ref>
114-
inline Ref object_manager_ref_arg_from_python<Ref>::operator()(PyObject*) const
114+
inline Ref object_manager_ref_arg_from_python<Ref>::operator()() const
115115
{
116116
return python::detail::void_ptr_to_reference(
117117
this->m_result.bytes, (Ref(*)())0);

include/boost/python/converter/pytype_arg_from_python.hpp

Lines changed: 0 additions & 99 deletions
This file was deleted.

include/boost/python/data_members.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ namespace detail
6969

7070
if (!policies.precall(args_)) return 0;
7171

72-
PyObject* result = cr( (c0(PyTuple_GET_ITEM(args_, 0)))->*pm );
72+
PyObject* result = cr( (c0())->*pm );
7373

7474
return policies.postcall(args_, result);
7575
}
@@ -88,7 +88,7 @@ namespace detail
8888

8989
if (!policies.precall(args_)) return 0;
9090

91-
(c0(PyTuple_GET_ITEM(args_, 0))).*pm = c1(PyTuple_GET_ITEM(args_, 1));
91+
(c0()).*pm = c1();
9292

9393
return policies.postcall(args_, detail::none());
9494
}
@@ -128,7 +128,7 @@ namespace detail
128128

129129
if (!policies.precall(args_)) return 0;
130130

131-
*p = c0(PyTuple_GET_ITEM(args_, 0));
131+
*p = c0();
132132

133133
return policies.postcall(args_, detail::none());
134134
}

0 commit comments

Comments
 (0)