aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGanesh Viswanathan <dev@genotrance.com>2019-01-28 16:14:58 -0600
committerGanesh Viswanathan <dev@genotrance.com>2019-01-28 16:14:58 -0600
commit31ec7987dbb7df21fa36e7aeb5fb2f4a93cb1cb3 (patch)
tree3156ebf4f17d4fc4fe257ced0fc850b277d4b6b1
parent62b44fc1e2c98759b7f549f2b273884063be82b5 (diff)
downloadnimterop-31ec7987dbb7df21fa36e7aeb5fb2f4a93cb1cb3.tar.gz
nimterop-31ec7987dbb7df21fa36e7aeb5fb2f4a93cb1cb3.zip
Better context in _ error msg, gitPull fix for path, allow suppress of #define _X
-rw-r--r--nimterop/getters.nim10
-rw-r--r--nimterop/git.nim8
-rw-r--r--nimterop/globals.nim4
-rw-r--r--nimterop/grammar.nim9
4 files changed, 18 insertions, 13 deletions
diff --git a/nimterop/getters.nim b/nimterop/getters.nim
index 8b6b15d..42dc9f9 100644
--- a/nimterop/getters.nim
+++ b/nimterop/getters.nim
@@ -94,6 +94,9 @@ template checkUnderscores(name, errmsg: string): untyped =
proc getIdentifier*(name: string, kind: NimSymKind, parent=""): string =
doAssert name.len != 0, "Blank identifier error"
+ let
+ parentStr = if parent.nBl: parent & ":" else: ""
+
if name notin gStateRT.symOverride or parent.nBl:
if gStateRT.onSymbol != nil:
var
@@ -101,12 +104,13 @@ proc getIdentifier*(name: string, kind: NimSymKind, parent=""): string =
gStateRT.onSymbol(sym)
result = sym.name
- checkUnderscores(result, &"Identifier '{name}' still contains leading/trailing underscores '_' after 'cPlugin:onSymbol()': result '{result}'")
+ checkUnderscores(result, &"Identifier '{parentStr}{name}' ({kind}) still contains leading/trailing underscores '_' after 'cPlugin:onSymbol()': result '{result}'")
- doAssert result.nBl, &"Blank {kind} '{result}', originally '{name}', child of '{parent}' so cannot be empty"
+ if parent.nBl:
+ doAssert result.nBl, &"Blank identifier, originally '{parentStr}{name}' ({kind}), cannot be empty"
else:
result = name
- checkUnderscores(result, &"Identifier '{result}' contains unsupported leading/trailing underscores '_': use 'cPlugin:onSymbol()' to remove")
+ checkUnderscores(result, &"Identifier '{parentStr}{result}' ({kind}) contains unsupported leading/trailing underscores '_': use 'cPlugin:onSymbol()' to remove")
if result in gReserved:
result = &"`{result}`"
diff --git a/nimterop/git.nim b/nimterop/git.nim
index 8617b8b..7961385 100644
--- a/nimterop/git.nim
+++ b/nimterop/git.nim
@@ -65,15 +65,13 @@ macro gitCheckout*(file, outdir: static string): untyped =
sleep(500)
echo " Retrying ..."
-macro gitPull*(url: static string, outdirN = "", plistN = "", checkoutN = ""): untyped =
+macro gitPull*(url: static string, outdirN: static string = "", plist: static string = "", checkout: static string = ""): untyped =
let
- outdir = if outdirN.strVal().isAbsolute(): outdirN.strVal() else: getProjectPath()/outdirN.strVal()
- plist = plistN.strVal()
- checkout = checkoutN.strVal()
+ outdir = if outdirN.isAbsolute(): outdirN else: getProjectPath()/outdirN
if dirExists(outdir/".git"):
discard quote do:
- gitReset(`outdirN`)
+ gitReset(`outdir`)
return
else:
let
diff --git a/nimterop/globals.nim b/nimterop/globals.nim
index cfbefdb..b959958 100644
--- a/nimterop/globals.nim
+++ b/nimterop/globals.nim
@@ -47,7 +47,7 @@ type
tonim*: proc (ast: ref Ast, node: TSNode, nimState: NimState)
regex*: Regex
- AstTable = TableRef[string, seq[ref Ast]]
+ AstTable {.used.} = TableRef[string, seq[ref Ast]]
State = object
compile*, defines*, headers*, includeDirs*, searchDirs*, symOverride*: seq[string]
@@ -58,7 +58,7 @@ type
onSymbol*: OnSymbol
- NimState = ref object
+ NimState {.used.} = ref object
identifiers*: TableRef[string, string]
constStr*, debugStr*, enumStr*, procStr*, typeStr*: string
diff --git a/nimterop/grammar.nim b/nimterop/grammar.nim
index aae3b17..ad7ad9e 100644
--- a/nimterop/grammar.nim
+++ b/nimterop/grammar.nim
@@ -17,11 +17,14 @@ proc initGrammar(): Grammar =
""",
proc (ast: ref Ast, node: TSNode, nimState: NimState) =
let
- name = nimState.data[0].val.getIdentifier(nskConst)
val = nimState.data[1].val.getLit()
- if name.nBl and val.nBl and nimState.identifiers.addNewIdentifer(name):
- nimState.constStr &= &" {name}* = {val}\n"
+ if val.nBl:
+ let
+ name = nimState.data[0].val.getIdentifier(nskConst)
+
+ if name.nBl and nimState.identifiers.addNewIdentifer(name):
+ nimState.constStr &= &" {name}* = {val}\n"
))
let