diff options
| author | Ganesh Viswanathan <dev@genotrance.com> | 2018-12-26 17:42:13 -0600 |
|---|---|---|
| committer | Ganesh Viswanathan <dev@genotrance.com> | 2018-12-26 17:42:13 -0600 |
| commit | 1684e773ad51612ea1034834662049e1228ddad9 (patch) | |
| tree | 912d81944f2cde0d269c68a554d58aa522693a8f | |
| parent | 34cb1715b876ac9dd09b97b938638f6beaff926b (diff) | |
| download | nimterop-1684e773ad51612ea1034834662049e1228ddad9.tar.gz nimterop-1684e773ad51612ea1034834662049e1228ddad9.zip | |
Tests for enhancements
| -rw-r--r-- | nimterop/getters.nim | 4 | ||||
| -rw-r--r-- | nimterop/grammar.nim | 2 | ||||
| -rw-r--r-- | tests/include/test.h | 14 | ||||
| -rw-r--r-- | tests/tnimterop_c.nim | 5 |
4 files changed, 21 insertions, 4 deletions
diff --git a/nimterop/getters.nim b/nimterop/getters.nim index b03f931..28e1bd1 100644 --- a/nimterop/getters.nim +++ b/nimterop/getters.nim @@ -12,9 +12,9 @@ proc sanitizePath*(path: string): string = proc getIdentifier*(str: string): string = result = str.strip(chars={'_'}) -proc getUniqueIdentifier*(exists: seq[string]): string = +proc getUniqueIdentifier*(exists: seq[string], prefix = ""): string = var - name = gStateRT.sourceFile.extractFilename().multiReplace([(".", ""), ("-", "")]) + name = prefix & "_" & gStateRT.sourceFile.extractFilename().multiReplace([(".", ""), ("-", "")]) count = 1 while (name & $count) in exists: diff --git a/nimterop/grammar.nim b/nimterop/grammar.nim index e86f907..a8d8eed 100644 --- a/nimterop/grammar.nim +++ b/nimterop/grammar.nim @@ -154,7 +154,7 @@ proc initGrammar() = nname = name.getIdentifier() if nname.len == 0: - nname = getUniqueIdentifier(gStateRT.types) + nname = getUniqueIdentifier(gStateRT.types, "Enum") if nname notin gStateRT.types: gStateRT.types.add(nname) diff --git a/tests/include/test.h b/tests/include/test.h index af7eeb8..bf4f70d 100644 --- a/tests/include/test.h +++ b/tests/include/test.h @@ -29,6 +29,18 @@ typedef enum { enum6 } ENUM2; +enum { + enum7, + enum8, + enum9 +}; + +typedef enum ENUM4 { + enum10, + enum11, + enum12 +} ENUM4; + typedef void * VOIDPTR; typedef int * INTPTR; @@ -41,7 +53,7 @@ union UNION1 { float field2; }; -typedef union { +typedef union UNION2 { double field1; unsigned char field2; } UNION2; diff --git a/tests/tnimterop_c.nim b/tests/tnimterop_c.nim index 2477e61..45e94d6 100644 --- a/tests/tnimterop_c.nim +++ b/tests/tnimterop_c.nim @@ -24,6 +24,8 @@ var e: ENUM e2: ENUM2 = enum5 + e3: Enum_testh1 = enum7 + e4: ENUM4 = enum11 vptr: VOIDPTR iptr: INTPTR @@ -53,4 +55,7 @@ check test_call_param6(u2) == 'c' u.field1 = 4 check test_call_param7(u) == 4 +check e3 == enum7 +check e4 == enum11 + cAddStdDir() |
