Kenaz enum
Enum Specification
Enum allows the creation of typed constant set: 
enum testEnum
{
    val1,
    val2 = 15,
    val3 = 20
}
Both enum and enum element are metadata container, meaning that you can associate metadata with them. As shown in the previous example, enum resolves to integer, and you can specify the particular value of an enum element

When using an enum element in your code, you have to give its full qualified name, for exemple :
testEnum a  = val1;          // invalid
testEnum a2 = testEnum.val1; // valid
Unlike C++ enum, Kenaz enum cannot be converted to int.
Api output of an enum
If you specify the apiOutput metadata to your enum, kenaz will export the enum into C++ enum, with some modification. C++ enum and Kenaz enum differs in that that in kenaz you have to give the fully qualified name of an enum element to access it while in C++ enum are stored in the global scope (or the parent scope in the case of nested enum). If we perform a direct translation from Kenaz enum to C++ enum, we may encounter conflict when differents enum type define the same element :
enum A
{
    v,
    v2
}

enum B
{
    v, //no conflict in Kenaz, but in C++
    v3
}

To adress this issue, the Kenaz compiler uses the C++ namespace :
namespace KzAPI
{
   namespace A
   {
      enum KZA      
      {
           v  = 0,
           v2 = 1,
      };
   }
   using A::KZA;
}
The using directive is here to simplify the use of Kenaz type ( KzAPI::KZA instead of kzAPI::A::KZA). 




top of page