Skip to content

Commit

Permalink
Add missing converter.
Browse files Browse the repository at this point in the history
  • Loading branch information
moriyoshi committed May 31, 2011
1 parent 0f22790 commit 0bec713
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions binding/reaction_recorder_converter.hpp
Expand Up @@ -30,7 +30,7 @@ class ReactionRecorderWrapper: public Tbase_
};

template<typename Tbase_>
struct reaction_recorder_converter
struct reaction_recorder_lvalue_converter
{
typedef ReactionRecorderWrapper<Tbase_> native_type;

Expand All @@ -57,13 +57,39 @@ struct reaction_recorder_converter
}
};

template<typename Tbase_>
struct reaction_recorder_converter
{
typedef boost::shared_ptr<Tbase_> native_type;

static void* convertible(PyObject* ptr)
{
if (!PyCallable_Check(ptr))
{
return NULL;
}

return ptr;
}

static void construct(PyObject* ptr,
boost::python::converter::rvalue_from_python_storage<native_type>* data)
{
data->stage1.convertible =
new(data->storage.bytes) native_type(
new ReactionRecorderWrapper<Tbase_>(
static_cast<PyObject*>(data->stage1.convertible)));
}
};

template<typename Timpl_>
void register_reaction_recorder_converter()
{
using namespace boost::python;
typedef Timpl_ impl_type;

peer::util::to_native_lvalue_converter<impl_type, reaction_recorder_converter<impl_type> >();
peer::util::to_native_lvalue_converter<impl_type, reaction_recorder_lvalue_converter<impl_type> >();
peer::util::to_native_converter<boost::shared_ptr<impl_type>, reaction_recorder_converter<impl_type> >();
}

} // namespace binding
Expand Down

0 comments on commit 0bec713

Please sign in to comment.