[C++-sig] Boost Python loss of values
Jay Riley
super24bitsound at hotmail.com
Fri Aug 26 17:27:51 CEST 2011
Hi Jim,
Thanks for the suggestion, unfortunately it didn't work. It really feels like it's making a copy for some reason as once I return to the
int AttackWrapper::CalculateDamage(const
std::vector<Game::Battles::BattleCharacter*>& users,
Game::Battles::BattleCharacter* target, const
std::vector<Actions::ActionTarget>& targets,
Game::Battles::BattleField *field)
{
return call_method<int>(self, "CalculateDamage", users, ptr(target), targets, ptr(field));
}
function, the value are back to their expected value. Slicing wouldn't be a problem here would it, since Hit is a member of the base class anyways?
> Date: Thu, 25 Aug 2011 13:18:04 -0700
> From: talljimbo at gmail.com
> To: cplusplus-sig at python.org
> CC: super24bitsound at hotmail.com
> Subject: Re: [C++-sig] Boost Python loss of values
>
> On 08/25/2011 04:17 AM, Jay Riley wrote:
>
> >
> > And the python exposing is done as follows:
> >
> > class_<Attack, AttackWrapper, boost::shared_ptr<Attack>, bases<Action>
> > >("Attack")
> > .def("CalculateDamage", &AttackWrapper::CalculateDamageDefault);
> >
>
> This bit looks a little suspect, and I'm surprised that it compiles -
> class_ should only take 4 arguments if one of them is boost::noncopyable.
>
> I think you mean:
>
> class_< Attack, boost::shared_ptr<AttackWrapper>, bases<Action> >
> (...)
>
> See
>
> http://www.boost.org/doc/libs/1_47_0/libs/python/doc/v2/class.html
>
> for details of the arguments to class_.
>
> I don't have a good idea as to why this would cause the problem you're
> seeing (maybe you're slicing your AttackWrapper instances into Attack
> instances?) but I'd recommend fixing it first.
>
> Good Luck!
>
> Jim Bosch
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20110826/d35f7973/attachment.html>
More information about the Cplusplus-sig
mailing list