From f3d9193743d8635a46b53c7d36a3c77d8c61c83c Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Thu, 8 Feb 2001 01:54:59 +0000 Subject: [PATCH 01/23] Fix for linux gcc-2.95.2 [SVN r9023] --- example/getting_started5.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/example/getting_started5.cpp b/example/getting_started5.cpp index bbe4725a..4b64e4b8 100644 --- a/example/getting_started5.cpp +++ b/example/getting_started5.cpp @@ -70,7 +70,8 @@ BOOST_PYTHON_BEGIN_CONVERSION_NAMESPACE // MillerIndex from_python(PyObject* p, python::type) { - python::tuple tup = python::tuple(python::ref(p, ref::increment_count)); + python::tuple tup + = python::tuple(python::ref(p, python::ref::increment_count)); if (tup.size() != 3) { PyErr_SetString(PyExc_ValueError, "expecting exactly 3 values in tuple."); From b000c759477dc3cdaaa6ced47accf92e890fc7f3 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Fri, 23 Feb 2001 08:58:32 +0000 Subject: [PATCH 02/23] Fix for python::tuple.set_item() memory leak. [SVN r9316] --- example/getting_started5.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/getting_started5.cpp b/example/getting_started5.cpp index 4b64e4b8..c9f1ce36 100644 --- a/example/getting_started5.cpp +++ b/example/getting_started5.cpp @@ -97,7 +97,7 @@ BOOST_PYTHON_BEGIN_CONVERSION_NAMESPACE { python::tuple result(3); for (int i = 0; i < 3; i++) - result.set_item(i, to_python(hkl.v[i])); + result.set_item(i, python::ref(to_python(hkl.v[i]))); return result.reference().release(); } From 977841a7f383115244b27fdf58a4af6429852ff8 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Fri, 2 Mar 2001 01:48:30 +0000 Subject: [PATCH 03/23] Use PyObject_INIT() instead of hand-initializing objects [SVN r9375] --- include/boost/python/detail/base_object.hpp | 6 ++-- include/boost/python/detail/wrap_python.hpp | 7 +++++ src/extension_class.cpp | 7 +++-- src/functions.cpp | 31 ++++++++++++--------- 4 files changed, 34 insertions(+), 17 deletions(-) diff --git a/include/boost/python/detail/base_object.hpp b/include/boost/python/detail/base_object.hpp index f8ed665b..bf0faa7b 100644 --- a/include/boost/python/detail/base_object.hpp +++ b/include/boost/python/detail/base_object.hpp @@ -5,6 +5,9 @@ // // The author gratefully acknowleges the support of Dragon Systems, Inc., in // producing this work. +// +// Revision History: +// Mar 01 01 Use PyObject_INIT() instead of trying to hand-initialize (David Abrahams) #ifndef BASE_OBJECT_DWA051600_H_ # define BASE_OBJECT_DWA051600_H_ @@ -46,9 +49,8 @@ base_object::base_object(PyTypeObject* type_obj) std:: #endif memset(bp, 0, sizeof(base_python_type)); - ob_refcnt = 1; - ob_type = type_obj; Py_INCREF(type_obj); + PyObject_INIT(bp, type_obj); } template diff --git a/include/boost/python/detail/wrap_python.hpp b/include/boost/python/detail/wrap_python.hpp index eb831b68..9e57c287 100644 --- a/include/boost/python/detail/wrap_python.hpp +++ b/include/boost/python/detail/wrap_python.hpp @@ -15,6 +15,9 @@ // To use the Python debugging library, #define BOOST_DEBUG_PYTHON on the // compiler command-line. +// Revision History: +// 01 Mar 01 define PyObject_INIT() for Python 1.x + #ifdef _DEBUG # ifndef BOOST_DEBUG_PYTHON # undef _DEBUG // Don't let Python force the debug library just because we're debugging. @@ -76,3 +79,7 @@ typedef int pid_t; # define _DEBUG #endif +#if !defined(PY_MAJOR_VERSION) || PY_MAJOR_VERSION < 2 +# define PyObject_INIT(op, typeobj) \ + ( (op)->ob_type = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) +#endif diff --git a/src/extension_class.cpp b/src/extension_class.cpp index c15e538b..47862ec7 100644 --- a/src/extension_class.cpp +++ b/src/extension_class.cpp @@ -5,6 +5,9 @@ // // The author gratefully acknowleges the support of Dragon Systems, Inc., in // producing this work. +// +// Revision History: +// Mar 01 01 Use PyObject_INIT() instead of trying to hand-initialize (David Abrahams) #include #include @@ -446,8 +449,8 @@ operator_dispatcher::operator_dispatcher(const ref& o, const ref& s) : m_object(o), m_self(s), m_free_list_link(0) { - ob_refcnt = 1; - ob_type = &type_obj; + PyObject* self = this; + PyObject_INIT(self, &type_obj); } operator_dispatcher* diff --git a/src/functions.cpp b/src/functions.cpp index e166c91c..71b59136 100644 --- a/src/functions.cpp +++ b/src/functions.cpp @@ -5,6 +5,9 @@ // // The author gratefully acknowleges the support of Dragon Systems, Inc., in // producing this work. +// +// Revision History: +// Mar 01 01 Use PyObject_INIT() instead of trying to hand-initialize (David Abrahams) #include #include @@ -97,19 +100,6 @@ PyObject* function::call(PyObject* args, PyObject* keywords) const return 0; } -bound_function* bound_function::create(const ref& target, const ref& fn) -{ - bound_function* const result = free_list; - if (result == 0) - return new bound_function(target, fn); - - free_list = result->m_free_list_link; - result->m_target = target; - result->m_unbound_function = fn; - Py_INCREF(result); - return result; -} - // The instance class whose obj represents the type of bound_function // objects in Python. bound_functions must be GetAttrable so the __doc__ // attribute of built-in Python functions can be accessed when bound. @@ -123,6 +113,21 @@ private: // type_object hook override void dealloc(bound_function*) const; }; +bound_function* bound_function::create(const ref& target, const ref& fn) +{ + bound_function* const result = free_list; + if (result == 0) + return new bound_function(target, fn); + + free_list = result->m_free_list_link; + result->m_target = target; + result->m_unbound_function = fn; + + PyObject* self = result; + PyObject_INIT(self, type_object::instance()); + return result; +} + bound_function::bound_function(const ref& target, const ref& fn) : python_object(type_object::instance()), m_target(target), From f5fa4a460a27afdfb53b5054c6a9550c009b1817 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Sat, 3 Mar 2001 10:22:35 +0000 Subject: [PATCH 04/23] Wrong file name replaced (instance.hpp -> singleton.hpp). [SVN r9390] --- src/gen_all.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gen_all.py b/src/gen_all.py index 416c66f1..3877d181 100644 --- a/src/gen_all.py +++ b/src/gen_all.py @@ -10,7 +10,7 @@ def gen_all(args): open('caller.hpp', 'w').write(gen_caller(args)) open('init_function.hpp', 'w').write(gen_init_function(args)) open('signatures.hpp', 'w').write(gen_signatures(args)) - open('instance.hpp', 'w').write(gen_singleton(args)) + open('singleton.hpp', 'w').write(gen_singleton(args)) open('extension_class.hpp', 'w').write(gen_extclass(args)) if __name__ == '__main__': From 51d60a603590d559647283bbf3d9c33ebf866002 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Sat, 3 Mar 2001 11:48:52 +0000 Subject: [PATCH 05/23] added: converters for [plain] char and std::complex [SVN r9397] --- include/boost/python/conversions.hpp | 39 ++++++++++++++++++++++++++++ src/conversions.cpp | 21 +++++++++++++++ test/comprehensive.cpp | 34 ++++++++++++++++++++++++ test/comprehensive.py | 33 +++++++++++++++++++++++ 4 files changed, 127 insertions(+) diff --git a/include/boost/python/conversions.hpp b/include/boost/python/conversions.hpp index d11f7f14..b633c0ee 100644 --- a/include/boost/python/conversions.hpp +++ b/include/boost/python/conversions.hpp @@ -5,6 +5,9 @@ // // The author gratefully acknowleges the support of Dragon Systems, Inc., in // producing this work. +// +// Revision History: +// Mar 03 01 added: converters for [plain] char and std::complex (Ralf W. Grosse-Kunstleve) #ifndef METHOD_DWA122899_H_ # define METHOD_DWA122899_H_ @@ -16,6 +19,7 @@ # include # include # include +# include BOOST_PYTHON_BEGIN_CONVERSION_NAMESPACE // this is a gcc 2.95.2 bug workaround @@ -100,6 +104,10 @@ PyObject* to_python(unsigned short); unsigned short from_python(PyObject*, boost::python::type); unsigned short from_python(PyObject*, boost::python::type); +PyObject* to_python(char); +char from_python(PyObject*, boost::python::type); +char from_python(PyObject*, boost::python::type); + PyObject* to_python(signed char); signed char from_python(PyObject*, boost::python::type); signed char from_python(PyObject*, boost::python::type); @@ -130,6 +138,32 @@ PyObject* to_python(const std::string& s); std::string from_python(PyObject*, boost::python::type); std::string from_python(PyObject*, boost::python::type); +template +PyObject* to_python(const std::complex& sc) { + Py_complex pcc; + pcc.real = sc.real(); + pcc.imag = sc.imag(); + return PyComplex_FromCComplex(pcc); +} + +template +std::complex from_python(PyObject* p, + boost::python::type&>) { + if (! PyComplex_Check(p)) { + PyErr_SetString(PyExc_TypeError, "expected a complex number"); + throw boost::python::argument_error(); + } + return std::complex( + static_cast(PyComplex_RealAsDouble(p)), + static_cast(PyComplex_ImagAsDouble(p))); +} + +template +inline std::complex from_python(PyObject* p, + boost::python::type >) { + return from_python(p, boost::python::type&>()); +} + // For when your C++ function really wants to pass/return a PyObject* PyObject* to_python(PyObject*); PyObject* from_python(PyObject*, boost::python::type); @@ -304,6 +338,11 @@ inline unsigned short from_python(PyObject* p, boost::python::type()); } +inline char from_python(PyObject* p, boost::python::type) +{ + return from_python(p, boost::python::type()); +} + inline signed char from_python(PyObject* p, boost::python::type) { return from_python(p, boost::python::type()); diff --git a/src/conversions.cpp b/src/conversions.cpp index ded01e0e..369f197a 100644 --- a/src/conversions.cpp +++ b/src/conversions.cpp @@ -5,6 +5,9 @@ // // The author gratefully acknowleges the support of Dragon Systems, Inc., in // producing this work. +// +// Revision History: +// Mar 03 01 added: converters for [plain] char (Ralf W. Grosse-Kunstleve) #include #include @@ -160,6 +163,24 @@ unsigned short from_python(PyObject* p, boost::python::type type return integer_from_python(p, type); } +PyObject* to_python(char c) +{ + if (c == '\0') return PyString_FromString(""); + return PyString_FromStringAndSize(&c, 1); +} + +char from_python(PyObject* p, boost::python::type) +{ + int l = -1; + if (PyString_Check(p)) l = PyString_Size(p); + if (l < 0 || l > 1) { + PyErr_SetString(PyExc_TypeError, "expected string of length 0 or 1"); + throw boost::python::argument_error(); + } + if (l == 0) return '\0'; + return PyString_AsString(p)[0]; +} + PyObject* to_python(unsigned char i) { return integer_to_python(i); diff --git a/test/comprehensive.cpp b/test/comprehensive.cpp index 7fad74bb..592b0ebd 100644 --- a/test/comprehensive.cpp +++ b/test/comprehensive.cpp @@ -815,6 +815,25 @@ namespace bpl_test { w.set_secret_number(number); } + // Test plain char converters. + char get_plain_char() { return 'x'; } + std::string use_plain_char(char c) { return std::string(3, c); } + std::string use_const_plain_char(const char c) { return std::string(5, c); } + + // Test std::complex converters. + std::complex dpolar(double rho, double theta) { + return std::polar(rho, theta); + } + double dreal(const std::complex& c) { return c.real(); } + double dimag(std::complex c) { return c.imag(); } + + // Test std::complex converters. + std::complex fpolar(float rho, float theta) { + return std::polar(rho, theta); + } + double freal(const std::complex& c) { return c.real(); } + double fimag(std::complex c) { return c.imag(); } + /************************************************************/ /* */ /* init the module */ @@ -1036,6 +1055,21 @@ void init_module(boost::python::module_builder& m) world_class.def(world_getinitargs, "__getinitargs__"); world_class.def(world_getstate, "__getstate__"); world_class.def(world_setstate, "__setstate__"); + + // Test plain char converters. + m.def(get_plain_char, "get_plain_char"); + m.def(use_plain_char, "use_plain_char"); + m.def(use_const_plain_char, "use_const_plain_char"); + + // Test std::complex converters. + m.def(dpolar, "dpolar"); + m.def(dreal, "dreal"); + m.def(dimag, "dimag"); + + // Test std::complex converters. + m.def(fpolar, "fpolar"); + m.def(freal, "freal"); + m.def(fimag, "fimag"); } PyObject* raw(const boost::python::tuple& args, const boost::python::dictionary& keywords) diff --git a/test/comprehensive.py b/test/comprehensive.py index a8e181d2..8bc8021c 100644 --- a/test/comprehensive.py +++ b/test/comprehensive.py @@ -1070,6 +1070,39 @@ test methodologies for wrapping functions that return a pointer 3 >>> eo.second 1 + +======== test [plain] char converters ============== + >>> get_plain_char() + 'x' + >>> use_plain_char('a') + 'aaa' + >>> use_const_plain_char('b') + 'bbbbb' + +======== test std::complex converters ============== + >>> c = dpolar(3, 5) + >>> type(c) + + >>> '%.3g' % (dreal(c)) + '0.851' + >>> '%.3g' % (dimag(c)) + '-2.88' + >>> '%.3g' % (freal(c)) + '0.851' + >>> '%.3g' % (fimag(c)) + '-2.88' + >>> c = fpolar(7, 13) + >>> type(c) + + >>> '%.3g' % (fimag(c)) + '2.94' + >>> '%.3g' % (freal(c)) + '6.35' + >>> '%.3g' % (dimag(c)) + '2.94' + >>> '%.3g' % (dreal(c)) + '6.35' + ''' from test import * From 1d4427c056ef90b36aaaecc9babc86a778b82e95 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Sat, 3 Mar 2001 12:05:15 +0000 Subject: [PATCH 06/23] "T" replaced by "Held" to reduce chances of name clashes. [SVN r9398] --- .../boost/python/detail/extension_class.hpp | 30 +++++++++---------- src/gen_extclass.py | 10 +++---- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/include/boost/python/detail/extension_class.hpp b/include/boost/python/detail/extension_class.hpp index 94d9bf6b..bf43ec5c 100644 --- a/include/boost/python/detail/extension_class.hpp +++ b/include/boost/python/detail/extension_class.hpp @@ -61,7 +61,7 @@ T* check_non_null(T* p) return p; } -template class held_instance; +template class held_instance; typedef void* (*conversion_function_ptr)(void*); @@ -613,33 +613,33 @@ class extension_class // A simple wrapper over a T which allows us to use extension_class with a // single template parameter only. See extension_class, above. -template -class held_instance : public T +template +class held_instance : public Held { // There are no member functions: we want to avoid inadvertently overriding - // any virtual functions in T. + // any virtual functions in Held. public: - held_instance(PyObject*) : T() {} + held_instance(PyObject*) : Held() {} template - held_instance(PyObject*, A1 a1) : T(a1) {} + held_instance(PyObject*, A1 a1) : Held(a1) {} template - held_instance(PyObject*, A1 a1, A2 a2) : T(a1, a2) {} + held_instance(PyObject*, A1 a1, A2 a2) : Held(a1, a2) {} template - held_instance(PyObject*, A1 a1, A2 a2, A3 a3) : T(a1, a2, a3) {} + held_instance(PyObject*, A1 a1, A2 a2, A3 a3) : Held(a1, a2, a3) {} template - held_instance(PyObject*, A1 a1, A2 a2, A3 a3, A4 a4) : T(a1, a2, a3, a4) {} + held_instance(PyObject*, A1 a1, A2 a2, A3 a3, A4 a4) : Held(a1, a2, a3, a4) {} template - held_instance(PyObject*, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) : T(a1, a2, a3, a4, a5) {} + held_instance(PyObject*, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) : Held(a1, a2, a3, a4, a5) {} template - held_instance(PyObject*, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) : T(a1, a2, a3, a4, a5, a6) {} + held_instance(PyObject*, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) : Held(a1, a2, a3, a4, a5, a6) {} template - held_instance(PyObject*, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) : T(a1, a2, a3, a4, a5, a6, a7) {} + held_instance(PyObject*, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) : Held(a1, a2, a3, a4, a5, a6, a7) {} template - held_instance(PyObject*, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) : T(a1, a2, a3, a4, a5, a6, a7, a8) {} + held_instance(PyObject*, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) : Held(a1, a2, a3, a4, a5, a6, a7, a8) {} template - held_instance(PyObject*, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) : T(a1, a2, a3, a4, a5, a6, a7, a8, a9) {} + held_instance(PyObject*, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) : Held(a1, a2, a3, a4, a5, a6, a7, a8, a9) {} template - held_instance(PyObject*, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10) : T(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {} + held_instance(PyObject*, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10) : Held(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {} }; // Abstract base class for all obj holders. Base for template class diff --git a/src/gen_extclass.py b/src/gen_extclass.py index f8906970..7c378d45 100644 --- a/src/gen_extclass.py +++ b/src/gen_extclass.py @@ -66,7 +66,7 @@ T* check_non_null(T* p) return p; } -template class held_instance; +template class held_instance; typedef void* (*conversion_function_ptr)(void*); @@ -613,15 +613,15 @@ class extension_class // A simple wrapper over a T which allows us to use extension_class with a // single template parameter only. See extension_class, above. -template -class held_instance : public T +template +class held_instance : public Held { // There are no member functions: we want to avoid inadvertently overriding - // any virtual functions in T. + // any virtual functions in Held. public:""" + gen_functions("""%{ template <%(class A%n%:, %)>%} - held_instance(PyObject*%(, A%n% a%n%)) : T(%(a%n%:, %)) {}""", args) + held_instance(PyObject*%(, A%n% a%n%)) : Held(%(a%n%:, %)) {}""", args) + """ }; From b06d9e50ebf64969d198ab03430d21eb40cb8442 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Sat, 3 Mar 2001 12:55:53 +0000 Subject: [PATCH 07/23] added: pickle safety measures; bug fix: use bound_function::create() [SVN r9399] --- include/boost/python/class_builder.hpp | 10 ++++++ src/classes.cpp | 46 ++++++++++++++++++++------ test/comprehensive.py | 41 +++++++++++++++++++++++ 3 files changed, 87 insertions(+), 10 deletions(-) diff --git a/include/boost/python/class_builder.hpp b/include/boost/python/class_builder.hpp index 7ef843c4..4a9ec1b2 100644 --- a/include/boost/python/class_builder.hpp +++ b/include/boost/python/class_builder.hpp @@ -1,3 +1,6 @@ +// Revision History: +// Mar 03 01 added: pickle safety measures (Ralf W. Grosse-Kunstleve) + #ifndef CLASS_WRAPPER_DWA101000_H_ # define CLASS_WRAPPER_DWA101000_H_ @@ -24,6 +27,13 @@ class class_builder ~class_builder() {} + + inline void dict_defines_state() { + add(ref(BOOST_PYTHON_CONVERSION::to_python(1)), "__dict_defines_state__"); + } + inline void getstate_manages_dict() { + add(ref(BOOST_PYTHON_CONVERSION::to_python(1)), "__getstate_manages_dict__"); + } // define constructors template diff --git a/src/classes.cpp b/src/classes.cpp index 2901aa81..625d67b7 100644 --- a/src/classes.cpp +++ b/src/classes.cpp @@ -5,6 +5,10 @@ // // The author gratefully acknowleges the support of Dragon Systems, Inc., in // producing this work. +// +// Revision History: +// Mar 03 01 added: pickle safety measures (Ralf W. Grosse-Kunstleve) +// Mar 03 01 bug fix: use bound_function::create() (instead of new bound_function) #include #include @@ -67,8 +71,7 @@ namespace { ref global_class_reduce() { - static ref result(detail::new_wrapped_function(class_reduce)); - return result; + return ref(detail::new_wrapped_function(class_reduce)); } @@ -93,17 +96,41 @@ namespace { ref getstate(PyObject_GetAttrString(obj, const_cast("__getstate__")), ref::null_ok); PyErr_Clear(); + + ref dict(PyObject_GetAttrString(obj, const_cast("__dict__")), ref::null_ok); + PyErr_Clear(); + if (getstate.get() != 0) { + if (dict.get() != 0 && dictionary(dict).size() > 0) + { + ref getstate_manages_dict(PyObject_GetAttrString(instance_class.get(), const_cast("__getstate_manages_dict__")), ref::null_ok); + PyErr_Clear(); + if (getstate_manages_dict.get() == 0) + { + PyErr_SetString(PyExc_RuntimeError, "Incomplete pickle support (__getstate_manages_dict__ not set)"); + throw error_already_set(); + } + } + ref state = ref(PyEval_CallObject(getstate.get(), NULL)); return tuple(instance_class, initargs, state); } - ref state(PyObject_GetAttrString(obj, const_cast("__dict__")), ref::null_ok); - PyErr_Clear(); - if (state.get() != 0 && dictionary(state).size() > 0) + if (getinitargs.get() == 0) { - return tuple(instance_class, initargs, state); + ref dict_defines_state(PyObject_GetAttrString(instance_class.get(), const_cast("__dict_defines_state__")), ref::null_ok); + PyErr_Clear(); + if (dict_defines_state.get() == 0) + { + PyErr_SetString(PyExc_RuntimeError, "Incomplete pickle support (__dict_defines_state__ not set)"); + throw error_already_set(); + } + } + + if (dict.get() != 0 && dictionary(dict).size() > 0) + { + return tuple(instance_class, initargs, dict); } return tuple(instance_class, initargs); @@ -111,8 +138,7 @@ namespace { ref global_instance_reduce() { - static ref result(detail::new_wrapped_function(instance_reduce)); - return result; + return ref(detail::new_wrapped_function(instance_reduce)); } } @@ -177,7 +203,7 @@ namespace detail { if (!BOOST_CSTD_::strcmp(name, "__reduce__")) { ref target(as_object(this), ref::increment_count); - return new bound_function(target, global_class_reduce()); + return bound_function::create(target, global_class_reduce()); } ref local_attribute = m_name_space.get_item(string(name).reference()); @@ -348,7 +374,7 @@ PyObject* instance::getattr(const char* name, bool use_special_function) if (!BOOST_CSTD_::strcmp(name, "__reduce__")) { - return new detail::bound_function(ref(this, ref::increment_count), global_instance_reduce()); + return detail::bound_function::create(ref(this, ref::increment_count), global_instance_reduce()); } ref local_attribute = m_name_space.get_item(string(name).reference()); diff --git a/test/comprehensive.py b/test/comprehensive.py index 8bc8021c..3c7f3c61 100644 --- a/test/comprehensive.py +++ b/test/comprehensive.py @@ -239,6 +239,47 @@ Pickling tests: Hello from California! 42 Hello from California! 0 +Pickle safety measures: + >>> r=Rational(3, 4) + >>> r + Rational(3, 4) + >>> try: s=pickle.dumps(r) + ... except RuntimeError, err: print err[0] + ... + Incomplete pickle support (__dict_defines_state__ not set) + >>> class myrational(Rational): + ... __dict_defines_state__ = 1 # this is a lie but good enough for testing. + ... + >>> r=myrational(3, 4) + >>> r + Rational(3, 4) + >>> s=pickle.dumps(r) + + >>> class myworld(world): + ... def __init__(self): + ... world.__init__(self, 'anywhere') + ... self.x = 1 + ... + >>> w = myworld() + >>> w.greet() + 'Hello from anywhere!' + >>> w.__dict__ + {'x': 1} + >>> try: s=pickle.dumps(w) + ... except RuntimeError, err: print err[0] + ... + Incomplete pickle support (__getstate_manages_dict__ not set) + + >>> class myunsafeworld(myworld): + ... __getstate_manages_dict__ = 1 # this is a lie but good enough for testing. + ... + >>> w = myunsafeworld() + >>> w.greet() + 'Hello from anywhere!' + >>> w.__dict__ + {'x': 1} + >>> s=pickle.dumps(w) + Special member attributes. Tests courtesy of Barry Scott >>> class DerivedFromFoo(Foo): From fc62d3b44ec404cb470746c3c681764b846b88a8 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Sat, 3 Mar 2001 14:46:26 +0000 Subject: [PATCH 08/23] New Makefiles for tru64_cxx, linux_gcc, mingw32. [SVN r9400] --- build/Makefile.linux_gcc | 166 +++++++++++++++++++++++++++++++ build/Makefile.mingw32 | 210 +++++++++++++++++++++++++++++++++++++++ build/Makefile.tru64_cxx | 170 +++++++++++++++++++++++++++++++ build/tru64.mak | 51 ---------- 4 files changed, 546 insertions(+), 51 deletions(-) create mode 100644 build/Makefile.linux_gcc create mode 100644 build/Makefile.mingw32 create mode 100644 build/Makefile.tru64_cxx delete mode 100644 build/tru64.mak diff --git a/build/Makefile.linux_gcc b/build/Makefile.linux_gcc new file mode 100644 index 00000000..3e8f1041 --- /dev/null +++ b/build/Makefile.linux_gcc @@ -0,0 +1,166 @@ +# Usage: +# +# Create a new empty directory anywhere (preferably not in the boost tree). +# Copy this Makefile to that new directory and rename it to "Makefile" +# Set the BOOST pathname below. +# +# make softlinks Create softlinks to source code and tests +# make Compile all sources +# make test Run doctest tests +# make clean Remove all object files +# make unlink Remove softlinks + +BOOST= /net/cci/rwgk/boost + +PYEXE= /usr/local/Python-1.5.2/bin/python +PYINC= -I/usr/local/Python-1.5.2/include/python1.5 +#PYEXE= /usr/local/Python-2.0/bin/python +#PYINC= -I/usr/local/Python-2.0/include/python2.0 +#STLPORTINC= -I/usr/local/STLport-4.1b3/stlport +#STLPORTOPTS= \ +# -D__USE_STD_IOSTREAM \ +# -D__STL_NO_SGI_IOSTREAMS \ +# -D__STL_USE_NATIVE_STRING \ +# -D__STL_NO_NEW_C_HEADERS \ +# -D_RWSTD_COMPILE_INSTANTIATE=1 +#STLPORTINC= -I/usr/local/STLport-4.1b4/stlport +#STLPORTOPTS= -D__NO_USE_STD_IOSTREAM -D__STL_NO_SGI_IOSTREAMS +#STLPORTINC= -I/net/cci/xp/C++_C_headers + +STDOPTS= -ftemplate-depth-21 +WARNOPTS= +# use -msg_display_number to obtain integer tags for -msg_disable + +CPP= g++ +CPPOPTS= $(STLPORTINC) $(STLPORTOPTS) -I$(BOOST) $(PYINC) \ + $(STDOPTS) $(WARNOPTS) -g +MAKEDEP= -M + +LD= g++ +LDOPTS= -shared + +#HIDDEN= -hidden + +BPL_SRC = $(BOOST)/libs/python/src +BPL_TST = $(BOOST)/libs/python/test +BPL_EXA = $(BOOST)/libs/python/example +SOFTLINKS = \ +$(BPL_SRC)/classes.cpp \ +$(BPL_SRC)/conversions.cpp \ +$(BPL_SRC)/extension_class.cpp \ +$(BPL_SRC)/functions.cpp \ +$(BPL_SRC)/init_function.cpp \ +$(BPL_SRC)/module_builder.cpp \ +$(BPL_SRC)/objects.cpp \ +$(BPL_SRC)/types.cpp \ +$(BPL_TST)/comprehensive.cpp \ +$(BPL_TST)/comprehensive.hpp \ +$(BPL_TST)/comprehensive.py \ +$(BPL_TST)/doctest.py \ +$(BPL_EXA)/abstract.cpp \ +$(BPL_EXA)/getting_started1.cpp \ +$(BPL_EXA)/getting_started2.cpp \ +$(BPL_EXA)/getting_started3.cpp \ +$(BPL_EXA)/getting_started4.cpp \ +$(BPL_EXA)/getting_started5.cpp \ +$(BPL_EXA)/test_abstract.py \ +$(BPL_EXA)/test_getting_started1.py \ +$(BPL_EXA)/test_getting_started2.py \ +$(BPL_EXA)/test_getting_started3.py \ +$(BPL_EXA)/test_getting_started4.py \ +$(BPL_EXA)/test_getting_started5.py + +OBJ = classes.o conversions.o extension_class.o functions.o \ + init_function.o module_builder.o \ + objects.o types.o +DEPOBJ= $(OBJ) comprehensive.o abstract.o \ + getting_started1.o getting_started2.o getting_started3.o \ + getting_started4.o getting_started5.o + +.SUFFIXES: .o .cpp + +all: libbpl.a test.so abstract.so \ + getting_started1.so getting_started2.so getting_started3.so \ + getting_started4.so getting_started5.so + +softlinks: + @ for pn in $(SOFTLINKS); \ + do \ + bn=`basename "$$pn"`; \ + if [ ! -e "$$bn" ]; then \ + echo "ln -s $$pn ."; \ + ln -s "$$pn" .; \ + else \ + echo "info: no softlink created (file exists): $$bn"; \ + fi; \ + done + +unlink: + @ for pn in $(SOFTLINKS); \ + do \ + bn=`basename "$$pn"`; \ + if [ -L "$$bn" ]; then \ + echo "rm $$bn"; \ + rm "$$bn"; \ + elif [ -e "$$bn" ]; then \ + echo "info: not a softlink: $$bn"; \ + fi; \ + done + +libbpl.a: $(OBJ) + rm -f libbpl.a + ar r libbpl.a $(OBJ) + +test.so: $(OBJ) comprehensive.o + $(LD) $(LDOPTS) $(OBJ) comprehensive.o -o test.so -lm + +abstract.so: $(OBJ) abstract.o + $(LD) $(LDOPTS) $(OBJ) abstract.o -o abstract.so + +getting_started1.so: $(OBJ) getting_started1.o + $(LD) $(LDOPTS) $(OBJ) getting_started1.o -o getting_started1.so + +getting_started2.so: $(OBJ) getting_started2.o + $(LD) $(LDOPTS) $(OBJ) getting_started2.o -o getting_started2.so + +getting_started3.so: $(OBJ) getting_started3.o + $(LD) $(LDOPTS) $(OBJ) getting_started3.o -o getting_started3.so + +getting_started4.so: $(OBJ) getting_started4.o + $(LD) $(LDOPTS) $(OBJ) getting_started4.o -o getting_started4.so + +getting_started5.so: $(OBJ) getting_started5.o + $(LD) $(LDOPTS) $(OBJ) getting_started5.o -o getting_started5.so + +.cpp.o: + $(CPP) $(CPPOPTS) -c $*.cpp + +test: + $(PYEXE) comprehensive.py + $(PYEXE) test_abstract.py + $(PYEXE) test_getting_started1.py + $(PYEXE) test_getting_started2.py + $(PYEXE) test_getting_started3.py + $(PYEXE) test_getting_started4.py + $(PYEXE) test_getting_started5.py + +clean: + rm -f $(OBJ) libbpl.a libbpl.a.input + rm -f comprehensive.o test.so + rm -f abstract.o abstract.so + rm -f getting_started1.o getting_started1.so + rm -f getting_started2.o getting_started2.so + rm -f getting_started3.o getting_started3.so + rm -f getting_started4.o getting_started4.so + rm -f getting_started5.o getting_started5.so + rm -f so_locations *.pyc + rm -rf cxx_repository + +depend: + @ cat Makefile.nodepend; \ + for obj in $(DEPOBJ); \ + do \ + bn=`echo "$$obj" | cut -d. -f1`; \ + $(CPP) $(CPPOPTS) $(MAKEDEP) "$$bn".cpp; \ + done + diff --git a/build/Makefile.mingw32 b/build/Makefile.mingw32 new file mode 100644 index 00000000..2d86efcd --- /dev/null +++ b/build/Makefile.mingw32 @@ -0,0 +1,210 @@ +# Usage: +# +# Create a new empty directory anywhere (preferably not in the boost tree). +# Copy this Makefile to that new directory and rename it to "Makefile" +# Set the BOOST_* pathnames below. +# +# The idea is that the build directory is on a Unix filesystem that +# is mounted on a PC using SAMBA. Use this makefile under both Unix +# and Windows: +# +# Unix: make softlinks Create softlinks to source code and tests +# Win: make Compile all sources +# Win: make test Run doctest tests +# Unix: make clean Remove all object files +# Unix: make unlink Remove softlinks + +# To install mingw32, follow instructions at: +# http://starship.python.net/crew/kernr/mingw32/Notes.html +# In particular, install: +# ftp://ftp.xraylith.wisc.edu/pub/khan/gnu-win32/mingw32/gcc-2.95.2/gcc-2.95.2-msvcrt.exe +# ftp://ftp.xraylith.wisc.edu/pub/khan/gnu-win32/mingw32/gcc-2.95.2/fixes/quote-fix-msvcrt.exe +# http://starship.python.net/crew/kernr/mingw32/Python-1.5.2-mingw32.zip +# Unpack the first two archives in the default locations and update your PATH. +# Unpack the third archive in \usr. + +# Note: comprehensive.cpp generates compiler errors and later crashes. +# L:\boost\boost\python\detail\extension_class.hpp:643: warning: +# alignment of `vtable for class +# boost::python::detail::held_instance' +# is greater than maximum object file alignment. Using 16. +# Could this be fixed with compiler options? +# -fhuge-objects looks interesting, but requires recompiling the C++ library. +# (what exactly does that mean?) +# -fvtable-thunks eliminates the compiler warning, but "import test" still +# causes a crash. + +BOOST_UNIX= /net/cci/rwgk/boost +BOOST_WIN= "L:\boost" + +PYEXE= "C:\Program files\Python\python.exe" +PYINC= -I"C:\usr\include\python1.5" +PYLIB= "C:\usr\lib\libpython15.a" + +STDOPTS= -ftemplate-depth-21 +WARNOPTS= + +CPP= g++ +CPPOPTS= $(STLPORTINC) $(STLPORTOPTS) -I$(BOOST_WIN) $(PYINC) \ + $(STDOPTS) $(WARNOPTS) -g + +LD= g++ +LDOPTS= -shared + +BPL_SRC = $(BOOST_UNIX)/libs/python/src +BPL_TST = $(BOOST_UNIX)/libs/python/test +BPL_EXA = $(BOOST_UNIX)/libs/python/example +SOFTLINKS = \ +$(BPL_SRC)/classes.cpp \ +$(BPL_SRC)/conversions.cpp \ +$(BPL_SRC)/extension_class.cpp \ +$(BPL_SRC)/functions.cpp \ +$(BPL_SRC)/init_function.cpp \ +$(BPL_SRC)/module_builder.cpp \ +$(BPL_SRC)/objects.cpp \ +$(BPL_SRC)/types.cpp \ +$(BPL_TST)/comprehensive.cpp \ +$(BPL_TST)/comprehensive.hpp \ +$(BPL_TST)/comprehensive.py \ +$(BPL_TST)/doctest.py \ +$(BPL_EXA)/abstract.cpp \ +$(BPL_EXA)/getting_started1.cpp \ +$(BPL_EXA)/getting_started2.cpp \ +$(BPL_EXA)/getting_started3.cpp \ +$(BPL_EXA)/getting_started4.cpp \ +$(BPL_EXA)/getting_started5.cpp \ +$(BPL_EXA)/passing_char.cpp \ +$(BPL_EXA)/test_abstract.py \ +$(BPL_EXA)/test_getting_started1.py \ +$(BPL_EXA)/test_getting_started2.py \ +$(BPL_EXA)/test_getting_started3.py \ +$(BPL_EXA)/test_getting_started4.py \ +$(BPL_EXA)/test_getting_started5.py + +DEFS= \ +test \ +abstract \ +getting_started1 \ +getting_started2 \ +getting_started3 \ +getting_started4 \ +getting_started5 + +OBJ = classes.o conversions.o extension_class.o functions.o \ + init_function.o module_builder.o \ + objects.o types.o + +.SUFFIXES: .o .cpp + +all: libbpl.a test.pyd abstract.pyd \ + getting_started1.pyd getting_started2.pyd getting_started3.pyd \ + getting_started4.pyd getting_started5.pyd + +softlinks: defs + @ for pn in $(SOFTLINKS); \ + do \ + bn=`basename "$$pn"`; \ + if [ ! -e "$$bn" ]; then \ + echo "ln -s $$pn ."; \ + ln -s "$$pn" .; \ + else \ + echo "info: no softlink created (file exists): $$bn"; \ + fi; \ + done + +unlink: rmdefs + @ for pn in $(SOFTLINKS); \ + do \ + bn=`basename "$$pn"`; \ + if [ -L "$$bn" ]; then \ + echo "rm $$bn"; \ + rm "$$bn"; \ + elif [ -e "$$bn" ]; then \ + echo "info: not a softlink: $$bn"; \ + fi; \ + done + +defs: + @ for def in $(DEFS); \ + do \ + echo "EXPORTS\n\tinit$$def" > $$def.def; \ + done + +rmdefs: + @ for def in $(DEFS); \ + do \ + rm $$def.def; \ + done + +libbpl.a: $(OBJ) + del libbpl.a + ar r libbpl.a $(OBJ) + +DLLWRAPOPTS= -s --driver-name g++ -s + --entry _DllMainCRTStartup@12 --target=i386-mingw32 + +test.pyd: $(OBJ) comprehensive.o + dllwrap $(DLLWRAPOPTS) \ + --dllname test.pyd \ + --def test.def \ + $(OBJ) comprehensive.o $(PYLIB) + +abstract.pyd: $(OBJ) abstract.o + dllwrap $(DLLWRAPOPTS) \ + --dllname abstract.pyd \ + --def abstract.def \ + $(OBJ) abstract.o $(PYLIB) + +getting_started1.pyd: $(OBJ) getting_started1.o + dllwrap $(DLLWRAPOPTS) \ + --dllname getting_started1.pyd \ + --def getting_started1.def \ + $(OBJ) getting_started1.o $(PYLIB) + +getting_started2.pyd: $(OBJ) getting_started2.o + dllwrap $(DLLWRAPOPTS) \ + --dllname getting_started2.pyd \ + --def getting_started2.def \ + $(OBJ) getting_started2.o $(PYLIB) + +getting_started3.pyd: $(OBJ) getting_started3.o + dllwrap $(DLLWRAPOPTS) \ + --dllname getting_started3.pyd \ + --def getting_started3.def \ + $(OBJ) getting_started3.o $(PYLIB) + +getting_started4.pyd: $(OBJ) getting_started4.o + dllwrap $(DLLWRAPOPTS) \ + --dllname getting_started4.pyd \ + --def getting_started4.def \ + $(OBJ) getting_started4.o $(PYLIB) + +getting_started5.pyd: $(OBJ) getting_started5.o + dllwrap $(DLLWRAPOPTS) \ + --dllname getting_started5.pyd \ + --def getting_started5.def \ + $(OBJ) getting_started5.o $(PYLIB) + +.cpp.o: + $(CPP) $(CPPOPTS) -c $*.cpp + +test: + $(PYEXE) comprehensive.py + $(PYEXE) test_abstract.py + $(PYEXE) test_getting_started1.py + $(PYEXE) test_getting_started2.py + $(PYEXE) test_getting_started3.py + $(PYEXE) test_getting_started4.py + $(PYEXE) test_getting_started5.py + +clean: + rm -f $(OBJ) libbpl.a libbpl.a.input + rm -f comprehensive.o test.pyd + rm -f abstract.o abstract.pyd + rm -f getting_started1.o getting_started1.pyd + rm -f getting_started2.o getting_started2.pyd + rm -f getting_started3.o getting_started3.pyd + rm -f getting_started4.o getting_started4.pyd + rm -f getting_started5.o getting_started5.pyd + rm -f so_locations *.pyc + rm -rf cxx_repository diff --git a/build/Makefile.tru64_cxx b/build/Makefile.tru64_cxx new file mode 100644 index 00000000..7b932bd3 --- /dev/null +++ b/build/Makefile.tru64_cxx @@ -0,0 +1,170 @@ +# Usage: +# +# Create a new empty directory anywhere (preferably not in the boost tree). +# Copy this Makefile to that new directory and rename it to "Makefile" +# Set the BOOST pathname below. +# +# make softlinks Create softlinks to source code and tests +# make Compile all sources +# make test Run doctest tests +# make clean Remove all object files +# make unlink Remove softlinks + +BOOST= /net/cci/rwgk/boost + +PYEXE= /usr/local/Python-1.5.2/bin/python +PYINC= -I/usr/local/Python-1.5.2/include/python1.5 +#PYEXE= /usr/local/Python-2.0/bin/python +#PYINC= -I/usr/local/Python-2.0/include/python2.0 +#STLPORTINC= -I/usr/local/STLport-4.1b3/stlport +#STLPORTOPTS= \ +# -D__USE_STD_IOSTREAM \ +# -D__STL_NO_SGI_IOSTREAMS \ +# -D__STL_USE_NATIVE_STRING \ +# -D__STL_NO_NEW_C_HEADERS \ +# -D_RWSTD_COMPILE_INSTANTIATE=1 +#STLPORTINC= -I/usr/local/STLport-4.1b4/stlport +#STLPORTOPTS= -D__NO_USE_STD_IOSTREAM -D__STL_NO_SGI_IOSTREAMS +STLPORTINC= -I/net/cci/xp/C++_C_headers + +STDOPTS= -std strict_ansi +WARNOPTS= -msg_disable 186,450,1115 +# use -msg_display_number to obtain integer tags for -msg_disable + +CPP= cxx +CPPOPTS= $(STLPORTINC) $(STLPORTOPTS) -I$(BOOST) $(PYINC) \ + $(STDOPTS) $(WARNOPTS) -g +MAKEDEP= -Em + +LD= cxx +LDOPTS= -shared -expect_unresolved 'Py*' -expect_unresolved '_Py*' + +#HIDDEN= -hidden + +BPL_SRC = $(BOOST)/libs/python/src +BPL_TST = $(BOOST)/libs/python/test +BPL_EXA = $(BOOST)/libs/python/example +SOFTLINKS = \ +$(BPL_SRC)/classes.cpp \ +$(BPL_SRC)/conversions.cpp \ +$(BPL_SRC)/extension_class.cpp \ +$(BPL_SRC)/functions.cpp \ +$(BPL_SRC)/init_function.cpp \ +$(BPL_SRC)/module_builder.cpp \ +$(BPL_SRC)/objects.cpp \ +$(BPL_SRC)/types.cpp \ +$(BPL_TST)/comprehensive.cpp \ +$(BPL_TST)/comprehensive.hpp \ +$(BPL_TST)/comprehensive.py \ +$(BPL_TST)/doctest.py \ +$(BPL_EXA)/abstract.cpp \ +$(BPL_EXA)/getting_started1.cpp \ +$(BPL_EXA)/getting_started2.cpp \ +$(BPL_EXA)/getting_started3.cpp \ +$(BPL_EXA)/getting_started4.cpp \ +$(BPL_EXA)/getting_started5.cpp \ +$(BPL_EXA)/test_abstract.py \ +$(BPL_EXA)/test_getting_started1.py \ +$(BPL_EXA)/test_getting_started2.py \ +$(BPL_EXA)/test_getting_started3.py \ +$(BPL_EXA)/test_getting_started4.py \ +$(BPL_EXA)/test_getting_started5.py + +OBJ = classes.o conversions.o extension_class.o functions.o \ + init_function.o module_builder.o \ + objects.o types.o +DEPOBJ= $(OBJ) comprehensive.o abstract.o \ + getting_started1.o getting_started2.o getting_started3.o \ + getting_started4.o getting_started5.o + +.SUFFIXES: .o .cpp + +all: libbpl.a test.so abstract.so \ + getting_started1.so getting_started2.so getting_started3.so \ + getting_started4.so getting_started5.so + +softlinks: + @ for pn in $(SOFTLINKS); \ + do \ + bn=`basename "$$pn"`; \ + if [ ! -e "$$bn" ]; then \ + echo "ln -s $$pn ."; \ + ln -s "$$pn" .; \ + else \ + echo "info: no softlink created (file exists): $$bn"; \ + fi; \ + done + +unlink: + @ for pn in $(SOFTLINKS); \ + do \ + bn=`basename "$$pn"`; \ + if [ -L "$$bn" ]; then \ + echo "rm $$bn"; \ + rm "$$bn"; \ + elif [ -e "$$bn" ]; then \ + echo "info: not a softlink: $$bn"; \ + fi; \ + done + +libbpl.a: $(OBJ) + rm -f libbpl.a + cd cxx_repository; \ + ls -1 > ../libbpl.a.input; \ + ar r ../libbpl.a -input ../libbpl.a.input + rm -f libbpl.a.input + ar r libbpl.a $(OBJ) + +test.so: $(OBJ) comprehensive.o + $(LD) $(LDOPTS) $(OBJ) comprehensive.o -o test.so -lm + +abstract.so: $(OBJ) abstract.o + $(LD) $(LDOPTS) $(OBJ) abstract.o -o abstract.so + +getting_started1.so: $(OBJ) getting_started1.o + $(LD) $(LDOPTS) $(OBJ) getting_started1.o -o getting_started1.so + +getting_started2.so: $(OBJ) getting_started2.o + $(LD) $(LDOPTS) $(OBJ) getting_started2.o -o getting_started2.so + +getting_started3.so: $(OBJ) getting_started3.o + $(LD) $(LDOPTS) $(OBJ) getting_started3.o -o getting_started3.so + +getting_started4.so: $(OBJ) getting_started4.o + $(LD) $(LDOPTS) $(OBJ) getting_started4.o -o getting_started4.so + +getting_started5.so: $(OBJ) getting_started5.o + $(LD) $(LDOPTS) $(OBJ) getting_started5.o -o getting_started5.so + +.cpp.o: + $(CPP) $(CPPOPTS) -c $*.cpp + +test: + $(PYEXE) comprehensive.py + $(PYEXE) test_abstract.py + $(PYEXE) test_getting_started1.py + $(PYEXE) test_getting_started2.py + $(PYEXE) test_getting_started3.py + $(PYEXE) test_getting_started4.py + $(PYEXE) test_getting_started5.py + +clean: + rm -f $(OBJ) libbpl.a libbpl.a.input + rm -f comprehensive.o test.so + rm -f abstract.o abstract.so + rm -f getting_started1.o getting_started1.so + rm -f getting_started2.o getting_started2.so + rm -f getting_started3.o getting_started3.so + rm -f getting_started4.o getting_started4.so + rm -f getting_started5.o getting_started5.so + rm -f so_locations *.pyc + rm -rf cxx_repository + +depend: + @ cat Makefile.nodepend; \ + for obj in $(DEPOBJ); \ + do \ + bn=`echo "$$obj" | cut -d. -f1`; \ + $(CPP) $(CPPOPTS) $(MAKEDEP) "$$bn".cpp; \ + done + diff --git a/build/tru64.mak b/build/tru64.mak deleted file mode 100644 index 6631615c..00000000 --- a/build/tru64.mak +++ /dev/null @@ -1,51 +0,0 @@ -# -# Tested with: -# Compaq C++ V6.2-024 for Digital UNIX V5.0 (Rev. 910) -# -# Python 1.5.2 was installed without any customizations. -# boost_all.zip vers. 1.18.1 was unpacked using unzip -aa and not modified. -# STLport-4.1b3 was unpacked using unzip -aa and not modified. -# -# Initial version 2000-10-20: Ralf W. Grosse-Kunstleve, rwgk@cci.lbl.gov -# - -PYINC= /usr/local/include/python1.5 -BOOSTINC= /usr/local/boost_1_18_1 -STLPORTINC= /usr/local/STLport-4.1b3/stlport -STLPORTOPTS= \ - -D__USE_STD_IOSTREAM \ - -D__STL_NO_SGI_IOSTREAMS \ - -D__STL_NO_NEW_C_HEADERS \ - -D_RWSTD_COMPILE_INSTANTIATE=1 - -STDOPTS= -std strict_ansi -WARNOPTS= -msg_disable 186,450,1115 -# use -msg_display_number to obtain integer tags for -msg_disable - -CPP= cxx -CPPOPTS= -I$(STLPORTINC) $(STLPORTOPTS) -I$(BOOSTINC) -I$(PYINC) \ - $(STDOPTS) $(WARNOPTS) - -LD= cxx -LDOPTS= -shared -expect_unresolved '*' - -OBJ = extclass.o functions.o init_function.o module.o newtypes.o \ - objects.o py.o subclass.o - -.SUFFIXES: .o .cpp - -all: demo.so hello.so - -demo.so: $(OBJ) extclass_demo.o - $(LD) $(LDOPTS) $(OBJ) extclass_demo.o -o demo.so - -hello.so: $(OBJ) example1.o - $(LD) $(LDOPTS) $(OBJ) example1.o -o hello.so - -.cpp.o: - -$(CPP) $(CPPOPTS) $(INC) -c $*.cpp - -clean: - rm -f $(OBJ) extclass_demo.o example1.o demo.so hello.so so_locations - rm -rf cxx_repository - rm -f *.pyc From 28e6a84acbf5c2fe893d5ca74b49dc78764588e9 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 4 Mar 2001 15:10:16 +0000 Subject: [PATCH 09/23] Fixed std::complex<> stuff to work with MSVC [SVN r9408] --- include/boost/python/conversions.hpp | 82 +++++++++++++++++++++------- 1 file changed, 61 insertions(+), 21 deletions(-) diff --git a/include/boost/python/conversions.hpp b/include/boost/python/conversions.hpp index b633c0ee..47f80989 100644 --- a/include/boost/python/conversions.hpp +++ b/include/boost/python/conversions.hpp @@ -7,7 +7,9 @@ // producing this work. // // Revision History: -// Mar 03 01 added: converters for [plain] char and std::complex (Ralf W. Grosse-Kunstleve) +// 04 Mar 01 Fixed std::complex<> stuff to work with MSVC (David Abrahams) +// 03 Mar 01 added: converters for [plain] char and std::complex +// (Ralf W. Grosse-Kunstleve) #ifndef METHOD_DWA122899_H_ # define METHOD_DWA122899_H_ @@ -19,8 +21,18 @@ # include # include # include + +# ifdef BOOST_MSVC6_OR_EARLIER +# pragma warning(push) +# pragma warning(disable:4275) // disable a bogus warning caused by +# endif + # include +# ifdef BOOST_MSVC6_OR_EARLIER +# pragma warning(pop) +# endif + BOOST_PYTHON_BEGIN_CONVERSION_NAMESPACE // this is a gcc 2.95.2 bug workaround // This can be instantiated on an enum to provide the to_python/from_python @@ -74,6 +86,30 @@ inline void xdecref(T* p) xdecref_impl(reinterpret_cast(p_base)); } +namespace detail { + + void expect_complex(PyObject*); + + template + std::complex complex_from_python(PyObject* p, boost::python::type) + { + expect_complex(p); + + return std::complex( + static_cast(PyComplex_RealAsDouble(p)), + static_cast(PyComplex_ImagAsDouble(p))); + } + + template + PyObject* complex_to_python(const std::complex& sc) { + Py_complex pcc; + pcc.real = sc.real(); + pcc.imag = sc.imag(); + return PyComplex_FromCComplex(pcc); + } + +} + }} // namespace boost::python BOOST_PYTHON_BEGIN_CONVERSION_NAMESPACE @@ -138,30 +174,34 @@ PyObject* to_python(const std::string& s); std::string from_python(PyObject*, boost::python::type); std::string from_python(PyObject*, boost::python::type); -template -PyObject* to_python(const std::complex& sc) { - Py_complex pcc; - pcc.real = sc.real(); - pcc.imag = sc.imag(); - return PyComplex_FromCComplex(pcc); +inline PyObject* to_python(const std::complex& x) +{ + return boost::python::detail::complex_to_python(x); } -template -std::complex from_python(PyObject* p, - boost::python::type&>) { - if (! PyComplex_Check(p)) { - PyErr_SetString(PyExc_TypeError, "expected a complex number"); - throw boost::python::argument_error(); - } - return std::complex( - static_cast(PyComplex_RealAsDouble(p)), - static_cast(PyComplex_ImagAsDouble(p))); +inline PyObject* to_python(const std::complex& x) +{ + return boost::python::detail::complex_to_python(x); } -template -inline std::complex from_python(PyObject* p, - boost::python::type >) { - return from_python(p, boost::python::type&>()); +inline std::complex from_python(PyObject* p, + boost::python::type >) { + return boost::python::detail::complex_from_python(p, boost::python::type()); +} + +inline std::complex from_python(PyObject* p, + boost::python::type&>) { + return boost::python::detail::complex_from_python(p, boost::python::type()); +} + +inline std::complex from_python(PyObject* p, + boost::python::type >) { + return boost::python::detail::complex_from_python(p, boost::python::type()); +} + +inline std::complex from_python(PyObject* p, + boost::python::type&>) { + return boost::python::detail::complex_from_python(p, boost::python::type()); } // For when your C++ function really wants to pass/return a PyObject* From 0b97d9bae58d79e4c834f9e5a809a4fe36116368 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 4 Mar 2001 15:12:30 +0000 Subject: [PATCH 10/23] Some fixes so it will compile with Intel C++ [SVN r9409] --- include/boost/python/detail/config.hpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/include/boost/python/detail/config.hpp b/include/boost/python/detail/config.hpp index faf52ee4..3207f7c6 100644 --- a/include/boost/python/detail/config.hpp +++ b/include/boost/python/detail/config.hpp @@ -6,6 +6,9 @@ // The author gratefully acknowleges the support of Dragon Systems, Inc., in // producing this work. +// Revision History: +// 04 Mar 01 Some fixes so it will compile with Intel C++ (Dave Abrahams) + #ifndef CONFIG_DWA052200_H_ # define CONFIG_DWA052200_H_ @@ -46,8 +49,9 @@ # endif // The STLport puts all of the standard 'C' library names in std (as far as the -// user is concerned), but without it you need a fix if you're using MSVC. -# if defined(BOOST_MSVC6_OR_EARLIER) && !defined(__STLPORT) +// user is concerned), but without it you need a fix if you're using MSVC or +// Intel C++ +# if defined(BOOST_MSVC_STD_ITERATOR) # define BOOST_CSTD_ # else # define BOOST_CSTD_ std From a40daca9ef899a340608ee22b729a53160bb46b1 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 4 Mar 2001 15:14:04 +0000 Subject: [PATCH 11/23] *** empty log message *** [SVN r9410] --- include/boost/python/detail/wrap_python.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/boost/python/detail/wrap_python.hpp b/include/boost/python/detail/wrap_python.hpp index 9e57c287..d5b75374 100644 --- a/include/boost/python/detail/wrap_python.hpp +++ b/include/boost/python/detail/wrap_python.hpp @@ -16,7 +16,8 @@ // compiler command-line. // Revision History: -// 01 Mar 01 define PyObject_INIT() for Python 1.x +// 04 Mar 01 Rolled in some changes from the Dragon fork (Dave Abrahams) +// 01 Mar 01 define PyObject_INIT() for Python 1.x (Dave Abrahams) #ifdef _DEBUG # ifndef BOOST_DEBUG_PYTHON @@ -64,6 +65,8 @@ typedef int pid_t; # define _MSC_VER 900 # endif +# elif defined(_MSC_VER) +# include // prevents Python.h from defining LONGLONG_MAX, LONGLONG_MIN, and ULONGLONG_MAX # endif #endif // _WIN32 From 71aff9f0e8fce2dda850f08f861dc9fcbbc3f39b Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 4 Mar 2001 15:41:47 +0000 Subject: [PATCH 12/23] Changed library name to libboost_python.a [SVN r9411] --- build/como.mak | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/build/como.mak b/build/como.mak index 5a9920d8..c6f340a5 100644 --- a/build/como.mak +++ b/build/como.mak @@ -1,3 +1,5 @@ +# Revision History: +# 04 Mar 01 Changed library name to libboost_python.a (David Abrahams) LIBSRC = \ classes.cpp \ conversions.cpp \ @@ -30,8 +32,8 @@ endif | sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@; \ [ -s $@ ] || rm -f $@ -example1: example1.o libpycpp.a - como-dyn-link -o ../example/hellomodule.$(MODULE_EXTENSION) $(PYHTON_LIB) example1.o -L. -lpycpp +example1: example1.o libboost_python.a + como-dyn-link -o ../example/hellomodule.$(MODULE_EXTENSION) $(PYHTON_LIB) example1.o -L. -lboost_python python ../example/test_example1.py example1.o: ../example/example1.cpp @@ -40,9 +42,9 @@ example1.o: ../example/example1.cpp clean: rm -rf *.o *.$(MODULE_EXTENSION) *.a *.d *.pyc *.bak a.out -libpycpp.a: $(LIBOBJ) - rm -f libpycpp.a - ar cq libpycpp.a $(LIBOBJ) +libboost_python.a: $(LIBOBJ) + rm -f libboost_python.a + ar cq libboost_python.a $(LIBOBJ) DEP = $(OBJ:.o=.d) From 4aa4f1c3b3b625450c1875548a49731db8bd6f3d Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 4 Mar 2001 15:45:02 +0000 Subject: [PATCH 13/23] Added DebugPython target; cleaned up some mess introduced by others [SVN r9412] --- build/bpl_static.dsp | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/build/bpl_static.dsp b/build/bpl_static.dsp index 701dd309..92af59c7 100644 --- a/build/bpl_static.dsp +++ b/build/bpl_static.dsp @@ -4,7 +4,7 @@ # TARGTYPE "Win32 (x86) Static Library" 0x0104 -CFG=bpl_static - Win32 Debug +CFG=bpl_static - Win32 DebugPython !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE @@ -13,12 +13,13 @@ CFG=bpl_static - Win32 Debug !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE -!MESSAGE NMAKE /f "bpl_static.mak" CFG="bpl_static - Win32 Debug" +!MESSAGE NMAKE /f "bpl_static.mak" CFG="bpl_static - Win32 DebugPython" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "bpl_static - Win32 Release" (based on "Win32 (x86) Static Library") !MESSAGE "bpl_static - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE "bpl_static - Win32 DebugPython" (based on "Win32 (x86) Static Library") !MESSAGE # Begin Project @@ -64,7 +65,30 @@ LIB32=link.exe -lib # PROP Intermediate_Dir "Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /MDd /W4 /WX /Gm /GR /GX /ZI /Od /I "d:\boost\type_traits" /I "..\..\.." /I "c:\progra~1\python20\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /YX /FD /GZ /c +# ADD CPP /nologo /MDd /W4 /WX /Gm /GR /GX /Zi /Od /I "..\..\.." /I "c:\tools\python\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ELSEIF "$(CFG)" == "bpl_static - Win32 DebugPython" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "bpl_static___Win32_DebugPython" +# PROP BASE Intermediate_Dir "bpl_static___Win32_DebugPython" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "DebugPython" +# PROP Intermediate_Dir "DebugPython" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MDd /W4 /WX /Gm /GR /GX /Zi /Od /I "..\..\.." /I "c:\tools\python\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /YX /FD /GZ /c +# ADD CPP /nologo /MDd /W4 /WX /Gm /GR /GX /Zi /Od /I "..\..\.." /I "c:\tools\python\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "BOOST_DEBUG_PYTHON" /FR /YX /FD /GZ /EHs /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe @@ -80,6 +104,7 @@ LIB32=link.exe -lib # Name "bpl_static - Win32 Release" # Name "bpl_static - Win32 Debug" +# Name "bpl_static - Win32 DebugPython" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" From 4b926b7c7fa3aaf563745281034ed2405cf8b36b Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 4 Mar 2001 15:48:50 +0000 Subject: [PATCH 14/23] Changed library name to libboost_python.a, various cleanups, attempted Cygwin compatibility. Still needs testing on Linux. [SVN r9413] --- build/gcc.mak | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/build/gcc.mak b/build/gcc.mak index d0b42548..f71185e0 100644 --- a/build/gcc.mak +++ b/build/gcc.mak @@ -1,3 +1,10 @@ +# Revision History + +# 04 Mar 01 Changed library name to libboost_python.a, various cleanups, +# attempted Cygwin compatibility. Still needs testing on Linux +# (David Abrahams) + + LIBSRC = \ classes.cpp \ conversions.cpp \ @@ -11,13 +18,16 @@ LIBSRC = \ LIBOBJ = $(LIBSRC:.cpp=.o) OBJ = $(LIBOBJ) +PYTHON_INC=$(ROOT)/usr/local/include/python2.0 +# libpython2.0.dll ifeq "$(OS)" "Windows_NT" -PYTHON_LIB=c:/tools/python/libs/python15.lib -INC = -Ic:/cygnus/usr/include/g++-3 -Ic:/cygnus/usr/include -Ic:/boost -Ic:/tools/python/include +ROOT=c:/cygnus +INC = -Ic:/cygnus/usr/include/g++-3 -Ic:/cygnus/usr/include -Ic:/boost -I$(PYTHON_INC) MODULE_EXTENSION=dll +PYTHON_LIB=c:/cygnus/usr/local/lib/python2.0/config/libpython2.0.dll.a else -INC = -I/usr/local/include/python1.5 +INC = -I$(PYTHON_INC) MODULE_EXTENSION=so endif @@ -31,20 +41,30 @@ endif [ -s $@ ] || rm -f $@ -example1: example1.o libpycpp.a - g++ -shared -o ../example/hellomodule.$(MODULE_EXTENSION) $(PYHTON_LIB) example1.o -L. -lpycpp - python ../example/test_example1.py +PYTHON = python + +test: comprehensive.o libboost_python.a + g++ $(CXXFLAGS) -shared -o ../test/boost_python_test.$(MODULE_EXTENSION) comprehensive.o -L. -lboost_python $(PYTHON_LIB) + $(PYTHON) ../test/comprehensive.py + +comprehensive.o: ../test/comprehensive.cpp + g++ $(CXXFLAGS) --template-depth-32 -fPIC -Wall -W $(INC) -o $*.o -c $< + + +example1: example1.o libboost_python.a + g++ $(CXXFLAGS) -shared -o ../example/hellomodule.$(MODULE_EXTENSION) example1.o -L. -lboost_python $(PYTHON_LIB) + $(PYTHON) ../example/test_example1.py example1.o: ../example/example1.cpp - g++ -fPIC -Wall -W $(INC) -o $*.o -c $< + g++ $(CXXFLAGS) --template-depth-32 -fPIC -Wall -W $(INC) -o $*.o -c $< clean: rm -rf *.o *.$(MODULE_EXTENSION) *.a *.d *.pyc *.bak a.out -libpycpp.a: $(LIBOBJ) - rm -f libpycpp.a - ar cq libpycpp.a $(LIBOBJ) +libboost_python.a: $(LIBOBJ) + rm -f libboost_python.a + ar cq libboost_python.a $(LIBOBJ) DEP = $(OBJ:.o=.d) From f82151f925a3481ea05dd1b095069d5b5401f3ab Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 4 Mar 2001 15:48:55 +0000 Subject: [PATCH 15/23] no message [SVN r9414] --- build/build.opt | Bin 84480 -> 80384 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/build/build.opt b/build/build.opt index a650cf1f83e6ca05cbe1a0fccd96f89b59f47f31..9cdea95b7eef30bf876fd69fc7e9971cd8f4a6f9 100644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907!<)i0+ cz}o(!^k@i-ybu_j{~394KI-Gq5P*dM06)EQvH$=8 From bf5eec727e06ee5fbeaa19a2a8ff9870f66c2ff0 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 4 Mar 2001 15:53:00 +0000 Subject: [PATCH 16/23] Added DebugPython target [SVN r9415] --- build/example1/example1.dsp | 39 +++++++++++++++++++++++++++----- build/rwgk1/rwgk1.dsp | 38 +++++++++++++++++++++++++++---- build/test/test.dsp | 45 ++++++++++++++++++++++++++++++++----- 3 files changed, 107 insertions(+), 15 deletions(-) diff --git a/build/example1/example1.dsp b/build/example1/example1.dsp index 78d1f0d8..dcff3f55 100644 --- a/build/example1/example1.dsp +++ b/build/example1/example1.dsp @@ -4,7 +4,7 @@ # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 -CFG=example1 - Win32 Debug +CFG=example1 - Win32 DebugPython !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE @@ -13,12 +13,13 @@ CFG=example1 - Win32 Debug !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE -!MESSAGE NMAKE /f "example1.mak" CFG="example1 - Win32 Debug" +!MESSAGE NMAKE /f "example1.mak" CFG="example1 - Win32 DebugPython" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "example1 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "example1 - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "example1 - Win32 DebugPython" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project @@ -68,8 +69,8 @@ LINK32=link.exe # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE1_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /Gm /GR /GX /ZI /Od /I "..\..\..\.." /I "c:\tools\python\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE1_EXPORTS" /YX /FD /GZ /c +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE1_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /GR /GX /Zi /Od /I "..\..\..\.." /I "c:\tools\python\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE1_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x409 /d "_DEBUG" @@ -79,7 +80,34 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"Debug/hello.dll" /pdbtype:sept /libpath:"c:\tools\python\libs" +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:no /debug /machine:I386 /out:"Debug/hello.dll" /pdbtype:sept /libpath:"c:\tools\python\libs" + +!ELSEIF "$(CFG)" == "example1 - Win32 DebugPython" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "example1___Win32_DebugPython" +# PROP BASE Intermediate_Dir "example1___Win32_DebugPython" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "DebugPython" +# PROP Intermediate_Dir "DebugPython" +# PROP Ignore_Export_Lib 1 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MDd /W3 /Gm /GR /GX /Zi /Od /I "..\..\..\.." /I "c:\tools\python\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE1_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /GR /GX /Zi /Od /I "..\..\..\.." /I "c:\tools\python\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE1_EXPORTS" /D "BOOST_DEBUG_PYTHON" /YX /FD /GZ /EHs /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:no /debug /machine:I386 /out:"Debug/hello.dll" /pdbtype:sept /libpath:"c:\tools\python\libs" +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:no /debug /machine:I386 /out:"DebugPython/hello_d.dll" /pdbtype:sept /libpath:"c:\tools\python\src\PCbuild" !ENDIF @@ -87,6 +115,7 @@ LINK32=link.exe # Name "example1 - Win32 Release" # Name "example1 - Win32 Debug" +# Name "example1 - Win32 DebugPython" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" diff --git a/build/rwgk1/rwgk1.dsp b/build/rwgk1/rwgk1.dsp index 18526979..daf736b3 100644 --- a/build/rwgk1/rwgk1.dsp +++ b/build/rwgk1/rwgk1.dsp @@ -4,7 +4,7 @@ # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 -CFG=rwgk1 - Win32 Debug +CFG=rwgk1 - Win32 DebugPython !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE @@ -13,12 +13,13 @@ CFG=rwgk1 - Win32 Debug !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE -!MESSAGE NMAKE /f "rwgk1.mak" CFG="rwgk1 - Win32 Debug" +!MESSAGE NMAKE /f "rwgk1.mak" CFG="rwgk1 - Win32 DebugPython" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "rwgk1 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "rwgk1 - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "rwgk1 - Win32 DebugPython" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project @@ -65,9 +66,10 @@ LINK32=link.exe # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RWGK1_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\.." /I "c:\tools\python\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RWGK1_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\..\.." /I "c:\tools\python\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RWGK1_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x409 /d "_DEBUG" @@ -77,7 +79,34 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /libpath:"c:\tools\python\libs" +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:no /debug /machine:I386 /pdbtype:sept /libpath:"c:\tools\python\libs" + +!ELSEIF "$(CFG)" == "rwgk1 - Win32 DebugPython" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "rwgk1___Win32_DebugPython" +# PROP BASE Intermediate_Dir "rwgk1___Win32_DebugPython" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "DebugPython" +# PROP Intermediate_Dir "DebugPython" +# PROP Ignore_Export_Lib 1 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\..\.." /I "c:\tools\python\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RWGK1_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\..\.." /I "c:\tools\python\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RWGK1_EXPORTS" /D "BOOST_DEBUG_PYTHON" /YX /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:no /debug /machine:I386 /pdbtype:sept /libpath:"c:\tools\python\libs" +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:no /debug /machine:I386 /out:"DebugPython/rwgk1_d.dll" /pdbtype:sept /libpath:"C:\tools\python\src\PCbuild" !ENDIF @@ -85,6 +114,7 @@ LINK32=link.exe # Name "rwgk1 - Win32 Release" # Name "rwgk1 - Win32 Debug" +# Name "rwgk1 - Win32 DebugPython" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" diff --git a/build/test/test.dsp b/build/test/test.dsp index a29d011a..0816bf1e 100644 --- a/build/test/test.dsp +++ b/build/test/test.dsp @@ -4,7 +4,7 @@ # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 -CFG=test - Win32 Debug +CFG=test - Win32 DebugPython !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE @@ -13,12 +13,13 @@ CFG=test - Win32 Debug !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE -!MESSAGE NMAKE /f "test.mak" CFG="test - Win32 Debug" +!MESSAGE NMAKE /f "test.mak" CFG="test - Win32 DebugPython" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "test - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "test - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "test - Win32 DebugPython" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project @@ -44,6 +45,7 @@ RSC=rc.exe # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TEST_EXPORTS" /YX /FD /c # ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "..\..\..\.." /I "c:\tools\python\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TEST_EXPORTS" /YX /FD /Zm200 /c +# SUBTRACT CPP /Fr # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x409 /d "NDEBUG" @@ -53,7 +55,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /libpath:"c:\tools\python\libs" +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"Release/boost_python_test.dll" /libpath:"c:\tools\python\libs" !ELSEIF "$(CFG)" == "test - Win32 Debug" @@ -68,8 +70,9 @@ LINK32=link.exe # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TEST_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /Gm /GR /GX /ZI /Od /I "..\..\..\.." /I "c:\tools\python\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TEST_EXPORTS" /YX /FD /GZ /Zm200 /c +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TEST_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /GR /GX /Zi /Od /I "..\..\..\.." /I "c:\tools\python\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TEST_EXPORTS" /YX /FD /GZ /Zm200 /c +# SUBTRACT CPP /Fr # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x409 /d "_DEBUG" @@ -79,7 +82,36 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /libpath:"c:\tools\python\libs" +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:no /debug /machine:I386 /out:"Debug/boost_python_test.dll" /pdbtype:sept /libpath:"c:\tools\python\libs" +# SUBTRACT LINK32 /pdb:none + +!ELSEIF "$(CFG)" == "test - Win32 DebugPython" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "test___Win32_DebugPython" +# PROP BASE Intermediate_Dir "test___Win32_DebugPython" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "DebugPython" +# PROP Intermediate_Dir "DebugPython" +# PROP Ignore_Export_Lib 1 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MDd /W3 /Gm /GR /GX /Zi /Od /I "..\..\..\.." /I "c:\tools\python\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TEST_EXPORTS" /YX /FD /GZ /Zm200 /c +# ADD CPP /nologo /MDd /W3 /Gm /GR /GX /Zi /Od /I "..\..\..\.." /I "c:\tools\python\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TEST_EXPORTS" /D "BOOST_DEBUG_PYTHON" /YX /FD /GZ /Zm200 /EHs /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:no /debug /machine:I386 /pdbtype:sept /libpath:"c:\tools\python\libs" +# SUBTRACT BASE LINK32 /pdb:none +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:no /debug /machine:I386 /out:"DebugPython/boost_python_test_d.dll" /pdbtype:sept /libpath:"c:\tools\python\src\PCbuild" # SUBTRACT LINK32 /pdb:none !ENDIF @@ -88,6 +120,7 @@ LINK32=link.exe # Name "test - Win32 Release" # Name "test - Win32 Debug" +# Name "test - Win32 DebugPython" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" From afdaa4d0d848ec7242cf5b5f1d4d8a00e1639e20 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 4 Mar 2001 15:55:35 +0000 Subject: [PATCH 17/23] Rolled in const_cast from Dragon fork [SVN r9416] --- src/classes.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/classes.cpp b/src/classes.cpp index 625d67b7..c609eeef 100644 --- a/src/classes.cpp +++ b/src/classes.cpp @@ -7,8 +7,9 @@ // producing this work. // // Revision History: -// Mar 03 01 added: pickle safety measures (Ralf W. Grosse-Kunstleve) -// Mar 03 01 bug fix: use bound_function::create() (instead of new bound_function) +// 04 Mar 01 Rolled in const_cast from Dragon fork (Dave Abrahams) +// 03 Mar 01 added: pickle safety measures (Ralf W. Grosse-Kunstleve) +// 03 Mar 01 bug fix: use bound_function::create() (instead of new bound_function) #include #include @@ -881,7 +882,7 @@ namespace { PyObject *globals = PyEval_GetGlobals(); if (globals != NULL) { - PyObject *module_name = PyDict_GetItemString(globals, "__name__"); + PyObject *module_name = PyDict_GetItemString(globals, const_cast("__name__")); if (module_name != NULL) name_space.set_item(module_key, module_name); } From a3f822b7d3b24fa9d179e68bfe7cc93093fe368d Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Sun, 4 Mar 2001 15:56:07 +0000 Subject: [PATCH 18/23] Documentation for pickle support. [SVN r9417] --- doc/index.html | 2 +- doc/pickle.html | 223 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 224 insertions(+), 1 deletion(-) create mode 100644 doc/pickle.html diff --git a/doc/index.html b/doc/index.html index 9ddd65d3..4550be5c 100644 --- a/doc/index.html +++ b/doc/index.html @@ -116,7 +116,7 @@ among others.
  • Advanced Topics
      -
    1. Pickling +
    2. Pickle Support
    3. class_builder<> diff --git a/doc/pickle.html b/doc/pickle.html new file mode 100644 index 00000000..0e64d6fc --- /dev/null +++ b/doc/pickle.html @@ -0,0 +1,223 @@ + + + BPL Pickle Support + + + +c++boost.gif (8819 bytes) + + +
      +

      BPL Pickle Support

      + +Pickle is a Python module for object serialization, also known +as persistence, marshalling, or flattening. + +

      +It is often necessary to save and restore the contents of an object to +a file. One approach to this problem is to write a pair of functions +that read and write data from a file in a special format. A powerful +alternative approach is to use Python's pickle module. Exploiting +Python's ability for introspection, the pickle module recursively +converts nearly arbitrary Python objects into a stream of bytes that +can be written to a file. + +

      +The Boost Python Library supports the pickle module by emulating the +interface implemented by Jim Fulton's ExtensionClass module that is +included in the ZOPE distribution +(http://www.zope.org/). +This interface is similar to that for regular Python classes as +described in detail in the Python Library Reference for pickle: + +

      + http://www.python.org/doc/current/lib/module-pickle.html +
      + +
      +

      The BPL Pickle Interface

      + +At the user level, the BPL pickle interface involves three special +methods: + +
      +
      +__getinitargs__ +
      + When an instance of a BPL extension class is pickled, the pickler + tests if the instance has a __getinitargs__ method. This method must + return a Python tuple. When the instance is restored by the + unpickler, the contents of this tuple are used as the arguments for + the class constructor. + +

      + If __getinitargs__ is not defined, the class constructor will be + called without arguments. + +

      +

      +__getstate__ + +
      + When an instance of a BPL extension class is pickled, the pickler + tests if the instance has a __getstate__ method. This method should + return a Python object representing the state of the instance. + +

      + If __getstate__ is not defined, the instance's __dict__ is pickled + (if it is not empty). + +

      +

      +__setstate__ + +
      + When an instance of a BPL extension class is restored by the + unpickler, it is first constructed using the result of + __getinitargs__ as arguments (see above). Subsequently the unpickler + tests if the new instance has a __setstate__ method. If so, this + method is called with the result of __getstate__ (a Python object) as + the argument. + +

      + If __setstate__ is not defined, the result of __getstate__ must be + a Python dictionary. The items of this dictionary are added to + the instance's __dict__. +

      + +If both __getstate__ and __setstate__ are defined, the Python object +returned by __getstate__ need not be a dictionary. The __getstate__ and +__setstate__ methods can do what they want. + +
      +

      Pitfalls and Safety Guards

      + +In BPL extension modules with many extension classes, providing +complete pickle support for all classes would be a significant +overhead. In general complete pickle support should only be implemented +for extension classes that will eventually be pickled. However, the +author of a BPL extension module might not anticipate correctly which +classes need support for pickle. Unfortunately, the pickle protocol +described above has two important pitfalls that the end user of a BPL +extension module might not be aware of: + +
      +
      +Pitfall 1: +Both __getinitargs__ and __getstate__ are not defined. + +
      + In this situation the unpickler calls the class constructor without + arguments and then adds the __dict__ that was pickled by default to + that of the new instance. + +

      + However, most C++ classes wrapped with the BPL will have member data + that are not restored correctly by this procedure. To alert the user + to this problem, a safety guard is provided. If both __getinitargs__ + and __getstate__ are not defined, the BPL tests if the class has an + attribute __dict_defines_state__. An exception is raised if this + attribute is not defined: + +

      +    RuntimeError: Incomplete pickle support (__dict_defines_state__ not set)
      +
      + + In the rare cases where this is not the desired behavior, the safety + guard can deliberately be disabled. The corresponding C++ code for + this is, e.g.: + +
      +    class_builder py_your_class(your_module, "your_class");
      +    py_your_class.dict_defines_state();
      +
      + + It is also possible to override the safety guard at the Python level. + E.g.: + +
      +    import your_bpl_module
      +    class your_class(your_bpl_module.your_class):
      +      __dict_defines_state__ = 1
      +
      + +

      +

      +Pitfall 2: +__getstate__ is defined and the instance's __dict__ is not empty. + +
      + The author of a BPL extension class might provide a __getstate__ + method without considering the possibilities that: + +

      +

        +
      • + his class is used as a base class. Most likely the __dict__ of + instances of the derived class needs to be pickled in order to + restore the instances correctly. + +

        +

      • + the user adds items to the instance's __dict__ directly. Again, + the __dict__ of the instance then needs to be pickled. +
      +

      + + To alert the user to this highly unobvious problem, a safety guard is + provided. If __getstate__ is defined and the instance's __dict__ is + not empty, the BPL tests if the class has an attribute + __getstate_manages_dict__. An exception is raised if this attribute + is not defined: + +

      +    RuntimeError: Incomplete pickle support (__getstate_manages_dict__ not set)
      +
      + + To resolve this problem, it should first be established that the + __getstate__ and __setstate__ methods manage the instances's __dict__ + correctly. Note that this can be done both at the C++ and the Python + level. Finally, the safety guard should intentionally be overridden. + E.g. in C++: + +
      +    class_builder py_your_class(your_module, "your_class");
      +    py_your_class.getstate_manages_dict();
      +
      + + In Python: + +
      +    import your_bpl_module
      +    class your_class(your_bpl_module.your_class):
      +      __getstate_manages_dict__ = 1
      +      def __getstate__(self):
      +        # your code here
      +      def __setstate__(self, state):
      +        # your code here
      +
      +
      + +
      +

      Practical Advice

      + +
        +
      • + Avoid using __getstate__ if the instance can also be reconstructed + by way of __getinitargs__. This automatically avoids Pitfall 2. + +

        +

      • + If __getstate__ is required, include the instance's __dict__ in the + Python object that is returned. +
      + +
      +
      +Author: Ralf W. Grosse-Kunstleve, March 2001 +
      + From af6cfd0ea8b5c854e66ecc8540f8c3fb54860e54 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 4 Mar 2001 15:56:38 +0000 Subject: [PATCH 19/23] std::complex<> fixes for MSVC [SVN r9418] --- src/conversions.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/conversions.cpp b/src/conversions.cpp index 369f197a..88e30048 100644 --- a/src/conversions.cpp +++ b/src/conversions.cpp @@ -7,7 +7,8 @@ // producing this work. // // Revision History: -// Mar 03 01 added: converters for [plain] char (Ralf W. Grosse-Kunstleve) +// 04 Mar 01 std::complex<> fixes for MSVC (Dave Abrahams) +// 03 Mar 01 added: converters for [plain] char (Ralf W. Grosse-Kunstleve) #include #include @@ -47,6 +48,19 @@ void handle_exception() } } +namespace detail { + + void expect_complex(PyObject* p) + { + if (!PyComplex_Check(p)) + { + PyErr_SetString(PyExc_TypeError, "expected a complex number"); + throw boost::python::argument_error(); + } + } + +} // namespace boost::python::detail + }} // namespace boost::python BOOST_PYTHON_BEGIN_CONVERSION_NAMESPACE From f6ba5a41da56aabcd0c337b1bd3fcaf36923d889 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 4 Mar 2001 15:57:47 +0000 Subject: [PATCH 20/23] Use PyObject_INIT() instead of trying to hand-initialize [SVN r9419] --- src/extension_class.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/extension_class.cpp b/src/extension_class.cpp index 47862ec7..f71976b9 100644 --- a/src/extension_class.cpp +++ b/src/extension_class.cpp @@ -7,7 +7,7 @@ // producing this work. // // Revision History: -// Mar 01 01 Use PyObject_INIT() instead of trying to hand-initialize (David Abrahams) +// 04 Mar 01 Use PyObject_INIT() instead of trying to hand-initialize (David Abrahams) #include #include @@ -463,7 +463,9 @@ operator_dispatcher::create(const ref& object, const ref& self) free_list = result->m_free_list_link; result->m_object = object; result->m_self = self; - Py_INCREF(result); + + PyObject* result_as_pyobject = result; + PyObject_INIT(result_as_pyobject, &type_obj); return result; } From 405710e635cce91ce42a0bd82ba4925cc82dc4dc Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 4 Mar 2001 15:59:52 +0000 Subject: [PATCH 21/23] Changed name of extension module so it would work with DebugPython, eliminated useless test that aggravated MSVC [SVN r9420] --- test/comprehensive.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/test/comprehensive.cpp b/test/comprehensive.cpp index 592b0ebd..57edd687 100644 --- a/test/comprehensive.cpp +++ b/test/comprehensive.cpp @@ -5,6 +5,10 @@ // // The author gratefully acknowleges the support of Dragon Systems, Inc., in // producing this work. + +// Revision History: +// 04 Mar 01 Changed name of extension module so it would work with DebugPython, +// eliminated useless test that aggravated MSVC (David Abrahams) #include "comprehensive.hpp" #include #include // used for portability on broken compilers @@ -818,7 +822,14 @@ namespace bpl_test { // Test plain char converters. char get_plain_char() { return 'x'; } std::string use_plain_char(char c) { return std::string(3, c); } - std::string use_const_plain_char(const char c) { return std::string(5, c); } + + // This doesn't test anything but the compiler, since it has the same signature as the above. + // Since MSVC is broken and gets the signature wrong, we'll skip it. + std::string use_const_plain_char( +#ifndef BOOST_MSVC6_OR_EARLIER + const +#endif + char c) { return std::string(5, c); } // Test std::complex converters. std::complex dpolar(double rho, double theta) { @@ -1091,18 +1102,18 @@ PyObject* raw(const boost::python::tuple& args, const boost::python::dictionary& void init_module() { - boost::python::module_builder test("test"); - init_module(test); + boost::python::module_builder boost_python_test("boost_python_test"); + init_module(boost_python_test); // Just for giggles, add a raw metaclass. - test.add(new boost::python::meta_class); + boost_python_test.add(new boost::python::meta_class); } extern "C" #ifdef _WIN32 __declspec(dllexport) #endif -void inittest() +void initboost_python_test() { try { bpl_test::init_module(); From 7208104122237e24eafd16f471ebc6eedf289e6b Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 4 Mar 2001 16:02:46 +0000 Subject: [PATCH 22/23] Changed name of extension module so it would work with DebugPython, fixed exception message checking to work with Python 2.0 [SVN r9421] --- test/comprehensive.py | 44 ++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/test/comprehensive.py b/test/comprehensive.py index 3c7f3c61..c8033575 100644 --- a/test/comprehensive.py +++ b/test/comprehensive.py @@ -7,6 +7,15 @@ r''' // The author gratefully acknowleges the support of Dragon Systems, Inc., in // producing this work. +// Revision History: +// 04 Mar 01 Changed name of extension module so it would work with DebugPython, +// fixed exception message checking to work with Python 2.0 +// (Dave Abrahams) + +Load up the extension module + + >>> from boost_python_test import * + Automatic checking of the number and type of arguments. Foo's constructor takes a single long parameter. @@ -17,9 +26,9 @@ a single long parameter. >>> try: ext = Foo('foo') ... except TypeError, err: - ... assert re.match( - ... '(illegal argument type for built-in operation)|(an integer is required)', str(err)) - ... else: print 'no exception' + ... assert_integer_expected(err) + ... else: + ... print 'no exception' >>> ext = Foo(1) @@ -209,7 +218,7 @@ Polymorphism also works: Pickling tests: >>> world.__module__ - 'test' + 'boost_python_test' >>> world.__safe_for_unpickling__ 1 >>> world.__reduce__() @@ -697,10 +706,11 @@ Testing interaction between callbacks, base declarations, and overloading >>> c = CallbackTest() >>> c.testCallback(1) 2 - >>> c.testCallback('foo') - Traceback (innermost last): - File "", line 1, in ? - TypeError: illegal argument type for built-in operation + + >>> try: c.testCallback('foo') + ... except TypeError, err: assert_integer_expected(err) + ... else: print 'no exception' + >>> c.callback(1) 2 >>> c.callback('foo') @@ -719,10 +729,11 @@ Testing interaction between callbacks, base declarations, and overloading -1 >>> r.callback('foo') 'foo 1' - >>> r.testCallback('foo') - Traceback (innermost last): - File "", line 1, in ? - TypeError: illegal argument type for built-in operation + + >>> try: r.testCallback('foo') + ... except TypeError, err: assert_integer_expected(err) + ... else: print 'no exception' + >>> r.testCallback(1) -1 >>> testCallback(r, 1) @@ -1145,8 +1156,15 @@ test methodologies for wrapping functions that return a pointer '6.35' ''' +#' + +def assert_integer_expected(err): + """Handle a common error report which appears differently in Python 1.5.x and 2.0""" + assert isinstance(err, TypeError) + message = str(err) + assert (message == "illegal argument type for built-in operation" + or message == "an integer is required") -from test import * import string import re import sys From 03dd2883f71fd8753148a3493ff4a70f909bd4f4 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Sun, 4 Mar 2001 17:39:14 +0000 Subject: [PATCH 23/23] file name change: test.so -> boost_python_test.so [SVN r9426] --- build/Makefile.linux_gcc | 8 ++++---- build/Makefile.mingw32 | 16 ++++++++-------- build/Makefile.tru64_cxx | 8 ++++---- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/build/Makefile.linux_gcc b/build/Makefile.linux_gcc index 3e8f1041..7021e221 100644 --- a/build/Makefile.linux_gcc +++ b/build/Makefile.linux_gcc @@ -79,7 +79,7 @@ DEPOBJ= $(OBJ) comprehensive.o abstract.o \ .SUFFIXES: .o .cpp -all: libbpl.a test.so abstract.so \ +all: libbpl.a boost_python_test.so abstract.so \ getting_started1.so getting_started2.so getting_started3.so \ getting_started4.so getting_started5.so @@ -111,8 +111,8 @@ libbpl.a: $(OBJ) rm -f libbpl.a ar r libbpl.a $(OBJ) -test.so: $(OBJ) comprehensive.o - $(LD) $(LDOPTS) $(OBJ) comprehensive.o -o test.so -lm +boost_python_test.so: $(OBJ) comprehensive.o + $(LD) $(LDOPTS) $(OBJ) comprehensive.o -o boost_python_test.so -lm abstract.so: $(OBJ) abstract.o $(LD) $(LDOPTS) $(OBJ) abstract.o -o abstract.so @@ -146,7 +146,7 @@ test: clean: rm -f $(OBJ) libbpl.a libbpl.a.input - rm -f comprehensive.o test.so + rm -f comprehensive.o boost_python_test.so rm -f abstract.o abstract.so rm -f getting_started1.o getting_started1.so rm -f getting_started2.o getting_started2.so diff --git a/build/Makefile.mingw32 b/build/Makefile.mingw32 index 2d86efcd..7c5f2c52 100644 --- a/build/Makefile.mingw32 +++ b/build/Makefile.mingw32 @@ -31,8 +31,8 @@ # Could this be fixed with compiler options? # -fhuge-objects looks interesting, but requires recompiling the C++ library. # (what exactly does that mean?) -# -fvtable-thunks eliminates the compiler warning, but "import test" still -# causes a crash. +# -fvtable-thunks eliminates the compiler warning, +# but "import boost_python_test" still causes a crash. BOOST_UNIX= /net/cci/rwgk/boost BOOST_WIN= "L:\boost" @@ -82,7 +82,7 @@ $(BPL_EXA)/test_getting_started4.py \ $(BPL_EXA)/test_getting_started5.py DEFS= \ -test \ +boost_python_test \ abstract \ getting_started1 \ getting_started2 \ @@ -96,7 +96,7 @@ OBJ = classes.o conversions.o extension_class.o functions.o \ .SUFFIXES: .o .cpp -all: libbpl.a test.pyd abstract.pyd \ +all: libbpl.a boost_python_test.pyd abstract.pyd \ getting_started1.pyd getting_started2.pyd getting_started3.pyd \ getting_started4.pyd getting_started5.pyd @@ -143,10 +143,10 @@ libbpl.a: $(OBJ) DLLWRAPOPTS= -s --driver-name g++ -s --entry _DllMainCRTStartup@12 --target=i386-mingw32 -test.pyd: $(OBJ) comprehensive.o +boost_python_test.pyd: $(OBJ) comprehensive.o dllwrap $(DLLWRAPOPTS) \ - --dllname test.pyd \ - --def test.def \ + --dllname boost_python_test.pyd \ + --def boost_python_test.def \ $(OBJ) comprehensive.o $(PYLIB) abstract.pyd: $(OBJ) abstract.o @@ -199,7 +199,7 @@ test: clean: rm -f $(OBJ) libbpl.a libbpl.a.input - rm -f comprehensive.o test.pyd + rm -f comprehensive.o boost_python_test.pyd rm -f abstract.o abstract.pyd rm -f getting_started1.o getting_started1.pyd rm -f getting_started2.o getting_started2.pyd diff --git a/build/Makefile.tru64_cxx b/build/Makefile.tru64_cxx index 7b932bd3..2b417944 100644 --- a/build/Makefile.tru64_cxx +++ b/build/Makefile.tru64_cxx @@ -79,7 +79,7 @@ DEPOBJ= $(OBJ) comprehensive.o abstract.o \ .SUFFIXES: .o .cpp -all: libbpl.a test.so abstract.so \ +all: libbpl.a boost_python_test.so abstract.so \ getting_started1.so getting_started2.so getting_started3.so \ getting_started4.so getting_started5.so @@ -115,8 +115,8 @@ libbpl.a: $(OBJ) rm -f libbpl.a.input ar r libbpl.a $(OBJ) -test.so: $(OBJ) comprehensive.o - $(LD) $(LDOPTS) $(OBJ) comprehensive.o -o test.so -lm +boost_python_test.so: $(OBJ) comprehensive.o + $(LD) $(LDOPTS) $(OBJ) comprehensive.o -o boost_python_test.so -lm abstract.so: $(OBJ) abstract.o $(LD) $(LDOPTS) $(OBJ) abstract.o -o abstract.so @@ -150,7 +150,7 @@ test: clean: rm -f $(OBJ) libbpl.a libbpl.a.input - rm -f comprehensive.o test.so + rm -f comprehensive.o boost_python_test.so rm -f abstract.o abstract.so rm -f getting_started1.o getting_started1.so rm -f getting_started2.o getting_started2.so