Skip to content

Commit da59799

Browse files
committed
class.hpp, object/select_holder.hpp, object/pointer_holder.hpp -
fix a problem which was causing value_holder<T> to be instantiated on abstract classes. Now we compute the held_type at an outer level thereby avoiding the inner instantiation. object_core.hpp - workarounds for GCC 2.x bugs suite/indexing/detail/indexing_suite_detail.hpp - workaround for a CWPro8 bug [SVN r19635]
1 parent d8c7e75 commit da59799

File tree

5 files changed

+42
-20
lines changed

5 files changed

+42
-20
lines changed

include/boost/python/class.hpp

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -585,19 +585,14 @@ inline void class_<T,X1,X2,X3>::register_() const
585585
objects::register_class_from_python<T,bases>();
586586

587587
typedef BOOST_DEDUCED_TYPENAME holder_selector::type select_holder;
588-
typedef BOOST_DEDUCED_TYPENAME select_holder::type holder;
589-
typedef BOOST_DEDUCED_TYPENAME holder::held_type held_t;
588+
typedef BOOST_DEDUCED_TYPENAME select_holder::held_type held_t;
590589

591590
detail::register_wrapper_class<held_t,T>();
592591

593592
detail::register_class_to_python<T>(
594593
mpl::bool_<is_copyable>()
595-
# if BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
596-
, holder_selector::execute((held_type*)0)
597-
# else
598-
, BOOST_DEDUCED_TYPENAME holder_selector::type()
599-
# endif
600-
);
594+
, BOOST_DEDUCED_TYPENAME holder_selector::type()
595+
);
601596
}
602597

603598
template <class T, class X1, class X2, class X3>
@@ -606,11 +601,7 @@ inline class_<T,X1,X2,X3>::class_(char const* name, char const* doc)
606601
{
607602
this->register_();
608603
this->set_instance_size(holder_selector::additional_size());
609-
# if BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
610-
holder_selector::execute((held_type*)0).assert_default_constructible();
611-
# else
612604
holder_selector::type::assert_default_constructible();
613-
# endif
614605
this->def(init<>());
615606
}
616607

include/boost/python/object/pointer_holder.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ bool is_null(T* p, int)
5252
template <class Pointer, class Value>
5353
struct pointer_holder : instance_holder
5454
{
55-
typedef Value held_type;
5655
typedef Value value_type;
5756

5857
pointer_holder(Pointer);
@@ -75,6 +74,7 @@ template <class Pointer, class Value>
7574
struct pointer_holder_back_reference : instance_holder
7675
{
7776
typedef typename python::pointee<Pointer>::type held_type;
77+
private:
7878
typedef Value value_type;
7979

8080
// Not sure about this one -- can it work? The source object

include/boost/python/object/select_holder.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ namespace detail
109109
, value_holder<T>
110110
>::type type;
111111

112+
typedef Held held_type;
113+
112114
static inline void register_() {}
113115

114116
static type* get() { return 0; }
@@ -136,6 +138,8 @@ namespace detail
136138
, pointer_holder<Ptr,T>
137139
>::type type;
138140

141+
typedef typename pointee<Ptr>::type held_type;
142+
139143
static inline void register_()
140144
{
141145
select_pointer_holder::register_(use_back_ref());

include/boost/python/object_core.hpp

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
# include <boost/type_traits/is_same.hpp>
3636
# include <boost/type_traits/is_convertible.hpp>
37+
# include <boost/type_traits/remove_reference.hpp>
3738

3839
# if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
3940
# include <boost/type_traits/add_pointer.hpp>
@@ -217,6 +218,7 @@ namespace api
217218
PyObject* m_ptr;
218219
};
219220

221+
# if BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
220222
template <class T, class U>
221223
struct is_derived_impl
222224
{
@@ -235,26 +237,51 @@ namespace api
235237
struct is_derived
236238
: mpl::bool_<is_derived_impl<T,U>::value>
237239
{};
240+
# else
241+
template <class T, class U>
242+
struct is_derived
243+
: is_convertible<
244+
typename remove_reference<T>::type*
245+
, U const*
246+
>
247+
{};
248+
# endif
238249

239250
template <class T>
240251
typename objects::unforward_cref<T>::type do_unforward_cref(T const& x)
241252
{
253+
# if BOOST_WORKAROUND(__GNUC__, == 2)
254+
typedef typename objects::unforward_cref<T>::type ret;
255+
return ret(x);
256+
# else
242257
return x;
258+
# endif
243259
}
244260

261+
# if BOOST_WORKAROUND(__GNUC__, == 2)
262+
// GCC 2.x has non-const string literals; this hacks around that problem.
263+
template <unsigned N>
264+
char const (& do_unforward_cref(char const(&x)[N]) )[N]
265+
{
266+
return x;
267+
}
268+
# endif
269+
245270
class object;
246271

247272
template <class T>
248273
PyObject* object_base_initializer(T const& x)
249274
{
275+
typedef typename is_derived<
276+
BOOST_DEDUCED_TYPENAME objects::unforward_cref<T>::type
277+
, object
278+
>::type is_obj;
279+
250280
return object_initializer<
251281
BOOST_DEDUCED_TYPENAME unwrap_reference<T>::type
252282
>::get(
253283
api::do_unforward_cref(x)
254-
, is_derived<
255-
BOOST_DEDUCED_TYPENAME objects::unforward_cref<T>::type
256-
, object
257-
>()
284+
, is_obj()
258285
);
259286
}
260287

include/boost/python/suite/indexing/detail/indexing_suite_detail.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,12 @@ namespace boost { namespace python { namespace detail {
168168

169169
while (right != proxies.end())
170170
{
171+
typedef typename Proxy::container_type::difference_type difference_type;
171172
extract<Proxy&> p(*right);
172173
p().set_index(
173174
extract<Proxy&>(*right)().get_index()
174-
- (typename Proxy::container_type::difference_type(to)
175-
- from - len)
176-
);
175+
- (difference_type(to) - from - len)
176+
);
177177

178178
++right;
179179
}

0 commit comments

Comments
 (0)