S
Shawn McGrath
Hi, I'm trying to expose a C++ class' internals to python via
boost:ython. I can do integer/boolean functions fine, but as soon
as I do a string get/set it craps out.
boost:ython::class_<Entity, std::auto_ptr<pyEntity> >("Entity")
//publics
.def("isActive", &Entity::isActive) //bool
.def("activate", &Entity::activate) //bool
.def("deactivate", &Entity::deactivate) //bool
//...
.add_property("name", &Entity::getName) //compile error (1)
.def("getName", &Entity::getName,
boost:ython::return_internal_reference<>()); //runtime error(2)
Compile error (1) shows this: C:/MinGW/include/boost/python/detail/
invoke.hpp: In function `PyObject*
boost:ython::detail::invoke(boost:ython::detail::invoke_tag_<
false, true>, const RC&, F&, TC&) [with RC =
boost:ython::detail::specify_a_return_value_policy_to_wrap_functions_returning<const
std::string&>, F = const std::string&(rsblsb::Entity::*)() const, TC =
boost:ython::arg_from_python<rsblsb::Entity&>]':
C:/MinGW/include/boost/python/detail/caller.hpp:199: instantiated
from `PyObject* boost:ython::detail::caller_arity<1u>::impl<F,
Policies, Sig>:perator()(PyObject*, PyObject*) [with F = const
std::string&(rsblsb::Entity::*)() const, Policies =
boost:ython::default_call_policies, Sig = boost::mpl::vector2<const
std::string&, rsblsb::Entity&>]'
C:/MinGW/include/boost/python/object/py_function.hpp:38:
instantiated from `PyObject*
boost:ython:bjects::caller_py_function_impl<Caller>:perator()
(PyObject*, PyObject*) [with Caller =
boost:ython::detail::caller<const std::string&(rsblsb::Entity::*)()
const, boost:ython::default_call_policies, boost::mpl::vector2<const
std::string&, rsblsb::Entity&> >]'
C:\Game\svn\Platform\Framework\Python\PyModuleSetup.cc:58:
instantiated from here
C:/MinGW/include/boost/python/detail/invoke.hpp:88: error: no match
for call to `(const
boost:ython::detail::specify_a_return_value_policy_to_wrap_functions_returning<const
std::string&>) (const std::basic_string<char, std::char_traits<char>,
std::allocator<char> >&)'
Runtime error 2 just crashes whenever I try:
import modulename
I = modulename.Entity()
I.getName()
Anyone have any idea what I can try? thanks a lot!
-Shawn.
boost:ython. I can do integer/boolean functions fine, but as soon
as I do a string get/set it craps out.
boost:ython::class_<Entity, std::auto_ptr<pyEntity> >("Entity")
//publics
.def("isActive", &Entity::isActive) //bool
.def("activate", &Entity::activate) //bool
.def("deactivate", &Entity::deactivate) //bool
//...
.add_property("name", &Entity::getName) //compile error (1)
.def("getName", &Entity::getName,
boost:ython::return_internal_reference<>()); //runtime error(2)
Compile error (1) shows this: C:/MinGW/include/boost/python/detail/
invoke.hpp: In function `PyObject*
boost:ython::detail::invoke(boost:ython::detail::invoke_tag_<
false, true>, const RC&, F&, TC&) [with RC =
boost:ython::detail::specify_a_return_value_policy_to_wrap_functions_returning<const
std::string&>, F = const std::string&(rsblsb::Entity::*)() const, TC =
boost:ython::arg_from_python<rsblsb::Entity&>]':
C:/MinGW/include/boost/python/detail/caller.hpp:199: instantiated
from `PyObject* boost:ython::detail::caller_arity<1u>::impl<F,
Policies, Sig>:perator()(PyObject*, PyObject*) [with F = const
std::string&(rsblsb::Entity::*)() const, Policies =
boost:ython::default_call_policies, Sig = boost::mpl::vector2<const
std::string&, rsblsb::Entity&>]'
C:/MinGW/include/boost/python/object/py_function.hpp:38:
instantiated from `PyObject*
boost:ython:bjects::caller_py_function_impl<Caller>:perator()
(PyObject*, PyObject*) [with Caller =
boost:ython::detail::caller<const std::string&(rsblsb::Entity::*)()
const, boost:ython::default_call_policies, boost::mpl::vector2<const
std::string&, rsblsb::Entity&> >]'
C:\Game\svn\Platform\Framework\Python\PyModuleSetup.cc:58:
instantiated from here
C:/MinGW/include/boost/python/detail/invoke.hpp:88: error: no match
for call to `(const
boost:ython::detail::specify_a_return_value_policy_to_wrap_functions_returning<const
std::string&>) (const std::basic_string<char, std::char_traits<char>,
std::allocator<char> >&)'
Runtime error 2 just crashes whenever I try:
import modulename
I = modulename.Entity()
I.getName()
Anyone have any idea what I can try? thanks a lot!
-Shawn.