2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-19 04:22:16 +00:00

Use bitwise combination of numeric method IDs to decide what to support

[SVN r22197]
This commit is contained in:
Raoul Gough
2004-02-08 19:04:39 +00:00
parent d79c063b97
commit 2c8f1fb5d3
3 changed files with 17 additions and 13 deletions

View File

@@ -17,7 +17,6 @@
#include "int_wrapper.hpp"
#include <boost/python/suite/indexing/container_suite.hpp>
#include <boost/python/suite/indexing/iterator_range.hpp> // for begin(), end()
#include <boost/python/suite/indexing/vector.hpp>
#include <vector>
#include <boost/python/class.hpp>
@@ -37,12 +36,7 @@ std::vector<int_wrapper> get_vector ()
int_wrapper(7), int_wrapper(0) };
return std::vector<int_wrapper>
#if BOOST_WORKAROUND (BOOST_MSVC, <=1200)
(array, array + sizeof(array) / sizeof (array[0]));
#else
(boost::python::indexing::begin(array),
boost::python::indexing::end(array));
#endif
}
BOOST_PYTHON_MODULE(test_indexing_const_ext)

View File

@@ -1,11 +1,14 @@
// Module test_vector_disable.cpp
//
// 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)
//
// Module test_vector_disable.cpp
//
// Expose a vector with minimal supported methods. Should produce a
// much smaller object file that otherwise.
//
// History
// =======
// 2003/11/19 rmg File creation
@@ -26,15 +29,20 @@ BOOST_PYTHON_MODULE(test_vector_disable_ext)
typedef std::vector<int> Container1;
// Generate a vector suite with all optional support disabled
// Binary mask for the four methods we want to support
unsigned int const mask
= indexing::method_getitem
| indexing::method_setitem
| indexing::method_delitem
| indexing::method_append;
#if !defined (BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
// Normal case (automatic algorithm and traits selection)
typedef indexing::container_suite<Container1, indexing::minimum_support>
typedef indexing::container_suite<Container1, mask>
Suite1;
#else
// For broken compilers - explicit selection of algorithms/traits
typedef indexing::vector_suite<Container1, indexing::minimum_support>
typedef indexing::vector_suite<Container1, mask>
Suite1;
#endif

View File

@@ -56,10 +56,12 @@ BOOST_PYTHON_MODULE(test_vector_shared_ext)
#else
// Otherwise do it the hard way
typedef indexing::indirect_value_traits<int_wrapper_holder> value_traits_;
typedef indexing::default_sequence_traits<Container1, value_traits_>
typedef indexing::random_access_sequence_traits<Container1, value_traits_>
container_traits_;
typedef indexing::default_algorithms<container_traits_> algorithms_;
typedef indexing::container_suite<Container1, 0, algorithms_> Suite1;
typedef indexing::container_suite<
Container1, indexing::all_methods, algorithms_> Suite1;
#endif
boost::python::class_<Container1>("Vector_shared")