[PySide] Cannot pass enum by reference

Hugo Parente Lima hugo.lima at openbossa.org
Wed May 30 22:32:29 CEST 2012


On Wednesday, May 30, 2012 01:50:39 PM John Cummings wrote:
> On 05/30/2012 01:09 PM, Hugo Parente Lima wrote:
> > It can be passed by value unless it's a const reference, otherwise the
> > following code wont work.
> > 
> > enum ValEnum { One, Other };
> > void oneOrTheOtherEnumValue(ValEnum&  enumValue) {
> > 
> >      enumValue = Other;
> > 
> > }
> > 
> > ValEnum a = One;
> > oneOrTheOtherEnumValue(a);
> > // a should be equal to Other.
> > 
> > This is why Shiboken tries to use a pointer, but the code seems wrong
> > anyway> 
> > :-/.
> 
> The subject of the thread was incorrect before. Sorry for the confusion.
> 
> Your statement "It can be passed by value unless it's a const reference" is
> circular. Passing by value is by definition not passing by reference.
> Perhaps I don't understand your statement.

What I meant was:

If the library function being bound has a const reference parameter, we can 
internally copy this value around and this will not affect the API of the bound 
library. But if the reference isn't const, the generated code can't pass this 
parameter by value in any place because it'll change the API behavior, i.e. if 
the function changes the parameter, the change wont be visible after the 
function call.

This is why Shiboken uses pointers on non-const references, but as you noticed 
it's buggy and generating broken code.

 
> It also doesn't matter if the reference is const or not in this case, the
> current Shiboken still does not create a correct wrapper. Old versions did.
> 
> John Cummings
> _______________________________________________
> PySide mailing list
> PySide at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/pyside
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20120530/9a858b46/attachment.sig>


More information about the PySide mailing list