From cdcf8633bb2c149327f118f9fe897ec0277ba8d1 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Wed, 22 Mar 2006 09:53:34 +0000 Subject: [PATCH 001/268] Force multithreading for Python test. Workaround for problem described in http://thread.gmane.org/gmane.comp.lib.boost.devel/139601 [SVN r33434] --- test/Jamfile.v2 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 1cdb8983..925f6cf5 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -2,6 +2,8 @@ use-project /boost/python : ../build ; project /boost/python/test ; +project : requirements multi ; + rule py-run ( sources * ) { return [ run $(sources) /boost/python//boost_python ] ; From 3fdfb30e334935ae1f871ff3b603f395a75d95bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Sch=C3=B6pflin?= Date: Thu, 23 Mar 2006 09:38:03 +0000 Subject: [PATCH 002/268] Include python first, fixes error on Tru64/CXX. [SVN r33454] --- test/upcast.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/upcast.cpp b/test/upcast.cpp index 62df4937..9b66c3d8 100755 --- a/test/upcast.cpp +++ b/test/upcast.cpp @@ -2,8 +2,9 @@ // Distributed under 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) -#include + #include +#include struct X { long x; }; struct Y : X, PyObject {}; @@ -16,4 +17,3 @@ int main() BOOST_TEST(&boost::python::upcast(&y)->ob_refcnt == &y.ob_refcnt); return boost::report_errors(); } - From fe3abeda9f93a3255dbde87fa977954b5c880f0f Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Thu, 18 May 2006 15:49:41 +0000 Subject: [PATCH 003/268] much more informative pickle error messages if pickling is not enabled [SVN r34004] --- src/object/class.cpp | 5 ++++- src/object/pickle_support.cpp | 17 +++++++++++++++++ test/pickle1.cpp | 5 +++++ test/pickle1.py | 5 +++++ 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/object/class.cpp b/src/object/class.cpp index efc492c6..7faf1830 100644 --- a/src/object/class.cpp +++ b/src/object/class.cpp @@ -530,6 +530,10 @@ namespace objects if (scope().ptr() != Py_None) scope().attr(name) = result; + // For pickle. Will lead to informative error messages if pickling + // is not enabled. + result.attr("__reduce__") = object(make_instance_reduce_function()); + return result; } } @@ -627,7 +631,6 @@ namespace objects void class_base::enable_pickling_(bool getstate_manages_dict) { - setattr("__reduce__", object(make_instance_reduce_function())); setattr("__safe_for_unpickling__", object(true)); if (getstate_manages_dict) diff --git a/src/object/pickle_support.cpp b/src/object/pickle_support.cpp index 897ee633..1c574552 100644 --- a/src/object/pickle_support.cpp +++ b/src/object/pickle_support.cpp @@ -8,6 +8,7 @@ #include #include #include +#include namespace boost { namespace python { @@ -19,6 +20,22 @@ namespace { object instance_class(instance_obj.attr("__class__")); result.append(instance_class); object none; + if (!getattr(instance_obj, "__safe_for_unpickling__", none)) + { + str type_name(getattr(instance_class, "__name__")); + str module_name(getattr(instance_class, "__module__", "")); + if (module_name) + module_name += "."; + + PyErr_SetObject( + PyExc_RuntimeError, + ( "Pickling of \"%s\" instances is not enabled" + " (http://www.boost.org/libs/python/doc/v2/pickle.html)" + % (module_name+type_name)).ptr() + ); + + throw_error_already_set(); + } object getinitargs = getattr(instance_obj, "__getinitargs__", none); tuple initargs; if (getinitargs.ptr() != none.ptr()) { diff --git a/test/pickle1.cpp b/test/pickle1.cpp index bcdb2633..c1f8c805 100644 --- a/test/pickle1.cpp +++ b/test/pickle1.cpp @@ -45,6 +45,8 @@ namespace { } }; + // To support test of "pickling not enabled" error message. + struct noop {}; } BOOST_PYTHON_MODULE(pickle1_ext) @@ -54,4 +56,7 @@ BOOST_PYTHON_MODULE(pickle1_ext) .def("greet", &world::greet) .def_pickle(world_pickle_suite()) ; + + // To support test of "pickling not enabled" error message. + class_("noop"); } diff --git a/test/pickle1.py b/test/pickle1.py index bb66b31b..8369768d 100644 --- a/test/pickle1.py +++ b/test/pickle1.py @@ -18,6 +18,11 @@ r'''>>> import pickle1_ext Hello from California! >>> print wl.greet() Hello from California! + + >>> noop = pickle1_ext.noop() + >>> try: pickle.dumps(noop) + ... except RuntimeError, e: print str(e)[:55] + Pickling of "pickle1_ext.noop" instances is not enabled ''' def run(args = None): From b0ba7dfc505b177eb9d8d9fe8f582325f2788d37 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Thu, 18 May 2006 16:15:59 +0000 Subject: [PATCH 004/268] also exercise OVERLOADS with docstring [SVN r34006] --- test/args.cpp | 1 + test/args.py | 2 ++ test/keywords.cpp | 1 + test/keywords_test.py | 2 ++ 4 files changed, 6 insertions(+) diff --git a/test/args.cpp b/test/args.cpp index f6f16415..e25ea043 100644 --- a/test/args.cpp +++ b/test/args.cpp @@ -85,6 +85,7 @@ BOOST_PYTHON_MODULE(args_ext) .def("inner5", &X::inner, "docstring", args("n"), return_internal_reference<>()) .def("f1", &X::f, X_f_overloads(args("x", "y", "z"))) + .def("f2", &X::f, X_f_overloads(args("x", "y", "z"), "f2's docstring")) ; def("inner", &X::inner, "docstring", args("self", "n"), return_internal_reference<>()); diff --git a/test/args.py b/test/args.py index cff6a7b8..695a07dc 100644 --- a/test/args.py +++ b/test/args.py @@ -84,6 +84,8 @@ (2, 4.25, 'wow') >>> q.f1() (1, 4.25, 'wow') +>>> q.f2.__doc__.splitlines()[-3] +"f2's docstring" >>> X.f.__doc__.splitlines()[:2] ["This is X.f's docstring", 'C++ signature:'] diff --git a/test/keywords.cpp b/test/keywords.cpp index 599f98d8..39bac062 100755 --- a/test/keywords.cpp +++ b/test/keywords.cpp @@ -103,6 +103,7 @@ BOOST_PYTHON_MODULE(keywords) , init >() ) .def("set", &Bar::set, bar_set()) + .def("set2", &Bar::set, bar_set("set2's docstring")) .def("seta", &Bar::seta, arg("a")) .def("a", &Bar::geta) diff --git a/test/keywords_test.py b/test/keywords_test.py index ff4d8014..aa31b76b 100644 --- a/test/keywords_test.py +++ b/test/keywords_test.py @@ -80,6 +80,8 @@ >>> f.set(1,1.0,"1") >>> f.a(), f.b(), f.n() (1, 1.0, '1') +>>> f.set2.__doc__.splitlines()[-3] +"set2's docstring" ''' From 92862028b7f35d81a63b2780be6fad57e5bdb6b2 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Thu, 18 May 2006 18:46:26 +0000 Subject: [PATCH 005/268] MIPSpro 7.3.1 compatibility [SVN r34009] --- src/object/pickle_support.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/object/pickle_support.cpp b/src/object/pickle_support.cpp index 1c574552..69a8f5a7 100644 --- a/src/object/pickle_support.cpp +++ b/src/object/pickle_support.cpp @@ -23,7 +23,7 @@ namespace { if (!getattr(instance_obj, "__safe_for_unpickling__", none)) { str type_name(getattr(instance_class, "__name__")); - str module_name(getattr(instance_class, "__module__", "")); + str module_name(getattr(instance_class, "__module__", str())); if (module_name) module_name += "."; From 59f81def56f5007542c1f388fc1c22d72d6e5d60 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Thu, 18 May 2006 18:47:12 +0000 Subject: [PATCH 006/268] Python include must appear before any system include [SVN r34010] --- test/callbacks.cpp | 2 +- test/list.cpp | 3 +-- test/module_tail.cpp | 2 +- test/staticmethod.cpp | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/test/callbacks.cpp b/test/callbacks.cpp index ee305553..6675bd41 100644 --- a/test/callbacks.cpp +++ b/test/callbacks.cpp @@ -2,7 +2,6 @@ // Distributed under 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) -#include #include #include @@ -13,6 +12,7 @@ #include #include #include +#include using namespace boost::python; BOOST_STATIC_ASSERT(converter::is_object_manager >::value); diff --git a/test/list.cpp b/test/list.cpp index d9c47a62..08037fd0 100644 --- a/test/list.cpp +++ b/test/list.cpp @@ -2,8 +2,6 @@ // Distributed under 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) -#include - #include #include @@ -11,6 +9,7 @@ #include #include #include +#include #include "test_class.hpp" using namespace boost::python; diff --git a/test/module_tail.cpp b/test/module_tail.cpp index 594949ef..02cfc6a3 100644 --- a/test/module_tail.cpp +++ b/test/module_tail.cpp @@ -32,7 +32,7 @@ extern "C" void (*old_translator)(unsigned, EXCEPTION_POINTERS*) #include struct test_failure : std::exception { - test_failure(char const* expr, char const* function, char const* file, unsigned line) + test_failure(char const* expr, char const* /*function*/, char const* file, unsigned line) : msg(file + boost::python::str(":%s:") % line + ": Boost.Python assertion failure: " + expr) {} diff --git a/test/staticmethod.cpp b/test/staticmethod.cpp index 0501c7c5..76728af8 100644 --- a/test/staticmethod.cpp +++ b/test/staticmethod.cpp @@ -2,7 +2,6 @@ // Distributed under 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) -#include #include #include @@ -10,6 +9,7 @@ #include #include #include +#include using namespace boost::python; From 66ac61450e626c780802f9e951d15ae04b5f0410 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Thu, 18 May 2006 22:09:20 +0000 Subject: [PATCH 007/268] avoid Visual C++ 7.1 "resolved overload was found by argument-dependent lookup" warning [SVN r34016] --- src/object/pickle_support.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/object/pickle_support.cpp b/src/object/pickle_support.cpp index 69a8f5a7..f70eb17f 100644 --- a/src/object/pickle_support.cpp +++ b/src/object/pickle_support.cpp @@ -23,7 +23,7 @@ namespace { if (!getattr(instance_obj, "__safe_for_unpickling__", none)) { str type_name(getattr(instance_class, "__name__")); - str module_name(getattr(instance_class, "__module__", str())); + str module_name(getattr(instance_class, "__module__", object(""))); if (module_name) module_name += "."; From caa9cb8268f30cacc22b8fe0de60db7e7d6f33c7 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Thu, 18 May 2006 22:41:14 +0000 Subject: [PATCH 008/268] Python 2.5 compatibility [SVN r34017] --- .../python/converter/builtin_converters.hpp | 4 ++-- include/boost/python/detail/wrap_python.hpp | 6 ++++++ include/boost/python/list.hpp | 8 +++---- include/boost/python/object.hpp | 4 ++-- src/list.cpp | 4 ++-- src/object/class.cpp | 5 +++-- src/object/function.cpp | 8 ++++--- src/object_protocol.cpp | 4 ++-- src/str.cpp | 21 +++++++++++++++++-- 9 files changed, 45 insertions(+), 19 deletions(-) diff --git a/include/boost/python/converter/builtin_converters.hpp b/include/boost/python/converter/builtin_converters.hpp index 3ae45c37..b7406632 100644 --- a/include/boost/python/converter/builtin_converters.hpp +++ b/include/boost/python/converter/builtin_converters.hpp @@ -115,9 +115,9 @@ BOOST_PYTHON_TO_PYTHON_BY_VALUE(unsigned BOOST_PYTHON_LONG_LONG, ::PyLong_FromUn BOOST_PYTHON_TO_PYTHON_BY_VALUE(char, converter::do_return_to_python(x)) BOOST_PYTHON_TO_PYTHON_BY_VALUE(char const*, converter::do_return_to_python(x)) -BOOST_PYTHON_TO_PYTHON_BY_VALUE(std::string, ::PyString_FromStringAndSize(x.data(),implicit_cast(x.size()))) +BOOST_PYTHON_TO_PYTHON_BY_VALUE(std::string, ::PyString_FromStringAndSize(x.data(),implicit_cast(x.size()))) #if defined(Py_USING_UNICODE) && !defined(BOOST_NO_STD_WSTRING) -BOOST_PYTHON_TO_PYTHON_BY_VALUE(std::wstring, ::PyUnicode_FromWideChar(x.data(),implicit_cast(x.size()))) +BOOST_PYTHON_TO_PYTHON_BY_VALUE(std::wstring, ::PyUnicode_FromWideChar(x.data(),implicit_cast(x.size()))) # endif BOOST_PYTHON_TO_PYTHON_BY_VALUE(float, ::PyFloat_FromDouble(x)) BOOST_PYTHON_TO_PYTHON_BY_VALUE(double, ::PyFloat_FromDouble(x)) diff --git a/include/boost/python/detail/wrap_python.hpp b/include/boost/python/detail/wrap_python.hpp index cce01868..6ca45eee 100644 --- a/include/boost/python/detail/wrap_python.hpp +++ b/include/boost/python/detail/wrap_python.hpp @@ -141,6 +141,12 @@ typedef int pid_t; # include #endif +#if PY_VERSION_HEX < 0x02050000 +typedef int Py_ssize_t; +#define PY_SSIZE_T_MIN INT_MIN +#define PY_SSIZE_T_MAX INT_MAX +#endif + #ifdef BOOST_PYTHON_ULONG_MAX_UNDEFINED # undef ULONG_MAX # undef BOOST_PYTHON_ULONG_MAX_UNDEFINED diff --git a/include/boost/python/list.hpp b/include/boost/python/list.hpp index 793cd08a..c6ba7323 100644 --- a/include/boost/python/list.hpp +++ b/include/boost/python/list.hpp @@ -24,11 +24,11 @@ namespace detail long index(object_cref value) const; // return index of first occurrence of value - void insert(int index, object_cref); // insert object before index + void insert(Py_ssize_t index, object_cref); // insert object before index void insert(object const& index, object_cref); object pop(); // remove and return item at index (default last) - object pop(long index); + object pop(Py_ssize_t index); object pop(object const& index); void remove(object_cref value); // remove first occurrence of value @@ -86,7 +86,7 @@ class list : public detail::list_base } template - void insert(int index, T const& x) // insert object before index + void insert(Py_ssize_t index, T const& x) // insert object before index { base::insert(index, object(x)); } @@ -98,7 +98,7 @@ class list : public detail::list_base } object pop() { return base::pop(); } - object pop(long index) { return base::pop(index); } + object pop(Py_ssize_t index) { return base::pop(index); } template object pop(T const& index) diff --git a/include/boost/python/object.hpp b/include/boost/python/object.hpp index 677ffb42..2e36b632 100755 --- a/include/boost/python/object.hpp +++ b/include/boost/python/object.hpp @@ -15,9 +15,9 @@ namespace boost { namespace python { - inline long len(object const& obj) + inline Py_ssize_t len(object const& obj) { - long result = PyObject_Length(obj.ptr()); + Py_ssize_t result = PyObject_Length(obj.ptr()); if (PyErr_Occurred()) throw_error_already_set(); return result; } diff --git a/src/list.cpp b/src/list.cpp index 79f758a9..ca62e627 100644 --- a/src/list.cpp +++ b/src/list.cpp @@ -53,7 +53,7 @@ long list_base::index(object_cref value) const return result; } -void list_base::insert(int index, object_cref item) +void list_base::insert(Py_ssize_t index, object_cref item) { if (PyList_CheckExact(this->ptr())) { @@ -79,7 +79,7 @@ object list_base::pop() return this->attr("pop")(); } -object list_base::pop(long index) +object list_base::pop(Py_ssize_t index) { return this->pop(object(index)); } diff --git a/src/object/class.cpp b/src/object/class.cpp index 7faf1830..63f5cf97 100644 --- a/src/object/class.cpp +++ b/src/object/class.cpp @@ -506,13 +506,14 @@ namespace objects // were declared, we'll use our class_type() as the single base // class. std::size_t const num_bases = (std::max)(num_types - 1, static_cast(1)); - handle<> bases(PyTuple_New(num_bases)); + assert(num_bases <= PY_SSIZE_T_MAX); + handle<> bases(PyTuple_New(static_cast(num_bases))); for (std::size_t i = 1; i <= num_bases; ++i) { type_handle c = (i >= num_types) ? class_type() : get_class(types[i]); // PyTuple_SET_ITEM steals this reference - PyTuple_SET_ITEM(bases.get(), i - 1, upcast(c.release())); + PyTuple_SET_ITEM(bases.get(), static_cast(i - 1), upcast(c.release())); } // Call the class metatype to create a new class diff --git a/src/object/function.cpp b/src/object/function.cpp index 653343b9..44b8853c 100644 --- a/src/object/function.cpp +++ b/src/object/function.cpp @@ -64,7 +64,7 @@ function::function( = max_arity > num_keywords ? max_arity - num_keywords : 0; - unsigned tuple_size = num_keywords ? max_arity : 0; + Py_ssize_t tuple_size = num_keywords ? max_arity : 0; m_arg_names = object(handle<>(PyTuple_New(tuple_size))); if (num_keywords != 0) @@ -158,7 +158,9 @@ PyObject* function::call(PyObject* args, PyObject* keywords) const else { // build a new arg tuple, will adjust its size later - inner_args = handle<>(PyTuple_New(max_arity)); + assert(max_arity <= PY_SSIZE_T_MAX); + inner_args = handle<>( + PyTuple_New(static_cast(max_arity))); // Fill in the positional arguments for (std::size_t i = 0; i < n_unnamed_actual; ++i) @@ -293,7 +295,7 @@ void function::argument_error(PyObject* args, PyObject* /*keywords*/) const % make_tuple(this->m_namespace, this->m_name); list actual_args; - for (int i = 0; i < PyTuple_Size(args); ++i) + for (Py_ssize_t i = 0; i < PyTuple_Size(args); ++i) { char const* name = PyTuple_GetItem(args, i)->ob_type->tp_name; actual_args.append(str(name)); diff --git a/src/object_protocol.cpp b/src/object_protocol.cpp index c23b8bb3..b62b63a1 100755 --- a/src/object_protocol.cpp +++ b/src/object_protocol.cpp @@ -106,7 +106,7 @@ namespace // slicing code copied directly out of the Python implementation PySequenceMethods *sq = tp->tp_as_sequence; if (sq && sq->sq_slice && ISINT(v) && ISINT(w)) { - int ilow = 0, ihigh = INT_MAX; + Py_ssize_t ilow = 0, ihigh = PY_SSIZE_T_MAX; if (!_PyEval_SliceIndex(v, &ilow)) return NULL; if (!_PyEval_SliceIndex(w, &ihigh)) @@ -133,7 +133,7 @@ namespace // slicing code copied directly out of the Python implementation PySequenceMethods *sq = tp->tp_as_sequence; if (sq && sq->sq_slice && ISINT(v) && ISINT(w)) { - int ilow = 0, ihigh = INT_MAX; + Py_ssize_t ilow = 0, ihigh = PY_SSIZE_T_MAX; if (!_PyEval_SliceIndex(v, &ilow)) return -1; if (!_PyEval_SliceIndex(w, &ihigh)) diff --git a/src/str.cpp b/src/str.cpp index c452a285..8a321d27 100644 --- a/src/str.cpp +++ b/src/str.cpp @@ -21,10 +21,25 @@ str_base::str_base(const char* s) : object(detail::new_reference(::PyString_FromString(s))) {} +namespace { + + Py_ssize_t str_size_as_py_ssize_t(std::size_t n) + { + if (n > PY_SSIZE_T_MAX) + { + throw std::range_error("str size > PY_SSIZE_T_MAX"); + } + return static_cast(n); + } + +} // namespace + str_base::str_base(char const* start, char const* finish) : object( detail::new_reference( - ::PyString_FromStringAndSize(start, finish - start) + ::PyString_FromStringAndSize( + start, str_size_as_py_ssize_t(finish - start) + ) ) ) {} @@ -32,7 +47,9 @@ str_base::str_base(char const* start, char const* finish) str_base::str_base(char const* start, std::size_t length) // new str : object( detail::new_reference( - ::PyString_FromStringAndSize(start, length) + ::PyString_FromStringAndSize( + start, str_size_as_py_ssize_t(length) + ) ) ) {} From cab94a7bbac60637e0d2cdcee61beb433e10be69 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Fri, 2 Jun 2006 05:39:50 +0000 Subject: [PATCH 009/268] adjustments for new MIPSpro 7.4.4 [SVN r34132] --- include/boost/python/detail/wrap_python.hpp | 2 +- include/boost/python/type_id.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/python/detail/wrap_python.hpp b/include/boost/python/detail/wrap_python.hpp index 6ca45eee..60448ac9 100644 --- a/include/boost/python/detail/wrap_python.hpp +++ b/include/boost/python/detail/wrap_python.hpp @@ -48,7 +48,7 @@ #endif # include -# if defined(_SGI_COMPILER_VERSION) && _SGI_COMPILER_VERSION == 741 +# if defined(_SGI_COMPILER_VERSION) && _SGI_COMPILER_VERSION >= 740 # undef _POSIX_C_SOURCE # undef _XOPEN_SOURCE # endif diff --git a/include/boost/python/type_id.hpp b/include/boost/python/type_id.hpp index fecf8b8d..559a38b5 100755 --- a/include/boost/python/type_id.hpp +++ b/include/boost/python/type_id.hpp @@ -89,7 +89,7 @@ inline type_info type_id(BOOST_EXPLICIT_TEMPLATE_TYPE(T)) } # if (defined(__EDG_VERSION__) && __EDG_VERSION__ < 245) \ - || (defined(__sgi) && defined(_COMPILER_VERSION) && _COMPILER_VERSION <= 741) + || (defined(__sgi) && defined(_COMPILER_VERSION) && _COMPILER_VERSION <= 744) // Older EDG-based compilers seems to mistakenly distinguish "int" from // "signed int", etc., but only in typeid() expressions. However // though int == signed int, the "signed" decoration is propagated From c9300e07c2b209bfd2d825f5f487a276db014388 Mon Sep 17 00:00:00 2001 From: Joel de Guzman Date: Tue, 20 Jun 2006 00:33:22 +0000 Subject: [PATCH 010/268] added custom converter test for map indexing suite [SVN r34359] --- test/map_indexing_suite.cpp | 68 +++++++++++++++++++++++++++++++++++++ test/map_indexing_suite.py | 13 +++++++ 2 files changed, 81 insertions(+) diff --git a/test/map_indexing_suite.cpp b/test/map_indexing_suite.cpp index 1a548d31..8b5e3b6e 100644 --- a/test/map_indexing_suite.cpp +++ b/test/map_indexing_suite.cpp @@ -26,6 +26,62 @@ std::string x_value(X const& x) return "gotya " + x.s; } +struct A +{ + int value; + A() : value(0){}; + A(int v) : value(v) {}; +}; + +bool operator==(const A& v1, const A& v2) +{ + return (v1.value == v2.value); +} + +struct B +{ + A a; +}; + +// Converter from A to python int +struct AToPython +{ + static PyObject* convert(const A& s) + { + return boost::python::incref(boost::python::object((int)s.value).ptr()); + } +}; + +// Conversion from python int to A +struct AFromPython +{ + AFromPython() + { + boost::python::converter::registry::push_back( + &convertible, + &construct, + boost::python::type_id< A >()); + } + + static void* convertible(PyObject* obj_ptr) + { + if (!PyInt_Check(obj_ptr)) return 0; + return obj_ptr; + } + + static void construct( + PyObject* obj_ptr, + boost::python::converter::rvalue_from_python_stage1_data* data) + { + void* storage = ( + (boost::python::converter::rvalue_from_python_storage< A >*) + data)-> storage.bytes; + + new (storage) A((int)PyInt_AsLong(obj_ptr)); + data->convertible = storage; + } +}; + BOOST_PYTHON_MODULE(map_indexing_suite_ext) { class_("X") @@ -58,6 +114,18 @@ BOOST_PYTHON_MODULE(map_indexing_suite_ext) class_ > >("TestMap") .def(map_indexing_suite >, true>()) ; + + to_python_converter< A , AToPython >(); + AFromPython(); + + class_< std::map >("AMap") + .def(map_indexing_suite, true >()) + ; + + class_< B >("B") + .add_property("a", make_getter(&B::a, return_value_policy()), + make_setter(&B::a, return_value_policy())) + ; } #include "module_tail.cpp" diff --git a/test/map_indexing_suite.py b/test/map_indexing_suite.py index 646f6194..01fa943d 100644 --- a/test/map_indexing_suite.py +++ b/test/map_indexing_suite.py @@ -11,6 +11,7 @@ >>> assert "map_indexing_suite_IntMap_entry" in dir() >>> assert "map_indexing_suite_TestMap_entry" in dir() >>> assert "map_indexing_suite_XMap_entry" in dir() +>>> assert "map_indexing_suite_AMap_entry" in dir() >>> x = X('hi') >>> x hi @@ -201,6 +202,18 @@ kiwi ... dom = el.data() joel kimpo +##################################################################### +# Test custom converter... +##################################################################### + +>>> am = AMap() +>>> am[3] = 4 +>>> am[3] +4 +>>> for i in am: +... i.data() +4 + ##################################################################### # END.... ##################################################################### From d3c474b295028c1f9d5a054ebefc3a1a02402d6f Mon Sep 17 00:00:00 2001 From: Joel de Guzman Date: Tue, 20 Jun 2006 14:01:12 +0000 Subject: [PATCH 011/268] terminology tweak [SVN r34360] --- include/boost/python/suite/indexing/indexing_suite.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/python/suite/indexing/indexing_suite.hpp b/include/boost/python/suite/indexing/indexing_suite.hpp index 61e3593c..0ebb755a 100644 --- a/include/boost/python/suite/indexing/indexing_suite.hpp +++ b/include/boost/python/suite/indexing/indexing_suite.hpp @@ -18,7 +18,7 @@ namespace boost { namespace python { - // indexing_suite class. This class is the protocol class for + // indexing_suite class. This class is the facade class for // the management of C++ containers intended to be integrated // to Python. The objective is make a C++ container look and // feel and behave exactly as we'd expect a Python container. From cf68da0b19a6759a4a18e200e638ae56b5c65d2b Mon Sep 17 00:00:00 2001 From: Joel de Guzman Date: Thu, 22 Jun 2006 13:33:46 +0000 Subject: [PATCH 012/268] added test for vector [SVN r34374] --- test/vector_indexing_suite.cpp | 5 +++++ test/vector_indexing_suite.py | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/test/vector_indexing_suite.cpp b/test/vector_indexing_suite.cpp index a2dd1403..0f9cd74c 100644 --- a/test/vector_indexing_suite.cpp +++ b/test/vector_indexing_suite.cpp @@ -53,5 +53,10 @@ BOOST_PYTHON_MODULE(vector_indexing_suite_ext) class_ >("BoolVec") .def(vector_indexing_suite >()) ; + + // vector of strings + class_ >("StringVec") + .def(vector_indexing_suite >()) + ; } diff --git a/test/vector_indexing_suite.py b/test/vector_indexing_suite.py index 302fc67c..5914472f 100644 --- a/test/vector_indexing_suite.py +++ b/test/vector_indexing_suite.py @@ -321,6 +321,12 @@ e >>> print_xvec(v) [ a b c d e f g h i j ] +##################################################################### +# vector of strings +##################################################################### +>>> sv = StringVec() +>>> sv.append('a') + ##################################################################### # END.... ##################################################################### From 0605e9fdcf134b35621346b6d40b9f311f0b2f7b Mon Sep 17 00:00:00 2001 From: Joel de Guzman Date: Thu, 22 Jun 2006 13:43:09 +0000 Subject: [PATCH 013/268] minor tweak [SVN r34375] --- test/vector_indexing_suite.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/vector_indexing_suite.py b/test/vector_indexing_suite.py index 5914472f..9bb75700 100644 --- a/test/vector_indexing_suite.py +++ b/test/vector_indexing_suite.py @@ -326,6 +326,8 @@ e ##################################################################### >>> sv = StringVec() >>> sv.append('a') +>>> print sv[0] +a ##################################################################### # END.... From 2640f5af94030ff84786a34a0677bd6842048f21 Mon Sep 17 00:00:00 2001 From: Joel de Guzman Date: Thu, 29 Jun 2006 09:35:52 +0000 Subject: [PATCH 014/268] new css [SVN r34426] --- doc/tutorial/doc/html/boostbook.css | 203 +++++++++++++++++++--------- 1 file changed, 142 insertions(+), 61 deletions(-) diff --git a/doc/tutorial/doc/html/boostbook.css b/doc/tutorial/doc/html/boostbook.css index 802c773f..d84d5384 100644 --- a/doc/tutorial/doc/html/boostbook.css +++ b/doc/tutorial/doc/html/boostbook.css @@ -23,23 +23,24 @@ p { - text-align: justify; - font-size: 11pt; - line-height: 1.2; + text-align: left; + font-size: 10pt; + line-height: 1.15; } /*============================================================================= Program listings =============================================================================*/ - tt.computeroutput + /* Code on paragraphs */ + p tt.computeroutput { - font-size: 10pt; + font-size: 9pt; } pre.synopsis { - font-size: 10pt; + font-size: 90%; margin: 1pc 4% 0pc 4%; padding: 0.5pc 0.5pc 0.5pc 0.5pc; } @@ -47,32 +48,36 @@ .programlisting, .screen { - font-size: 10pt; + font-size: 9pt; display: block; margin: 1pc 4% 0pc 4%; padding: 0.5pc 0.5pc 0.5pc 0.5pc; } + /* Program listings in tables don't get borders */ + td .programlisting, + td .screen + { + margin: 0pc 0pc 0pc 0pc; + padding: 0pc 0pc 0pc 0pc; + } + /*============================================================================= Headings =============================================================================*/ - h1, - h2, - h3, - h4, - h5, - h6 + h1, h2, h3, h4, h5, h6 { text-align: left; - margin-top: 2pc; + margin: 1em 0em 0.5em 0em; + font-weight: bold; } - h1 { font: 170% } + h1 { font: 140% } h2 { font: bold 140% } - h3 { font: bold 120% } - h4 { font: bold 100% } - h5 { font: italic 100% } + h3 { font: bold 130% } + h4 { font: bold 120% } + h5 { font: italic 110% } h6 { font: italic 100% } /* Top page titles */ @@ -89,12 +94,41 @@ margin-bottom: 1pc; } - h1.title { font-size: 220% } - h2.title { font-size: 220% } - h3.title { font-size: 170% } - h4.title { font-size: 140% } - h5.title { font-size: 120% } - h6.title { font-size: 120% } + h1.title { font-size: 140% } + h2.title { font-size: 140% } + h3.title { font-size: 130% } + h4.title { font-size: 120% } + h5.title { font-size: 110% } + h6.title { font-size: 100% } + + .section h1 + { + margin: 0em 0em 0.5em 0em; + font-size: 140%; + } + + .section h2 { font-size: 140% } + .section h3 { font-size: 130% } + .section h4 { font-size: 120% } + .section h5 { font-size: 110% } + .section h6 { font-size: 100% } + + /* Code on titles */ + h1 tt.computeroutput { font-size: 140% } + h2 tt.computeroutput { font-size: 140% } + h3 tt.computeroutput { font-size: 130% } + h4 tt.computeroutput { font-size: 120% } + h5 tt.computeroutput { font-size: 110% } + h6 tt.computeroutput { font-size: 100% } + +/*============================================================================= + Author +=============================================================================*/ + + h3.author + { + font-size: 100% + } /*============================================================================= Lists @@ -102,20 +136,20 @@ li { - font-size: 11pt; + font-size: 10pt; line-height: 1.3; } /* Unordered lists */ ul { - text-align: justify; + text-align: left; } /* Ordered lists */ ol { - text-align: justify; + text-align: left; } /*============================================================================= @@ -159,9 +193,9 @@ .toc { margin: 1pc 4% 0pc 4%; - padding: 0.5pc; - font-size: 11pt; - line-height: 1.3; + padding: 0.1pc 1pc 0.1pc 1pc; + font-size: 80%; + line-height: 1.15; } .boost-toc @@ -180,7 +214,6 @@ margin-left: 4%; padding-right: 0.5em; padding-left: 0.5em; - font-size: 120%; } .informaltable table, @@ -202,8 +235,8 @@ div.table table tr td { padding: 0.5em; - text-align: justify; - font-size: 11pt; + text-align: left; + font-size: 9pt; } div.informaltable table tr th, @@ -211,51 +244,76 @@ { padding: 0.5em 0.5em 0.5em 0.5em; border: 1pt solid white; + font-size: 80%; } /*============================================================================= Blurbs =============================================================================*/ - div.informaltable table tr td.blurb + div.note, + div.tip, + div.important, + div.caution, + div.warning, + p.blurb { - font-size: 10pt; /* A little bit smaller than the main text */ + font-size: 9pt; /* A little bit smaller than the main text */ line-height: 1.2; + display: block; + margin: 1pc 4% 0pc 4%; + padding: 0.5pc 0.5pc 0.5pc 0.5pc; } - td.blurb img + p.blurb img { padding: 1pt; } /*============================================================================= - Misc + Variable Lists =============================================================================*/ - /* Tone down the title of Parameter lists */ - div.variablelist p.title + /* Make the terms in definition lists bold */ + div.variablelist dl dt, + span.term { font-weight: bold; - font-size: 100%; - text-align: left; + font-size: 10pt; } - - /* Tabularize parameter lists */ + + div.variablelist table tbody tr td + { + text-align: left; + vertical-align: top; + padding: 0em 2em 0em 0em; + font-size: 10pt; + margin: 0em 0em 0.5em 0em; + line-height: 1; + } + div.variablelist dl dt { - float: left; - clear: left; - display: block; - font-style: italic; + margin-bottom: 0.2em; } - + div.variablelist dl dd { - display: block; - clear: right; - padding-left: 8pc; + margin: 0em 0em 0.5em 2em; + font-size: 10pt; } + div.variablelist table tbody tr td p, + div.variablelist dl dd p + { + margin: 0em 0em 0.5em 0em; + line-height: 1; + } + +/*============================================================================= + Misc +=============================================================================*/ + /* Title of books and articles in bibliographies */ span.title { @@ -294,6 +352,14 @@ { color: #9c5a9c; } + + h1 a, h2 a, h3 a, h4 a, h5 a, h6 a, + h1 a:hover, h2 a:hover, h3 a:hover, h4 a:hover, h5 a:hover, h6 a:hover, + h1 a:visited, h2 a:visited, h3 a:visited, h4 a:visited, h5 a:visited, h6 a:visited + { + text-decoration: none; /* no underline */ + color: #000000; + } /* Syntax Highlighting */ .keyword { color: #0000AA; } @@ -322,41 +388,50 @@ /* Program listing */ pre.synopsis { - background-color: #F3F3F3; - border: 1pt solid #C0C0C0; + border: 1px solid #DCDCDC; } .programlisting, .screen { - background-color: #F3F3F3; - border: 1pt solid #C0C0C0; + border: 1px solid #DCDCDC; + } + + td .programlisting, + td .screen + { + border: 0px solid #DCDCDC; } /* Blurbs */ - div.informaltable table tr td.blurb + div.note, + div.tip, + div.important, + div.caution, + div.warning, + p.blurb { - background-color: #FFFFF0; - border: 1pt solid #707070; + border: 1px solid #DCDCDC; } /* Table of contents */ .toc { - background-color: #F3F3F3; + border: 1px solid #DCDCDC; } /* Tables */ div.informaltable table tr td, div.table table tr td { - background-color: #F0F0F0; + border: 1px solid #DCDCDC; } div.informaltable table tr th, div.table table tr th { - background-color: #E4E4E4; + background-color: #F0F0F0; + border: 1px solid #DCDCDC; } /* Misc */ @@ -396,6 +471,12 @@ border: 1px solid gray; } + td .programlisting, + td .screen + { + border: 0px solid #DCDCDC; + } + /* Table of contents */ .toc { From 596e92404afee381fea635f694b734f2616b0d72 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Tue, 11 Jul 2006 04:09:41 +0000 Subject: [PATCH 015/268] old misunderstanding corrected (L-BFGS) [SVN r34504] --- doc/projects.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/projects.html b/doc/projects.html index 605eb823..91acd5e8 100644 --- a/doc/projects.html +++ b/doc/projects.html @@ -304,7 +304,7 @@

The SourceForge cctbx project is organized in modules to facilitate use in non-crystallographic applications. The scitbx module implements a general purpose array family for scientific applications and pure C++ - ports of FFTPACK and the LBFGS conjugate gradient minimizer.

+ ports of FFTPACK and the L-BFGS quasi-Newton minimizer.

EMSolve
From a1e865061c2f80be160bc4d42f3c6edcac41df27 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Sat, 22 Jul 2006 07:12:10 +0000 Subject: [PATCH 016/268] Don't link Boost.Python to python library, and don't require multi for embedding applications. * libs/python/build/Jamfile.v2: (boost_python): Don't link to /python//python. Use /python//python_for_extensions. * libs/python/test/Jamfile.v2: Remove multi project requirements. (py-run): Link to /python//python. (exec): Likewise. * tools/build/v2/tools/python.jam: (pthread): Declare. (init-unix): Add 'pthread' to extra-libs. ( [SVN r34662] --- build/Jamfile.v2 | 7 ++++++- test/Jamfile.v2 | 6 ++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/build/Jamfile.v2 b/build/Jamfile.v2 index 66427745..50169cc7 100644 --- a/build/Jamfile.v2 +++ b/build/Jamfile.v2 @@ -59,7 +59,12 @@ lib boost_python : # requirements static:BOOST_PYTHON_STATIC_LIB BOOST_PYTHON_SOURCE - /python//python + # We don't link to Python library itself. If + # Boost.Python is used for extension, all Python + # symbols are available in Python interpreter. + # If Boost.Python is used for extending, client + # is required to link to /python//python itself. + /python//python_for_extensions : # default build shared : # usage requirements diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 925f6cf5..8e000ec4 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -2,11 +2,9 @@ use-project /boost/python : ../build ; project /boost/python/test ; -project : requirements multi ; - rule py-run ( sources * ) { - return [ run $(sources) /boost/python//boost_python ] ; + return [ run $(sources) /boost/python//boost_python /python//python ] ; } rule py-compile ( sources * ) @@ -36,7 +34,7 @@ test-suite python : [ - run exec.cpp ../build//boost_python/static + run exec.cpp ../build//boost_python/static /python//python : # program args : exec.py : # requirements From f5a69a1dab0f4caaf48e58ffd10ca07e9cfd9275 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Sat, 22 Jul 2006 12:28:00 +0000 Subject: [PATCH 017/268] Windows fix: use /pytho/python_for_extensions, not , so that we actually link to Python import lib on windows. [SVN r34666] --- build/Jamfile.v2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/Jamfile.v2 b/build/Jamfile.v2 index 50169cc7..1822fa39 100644 --- a/build/Jamfile.v2 +++ b/build/Jamfile.v2 @@ -64,7 +64,7 @@ lib boost_python # symbols are available in Python interpreter. # If Boost.Python is used for extending, client # is required to link to /python//python itself. - /python//python_for_extensions + /python//python_for_extensions : # default build shared : # usage requirements From ec77608840392169ac57607b309545c4d324910d Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Sat, 22 Jul 2006 12:53:49 +0000 Subject: [PATCH 018/268] Clarify comment [SVN r34668] --- build/Jamfile.v2 | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/build/Jamfile.v2 b/build/Jamfile.v2 index 1822fa39..dbf0df00 100644 --- a/build/Jamfile.v2 +++ b/build/Jamfile.v2 @@ -9,7 +9,7 @@ if [ python.configured ] { project boost/python : source-location ../src : requirements - #$(PYTHON_PATH)/include + #$(PYTHON_PATH)/include # $(lib_condition)$(PYTHON_PATH)/libs # shared:$(PYTHON_LIB) # $(defines) @@ -59,12 +59,16 @@ lib boost_python : # requirements static:BOOST_PYTHON_STATIC_LIB BOOST_PYTHON_SOURCE - # We don't link to Python library itself. If - # Boost.Python is used for extension, all Python - # symbols are available in Python interpreter. - # If Boost.Python is used for extending, client - # is required to link to /python//python itself. - /python//python_for_extensions + # On Linux, we don't link to Python library itself. If + # Boost.Python is used for extension, all Python + # symbols are available in Python interpreter. + # If Boost.Python is used for extending, client + # is required to link to /python//python itself. + # On Windows, all code using Python has to link + # to python import library. The 'python_for_extension' + # is the target that's setup to provide either just + # include paths, or import library. + /python//python_for_extensions : # default build shared : # usage requirements From f332ff2d89e937667b9850692944d16b47ad5f82 Mon Sep 17 00:00:00 2001 From: Gennaro Prota Date: Mon, 24 Jul 2006 22:04:05 +0000 Subject: [PATCH 019/268] minor fix: violation of min/max guidelines [SVN r34717] --- include/boost/python/with_custodian_and_ward.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/python/with_custodian_and_ward.hpp b/include/boost/python/with_custodian_and_ward.hpp index 11ee79d1..906de6d7 100644 --- a/include/boost/python/with_custodian_and_ward.hpp +++ b/include/boost/python/with_custodian_and_ward.hpp @@ -90,7 +90,7 @@ struct with_custodian_and_ward_postcall : BasePolicy_ // check if either custodian or ward exceeds the arity // (this weird formulation avoids "always false" warnings // for arity_ = 0) - if ( std::max(custodian, ward) > arity_ ) + if ( (std::max)(custodian, ward) > arity_ ) #endif { PyErr_SetString( From 4081605e4b7d0a13437e6b015569ee19c2e31668 Mon Sep 17 00:00:00 2001 From: Gennaro Prota Date: Mon, 24 Jul 2006 22:14:15 +0000 Subject: [PATCH 020/268] removed tabs (inspect tool) [SVN r34719] --- src/converter/type_id.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/converter/type_id.cpp b/src/converter/type_id.cpp index 738cfd11..c6a8bf7a 100644 --- a/src/converter/type_id.cpp +++ b/src/converter/type_id.cpp @@ -14,7 +14,7 @@ #if defined(__QNXNTO__) # include -#else /* defined(__QNXNTO__) */ +#else /* defined(__QNXNTO__) */ #if !defined(__GNUC__) || __GNUC__ >= 3 || __SGI_STL_PORT || __EDG_VERSION__ # include @@ -35,7 +35,7 @@ class __class_type_info; # include # endif # endif -#endif /* defined(__QNXNTO__) */ +#endif /* defined(__QNXNTO__) */ namespace boost { namespace python { @@ -45,7 +45,7 @@ namespace boost { namespace python { namespace cxxabi { extern "C" char* __cxa_demangle(char const*, char*, std::size_t*, int*); } -# else /* defined(__QNXNTO__) */ +# else /* defined(__QNXNTO__) */ # ifdef __GNUC__ # if __GNUC__ < 3 @@ -61,10 +61,10 @@ namespace abi { extern "C" char* __cxa_demangle(char const*, char*, std::size_t*, int*); } -# endif /* __GNUC__ == 3 && __GNUC_MINOR__ == 0 */ -# endif /* __GNUC__ < 3 */ -# endif /* __GNUC__ */ -# endif /* defined(__QNXNTO__) */ +# endif /* __GNUC__ == 3 && __GNUC_MINOR__ == 0 */ +# endif /* __GNUC__ < 3 */ +# endif /* __GNUC__ */ +# endif /* defined(__QNXNTO__) */ namespace { From f240e0bab644b353b8f194defa14012804c69fa4 Mon Sep 17 00:00:00 2001 From: Gennaro Prota Date: Mon, 24 Jul 2006 22:20:25 +0000 Subject: [PATCH 021/268] removed tabs (inspect tool) [SVN r34720] --- src/exec.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/exec.cpp b/src/exec.cpp index 0981f8b1..5d20bd82 100644 --- a/src/exec.cpp +++ b/src/exec.cpp @@ -34,9 +34,9 @@ object exec_file(str filename, object global, object local) if (!pyfile) throw std::invalid_argument(std::string(f) + " : no such file"); python::handle<> file(pyfile); PyObject* result = PyRun_File(PyFile_AsFile(file.get()), - f, - Py_file_input, - global.ptr(), local.ptr()); + f, + Py_file_input, + global.ptr(), local.ptr()); if (!result) throw_error_already_set(); return object(detail::new_reference(result)); } From 9ee0d36a1df4cdb45e0cc2847a52caadd1a55a8a Mon Sep 17 00:00:00 2001 From: Gennaro Prota Date: Mon, 24 Jul 2006 22:25:35 +0000 Subject: [PATCH 022/268] removed tabs (inspect tool) [SVN r34722] --- test/exec.cpp | 2 +- test/voidptr.cpp | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/test/exec.cpp b/test/exec.cpp index 889a5324..1843d183 100644 --- a/test/exec.cpp +++ b/test/exec.cpp @@ -54,7 +54,7 @@ void exec_test() // Register the module with the interpreter if (PyImport_AppendInittab("embedded_hello", initembedded_hello) == -1) throw std::runtime_error("Failed to add embedded_hello to the interpreter's " - "builtin modules"); + "builtin modules"); // Retrieve the main module python::object main = python::import("__main__"); diff --git a/test/voidptr.cpp b/test/voidptr.cpp index 9acc5b18..82e412be 100755 --- a/test/voidptr.cpp +++ b/test/voidptr.cpp @@ -12,23 +12,23 @@ static void *test=(void *) 78; void *get() { - return test; + return test; } void *getnull() { - return 0; + return 0; } void use(void *a) { - if(a!=test) + if(a!=test) throw std::runtime_error(std::string("failed")); } int useany(void *a) { - return a ? 1 : 0; + return a ? 1 : 0; } @@ -36,8 +36,8 @@ namespace bpl = boost::python; BOOST_PYTHON_MODULE(voidptr_ext) { - bpl::def("get", &::get, bpl::return_value_policy()); - bpl::def("getnull", &::getnull, bpl::return_value_policy()); - bpl::def("use", &::use); - bpl::def("useany", &::useany); + bpl::def("get", &::get, bpl::return_value_policy()); + bpl::def("getnull", &::getnull, bpl::return_value_policy()); + bpl::def("use", &::use); + bpl::def("useany", &::useany); } From 88be35ddc2aa06694e333820eb7264a64e5948e6 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Fri, 11 Aug 2006 00:47:48 +0000 Subject: [PATCH 023/268] Attempt Sun-5.8 workaround [SVN r34864] --- test/args.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/args.cpp b/test/args.cpp index e25ea043..c2df69d0 100644 --- a/test/args.cpp +++ b/test/args.cpp @@ -14,6 +14,10 @@ using namespace boost::python; +#if BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580)) +using boost::python::make_tuple; +#endif + tuple f(int x = 1, double y = 4.25, char const* z = "wow") { return make_tuple(x, y, z); From 48696918de8d3c8e8bf645e5e701749b53c9041b Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Fri, 11 Aug 2006 15:50:21 +0000 Subject: [PATCH 024/268] Try not specifying static link, to see if it makes Darwin happy [SVN r34871] --- test/Jamfile.v2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 8e000ec4..6e7139b2 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -170,7 +170,7 @@ bpl-test crossmod_exception [ run select_from_python_test.cpp ../src/converter/type_id.cpp : : - : BOOST_PYTHON_STATIC_LIB + : # BOOST_PYTHON_STATIC_LIB /python//python ] From dd3a136b180a54142f2eb41a7bf6d777cfaf9bac Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Tue, 22 Aug 2006 11:50:35 +0000 Subject: [PATCH 025/268] Attempted Sun workaround [SVN r34914] --- test/args.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/args.cpp b/test/args.cpp index c2df69d0..20e0e532 100644 --- a/test/args.cpp +++ b/test/args.cpp @@ -15,7 +15,7 @@ using namespace boost::python; #if BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580)) -using boost::python::make_tuple; +# define make_tuple boost::python::make_tuple #endif tuple f(int x = 1, double y = 4.25, char const* z = "wow") From c839427246dfecedd93711a4a401b0d64136ad66 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Thu, 24 Aug 2006 13:04:59 +0000 Subject: [PATCH 026/268] Sun workaround [SVN r34939] --- test/defaults.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/defaults.cpp b/test/defaults.cpp index 665abd55..5f95c544 100644 --- a/test/defaults.cpp +++ b/test/defaults.cpp @@ -17,6 +17,10 @@ using namespace boost::python; +#if BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580)) +# define make_tuple boost::python::make_tuple +#endif + char const* const format = "int(%s); char(%s); string(%s); double(%s); "; /////////////////////////////////////////////////////////////////////////////// From d3418d494c1b1567da6e24ecbcb6d245682184e1 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Thu, 24 Aug 2006 19:03:35 +0000 Subject: [PATCH 027/268] Restort BOOST_PYTHON_STATIC_LIB. We don't want to create exported symbols. [SVN r34942] --- test/Jamfile.v2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 6e7139b2..8e000ec4 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -170,7 +170,7 @@ bpl-test crossmod_exception [ run select_from_python_test.cpp ../src/converter/type_id.cpp : : - : # BOOST_PYTHON_STATIC_LIB + : BOOST_PYTHON_STATIC_LIB /python//python ] From 279a4f788852c5f2dbdf060709e676e0e3e71516 Mon Sep 17 00:00:00 2001 From: Joel de Guzman Date: Thu, 31 Aug 2006 06:01:57 +0000 Subject: [PATCH 028/268] Update [SVN r35006] --- doc/tutorial/doc/html/index.html | 6 +- doc/tutorial/doc/html/python/embedding.html | 73 +++++++++----------- doc/tutorial/doc/html/python/exposing.html | 49 ++++++------- doc/tutorial/doc/html/python/functions.html | 24 +++---- doc/tutorial/doc/html/python/hello.html | 36 +++++----- doc/tutorial/doc/html/python/object.html | 27 ++++---- doc/tutorial/doc/html/python/techniques.html | 37 +++++----- doc/tutorial/doc/tutorial.qbk | 2 +- 8 files changed, 114 insertions(+), 140 deletions(-) diff --git a/doc/tutorial/doc/html/index.html b/doc/tutorial/doc/html/index.html index 9a25b848..10529faa 100644 --- a/doc/tutorial/doc/html/index.html +++ b/doc/tutorial/doc/html/index.html @@ -31,7 +31,7 @@
-

+

Distributed under 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 ) @@ -94,7 +94,7 @@ (IDL).

- + Hello World

@@ -139,7 +139,7 @@

- +

Last revised: February 14, 2006 at 02:23:06 GMT

Last revised: August 31, 2006 at 05:59:58 GMT


diff --git a/doc/tutorial/doc/html/python/embedding.html b/doc/tutorial/doc/html/python/embedding.html index 26eaff1e..359ad5fc 100644 --- a/doc/tutorial/doc/html/python/embedding.html +++ b/doc/tutorial/doc/html/python/embedding.html @@ -40,7 +40,7 @@ Python/C API at all. So stay tuned... smiley

- + Building embedded programs

@@ -84,7 +84,7 @@ exe embedded_program # name of the executable <find-library>$(PYTHON_EMBEDDED_LIBRARY) ;

- + Getting started

@@ -93,9 +93,7 @@ exe embedded_program # name of the executable

  1. - -#include -  <boost/python.hpp>

    + #include <boost/python.hpp>

  2. Call Py_Initialize() @@ -131,7 +129,7 @@ exe embedded_program # name of the executable automate the process.

    - + Reference-counting handles and objects

    @@ -165,20 +163,17 @@ exe embedded_program # name of the executable a new reference is PyRun_String which we'll discuss in the next section.

    -
    - - -
    note Handle is a class - template, so why haven't we been using any template - parameters?

    handle has a - single template parameter specifying the type of the managed object. - This type is PyObject 99% of the time, so the parameter - was defaulted to PyObject for convenience. Therefore - we can use the shorthand handle<> instead - of the longer, but equivalent, handle<PyObject>. -
    +

    + note Handle is a class template, + so why haven't we been using any template parameters?

    + handle has a single template parameter specifying the + type of the managed object. This type is PyObject 99% + of the time, so the parameter was defaulted to PyObject + for convenience. Therefore we can use the shorthand handle<> + instead of the longer, but equivalent, handle<PyObject>. +

    - + Running Python code

    @@ -201,7 +196,7 @@ exe embedded_program # name of the executable

    - + Start symbols

    @@ -274,18 +269,16 @@ exe embedded_program # name of the executable This should create a file called 'hello.txt' in the current directory containing a phrase that is well-known in programming circles.

    -
    - - -
    note Note that - we wrap the return value of PyRun_String - in a (nameless) handle even though we are not interested - in it. If we didn't do this, the the returned object would be kept - alive unnecessarily. Unless you want to be a Dr. Frankenstein, always - wrap PyObject*s in handles. -
    +

    + note Note that we wrap + the return value of PyRun_String + in a (nameless) handle even though we are not interested + in it. If we didn't do this, the the returned object would be kept alive + unnecessarily. Unless you want to be a Dr. Frankenstein, always wrap PyObject*s + in handles. +

    - + Beyond handles

    @@ -331,17 +324,15 @@ exe embedded_program # name of the executable int five_squared = extract<int>(result); -

    - - -
    note Note that - object's member function to return the wrapped - PyObject* is called ptr instead - of get. This makes sense if you take into account - the different functions that object and handle - perform.
    +

    + note Note that object's + member function to return the wrapped PyObject* is called + ptr instead of get. This makes sense + if you take into account the different functions that object + and handle perform. +

    - + Exception handling

    diff --git a/doc/tutorial/doc/html/python/exposing.html b/doc/tutorial/doc/html/python/exposing.html index fa5c1096..b978d50a 100644 --- a/doc/tutorial/doc/html/python/exposing.html +++ b/doc/tutorial/doc/html/python/exposing.html @@ -379,13 +379,10 @@ The wrapper template makes the job of wrapping classes that are meant to overridden in Python, easier.

    -
    - - -
    alert MSVC6/7 Workaround
    -
    If you are using Microsoft Visual C++ 6 or 7, you have to write - f as:

    - return call<int>(this->get_override("f").ptr());.
    +

    + alert MSVC6/7 Workaround
    +
    If you are using Microsoft Visual C++ 6 or 7, you have to write f as:

    return call<int>(this->get_override("f").ptr());. +

    BaseWrap's overridden virtual member function f in effect calls the corresponding method of the Python object through get_override. @@ -403,14 +400,10 @@ that the function f is a pure virtual function.

    -
    - - -
    note member function and - methods

    Python, like many object oriented languages - uses the term methods. Methods correspond - roughly to C++'s member functions -
    +

    + note member function and methods
    +
    Python, like many object oriented languages uses the term methods. Methods correspond roughly to C++'s member functions +

@@ -464,12 +457,11 @@ we have to check if there is an override for f. If none, then we call Base::f().

-
- - -
alert MSVC6/7 Workaround
-
If you are using Microsoft Visual C++ 6 or 7, you have to rewrite - the line with the *note* as:

return call<char const*>(f.ptr());.
+

+ alert MSVC6/7 Workaround
+
If you are using Microsoft Visual C++ 6 or 7, you have to rewrite + the line with the *note* as:

return call<char const*>(f.ptr());. +

Finally, exposing:

@@ -516,7 +508,7 @@

Class Operators/Special Functions

- + Python Operators

@@ -565,7 +557,7 @@ expressions".

- + Special Methods

@@ -593,11 +585,12 @@

Need we say more?

-
- - -
note What is the business of operator<<? Well, the method str requires the operator<< to do its work (i.e. operator<< - is used by the method defined by def(str(self)).
+

+ note What is the business of operator<<? Well, the method str + requires the operator<< + to do its work (i.e. operator<< is used by the method defined by + def(str(self)). +

diff --git a/doc/tutorial/doc/html/python/functions.html b/doc/tutorial/doc/html/python/functions.html index 81bf8263..a2ef6ff4 100644 --- a/doc/tutorial/doc/html/python/functions.html +++ b/doc/tutorial/doc/html/python/functions.html @@ -206,7 +206,7 @@ Namespaces are one honking great idea -- let's do more of those!
  • BOOM!
  • - + Call Policies

    @@ -287,13 +287,11 @@ Namespaces are one honking great idea -- let's do more of those! and hold the instance -

    - - -
    smiley Remember the Zen, Luke:
    -
    "Explicit is better than implicit"
    "In - the face of ambiguity, refuse the temptation to guess"
    -
    +

    + smiley Remember the Zen, Luke:
    +
    "Explicit is better than implicit"
    "In the face + of ambiguity, refuse the temptation to guess"
    +

    @@ -404,7 +402,7 @@ Namespaces are one honking great idea -- let's do more of those!

    - + BOOST_PYTHON_FUNCTION_OVERLOADS

    @@ -434,7 +432,7 @@ Namespaces are one honking great idea -- let's do more of those! def("foo", foo, foo_overloads());

    - + BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS

    @@ -480,7 +478,7 @@ Namespaces are one honking great idea -- let's do more of those! reference for details.

    - + init and optional

    @@ -547,14 +545,14 @@ Namespaces are one honking great idea -- let's do more of those! Then...

    -.def("foo", foo, foo_overloads());
    +.def("foo", (void(*)(bool, int, char))0, foo_overloads());
     

    Notice though that we have a situation now where we have a minimum of zero (0) arguments and a maximum of 3 arguments.

    - + Manual Wrapping

    diff --git a/doc/tutorial/doc/html/python/hello.html b/doc/tutorial/doc/html/python/hello.html index fe93c26b..c166c4e0 100644 --- a/doc/tutorial/doc/html/python/hello.html +++ b/doc/tutorial/doc/html/python/hello.html @@ -26,7 +26,7 @@

    Building Hello World

    - + From Start To Finish

    @@ -35,17 +35,16 @@ necessary to achieve that. We shall use the build tool that comes bundled with every boost distribution: bjam.

    -
    - - -
    note Building without bjam
    -
    Besides bjam, there are of course other ways to get your module - built. What's written here should not be taken as "the one and only - way". There are of course other build tools apart from bjam.
    -
    Take note however that the preferred build tool for Boost.Python - is bjam. There are so many ways to set up the build incorrectly. Experience - shows that 90% of the "I can't build Boost.Python" problems - come from people who had to use a different tool.
    +

    + note Building without bjam
    +
    Besides bjam, there are of course other ways to get your module built. + What's written here should not be taken as "the one and only way". + There are of course other build tools apart from bjam.
    +
    Take note however that the preferred build tool for Boost.Python is + bjam. There are so many ways to set up the build incorrectly. Experience shows + that 90% of the "I can't build Boost.Python" problems come from people + who had to use a different tool. +

    We shall skip over the details. Our objective will be to simply create the hello world module and run it in Python. For a complete reference to building @@ -99,7 +98,7 @@ platforms. The complete list of Bjam executables can be found here.

    - + Let's Jam!

    @@ -150,7 +149,7 @@ extension hello # Declare a Python extension called hello The last part tells BJam that we are depending on the Boost Python Library.

    - + Running bjam

    @@ -178,11 +177,10 @@ set PYTHON_VERSION=2.2 The above assumes that the Python installation is in c:/dev/tools/python and that we are using Python version 2.2. You'll have to tweak these appropriately.

    -
    - - -
    tip Be sure not to include a third number, e.g. not "2.2.1", even if that's the version - you have.
    +

    + tip Be sure not to include a third number, e.g. not "2.2.1", even if that's the version you + have. +

    Take note that you may also do that through the Jamrules file we put in our project as detailed above. The file has detailed diff --git a/doc/tutorial/doc/html/python/object.html b/doc/tutorial/doc/html/python/object.html index 50a11036..29e997dd 100644 --- a/doc/tutorial/doc/html/python/object.html +++ b/doc/tutorial/doc/html/python/object.html @@ -176,12 +176,11 @@ % x,y,z in Python, which is useful since there's no easy way to do that in std C++.

    -
    - - -
    alert Beware the - common pitfall of forgetting that the constructors of most of Python's - mutable types make copies, just as in Python.
    +

    + alert Beware the common + pitfall of forgetting that the constructors of most of Python's mutable types + make copies, just as in Python. +

    Python:

    @@ -197,7 +196,7 @@ d['whatever'] = 3; // modifies the copy

    - + class_<T> as objects

    @@ -295,14 +294,12 @@ above creates a Python class derived from Python's int type which is associated with the C++ type passed as its first parameter.

    -
    - - -
    note what is a scope?
    -
    The scope is a class that has an associated global Python object - which controls the Python namespace in which new extension classes - and wrapped functions will be defined as attributes. Details can be - found here.
    +

    + note what is a scope?
    +
    The scope is a class that has an associated global Python object which + controls the Python namespace in which new extension classes and wrapped + functions will be defined as attributes. Details can be found here. +

    You can access those values in Python as

    diff --git a/doc/tutorial/doc/html/python/techniques.html b/doc/tutorial/doc/html/python/techniques.html index 4f57d5b4..a06ea749 100644 --- a/doc/tutorial/doc/html/python/techniques.html +++ b/doc/tutorial/doc/html/python/techniques.html @@ -96,13 +96,12 @@ Compiling these files will generate the following Python extensions: core.pyd, io.pyd and filters.pyd.

    -
    - - -
    note The extension .pyd is used - for python extension modules, which are just shared libraries. Using - the default for your system, like .so for Unix and - .dll for Windows, works just as well.
    +

    + note The extension .pyd is used for python + extension modules, which are just shared libraries. Using the default for + your system, like .so for Unix and .dll + for Windows, works just as well. +

    Now, we create this directory structure for our Python package:

    @@ -425,19 +424,17 @@ exporting it to Python at the same time: changes in a class will only demand the compilation of a single cpp, instead of the entire wrapper code.

    -
    - - -
    note If you're exporting your classes with Pyste, - take a look at the --multiple option, that generates - the wrappers in various files as demonstrated here.
    -
    - - -
    note This method is useful too if you are getting the - error message "fatal error C1204:Compiler limit:internal - structure overflow" when compiling a large source file, - as explained in the FAQ.
    +

    + note If you're exporting your classes with Pyste, + take a look at the --multiple option, that generates the + wrappers in various files as demonstrated here. +

    +

    + note This method is useful too if you are getting the error + message "fatal error C1204:Compiler limit:internal structure + overflow" when compiling a large source file, as explained + in the FAQ. +

    diff --git a/doc/tutorial/doc/tutorial.qbk b/doc/tutorial/doc/tutorial.qbk index 0c49dee7..c90db572 100644 --- a/doc/tutorial/doc/tutorial.qbk +++ b/doc/tutorial/doc/tutorial.qbk @@ -1100,7 +1100,7 @@ overloaded functions in one-shot: Then... - .def("foo", foo, foo_overloads()); + .def("foo", (void(*)(bool, int, char))0, foo_overloads()); Notice though that we have a situation now where we have a minimum of zero (0) arguments and a maximum of 3 arguments. From 5a143197539faa52d05751936c212a81215d6e33 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Mon, 11 Sep 2006 10:38:14 +0000 Subject: [PATCH 029/268] SunPro workarounds [SVN r35067] --- test/numpy.cpp | 4 ++++ test/pickle3.cpp | 4 ++++ test/slice.cpp | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/test/numpy.cpp b/test/numpy.cpp index 4c7f0a12..9fdf311c 100644 --- a/test/numpy.cpp +++ b/test/numpy.cpp @@ -10,6 +10,10 @@ using namespace boost::python; +#if BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580)) +# define make_tuple boost::python::make_tuple +#endif + // See if we can invoke array() from C++ object new_array() { diff --git a/test/pickle3.cpp b/test/pickle3.cpp index cffcb9c0..2816a428 100644 --- a/test/pickle3.cpp +++ b/test/pickle3.cpp @@ -25,6 +25,10 @@ #include #include +#if BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580)) +# define make_tuple boost::python::make_tuple +#endif + namespace { // Avoid cluttering the global namespace. // A friendly class. diff --git a/test/slice.cpp b/test/slice.cpp index 6532fd60..b93e480f 100644 --- a/test/slice.cpp +++ b/test/slice.cpp @@ -9,6 +9,10 @@ using namespace boost::python; +#if BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580)) +# define make_tuple boost::python::make_tuple +#endif + // These checks are only valid under Python 2.3 // (rich slicing wasn't supported for builtins under Python 2.2) bool check_string_rich_slice() From 9366c4835194cb091ed23f3b0b68faf907c53846 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Mon, 11 Sep 2006 22:08:18 +0000 Subject: [PATCH 030/268] add missing license/copyright info [SVN r35068] --- build/Jamfile | 7 +++---- build/Jamfile.v2 | 4 ++++ doc/PyConDC_2003/bpl.html | 6 ++++++ doc/PyConDC_2003/bpl.txt | 4 ++++ doc/PyConDC_2003/bpl_mods.txt | 4 ++++ doc/building.html | 3 +++ doc/index.html | 3 +++ doc/news.html | 3 +++ doc/projects.html | 3 +++ doc/support.html | 3 +++ doc/tutorial/doc/html/index.html | 3 +++ doc/tutorial/doc/html/python/embedding.html | 3 +++ doc/tutorial/doc/html/python/exception.html | 3 +++ doc/tutorial/doc/html/python/exposing.html | 3 +++ doc/tutorial/doc/html/python/functions.html | 3 +++ doc/tutorial/doc/html/python/hello.html | 3 +++ doc/tutorial/doc/html/python/iterators.html | 3 +++ doc/tutorial/doc/html/python/object.html | 3 +++ doc/tutorial/doc/html/python/techniques.html | 3 +++ doc/tutorial/index.html | 3 +++ doc/v2/Apr2002.html | 3 +++ doc/v2/CallPolicies.html | 3 +++ doc/v2/Dereferenceable.html | 3 +++ doc/v2/Extractor.html | 3 +++ doc/v2/HolderGenerator.html | 3 +++ doc/v2/Jun2002.html | 3 +++ doc/v2/Mar2002.html | 3 +++ doc/v2/May2002.html | 3 +++ doc/v2/ObjectWrapper.html | 3 +++ doc/v2/ResultConverter.html | 3 +++ doc/v2/acknowledgments.html | 3 +++ doc/v2/args.html | 3 +++ doc/v2/call.html | 3 +++ doc/v2/call_method.html | 3 +++ doc/v2/callbacks.html | 3 +++ doc/v2/class.html | 3 +++ doc/v2/configuration.html | 3 +++ doc/v2/copy_const_reference.html | 3 +++ doc/v2/copy_non_const_reference.html | 3 +++ doc/v2/data_members.html | 3 +++ doc/v2/def.html | 3 +++ doc/v2/definitions.html | 3 +++ doc/v2/dict.html | 3 +++ doc/v2/docstring_options.html | 3 +++ doc/v2/enum.html | 3 +++ doc/v2/errors.html | 3 +++ doc/v2/exception_translator.html | 3 +++ doc/v2/exec.html | 3 +++ doc/v2/extract.html | 3 +++ doc/v2/faq.html | 3 +++ doc/v2/handle.html | 3 +++ doc/v2/has_back_reference.html | 3 +++ doc/v2/implicit.html | 3 +++ doc/v2/import.html | 3 +++ doc/v2/index.html | 3 +++ doc/v2/indexing.html | 3 +++ doc/v2/init.html | 3 +++ doc/v2/instance_holder.html | 3 +++ doc/v2/iterator.html | 3 +++ doc/v2/list.html | 3 +++ doc/v2/long.html | 3 +++ doc/v2/lvalue_from_pytype.html | 3 +++ doc/v2/make_function.html | 3 +++ doc/v2/manage_new_object.html | 3 +++ doc/v2/numeric.html | 3 +++ doc/v2/object.html | 3 +++ doc/v2/opaque_pointer_converter.html | 3 +++ doc/v2/operators.html | 3 +++ doc/v2/overloads.html | 3 +++ doc/v2/platforms.html | 3 +++ doc/v2/progress_reports.html | 3 +++ doc/v2/python.html | 3 +++ doc/v2/raw_function.html | 3 +++ doc/v2/reference.html | 3 +++ doc/v2/reference_existing_object.html | 3 +++ doc/v2/register_ptr_to_python.html | 3 +++ doc/v2/return_arg.html | 3 +++ doc/v2/return_by_value.html | 3 +++ doc/v2/return_internal_reference.html | 3 +++ doc/v2/return_opaque_pointer.html | 3 +++ doc/v2/return_value_policy.html | 3 +++ doc/v2/scope.html | 3 +++ doc/v2/slice.html | 3 +++ doc/v2/stl_iterator.html | 3 +++ doc/v2/str.html | 3 +++ doc/v2/to_python_converter.html | 3 +++ doc/v2/tuple.html | 3 +++ doc/v2/with_custodian_and_ward.html | 3 +++ 88 files changed, 270 insertions(+), 4 deletions(-) diff --git a/build/Jamfile b/build/Jamfile index f4293c0d..92f715c2 100644 --- a/build/Jamfile +++ b/build/Jamfile @@ -1,7 +1,6 @@ -# (C) Copyright David Abrahams 2001. Permission to copy, use, modify, sell and -# distribute this software is granted provided this copyright notice appears -# in all copies. This software is provided "as is" without express or implied -# warranty, and with no claim as to its suitability for any purpose. +# Copyright David Abrahams 2001-2006. Distributed under 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) # # Boost.Python library Jamfile diff --git a/build/Jamfile.v2 b/build/Jamfile.v2 index dbf0df00..3987bb15 100644 --- a/build/Jamfile.v2 +++ b/build/Jamfile.v2 @@ -1,3 +1,7 @@ +# Copyright David Abrahams 2001-2006. Distributed under 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) + import os ; import modules ; diff --git a/doc/PyConDC_2003/bpl.html b/doc/PyConDC_2003/bpl.html index 4ee77260..32b655bd 100755 --- a/doc/PyConDC_2003/bpl.html +++ b/doc/PyConDC_2003/bpl.html @@ -1,5 +1,11 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc/tutorial/doc/html/python/embedding.html b/doc/tutorial/doc/html/python/embedding.html index 359ad5fc..79971d82 100644 --- a/doc/tutorial/doc/html/python/embedding.html +++ b/doc/tutorial/doc/html/python/embedding.html @@ -1,3 +1,6 @@ + + + diff --git a/doc/tutorial/doc/html/python/exception.html b/doc/tutorial/doc/html/python/exception.html index d443959b..04033f03 100644 --- a/doc/tutorial/doc/html/python/exception.html +++ b/doc/tutorial/doc/html/python/exception.html @@ -1,3 +1,6 @@ + + + diff --git a/doc/tutorial/doc/html/python/exposing.html b/doc/tutorial/doc/html/python/exposing.html index b978d50a..42f188f3 100644 --- a/doc/tutorial/doc/html/python/exposing.html +++ b/doc/tutorial/doc/html/python/exposing.html @@ -1,3 +1,6 @@ + + + diff --git a/doc/tutorial/doc/html/python/functions.html b/doc/tutorial/doc/html/python/functions.html index a2ef6ff4..3a9b53b3 100644 --- a/doc/tutorial/doc/html/python/functions.html +++ b/doc/tutorial/doc/html/python/functions.html @@ -1,3 +1,6 @@ + + + diff --git a/doc/tutorial/doc/html/python/hello.html b/doc/tutorial/doc/html/python/hello.html index c166c4e0..efdba8c2 100644 --- a/doc/tutorial/doc/html/python/hello.html +++ b/doc/tutorial/doc/html/python/hello.html @@ -1,3 +1,6 @@ + + + diff --git a/doc/tutorial/doc/html/python/iterators.html b/doc/tutorial/doc/html/python/iterators.html index 4abaa075..bbe42b0f 100644 --- a/doc/tutorial/doc/html/python/iterators.html +++ b/doc/tutorial/doc/html/python/iterators.html @@ -1,3 +1,6 @@ + + + diff --git a/doc/tutorial/doc/html/python/object.html b/doc/tutorial/doc/html/python/object.html index 29e997dd..583a4779 100644 --- a/doc/tutorial/doc/html/python/object.html +++ b/doc/tutorial/doc/html/python/object.html @@ -1,3 +1,6 @@ + + + diff --git a/doc/tutorial/doc/html/python/techniques.html b/doc/tutorial/doc/html/python/techniques.html index a06ea749..a60b7278 100644 --- a/doc/tutorial/doc/html/python/techniques.html +++ b/doc/tutorial/doc/html/python/techniques.html @@ -1,3 +1,6 @@ + + + diff --git a/doc/tutorial/index.html b/doc/tutorial/index.html index b6ce29ba..c2a2aab5 100644 --- a/doc/tutorial/index.html +++ b/doc/tutorial/index.html @@ -1,4 +1,7 @@ + + + diff --git a/doc/v2/Apr2002.html b/doc/v2/Apr2002.html index 125c7b75..4b26cb93 100644 --- a/doc/v2/Apr2002.html +++ b/doc/v2/Apr2002.html @@ -1,3 +1,6 @@ + + + diff --git a/doc/v2/CallPolicies.html b/doc/v2/CallPolicies.html index 946296a9..5efbdcdb 100644 --- a/doc/v2/CallPolicies.html +++ b/doc/v2/CallPolicies.html @@ -1,5 +1,8 @@ + + + + + diff --git a/doc/v2/Extractor.html b/doc/v2/Extractor.html index d09f7e12..72915f84 100755 --- a/doc/v2/Extractor.html +++ b/doc/v2/Extractor.html @@ -1,3 +1,6 @@ + + + diff --git a/doc/v2/HolderGenerator.html b/doc/v2/HolderGenerator.html index 9443c73a..e904b115 100755 --- a/doc/v2/HolderGenerator.html +++ b/doc/v2/HolderGenerator.html @@ -1,3 +1,6 @@ + + + diff --git a/doc/v2/Jun2002.html b/doc/v2/Jun2002.html index 6521e79a..d3d61d49 100644 --- a/doc/v2/Jun2002.html +++ b/doc/v2/Jun2002.html @@ -1,3 +1,6 @@ + + + diff --git a/doc/v2/Mar2002.html b/doc/v2/Mar2002.html index a815f358..60a2f720 100644 --- a/doc/v2/Mar2002.html +++ b/doc/v2/Mar2002.html @@ -1,3 +1,6 @@ + + + diff --git a/doc/v2/May2002.html b/doc/v2/May2002.html index b89f82e1..764b7d9e 100644 --- a/doc/v2/May2002.html +++ b/doc/v2/May2002.html @@ -1,3 +1,6 @@ + + + diff --git a/doc/v2/ObjectWrapper.html b/doc/v2/ObjectWrapper.html index 9949173d..3b8d797c 100644 --- a/doc/v2/ObjectWrapper.html +++ b/doc/v2/ObjectWrapper.html @@ -1,5 +1,8 @@ + + + + + diff --git a/doc/v2/acknowledgments.html b/doc/v2/acknowledgments.html index 0391c5d1..4d9894e7 100644 --- a/doc/v2/acknowledgments.html +++ b/doc/v2/acknowledgments.html @@ -1,5 +1,8 @@ + + + + + + + + diff --git a/doc/v2/call_method.html b/doc/v2/call_method.html index 50eb6e3e..0965002f 100644 --- a/doc/v2/call_method.html +++ b/doc/v2/call_method.html @@ -1,5 +1,8 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc/v2/extract.html b/doc/v2/extract.html index 10c21ef3..dc63b9e6 100644 --- a/doc/v2/extract.html +++ b/doc/v2/extract.html @@ -1,5 +1,8 @@ + + + + + + + + + + + + + + + + + + diff --git a/doc/v2/index.html b/doc/v2/index.html index 0d5ace16..92593d06 100644 --- a/doc/v2/index.html +++ b/doc/v2/index.html @@ -1,5 +1,8 @@ + + + + + + + + + + + + diff --git a/doc/v2/iterator.html b/doc/v2/iterator.html index fa53faa2..8d0ab613 100644 --- a/doc/v2/iterator.html +++ b/doc/v2/iterator.html @@ -1,5 +1,8 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc/v2/operators.html b/doc/v2/operators.html index b4d91bb8..231ddf01 100755 --- a/doc/v2/operators.html +++ b/doc/v2/operators.html @@ -1,5 +1,8 @@ + + + + + + + + + + + diff --git a/doc/v2/python.html b/doc/v2/python.html index 9895fb53..1e50f88d 100644 --- a/doc/v2/python.html +++ b/doc/v2/python.html @@ -1,5 +1,8 @@ + + + + + + + + + + + + + + diff --git a/doc/v2/return_arg.html b/doc/v2/return_arg.html index d9500011..3ecfc898 100755 --- a/doc/v2/return_arg.html +++ b/doc/v2/return_arg.html @@ -1,5 +1,8 @@ + + + + + + + + + + + + diff --git a/doc/v2/return_value_policy.html b/doc/v2/return_value_policy.html index 3d9cb611..2a05eaca 100644 --- a/doc/v2/return_value_policy.html +++ b/doc/v2/return_value_policy.html @@ -1,5 +1,8 @@ + + + + + + + + + + + + diff --git a/doc/v2/str.html b/doc/v2/str.html index 037d5401..382a3707 100644 --- a/doc/v2/str.html +++ b/doc/v2/str.html @@ -1,5 +1,8 @@ + + + + + + + + + + + + Date: Tue, 12 Sep 2006 22:37:09 +0000 Subject: [PATCH 031/268] Move definition of BOOST_PYTHON_SUPPRESS_REGISTRY_INITIALIZATION back where it belongs. [SVN r35076] --- test/Jamfile.v2 | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 8e000ec4..7dd3ffe0 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -4,7 +4,13 @@ project /boost/python/test ; rule py-run ( sources * ) { - return [ run $(sources) /boost/python//boost_python /python//python ] ; + return [ run $(sources) /boost/python//boost_python /python//python + : # args + : # input files + : #requirements + BOOST_PYTHON_SUPPRESS_REGISTRY_INITIALIZATION + + ] ; } rule py-compile ( sources * ) @@ -18,10 +24,6 @@ rule py-compile-fail ( sources * ) } -project : - requirements BOOST_PYTHON_SUPPRESS_REGISTRY_INITIALIZATION - ; - #template py-unit-test # : From 05070faf122e8d3814d18f74ba613b6fc23265ca Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Tue, 12 Sep 2006 23:58:40 +0000 Subject: [PATCH 032/268] Attempt to capture better debugging info in output [SVN r35079] --- test/numpy.cpp | 77 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 47 insertions(+), 30 deletions(-) diff --git a/test/numpy.cpp b/test/numpy.cpp index 9fdf311c..deb9667b 100644 --- a/test/numpy.cpp +++ b/test/numpy.cpp @@ -39,16 +39,33 @@ void info(numeric::array const& z) z.info(); } +#define CHECK(expr) \ +{ \ + object result; \ + try { result = object(expr); } \ + catch(error_already_set) \ + { \ + PyObject* type, *value, *traceback; \ + PyErr_Fetch(&type, &value, &traceback); \ + handle<> ty(type), v(value), tr(traceback); \ + str format("exception type: %s\n"); \ + format += "exception value: %s\n"; \ + format += "traceback:\n%s" ; \ + result = format % boost::python::make_tuple(ty, v, tr); \ + } \ + check(result); \ +} + // Tests which work on both Numeric and numarray array objects. Of // course all of the operators "just work" since numeric::array // inherits that behavior from object. void exercise(numeric::array& y, object check) { y[make_tuple(2,1)] = 3; - check(y); - check(y.astype('D')); - check(y.copy()); - check(y.typecode()); + CHECK(y); + CHECK(y.astype('D')); + CHECK(y.copy()); + CHECK(y.typecode()); } // numarray-specific tests. check is a callable object which we can @@ -56,43 +73,43 @@ void exercise(numeric::array& y, object check) // the results of corresponding python operations. void exercise_numarray(numeric::array& y, object check) { - check(y.astype()); + CHECK(y.astype()); - check(y.argmax()); - check(y.argmax(0)); + CHECK(y.argmax()); + CHECK(y.argmax(0)); - check(y.argmin()); - check(y.argmin(0)); + CHECK(y.argmin()); + CHECK(y.argmin(0)); - check(y.argsort()); - check(y.argsort(1)); + CHECK(y.argsort()); + CHECK(y.argsort(1)); y.byteswap(); - check(y); + CHECK(y); - check(y.diagonal()); - check(y.diagonal(1)); - check(y.diagonal(0, 1)); - check(y.diagonal(0, 1, 0)); + CHECK(y.diagonal()); + CHECK(y.diagonal(1)); + CHECK(y.diagonal(0, 1)); + CHECK(y.diagonal(0, 1, 0)); - check(y.is_c_array()); - check(y.isbyteswapped()); + CHECK(y.is_c_array()); + CHECK(y.isbyteswapped()); - check(y.trace()); - check(y.trace(1)); - check(y.trace(0, 1)); - check(y.trace(0, 1, 0)); + CHECK(y.trace()); + CHECK(y.trace(1)); + CHECK(y.trace(0, 1)); + CHECK(y.trace(0, 1, 0)); - check(y.new_('D')); + CHECK(y.new_('D')); y.sort(); - check(y); - check(y.type()); + CHECK(y); + CHECK(y.type()); - check(y.factory(make_tuple(1.2, 3.4))); - check(y.factory(make_tuple(1.2, 3.4), "Double")); - check(y.factory(make_tuple(1.2, 3.4), "Double", make_tuple(1,2,1))); - check(y.factory(make_tuple(1.2, 3.4), "Double", make_tuple(2,1,1), false)); - check(y.factory(make_tuple(1.2, 3.4), "Double", make_tuple(2), true, true)); + CHECK(y.factory(make_tuple(1.2, 3.4))); + CHECK(y.factory(make_tuple(1.2, 3.4), "Double")); + CHECK(y.factory(make_tuple(1.2, 3.4), "Double", make_tuple(1,2,1))); + CHECK(y.factory(make_tuple(1.2, 3.4), "Double", make_tuple(2,1,1), false)); + CHECK(y.factory(make_tuple(1.2, 3.4), "Double", make_tuple(2), true, true)); } BOOST_PYTHON_MODULE(numpy_ext) From 567a2c7b89d99baf20cff5799c5f23048b7ec4a9 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Wed, 13 Sep 2006 22:47:11 +0000 Subject: [PATCH 033/268] attempt unverified workaround for http://tinyurl.com/gvrgd [SVN r35103] --- src/converter/builtin_converters.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/converter/builtin_converters.cpp b/src/converter/builtin_converters.cpp index 2ce1fe9f..e1dead43 100644 --- a/src/converter/builtin_converters.cpp +++ b/src/converter/builtin_converters.cpp @@ -304,13 +304,16 @@ namespace static std::wstring extract(PyObject* intermediate) { std::wstring result(::PyObject_Length(intermediate), L' '); - int err = PyUnicode_AsWideChar( - (PyUnicodeObject *)intermediate - , result.size() ? &result[0] : 0 - , result.size()); + if (!result.empty()) + { + int err = PyUnicode_AsWideChar( + (PyUnicodeObject *)intermediate + , &result[0] + , result.size()); - if (err == -1) - throw_error_already_set(); + if (err == -1) + throw_error_already_set(); + } return result; } }; From 2610eb9acb04ad3902654202254d047802923de7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gottfried=20Gan=C3=9Fauge?= Date: Thu, 14 Sep 2006 05:59:29 +0000 Subject: [PATCH 034/268] Type object for opaque initialized with PyType_Clear. opaque is registered only if not another module has already registered a conversion for that pointer type. Doc update. [SVN r35104] --- doc/v2/opaque_pointer_converter.html | 145 ------------------ doc/v2/reference.html | 10 +- doc/v2/return_opaque_pointer.html | 6 +- .../boost/python/opaque_pointer_converter.hpp | 27 +++- test/Jamfile | 4 + test/Jamfile.v2 | 4 + test/opaque.py | 7 +- 7 files changed, 45 insertions(+), 158 deletions(-) delete mode 100644 doc/v2/opaque_pointer_converter.html diff --git a/doc/v2/opaque_pointer_converter.html b/doc/v2/opaque_pointer_converter.html deleted file mode 100644 index a44dee92..00000000 --- a/doc/v2/opaque_pointer_converter.html +++ /dev/null @@ -1,145 +0,0 @@ - - - - - - - - - - - Boost.Python - <boost/python/opaque_pointer_converter.hpp> - - - -
    - - - - - -
    -

    C++ Boost

    -
    -

    Boost.Python

    - -

    Header - <boost/python/opaque_pointer_converter.hpp>

    -
    -
    - -

    Contents

    - -
    -
    Classes
    - -
    -
    -
    Class template - opaque_pointer_converter<P>
    - -
    -
    -
    Class template - opaque_pointer_converter synopsis
    -
    -
    -
    -
    - -
    Macros
    -
    -
    -
    Macro - BOOST_PYTHON_OPAQUE_SPECIALIZED_TYPE_ID
    -
    -
    - -
    Example
    - -
    See Also
    -
    -
    - -

    Classes

    - -

    Class template - opaque_pointer_converter<P>

    - -

    opaque_pointer_converter<> is derived from - - to_python_converter - and registers itself as an - - lvalue_from_pytype converter from Python objects - into pointers to undefined types. - Thus it may be used as a converter from opaque pointers into - Python objects and vice versa.

    - -

    Class template - opaque_pointer_converter synopsis

    -
    -namespace boost { namespace python
    -{
    -    template<class Pointer>
    -    struct opaque_pointer_converter
    -        : to_python_converter<
    -          Pointer, opaque_pointer_converter<Pointer> >
    -    {
    -        explicit opaque_pointer_converter(char const* name);
    -    };
    -}}
    -
    - -

    Class template - opaque_pointer_converter constructor

    -
    -explicit opaque_pointer_converter(char const* name);
    -
    - -
    -
    Effects: -

    Registers the instance as a - - lvalue_from_pytype converter from Python objects - into opaque pointers.

    -

    The name is used for the type of the Python Objects created; - it should be printable but needn't be an - ntbs because the object type is - not supposed to be user constructible within python scripts.

    -
    -
    - -

    Macros

    - -

    - Macro BOOST_PYTHON_OPAQUE_SPECIALIZED_TYPE_ID(Pointee)

    -

    This macro must be used to define specializations of the - type_id function - which can't be instantiated for incomplete types.

    -

    Note

    -

    In order for this to work in a cross-module environment the macro must - be invoked in every translation unit which uses the - opaque_pointer_converter.

    - -

    Example

    - - please see example for - return_opaque_pointer. - -

    See Also

    -

    - return_opaque_pointer -

    - -

    Revised - 10 March, 2003 -

    - -

    © Copyright 2003 Haufe Mediengruppe. All Rights - Reserved.

    - - - diff --git a/doc/v2/reference.html b/doc/v2/reference.html index 5fe7b5d5..1dc9a96d 100644 --- a/doc/v2/reference.html +++ b/doc/v2/reference.html @@ -907,26 +907,26 @@
    opaque_pointer_converter.hpp
    + "opaque.html">opaque_pointer_converter.hpp
    Classes
    + "opaque.html#classes">Classes
    opaque_pointer_converter
    + "opaque.html#opaque-spec">opaque
    -
    Macros
    +
    Macros
    + "opaque.html#BOOST_PYTHON_OPAQUE_SPECIALIZED_TYPE_ID-spec"> BOOST_PYTHON_OPAQUE_SPECIALIZED_TYPE_ID
    diff --git a/doc/v2/return_opaque_pointer.html b/doc/v2/return_opaque_pointer.html index bdad3eab..52d8396e 100644 --- a/doc/v2/return_opaque_pointer.html +++ b/doc/v2/return_opaque_pointer.html @@ -70,7 +70,7 @@ undefined types such that the return value is copied into a new Python object.

    In addition to specifying the return_opaque_pointer - policy the + policy the BOOST_PYTHON_OPAQUE_SPECIALIZED_TYPE_ID macro must be used to define specializations for the type_id function @@ -177,8 +177,8 @@ if __name__ == '__main__':

    See Also

    - - opaque_pointer_converter + + opaque

    Revised diff --git a/include/boost/python/opaque_pointer_converter.hpp b/include/boost/python/opaque_pointer_converter.hpp index e54561c7..761c414e 100644 --- a/include/boost/python/opaque_pointer_converter.hpp +++ b/include/boost/python/opaque_pointer_converter.hpp @@ -1,4 +1,4 @@ -// Copyright Gottfried Ganßauge 2003. +// Copyright Gottfried Ganßauge 2003..2006. // Distributed under 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) @@ -11,6 +11,7 @@ # include # include # include +# include # include # include # include @@ -44,9 +45,16 @@ struct opaque { opaque() { - type_object.tp_name = const_cast(type_id().name()); - converter::registry::insert(&extract, type_id()); - converter::registry::insert(&wrap, type_id()); + if (type_object.tp_name == 0) + { + type_object.tp_name = const_cast(type_id().name()); + if (PyType_Ready (&type_object) < 0) + { + throw error_already_set(); + } + + register_self(); + } } static opaque instance; @@ -78,6 +86,17 @@ private: } } + void register_self() { + converter::registration const *existing = + converter::registry::query (type_id()); + + if ((existing == 0) || (existing->m_to_python == 0)) + { + converter::registry::insert(&extract, type_id()); + converter::registry::insert(&wrap, type_id()); + } + } + struct python_instance { PyObject_HEAD diff --git a/test/Jamfile b/test/Jamfile index 87abb096..d3a435f0 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -170,6 +170,10 @@ bpl-test crossmod_exception [ bpl-test extract ] +[ +bpl-test crossmod_opaque + : crossmod_opaque.py crossmod_opaque_a.cpp crossmod_opaque_b.cpp +] [ bpl-test opaque ] [ bpl-test voidptr ] diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 7dd3ffe0..14a6d633 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -116,6 +116,10 @@ bpl-test crossmod_exception [ bpl-test extract ] +[ +bpl-test crossmod_opaque + : crossmod_opaque.py crossmod_opaque_a.cpp crossmod_opaque_b.cpp +] [ bpl-test opaque ] [ bpl-test voidptr ] diff --git a/test/opaque.py b/test/opaque.py index 6d994bd7..ab1bfb13 100644 --- a/test/opaque.py +++ b/test/opaque.py @@ -1,5 +1,5 @@ # -*- coding: iso-latin-1 -*- -# Copyright Gottfried Ganßauge 2003. Permission to copy, use, +# Copyright Gottfried Ganßauge 2003..2006. Permission to copy, use, # modify, sell and distribute this software is granted provided this # copyright notice appears in all copies. This software is provided # "as is" without express or implied warranty, and with no claim as @@ -66,6 +66,11 @@ RuntimeError: success >>> try: use2(get()) ... except TypeError: pass ... else: print 'expected a TypeError' + + This used to result in a segmentation violation + +>>> type(get()) != type (get2()) +1 """ def run(args = None): import sys From 864ece5539b27ee3a29c3518afa1bb9c8b512ca0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gottfried=20Gan=C3=9Fauge?= Date: Thu, 14 Sep 2006 19:06:33 +0000 Subject: [PATCH 035/268] cross module compatibility test for opaque [SVN r35111] --- test/crossmod_opaque.py | 14 ++++++++++++++ test/crossmod_opaque_a.cpp | 26 ++++++++++++++++++++++++++ test/crossmod_opaque_b.cpp | 26 ++++++++++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 test/crossmod_opaque.py create mode 100644 test/crossmod_opaque_a.cpp create mode 100644 test/crossmod_opaque_b.cpp diff --git a/test/crossmod_opaque.py b/test/crossmod_opaque.py new file mode 100644 index 00000000..f649921c --- /dev/null +++ b/test/crossmod_opaque.py @@ -0,0 +1,14 @@ +# Copyright Gottfried Ganßauge 2006. +# Distributed under 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) + +print "running..." + +import crossmod_opaque_a +import crossmod_opaque_b + +crossmod_opaque_a.get() +crossmod_opaque_b.get() + +print "Done." diff --git a/test/crossmod_opaque_a.cpp b/test/crossmod_opaque_a.cpp new file mode 100644 index 00000000..80283f47 --- /dev/null +++ b/test/crossmod_opaque_a.cpp @@ -0,0 +1,26 @@ +// Copyright Gottfried Ganßauge 2006. +// Distributed under 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) +# include +# include +# include +# include + +typedef struct opaque_ *opaque; + +opaque the_op = ((opaque) 0x47110815); + +opaque get() { return the_op; } + +BOOST_PYTHON_OPAQUE_SPECIALIZED_TYPE_ID(opaque_) + +namespace bpl = boost::python; + +BOOST_PYTHON_MODULE(crossmod_opaque_a) +{ + bpl::def ( + "get", + &::get, + bpl::return_value_policy()); +} diff --git a/test/crossmod_opaque_b.cpp b/test/crossmod_opaque_b.cpp new file mode 100644 index 00000000..1e3e18bc --- /dev/null +++ b/test/crossmod_opaque_b.cpp @@ -0,0 +1,26 @@ +// Copyright Gottfried Ganßauge 2006. +// Distributed under 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) +# include +# include +# include +# include + +typedef struct opaque_ *opaque; + +opaque the_op = ((opaque) 0x47110815); + +opaque get() { return the_op; } + +BOOST_PYTHON_OPAQUE_SPECIALIZED_TYPE_ID(opaque_) + +namespace bpl = boost::python; + +BOOST_PYTHON_MODULE(crossmod_opaque_b) +{ + bpl::def ( + "get", + &::get, + bpl::return_value_policy()); +} From 777ce7b561cdcb5c3adf3960505ee512e1e25d30 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Thu, 14 Sep 2006 21:53:00 +0000 Subject: [PATCH 036/268] magic coding: iso-latin1 comment added to avoid Python SyntaxError [SVN r35113] --- test/crossmod_opaque.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test/crossmod_opaque.py b/test/crossmod_opaque.py index f649921c..06637385 100644 --- a/test/crossmod_opaque.py +++ b/test/crossmod_opaque.py @@ -1,3 +1,4 @@ +# -*- coding: iso-latin-1 -*- # Copyright Gottfried Ganßauge 2006. # Distributed under the Boost Software License, Version 1.0. (See # accompanying file LICENSE_1_0.txt or copy at From eea769717551dfee522f2f71501f7057ce48790e Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Thu, 14 Sep 2006 21:57:56 +0000 Subject: [PATCH 037/268] if __name__ == '__main__' [SVN r35114] --- test/crossmod_opaque.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/test/crossmod_opaque.py b/test/crossmod_opaque.py index 06637385..2c8075bc 100644 --- a/test/crossmod_opaque.py +++ b/test/crossmod_opaque.py @@ -4,12 +4,13 @@ # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) -print "running..." +if __name__ == '__main__': + print "running..." -import crossmod_opaque_a -import crossmod_opaque_b + import crossmod_opaque_a + import crossmod_opaque_b -crossmod_opaque_a.get() -crossmod_opaque_b.get() + crossmod_opaque_a.get() + crossmod_opaque_b.get() -print "Done." + print "Done." From f5421ca6b274e1fe2b8377c95d7eaff93da63679 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sat, 16 Sep 2006 18:43:53 +0000 Subject: [PATCH 038/268] Default to Python 2.4 in Unix builds Applied contributed patches http://tinyurl.com/ndljr and http://tinyurl.com/18r [SVN r35138] --- doc/v2/operators.html | 12 ++++++++++++ .../boost/python/converter/registrations.hpp | 1 + include/boost/python/object/pointer_holder.hpp | 2 +- include/boost/python/operators.hpp | 2 ++ src/converter/registry.cpp | 18 ++++++++++++++++++ 5 files changed, 34 insertions(+), 1 deletion(-) diff --git a/doc/v2/operators.html b/doc/v2/operators.html index 231ddf01..10e566ec 100755 --- a/doc/v2/operators.html +++ b/doc/v2/operators.html @@ -214,6 +214,9 @@ namespace boost { namespace python { namespace self_ns { operator_<unspecified> str(self_t); + operator_<unspecified> repr(self_t); + }}}; The tables below describe the methods generated when the results of the @@ -765,6 +768,15 @@ namespace boost { namespace python { namespace self_ns { lexical_cast<std::string>(x) + + + repr + + __repr__ + + lexical_cast<std::string>(x) +

    Class Template other

    diff --git a/include/boost/python/converter/registrations.hpp b/include/boost/python/converter/registrations.hpp index d71401de..0f335f95 100644 --- a/include/boost/python/converter/registrations.hpp +++ b/include/boost/python/converter/registrations.hpp @@ -34,6 +34,7 @@ struct BOOST_PYTHON_DECL registration { public: // member functions explicit registration(type_info target, bool is_shared_ptr = false); + ~registration(); // Convert the appropriately-typed data to Python PyObject* to_python(void const volatile*) const; diff --git a/include/boost/python/object/pointer_holder.hpp b/include/boost/python/object/pointer_holder.hpp index 569c9d4e..7fad2a25 100644 --- a/include/boost/python/object/pointer_holder.hpp +++ b/include/boost/python/object/pointer_holder.hpp @@ -179,7 +179,7 @@ void* pointer_holder_back_reference::holds(type_info dst_t, bool BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_UNFORWARD_LOCAL, nil) )) { - python::detail::initialize_wrapper(self, &*this->m_p); + python::detail::initialize_wrapper(self, get_pointer(this->m_p)); } # undef N diff --git a/include/boost/python/operators.hpp b/include/boost/python/operators.hpp index d10a0094..89fe4099 100644 --- a/include/boost/python/operators.hpp +++ b/include/boost/python/operators.hpp @@ -339,6 +339,7 @@ BOOST_PYTHON_UNARY_OPERATOR(long, PyLong_FromLong, long_) BOOST_PYTHON_UNARY_OPERATOR(float, double, float_) BOOST_PYTHON_UNARY_OPERATOR(complex, std::complex, complex_) BOOST_PYTHON_UNARY_OPERATOR(str, lexical_cast, str) +BOOST_PYTHON_UNARY_OPERATOR(repr, lexical_cast, repr) # undef BOOST_PYTHON_UNARY_OPERATOR }} // namespace boost::python @@ -350,6 +351,7 @@ using boost::python::self_ns::long_; using boost::python::self_ns::float_; using boost::python::self_ns::complex_; using boost::python::self_ns::str; +using boost::python::self_ns::repr; using boost::python::self_ns::pow; # endif diff --git a/src/converter/registry.cpp b/src/converter/registry.cpp index 50da37d5..179111c6 100644 --- a/src/converter/registry.cpp +++ b/src/converter/registry.cpp @@ -57,6 +57,24 @@ BOOST_PYTHON_DECL PyObject* registration::to_python(void const volatile* source) : this->m_to_python(const_cast(source)); } +namespace +{ + template< typename T > + void delete_node( T* node ) + { + if( !!node && !!node->next ) + delete_node( node->next ); + delete node; + } +} + +registration::~registration() +{ + delete_node(lvalue_chain); + delete_node(rvalue_chain); +} + + namespace // { typedef registration entry; From 0806e899641d0319b56583b900c3278a26a9811c Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 17 Sep 2006 02:41:20 +0000 Subject: [PATCH 039/268] More informative error messages Better autoconfiguration [SVN r35140] --- test/slice.cpp | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/test/slice.cpp b/test/slice.cpp index b93e480f..7a1ab020 100644 --- a/test/slice.cpp +++ b/test/slice.cpp @@ -1,5 +1,6 @@ #include #include +#include #include // Copyright (c) 2004 Jonathan Brandmeyer @@ -43,8 +44,16 @@ bool check_string_rich_slice() return s[slice(2,-1)][slice(1,-1)] == "lo, wor"; } +// Tried to get more info into the error message (actual array +// contents) but Numeric complains that treating an array as a boolean +// value doesn't make any sense. +#define ASSERT_EQUAL( e1, e2 ) \ +if ((e1) != (e2)) \ + return str("assertion failed: " #e1 " == " #e2 "\nLHS:\n") /*+ str(e1) + "\nRHS:\n" + str(e2)*/; \ +else + // These tests work with Python 2.2, but you must have Numeric installed. -bool check_numeric_array_rich_slice() +object check_numeric_array_rich_slice() { using numeric::array; array original = array( make_tuple( make_tuple( 11, 12, 13, 14), @@ -64,22 +73,21 @@ bool check_numeric_array_rich_slice() // The following comments represent equivalent Python expressions used // to validate the array behavior. // original[::] == original - if (original[slice()] != original) - return false; + ASSERT_EQUAL(original[slice()],original); + // original[:2,:2] == array( [[11, 12], [21, 22]]) - if (original[make_tuple(slice(_,2), slice(_,2))] != upper_left_quadrant) - return false; + ASSERT_EQUAL(original[make_tuple(slice(_,2), slice(_,2))],upper_left_quadrant); + // original[::2,::2] == array( [[11, 13], [31, 33]]) - if (original[make_tuple( slice(_,_,2), slice(_,_,2))] != odd_cells) - return false; + ASSERT_EQUAL(original[make_tuple( slice(_,_,2), slice(_,_,2))],odd_cells); + // original[1::2, 1::2] == array( [[22, 24], [42, 44]]) - if (original[make_tuple( slice(1,_,2), slice(1,_,2))] != even_cells) - return false; - // original[:-3:-1, :-3,-1] == array( [[44, 43], [34, 33]]) - if (original[make_tuple( slice(_,-3,-1), slice(_,-3,-1))] != lower_right_quadrant_reversed) - return false; + ASSERT_EQUAL(original[make_tuple( slice(1,_,2), slice(1,_,2))],even_cells); - return true; + // original[:-3:-1, :-3,-1] == array( [[44, 43], [34, 33]]) + ASSERT_EQUAL(original[make_tuple( slice(_,-3,-1), slice(_,-3,-1))],lower_right_quadrant_reversed); + + return str(1); } // Verify functions accepting a slice argument can be called From cee8e0704666bc932cfc1face215a75140fafe9e Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Mon, 18 Sep 2006 02:59:31 +0000 Subject: [PATCH 040/268] Checkin missing op_repr definition [SVN r35153] --- include/boost/python/detail/operator_id.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/boost/python/detail/operator_id.hpp b/include/boost/python/detail/operator_id.hpp index f2cd404e..4a2785ed 100755 --- a/include/boost/python/detail/operator_id.hpp +++ b/include/boost/python/detail/operator_id.hpp @@ -47,7 +47,8 @@ enum operator_id op_ixor, op_ior, op_complex, - op_nonzero + op_nonzero, + op_repr }; }}} // namespace boost::python::detail From 41a342f0263d31a29fc566256a86e7f0ed30e50d Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Mon, 18 Sep 2006 18:25:12 +0000 Subject: [PATCH 041/268] vc6/7 workaround [SVN r35164] --- test/slice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/slice.cpp b/test/slice.cpp index 7a1ab020..491dcbad 100644 --- a/test/slice.cpp +++ b/test/slice.cpp @@ -49,7 +49,7 @@ bool check_string_rich_slice() // value doesn't make any sense. #define ASSERT_EQUAL( e1, e2 ) \ if ((e1) != (e2)) \ - return str("assertion failed: " #e1 " == " #e2 "\nLHS:\n") /*+ str(e1) + "\nRHS:\n" + str(e2)*/; \ + return object("assertion failed: " #e1 " == " #e2 "\nLHS:\n") /*+ str(e1) + "\nRHS:\n" + str(e2)*/; \ else // These tests work with Python 2.2, but you must have Numeric installed. From bed1d26904e041cda169c07e3484dcd2e99350d9 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Mon, 18 Sep 2006 22:21:50 +0000 Subject: [PATCH 042/268] Return an int, not a string, on success from check_numeric_array_rich_slice, since that's what the tests expect. [SVN r35184] --- test/slice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/slice.cpp b/test/slice.cpp index 491dcbad..f25c9017 100644 --- a/test/slice.cpp +++ b/test/slice.cpp @@ -87,7 +87,7 @@ object check_numeric_array_rich_slice() // original[:-3:-1, :-3,-1] == array( [[44, 43], [34, 33]]) ASSERT_EQUAL(original[make_tuple( slice(_,-3,-1), slice(_,-3,-1))],lower_right_quadrant_reversed); - return str(1); + return object(1); } // Verify functions accepting a slice argument can be called From 921e306b9a59e0ba019d94b9abdecea8d5b92cf7 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Wed, 20 Sep 2006 21:59:03 +0000 Subject: [PATCH 043/268] Fix license/copyright [SVN r35234] --- doc/PyConDC_2003/default.css | 2 ++ doc/boost.css | 4 ++++ doc/polymorphism.txt | 5 +++++ doc/tutorial/doc/Jamfile.v2 | 3 +++ doc/v2/callbacks.txt | 4 ++++ doc/v2/def_visitor.html | 4 +++- doc/v2/default_call_policies.html | 6 ++++-- doc/v2/feb2002.html | 7 ++++--- doc/v2/module.html | 4 +++- doc/v2/pickle.html | 8 +++----- doc/v2/pointee.html | 5 ++++- doc/v2/ptr.html | 4 +++- doc/v2/to_python_indirect.html | 4 +++- doc/v2/to_python_value.html | 4 +++- doc/v2/type_id.html | 4 +++- doc/v2/wrapper.html | 4 +++- example/Jamfile | 5 +++-- example/Jamfile.v2 | 6 +++--- example/README | 4 ++++ example/boost-build.jam | 5 +++-- example/test_getting_started1.py | 3 +++ example/test_getting_started2.py | 3 +++ example/test_std_pair.py | 3 +++ include/boost/python/detail/python22_fixed.h | 2 ++ index.html | 3 +++ pyste/NEWS | 4 ++++ pyste/README | 4 ++++ pyste/TODO | 4 ++++ pyste/dist/create_build.py | 4 ++++ pyste/dist/setup.py | 4 ++++ pyste/doc/adding_new_methods.html | 7 +++---- pyste/doc/exporting_an_entire_header.html | 7 +++---- pyste/doc/global_variables.html | 7 +++---- pyste/doc/inserting_code.html | 7 +++---- pyste/doc/introduction.html | 7 +++---- pyste/doc/policies.html | 7 +++---- pyste/doc/pyste.txt | 6 ++++++ pyste/doc/renaming_and_excluding.html | 7 +++---- pyste/doc/running_pyste.html | 7 +++---- pyste/doc/smart_pointers.html | 7 +++---- pyste/doc/templates.html | 7 +++---- pyste/doc/the_interface_files.html | 7 +++---- pyste/doc/theme/style.css | 9 +++++++++ pyste/doc/wrappers.html | 7 +++---- pyste/index.html | 7 +++---- pyste/install/pyste.py | 4 ++++ release_notes.txt | 6 ++++++ test/Jamfile | 3 +++ test/Jamfile.v2 | 3 +++ test/andreas_beyer.cpp | 3 +++ test/crossmod_exception.py | 7 ++----- test/opaque.py | 9 ++++----- test/pointer_vector.cpp | 3 +++ 53 files changed, 183 insertions(+), 87 deletions(-) diff --git a/doc/PyConDC_2003/default.css b/doc/PyConDC_2003/default.css index 2e1fddb9..6a1adb08 100644 --- a/doc/PyConDC_2003/default.css +++ b/doc/PyConDC_2003/default.css @@ -5,6 +5,8 @@ :version: $Revision$ :copyright: This stylesheet has been placed in the public domain. +boostinspect:nolicense + Default cascading style sheet for the HTML output of Docutils. */ diff --git a/doc/boost.css b/doc/boost.css index cf5c8a97..6c3e9808 100644 --- a/doc/boost.css +++ b/doc/boost.css @@ -1,3 +1,7 @@ +/* Copyright David Abrahams 2006. Distributed under 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) +*/ H1 { FONT-SIZE: 200% diff --git a/doc/polymorphism.txt b/doc/polymorphism.txt index c6f89416..38e2f691 100644 --- a/doc/polymorphism.txt +++ b/doc/polymorphism.txt @@ -1,3 +1,8 @@ +.. Copyright David Abrahams 2006. Distributed under 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) + How Runtime Polymorphism is expressed in Boost.Python: ----------------------------------------------------- diff --git a/doc/tutorial/doc/Jamfile.v2 b/doc/tutorial/doc/Jamfile.v2 index f115ceac..963f9346 100644 --- a/doc/tutorial/doc/Jamfile.v2 +++ b/doc/tutorial/doc/Jamfile.v2 @@ -1,3 +1,6 @@ +# Copyright Joel de Guzman 2006. Distributed under 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) project boost/libs/python/doc/tutorial/doc ; import boostbook : boostbook ; diff --git a/doc/v2/callbacks.txt b/doc/v2/callbacks.txt index a58ca0ea..2795680f 100644 --- a/doc/v2/callbacks.txt +++ b/doc/v2/callbacks.txt @@ -1,3 +1,7 @@ +.. Copyright David Abrahams 2006. Distributed under 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) + Here's the plan: I aim to provide an interface similar to that of Boost.Python v1's diff --git a/doc/v2/def_visitor.html b/doc/v2/def_visitor.html index f480405a..08fa0c51 100644 --- a/doc/v2/def_visitor.html +++ b/doc/v2/def_visitor.html @@ -132,4 +132,6 @@ BOOST_PYTHON_MODULE(my_ext)

    -

    © Copyright Joel de Guzman 2003. \ No newline at end of file +

    © Copyright Joel de Guzman 2003. Distributed under 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) diff --git a/doc/v2/default_call_policies.html b/doc/v2/default_call_policies.html index 2998769a..772b5c63 100644 --- a/doc/v2/default_call_policies.html +++ b/doc/v2/default_call_policies.html @@ -165,6 +165,8 @@ struct return_value_policy : Base -

    © Copyright Dave - Abrahams 2002. +

    © Copyright Dave + Abrahams 2002. Distributed under 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)

    diff --git a/doc/v2/feb2002.html b/doc/v2/feb2002.html index 8e59337b..a6b91c83 100644 --- a/doc/v2/feb2002.html +++ b/doc/v2/feb2002.html @@ -360,7 +360,8 @@ -

    © Copyright Dave Abrahams - 2002. +

    © Copyright Dave Abrahams 2002. Distributed + under 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)

    diff --git a/doc/v2/module.html b/doc/v2/module.html index 04a5fbcd..024e477f 100644 --- a/doc/v2/module.html +++ b/doc/v2/module.html @@ -104,5 +104,7 @@ RuntimeError: Unidentifiable C++ Exception

    © Copyright Dave - Abrahams 2002. + Abrahams 2002. Distributed + under 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)

    diff --git a/doc/v2/pickle.html b/doc/v2/pickle.html index 6d083ab4..1daf5ddb 100644 --- a/doc/v2/pickle.html +++ b/doc/v2/pickle.html @@ -320,11 +320,9 @@ See also the
    -© Copyright Ralf W. Grosse-Kunstleve 2001-2004. Permission to copy, -use, modify, sell and distribute this document is granted provided this -copyright notice appears in all copies. This document is provided "as -is" without express or implied warranty, and with no claim as to its -suitability for any purpose. +© Copyright Ralf W. Grosse-Kunstleve 2001-2004. Distributed under + 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)

    Updated: Feb 2004. diff --git a/doc/v2/pointee.html b/doc/v2/pointee.html index 45994190..4d817a45 100644 --- a/doc/v2/pointee.html +++ b/doc/v2/pointee.html @@ -112,5 +112,8 @@ BOOST_PYTHON_MODULE(pointee_demo)

    © Copyright Dave - Abrahams 2002. + Abrahams 2002. Distributed + under 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)

    + diff --git a/doc/v2/ptr.html b/doc/v2/ptr.html index 39d7fc8f..05305893 100644 --- a/doc/v2/ptr.html +++ b/doc/v2/ptr.html @@ -259,5 +259,7 @@ void pass_as_arg(expensive_to_copy* x, PyObject* f)

    © Copyright Dave - Abrahams 2002. + Abrahams 2002. Distributed + under 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)

    diff --git a/doc/v2/to_python_indirect.html b/doc/v2/to_python_indirect.html index 159fef71..40be2976 100644 --- a/doc/v2/to_python_indirect.html +++ b/doc/v2/to_python_indirect.html @@ -190,5 +190,7 @@ struct reference_existing_object

    © Copyright Dave - Abrahams 2002. + Abrahams 2002. Distributed + under 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)

    diff --git a/doc/v2/to_python_value.html b/doc/v2/to_python_value.html index ccd9b5d3..9df49319 100644 --- a/doc/v2/to_python_value.html +++ b/doc/v2/to_python_value.html @@ -97,5 +97,7 @@ PyObject* operator()(argument_type x) const;

    © Copyright Dave - Abrahams 2002. + Abrahams 2002. Distributed under 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)

    diff --git a/doc/v2/type_id.html b/doc/v2/type_id.html index 59025e0f..2641fe37 100755 --- a/doc/v2/type_id.html +++ b/doc/v2/type_id.html @@ -215,7 +215,9 @@ bool is_int(T x)

    © Copyright Dave Abrahams 2002.

    + "../../../../people/dave_abrahams.htm">Dave Abrahams 2002. Distributed under 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)< diff --git a/doc/v2/wrapper.html b/doc/v2/wrapper.html index 00109b9c..8fedd475 100755 --- a/doc/v2/wrapper.html +++ b/doc/v2/wrapper.html @@ -232,5 +232,7 @@ BOOST_PYTHON_MODULE_INIT(polymorphism)

    © Copyright Dave - Abrahams 2004 + Abrahams 2004 Distributed under 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)

    diff --git a/example/Jamfile b/example/Jamfile index 10fe384e..24303a6b 100644 --- a/example/Jamfile +++ b/example/Jamfile @@ -1,5 +1,6 @@ -# Copyright David Abrahams 2003. See accompanying LICENSE for terms -# and conditions of use. +# Copyright David Abrahams 2003-2006. Distributed under 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) # This is the top of our own project tree project-root ; diff --git a/example/Jamfile.v2 b/example/Jamfile.v2 index 7a9e5b87..0695aac2 100644 --- a/example/Jamfile.v2 +++ b/example/Jamfile.v2 @@ -1,6 +1,6 @@ -# This is the Jamfile for Boost.Build v2, which is currently in -# prerelease. Ignore this file unless you are a bleading edge sort of -# person. +# Copyright David Abrahams 2006. Distributed under 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) project : requirements /boost/python//boost_python ; diff --git a/example/README b/example/README index 97fdbc38..a9bd7941 100644 --- a/example/README +++ b/example/README @@ -1,3 +1,7 @@ +.. Copyright David Abrahams 2006. Distributed under 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) + To get started with the Boost Python Library, use the examples getting_started1.cpp and getting_started2.cpp. diff --git a/example/boost-build.jam b/example/boost-build.jam index 0e94752d..2075a00f 100755 --- a/example/boost-build.jam +++ b/example/boost-build.jam @@ -1,5 +1,6 @@ -# Copyright David Abrahams 2003. See accompanying LICENSE for terms -# and conditions of use. +# Copyright David Abrahams 2006. Distributed under 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) # Edit this path to point at the tools/build/v1 subdirectory of your # Boost installation. Absolute paths work, too. diff --git a/example/test_getting_started1.py b/example/test_getting_started1.py index cd8fb59e..32dc1f6e 100644 --- a/example/test_getting_started1.py +++ b/example/test_getting_started1.py @@ -1,3 +1,6 @@ +# Copyright Ralf W. Grosse-Kunstleve 2006. Distributed under 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) r'''>>> import getting_started1 >>> print getting_started1.greet() hello, world diff --git a/example/test_getting_started2.py b/example/test_getting_started2.py index ccfaa4f1..ae86017b 100644 --- a/example/test_getting_started2.py +++ b/example/test_getting_started2.py @@ -1,3 +1,6 @@ +# Copyright Ralf W. Grosse-Kunstleve 2006. Distributed under 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) r'''>>> from getting_started2 import * >>> hi = hello('California') >>> hi.greet() diff --git a/example/test_std_pair.py b/example/test_std_pair.py index 89a2b8f3..64f239fe 100644 --- a/example/test_std_pair.py +++ b/example/test_std_pair.py @@ -1,3 +1,6 @@ +# Copyright Ralf W. Grosse-Kunstleve 2006. Distributed under 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) import std_pair_ext assert std_pair_ext.foo() == (3, 5) print "OK" diff --git a/include/boost/python/detail/python22_fixed.h b/include/boost/python/detail/python22_fixed.h index e236c2b0..32bf941f 100644 --- a/include/boost/python/detail/python22_fixed.h +++ b/include/boost/python/detail/python22_fixed.h @@ -4,6 +4,8 @@ // Copyright (c) 2001, 2002 Python Software Foundation; All Rights // Reserved // +// boostinspect:nolicense (don't complain about the lack of a Boost license) +// // Changes from the original: // 1. #includes for Python 2.2.1 // 2. Provides missing extern "C" wrapper for "iterobject.h" and "descrobject.h". diff --git a/index.html b/index.html index 40f1ae14..9c6acc88 100644 --- a/index.html +++ b/index.html @@ -1,3 +1,6 @@ + + + diff --git a/pyste/NEWS b/pyste/NEWS index aaa8e3b3..31a5ceba 100644 --- a/pyste/NEWS +++ b/pyste/NEWS @@ -1,3 +1,7 @@ +.. Copyright Bruno da Silva de Oliveira 2006. Distributed under 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) + 25 April 2005 - Fixed bug where the code for wrappers of member functions were defined outside the pyste namespace. Reported by Dan Haffey. diff --git a/pyste/README b/pyste/README index e4e3734e..c378f391 100644 --- a/pyste/README +++ b/pyste/README @@ -1,3 +1,7 @@ +.. Copyright Bruno da Silva de Oliveira 2006. Distributed under 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) + Pyste - Python Semi-Automatic Exporter ====================================== diff --git a/pyste/TODO b/pyste/TODO index e0ff578b..0b3c9024 100644 --- a/pyste/TODO +++ b/pyste/TODO @@ -1,3 +1,7 @@ +.. Copyright Bruno da Silva de Oliveira 2006. Distributed under 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) + - Make Pyste accept already-generated xml files - throw() declaration in virtual wrapper's member functions diff --git a/pyste/dist/create_build.py b/pyste/dist/create_build.py index 506426f0..a6836995 100644 --- a/pyste/dist/create_build.py +++ b/pyste/dist/create_build.py @@ -1,3 +1,7 @@ +# Copyright Bruno da Silva de Oliveira 2006. Distributed under 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) + import os import sys import shutil diff --git a/pyste/dist/setup.py b/pyste/dist/setup.py index eea2751f..fc7c74e2 100644 --- a/pyste/dist/setup.py +++ b/pyste/dist/setup.py @@ -1,3 +1,7 @@ +# Copyright Bruno da Silva de Oliveira 2006. Distributed under 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) + from distutils.core import setup import py2exe import sys diff --git a/pyste/doc/adding_new_methods.html b/pyste/doc/adding_new_methods.html index 9cd603e4..afa772bc 100644 --- a/pyste/doc/adding_new_methods.html +++ b/pyste/doc/adding_new_methods.html @@ -72,9 +72,8 @@ Now from Python:



    +Distributed under + 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)

    diff --git a/pyste/doc/exporting_an_entire_header.html b/pyste/doc/exporting_an_entire_header.html index d1f22e1e..db25325c 100644 --- a/pyste/doc/exporting_an_entire_header.html +++ b/pyste/doc/exporting_an_entire_header.html @@ -78,9 +78,8 @@ use at you own risk.

    +Distributed under + 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)

    diff --git a/pyste/doc/global_variables.html b/pyste/doc/global_variables.html index 2170e4e8..0efd2950 100644 --- a/pyste/doc/global_variables.html +++ b/pyste/doc/global_variables.html @@ -42,9 +42,8 @@ functions, and export those.



    +Distributed under + 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)

    diff --git a/pyste/doc/inserting_code.html b/pyste/doc/inserting_code.html index 866e5bad..97eb70f3 100644 --- a/pyste/doc/inserting_code.html +++ b/pyste/doc/inserting_code.html @@ -65,9 +65,8 @@ Will generate:



    +Distributed under + 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)

    diff --git a/pyste/doc/introduction.html b/pyste/doc/introduction.html index 352aed2e..94388493 100644 --- a/pyste/doc/introduction.html +++ b/pyste/doc/introduction.html @@ -66,9 +66,8 @@ Pyste supports the following features:



    +Distributed under + 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)

    diff --git a/pyste/doc/policies.html b/pyste/doc/policies.html index 8061f9b1..3628093b 100644 --- a/pyste/doc/policies.html +++ b/pyste/doc/policies.html @@ -83,9 +83,8 @@ to, though.

    +Distributed under + 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)

    diff --git a/pyste/doc/pyste.txt b/pyste/doc/pyste.txt index 08eda4aa..b6354084 100644 --- a/pyste/doc/pyste.txt +++ b/pyste/doc/pyste.txt @@ -1,5 +1,11 @@ [doc Pyste Documentation] +[/ + Distributed under + 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) +] + [def GCCXML [@http://www.gccxml.org GCCXML]] [def Boost.Python [@../../index.html Boost.Python]] diff --git a/pyste/doc/renaming_and_excluding.html b/pyste/doc/renaming_and_excluding.html index 185b8d7e..ce6654c4 100644 --- a/pyste/doc/renaming_and_excluding.html +++ b/pyste/doc/renaming_and_excluding.html @@ -80,9 +80,8 @@ C::foo that way.



    +Distributed under + 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)

    diff --git a/pyste/doc/running_pyste.html b/pyste/doc/running_pyste.html index 5f72e603..9bd9a3ae 100644 --- a/pyste/doc/running_pyste.html +++ b/pyste/doc/running_pyste.html @@ -193,9 +193,8 @@ created again, but no code will be generated.



    +Distributed under + 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)

    diff --git a/pyste/doc/smart_pointers.html b/pyste/doc/smart_pointers.html index 095d2482..cddc96f2 100644 --- a/pyste/doc/smart_pointers.html +++ b/pyste/doc/smart_pointers.html @@ -77,9 +77,8 @@ specify the smart pointer as the holder for a class, use the functions

    +Distributed under + 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)

    diff --git a/pyste/doc/templates.html b/pyste/doc/templates.html index f2b978bb..a1c1cfef 100644 --- a/pyste/doc/templates.html +++ b/pyste/doc/templates.html @@ -95,9 +95,8 @@ either a string with the types separated by whitespace, or a list of strings

    +Distributed under + 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)

    diff --git a/pyste/doc/the_interface_files.html b/pyste/doc/the_interface_files.html index 117301b4..9c020043 100644 --- a/pyste/doc/the_interface_files.html +++ b/pyste/doc/the_interface_files.html @@ -95,9 +95,8 @@ Note that we specify that B needs to know about A to be proper

    +Distributed under + 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)

    diff --git a/pyste/doc/theme/style.css b/pyste/doc/theme/style.css index 53a6205e..7a25e6c9 100644 --- a/pyste/doc/theme/style.css +++ b/pyste/doc/theme/style.css @@ -1,3 +1,12 @@ +/*============================================================================= + Copyright (c) 2003 Bruno da Silva de Oliveira + http://spirit.sourceforge.net/ + + 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) +=============================================================================*/ + body { background-image: url(bkd.gif); diff --git a/pyste/doc/wrappers.html b/pyste/doc/wrappers.html index 0943c0c5..534ae552 100644 --- a/pyste/doc/wrappers.html +++ b/pyste/doc/wrappers.html @@ -117,9 +117,8 @@ code to compile when you set a wrapper for a virtual member function.

    +Distributed under + 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)

    diff --git a/pyste/index.html b/pyste/index.html index 55b7d39f..953b37c1 100644 --- a/pyste/index.html +++ b/pyste/index.html @@ -83,9 +83,8 @@

    +Distributed under + 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)

    diff --git a/pyste/install/pyste.py b/pyste/install/pyste.py index 9547d5f7..da926235 100644 --- a/pyste/install/pyste.py +++ b/pyste/install/pyste.py @@ -1,4 +1,8 @@ #!/usr/bin/env python +# Copyright Bruno da Silva de Oliveira 2006. Distributed under 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) + from Pyste import pyste pyste.main() diff --git a/release_notes.txt b/release_notes.txt index 8932a0aa..1fd0f1b1 100644 --- a/release_notes.txt +++ b/release_notes.txt @@ -1,3 +1,9 @@ +.. Copyright David Abrahams 2006. Distributed under 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) + +These are old release notes for Boost.Python v1 + 2000-11-22 10:00 Ullrich fixed bug in operator_dispatcher. diff --git a/test/Jamfile b/test/Jamfile index d3a435f0..9203332b 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -1,3 +1,6 @@ +# Copyright David Abrahams 2006. Distributed under 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) # # To run all tests quietly: jam test # To run all tests with verbose output: jam -sPYTHON_TEST_ARGS=-v test diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 14a6d633..78ac8d8d 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -1,3 +1,6 @@ +# Copyright David Abrahams 2006. Distributed under 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) use-project /boost/python : ../build ; project /boost/python/test ; diff --git a/test/andreas_beyer.cpp b/test/andreas_beyer.cpp index a39e9f04..da3aa751 100755 --- a/test/andreas_beyer.cpp +++ b/test/andreas_beyer.cpp @@ -1,3 +1,6 @@ +// Copyright David Abrahams 2006. Distributed under 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) #include #include #include diff --git a/test/crossmod_exception.py b/test/crossmod_exception.py index c8430849..48f849a4 100644 --- a/test/crossmod_exception.py +++ b/test/crossmod_exception.py @@ -1,9 +1,6 @@ # Copyright (C) 2003 Rational Discovery LLC -# Permission to copy, use, modify, sell and distribute this software -# is granted provided this copyright notice appears in all -# copies. This software is provided "as is" without express or -# implied warranty, and with no claim as to its suitability for any -# purpose. +# Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) print "running..." diff --git a/test/opaque.py b/test/opaque.py index ab1bfb13..d10ac784 100644 --- a/test/opaque.py +++ b/test/opaque.py @@ -1,9 +1,8 @@ # -*- coding: iso-latin-1 -*- -# Copyright Gottfried Ganßauge 2003..2006. Permission to copy, use, -# modify, sell and distribute this software is granted provided this -# copyright notice appears in all copies. This software is provided -# "as is" without express or implied warranty, and with no claim as -# to its suitability for any purpose. +# Copyright Gottfried Ganßauge 2003..2006. Distributed under 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) + """ >>> from opaque_ext import * diff --git a/test/pointer_vector.cpp b/test/pointer_vector.cpp index 4c446d1a..c1f7dbd4 100644 --- a/test/pointer_vector.cpp +++ b/test/pointer_vector.cpp @@ -1,3 +1,6 @@ +// Copyright Joel de Guzman 2005-2006. Distributed under 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) #include #include #include From e527bc860f9b2239c64da9185885145261b6ee4d Mon Sep 17 00:00:00 2001 From: Stefan Seefeld Date: Wed, 20 Sep 2006 22:30:39 +0000 Subject: [PATCH 044/268] Fix copyright issues. [SVN r35236] --- test/exec.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/exec.py b/test/exec.py index 5c1ad592..5a8faf79 100644 --- a/test/exec.py +++ b/test/exec.py @@ -1,2 +1,6 @@ +# Copyright Stefan Seefeld 2006. Distributed under 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) + print 'Hello World !' number = 42 From e00a88ff4902f60fa84902ab293504d1849500b7 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Thu, 21 Sep 2006 02:40:19 +0000 Subject: [PATCH 045/268] Fix inspection issues [SVN r35239] --- include/boost/python/converter/implicit.hpp | 6 +++++- pyste/doc/pyste.txt | 9 ++++----- pyste/doc/theme/style.css | 1 - test/crossmod_exception.py | 6 +++--- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/include/boost/python/converter/implicit.hpp b/include/boost/python/converter/implicit.hpp index 190bab32..cf5d8fa6 100644 --- a/include/boost/python/converter/implicit.hpp +++ b/include/boost/python/converter/implicit.hpp @@ -29,8 +29,12 @@ struct implicit static void construct(PyObject* obj, rvalue_from_python_stage1_data* data) { void* storage = ((rvalue_from_python_storage*)data)->storage.bytes; + + arg_from_python get_source(obj); + bool convertible = get_source.convertible(); + BOOST_ASSERT(convertible); - new (storage) Target(extract(obj)()); + new (storage) Target(get_source()); // record successful construction data->convertible = storage; diff --git a/pyste/doc/pyste.txt b/pyste/doc/pyste.txt index b6354084..186a31cb 100644 --- a/pyste/doc/pyste.txt +++ b/pyste/doc/pyste.txt @@ -1,10 +1,9 @@ [doc Pyste Documentation] -[/ - Distributed under - 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) -] +[/ Copyright 2003 Bruno da Silva de Oliveira and Joel de Guzman. +Distributed under 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) ] [def GCCXML [@http://www.gccxml.org GCCXML]] [def Boost.Python [@../../index.html Boost.Python]] diff --git a/pyste/doc/theme/style.css b/pyste/doc/theme/style.css index 7a25e6c9..643df02a 100644 --- a/pyste/doc/theme/style.css +++ b/pyste/doc/theme/style.css @@ -1,6 +1,5 @@ /*============================================================================= Copyright (c) 2003 Bruno da Silva de Oliveira - http://spirit.sourceforge.net/ Use, modification and distribution is subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at diff --git a/test/crossmod_exception.py b/test/crossmod_exception.py index 48f849a4..dd50dae2 100644 --- a/test/crossmod_exception.py +++ b/test/crossmod_exception.py @@ -1,6 +1,6 @@ -# Copyright (C) 2003 Rational Discovery LLC -# Software License, Version 1.0. (See accompanying -# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# Copyright (C) 2003 Rational Discovery LLC. Distributed under 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) print "running..." From ccc56c2a4c00cf27c87870b8d50362af4cbf40dd Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Thu, 21 Sep 2006 03:43:59 +0000 Subject: [PATCH 046/268] Apply Boost license, with permission from Prabhu Ramachandran. [SVN r35240] --- pyste/install/setup.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pyste/install/setup.py b/pyste/install/setup.py index 6c156536..c1703981 100644 --- a/pyste/install/setup.py +++ b/pyste/install/setup.py @@ -1,4 +1,6 @@ -# contributed by Prabhu Ramachandran +# Copyright Prabhu Ramachandran 2006. Distributed under 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) from distutils.core import setup import sys From 070e02d7d5395157704ba1b9d9b517b0467a0e5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gottfried=20Gan=C3=9Fauge?= Date: Thu, 21 Sep 2006 07:07:14 +0000 Subject: [PATCH 047/268] Renamed from opaque_pointer_converter.html [SVN r35242] --- doc/v2/opaque.html | 134 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 doc/v2/opaque.html diff --git a/doc/v2/opaque.html b/doc/v2/opaque.html new file mode 100644 index 00000000..5f55d5c8 --- /dev/null +++ b/doc/v2/opaque.html @@ -0,0 +1,134 @@ + + + + + + + + Boost.Python - <boost/python/opaque_pointer_converter.hpp> + + + + + + + + + +
    +

    C++ Boost

    +
    +

    Boost.Python

    + +

    Header + <boost/python/opaque_pointer_converter.hpp>

    +
    +
    + +

    Contents

    + +
    +
    Classes
    + +
    +
    +
    Class template + opaque<Pointee>
    + +
    +
    +
    Class template + opaque synopsis
    +
    +
    +
    +
    + +
    Macros
    +
    +
    +
    Macro + BOOST_PYTHON_OPAQUE_SPECIALIZED_TYPE_ID
    +
    +
    + +
    See Also
    +
    +
    + +

    Classes

    + +

    Class template + opaque<P>

    + +

    opaque<> registers itself as a converter from + Python objects to pointers to undefined types and vice versa.

    + +

    Class template + opaque synopsis

    +
    +namespace boost { namespace python
    +{
    +    template<class Pointee>
    +    struct opaque
    +    {
    +        opaque();
    +    };
    +}}
    +
    + +

    Class template + opaque constructor

    +
    +opaque();
    +
    + +
    +
    Effects: +
      +
    • Registers the instance as a + lvalue_from_pytype + converter from Python objects into opaque pointers.

      +

      The Python Objects created are named after the type pointed to + by the opaque pointer being wrapped.

    • +
    • Registers the instance as a + to_python_converter + from opaque pointers to Python objects.

    • +
    +

    If there is already an instance registered by another module, this + instance doesn't try to register again in order to avoid warnings + about multiple registrations.

    + +

    Note

    +

    Normally only a single instance of this class is created for every + Pointee.

    +
    +
    + +

    Macros

    + +

    + Macro BOOST_PYTHON_OPAQUE_SPECIALIZED_TYPE_ID(Pointee)

    +

    This macro must be used to define specializations of the + type_id function + which can't be instantiated for incomplete types.

    +

    Note

    +

    The macro must be invoked in every translation unit which uses the + opaque converter.

    + +

    See Also

    +

    + return_opaque_pointer +

    + +

    Revised + 10 September, 2006 +

    + +

    © Copyright 2003..2006 Haufe Mediengruppe. All Rights + Reserved.

    + + + From afedc1cd9a98c6451db1694bbcea91ed5b282cc5 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Thu, 21 Sep 2006 07:26:35 +0000 Subject: [PATCH 048/268] Add tests [SVN r35244] --- example/Jamfile.v2 | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/example/Jamfile.v2 b/example/Jamfile.v2 index 0695aac2..a8e6e966 100644 --- a/example/Jamfile.v2 +++ b/example/Jamfile.v2 @@ -5,5 +5,32 @@ project : requirements /boost/python//boost_python ; python-extension getting_started1 : getting_started1.cpp ; + +bpl-test test1 + : # Python test driver + test_getting_started1.py + # extension modules to use + getting_started1 ; + + python-extension getting_started2 : getting_started2.cpp ; +bpl-test test2 + : # Python test driver + test_getting_started2.py + # extension modules to use + getting_started2 ; + +python-extension std_pair : std_pair.cpp ; + +bpl-test test3 + : # Python test driver + test_std_pair.py + # extension modules to use + std_pair_ext ; + +# Don't run tests by default +explicit test1 test2 test3 ; +alias test : test1 test2 test3 ; +explicit test ; + From c7fb2f704760a68443908715902988d79f756323 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Fri, 22 Sep 2006 15:12:04 +0000 Subject: [PATCH 049/268] Attempt GCC-3.4.4 and 4.0.1 workarounds [SVN r35276] --- include/boost/python/opaque_pointer_converter.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/boost/python/opaque_pointer_converter.hpp b/include/boost/python/opaque_pointer_converter.hpp index 761c414e..d2a7c94d 100644 --- a/include/boost/python/opaque_pointer_converter.hpp +++ b/include/boost/python/opaque_pointer_converter.hpp @@ -53,7 +53,7 @@ struct opaque throw error_already_set(); } - register_self(); + this->register_self(); } } @@ -86,7 +86,8 @@ private: } } - void register_self() { + void register_self() + { converter::registration const *existing = converter::registry::query (type_id()); From c6f2aa4ef2b61926efb40428b79b36b5dbc8613f Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Tue, 26 Sep 2006 00:25:07 +0000 Subject: [PATCH 050/268] new boost/python/ssize_t.hpp; avoids potential clash of Py_ssize_t typedef and PY_SSIZE_T_MIN/MAX macros with definitions from other libraries [SVN r35325] --- doc/v2/reference.html | 10 ++ doc/v2/ssize_t.html | 96 +++++++++++++++++++ .../python/converter/builtin_converters.hpp | 5 +- include/boost/python/detail/wrap_python.hpp | 6 -- include/boost/python/list.hpp | 9 +- include/boost/python/object.hpp | 6 +- include/boost/python/ssize_t.hpp | 29 ++++++ src/list.cpp | 5 +- src/object/class.cpp | 7 +- src/object/function.cpp | 9 +- src/object_protocol.cpp | 5 +- src/str.cpp | 9 +- 12 files changed, 166 insertions(+), 30 deletions(-) create mode 100644 doc/v2/ssize_t.html create mode 100644 include/boost/python/ssize_t.hpp diff --git a/doc/v2/reference.html b/doc/v2/reference.html index 1dc9a96d..927eadd8 100644 --- a/doc/v2/reference.html +++ b/doc/v2/reference.html @@ -1094,6 +1094,16 @@
    + +
    ssize_t.hpp
    + +
    +
    +
    Typedefs
    + +
    Constants
    +
    +

    Topics

    diff --git a/doc/v2/ssize_t.html b/doc/v2/ssize_t.html new file mode 100644 index 00000000..137f6d14 --- /dev/null +++ b/doc/v2/ssize_t.html @@ -0,0 +1,96 @@ + + + + + + + + + + + + Boost.Python - <boost/python/ssize_t.hpp> + + + + + + + + + +
    +

    C++ Boost

    +
    +

    Boost.Python

    + +

    Header + <boost/python/ssize_t.hpp>

    +
    +
    + +

    Contents

    + +
    +
    Introduction
    + +
    Typedef
    + +
    Constants
    +
    +
    + +

    Introduction

    + +

    Python 2.5 introduces a new Py_ssize_t typedef and + two related macros (PEP 353). The + <boost/python/ssize_t.hpp> header imports these + definitions into the boost::python namespace as + ssize_t, ssize_t_max, and ssize_t_min. + Appropriate definitions are provided for backward compatibility + with previous Python versions.

    + +

    Typedefs

    Imports + Py_ssize_t into the boost::python namespace if + available, or provides an appropriate typedef for backward + compatibility: +
    +#if PY_VERSION_HEX >= 0x02050000
    +typedef Py_ssize_t ssize_t;
    +#else
    +typedef int ssize_t;
    +#endif
    +
    + +

    Constants

    Imports + PY_SSIZE_T_MAX and PY_SSIZE_T_MIN as constants + into the boost::python namespace if available, or + provides appropriate constants for backward compatibility: +
    +#if PY_VERSION_HEX >= 0x02050000
    +ssize_t const ssize_t_max = PY_SSIZE_T_MAX;
    +ssize_t const ssize_t_min = PY_SSIZE_T_MIN;
    +#else
    +ssize_t const ssize_t_max = INT_MAX;
    +ssize_t const ssize_t_min = INT_MIN;
    +#endif
    +
    + +

    Revised + + 25 September, 2006 +

    + +

    © Copyright Ralf W. + Grosse-Kunstleve 2006.

    + + diff --git a/include/boost/python/converter/builtin_converters.hpp b/include/boost/python/converter/builtin_converters.hpp index b7406632..dddb154c 100644 --- a/include/boost/python/converter/builtin_converters.hpp +++ b/include/boost/python/converter/builtin_converters.hpp @@ -7,6 +7,7 @@ # include # include # include +# include # include # include # include @@ -115,9 +116,9 @@ BOOST_PYTHON_TO_PYTHON_BY_VALUE(unsigned BOOST_PYTHON_LONG_LONG, ::PyLong_FromUn BOOST_PYTHON_TO_PYTHON_BY_VALUE(char, converter::do_return_to_python(x)) BOOST_PYTHON_TO_PYTHON_BY_VALUE(char const*, converter::do_return_to_python(x)) -BOOST_PYTHON_TO_PYTHON_BY_VALUE(std::string, ::PyString_FromStringAndSize(x.data(),implicit_cast(x.size()))) +BOOST_PYTHON_TO_PYTHON_BY_VALUE(std::string, ::PyString_FromStringAndSize(x.data(),implicit_cast(x.size()))) #if defined(Py_USING_UNICODE) && !defined(BOOST_NO_STD_WSTRING) -BOOST_PYTHON_TO_PYTHON_BY_VALUE(std::wstring, ::PyUnicode_FromWideChar(x.data(),implicit_cast(x.size()))) +BOOST_PYTHON_TO_PYTHON_BY_VALUE(std::wstring, ::PyUnicode_FromWideChar(x.data(),implicit_cast(x.size()))) # endif BOOST_PYTHON_TO_PYTHON_BY_VALUE(float, ::PyFloat_FromDouble(x)) BOOST_PYTHON_TO_PYTHON_BY_VALUE(double, ::PyFloat_FromDouble(x)) diff --git a/include/boost/python/detail/wrap_python.hpp b/include/boost/python/detail/wrap_python.hpp index 60448ac9..88597b58 100644 --- a/include/boost/python/detail/wrap_python.hpp +++ b/include/boost/python/detail/wrap_python.hpp @@ -141,12 +141,6 @@ typedef int pid_t; # include #endif -#if PY_VERSION_HEX < 0x02050000 -typedef int Py_ssize_t; -#define PY_SSIZE_T_MIN INT_MIN -#define PY_SSIZE_T_MAX INT_MAX -#endif - #ifdef BOOST_PYTHON_ULONG_MAX_UNDEFINED # undef ULONG_MAX # undef BOOST_PYTHON_ULONG_MAX_UNDEFINED diff --git a/include/boost/python/list.hpp b/include/boost/python/list.hpp index c6ba7323..0f6d1e8e 100644 --- a/include/boost/python/list.hpp +++ b/include/boost/python/list.hpp @@ -9,6 +9,7 @@ # include # include +# include namespace boost { namespace python { @@ -24,11 +25,11 @@ namespace detail long index(object_cref value) const; // return index of first occurrence of value - void insert(Py_ssize_t index, object_cref); // insert object before index + void insert(ssize_t index, object_cref); // insert object before index void insert(object const& index, object_cref); object pop(); // remove and return item at index (default last) - object pop(Py_ssize_t index); + object pop(ssize_t index); object pop(object const& index); void remove(object_cref value); // remove first occurrence of value @@ -86,7 +87,7 @@ class list : public detail::list_base } template - void insert(Py_ssize_t index, T const& x) // insert object before index + void insert(ssize_t index, T const& x) // insert object before index { base::insert(index, object(x)); } @@ -98,7 +99,7 @@ class list : public detail::list_base } object pop() { return base::pop(); } - object pop(Py_ssize_t index) { return base::pop(index); } + object pop(ssize_t index) { return base::pop(index); } template object pop(T const& index) diff --git a/include/boost/python/object.hpp b/include/boost/python/object.hpp index 2e36b632..9adec90f 100755 --- a/include/boost/python/object.hpp +++ b/include/boost/python/object.hpp @@ -5,7 +5,7 @@ #ifndef OBJECT_DWA2002612_HPP # define OBJECT_DWA2002612_HPP -# include +# include # include # include # include @@ -15,9 +15,9 @@ namespace boost { namespace python { - inline Py_ssize_t len(object const& obj) + inline ssize_t len(object const& obj) { - Py_ssize_t result = PyObject_Length(obj.ptr()); + ssize_t result = PyObject_Length(obj.ptr()); if (PyErr_Occurred()) throw_error_already_set(); return result; } diff --git a/include/boost/python/ssize_t.hpp b/include/boost/python/ssize_t.hpp new file mode 100644 index 00000000..e8a2d92f --- /dev/null +++ b/include/boost/python/ssize_t.hpp @@ -0,0 +1,29 @@ +// Copyright Ralf W. Grosse-Kunstleve & David Abrahams 2006. +// Distributed under 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) + +#ifndef BOOST_PYTHON_SSIZE_T_RWGK20060924_HPP +# define BOOST_PYTHON_SSIZE_T_RWGK20060924_HPP + +# include + +namespace boost { namespace python { + +#if PY_VERSION_HEX >= 0x02050000 + +typedef Py_ssize_t ssize_t; +ssize_t const ssize_t_max = PY_SSIZE_T_MAX; +ssize_t const ssize_t_min = PY_SSIZE_T_MIN; + +#else + +typedef int ssize_t; +ssize_t const ssize_t_max = INT_MAX; +ssize_t const ssize_t_min = INT_MIN; + +#endif + +}} // namespace boost::python + +#endif // BOOST_PYTHON_SSIZE_T_RWGK20060924_HPP diff --git a/src/list.cpp b/src/list.cpp index ca62e627..b8f31fb8 100644 --- a/src/list.cpp +++ b/src/list.cpp @@ -3,6 +3,7 @@ // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #include +#include namespace boost { namespace python { namespace detail { @@ -53,7 +54,7 @@ long list_base::index(object_cref value) const return result; } -void list_base::insert(Py_ssize_t index, object_cref item) +void list_base::insert(ssize_t index, object_cref item) { if (PyList_CheckExact(this->ptr())) { @@ -79,7 +80,7 @@ object list_base::pop() return this->attr("pop")(); } -object list_base::pop(Py_ssize_t index) +object list_base::pop(ssize_t index) { return this->pop(object(index)); } diff --git a/src/object/class.cpp b/src/object/class.cpp index 63f5cf97..9daf42b7 100644 --- a/src/object/class.cpp +++ b/src/object/class.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -506,14 +507,14 @@ namespace objects // were declared, we'll use our class_type() as the single base // class. std::size_t const num_bases = (std::max)(num_types - 1, static_cast(1)); - assert(num_bases <= PY_SSIZE_T_MAX); - handle<> bases(PyTuple_New(static_cast(num_bases))); + assert(num_bases <= ssize_t_max); + handle<> bases(PyTuple_New(static_cast(num_bases))); for (std::size_t i = 1; i <= num_bases; ++i) { type_handle c = (i >= num_types) ? class_type() : get_class(types[i]); // PyTuple_SET_ITEM steals this reference - PyTuple_SET_ITEM(bases.get(), static_cast(i - 1), upcast(c.release())); + PyTuple_SET_ITEM(bases.get(), static_cast(i - 1), upcast(c.release())); } // Call the class metatype to create a new class diff --git a/src/object/function.cpp b/src/object/function.cpp index 44b8853c..1f094f42 100644 --- a/src/object/function.cpp +++ b/src/object/function.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -64,7 +65,7 @@ function::function( = max_arity > num_keywords ? max_arity - num_keywords : 0; - Py_ssize_t tuple_size = num_keywords ? max_arity : 0; + ssize_t tuple_size = num_keywords ? max_arity : 0; m_arg_names = object(handle<>(PyTuple_New(tuple_size))); if (num_keywords != 0) @@ -158,9 +159,9 @@ PyObject* function::call(PyObject* args, PyObject* keywords) const else { // build a new arg tuple, will adjust its size later - assert(max_arity <= PY_SSIZE_T_MAX); + assert(max_arity <= ssize_t_max); inner_args = handle<>( - PyTuple_New(static_cast(max_arity))); + PyTuple_New(static_cast(max_arity))); // Fill in the positional arguments for (std::size_t i = 0; i < n_unnamed_actual; ++i) @@ -295,7 +296,7 @@ void function::argument_error(PyObject* args, PyObject* /*keywords*/) const % make_tuple(this->m_namespace, this->m_name); list actual_args; - for (Py_ssize_t i = 0; i < PyTuple_Size(args); ++i) + for (ssize_t i = 0; i < PyTuple_Size(args); ++i) { char const* name = PyTuple_GetItem(args, i)->ob_type->tp_name; actual_args.append(str(name)); diff --git a/src/object_protocol.cpp b/src/object_protocol.cpp index b62b63a1..8606fa2b 100755 --- a/src/object_protocol.cpp +++ b/src/object_protocol.cpp @@ -6,6 +6,7 @@ #include #include #include +#include namespace boost { namespace python { namespace api { @@ -106,7 +107,7 @@ namespace // slicing code copied directly out of the Python implementation PySequenceMethods *sq = tp->tp_as_sequence; if (sq && sq->sq_slice && ISINT(v) && ISINT(w)) { - Py_ssize_t ilow = 0, ihigh = PY_SSIZE_T_MAX; + ssize_t ilow = 0, ihigh = ssize_t_max; if (!_PyEval_SliceIndex(v, &ilow)) return NULL; if (!_PyEval_SliceIndex(w, &ihigh)) @@ -133,7 +134,7 @@ namespace // slicing code copied directly out of the Python implementation PySequenceMethods *sq = tp->tp_as_sequence; if (sq && sq->sq_slice && ISINT(v) && ISINT(w)) { - Py_ssize_t ilow = 0, ihigh = PY_SSIZE_T_MAX; + ssize_t ilow = 0, ihigh = ssize_t_max; if (!_PyEval_SliceIndex(v, &ilow)) return -1; if (!_PyEval_SliceIndex(w, &ihigh)) diff --git a/src/str.cpp b/src/str.cpp index 8a321d27..5216cf54 100644 --- a/src/str.cpp +++ b/src/str.cpp @@ -3,6 +3,7 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include #include +#include namespace boost { namespace python { namespace detail { @@ -23,13 +24,13 @@ str_base::str_base(const char* s) namespace { - Py_ssize_t str_size_as_py_ssize_t(std::size_t n) + ssize_t str_size_as_py_ssize_t(std::size_t n) { - if (n > PY_SSIZE_T_MAX) + if (n > ssize_t_max) { - throw std::range_error("str size > PY_SSIZE_T_MAX"); + throw std::range_error("str size > ssize_t_max"); } - return static_cast(n); + return static_cast(n); } } // namespace From 5e5d34cc361f678d381f3f55fc7424bc2beb7d2d Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Tue, 26 Sep 2006 04:23:32 +0000 Subject: [PATCH 051/268] Fixed broken links [SVN r35329] --- doc/news.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/news.html b/doc/news.html index ce4ead50..6e637a04 100644 --- a/doc/news.html +++ b/doc/news.html @@ -45,7 +45,7 @@
  • Support for converting void* to/from python, with opaque_pointer_converter + href="v2/opaque.html">opaque_pointer_converter as the return value policy. Thanks to Niall Douglas for the initial patch. @@ -219,7 +219,7 @@ BOOST_PYTHON_MODULE(test)
    Gottfried Ganßauge has contributed opaque pointer support.
    + "v2/opaque.html">opaque pointer support.
    Bruno da Silva de Oliveira has contributed the exciting Pyste ("Pie-steh") package.
    From 94500ae36debfe45eb0a47b53c81fd0fa530661a Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Thu, 28 Sep 2006 14:41:01 +0000 Subject: [PATCH 052/268] Tests and fixes for a bad interaction between wrapper<> and operators support. "self" arguments weren't getting unwrapped properly. [SVN r35365] --- .../boost/python/detail/unwrap_wrapper.hpp | 32 ++++---------- include/boost/python/operators.hpp | 17 +++++--- include/boost/python/wrapper.hpp | 4 +- test/Jamfile.v2 | 1 + test/operators_wrapper.cpp | 42 +++++++++++++++++++ test/operators_wrapper.py | 11 +++++ 6 files changed, 77 insertions(+), 30 deletions(-) create mode 100644 test/operators_wrapper.cpp create mode 100644 test/operators_wrapper.py diff --git a/include/boost/python/detail/unwrap_wrapper.hpp b/include/boost/python/detail/unwrap_wrapper.hpp index a0f6a65a..95bc233a 100755 --- a/include/boost/python/detail/unwrap_wrapper.hpp +++ b/include/boost/python/detail/unwrap_wrapper.hpp @@ -6,42 +6,28 @@ # include # include -# if defined(BOOST_PYTHON_NO_SFINAE) -# include -# include -# else -# include -# endif +# include +# include namespace boost { namespace python { namespace detail { -# if defined(BOOST_PYTHON_NO_SFINAE) template struct unwrap_wrapper_helper { typedef typename T::_wrapper_wrapped_type_ type; }; - -template -typename mpl::eval_if,unwrap_wrapper_helper,mpl::identity >::type* -unwrap_wrapper(T*) -{ - return 0; -} -# else -template -typename disable_if_ret,T*>::type -unwrap_wrapper(T*) -{ - return 0; -} template -T* unwrap_wrapper(wrapper*) +struct unwrap_wrapper_ + : mpl::eval_if,unwrap_wrapper_helper,mpl::identity > +{}; + +template +typename unwrap_wrapper_::type* +unwrap_wrapper(T*) { return 0; } -# endif }}} // namespace boost::python::detail diff --git a/include/boost/python/operators.hpp b/include/boost/python/operators.hpp index 89fe4099..3851b494 100644 --- a/include/boost/python/operators.hpp +++ b/include/boost/python/operators.hpp @@ -169,7 +169,9 @@ namespace detail \ template \ struct apply \ { \ - static inline PyObject* execute(L& l, R const& r) \ + typedef typename unwrap_wrapper_::type lhs; \ + typedef typename unwrap_wrapper_::type rhs; \ + static PyObject* execute(lhs& l, rhs const& r) \ { \ return detail::convert_result(expr); \ } \ @@ -183,7 +185,9 @@ namespace detail \ template \ struct apply \ { \ - static inline PyObject* execute(R& r, L const& l) \ + typedef typename unwrap_wrapper_::type lhs; \ + typedef typename unwrap_wrapper_::type rhs; \ + static PyObject* execute(rhs& r, lhs const& l) \ { \ return detail::convert_result(expr); \ } \ @@ -271,8 +275,10 @@ namespace detail \ template \ struct apply \ { \ - static inline PyObject* \ - execute(back_reference l, R const& r) \ + typedef typename unwrap_wrapper_::type lhs; \ + typedef typename unwrap_wrapper_::type rhs; \ + static PyObject* \ + execute(back_reference l, rhs const& r) \ { \ l.get() op r; \ return python::incref(l.source().ptr()); \ @@ -311,7 +317,8 @@ namespace detail \ template \ struct apply \ { \ - static PyObject* execute(T& x) \ + typedef typename unwrap_wrapper_::type self_t; \ + static PyObject* execute(self_t& x) \ { \ return detail::convert_result(op(x)); \ } \ diff --git a/include/boost/python/wrapper.hpp b/include/boost/python/wrapper.hpp index 28871a5e..166c8e23 100755 --- a/include/boost/python/wrapper.hpp +++ b/include/boost/python/wrapper.hpp @@ -14,10 +14,10 @@ namespace boost { namespace python { template class wrapper : public detail::wrapper_base { -# if defined(BOOST_PYTHON_NO_SFINAE) public: + // Do not touch this implementation detail! typedef T _wrapper_wrapped_type_; -# endif + protected: override get_override(char const* name) const { diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 78ac8d8d..81db0676 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -82,6 +82,7 @@ bpl-test crossmod_exception [ bpl-test test_pointer_adoption ] [ bpl-test operators ] + [ bpl-test operators_wrapper ] [ bpl-test callbacks ] [ bpl-test defaults ] diff --git a/test/operators_wrapper.cpp b/test/operators_wrapper.cpp new file mode 100644 index 00000000..f00aa2b4 --- /dev/null +++ b/test/operators_wrapper.cpp @@ -0,0 +1,42 @@ +#include "boost/python.hpp" +#include + +struct vector +{ + virtual ~vector() {} + + vector operator+( const vector& x ) const + { return vector(); } + + vector& operator+=( const vector& x ) + { return *this; } + + vector operator-() const + { return *this; } +}; + +struct dvector : vector +{}; + +using namespace boost::python; + +struct vector_wrapper + : vector, wrapper< vector > +{ + vector_wrapper(vector const&) {} + vector_wrapper() {} +}; + +BOOST_PYTHON_MODULE( operators_wrapper_ext ) +{ + class_< vector_wrapper >( "vector" ) + .def( self + self ) + .def( self += self ) + .def( -self ) + ; + + scope().attr("v") = vector(); + std::auto_ptr dp(new dvector); + register_ptr_to_python< std::auto_ptr >(); + scope().attr("d") = dp; +} diff --git a/test/operators_wrapper.py b/test/operators_wrapper.py new file mode 100644 index 00000000..6c889b0a --- /dev/null +++ b/test/operators_wrapper.py @@ -0,0 +1,11 @@ +from operators_wrapper_ext import * + +class D2(vector): pass +d2 = D2() + +for lhs in (v,d,d2): + -lhs + for rhs in (v,d,d2): + lhs + rhs + lhs += rhs + From 5ab00bc9c8f3c6e4696154da885506a99159acd9 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Fri, 29 Sep 2006 22:24:12 +0000 Subject: [PATCH 053/268] Fix long-standing misnaming of "factory" method as "array" [SVN r35428] --- src/numeric.cpp | 2 +- test/numpy.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/numeric.cpp b/src/numeric.cpp index 698604d0..3e64e141 100644 --- a/src/numeric.cpp +++ b/src/numeric.cpp @@ -205,7 +205,7 @@ namespace aux , bool savespace , object typecode) { - return attr("array")(buffer, type, shape, copy, savespace, typecode); + return attr("factory")(buffer, type, shape, copy, savespace, typecode); } object array_base::getflat() const diff --git a/test/numpy.py b/test/numpy.py index e95bac88..6f186c59 100644 --- a/test/numpy.py +++ b/test/numpy.py @@ -87,11 +87,11 @@ def _numarray_tests(): >>> check(y); >>> check(y.type()); - >>> check(y.array((1.2, 3.4))); - >>> check(y.array((1.2, 3.4), "Double")); - >>> check(y.array((1.2, 3.4), "Double", (1,2,1))); - >>> check(y.array((1.2, 3.4), "Double", (2,1,1), false)); - >>> check(y.array((1.2, 3.4), "Double", (2,), true, true)); + >>> check(y.factory((1.2, 3.4))); + >>> check(y.factory((1.2, 3.4), "Double")); + >>> check(y.factory((1.2, 3.4), "Double", (1,2,1))); + >>> check(y.factory((1.2, 3.4), "Double", (2,1,1), false)); + >>> check(y.factory((1.2, 3.4), "Double", (2,), true, true)); >>> p.results [] From 7a59131d374cdf2b18ab5b593bcd10ba49076c4c Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 8 Oct 2006 05:17:20 +0000 Subject: [PATCH 054/268] Fix missing #include [SVN r35524] --- include/boost/python/operators.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/boost/python/operators.hpp b/include/boost/python/operators.hpp index 3851b494..e929779e 100644 --- a/include/boost/python/operators.hpp +++ b/include/boost/python/operators.hpp @@ -18,6 +18,7 @@ # include # include # include +# include # include # include From d78836b82844e73bca9310699a0c2339eb90f5df Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Mon, 9 Oct 2006 04:05:25 +0000 Subject: [PATCH 055/268] Fix lots of bugs in the numeric interface and tests. Tests: * Coerce a result to bool to deal with Python's new Bool type * Better reporting of mismatches in expected and received results * Remove bogus nullary y.astype() call * Fix all uses of trace and diagonal so they don't cause errors * Use appropriate typecodes * Use doctest detailed API to run just the relevant tests * Factor out error handling from macro API: * Added get_module_name() function to get current numeric module * new_(x) now returns an array instead of object * Fixed the signatures of the factory() family of functions * Updated docs accordingly. [SVN r35528] --- doc/v2/numeric.html | 268 ++++++++++++++++--------------- include/boost/python/numeric.hpp | 73 +++++---- src/numeric.cpp | 25 +-- test/numpy.cpp | 44 +++-- test/numpy.py | 67 +++++--- 5 files changed, 267 insertions(+), 210 deletions(-) diff --git a/doc/v2/numeric.html b/doc/v2/numeric.html index 0817f5ef..ea04d5aa 100644 --- a/doc/v2/numeric.html +++ b/doc/v2/numeric.html @@ -1,105 +1,105 @@ - + - - - - + + + + - Boost.Python - <boost/python/numeric.hpp> - + Boost.Python - <boost/python/numeric.hpp> + - - - - + +
    -

    C++ Boost

    -
    + + - - -
    +

    +

    +
    -

    Boost.Python

    +
    +

    Boost.Python

    -

    Header <boost/python/numeric.hpp>

    -
    -
    +

    Header <boost/python/numeric.hpp>

    + + + +
    -

    Contents

    +

    Contents

    -
    -
    Introduction
    +
    +
    Introduction
    -
    Classes
    +
    Classes
    -
    -
    -
    Class array
    +
    +
    +
    Class array
    -
    -
    -
    Class array - synopsis
    +
    +
    +
    Class array + synopsis
    -
    Class array - observer functions
    +
    Class array + observer functions
    -
    Class array - static functions
    -
    -
    -
    -
    +
    Class array static + functions
    +
    +
    +
    +
    -
    Example(s)
    -
    -
    +
    Example(s)
    +
    +
    -

    Introduction

    +

    Introduction

    -

    Exposes a TypeWrapper for the Python - array - type.

    +

    Exposes a TypeWrapper for the Python + array + type.

    -

    Classes

    +

    Classes

    -

    Class array

    +

    Class array

    -

    Provides access to the array types of Numerical Python's Numeric and NumArray modules. With - the exception of the functions documented below, the semantics of the constructors and - member functions defined below can be fully understood by reading the TypeWrapper concept - definition. Since array is publicly derived from object, the public object - interface applies to array instances as well.

    +

    Provides access to the array types of Numerical Python's Numeric and NumArray modules. With + the exception of the functions documented below, the semantics of the constructors and + member functions defined below can be fully understood by reading the + TypeWrapper concept + definition. Since array is publicly derived from + object, the public + object interface applies to array instances as well.

    -

    The default behavior is to use - numarray.NDArray as the associated Python type if the - numarray module is installed in the default location. - Otherwise it falls back to use Numeric.ArrayType. If neither - extension module is installed, conversions to arguments of type - numeric::array will cause overload resolution to reject the - overload, and other attempted uses of numeric::array will raise an appropriate Python exception. - The associated Python type can be set manually using the set_module_and_type(...) static - function.

    +

    The default behavior is + to use numarray.NDArray as the associated Python type if the + numarray module is installed in the default location. + Otherwise it falls back to use Numeric.ArrayType. If neither + extension module is installed, overloads of wrapped C++ functions with + numeric::array parameters will never be matched, and other + attempted uses of numeric::array will raise an appropriate Python exception. The + associated Python type can be set manually using the set_module_and_type(...) static + function.

    -

    Class array - synopsis

    -
    +  

    Class + array synopsis

    +
     namespace boost { namespace python { namespace numeric
     {
        class array : public object
    @@ -110,7 +110,7 @@ namespace boost { namespace python { namespace numeric
           object astype(Type const& type_);
     
           template <class Type>
    -      object new_(Type const& type_) const;
    +      array new_(Type const& type_) const;
     
           template <class Sequence> 
           void resize(Sequence const& x);
    @@ -136,14 +136,14 @@ namespace boost { namespace python { namespace numeric
           void tofile(File const& f) const;
     
           object factory();
    -      template <class Buffer>
    -      object factory(Buffer const&);
    -      template <class Buffer, class Type>
    -      object factory(Buffer const&, Type const&);
    -      template <class Buffer, class Type, class Shape>
    -      object factory(Buffer const&, Type const&, Shape const&, bool copy = true, bool savespace = false);
    -      template <class Buffer, class Type, class Shape>
    -      object factory(Buffer const&, Type const&, Shape const&, bool copy, bool savespace, char typecode);
    +      template <class Sequence>
    +      object factory(Sequence const&);
    +      template <class Sequence, class Typecode>
    +      object factory(Sequence const&, Typecode const&, bool copy = true, bool savespace = false);
    +      template <class Sequence, class Typecode, class Type>
    +      object factory(Sequence const&, Typecode const&, bool copy, bool savespace, Type const&);
    +      template <class Sequence, class Typecode, class Type, class Shape>
    +      object factory(Sequence const&, Typecode const&, bool copy, bool savespace, Type const&, Shape const&);
     
           template <class T1>
           explicit array(T1 const& x1);
    @@ -155,6 +155,7 @@ namespace boost { namespace python { namespace numeric
     
           static void set_module_and_type();
           static void set_module_and_type(char const* package_path = 0, char const* type_name = 0);
    +      static void get_module_name();
     
           object argmax(long axis=-1);
     
    @@ -203,54 +204,60 @@ namespace boost { namespace python { namespace numeric
     }}}
     
    -

    Class array observer - functions

    -
    +  

    Class + array observer functions

    +
     object factory();
    -template <class Buffer>
    -object factory(Buffer const&);
    -template <class Buffer, class Type>
    -object factory(Buffer const&, Type const&);
    -template <class Buffer, class Type, class Shape>
    -object factory(Buffer const&, Type const&, Shape const&, bool copy = true, bool savespace = false);
    -template <class Buffer, class Type, class Shape>
    -object factory(Buffer const&, Type const&, Shape const&, bool copy, bool savespace, char typecode);
    -
    - These functions map to the underlying array type's array() - function family. They are not called "array" because of the - C++ limitation that you can't define a member function with the same name - as its enclosing class. -
    +template <class Sequence>
    +object factory(Sequence const&);
    +template <class Sequence, class Typecode>
    +object factory(Sequence const&, Typecode const&, bool copy = true, bool savespace = false);
    +template <class Sequence, class Typecode, class Type>
    +object factory(Sequence const&, Typecode const&, bool copy, bool savespace, Type const&);
    +template <class Sequence, class Typecode, class Type, class Shape>
    +object factory(Sequence const&, Typecode const&, bool copy, bool savespace, Type const&, Shape const&);
    +
    These functions map to the underlying array type's array() +function family. They are not called "array" because of the C++ +limitation that you can't define a member function with the same name as its +enclosing class. +
     template <class Type>
    -object new_(Type const&) const;
    -
    - This function maps to the underlying array type's new() - function. It is not called "new" because that is a keyword - in C++. +array new_(Type const&) const; +
    This function maps to the underlying array type's new() +function. It is not called "new" because that is a keyword in +C++. -

    Class array static - functions

    -
    +  

    Class + array static functions

    +
     static void set_module_and_type(char const* package_path, char const* type_name);
     static void set_module_and_type();
     
    -
    -
    Requires: package_path and - type_name, if supplied, is an ntbs.
    +
    +
    Requires: package_path and + type_name, if supplied, is an ntbs.
    -
    Effects: The first form sets the package path of the module - which supplies the type named by type_name to - package_path. The second form restores the default search behavior. The associated Python - type will be searched for only the first time it is needed, and - thereafter the first time it is needed after an invocation of - set_module_and_type.
    -
    +
    Effects: The first form sets the package path of the module + that supplies the type named by type_name to + package_path. The second form restores the default search behavior. The associated Python type + will be searched for only the first time it is needed, and thereafter the + first time it is needed after an invocation of + set_module_and_type.
    +
    +
    +static std::string get_module_name()
    +
    -

    Example

    -
    +  
    +
    Effects: Returns the name of the module containing the class + that will be held by new numeric::array instances.
    +
    + +

    Example

    +
     #include <boost/python/numeric.hpp>
     #include <boost/python/tuple.hpp>
     
    @@ -261,10 +268,9 @@ void set_first_element(numeric::array& y, double value)
     }
     
    -

    Revised 03 October, 2002

    +

    Revised 07 October, 2006

    -

    © Copyright Dave Abrahams 2002.

    - +

    © Copyright Dave + Abrahams 2002-2006.

    + - diff --git a/include/boost/python/numeric.hpp b/include/boost/python/numeric.hpp index 14aa7d6d..3868154b 100644 --- a/include/boost/python/numeric.hpp +++ b/include/boost/python/numeric.hpp @@ -17,6 +17,8 @@ namespace boost { namespace python { namespace numeric { +struct array; + namespace aux { struct BOOST_PYTHON_DECL array_base : object @@ -36,18 +38,19 @@ namespace aux void info() const; bool is_c_array() const; bool isbyteswapped() const; - object new_(object type) const; + array new_(object type) const; void sort(); object trace(long offset = 0, long axis1 = 0, long axis2 = 1) const; object type() const; char typecode() const; - - object factory(object const& buffer=object() - , object const& type=object() - , object const& shape=object() - , bool copy = true - , bool savespace = false - , object typecode = object()); + + object factory( + object const& sequence = object() + , object const& typecode = object() + , bool copy = true + , bool savespace = false + , object type = object() + , object shape = object()); object getflat() const; long getrank() const; @@ -106,7 +109,7 @@ class array : public aux::array_base } template - object new_(Type const& type_) const + array new_(Type const& type_) const { return base::new_(object(type_)); } @@ -162,43 +165,48 @@ class array : public aux::array_base return base::factory(); } - template - object factory(Buffer const& buffer) + template + object factory(Sequence const& sequence) { - return base::factory(object(buffer)); + return base::factory(object(sequence)); } - template + template object factory( - Buffer const& buffer - , Type const& type_) + Sequence const& sequence + , Typecode const& typecode_ + , bool copy = true + , bool savespace = false + ) { - return base::factory(object(buffer), object(type_)); + return base::factory(object(sequence), object(typecode_), copy, savespace); } - template + template object factory( - Buffer const& buffer - , Type const& type_ - , Shape const& shape - , bool copy = true - , bool savespace = false) + Sequence const& sequence + , Typecode const& typecode_ + , bool copy + , bool savespace + , Type const& type + ) { - return base::factory(object(buffer), object(type_), object(shape), copy, savespace); + return base::factory(object(sequence), object(typecode_), copy, savespace, object(type)); } - template + template object factory( - Buffer const& buffer - , Type const& type_ - , Shape const& shape - , bool copy - , bool savespace - , char typecode) + Sequence const& sequence + , Typecode const& typecode_ + , bool copy + , bool savespace + , Type const& type + , Shape const& shape + ) { - return base::factory(object(buffer), object(type_), object(shape), copy, savespace, object(typecode)); + return base::factory(object(sequence), object(typecode_), copy, savespace, object(type), object(shape)); } - + # define BOOST_PYTHON_ENUM_AS_OBJECT(z, n, x) object(BOOST_PP_CAT(x,n)) # define BOOST_PP_LOCAL_MACRO(n) \ template \ @@ -210,6 +218,7 @@ class array : public aux::array_base # undef BOOST_PYTHON_AS_OBJECT static BOOST_PYTHON_DECL void set_module_and_type(char const* package_name = 0, char const* type_attribute_name = 0); + static BOOST_PYTHON_DECL std::string get_module_name(); public: // implementation detail -- for internal use only BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS(array, base); diff --git a/src/numeric.cpp b/src/numeric.cpp index 3e64e141..35c469c5 100644 --- a/src/numeric.cpp +++ b/src/numeric.cpp @@ -90,7 +90,12 @@ void array::set_module_and_type(char const* package_name, char const* type_attri module_name = package_name ? package_name : "" ; type_name = type_attribute_name ? type_attribute_name : "" ; } - + +std::string array::get_module_name() +{ + load(false); + return module_name; +} namespace aux { @@ -173,9 +178,9 @@ namespace aux return extract(attr("isbyteswapped")()); } - object array_base::new_(object type) const + array array_base::new_(object type) const { - return attr("new")(type); + return extract(attr("new")(type))(); } void array_base::sort() @@ -197,15 +202,17 @@ namespace aux { return extract(attr("typecode")()); } - - object array_base::factory(object const& buffer - , object const& type - , object const& shape + + object array_base::factory( + object const& sequence + , object const& typecode , bool copy , bool savespace - , object typecode) + , object type + , object shape + ) { - return attr("factory")(buffer, type, shape, copy, savespace, typecode); + return attr("factory")(sequence, typecode, copy, savespace, type, shape); } object array_base::getflat() const diff --git a/test/numpy.cpp b/test/numpy.cpp index deb9667b..962a6a8c 100644 --- a/test/numpy.cpp +++ b/test/numpy.cpp @@ -7,6 +7,7 @@ #include #include #include +#include using namespace boost::python; @@ -39,19 +40,28 @@ void info(numeric::array const& z) z.info(); } +namespace +{ + object handle_error() + { + PyObject* type, *value, *traceback; + PyErr_Fetch(&type, &value, &traceback); + handle<> ty(type), v(value), tr(traceback); + return object("exception"); + str format("exception type: %sn"); + format += "exception value: %sn"; + format += "traceback:n%s" ; + object ret = format % boost::python::make_tuple(ty, v, tr); + return ret; + } +} #define CHECK(expr) \ { \ object result; \ try { result = object(expr); } \ catch(error_already_set) \ { \ - PyObject* type, *value, *traceback; \ - PyErr_Fetch(&type, &value, &traceback); \ - handle<> ty(type), v(value), tr(traceback); \ - str format("exception type: %s\n"); \ - format += "exception value: %s\n"; \ - format += "traceback:\n%s" ; \ - result = format % boost::python::make_tuple(ty, v, tr); \ + result = handle_error(); \ } \ check(result); \ } @@ -73,7 +83,7 @@ void exercise(numeric::array& y, object check) // the results of corresponding python operations. void exercise_numarray(numeric::array& y, object check) { - CHECK(y.astype()); + CHECK(str(y)); CHECK(y.argmax()); CHECK(y.argmax(0)); @@ -89,7 +99,7 @@ void exercise_numarray(numeric::array& y, object check) CHECK(y.diagonal()); CHECK(y.diagonal(1)); - CHECK(y.diagonal(0, 1)); + CHECK(y.diagonal(0, 0)); CHECK(y.diagonal(0, 1, 0)); CHECK(y.is_c_array()); @@ -97,19 +107,22 @@ void exercise_numarray(numeric::array& y, object check) CHECK(y.trace()); CHECK(y.trace(1)); - CHECK(y.trace(0, 1)); + CHECK(y.trace(0, 0)); CHECK(y.trace(0, 1, 0)); - CHECK(y.new_('D')); + CHECK(y.new_("D").getshape()); + CHECK(y.new_("D").type()); y.sort(); CHECK(y); CHECK(y.type()); CHECK(y.factory(make_tuple(1.2, 3.4))); - CHECK(y.factory(make_tuple(1.2, 3.4), "Double")); - CHECK(y.factory(make_tuple(1.2, 3.4), "Double", make_tuple(1,2,1))); - CHECK(y.factory(make_tuple(1.2, 3.4), "Double", make_tuple(2,1,1), false)); - CHECK(y.factory(make_tuple(1.2, 3.4), "Double", make_tuple(2), true, true)); + CHECK(y.factory(make_tuple(1.2, 3.4), "f8")); + CHECK(y.factory(make_tuple(1.2, 3.4), "f8", true)); + CHECK(y.factory(make_tuple(1.2, 3.4), "f8", true, false)); + CHECK(y.factory(make_tuple(1.2, 3.4), "f8", true, false, object())); + CHECK (y.factory(make_tuple(1.2, 3.4), "f8", true, false, object(), make_tuple(1,2,1))); + } BOOST_PYTHON_MODULE(numpy_ext) @@ -119,6 +132,7 @@ BOOST_PYTHON_MODULE(numpy_ext) def("exercise", exercise); def("exercise_numarray", exercise_numarray); def("set_module_and_type", &numeric::array::set_module_and_type); + def("get_module_name", &numeric::array::get_module_name); def("info", info); } diff --git a/test/numpy.py b/test/numpy.py index 6f186c59..f4fbcdf3 100644 --- a/test/numpy.py +++ b/test/numpy.py @@ -8,6 +8,9 @@ # tests based on the availability of Numeric and numarray, the corresponding # test functions are simply deleted below if necessary. +# So we can coerce portably across Python versions +bool = type(1 == 1) + def numeric_tests(): ''' >>> from numpy_ext import * @@ -55,8 +58,8 @@ def _numarray_tests(): >>> check = p.check >>> exercise_numarray(x, p) - >>> check(y.astype()); - + >>> check(str(y)) + >>> check(y.argmax()); >>> check(y.argmax(0)); @@ -68,30 +71,35 @@ def _numarray_tests(): >>> y.byteswap(); >>> check(y); - + >>> check(y.diagonal()); >>> check(y.diagonal(1)); - >>> check(y.diagonal(0, 1)); + >>> check(y.diagonal(0, 0)); >>> check(y.diagonal(0, 1, 0)); >>> check(y.is_c_array()); - >>> check(y.isbyteswapped()); + + # coerce because numarray still returns an int and the C++ interface forces + # the return type to bool + >>> check( bool(y.isbyteswapped()) ); >>> check(y.trace()); >>> check(y.trace(1)); - >>> check(y.trace(0, 1)); + >>> check(y.trace(0, 0)); >>> check(y.trace(0, 1, 0)); - >>> check(y.new('D')); + >>> check(y.new('D').getshape()); + >>> check(y.new('D').type()); >>> y.sort(); >>> check(y); >>> check(y.type()); >>> check(y.factory((1.2, 3.4))); - >>> check(y.factory((1.2, 3.4), "Double")); - >>> check(y.factory((1.2, 3.4), "Double", (1,2,1))); - >>> check(y.factory((1.2, 3.4), "Double", (2,1,1), false)); - >>> check(y.factory((1.2, 3.4), "Double", (2,), true, true)); + >>> check(y.factory((1.2, 3.4), "f8")) + >>> check(y.factory((1.2, 3.4), "f8", true)) + >>> check(y.factory((1.2, 3.4), "f8", true, false)) + >>> check(y.factory((1.2, 3.4), "f8", true, false, None)) + >>> check(y.factory((1.2, 3.4), "f8", true, false, None, (1,2,1))) >>> p.results [] @@ -105,12 +113,12 @@ class _printer(object): def __init__(self): self.results = []; def __call__(self, *stuff): - self.results += [ str(x) for x in stuff ] + for x in stuff: + self.results.append(str(x)) def check(self, x): - if self.results[0] == str(x): - del self.results[0] - else: - print ' Expected:\n %s\n but got:\n %s' % (x, self.results[0]) + if self.results[0] != str(x): + print ' Expected:\n %s\n but the C++ interface gave:\n %s' % (x, self.results[0]) + del self.results[0] def _run(args = None): import sys @@ -150,21 +158,29 @@ def _run(args = None): failures = 0 + find = doctest.DocTestFinder().find + run = doctest.DocTestRunner().run + # # Run tests 4 different ways if both modules are installed, just # to show that set_module_and_type() is working properly # # run all the tests with default module search - print 'testing default extension module' - failures += doctest.testmod(sys.modules.get(__name__))[0] + print 'testing default extension module:', \ + numpy_ext.get_module_name() or '[numeric support not installed]' + for test in find(numeric_tests): + failures += run(test)[0] + # test against Numeric if installed if has_numeric: print 'testing Numeric module explicitly' numpy_ext.set_module_and_type('Numeric', 'ArrayType') - failures += doctest.testmod(sys.modules.get(__name__))[0] - + + for test in find(numeric_tests): + failures += run(test)[0] + global __test__ if has_numarray: # Add the _numarray_tests to the list of things to test in @@ -173,13 +189,18 @@ def _run(args = None): 'numeric_tests': numeric_tests } print 'testing numarray module explicitly' numpy_ext.set_module_and_type('numarray', 'NDArray') - failures += doctest.testmod(sys.modules.get(__name__))[0] + + for test in find(numeric_tests) + find(_numarray_tests): + failures += run(test)[0] del __test__ # see that we can go back to the default - print 'testing default module again' numpy_ext.set_module_and_type('', '') - failures += doctest.testmod(sys.modules.get(__name__))[0] + print 'testing default module again:', \ + numpy_ext.get_module_name() or '[numeric support not installed]' + + for test in find(numeric_tests): + failures += run(test)[0] return failures From 479a6ba4fc97b5224b46a0ffad7c715d5e8acb4a Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Tue, 10 Oct 2006 18:12:43 +0000 Subject: [PATCH 056/268] Try for backward compatibility with older versions of doctest [SVN r35535] --- test/numpy.py | 49 ++++++++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/test/numpy.py b/test/numpy.py index f4fbcdf3..afd5fdcf 100644 --- a/test/numpy.py +++ b/test/numpy.py @@ -120,9 +120,31 @@ class _printer(object): print ' Expected:\n %s\n but the C++ interface gave:\n %s' % (x, self.results[0]) del self.results[0] +def _count_failures(test_names = ('numeric_tests',)): + '''Given a sequence of test function names, run all the doctests associated + with each function and return the total number of failures. Works portably + across versions of doctest.''' + + import doctest + if hasattr(doctest, 'DocTestFinder'): + # Newer doctest fails to work with the old idiom, even though it's only + # marked "deprecated." + failures = 0 + for n in test_names: + for t in doctest.DocTestFinder().find(eval(n)): + print 'test:', t + failures += doctest.DocTestRunner().run(t)[0] + return failures + + else: + global __test__ + __test__ = {} + for t in test_names: + __test__[t] = eval(t) + return doctest.testmod(sys.modules.get(__name__))[0] + def _run(args = None): import sys - import doctest if args is not None: sys.argv = args @@ -158,9 +180,6 @@ def _run(args = None): failures = 0 - find = doctest.DocTestFinder().find - run = doctest.DocTestRunner().run - # # Run tests 4 different ways if both modules are installed, just # to show that set_module_and_type() is working properly @@ -170,37 +189,29 @@ def _run(args = None): print 'testing default extension module:', \ numpy_ext.get_module_name() or '[numeric support not installed]' - for test in find(numeric_tests): - failures += run(test)[0] + failures += _count_failures() # test against Numeric if installed if has_numeric: print 'testing Numeric module explicitly' numpy_ext.set_module_and_type('Numeric', 'ArrayType') - for test in find(numeric_tests): - failures += run(test)[0] - + failures += _count_failures() + global __test__ if has_numarray: - # Add the _numarray_tests to the list of things to test in - # this case. - __test__ = { 'numarray_tests':_numarray_tests, - 'numeric_tests': numeric_tests } print 'testing numarray module explicitly' numpy_ext.set_module_and_type('numarray', 'NDArray') - - for test in find(numeric_tests) + find(_numarray_tests): - failures += run(test)[0] - del __test__ + # Add the _numarray_tests to the list of things to test in + # this case. + failures += _count_failures(('_numarray_tests', 'numeric_tests')) # see that we can go back to the default numpy_ext.set_module_and_type('', '') print 'testing default module again:', \ numpy_ext.get_module_name() or '[numeric support not installed]' - for test in find(numeric_tests): - failures += run(test)[0] + failures += _count_failures() return failures From b714f6cc23633c7067ffac923f2d43c3f948cb30 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Tue, 10 Oct 2006 22:44:09 +0000 Subject: [PATCH 057/268] Adjust tests to account for numarray behavior differences [SVN r35539] --- test/slice.cpp | 9 ++++++--- test/slice.py | 23 ++++++++++------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/test/slice.cpp b/test/slice.cpp index f25c9017..4d4d03f0 100644 --- a/test/slice.cpp +++ b/test/slice.cpp @@ -48,14 +48,17 @@ bool check_string_rich_slice() // contents) but Numeric complains that treating an array as a boolean // value doesn't make any sense. #define ASSERT_EQUAL( e1, e2 ) \ -if ((e1) != (e2)) \ - return object("assertion failed: " #e1 " == " #e2 "\nLHS:\n") /*+ str(e1) + "\nRHS:\n" + str(e2)*/; \ + if (!all((e1) == (e2))) \ + return object("assertion failed: " #e1 " == " #e2 "\nLHS:\n") + str(e1) + "\nRHS:\n" + str(e2); \ else // These tests work with Python 2.2, but you must have Numeric installed. -object check_numeric_array_rich_slice() +object check_numeric_array_rich_slice( + char const* module_name, char const* array_type_name, object all) { using numeric::array; + array::set_module_and_type(module_name, array_type_name); + array original = array( make_tuple( make_tuple( 11, 12, 13, 14), make_tuple( 21, 22, 23, 24), make_tuple( 31, 32, 33, 34), diff --git a/test/slice.py b/test/slice.py index ed60c620..c281845b 100644 --- a/test/slice.py +++ b/test/slice.py @@ -12,23 +12,20 @@ ... print "test passed" ... test passed ->>> have_numeric = 0 >>> try: ... from Numeric import array -... have_numeric = 1 ... except: -... pass -... ->>> try: -... from numarray import array -... have_numeric = 1 -... except: -... pass -... ->>> if have_numeric: -... check_numeric_array_rich_slice() -... else: ... print 1 +... else: +... check_numeric_array_rich_slice('Numeric', 'ArrayType', lambda x:x) +... +1 +>>> try: +... from numarray import array, all +... except: +... print 1 +... else: +... check_numeric_array_rich_slice('numarray', 'NDArray', all) ... 1 >>> import sys From 9b67f0447d272c78aa2c19b96c207b2ea17c6fef Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Thu, 12 Oct 2006 06:41:18 +0000 Subject: [PATCH 058/268] Suppress a couple of msvc class/struct warnings [SVN r35567] --- include/boost/python/docstring_options.hpp | 2 +- include/boost/python/numeric.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/python/docstring_options.hpp b/include/boost/python/docstring_options.hpp index 08346ebc..507a4c5d 100755 --- a/include/boost/python/docstring_options.hpp +++ b/include/boost/python/docstring_options.hpp @@ -62,7 +62,7 @@ class BOOST_PYTHON_DECL docstring_options : boost::noncopyable show_signatures_ = true; } - friend class objects::function; + friend struct objects::function; private: static volatile bool show_user_defined_; diff --git a/include/boost/python/numeric.hpp b/include/boost/python/numeric.hpp index 3868154b..66fde676 100644 --- a/include/boost/python/numeric.hpp +++ b/include/boost/python/numeric.hpp @@ -17,7 +17,7 @@ namespace boost { namespace python { namespace numeric { -struct array; +class array; namespace aux { From 991a7c198adc907df8dd7592e4f1dd7b62c5fab7 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Thu, 12 Oct 2006 06:41:55 +0000 Subject: [PATCH 059/268] Workaround vc6 bugs [SVN r35568] --- test/slice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/slice.cpp b/test/slice.cpp index 4d4d03f0..f28e38f5 100644 --- a/test/slice.cpp +++ b/test/slice.cpp @@ -49,7 +49,7 @@ bool check_string_rich_slice() // value doesn't make any sense. #define ASSERT_EQUAL( e1, e2 ) \ if (!all((e1) == (e2))) \ - return object("assertion failed: " #e1 " == " #e2 "\nLHS:\n") + str(e1) + "\nRHS:\n" + str(e2); \ + return "assertion failed: " #e1 " == " #e2 "\nLHS:\n%s\nRHS:\n%s" % make_tuple(e1,e2); \ else // These tests work with Python 2.2, but you must have Numeric installed. From c3bd0fcbad03d3432fb65b7a68dc5c58640c0d1f Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Thu, 12 Oct 2006 09:07:07 +0000 Subject: [PATCH 060/268] Make object comparison operators return object instead of bool, to accomodate strange beasts like numarray arrays that return arrays that can't be used as truth values from their comparison ops. Fix numpy test for portability with old doctest (again!) [SVN r35572] --- doc/v2/object.html | 12 ++++++------ include/boost/python/object_operators.hpp | 16 ++++++++-------- src/object_operators.cpp | 18 ++++++++++++++++++ test/slice.cpp | 1 + 4 files changed, 33 insertions(+), 14 deletions(-) diff --git a/doc/v2/object.html b/doc/v2/object.html index 10be8757..a8913c70 100644 --- a/doc/v2/object.html +++ b/doc/v2/object.html @@ -854,12 +854,12 @@ void del(proxy<T> const& x);
     
    -template<class L,class R> bool operator>(L const&l,R const&r);
    -template<class L,class R> bool operator>=(L const&l,R const&r);
    -template<class L,class R> bool operator<(L const&l,R const&r);
    -template<class L,class R> bool operator<=(L const&l,R const&r);
    -template<class L,class R> bool operator==(L const&l,R const&r);
    -template<class L,class R> bool operator!=(L const&l,R const&r);
    +template<class L,class R> object operator>(L const&l,R const&r);
    +template<class L,class R> object operator>=(L const&l,R const&r);
    +template<class L,class R> object operator<(L const&l,R const&r);
    +template<class L,class R> object operator<=(L const&l,R const&r);
    +template<class L,class R> object operator==(L const&l,R const&r);
    +template<class L,class R> object operator!=(L const&l,R const&r);
     
    diff --git a/include/boost/python/object_operators.hpp b/include/boost/python/object_operators.hpp index 0515309b..f27f88f8 100644 --- a/include/boost/python/object_operators.hpp +++ b/include/boost/python/object_operators.hpp @@ -73,17 +73,11 @@ object_operators::operator!() const # define BOOST_PYTHON_COMPARE_OP(op, opid) \ template \ -BOOST_PYTHON_BINARY_RETURN(bool) operator op(L const& l, R const& r) \ +BOOST_PYTHON_BINARY_RETURN(object) operator op(L const& l, R const& r) \ { \ - return PyObject_RichCompareBool( \ + return PyObject_RichCompare( \ object(l).ptr(), object(r).ptr(), opid); \ } -BOOST_PYTHON_COMPARE_OP(>, Py_GT) -BOOST_PYTHON_COMPARE_OP(>=, Py_GE) -BOOST_PYTHON_COMPARE_OP(<, Py_LT) -BOOST_PYTHON_COMPARE_OP(<=, Py_LE) -BOOST_PYTHON_COMPARE_OP(==, Py_EQ) -BOOST_PYTHON_COMPARE_OP(!=, Py_NE) # undef BOOST_PYTHON_COMPARE_OP # define BOOST_PYTHON_BINARY_OPERATOR(op) \ @@ -93,6 +87,12 @@ BOOST_PYTHON_BINARY_RETURN(object) operator op(L const& l, R const& r) \ { \ return object(l) op object(r); \ } +BOOST_PYTHON_BINARY_OPERATOR(>) +BOOST_PYTHON_BINARY_OPERATOR(>=) +BOOST_PYTHON_BINARY_OPERATOR(<) +BOOST_PYTHON_BINARY_OPERATOR(<=) +BOOST_PYTHON_BINARY_OPERATOR(==) +BOOST_PYTHON_BINARY_OPERATOR(!=) BOOST_PYTHON_BINARY_OPERATOR(+) BOOST_PYTHON_BINARY_OPERATOR(-) BOOST_PYTHON_BINARY_OPERATOR(*) diff --git a/src/object_operators.cpp b/src/object_operators.cpp index 5d8ffd6a..b6f1c5fb 100644 --- a/src/object_operators.cpp +++ b/src/object_operators.cpp @@ -8,6 +8,24 @@ namespace boost { namespace python { namespace api { +# define BOOST_PYTHON_COMPARE_OP(op, opid) \ +BOOST_PYTHON_DECL object operator op(object const& l, object const& r) \ +{ \ + return object( \ + detail::new_reference( \ + PyObject_RichCompare( \ + l.ptr(), r.ptr(), opid)) \ + ); \ +} +BOOST_PYTHON_COMPARE_OP(>, Py_GT) +BOOST_PYTHON_COMPARE_OP(>=, Py_GE) +BOOST_PYTHON_COMPARE_OP(<, Py_LT) +BOOST_PYTHON_COMPARE_OP(<=, Py_LE) +BOOST_PYTHON_COMPARE_OP(==, Py_EQ) +BOOST_PYTHON_COMPARE_OP(!=, Py_NE) +# undef BOOST_PYTHON_COMPARE_OP + + #define BOOST_PYTHON_BINARY_OPERATOR(op, name) \ BOOST_PYTHON_DECL object operator op(object const& l, object const& r) \ { \ diff --git a/test/slice.cpp b/test/slice.cpp index f28e38f5..ebf2afa1 100644 --- a/test/slice.cpp +++ b/test/slice.cpp @@ -1,3 +1,4 @@ +Warning: No xauth data; using fake authentication data for X11 forwarding. #include #include #include From 600d444136cb0a624e94f84f0890597a47982937 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Fri, 13 Oct 2006 19:35:28 +0000 Subject: [PATCH 061/268] Fix some problems with testing on old docutils installations [SVN r35594] --- test/numpy.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/test/numpy.py b/test/numpy.py index afd5fdcf..af3e90ed 100644 --- a/test/numpy.py +++ b/test/numpy.py @@ -151,22 +151,18 @@ def _run(args = None): # See which of the numeric modules are installed has_numeric = 0 - try: - import Numeric - m = Numeric + try: import Numeric + except ImportError: pass + else: has_numeric = 1 - except ImportError: - global numeric_tests - numeric_tests = None + m = Numeric has_numarray = 0 - try: - import numarray - m = numarray + try: import numarray + except ImportError: pass + else: has_numarray = 1 - except ImportError: - global _numarray_tests - _numarray_tests = None + m = numarray # Bail if neither one is installed if not (has_numeric or has_numarray): From 31c19644ed5d6b9b29fc610d91dd02e832d59184 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Fri, 13 Oct 2006 21:34:26 +0000 Subject: [PATCH 062/268] make numpy tests portable to Darwin with older docutils [SVN r35597] --- test/Jamfile.v2 | 2 +- test/numarray_tests.py | 63 +++++++++++++++++ test/numeric_tests.py | 39 +++++++++++ test/numpy.py | 152 +++-------------------------------------- test/printer.py | 13 ++++ 5 files changed, 126 insertions(+), 143 deletions(-) create mode 100644 test/numarray_tests.py create mode 100644 test/numeric_tests.py create mode 100644 test/printer.py diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 81db0676..5b81cabd 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -68,7 +68,7 @@ bpl-test crossmod_exception [ bpl-test minimal ] [ bpl-test args ] [ bpl-test raw_ctor ] -[ bpl-test numpy ] +[ bpl-test numpy : printer.py numeric_tests.py numarray_tests.py numpy.py numpy.cpp ] [ bpl-test enum ] [ bpl-test exception_translator ] [ bpl-test pearu1 : test_cltree.py cltree.cpp ] diff --git a/test/numarray_tests.py b/test/numarray_tests.py new file mode 100644 index 00000000..be3d9d4e --- /dev/null +++ b/test/numarray_tests.py @@ -0,0 +1,63 @@ +# Copyright David Abrahams 2006. Distributed under 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) +import printer + +# So we can coerce portably across Python versions +bool = type(1 == 1) + +''' +>>> from numpy_ext import * +>>> x = new_array() +>>> y = x.copy() +>>> p = _printer() +>>> check = p.check +>>> exercise_numarray(x, p) + +>>> check(str(y)) + +>>> check(y.argmax()); +>>> check(y.argmax(0)); + +>>> check(y.argmin()); +>>> check(y.argmin(0)); + +>>> check(y.argsort()); +>>> check(y.argsort(1)); + +>>> y.byteswap(); +>>> check(y); + +>>> check(y.diagonal()); +>>> check(y.diagonal(1)); +>>> check(y.diagonal(0, 0)); +>>> check(y.diagonal(0, 1, 0)); + +>>> check(y.is_c_array()); + +# coerce because numarray still returns an int and the C++ interface forces +# the return type to bool +>>> check( bool(y.isbyteswapped()) ); + +>>> check(y.trace()); +>>> check(y.trace(1)); +>>> check(y.trace(0, 0)); +>>> check(y.trace(0, 1, 0)); + +>>> check(y.new('D').getshape()); +>>> check(y.new('D').type()); +>>> y.sort(); +>>> check(y); +>>> check(y.type()); + +>>> check(y.factory((1.2, 3.4))); +>>> check(y.factory((1.2, 3.4), "f8")) +>>> check(y.factory((1.2, 3.4), "f8", true)) +>>> check(y.factory((1.2, 3.4), "f8", true, false)) +>>> check(y.factory((1.2, 3.4), "f8", true, false, None)) +>>> check(y.factory((1.2, 3.4), "f8", true, false, None, (1,2,1))) + +>>> p.results +[] +>>> del p +''' diff --git a/test/numeric_tests.py b/test/numeric_tests.py new file mode 100644 index 00000000..569ec19e --- /dev/null +++ b/test/numeric_tests.py @@ -0,0 +1,39 @@ +# Copyright David Abrahams 2006. Distributed under 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) +import printer +''' +>>> from numpy_ext import * +>>> x = new_array() +>>> x[1,1] = 0.0 + +>>> try: take_array(3) +... except TypeError: pass +... else: print 'expected a TypeError' + +>>> take_array(x) + +>>> print x +[[1 2 3] + [4 0 6] + [7 8 9]] + +>>> y = x.copy() + + +>>> p = _printer() +>>> check = p.check +>>> exercise(x, p) +>>> y[2,1] = 3 +>>> check(y); + +>>> check(y.astype('D')); + +>>> check(y.copy()); + +>>> check(y.typecode()); + +>>> p.results +[] +>>> del p +''' diff --git a/test/numpy.py b/test/numpy.py index af3e90ed..84e8313d 100644 --- a/test/numpy.py +++ b/test/numpy.py @@ -2,149 +2,18 @@ # Software License, Version 1.0. (See accompanying # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -# Unfortunately the doctest module works differently in Python versions -# 2.2, 2.3, and 2.4. Newer versions evaluate all docstrings, even that -# of objects with names starting with an underscore. To portably disable -# tests based on the availability of Numeric and numarray, the corresponding -# test functions are simply deleted below if necessary. - -# So we can coerce portably across Python versions -bool = type(1 == 1) - -def numeric_tests(): - ''' - >>> from numpy_ext import * - >>> x = new_array() - >>> x[1,1] = 0.0 - - >>> try: take_array(3) - ... except TypeError: pass - ... else: print 'expected a TypeError' - - >>> take_array(x) - - >>> print x - [[1 2 3] - [4 0 6] - [7 8 9]] - - >>> y = x.copy() - - - >>> p = _printer() - >>> check = p.check - >>> exercise(x, p) - >>> y[2,1] = 3 - >>> check(y); - - >>> check(y.astype('D')); - - >>> check(y.copy()); - - >>> check(y.typecode()); - - >>> p.results - [] - >>> del p - ''' - pass - -def _numarray_tests(): - ''' - >>> from numpy_ext import * - >>> x = new_array() - >>> y = x.copy() - >>> p = _printer() - >>> check = p.check - >>> exercise_numarray(x, p) - - >>> check(str(y)) - - >>> check(y.argmax()); - >>> check(y.argmax(0)); - - >>> check(y.argmin()); - >>> check(y.argmin(0)); - - >>> check(y.argsort()); - >>> check(y.argsort(1)); - - >>> y.byteswap(); - >>> check(y); - - >>> check(y.diagonal()); - >>> check(y.diagonal(1)); - >>> check(y.diagonal(0, 0)); - >>> check(y.diagonal(0, 1, 0)); - - >>> check(y.is_c_array()); - - # coerce because numarray still returns an int and the C++ interface forces - # the return type to bool - >>> check( bool(y.isbyteswapped()) ); - - >>> check(y.trace()); - >>> check(y.trace(1)); - >>> check(y.trace(0, 0)); - >>> check(y.trace(0, 1, 0)); - - >>> check(y.new('D').getshape()); - >>> check(y.new('D').type()); - >>> y.sort(); - >>> check(y); - >>> check(y.type()); - - >>> check(y.factory((1.2, 3.4))); - >>> check(y.factory((1.2, 3.4), "f8")) - >>> check(y.factory((1.2, 3.4), "f8", true)) - >>> check(y.factory((1.2, 3.4), "f8", true, false)) - >>> check(y.factory((1.2, 3.4), "f8", true, false, None)) - >>> check(y.factory((1.2, 3.4), "f8", true, false, None, (1,2,1))) - - >>> p.results - [] - >>> del p - ''' - pass - false = 0; true = 1; -class _printer(object): - def __init__(self): - self.results = []; - def __call__(self, *stuff): - for x in stuff: - self.results.append(str(x)) - def check(self, x): - if self.results[0] != str(x): - print ' Expected:\n %s\n but the C++ interface gave:\n %s' % (x, self.results[0]) - del self.results[0] -def _count_failures(test_names = ('numeric_tests',)): - '''Given a sequence of test function names, run all the doctests associated - with each function and return the total number of failures. Works portably - across versions of doctest.''' - - import doctest - if hasattr(doctest, 'DocTestFinder'): - # Newer doctest fails to work with the old idiom, even though it's only - # marked "deprecated." - failures = 0 - for n in test_names: - for t in doctest.DocTestFinder().find(eval(n)): - print 'test:', t - failures += doctest.DocTestRunner().run(t)[0] - return failures - - else: - global __test__ - __test__ = {} - for t in test_names: - __test__[t] = eval(t) - return doctest.testmod(sys.modules.get(__name__))[0] - +import doctest, numeric_tests +def _count_failures(test_modules = (numeric_tests,)): + failures = 0 + for m in test_modules: + failures += doctest.testmod(m)[0] + return failures + def _run(args = None): - import sys + import sys, numarray_tests, numeric_tests if args is not None: sys.argv = args @@ -193,14 +62,13 @@ def _run(args = None): numpy_ext.set_module_and_type('Numeric', 'ArrayType') failures += _count_failures() - - global __test__ + if has_numarray: print 'testing numarray module explicitly' numpy_ext.set_module_and_type('numarray', 'NDArray') # Add the _numarray_tests to the list of things to test in # this case. - failures += _count_failures(('_numarray_tests', 'numeric_tests')) + failures += _count_failures((numarray_tests, numeric_tests)) # see that we can go back to the default numpy_ext.set_module_and_type('', '') diff --git a/test/printer.py b/test/printer.py new file mode 100644 index 00000000..e08f7c45 --- /dev/null +++ b/test/printer.py @@ -0,0 +1,13 @@ +# Copyright David Abrahams 2006. Distributed under 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) +class _printer(object): + def __init__(self): + self.results = []; + def __call__(self, *stuff): + for x in stuff: + self.results.append(str(x)) + def check(self, x): + if self.results[0] != str(x): + print ' Expected:\n %s\n but the C++ interface gave:\n %s' % (x, self.results[0]) + del self.results[0] From 9f4d39d9fe9ac3d2f958c67a70e470062760cad7 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Fri, 13 Oct 2006 22:06:17 +0000 Subject: [PATCH 063/268] correct trivial, obvious accident: stray line removed [SVN r35599] --- test/slice.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/test/slice.cpp b/test/slice.cpp index ebf2afa1..f28e38f5 100644 --- a/test/slice.cpp +++ b/test/slice.cpp @@ -1,4 +1,3 @@ -Warning: No xauth data; using fake authentication data for X11 forwarding. #include #include #include From a74c8e3da3a6b46a36cae9ac976a8ec8b845bb35 Mon Sep 17 00:00:00 2001 From: Stefan Seefeld Date: Fri, 27 Oct 2006 21:19:47 +0000 Subject: [PATCH 064/268] Fix symbol visibility. [SVN r35754] --- include/boost/python/exec.hpp | 2 ++ include/boost/python/import.hpp | 2 +- src/exec.cpp | 4 ++-- src/import.cpp | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/boost/python/exec.hpp b/include/boost/python/exec.hpp index fa4e324a..08d4459e 100644 --- a/include/boost/python/exec.hpp +++ b/include/boost/python/exec.hpp @@ -17,12 +17,14 @@ namespace python // global and local are the global and local scopes respectively, // used during execution. object +BOOST_PYTHON_DECL exec(str string, object global = object(), object local = object()); // Execute python source code from file filename. // global and local are the global and local scopes respectively, // used during execution. object +BOOST_PYTHON_DECL exec_file(str filename, object global = object(), object local = object()); } diff --git a/include/boost/python/import.hpp b/include/boost/python/import.hpp index 85d1afc0..45c02a93 100644 --- a/include/boost/python/import.hpp +++ b/include/boost/python/import.hpp @@ -14,7 +14,7 @@ namespace python { // Import the named module and return a reference to it. -object import(str name); +object BOOST_PYTHON_DECL import(str name); } } diff --git a/src/exec.cpp b/src/exec.cpp index 5d20bd82..5f2b8bc6 100644 --- a/src/exec.cpp +++ b/src/exec.cpp @@ -13,7 +13,7 @@ namespace boost namespace python { -object exec(str string, object global, object local) +object BOOST_PYTHON_DECL exec(str string, object global, object local) { // should be 'char const *' but older python versions don't use 'const' yet. char *s = python::extract(string); @@ -25,7 +25,7 @@ object exec(str string, object global, object local) // Execute python source code from file filename. // global and local are the global and local scopes respectively, // used during execution. -object exec_file(str filename, object global, object local) +object BOOST_PYTHON_DECL exec_file(str filename, object global, object local) { // should be 'char const *' but older python versions don't use 'const' yet. char *f = python::extract(filename); diff --git a/src/import.cpp b/src/import.cpp index b0df9b23..9686ab2f 100644 --- a/src/import.cpp +++ b/src/import.cpp @@ -13,7 +13,7 @@ namespace boost namespace python { -object import(str name) +object BOOST_PYTHON_DECL import(str name) { // should be 'char const *' but older python versions don't use 'const' yet. char *n = python::extract(name); From 6d2ee96ba3d522cc01eaaf9ae0c3ea00e703421b Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Fri, 3 Nov 2006 16:34:53 +0000 Subject: [PATCH 065/268] improve error message [SVN r35822] --- include/boost/python/make_constructor.hpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/include/boost/python/make_constructor.hpp b/include/boost/python/make_constructor.hpp index 598bf4f6..654a4f31 100755 --- a/include/boost/python/make_constructor.hpp +++ b/include/boost/python/make_constructor.hpp @@ -23,6 +23,7 @@ # include # include # include +# include namespace boost { namespace python { @@ -103,12 +104,14 @@ namespace detail // If the BasePolicy_ supplied a result converter it would be // ignored; issue an error if it's not the default. - BOOST_STATIC_ASSERT(( - is_same< + BOOST_MPL_ASSERT_MSG( + (is_same< typename BasePolicy_::result_converter , default_result_converter - >::value - )); + >::value) + , MAKE_CONSTRUCTOR_SUPPLIES_ITS_OWN_RESULT_CONVERTER_THAT_WOULD_OVERRIDE_YOURS + , (typename BasePolicy_::result_converter) + ); typedef constructor_result_converter result_converter; typedef offset_args > argument_package; From 2db61657f2b8341c8965aea1faca8387fa55c9c1 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Tue, 7 Nov 2006 19:11:57 +0000 Subject: [PATCH 066/268] Add copyright, license [SVN r35905] --- doc/tutorial/index.html | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/doc/tutorial/index.html b/doc/tutorial/index.html index c2a2aab5..82daf6df 100644 --- a/doc/tutorial/index.html +++ b/doc/tutorial/index.html @@ -8,6 +8,11 @@ Automatic redirection failed, click this - link + link  
    +

    © Copyright Beman Dawes, 2001

    +

    Distributed under the Boost Software License, Version 1.0. (See + accompanying file + LICENSE_1_0.txt or copy at + www.boost.org/LICENSE_1_0.txt)

    - + \ No newline at end of file From d67b0406834da38bb561dfd963c16b25d07a54ef Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Sun, 3 Dec 2006 20:43:48 +0000 Subject: [PATCH 067/268] fixes to support pickling of enums (by Shashank Bapat) [SVN r36256] --- src/object/enum.cpp | 10 +++++----- test/enum.py | 17 +++++++++++++++-- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/object/enum.cpp b/src/object/enum.cpp index a96cc819..1973270b 100644 --- a/src/object/enum.cpp +++ b/src/object/enum.cpp @@ -32,10 +32,11 @@ extern "C" { static PyObject* enum_repr(PyObject* self_) { + const char *mod = PyString_AsString(PyObject_GetAttrString( self_, "__module__")); enum_object* self = downcast(self_); if (!self->name) { - return PyString_FromFormat("%s(%ld)", self_->ob_type->tp_name, PyInt_AS_LONG(self_)); + return PyString_FromFormat("%s.%s(%ld)", mod, self_->ob_type->tp_name, PyInt_AS_LONG(self_)); } else { @@ -43,7 +44,7 @@ extern "C" if (name == 0) return 0; - return PyString_FromFormat("%s.%s", self_->ob_type->tp_name, name); + return PyString_FromFormat("%s.%s.%s", mod, self_->ob_type->tp_name, name); } } @@ -141,10 +142,9 @@ namespace object module_name = module_prefix(); if (module_name) - module_name += '.'; + d["__module__"] = module_name; - object result = (object(metatype))( - module_name + name, make_tuple(base), d); + object result = (object(metatype))(name, make_tuple(base), d); scope().attr(name) = result; diff --git a/test/enum.py b/test/enum.py index 27f09322..b78160ec 100644 --- a/test/enum.py +++ b/test/enum.py @@ -48,14 +48,27 @@ enum_ext.color.red enum_ext.color.green ''' +# pickling of enums only works with Python 2.3 or higher +exercise_pickling = ''' +>>> import pickle +>>> p = pickle.dumps(color.green, pickle.HIGHEST_PROTOCOL) +>>> l = pickle.loads(p) +>>> identity(l) +enum_ext.color.green +''' + def run(args = None): import sys import doctest + import pickle if args is not None: sys.argv = args - return doctest.testmod(sys.modules.get(__name__)) - + self = sys.modules.get(__name__) + if (hasattr(pickle, "HIGHEST_PROTOCOL")): + self.__doc__ += exercise_pickling + return doctest.testmod(self) + if __name__ == '__main__': print "running..." import sys From 8a4590b2efa0b7cd862e58c5d0638b3ac5041a2e Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Thu, 7 Dec 2006 17:44:05 +0000 Subject: [PATCH 068/268] Enable auto-linking [SVN r36291] --- include/boost/python/detail/config.hpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/boost/python/detail/config.hpp b/include/boost/python/detail/config.hpp index 3f2a19eb..9d3446bd 100644 --- a/include/boost/python/detail/config.hpp +++ b/include/boost/python/detail/config.hpp @@ -114,4 +114,24 @@ # define BOOST_PYTHON_OFFSETOF offsetof #endif +// enable automatic library variant selection ------------------------------// + +#if !defined(BOOST_PYTHON_SOURCE) && !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_PYTHON_NO_LIB) +// +// Set the name of our library, this will get undef'ed by auto_link.hpp +// once it's done with it: +// +#define BOOST_LIB_NAME boost_python +// +// If we're importing code from a dll, then tell auto_link.hpp about it: +// +#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_PYTHON_DYN_LINK) +# define BOOST_DYN_LINK +#endif +// +// And include the header that does the work: +// +#include +#endif // auto-linking disabled + #endif // CONFIG_DWA052200_H_ From 8fe9d41b5879bcbf430a187dcfb4f544d122cf1d Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Mon, 11 Dec 2006 02:50:55 +0000 Subject: [PATCH 069/268] Cleaned out flotsam and improved comments [SVN r36317] --- build/Jamfile.v2 | 42 ++++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/build/Jamfile.v2 b/build/Jamfile.v2 index 3987bb15..bf495a82 100644 --- a/build/Jamfile.v2 +++ b/build/Jamfile.v2 @@ -11,23 +11,8 @@ if [ python.configured ] { project boost/python - : source-location ../src - : requirements - #$(PYTHON_PATH)/include - # $(lib_condition)$(PYTHON_PATH)/libs - # shared:$(PYTHON_LIB) - # $(defines) - #: usage-requirements # requirement that will be propageted to *users* of this library - # $(PYTHON_PATH)/include - -# We have a bug which causes us to conclude that conditionalized -# properties in this section are not free. -# $(lib_condition)$(PYTHON_PATH)/lib/python2.2/config -# true:$(PYTHON_LIB) - - # $(PYTHON_PATH)/lib/python2.2/config - # $(PYTHON_LIB) - ; + : source-location ../src + ; lib boost_python : # sources @@ -63,16 +48,21 @@ lib boost_python : # requirements static:BOOST_PYTHON_STATIC_LIB BOOST_PYTHON_SOURCE - # On Linux, we don't link to Python library itself. If - # Boost.Python is used for extension, all Python - # symbols are available in Python interpreter. - # If Boost.Python is used for extending, client - # is required to link to /python//python itself. - # On Windows, all code using Python has to link - # to python import library. The 'python_for_extension' - # is the target that's setup to provide either just - # include paths, or import library. + + # On Windows, all code using Python has to link to the Python + # import library. + # + # On *nix we never link libboost_python to libpython. When + # extending Python, all Python symbols are provided by the + # Python interpreter executable. When embedding Python, the + # client executable is expected to explicitly link to + # /python//python (the target representing libpython) itself. + # + # python_for_extensions is a target defined by Boost.Build to + # provide the Python include paths, and on Windows, the Python + # import library, as usage requirements. /python//python_for_extensions + : # default build shared : # usage requirements From 0c4ebef57957eaba719f58b0fd239e18626d996f Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Mon, 11 Dec 2006 02:54:48 +0000 Subject: [PATCH 070/268] Fix auto-link to look at the right variable. Make boost-build.jam point at the v2 Boost. [SVN r36318] --- include/boost/python/detail/config.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/python/detail/config.hpp b/include/boost/python/detail/config.hpp index 9d3446bd..cfd762b9 100644 --- a/include/boost/python/detail/config.hpp +++ b/include/boost/python/detail/config.hpp @@ -125,7 +125,7 @@ // // If we're importing code from a dll, then tell auto_link.hpp about it: // -#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_PYTHON_DYN_LINK) +#ifdef BOOST_PYTHON_DYNAMIC_LIB # define BOOST_DYN_LINK #endif // From d8c3ff199eaca9603f912f75627ff2e43e004cdd Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Mon, 11 Dec 2006 03:35:10 +0000 Subject: [PATCH 071/268] Remove BBv1 for good [SVN r36321] --- example/Jamfile | 82 ----------------------------------------- example/Jamfile.v2 | 36 ------------------ example/Jamroot | 40 ++++++++++++++++++++ example/Jamrules | 36 ------------------ example/README | 19 +++------- example/boost-build.jam | 2 +- 6 files changed, 47 insertions(+), 168 deletions(-) delete mode 100644 example/Jamfile delete mode 100644 example/Jamfile.v2 create mode 100755 example/Jamroot delete mode 100755 example/Jamrules diff --git a/example/Jamfile b/example/Jamfile deleted file mode 100644 index 24303a6b..00000000 --- a/example/Jamfile +++ /dev/null @@ -1,82 +0,0 @@ -# Copyright David Abrahams 2003-2006. Distributed under 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) - -# This is the top of our own project tree -project-root ; - -# Declares the following targets: -# -# 1. an extension module called "getting_started1", which is -# built from "getting_started1.cpp". Built by default -# -# 2. A test target called my-test.test which runs -# test_getting_started1.py with the extension module above. Built -# when out-of date, but only if invoked by name or if the global -# "test" target is invoked. -# -# 3. A test target called my-test.run wihch runs the above test -# unconditionally. Built only when invoked by name. -# -# To see verbose test output, add "-sPYTHON_TEST_ARGS=-v" to the bjam -# command-line before the first target. -# - -# Include definitions needed for Python modules -import python ; - -# ----- getting_started1 ------- - -# Declare a Python extension called getting_started1 -extension getting_started1 -: # sources - getting_started1.cpp - - # requirements and dependencies for Boost.Python extensions -