From 219743964d79bbb0b6e9f52499f4f380884f8d72 Mon Sep 17 00:00:00 2001 From: nobody Date: Tue, 21 Mar 2006 02:26:31 +0000 Subject: [PATCH 01/94] This commit was manufactured by cvs2svn to create branch 'RC_1_34_0'. [SVN r33417] From 7b93f2fdc53f7e546f5bfbcc2efef96677cacce0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Sch=C3=B6pflin?= Date: Thu, 23 Mar 2006 09:40:38 +0000 Subject: [PATCH 02/94] Merged fix from HEAD for Tru64/CXX compilation error. [SVN r33455] --- 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 5cc33461dda6e2a75aa8bd2fa30ed6f66f8fa16e Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Mon, 10 Apr 2006 09:02:57 +0000 Subject: [PATCH 03/94] Merge from trunk [SVN r33626] --- 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 fa2185e5ab5d3b72717e6cbce47f999742568e21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Sch=C3=B6pflin?= Date: Tue, 6 Jun 2006 09:39:16 +0000 Subject: [PATCH 04/94] Merged header inclusion order fix from trunk to release branch. [SVN r34194] --- test/callbacks.cpp | 2 +- test/list.cpp | 3 +-- 2 files changed, 2 insertions(+), 3 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; From 7a645a6d8af8710167a12709e93323d80bd70dbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Sch=C3=B6pflin?= Date: Tue, 6 Jun 2006 09:44:35 +0000 Subject: [PATCH 05/94] Merged header inclusion order fix from trunk to release branch. [SVN r34195] --- test/staticmethod.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 e500919d257330c212327aad7a2cf6cdd5b318fb Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Sat, 22 Jul 2006 07:16:18 +0000 Subject: [PATCH 06/94] Merge: Don't link Boost.Python to python library [SVN r34663] --- 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 f852ce6f7bd2f52a0309c01dc5dc191cfc5c050a Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Sat, 22 Jul 2006 12:28:43 +0000 Subject: [PATCH 07/94] Windows [SVN r34667] --- 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 489dae2b58e7592605232e83e620c88c1d2ef9ca Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Sat, 22 Jul 2006 12:53:49 +0000 Subject: [PATCH 08/94] 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 c54acdb9db325050bd42cd4475d2f226da9dd5e2 Mon Sep 17 00:00:00 2001 From: Gennaro Prota Date: Mon, 24 Jul 2006 22:06:09 +0000 Subject: [PATCH 09/94] (merge from head) minor fix: violation of min/max guidelines [SVN r34718] --- 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 ecf70b05f2c9756cd7731ad195051d3e3a6c0f4a Mon Sep 17 00:00:00 2001 From: Gennaro Prota Date: Mon, 24 Jul 2006 22:21:39 +0000 Subject: [PATCH 10/94] (merge from head) removed tabs (inspect tool) [SVN r34721] --- src/converter/type_id.cpp | 14 +++++++------- src/exec.cpp | 6 +++--- 2 files changed, 10 insertions(+), 10 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 { 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 8fb6e1f48d37f56f7e76f0aa152176f5c9297baa Mon Sep 17 00:00:00 2001 From: Gennaro Prota Date: Mon, 24 Jul 2006 22:28:41 +0000 Subject: [PATCH 11/94] (merge from head) removed tabs (inspect tool) [SVN r34723] --- 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 45e4cf506f4d3bcc62b235d08b0f174f9ef028b5 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Fri, 11 Aug 2006 00:48:19 +0000 Subject: [PATCH 12/94] merged from trunk [SVN r34865] --- test/args.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/args.cpp b/test/args.cpp index f6f16415..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); @@ -85,6 +89,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<>()); From 786aeef998b79baea2cd85dad1f85da5d3560816 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Fri, 11 Aug 2006 15:51:09 +0000 Subject: [PATCH 13/94] merged from trunk [SVN r34872] --- 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 8b178594ff8afe6be1a81be98285787c0dd4dbb8 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Tue, 22 Aug 2006 11:51:18 +0000 Subject: [PATCH 14/94] merged from trunk [SVN r34915] --- 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 a99bd50e525661becf3ee77e83a39f46aa6d580b Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Thu, 24 Aug 2006 13:05:30 +0000 Subject: [PATCH 15/94] merged from trunk [SVN r34940] --- 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 3c1ae689a72e4471aeb0f28f7e6bc2e79bfa2b18 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Thu, 24 Aug 2006 19:04:23 +0000 Subject: [PATCH 16/94] merged from trunk [SVN r34943] --- 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 1d65b742733b8c1da811262d4153834282569290 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Mon, 11 Sep 2006 22:27:29 +0000 Subject: [PATCH 17/94] Add missing license/copyright [SVN r35070] --- 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 26eaff1e..93129beb 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 fa5c1096..c79507d1 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 81bf8263..e5c93736 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 fe93c26b..59cb86e3 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 50a11036..8d23f3ac 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 4f57d5b4..06d34e4d 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 18/94] 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 924eeccd532a2182b7e33126eaad046a76016fc9 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Wed, 13 Sep 2006 00:02:56 +0000 Subject: [PATCH 19/94] merged from trunk [SVN r35080] --- test/numpy.cpp | 81 ++++++++++++++++++++++++++++++------------------ test/pickle3.cpp | 4 +++ 2 files changed, 55 insertions(+), 30 deletions(-) diff --git a/test/numpy.cpp b/test/numpy.cpp index 4c7f0a12..deb9667b 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() { @@ -35,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 @@ -52,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) 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. From 326c871224a7a992a85b0d33a539a3bbbe9f502d Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Wed, 13 Sep 2006 22:47:11 +0000 Subject: [PATCH 20/94] 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 38f7a4e9b63fad1072a09470ebeac4ef4873c6da Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 17 Sep 2006 02:42:51 +0000 Subject: [PATCH 21/94] merge from HEAD [SVN r35141] --- test/slice.cpp | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/test/slice.cpp b/test/slice.cpp index 6532fd60..7a1ab020 100644 --- a/test/slice.cpp +++ b/test/slice.cpp @@ -1,5 +1,6 @@ #include #include +#include #include // Copyright (c) 2004 Jonathan Brandmeyer @@ -9,6 +10,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() @@ -39,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), @@ -60,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 029618f7199af0062b8001134dc3fa53deaeead5 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Mon, 18 Sep 2006 18:25:57 +0000 Subject: [PATCH 22/94] merged from HEAD [SVN r35165] --- 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 23057688f96f8a50fd108e4762c4b0fb650e87ce Mon Sep 17 00:00:00 2001 From: nobody Date: Mon, 18 Sep 2006 19:56:20 +0000 Subject: [PATCH 23/94] This commit was manufactured by cvs2svn to create branch 'RC_1_34_0'. [SVN r35170] --- test/crossmod_opaque.py | 16 ++++++++++++++++ test/crossmod_opaque_a.cpp | 26 ++++++++++++++++++++++++++ test/crossmod_opaque_b.cpp | 26 ++++++++++++++++++++++++++ 3 files changed, 68 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..2c8075bc --- /dev/null +++ b/test/crossmod_opaque.py @@ -0,0 +1,16 @@ +# -*- 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 +# http://www.boost.org/LICENSE_1_0.txt) + +if __name__ == '__main__': + 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 95f0b39c90e837f74c0c23db28e6e53351a71985 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Mon, 18 Sep 2006 22:22:31 +0000 Subject: [PATCH 24/94] merged from HEAD [SVN r35185] --- 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 7ff0f627292d11153fdfa9380d70134e0acb4468 Mon Sep 17 00:00:00 2001 From: Stefan Seefeld Date: Wed, 20 Sep 2006 22:30:39 +0000 Subject: [PATCH 25/94] 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 e70bbe4791d53f009f88fbf3025a77f78649b42d Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Wed, 20 Sep 2006 22:49:18 +0000 Subject: [PATCH 26/94] Fix license/copyright. Also port some "glaringly obvious" bugfixes from HEAD. Hope it doesn't cause problems. [SVN r35237] --- 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 ++ include/boost/python/detail/wrap_python.hpp | 2 +- include/boost/python/object/pointer_holder.hpp | 2 +- .../boost/python/opaque_pointer_converter.hpp | 16 ++++++++++++---- .../python/suite/indexing/indexing_suite.hpp | 2 +- include/boost/python/type_id.hpp | 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 | 5 +++++ 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 | 8 ++++++++ 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 | 14 +++++++++----- test/pointer_vector.cpp | 3 +++ 58 files changed, 202 insertions(+), 95 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/include/boost/python/detail/wrap_python.hpp b/include/boost/python/detail/wrap_python.hpp index cce01868..88597b58 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/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/opaque_pointer_converter.hpp b/include/boost/python/opaque_pointer_converter.hpp index e54561c7..7d2e0795 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; 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. 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 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..186a31cb 100644 --- a/pyste/doc/pyste.txt +++ b/pyste/doc/pyste.txt @@ -1,5 +1,10 @@ [doc Pyste Documentation] +[/ 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/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..643df02a 100644 --- a/pyste/doc/theme/style.css +++ b/pyste/doc/theme/style.css @@ -1,3 +1,11 @@ +/*============================================================================= + Copyright (c) 2003 Bruno da Silva de Oliveira + + 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 87abb096..56193772 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 7dd3ffe0..c0498c26 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 6d994bd7..d10ac784 100644 --- a/test/opaque.py +++ b/test/opaque.py @@ -1,9 +1,8 @@ # -*- coding: iso-latin-1 -*- -# Copyright Gottfried Ganßauge 2003. 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 * @@ -66,6 +65,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 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 7ba6a00617d8ed4ffbc5d26a7659cf545a1bdc9d Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Thu, 21 Sep 2006 03:43:59 +0000 Subject: [PATCH 27/94] 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 0d57e9e808c4aa24b00cbc7d1130202a7677339c Mon Sep 17 00:00:00 2001 From: nobody Date: Thu, 21 Sep 2006 07:07:15 +0000 Subject: [PATCH 28/94] This commit was manufactured by cvs2svn to create branch 'RC_1_34_0'. [SVN r35243] --- 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 815969bf8b3e8cd12bdfc6ead9b5f38eebf5a137 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Thu, 21 Sep 2006 07:27:11 +0000 Subject: [PATCH 29/94] Merge: Add tests [SVN r35245] --- 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 b5c893381f0e9d7f481bd5c4fed9f24b9615e40f Mon Sep 17 00:00:00 2001 From: Joel de Guzman Date: Thu, 21 Sep 2006 10:52:01 +0000 Subject: [PATCH 30/94] merge from head [SVN r35246] --- doc/tutorial/doc/html/boostbook.css | 203 +++++++++++++------ 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 ++-- 8 files changed, 255 insertions(+), 200 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 { diff --git a/doc/tutorial/doc/html/index.html b/doc/tutorial/doc/html/index.html index 629e07f8..ffe9a7c1 100644 --- a/doc/tutorial/doc/html/index.html +++ b/doc/tutorial/doc/html/index.html @@ -34,7 +34,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 ) @@ -97,7 +97,7 @@ (IDL).

- + Hello World

@@ -142,7 +142,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 93129beb..79971d82 100644 --- a/doc/tutorial/doc/html/python/embedding.html +++ b/doc/tutorial/doc/html/python/embedding.html @@ -43,7 +43,7 @@ Python/C API at all. So stay tuned... smiley

- + Building embedded programs

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

- + Getting started

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

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

    + #include <boost/python.hpp>

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

    - + Reference-counting handles and objects

    @@ -168,20 +166,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

    @@ -204,7 +199,7 @@ exe embedded_program # name of the executable

    - + Start symbols

    @@ -277,18 +272,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

    @@ -334,17 +327,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 c79507d1..42f188f3 100644 --- a/doc/tutorial/doc/html/python/exposing.html +++ b/doc/tutorial/doc/html/python/exposing.html @@ -382,13 +382,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. @@ -406,14 +403,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 +

@@ -467,12 +460,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:

@@ -519,7 +511,7 @@

Class Operators/Special Functions

- + Python Operators

@@ -568,7 +560,7 @@ expressions".

- + Special Methods

@@ -596,11 +588,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 e5c93736..3a9b53b3 100644 --- a/doc/tutorial/doc/html/python/functions.html +++ b/doc/tutorial/doc/html/python/functions.html @@ -209,7 +209,7 @@ Namespaces are one honking great idea -- let's do more of those!
  • BOOM!
  • - + Call Policies

    @@ -290,13 +290,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"
    +

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

    - + BOOST_PYTHON_FUNCTION_OVERLOADS

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

    - + BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS

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

    - + init and optional

    @@ -550,14 +548,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 59cb86e3..efdba8c2 100644 --- a/doc/tutorial/doc/html/python/hello.html +++ b/doc/tutorial/doc/html/python/hello.html @@ -29,7 +29,7 @@

    Building Hello World

    - + From Start To Finish

    @@ -38,17 +38,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 @@ -102,7 +101,7 @@ platforms. The complete list of Bjam executables can be found here.

    - + Let's Jam!

    @@ -153,7 +152,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

    @@ -181,11 +180,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 8d23f3ac..583a4779 100644 --- a/doc/tutorial/doc/html/python/object.html +++ b/doc/tutorial/doc/html/python/object.html @@ -179,12 +179,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:

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

    - + class_<T> as objects

    @@ -298,14 +297,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 06d34e4d..a60b7278 100644 --- a/doc/tutorial/doc/html/python/techniques.html +++ b/doc/tutorial/doc/html/python/techniques.html @@ -99,13 +99,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:

    @@ -428,19 +427,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. +

    From ef62f879630097f03921ae092c777f278383dad5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gottfried=20Gan=C3=9Fauge?= Date: Thu, 21 Sep 2006 16:46:21 +0000 Subject: [PATCH 31/94] type object gets initialized. Cross module support works [SVN r35252] --- include/boost/python/opaque_pointer_converter.hpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/boost/python/opaque_pointer_converter.hpp b/include/boost/python/opaque_pointer_converter.hpp index 7d2e0795..51bd1ccc 100644 --- a/include/boost/python/opaque_pointer_converter.hpp +++ b/include/boost/python/opaque_pointer_converter.hpp @@ -86,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 From 5acb44ede06bfe64944bbecf8bdc41a4e6c62d89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gottfried=20Gan=C3=9Fauge?= Date: Thu, 21 Sep 2006 16:46:42 +0000 Subject: [PATCH 32/94] Renamed from opaque_pointer_converter.html because class name changed [SVN r35253] --- doc/v2/opaque.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/v2/opaque.html b/doc/v2/opaque.html index 5f55d5c8..9ffcccdd 100644 --- a/doc/v2/opaque.html +++ b/doc/v2/opaque.html @@ -1,5 +1,9 @@ + + + + From decc34551aa617984344a2088b640c3bfb64b54c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gottfried=20Gan=C3=9Fauge?= Date: Thu, 21 Sep 2006 16:47:00 +0000 Subject: [PATCH 33/94] Renamed to opaque.html because class name changed [SVN r35254] --- doc/v2/opaque_pointer_converter.html | 145 --------------------------- 1 file changed, 145 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.

    - - - From 7ad9dc6c641abfd506bb4ec5b683c3196f05be89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gottfried=20Gan=C3=9Fauge?= Date: Thu, 21 Sep 2006 16:47:31 +0000 Subject: [PATCH 34/94] Changed references to opaque_pointer_converter.html to point to opaque.html instead [SVN r35255] --- doc/v2/return_opaque_pointer.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 From b8b7768eb7f9f71693c114471a1b0f7714c0f514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gottfried=20Gan=C3=9Fauge?= Date: Thu, 21 Sep 2006 16:47:49 +0000 Subject: [PATCH 35/94] Test for cross module support of opaque [SVN r35256] --- test/Jamfile | 4 ++++ test/Jamfile.v2 | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/test/Jamfile b/test/Jamfile index 56193772..9203332b 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -173,6 +173,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 c0498c26..78ac8d8d 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -119,6 +119,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 ] From 36abcee84794fdea9a9d8920dbbc0d3354455e5f Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Fri, 22 Sep 2006 15:13:30 +0000 Subject: [PATCH 36/94] merged from HEAD [SVN r35277] --- 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 51bd1ccc..83c76433 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 1bc3750ab3c4ade3b7bf8acd4d3dc0d36ec0d86f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gottfried=20Gan=C3=9Fauge?= Date: Mon, 25 Sep 2006 07:35:57 +0000 Subject: [PATCH 37/94] repaired broken links [SVN r35315] --- doc/v2/reference.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/v2/reference.html b/doc/v2/reference.html index 5fe7b5d5..5c3a9366 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_pointer_converter
    -
    Macros
    +
    Macros
    + "opaque.html#BOOST_PYTHON_OPAQUE_SPECIALIZED_TYPE_ID-spec"> BOOST_PYTHON_OPAQUE_SPECIALIZED_TYPE_ID
    From a824230155c19d8f8ba7e7546121f1c8d5c6bc76 Mon Sep 17 00:00:00 2001 From: nobody Date: Tue, 26 Sep 2006 00:25:08 +0000 Subject: [PATCH 38/94] This commit was manufactured by cvs2svn to create branch 'RC_1_34_0'. [SVN r35326] --- doc/v2/ssize_t.html | 96 ++++++++++++++++++++++++++++++++ include/boost/python/ssize_t.hpp | 29 ++++++++++ 2 files changed, 125 insertions(+) create mode 100644 doc/v2/ssize_t.html create mode 100644 include/boost/python/ssize_t.hpp 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/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 From 4eb286a0347afb14067ec16242c536071bd1e108 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Tue, 26 Sep 2006 00:48:44 +0000 Subject: [PATCH 39/94] ssize_t patches merged from HEAD [SVN r35327] --- doc/v2/reference.html | 10 +++++++++ .../python/converter/builtin_converters.hpp | 5 +++-- include/boost/python/list.hpp | 9 ++++---- include/boost/python/object.hpp | 6 ++--- src/list.cpp | 5 +++-- src/object/class.cpp | 6 +++-- src/object/function.cpp | 9 +++++--- src/object_protocol.cpp | 5 +++-- src/str.cpp | 22 +++++++++++++++++-- 9 files changed, 57 insertions(+), 20 deletions(-) diff --git a/doc/v2/reference.html b/doc/v2/reference.html index 5c3a9366..61dca9c6 100644 --- a/doc/v2/reference.html +++ b/doc/v2/reference.html @@ -1094,6 +1094,16 @@
    + +
    ssize_t.hpp
    + +
    +
    +
    Typedefs
    + +
    Constants
    +
    +

    Topics

    diff --git a/include/boost/python/converter/builtin_converters.hpp b/include/boost/python/converter/builtin_converters.hpp index 3ae45c37..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/list.hpp b/include/boost/python/list.hpp index 793cd08a..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(int 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(long 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(int 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(long 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 677ffb42..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 long len(object const& obj) + inline ssize_t len(object const& obj) { - long result = PyObject_Length(obj.ptr()); + 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..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(int 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(long 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 efc492c6..58234bbb 100644 --- a/src/object/class.cpp +++ b/src/object/class.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -506,13 +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)); - handle<> bases(PyTuple_New(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(), 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..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; - unsigned 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,7 +159,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 <= 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 +296,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 (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..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)) { - int ilow = 0, ihigh = INT_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)) { - int ilow = 0, ihigh = INT_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 c452a285..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 { @@ -21,10 +22,25 @@ str_base::str_base(const char* s) : object(detail::new_reference(::PyString_FromString(s))) {} +namespace { + + ssize_t str_size_as_py_ssize_t(std::size_t n) + { + if (n > ssize_t_max) + { + throw std::range_error("str size > 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 +48,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 375cc3aa9363f3ca8c55de3f9472b8a6a5ed6bff Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Tue, 26 Sep 2006 04:25:49 +0000 Subject: [PATCH 40/94] Fix broken links [SVN r35330] --- 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 72b06e70ee4cb66f817883dbcac68ac65afeb9dd Mon Sep 17 00:00:00 2001 From: nobody Date: Thu, 28 Sep 2006 14:41:02 +0000 Subject: [PATCH 41/94] This commit was manufactured by cvs2svn to create branch 'RC_1_34_0'. [SVN r35366] --- test/operators_wrapper.cpp | 42 ++++++++++++++++++++++++++++++++++++++ test/operators_wrapper.py | 11 ++++++++++ 2 files changed, 53 insertions(+) create mode 100644 test/operators_wrapper.cpp create mode 100644 test/operators_wrapper.py 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 d42054f3a03c644cac1f97650b7d0f11696d5c3e Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Fri, 29 Sep 2006 02:08:32 +0000 Subject: [PATCH 42/94] Cleans up license/copyright warnings [SVN r35409] --- test/crossmod_exception.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 d5219979a4cf4356d59b7f1b34ae4d548d5633c0 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Fri, 29 Sep 2006 02:09:13 +0000 Subject: [PATCH 43/94] Fix bugs uncovered by Roman Yakovenko [SVN r35410] --- include/boost/python/converter/implicit.hpp | 6 +++++- include/boost/python/operators.hpp | 19 ++++++++++++++----- 2 files changed, 19 insertions(+), 6 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/include/boost/python/operators.hpp b/include/boost/python/operators.hpp index d10a0094..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)); \ } \ @@ -339,6 +346,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 +358,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 From 315c3d50ee5b42a0e791f1324625bb1aca1ba78d Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Fri, 29 Sep 2006 15:45:29 +0000 Subject: [PATCH 44/94] Apply missing elements of previously-"applied" bug fix. [SVN r35421] --- .../boost/python/detail/unwrap_wrapper.hpp | 32 ++++++------------- include/boost/python/operators.hpp | 3 +- 2 files changed, 10 insertions(+), 25 deletions(-) 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 3851b494..41f24d28 100644 --- a/include/boost/python/operators.hpp +++ b/include/boost/python/operators.hpp @@ -18,6 +18,7 @@ # include # include # include +# include # include # include @@ -346,7 +347,6 @@ 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 @@ -358,7 +358,6 @@ 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 From 8553c109c7e44529c5b437513966fd864770b3b0 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Fri, 29 Sep 2006 22:27:57 +0000 Subject: [PATCH 45/94] merged from HEAD [SVN r35429] --- 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 545be29ad3cedc30bdd53b3377df0b6e98d16101 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 1 Oct 2006 18:25:44 +0000 Subject: [PATCH 46/94] (hopefully) grab the last bit of logic from HEAD for a bugfix I've been trying to apply to the branch for days(!) [SVN r35436] --- include/boost/python/wrapper.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 { From 49d4aac8ec00a0eee4232402a97c1da5cf5560e8 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Mon, 9 Oct 2006 04:05:25 +0000 Subject: [PATCH 47/94] 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 24ba93607b16cf7c98fc7782a0ea5eff3e2d9805 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Tue, 10 Oct 2006 18:12:43 +0000 Subject: [PATCH 48/94] Try for backward compatibility with older versions of doctest [SVN r35535] --- test/numpy.py | 47 +++++++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/test/numpy.py b/test/numpy.py index f4fbcdf3..0e84e19b 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 3b392c99be71eb4febfc758633da2d42c3f9f2b3 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Tue, 10 Oct 2006 22:44:09 +0000 Subject: [PATCH 49/94] 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 1755dad7e6c5bf7fe1c449a0e6afc31db67e9f5c Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Thu, 12 Oct 2006 06:42:20 +0000 Subject: [PATCH 50/94] merged from trunk [SVN r35569] --- 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 d61909d3ea2679c31e73eef440f54a070cf3bb4d Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Thu, 12 Oct 2006 09:07:07 +0000 Subject: [PATCH 51/94] 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 ++++++++++++++++++ 3 files changed, 32 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) \ { \ From c3bda6a903020172db2a7b1f15fcc93edc0c37ab Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Fri, 13 Oct 2006 19:35:28 +0000 Subject: [PATCH 52/94] 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 0e84e19b..80afe744 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 2bd9141d4a080c5cf8490faca18579915ffe6117 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Fri, 13 Oct 2006 21:34:26 +0000 Subject: [PATCH 53/94] make numpy tests portable to Darwin with older docutils [SVN r35597] --- test/Jamfile.v2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 78ac8d8d..34b31870 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 ] From da8e309957c37c23a92406e7cb47a213e2d18629 Mon Sep 17 00:00:00 2001 From: nobody Date: Fri, 13 Oct 2006 21:34:27 +0000 Subject: [PATCH 54/94] This commit was manufactured by cvs2svn to create branch 'RC_1_34_0'. [SVN r35598] --- test/numarray_tests.py | 63 ++++++++++++++++++++++++++++++++++++++++++ test/numeric_tests.py | 39 ++++++++++++++++++++++++++ test/printer.py | 13 +++++++++ 3 files changed, 115 insertions(+) create mode 100644 test/numarray_tests.py create mode 100644 test/numeric_tests.py create mode 100644 test/printer.py 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/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 3a53c1dec0290d932a03a6b7bad63747749062cb Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sat, 14 Oct 2006 19:10:30 +0000 Subject: [PATCH 55/94] Add fixes somehow missed for darwin [SVN r35612] --- test/numpy.py | 150 +++----------------------------------------------- 1 file changed, 9 insertions(+), 141 deletions(-) diff --git a/test/numpy.py b/test/numpy.py index 80afe744..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 @@ -194,13 +63,12 @@ def _run(args = None): 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('', '') From ca91dc828ed7d9c1ad0a7c060030799695200eb9 Mon Sep 17 00:00:00 2001 From: Stefan Seefeld Date: Fri, 27 Oct 2006 21:19:47 +0000 Subject: [PATCH 56/94] 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..903b29d4 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 10b85d67e760bf372d62716b1f71ecbdde47da64 Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Mon, 6 Nov 2006 17:10:46 +0000 Subject: [PATCH 57/94] Remove obsolete Boost.Build v1 files. [SVN r35880] --- build/Jamfile | 98 ---------------- example/Jamfile | 82 ------------- example/tutorial/Jamfile | 18 --- test/Jamfile | 240 --------------------------------------- 4 files changed, 438 deletions(-) delete mode 100644 build/Jamfile delete mode 100644 example/Jamfile delete mode 100644 example/tutorial/Jamfile delete mode 100644 test/Jamfile diff --git a/build/Jamfile b/build/Jamfile deleted file mode 100644 index 92f715c2..00000000 --- a/build/Jamfile +++ /dev/null @@ -1,98 +0,0 @@ -# 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 - - -# declare the location of this subproject relative to the root -subproject libs/python/build ; - -# bring in the rules for python -import python ; - -if [ check-python-config ] -{ - - local bpl-linkflags ; - - if $(UNIX) && ( $(OS) = AIX ) - { - bpl-linkflags = "-e initlibboost_python" ; - } - - # Enabling intrinsics (/0i) or maximize speed (/02) seem to cause - # internal compiler errors with this toolset. - local msvc-stlport-workarounds - = off "-Ogty -O1 -Gs" ; - - local sources = - numeric.cpp - list.cpp - long.cpp - dict.cpp - tuple.cpp - str.cpp - slice.cpp - - aix_init_module.cpp - converter/from_python.cpp - converter/registry.cpp - converter/type_id.cpp - object/enum.cpp - object/class.cpp - object/function.cpp - object/inheritance.cpp - object/life_support.cpp - object/pickle_support.cpp - errors.cpp - module.cpp - converter/builtin_converters.cpp - converter/arg_to_python_base.cpp - object/iterator.cpp - object/stl_iterator.cpp - object_protocol.cpp - object_operators.cpp - wrapper.cpp - exec.cpp - import.cpp - ; - - dll boost_python - : ../src/$(sources) - : $(BOOST_PYTHON_V2_PROPERTIES) - BOOST_PYTHON_SOURCE - $(bpl-linkflags) - $(msvc-stlport-workarounds) - <*>-bind_at_load - <*>-bind_at_load - ; - - template extension - : boost_python - : ../../.. - ; - - lib boost_python - : # sources - ../src/$(sources) - - : # requirements - $(BOOST_PYTHON_V2_PROPERTIES) - BOOST_PYTHON_SOURCE - BOOST_STATIC_LIB - $(bpl-linkflags) - $(msvc-stlport-workarounds) - ; - - stage bin-stage : boost_python boost_python - : "_debug" - "_pydebug" - : - debug release - ; - - install python lib - : boost_python boost_python - ; -} 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 -