Tests for enhancements
This commit is contained in:
parent
34cb1715b8
commit
1684e773ad
4 changed files with 21 additions and 4 deletions
|
|
@ -12,9 +12,9 @@ proc sanitizePath*(path: string): string =
|
||||||
proc getIdentifier*(str: string): string =
|
proc getIdentifier*(str: string): string =
|
||||||
result = str.strip(chars={'_'})
|
result = str.strip(chars={'_'})
|
||||||
|
|
||||||
proc getUniqueIdentifier*(exists: seq[string]): string =
|
proc getUniqueIdentifier*(exists: seq[string], prefix = ""): string =
|
||||||
var
|
var
|
||||||
name = gStateRT.sourceFile.extractFilename().multiReplace([(".", ""), ("-", "")])
|
name = prefix & "_" & gStateRT.sourceFile.extractFilename().multiReplace([(".", ""), ("-", "")])
|
||||||
count = 1
|
count = 1
|
||||||
|
|
||||||
while (name & $count) in exists:
|
while (name & $count) in exists:
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,7 @@ proc initGrammar() =
|
||||||
nname = name.getIdentifier()
|
nname = name.getIdentifier()
|
||||||
|
|
||||||
if nname.len == 0:
|
if nname.len == 0:
|
||||||
nname = getUniqueIdentifier(gStateRT.types)
|
nname = getUniqueIdentifier(gStateRT.types, "Enum")
|
||||||
|
|
||||||
if nname notin gStateRT.types:
|
if nname notin gStateRT.types:
|
||||||
gStateRT.types.add(nname)
|
gStateRT.types.add(nname)
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,18 @@ typedef enum {
|
||||||
enum6
|
enum6
|
||||||
} ENUM2;
|
} ENUM2;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
enum7,
|
||||||
|
enum8,
|
||||||
|
enum9
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef enum ENUM4 {
|
||||||
|
enum10,
|
||||||
|
enum11,
|
||||||
|
enum12
|
||||||
|
} ENUM4;
|
||||||
|
|
||||||
typedef void * VOIDPTR;
|
typedef void * VOIDPTR;
|
||||||
typedef int * INTPTR;
|
typedef int * INTPTR;
|
||||||
|
|
||||||
|
|
@ -41,7 +53,7 @@ union UNION1 {
|
||||||
float field2;
|
float field2;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef union {
|
typedef union UNION2 {
|
||||||
double field1;
|
double field1;
|
||||||
unsigned char field2;
|
unsigned char field2;
|
||||||
} UNION2;
|
} UNION2;
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,8 @@ var
|
||||||
|
|
||||||
e: ENUM
|
e: ENUM
|
||||||
e2: ENUM2 = enum5
|
e2: ENUM2 = enum5
|
||||||
|
e3: Enum_testh1 = enum7
|
||||||
|
e4: ENUM4 = enum11
|
||||||
|
|
||||||
vptr: VOIDPTR
|
vptr: VOIDPTR
|
||||||
iptr: INTPTR
|
iptr: INTPTR
|
||||||
|
|
@ -53,4 +55,7 @@ check test_call_param6(u2) == 'c'
|
||||||
u.field1 = 4
|
u.field1 = 4
|
||||||
check test_call_param7(u) == 4
|
check test_call_param7(u) == 4
|
||||||
|
|
||||||
|
check e3 == enum7
|
||||||
|
check e4 == enum11
|
||||||
|
|
||||||
cAddStdDir()
|
cAddStdDir()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue