2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-21 05:02:17 +00:00

fixed problem reported by Neal Becker; added a test case

[SVN r39223]
This commit is contained in:
Nikolay Mladenov
2007-09-12 21:31:39 +00:00
parent 5809078ba9
commit 62ef542eaf
2 changed files with 20 additions and 1 deletions

View File

@@ -106,7 +106,7 @@ struct object_manager_get_pytype<true>
PyObject* operator()(argument_type) const;
#ifndef BOOST_PYTHON_NO_PY_SIGNATURES
PyTypeObject const* get_pytype() const {return get_pytype((boost::type<T>*)0);}
PyTypeObject const* get_pytype() const {return get_pytype((boost::type<argument_type>*)0);}
#endif
// This information helps make_getter() decide whether to try to
// return an internal reference or not. I don't like it much,
@@ -114,6 +114,8 @@ struct object_manager_get_pytype<true>
BOOST_STATIC_CONSTANT(bool, uses_registry = false);
private:
#ifndef BOOST_PYTHON_NO_PY_SIGNATURES
template <class U>
PyTypeObject const* get_pytype(boost::type<shared_ptr<U> &> *) const {return converter::registered<U>::converters.to_python_target_type();}
template <class U>
PyTypeObject const* get_pytype(boost::type<const shared_ptr<U> &> *) const {return converter::registered<U>::converters.to_python_target_type();}
#endif

View File

@@ -43,6 +43,7 @@ struct functions
}
static shared_ptr<T> get() { return storage; }
static shared_ptr<T> &get1() { return storage; }
static int look_store()
{
@@ -71,6 +72,8 @@ struct functions
.staticmethod("identity")
.def("null", &null)
.staticmethod("null")
.def("get1", &get1, return_internal_reference<>())
.staticmethod("get1")
.def("get", &get)
.staticmethod("get")
.def("count", &T::count)
@@ -154,6 +157,14 @@ shared_ptr<Y> factory(int n)
// ------
// from Neal Becker
struct Test {
boost::shared_ptr<X> x;
};
// ------
BOOST_PYTHON_MODULE(shared_ptr_ext)
{
class_<A, boost::shared_ptr<A_Wrapper>, boost::noncopyable>("A")
@@ -193,6 +204,12 @@ BOOST_PYTHON_MODULE(shared_ptr_ext)
.def("value", &Z::value)
.def("v", &Z::v, &ZWrap::default_v)
);
// from Neal Becker
class_<Test> ("Test")
.def_readonly ("x", &Test::x, "x")
;
// ------
}
#include "module_tail.cpp"