[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] Partial support for scoped enums
From:       Phil Thompson <phil () riverbankcomputing ! com>
Date:       2017-08-11 14:46:25
Message-ID: 2EEDC931-2C6F-459F-80FD-5B42D0C325EF () riverbankcomputing ! com
[Download RAW message or body]

On 10 Aug 2017, at 1:59 pm, Shaheed Haque <srhaque@theiet.org> wrote:
> 
> Hi,
> 
> I think that SIP makes a partial attempt to support so-called "scoped enums" in \
> gencode.c in that enums are emitted with a static_cast<int> like this: 
> static sipEnumMemberDef enummembers_KWindowSystem[] = {
> {sipName_ClassHint, static_cast<int>( ::KWindowSystem::ClassHint), 15},
> {sipName_NETWM, static_cast<int>( ::KWindowSystem::NETWM), 15},
> {sipName_Unknown, static_cast<int>( ::KWindowSystem::Unknown), 16},
> {sipName_WMHints, static_cast<int>( ::KWindowSystem::WMHints), 15},
> {sipName_Wayland, static_cast<int>( ::KWindowSystem::Wayland), 16},
> {sipName_X11, static_cast<int>( ::KWindowSystem::X11), 16},
> {sipName_XApp, static_cast<int>( ::KWindowSystem::XApp), 15},
> };
> 
> However, there are a couple of parts missing. One missing part is that the emitted \
> code has two calls to "sipConvertFromEnum()", and I think that each call needs a \
> similar static_cast<int> applied to the first argument.

That will be fixed in tonight's snapshot.

> I'm not so sure about the fix for the second missing part. Looking at the above set \
> of enums. It turns out that ::KWindowSystem::{Unknown,Wayland,X11} actually should \
> be emitted as ::KWindowSystem::Platform::{Unknown,Wayland,X11} as that is a scoped \
> enum in the C++ code: 
> enum class Platform {
> Unknown,
> X11,
> Wayland
> };
> 
> The relevant logic is near line sipgen.c:3270 (in 4.19.4.dev1708081632) and the \
> correct prefix is available in the data: 
> (gdb) p *emd->ed.cname
> $49 = {nameflags = 1, text = 0x5555582be010 "KWindowSystem::Platform", len = 23, \
> offset = 634, next = 0x5555582bc880} 
> However, the code presently ends up calling 'prcode(fp, "%S::", classFQCName(ecd))' \
> for the result as above. I am unclear as to the correct change to the logic around \
> here though. 
> It would be great to get these two fixed (I have a trivial patch for the first part \
> if needed).

It's a bit more complicated than that. I'll talk about it in a separate posting.

Phil
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
https://www.riverbankcomputing.com/mailman/listinfo/pyqt


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic