[C++-sig] pybindgen: allow_subclassing option causing reference parameters to be copied?

Gustavo Carneiro gjcarneiro at gmail.com
Tue Jul 7 17:27:40 CEST 2009


2009/7/2 J. Michael Owen <mikeowen at llnl.gov>

> I pulled down your bazaar branch and merged it with my own changes (I need
> to use the container methods, inplace numeric operators, and numeric
> operators with built in python  types, so I have to keep using my changes
> for now), and now reference parameters are working just fine.  Great!
>

I just pushed your merged contribution with some fixes and unit tests to
bazaar trunk.


>
> Since the code I'm binding has probably thousands of reference parameters
> to expose, I've written little helper methods as shorthand for the long
> parameter definition.  This is probably a little specialized for what you
> want, but it might be helpful to include something like these (akin to the
> "param" method you already have in utils):
>

To be frank I don't like this. refparam does not give any hint that it
specifies direction inout for the parameter.  I don't think it's worth to
merge this.


>
> def refparam(cppobj, argname):
>     return Parameter.new("%s&" % cppobj, argname,
> direction=Parameter.DIRECTION_INOUT)
>
> def constrefparam(cppobj, argname):
>     return Parameter.new(ref("const %s&" % cppobj), argname,
> direction=Parameter.DIRECTION_INOUT)
>
> So on those changes I have for the pybindgen code (allowing the stuff I
> mention above), I'd be happy to modify them to fit in better with how you
> want pybindgen to look if you'd like to give me an idea what you're looking
> for.
>
> On Jun 30, 2009, at 6:29 AM, Gustavo Carneiro wrote:
>
>
> Ah, right.  The thing is, the code tries to make a copy of the object to
> give to the python wrapper in case it appears the python code kept a
> reference to the wrapper.
>
> I need to fix pybindgen to, if the class has no copy constructor keep the
> wrapper->obj pointer NULL instead of giving it a copy.
>
> The fix has been pushed to the bazaar branch.  See https://
> code.launchpad.net/~gjc/pybindgen/trunk<https://+code.launchpad.net/%7Egjc/pybindgen/trunk>
>
>
>
> _______________________________________________
> Cplusplus-sig mailing list
> Cplusplus-sig at python.org
> http://mail.python.org/mailman/listinfo/cplusplus-sig
>



-- 
Gustavo J. A. M. Carneiro
INESC Porto, Telecommunications and Multimedia Unit
"The universe is always one step beyond logic." -- Frank Herbert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20090707/a381946b/attachment-0001.htm>


More information about the Cplusplus-sig mailing list