2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-22 17:32:55 +00:00

factored out find_instance

[SVN r13181]
This commit is contained in:
Dave Abrahams
2002-03-12 20:43:42 +00:00
parent 23769371bc
commit 0bdf3542e4
2 changed files with 2 additions and 17 deletions

View File

@@ -65,20 +65,6 @@ struct instance
instance_holder* objects;
};
// Given an undecorated type_id, find the instance data which
// corresponds to it, or return 0 in case no such type is held.
BOOST_PYTHON_DECL void* find_instance_impl(PyObject*, converter::undecorated_type_id_t);
// This produces a function with the right signature for use in from_python conversions
template <class T>
struct instance_finder
{
static inline void* execute(PyObject* p)
{
return find_instance_impl(p, converter::undecorated_type_id<T>());
}
};
BOOST_PYTHON_DECL ref class_metatype();
BOOST_PYTHON_DECL ref class_type();

View File

@@ -10,6 +10,7 @@
# include <boost/mpl/for_each.hpp>
# include <boost/python/reference.hpp>
# include <boost/python/converter/registry.hpp>
# include <boost/python/object/find_instance.hpp>
namespace boost { namespace python { namespace objects {
@@ -89,9 +90,7 @@ template <class Derived, class Bases>
class_converters<Derived,Bases>::class_converters(ref const& type_object)
: m_wrapper(type_object)
{
converter::registry::insert(
&instance_finder<Derived>::execute
, converter::undecorated_type_id<Derived>());
(void)instance_finder<Derived>::registration;
// register all up/downcasts here
register_dynamic_id<Derived>();