News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

strong enum support

Started by killerbot, October 25, 2010, 11:02:59 AM

Previous topic - Next topic

killerbot

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 :


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 ?

Loaden


killerbot

it works perfectly :-)

Super great.

killerbot

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 ?

ollydbg

Quote from: 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.


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

enum class StrongEnum1
{
    on,
    off
};


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




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.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

ollydbg

Quote from: ollydbg on December 19, 2010, 02:10:44 PM

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:
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.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.