diff options
| author | Ganesh Viswanathan <dev@genotrance.com> | 2019-01-28 00:44:21 -0600 |
|---|---|---|
| committer | Ganesh Viswanathan <dev@genotrance.com> | 2019-01-28 00:44:21 -0600 |
| commit | b86a128456858c2669a4e7aab0899fb792b56c56 (patch) | |
| tree | d42236582e49b902ae91cd8e5244e0c66e696fcc | |
| parent | 70aa3e2b5e47102a7e9bdbb76320d8c6ccad57b9 (diff) | |
| download | nimterop-b86a128456858c2669a4e7aab0899fb792b56c56.tar.gz nimterop-b86a128456858c2669a4e7aab0899fb792b56c56.zip | |
Allow skip of symbol with _
| -rw-r--r-- | nimterop/getters.nim | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/nimterop/getters.nim b/nimterop/getters.nim index f430ae1..b03ecc5 100644 --- a/nimterop/getters.nim +++ b/nimterop/getters.nim @@ -87,26 +87,29 @@ proc getType*(str: string): string = if gTypeMap.hasKey(result): result = gTypeMap[result] -template checkUnderscores(str, errmsg: string): untyped = - if str.len != 0: - doAssert str[0] != '_' and str[^1] != '_', errmsg +template checkUnderscores(name, errmsg: string): untyped = + if name.len != 0: + doAssert name[0] != '_' and name[^1] != '_', errmsg -proc getIdentifier*(str: string, kind: NimSymKind): string = - doAssert str.len != 0, "Blank identifier error" +proc getIdentifier*(name: string, kind: NimSymKind): string = + doAssert name.len != 0, "Blank identifier error" - if gStateRT.onSymbol != nil: - var - sym = Symbol(name: str, kind: kind) - gStateRT.onSymbol(sym) + if name notin gStateRT.symOverride: + if gStateRT.onSymbol != nil: + var + sym = Symbol(name: name, kind: kind) + gStateRT.onSymbol(sym) - result = sym.name - checkUnderscores(result, &"Identifier '{str}' still contains leading/trailing underscores '_' after 'cPlugin:onSymbol()': result '{result}'") - else: - result = str - checkUnderscores(result, &"Identifier '{result}' contains unsupported leading/trailing underscores '_': use 'cPlugin:onSymbol()' to remove") + result = sym.name + checkUnderscores(result, &"Identifier '{name}' still contains leading/trailing underscores '_' after 'cPlugin:onSymbol()': result '{result}'") + else: + result = name + checkUnderscores(result, &"Identifier '{result}' contains unsupported leading/trailing underscores '_': use 'cPlugin:onSymbol()' to remove") - if result in gReserved: - result = &"`{result}`" + if result in gReserved: + result = &"`{result}`" + else: + result = "" proc getUniqueIdentifier*(existing: TableRef[string, string], prefix = ""): string = var |
