aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGanesh Viswanathan <dev@genotrance.com>2020-04-13 20:18:37 -0500
committerGanesh Viswanathan <dev@genotrance.com>2020-04-13 20:18:37 -0500
commit08306b98020d5dcfd513b515f7955d44cfef1d6b (patch)
treecb33d43744485774b14b2e168d7d886a244fb319
parentf23d17d0b2f2e6bd66b0d685461d9dd1c2070918 (diff)
downloadnimterop-issue172.tar.gz
nimterop-issue172.zip
Fix #172 - skip qualifiersissue172
-rw-r--r--nimterop.nimble2
-rw-r--r--nimterop/getters.nim18
-rw-r--r--tests/include/tast2.h10
-rw-r--r--tests/tast2.nim7
4 files changed, 33 insertions, 4 deletions
diff --git a/nimterop.nimble b/nimterop.nimble
index cd36e1c..9600faa 100644
--- a/nimterop.nimble
+++ b/nimterop.nimble
@@ -23,7 +23,7 @@ proc execTest(test: string, flags = "") =
execCmd "nim cpp --hints:off " & flags & " -r " & test
task buildToast, "build toast":
- execCmd("nim c --hints:off -f nimterop/toast.nim")
+ execCmd("nim c --hints:off nimterop/toast.nim")
task bt, "build toast":
execCmd("nim c --hints:off -d:danger nimterop/toast.nim")
diff --git a/nimterop/getters.nim b/nimterop/getters.nim
index e47113d..76b528d 100644
--- a/nimterop/getters.nim
+++ b/nimterop/getters.nim
@@ -234,7 +234,14 @@ proc getAtom*(node: TSNode): TSNode =
if node.getName() in gAtoms:
return node
elif node.len() != 0:
- return node[0].getAtom()
+ if node[0].getName() == "type_qualifier":
+ # Skip const, volatile
+ if node.len() > 1:
+ return node[1].getAtom()
+ else:
+ return
+ else:
+ return node[0].getAtom()
proc getStartAtom*(node: TSNode): int =
if not node.isNil:
@@ -256,7 +263,14 @@ proc getXCount*(node: TSNode, ntype: string, reverse = false): int =
cnode = cnode.tsNodeParent()
else:
if cnode.len() != 0:
- cnode = cnode[0]
+ if cnode[0].getName() == "type_qualifier":
+ # Skip const, volatile
+ if cnode.len() > 1:
+ cnode = cnode[1]
+ else:
+ break
+ else:
+ cnode = cnode[0]
else:
break
diff --git a/tests/include/tast2.h b/tests/include/tast2.h
index 76aadc9..136784a 100644
--- a/tests/include/tast2.h
+++ b/tests/include/tast2.h
@@ -170,6 +170,11 @@ typedef struct SDL_AudioCVT
int needed;
} SDL_AudioCVT;
+// Issue #172
+typedef struct {
+ const char* const* x;
+} SomeType;
+
// DUPLICATES
@@ -334,6 +339,11 @@ typedef struct SDL_AudioCVT
int needed;
} SDL_AudioCVT;
+// Issue #172
+typedef struct {
+ const char* const* x;
+} SomeType;
+
#endif
diff --git a/tests/tast2.nim b/tests/tast2.nim
index 4741062..6d749c6 100644
--- a/tests/tast2.nim
+++ b/tests/tast2.nim
@@ -367,4 +367,9 @@ checkPragmas(GPU_Target, pHeaderBy, istype = false)
# Issue #185
assert AudioCVT is object
testFields(AudioCVT, "needed!cint")
-checkPragmas(AudioCVT, pHeaderBy, istype = false, "SDL_") \ No newline at end of file
+checkPragmas(AudioCVT, pHeaderBy, istype = false, "SDL_")
+
+# Issue #172
+assert SomeType is object
+testFields(SomeType, "x!ptr cstring")
+checkPragmas(SomeType, pHeaderImpBy) \ No newline at end of file