Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => CodeCompletion redesign => Topic started by: killerbot on October 25, 2010, 11:02:59 am

Title: strong enum support
Post by: killerbot on October 25, 2010, 11:02:59 am
Could our CC gurus have a quick look on the effort needed to support strong enums types (feature from C++0x).

Here's a little code snippet :

Code
enum class StrongEnum1
{
    on,
    off
};

enum class StrongEnum2
{
    on,
    off
};

int main()
{
    StrongEnum1 value1;
    value1 = StrongEnum1::on;

    return 0;
}

Current situation.

While typing the line "value1 = StrongEnum1::on;" :
- StrongEnum1 does not give a completion suggestion, due to this it has to be typed completely manually
- StrongEnum1:: does not provide a suggestion list of the possible enum values.

What do you guys think ?
Title: Re: strong enum support
Post by: Loaden on October 25, 2010, 01:08:15 pm
supported in rev6759. :)
Title: Re: strong enum support
Post by: killerbot on October 25, 2010, 08:10:21 pm
it works perfectly :-)

Super great.
Title: Re: strong enum support
Post by: killerbot on December 19, 2010, 09:52:26 am
just found one little hickup.

When I tooltip over the enum class type, the tooltip shows 2 things :

enum Foo {}
class Foo {}


where it should only show :

enum class Foo {}

Note from time to time, it only says enum Foo. A bit weird.

NOtice something else, when hovering over a struct it also says :
class FooStruct, where I guess we should say : struct FooStruct , right ?
Title: Re: strong enum support
Post by: ollydbg on December 19, 2010, 02:10:44 pm
just found one little hickup.

When I tooltip over the enum class type, the tooltip shows 2 things :

enum Foo {}
class Foo {}


where it should only show :

enum class Foo {}

Note from time to time, it only says enum Foo. A bit weird.


should show "enum Foo". I just reviewed the rev6759, loaden just eat the "class" keyword after enum. so

Code
enum class StrongEnum1
{
    on,
    off
};

is indeed becomes:
Code
enum StrongEnum1
{
    on,
    off
};



Code
NOtice something else, when hovering over a struct it also says : 
class FooStruct, where I guess we should say : struct FooStruct , right ?
confirmed, I think this can be fixed easily, I will look into it right now.
Title: Re: strong enum support
Post by: ollydbg on December 19, 2010, 02:24:01 pm

Code
NOtice something else, when hovering over a struct it also says : 
class FooStruct, where I guess we should say : struct FooStruct , right ?
confirmed, I think this can be fixed easily, I will look into it right now.

oh, I found that there is not "struct" Token...

see the declaration:
Code
enum TokenKind
{
    // changed in order to reflect the priority
    tkNamespace     = 0x0001,
    tkClass         = 0x0002,
    tkEnum          = 0x0004,
    tkTypedef       = 0x0008, // typedefs are stored as classes inheriting from the typedef'd type (taking advantage of existing inheritance code)
    tkConstructor   = 0x0010,
    tkDestructor    = 0x0020,
    tkFunction      = 0x0040,
    tkVariable      = 0x0080,
    tkEnumerator    = 0x0100,
    tkPreprocessor  = 0x0200,
    tkMacro         = 0x0400,

    // convenient masks
    tkAnyContainer  = tkClass    | tkNamespace   | tkTypedef,
    tkAnyFunction   = tkFunction | tkConstructor | tkDestructor,

    // undefined or just "all"
    tkUndefined     = 0xFFFF
};

so, the "struct" is recorded as "class"...

not easy to change, because we need to change a lot if we add a new "struct" type.