aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2013-08-27 21:56:44 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2013-09-02 09:13:14 +0100
commitff0a16dfb8910dfd90038cfbf86b43b4629246a5 (patch)
treeea664bde31f7d8d928e8df84652aa4e3b9ece4b4
parent179071d7a3696a51ec8b28ac50acb70fc58c963e (diff)
downloadpaludis-ff0a16dfb8910dfd90038cfbf86b43b4629246a5.tar.gz
paludis-ff0a16dfb8910dfd90038cfbf86b43b4629246a5.tar.xz
Another attempt at new Boost compatibility
Instead of weird hacks with const_cast that aren't compatible with Boost's get_pointer implementation for shared_ptr, use non-const pointers as the representation and register conversions, like most of the classes did already.
-rw-r--r--python/choices.cc9
-rw-r--r--python/dep_spec.cc3
-rw-r--r--python/paludis_python.hh14
3 files changed, 8 insertions, 18 deletions
diff --git a/python/choices.cc b/python/choices.cc
index 18287ef..b4658da 100644
--- a/python/choices.cc
+++ b/python/choices.cc
@@ -30,7 +30,8 @@ namespace bp = boost::python;
void expose_choices()
{
- bp::class_<Choices, std::shared_ptr<const Choices>, boost::noncopyable> choices(
+ register_shared_ptrs_to_python<Choices>(rsp_const);
+ bp::class_<Choices, std::shared_ptr<Choices>, boost::noncopyable> choices(
"Choices",
"A collection of configurable values for a PackageID",
bp::init<>("__init__()")
@@ -50,7 +51,8 @@ void expose_choices()
)
;
- bp::class_<Choice, std::shared_ptr<const Choice>, boost::noncopyable> choice(
+ register_shared_ptrs_to_python<Choice>(rsp_const);
+ bp::class_<Choice, std::shared_ptr<Choice>, boost::noncopyable> choice(
"Choice",
"An individual choice in a Choices collection.",
bp::no_init
@@ -90,7 +92,8 @@ void expose_choices()
)
;
- bp::class_<ChoiceValue, std::shared_ptr<const ChoiceValue>, boost::noncopyable> choice_value(
+ register_shared_ptrs_to_python<ChoiceValue>(rsp_const);
+ bp::class_<ChoiceValue, std::shared_ptr<ChoiceValue>, boost::noncopyable> choice_value(
"ChoiceValue",
"An individual value in a ChoiceValue",
bp::no_init
diff --git a/python/dep_spec.cc b/python/dep_spec.cc
index 7e10916..dbf6066 100644
--- a/python/dep_spec.cc
+++ b/python/dep_spec.cc
@@ -1220,12 +1220,13 @@ void expose_dep_spec()
"Create a PackageDepSpec from user input."
);
+ register_shared_ptrs_to_python<PythonPackageDepSpec>(rsp_const);
bp::implicitly_convertible<PythonPackageDepSpec, PackageDepSpec>();
bp::implicitly_convertible<PythonPackageDepSpec, std::shared_ptr<PackageDepSpec> >();
bp::implicitly_convertible<std::shared_ptr<PackageDepSpec>, std::shared_ptr<const PackageDepSpec> >();
RegisterDepSpecToPython<PackageDepSpec, PythonPackageDepSpec>();
- bp::class_<PythonPackageDepSpec, std::shared_ptr<const PythonPackageDepSpec>, bp::bases<PythonStringDepSpec> >
+ bp::class_<PythonPackageDepSpec, std::shared_ptr<PythonPackageDepSpec>, bp::bases<PythonStringDepSpec> >
(
"PackageDepSpec",
"A PackageDepSpec represents a package name (for example, 'app-editors/vim'),"
diff --git a/python/paludis_python.hh b/python/paludis_python.hh
index 9c6678b..0691fee 100644
--- a/python/paludis_python.hh
+++ b/python/paludis_python.hh
@@ -38,13 +38,6 @@ namespace paludis
{
return p.get();
}
-
- // Make Boost.Python work with std::shared_ptr<const>
- template <typename T_>
- inline T_ * get_pointer(std::shared_ptr<const T_> const & p)
- {
- return const_cast<T_*>(p.get());
- }
}
#endif
@@ -58,13 +51,6 @@ namespace boost
{
typedef T_ type;
};
-
- // Make Boost.Python work with std::shared_ptr<const>
- template <typename T_>
- struct pointee<std::shared_ptr<const T_> >
- {
- typedef T_ type;
- };
}
}