On 08/26/2011 08:27 AM, Jay Riley wrote:
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?


Yes, that's right. What exactly is "self", above? I assume it's a data member of AttackWrapper of type PyObject *, which shouldn't produce a copy, but if it's something else, well, that could be a factor.

Jim



 > Date: Thu, 25 Aug 2011 13:18:04 -0700
 > From: tallji...@gmail.com
 > To: cplusplus-sig@python.org
 > CC: super24bitso...@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


_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to