[Vala] enums



It is not possible to define an enum inside a class definition?

public class Foo.Bar
{
        enum Constants {
                OK       = 0,
                ERROR    = 1,
                INTERNAL = 2
        }
       ...

valac says: 

  "error: syntax error, unexpected enum"

So, i think that definitions like:

public class Foo.Bar
{
   enum {
    OK = 0,
    ERR = 1,
    INT = 2
   }
}

should be converted into defines like:
  #define FOO_BAR_OK 0
  #define FOO_BAR_ERR 1
...

this probably breaks the syntax transformation..so..maybe we should
be able to define anonymous enums and named enums like C does, but for vala:

 - Foo.Bar.OK
or
 - Foo.Bar.OK
 

Btw...it is possible to define the type for an enum? or are they always integers?

thanks

  --pancake



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]