From 494bede2c095197086acc7caafbe576fa077a37d Mon Sep 17 00:00:00 2001 From: Raoul Gough Date: Fri, 5 Dec 2003 17:36:14 +0000 Subject: [PATCH] Rationalize some identifier names [SVN r21150] --- .../python/suite/indexing/container_proxy.hpp | 25 ++++---- .../python/suite/indexing/container_suite.hpp | 12 ++-- .../suite/indexing/container_traits.hpp | 28 ++++----- include/boost/python/suite/indexing/deque.hpp | 9 ++- .../suite/indexing/element_proxy_traits.hpp | 24 ++++---- .../suite/indexing/int_slice_helper.hpp | 20 +++---- .../python/suite/indexing/iterator_range.hpp | 15 +++-- include/boost/python/suite/indexing/list.hpp | 22 +++---- include/boost/python/suite/indexing/map.hpp | 14 ++--- .../python/suite/indexing/proxy_iterator.hpp | 11 ++-- include/boost/python/suite/indexing/set.hpp | 13 ++--- .../python/suite/indexing/value_traits.hpp | 40 ++++++------- .../boost/python/suite/indexing/vector.hpp | 9 ++- .../boost/python/suite/indexing/visitor.hpp | 57 +++++++++++-------- 14 files changed, 156 insertions(+), 143 deletions(-) diff --git a/include/boost/python/suite/indexing/container_proxy.hpp b/include/boost/python/suite/indexing/container_proxy.hpp index beddf022..d2770857 100755 --- a/include/boost/python/suite/indexing/container_proxy.hpp +++ b/include/boost/python/suite/indexing/container_proxy.hpp @@ -1,11 +1,14 @@ -// Header file container_proxy.hpp -// // Copyright (c) 2003 Raoul M. Gough // // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy // at http://www.boost.org/LICENSE_1_0.txt) // +// Header file container_proxy.hpp +// +// A container-wrapper that provides Python-style reference semantics +// for values stored in vector-like containers via element proxies. +// // Class invariant: // size() == m_proxies.size() // for 0 <= i < size() @@ -39,7 +42,6 @@ #include #include #include -#include namespace boost { namespace python { namespace indexing { @@ -683,17 +685,18 @@ namespace boost { namespace python { namespace indexing { #if defined (BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) // value_traits for the reference type (i.e. our element_proxy - // instance) supplies a custom visitor_helper. Compilers without - // partial specialization need help here. + // instance) supplies a custom visit_container_class. Compilers + // without partial specialization need help here. - typedef element_proxy_traits value_traits_; + typedef element_proxy_traits value_traits_type; - // Hide base class visitor_helper, which would call the + // Hide base class visit_container_class, which would call the // unspecialized value_traits version template - static void visitor_helper (PythonClass &pyClass, Policy const &policy) + static void visit_container_class( + PythonClass &pyClass, Policy const &policy) { - value_traits_::visitor_helper (pyClass, policy); + value_traits_type::visit_container_class (pyClass, policy); } #endif }; @@ -701,11 +704,11 @@ namespace boost { namespace python { namespace indexing { #if !defined (BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) namespace detail { /////////////////////////////////////////////////////////////////////// - // algo_selector support for container_proxy instances + // algorithms support for container_proxy instances /////////////////////////////////////////////////////////////////////// template - class selector_impl > + class algorithms_selector > { typedef container_proxy Container; diff --git a/include/boost/python/suite/indexing/container_suite.hpp b/include/boost/python/suite/indexing/container_suite.hpp index 910bb068..3cda03e5 100755 --- a/include/boost/python/suite/indexing/container_suite.hpp +++ b/include/boost/python/suite/indexing/container_suite.hpp @@ -1,13 +1,13 @@ -// -*- mode:c++ -*- -// -// Header file container_suite.hpp -// // Copyright (c) 2003 Raoul M. Gough // // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy // at http://www.boost.org/LICENSE_1_0.txt) // +// Header file container_suite.hpp +// +// Top-level interface to the container suite. +// // History // ======= // 2003/ 8/23 rmg File creation @@ -19,7 +19,7 @@ #ifndef BOOST_PYTHON_INDEXING_CONTAINER_SUITE_HPP #define BOOST_PYTHON_INDEXING_CONTAINER_SUITE_HPP -#include +#include #include #include @@ -33,7 +33,7 @@ namespace boost { namespace python { namespace indexing { class Container, int Flags = 0, class Algorithms - = algo_selector + = algorithms > struct container_suite : public visitor diff --git a/include/boost/python/suite/indexing/container_traits.hpp b/include/boost/python/suite/indexing/container_traits.hpp index 17943bf5..b56b8838 100755 --- a/include/boost/python/suite/indexing/container_traits.hpp +++ b/include/boost/python/suite/indexing/container_traits.hpp @@ -1,14 +1,14 @@ -// Header file container_traits.hpp -// -// Traits information about entire containers for use in determining -// what Python methods to support for a container. -// // Copyright (c) 2003 Raoul M. Gough // // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy // at http://www.boost.org/LICENSE_1_0.txt) // +// Header file container_traits.hpp +// +// Traits information about entire containers for use in determining +// what Python methods to provide. +// // History // ======= // 2003/ 8/23 rmg File creation as container_suite.hpp @@ -85,26 +85,25 @@ namespace boost { namespace python { namespace indexing { typedef typename make_signed::type index_type; // at(), operator[]. Signed to support Python -ve indexes - typedef typename BOOST_PYTHON_INDEXING_CALL_TRAITS ::param_type + typedef typename BOOST_PYTHON_INDEXING_CALL_TRAITS::param_type value_param; - typedef typename BOOST_PYTHON_INDEXING_CALL_TRAITS ::param_type + typedef typename BOOST_PYTHON_INDEXING_CALL_TRAITS::param_type key_param; - typedef typename BOOST_PYTHON_INDEXING_CALL_TRAITS ::param_type + typedef typename BOOST_PYTHON_INDEXING_CALL_TRAITS::param_type index_param; // Allow client code to replace the default value traits via our // second (optional) template parameter typedef value_traits default_value_traits; - typedef typename detail::maybe_override< - default_value_traits, ValueTraits>::type value_traits_; + default_value_traits, ValueTraits>::type value_traits_type; BOOST_STATIC_CONSTANT( bool, has_mutable_ref = ICE_AND (base_type::has_mutable_ref, is_mutable)); BOOST_STATIC_CONSTANT( - bool, has_find = value_traits_::equality_comparable); + bool, has_find = value_traits_type::equality_comparable); // Assume the worst for everything else BOOST_STATIC_CONSTANT (bool, has_insert = false); @@ -112,11 +111,12 @@ namespace boost { namespace python { namespace indexing { BOOST_STATIC_CONSTANT (bool, has_pop_back = false); BOOST_STATIC_CONSTANT (bool, has_push_back = false); - // Forward visitor_helper to value_traits_ + // Forward visit_container_class to value_traits_type template - static void visitor_helper (PythonClass &pyClass, Policy const &policy) + static void visit_container_class( + PythonClass &pyClass, Policy const &policy) { - value_traits_::visitor_helper (pyClass, policy); + value_traits_type::visit_container_class (pyClass, policy); } }; diff --git a/include/boost/python/suite/indexing/deque.hpp b/include/boost/python/suite/indexing/deque.hpp index 9c652320..d9e41c5f 100755 --- a/include/boost/python/suite/indexing/deque.hpp +++ b/include/boost/python/suite/indexing/deque.hpp @@ -1,11 +1,11 @@ -// Header file deque.hpp -// // Copyright (c) 2003 Raoul M. Gough // // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy // at http://www.boost.org/LICENSE_1_0.txt) // +// Header file deque.hpp +// // Indexing algorithms support for std::deque instances // // History @@ -21,18 +21,17 @@ #include #include #include -#include #include namespace boost { namespace python { namespace indexing { #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) namespace detail { /////////////////////////////////////////////////////////////////////// - // algo_selector support for std::deque instances + // algorithms support for std::deque instances /////////////////////////////////////////////////////////////////////// template - class selector_impl > + class algorithms_selector > { typedef std::deque Container; diff --git a/include/boost/python/suite/indexing/element_proxy_traits.hpp b/include/boost/python/suite/indexing/element_proxy_traits.hpp index 60a796b6..18917399 100755 --- a/include/boost/python/suite/indexing/element_proxy_traits.hpp +++ b/include/boost/python/suite/indexing/element_proxy_traits.hpp @@ -1,16 +1,18 @@ -// Header file element_proxy_traits.hpp -// // Copyright (c) 2003 Raoul M. Gough // // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy // at http://www.boost.org/LICENSE_1_0.txt) // +// Header file element_proxy_traits.hpp +// +// Note: element_proxy.hpp must be included before this header +// // This is a separate header so that element_proxy.hpp is not // dependant on register_ptr_to_python.hpp. This avoids a problem with // two-phase name lookup, where register_ptr_to_python must be // included *after* the element_proxy overload of boost::get_pointer -// is defined. +// is declared. // // History // ======= @@ -33,26 +35,26 @@ namespace boost { namespace python { namespace indexing { : public value_traits< BOOST_DEDUCED_TYPENAME ContainerProxy::raw_value_type> { - typedef element_proxy element_proxy_; + typedef element_proxy element_proxy_type; typedef typename ContainerProxy::raw_value_type raw_value_type; typedef value_traits base_type; // Wrap the base class versions of the comparisons using // indirection struct less - : std::binary_function + : std::binary_function { typename base_type::less m_base_compare; bool operator()( - element_proxy_ const &p1, element_proxy_ const &p2) const + element_proxy_type const &p1, element_proxy_type const &p2) const { return m_base_compare (*p1, *p2); } }; struct equal_to - : std::binary_function + : std::binary_function { // First param is raw_value_type to interface smoothly with the // bind1st used in default_algorithms::find @@ -60,17 +62,17 @@ namespace boost { namespace python { namespace indexing { typename base_type::equal_to m_base_compare; bool operator()( - raw_value_type const &v, element_proxy_ const &p) const + raw_value_type const &v, element_proxy_type const &p) const { return m_base_compare (v, *p); } }; template - static void visitor_helper (PythonClass &, Policy const &) + static void visit_container_class (PythonClass &, Policy const &) { - boost::python::register_ptr_to_python(); - boost::python::implicitly_convertible(); + register_ptr_to_python(); + implicitly_convertible(); } }; diff --git a/include/boost/python/suite/indexing/int_slice_helper.hpp b/include/boost/python/suite/indexing/int_slice_helper.hpp index ac9589ef..e6610e93 100755 --- a/include/boost/python/suite/indexing/int_slice_helper.hpp +++ b/include/boost/python/suite/indexing/int_slice_helper.hpp @@ -1,13 +1,11 @@ -// -*- mode:c++ -*- -// -// Header file int_slice_helper.hpp -// // Copyright (c) 2003 Raoul M. Gough // // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy // at http://www.boost.org/LICENSE_1_0.txt) // +// Header file int_slice_helper.hpp +// // History // ======= // 2003/10/13 rmg File creation @@ -28,13 +26,13 @@ namespace boost { namespace python { namespace indexing { // Works with a SliceType that provides an int-like index_type // that is convertible to the algorithm's index_param - typedef Algorithms algorithms; + typedef Algorithms algorithms_type; typedef SliceType slice_type; - typedef typename algorithms::container container; - typedef typename algorithms::reference reference; - typedef typename algorithms::value_param value_param; - typedef typename algorithms::container_traits container_traits; + typedef typename algorithms_type::container container; + typedef typename algorithms_type::reference reference; + typedef typename algorithms_type::value_param value_param; + typedef typename algorithms_type::container_traits container_traits; typedef typename slice_type::index_type index_type; int_slice_helper (container &c, slice_type const &); @@ -91,7 +89,7 @@ namespace boost { namespace python { namespace indexing { typename int_slice_helper::reference int_slice_helper::current () const { - return algorithms::get (*m_ptr, m_pos); + return algorithms_type::get (*m_ptr, m_pos); } template @@ -111,7 +109,7 @@ namespace boost { namespace python { namespace indexing { template void int_slice_helper::assign (value_param val) const { - algorithms::assign (*m_ptr, m_pos, val); + algorithms_type::assign (*m_ptr, m_pos, val); } namespace detail { diff --git a/include/boost/python/suite/indexing/iterator_range.hpp b/include/boost/python/suite/indexing/iterator_range.hpp index 392da52c..0cfa568b 100755 --- a/include/boost/python/suite/indexing/iterator_range.hpp +++ b/include/boost/python/suite/indexing/iterator_range.hpp @@ -1,14 +1,14 @@ -// Header file iterator_range.hpp -// -// Emulate an STL container using a pair of iterators. Doesn't support -// insertion or deletion, for the obvious reasons. -// // Copyright (c) 2003 Raoul M. Gough // // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy // at http://www.boost.org/LICENSE_1_0.txt) // +// Header file iterator_range.hpp +// +// Emulate an STL container using a pair of iterators. Doesn't support +// insertion or deletion, for the obvious reasons. +// // History // ======= // 2003/ 9/ 9 rmg File creation as iterator_pair.hpp @@ -28,7 +28,6 @@ #include #include #include -#include namespace boost { namespace python { namespace indexing { template @@ -183,11 +182,11 @@ namespace boost { namespace python { namespace indexing { #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) namespace detail { /////////////////////////////////////////////////////////////////////// - // algo_selector support for iterator_range instances + // algorithms support for iterator_range instances /////////////////////////////////////////////////////////////////////// template - class selector_impl > + class algorithms_selector > { typedef iterator_range Container; diff --git a/include/boost/python/suite/indexing/list.hpp b/include/boost/python/suite/indexing/list.hpp index 681e9fbb..449c1445 100755 --- a/include/boost/python/suite/indexing/list.hpp +++ b/include/boost/python/suite/indexing/list.hpp @@ -1,11 +1,11 @@ -// Header file list.hpp -// // Copyright (c) 2003 Raoul M. Gough // // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy // at http://www.boost.org/LICENSE_1_0.txt) // +// Header file list.hpp +// // Indexing algorithms support for std::list instances // // History @@ -21,7 +21,6 @@ #include #include #include -#include #include #if BOOST_WORKAROUND (BOOST_MSVC, == 1200) @@ -58,11 +57,11 @@ namespace boost { namespace python { namespace indexing { #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) namespace detail { /////////////////////////////////////////////////////////////////////// - // algo_selector support for std::list instances + // algorithms support for std::list instances /////////////////////////////////////////////////////////////////////// template - class selector_impl > + class algorithms_selector > { typedef std::list Container; @@ -103,14 +102,17 @@ namespace boost { namespace python { namespace indexing { template void list_algorithms::sort (container &c) { - typedef typename self_type::container_traits::value_traits_ value_traits_; - typedef typename value_traits_::less comparison; + typedef typename self_type::container_traits::value_traits_type + vtraits; + + typedef typename vtraits::less comparison; #if BOOST_WORKAROUND (BOOST_MSVC, == 1200) // MSVC6 doesn't have a templated sort member in list, so we just // use the parameterless version. This gives the correct behaviour - // provided that value_traits_::less is std::less. It - // would be possible to support std::greater (the only other - // overload of list::sort in MSVC6) with some additional work. + // provided that value_traits_type::less is exactly + // std::less. It would be possible to support + // std::greater (the only other overload of list::sort in + // MSVC6) with some additional work. BOOST_STATIC_ASSERT( (::boost::is_same >::value)); c.sort (); diff --git a/include/boost/python/suite/indexing/map.hpp b/include/boost/python/suite/indexing/map.hpp index 37a1af5b..22a32cf2 100755 --- a/include/boost/python/suite/indexing/map.hpp +++ b/include/boost/python/suite/indexing/map.hpp @@ -1,11 +1,11 @@ -// Header file map.hpp -// // Copyright (c) 2003 Raoul M. Gough // // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy // at http://www.boost.org/LICENSE_1_0.txt) // +// Header file map.hpp +// // Indexing algorithms support for std::map instances // // History @@ -21,8 +21,6 @@ #include #include #include -#include -#include #include #include @@ -91,11 +89,11 @@ namespace boost { namespace python { namespace indexing { #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) namespace detail { /////////////////////////////////////////////////////////////////////// - // algo_selector support for std::map instances + // algorithms support for std::map instances /////////////////////////////////////////////////////////////////////// template - class selector_impl > + class algorithms_selector > { typedef std::map Container; @@ -108,11 +106,11 @@ namespace boost { namespace python { namespace indexing { }; /////////////////////////////////////////////////////////////////////// - // algo_selector support for std::multimap instances + // algorithms support for std::multimap instances /////////////////////////////////////////////////////////////////////// template - class selector_impl > + class algorithms_selector > { typedef std::multimap Container; diff --git a/include/boost/python/suite/indexing/proxy_iterator.hpp b/include/boost/python/suite/indexing/proxy_iterator.hpp index 1a47612e..fdece46f 100755 --- a/include/boost/python/suite/indexing/proxy_iterator.hpp +++ b/include/boost/python/suite/indexing/proxy_iterator.hpp @@ -48,7 +48,7 @@ namespace boost { namespace python { namespace indexing { > base_type; public: - typedef ContainerProxy container_proxy_; + typedef ContainerProxy container_proxy_type; typedef Iter raw_iterator; typedef Traits raw_iterator_traits; @@ -59,9 +59,12 @@ namespace boost { namespace python { namespace indexing { typedef value_type *pointer; typedef value_type reference; // Already has reference semantics - proxy_iterator (container_proxy_ *p, size_type i) : ptr (p), index (i) { } + proxy_iterator (container_proxy_type *p, size_type i) + : ptr (p), index (i) + { + } - proxy_iterator (container_proxy_ *p, raw_iterator iter) + proxy_iterator (container_proxy_type *p, raw_iterator iter) : ptr (p), index (iter - p->raw_container().begin()) { } @@ -139,7 +142,7 @@ namespace boost { namespace python { namespace indexing { #else private: #endif - container_proxy_ *ptr; + container_proxy_type *ptr; size_type index; }; } } } diff --git a/include/boost/python/suite/indexing/set.hpp b/include/boost/python/suite/indexing/set.hpp index 4bc8daf4..2a6fcb9a 100755 --- a/include/boost/python/suite/indexing/set.hpp +++ b/include/boost/python/suite/indexing/set.hpp @@ -1,11 +1,11 @@ -// Header file set.hpp -// // Copyright (c) 2003 Raoul M. Gough // // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy // at http://www.boost.org/LICENSE_1_0.txt) // +// Header file set.hpp +// // Indexing algorithms support for std::set instances // // History @@ -21,7 +21,6 @@ #include #include #include -#include #include namespace boost { namespace python { namespace indexing { @@ -79,11 +78,11 @@ namespace boost { namespace python { namespace indexing { #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) namespace detail { /////////////////////////////////////////////////////////////////////// - // algo_selector support for std::set instances + // algorithms support for std::set instances /////////////////////////////////////////////////////////////////////// template - class selector_impl > + class algorithms_selector > { typedef std::set Container; @@ -96,11 +95,11 @@ namespace boost { namespace python { namespace indexing { }; /////////////////////////////////////////////////////////////////////// - // algo_selector support for std::multiset instances + // algorithms support for std::multiset instances /////////////////////////////////////////////////////////////////////// template - class selector_impl > + class algorithms_selector > { typedef std::multiset Container; diff --git a/include/boost/python/suite/indexing/value_traits.hpp b/include/boost/python/suite/indexing/value_traits.hpp index 618efdee..15451998 100755 --- a/include/boost/python/suite/indexing/value_traits.hpp +++ b/include/boost/python/suite/indexing/value_traits.hpp @@ -1,16 +1,14 @@ -// -*- mode:c++ -*- -// -// Header file value_traits.hpp -// -// Traits information about container element types for use in -// determining which Python methods to support for a container. -// // Copyright (c) 2003 Raoul M. Gough // // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy // at http://www.boost.org/LICENSE_1_0.txt) // +// Header file value_traits.hpp: +// +// Traits information for use in determining which Python methods to +// support for a container with elements of a given type. +// // History // ======= // 2003/ 9/12 rmg File creation @@ -26,29 +24,31 @@ #include namespace boost { namespace python { namespace indexing { - // The value_traits template is used by default by all - // ContainerTraits templates. It can be overridden by specialization - // or by supplying the optional ValueTraits parameter to a container - // traits template. + // The default_value_traits template is used by all ContainerTraits + // templates. It can be overridden by specialization or by supplying + // the optional ValueTraits parameter to a container traits + // template. template struct value_traits; - // Implementation for default use + // Implementation for default use. Providing this in a separate + // template allows specializations of value_traits to make use of + // it. template - struct default_value_traits { + struct simple_value_traits { BOOST_STATIC_CONSTANT (bool, equality_comparable = true); typedef std::equal_to equal_to; - BOOST_STATIC_CONSTANT (bool, lessthan_comparable = true); + BOOST_STATIC_CONSTANT (bool, less_than_comparable = true); typedef std::less less; - // Default, do-nothing, version of visitor_helper + // Default, do-nothing, version of visit_container_class template - static void visitor_helper (PythonClass &, Policy const &) { } + static void visit_container_class (PythonClass &, Policy const &) { } }; // Implementation using pointer indirection template - struct indirect_value_traits : default_value_traits { + struct indirect_value_traits : simple_value_traits { // Hide the base class versions of the comparisons, using these // indirect versions struct less : std::binary_function { @@ -64,10 +64,10 @@ namespace boost { namespace python { namespace indexing { }; }; - // Default implementation selection + // Default implementation selection. It's basically just a typedef + // for simple_value_traits template - struct value_traits - : default_value_traits + struct value_traits : simple_value_traits { }; diff --git a/include/boost/python/suite/indexing/vector.hpp b/include/boost/python/suite/indexing/vector.hpp index f8741207..97d3708d 100755 --- a/include/boost/python/suite/indexing/vector.hpp +++ b/include/boost/python/suite/indexing/vector.hpp @@ -1,11 +1,11 @@ -// Header file vector.hpp -// // Copyright (c) 2003 Raoul M. Gough // // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy // at http://www.boost.org/LICENSE_1_0.txt) // +// Header file vector.hpp +// // Indexing algorithms support for std::vector instances // // History @@ -21,18 +21,17 @@ #include #include #include -#include #include namespace boost { namespace python { namespace indexing { #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) namespace detail { /////////////////////////////////////////////////////////////////////// - // algo_selector support for std::vector instances + // algorithms support for std::vector instances /////////////////////////////////////////////////////////////////////// template - class selector_impl > + class algorithms_selector > { typedef std::vector Container; diff --git a/include/boost/python/suite/indexing/visitor.hpp b/include/boost/python/suite/indexing/visitor.hpp index ee702974..da7d9235 100755 --- a/include/boost/python/suite/indexing/visitor.hpp +++ b/include/boost/python/suite/indexing/visitor.hpp @@ -1,11 +1,14 @@ -// Header file visitor.hpp -// // Copyright (c) 2003 Raoul M. Gough // // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy // at http://www.boost.org/LICENSE_1_0.txt) // +// Header file visitor.hpp: +// +// def_visitor implementation to install the container_suite's Python +// methods in an object of a boost::python::class_<> instance. +// // History // ======= // 2003/ 9/11 rmg File creation from container_suite.hpp @@ -26,9 +29,16 @@ #include #include -#define ICE_AND(a, b) ::boost::type_traits::ice_and <(a), (b)>::value -#define ICE_NOT(a) ::boost::type_traits::ice_not <(a)>::value -// undef'd at end of header +# if defined (BOOST_MSVC) + // Prevent MSVC int-to-bool truncation warning (C4305) +# define QUIET_BOOL(val) static_cast(val) +# else +# define QUIET_BOOL(val) (val) +# endif + +# define ICE_AND(a, b) ::boost::type_traits::ice_and <(a), (b)>::value +# define ICE_NOT(a) ::boost::type_traits::ice_not ::value +// these three macros undef'd at end of header namespace boost { namespace python { namespace indexing { enum visitor_flags { @@ -495,9 +505,9 @@ namespace boost { namespace python { namespace indexing { Policy m_policy; public: - typedef Algorithms algorithms; - typedef typename algorithms::container_traits traits; - typedef typename traits::value_traits_ value_traits_; + typedef Algorithms algorithms_type; + typedef typename algorithms_type::container_traits traits; + typedef typename traits::value_traits_type value_traits_type; explicit visitor (Policy const &policy = Policy()) : m_policy (policy) { } @@ -523,43 +533,43 @@ namespace boost { namespace python { namespace indexing { ICE_AND( traits::has_copyable_iter, ICE_NOT (Flags & disable_len)) - >::apply (pyClass, algorithms(), precallPolicy); + >::apply (pyClass, algorithms_type(), precallPolicy); maybe_add_getitem - ::apply (pyClass, algorithms(), m_policy); + ::apply (pyClass, algorithms_type(), m_policy); maybe_add_setitem< ICE_AND (traits::has_mutable_ref, has_indexing), has_slicing - >::apply (pyClass, algorithms(), m_policy); + >::apply (pyClass, algorithms_type(), m_policy); maybe_add_delitem - ::apply (pyClass, algorithms(), m_policy); + ::apply (pyClass, algorithms_type(), m_policy); maybe_add_iter< ICE_AND( traits::index_style != index_style_linear, traits::has_copyable_iter) - >::apply (pyClass, algorithms(), m_policy); + >::apply (pyClass, algorithms_type(), m_policy); maybe_add_sort< ICE_AND( ICE_AND( traits::is_reorderable, - value_traits_::lessthan_comparable), + value_traits_type::less_than_comparable), ICE_NOT (Flags & disable_reorder)) - >::apply (pyClass, algorithms(), precallPolicy); + >::apply (pyClass, algorithms_type(), precallPolicy); maybe_add_reverse< ICE_AND (traits::is_reorderable, ICE_NOT (Flags & disable_reorder)) - >::apply (pyClass, algorithms(), precallPolicy); + >::apply (pyClass, algorithms_type(), precallPolicy); maybe_add_append - ::apply (pyClass, algorithms(), precallPolicy); + ::apply (pyClass, algorithms_type(), precallPolicy); maybe_add_insert< ICE_AND (traits::has_insert, ICE_NOT (Flags & disable_insert)) - >::apply (pyClass, algorithms(), precallPolicy); + >::apply (pyClass, algorithms_type(), precallPolicy); maybe_add_extend< ICE_AND( @@ -567,7 +577,7 @@ namespace boost { namespace python { namespace indexing { traits::index_style == index_style_linear, traits::has_insert), ICE_NOT (Flags & disable_extend)) - >::apply (pyClass, algorithms(), precallPolicy); + >::apply (pyClass, algorithms_type(), precallPolicy); maybe_add_index< ICE_AND( @@ -575,21 +585,22 @@ namespace boost { namespace python { namespace indexing { traits::index_style == index_style_linear, traits::has_find), ICE_NOT (Flags & disable_search)) - >::apply (pyClass, algorithms(), precallPolicy); + >::apply (pyClass, algorithms_type(), precallPolicy); maybe_add_count< ICE_AND( traits::has_find, ICE_NOT (Flags & disable_search)), traits::index_style - >::apply (pyClass, algorithms(), precallPolicy); + >::apply (pyClass, algorithms_type(), precallPolicy); - Algorithms::visitor_helper (pyClass, m_policy); + Algorithms::visit_container_class (pyClass, m_policy); } }; } } } -#undef ICE_AND #undef ICE_NOT +#undef ICE_AND +#undef QUIET_BOOL #endif // BOOST_PYTHON_INDEXING_VISITOR_HPP