cgo: add support for enum types

Enum types are implemented as named types (with possible accompanying
typedefs as type aliases). The constants inside the enums are treated as
Go constants like in the Go toolchain.
This commit is contained in:
Ayke van Laethem
2019-05-16 22:16:58 +02:00
committed by Ron Evans
parent 82dc14b741
commit dfa713040a
7 changed files with 159 additions and 0 deletions
+19
View File
@@ -47,6 +47,24 @@ void unionSetShort(short s);
void unionSetFloat(float f);
void unionSetData(short f0, short f1, short f2);
typedef enum option {
optionA,
optionB,
optionC = -5,
optionD,
optionE = 10,
optionF,
optionG,
} option_t;
typedef enum {
option2A = 20,
} option2_t;
typedef enum {
option3A = 21,
} option3_t;
// test globals and datatypes
extern int global;
extern int unusedGlobal;
@@ -66,6 +84,7 @@ extern int globalStructSize;
extern short globalArray[3];
extern joined_t globalUnion;
extern int globalUnionSize;
extern option_t globalOption;
// test duplicate definitions
int add(int a, int b);