<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'><div dir='ltr'>
Self is indeed a PyObject* <br><br>this is a bit confusing<br><br><div>> Date: Fri, 26 Aug 2011 13:00:11 -0700<br>> From: talljimbo@gmail.com<br>> To: cplusplus-sig@python.org<br>> Subject: Re: [C++-sig] Boost Python loss of values<br>> <br>> On 08/26/2011 08:27 AM, Jay Riley wrote:<br>> > Hi Jim,<br>> ><br>> > Thanks for the suggestion, unfortunately it didn't work. It really feels<br>> > like it's making a copy for some reason as once I return to the<br>> ><br>> > int AttackWrapper::CalculateDamage(const<br>> > std::vector<Game::Battles::BattleCharacter*>& users,<br>> > Game::Battles::BattleCharacter* target, const<br>> > std::vector<Actions::ActionTarget>& targets, Game::Battles::BattleField<br>> > *field)<br>> > {<br>> > return call_method<int>(self, "CalculateDamage", users, ptr(target),<br>> > targets, ptr(field));<br>> > }<br>> ><br>> > function, the value are back to their expected value. Slicing wouldn't<br>> > be a problem here would it, since Hit is a member of the base class anyways?<br>> ><br>> <br>> Yes, that's right. What exactly is "self", above? I assume it's a data <br>> member of AttackWrapper of type PyObject *, which shouldn't produce a <br>> copy, but if it's something else, well, that could be a factor.<br>> <br>> Jim<br>> <br>> <br>> <br>> > > Date: Thu, 25 Aug 2011 13:18:04 -0700<br>> > > From: talljimbo@gmail.com<br>> > > To: cplusplus-sig@python.org<br>> > > CC: super24bitsound@hotmail.com<br>> > > Subject: Re: [C++-sig] Boost Python loss of values<br>> > ><br>> > > On 08/25/2011 04:17 AM, Jay Riley wrote:<br>> > ><br>> > > ><br>> > > > And the python exposing is done as follows:<br>> > > ><br>> > > > class_<Attack, AttackWrapper, boost::shared_ptr<Attack>, bases<Action><br>> > > > >("Attack")<br>> > > > .def("CalculateDamage", &AttackWrapper::CalculateDamageDefault);<br>> > > ><br>> > ><br>> > > This bit looks a little suspect, and I'm surprised that it compiles -<br>> > > class_ should only take 4 arguments if one of them is boost::noncopyable.<br>> > ><br>> > > I think you mean:<br>> > ><br>> > > class_< Attack, boost::shared_ptr<AttackWrapper>, bases<Action> ><br>> > > (...)<br>> > ><br>> > > See<br>> > ><br>> > > http://www.boost.org/doc/libs/1_47_0/libs/python/doc/v2/class.html<br>> > ><br>> > > for details of the arguments to class_.<br>> > ><br>> > > I don't have a good idea as to why this would cause the problem you're<br>> > > seeing (maybe you're slicing your AttackWrapper instances into Attack<br>> > > instances?) but I'd recommend fixing it first.<br>> > ><br>> > > Good Luck!<br>> > ><br>> > > Jim Bosch<br>> ><br>> ><br>> > _______________________________________________<br>> > Cplusplus-sig mailing list<br>> > Cplusplus-sig@python.org<br>> > http://mail.python.org/mailman/listinfo/cplusplus-sig<br>> <br>> _______________________________________________<br>> Cplusplus-sig mailing list<br>> Cplusplus-sig@python.org<br>> http://mail.python.org/mailman/listinfo/cplusplus-sig<br></div>                                            </div></body>
</html>