On Wednesday, May 30, 2012 11:33:54 AM John Cummings wrote:
> I uncovered a bug with the latest Shiboken when passing an enum by
> reference. Like Nathan, I have a bug report ready to go when the system
> comes back up.
> 
> In previous versions, you could pass an enum by reference to a method like
> so:
> 
> class Val
> {
> enum ValEnum { One, Other };
> ValEnum oneOrTheOtherEnumValue(ValEnum& enumValue) { return enumValue == One
> ? Other : One; }
> }
> 
> You get compilation errors with version 1.1.1 and with HEAD. The generated
> code is trying to use a pointer instead of reference. Previous version of
> Shiboken worked just fine (specifically, 1.0.7 worked, I'm not sure about
> other versions until 1.1.1).
> 
> Unlike Nathan, I don't have a patch ready. The workaround is obviously to
> pass an enum by value not by reference (which is admittedly a bit overkill
> anyway). If someone knows of a better solution, I'm willing to try it.

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 
:-/.


 
> John Cummings
> _______________________________________________
> PySide mailing list
> [email protected]
> http://lists.qt-project.org/mailman/listinfo/pyside

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
PySide mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/pyside

Reply via email to