[PyKDE] Re: PyKDE Digest, Vol 6, Issue 5

Phil Thompson phil at riverbankcomputing.co.uk
Tue Jan 11 10:44:40 GMT 2005


> It looks like a clarification of C++ is in order.
>>>
>>> I would expect that one can pass a Python int as well as a SIP-4.2
>>> enum
>>> argument into an enum parameter of a function wrapped by SIP (a C++
>>> function with a C++ enum parameter accepts C++ int arguments).
>
> That is incorrect.  C++ will NOT accept an int when a function has an
> enum parameter.  However, if the function takes an int it WILL allow an
> enum.  This is because C++ will convert and enum into an int, but not
> an int into an enum.  This is part of its type safety features.
>
>
>> Ok, I've had second thoughts about this - the idiom of oring enum
>> values is
>> too common. Tonight's SIP snapshot will allow an integer whereever an
>> enum is
>> expected. I can still get QListBox.setColumnMode() to work properly,
>> which
>> was the original intent of the change.
>>
> The 'or'ing together of enums to form an argument to a function is
> common, but if you look, the function signature takes an 'int' and not
> the enum.  When this is done, the enum is just being used as a symbolic
> constant and its type is usually irrelevant.

Ok, I've now had third thoughts about this after realising that the
exceptions I was seeing with the strict checking were bugs in the examples
I was using, and not related to the oring of enums. Strict checking will
go back into the next snapshot.

There will be a SIP v4.2rc1 before the final release of v4.2 to give
people a final opportunity to change my mind (again).

Phil




More information about the PyQt mailing list