Minor changes
This commit is contained in:
parent
b9b5174759
commit
50eba9a485
2 changed files with 36 additions and 18 deletions
|
|
@ -34,16 +34,20 @@ macro cDebug*(): untyped =
|
|||
macro cDefine*(name: static string, val: static string = ""): untyped =
|
||||
result = newNimNode(nnkStmtList)
|
||||
|
||||
var str = "-D" & name
|
||||
var str = name
|
||||
if val.nBl:
|
||||
str &= &"=\"{val}\""
|
||||
|
||||
result.add(quote do:
|
||||
{.passC: `str`.}
|
||||
)
|
||||
if str notin gDefines:
|
||||
gDefines.add(str)
|
||||
str = "-D" & str
|
||||
|
||||
if gDebug:
|
||||
echo result.repr
|
||||
result.add(quote do:
|
||||
{.passC: `str`.}
|
||||
)
|
||||
|
||||
if gDebug:
|
||||
echo result.repr
|
||||
|
||||
macro cAddSearchDir*(dir: static string): untyped =
|
||||
result = newNimNode(nnkStmtList)
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
import macros, strutils
|
||||
import macros, strformat, strutils
|
||||
|
||||
import regex
|
||||
|
||||
import globals
|
||||
import git, globals
|
||||
|
||||
proc getIdentifier*(str: string): string =
|
||||
result = str.strip(chars={'_'})
|
||||
|
||||
proc getType*(str: string): string =
|
||||
result = str.strip(chars={'_'}).replace(re"([u]?int[\d]+)_t", "$1").replace(re"^void$", "object")
|
||||
|
||||
|
||||
proc getLit*(str: string): string =
|
||||
if str.contains(re"^[\-]?[\d]+$") or
|
||||
str.contains(re"^[\-]?[\d]*\.[\d]+$") or
|
||||
|
|
@ -19,15 +19,8 @@ proc getLit*(str: string): string =
|
|||
proc getNodeValIf*(node: ref Ast, esym: Sym): string =
|
||||
if esym != node.sym:
|
||||
return
|
||||
|
||||
return gCode[node.start .. node.stop-1].strip()
|
||||
|
||||
proc getGccPaths*(mode = "c"): string =
|
||||
var
|
||||
nul = when defined(Windows): "nul" else: "/dev/null"
|
||||
mmode = if mode == "cpp": "c++" else: mode
|
||||
|
||||
return staticExec("gcc -Wp,-v -x" & mmode & " " & nul)
|
||||
return gCode[node.start .. node.stop-1].strip()
|
||||
|
||||
proc getLineCol*(node: ref Ast): tuple[line, col: int] =
|
||||
result.line = 1
|
||||
|
|
@ -36,4 +29,25 @@ proc getLineCol*(node: ref Ast): tuple[line, col: int] =
|
|||
if gCode[i] == '\n':
|
||||
result.col = 0
|
||||
result.line += 1
|
||||
result.col += 1
|
||||
result.col += 1
|
||||
|
||||
proc getGccPaths*(mode = "c"): string =
|
||||
var
|
||||
nul = when defined(Windows): "nul" else: "/dev/null"
|
||||
mmode = if mode == "cpp": "c++" else: mode
|
||||
|
||||
return staticExec("gcc -Wp,-v -x" & mmode & " " & nul)
|
||||
|
||||
proc getPreprocessor*(fullpath: string, mode = "cpp"): string =
|
||||
var
|
||||
mmode = if mode == "cpp": "c++" else: mode
|
||||
cmd = &"gcc -E -dD -x{mmode} "
|
||||
|
||||
for inc in gIncludeDirs:
|
||||
cmd &= &"-I\"{inc}\" "
|
||||
|
||||
for def in gDefines:
|
||||
cmd &= &"-D{def} "
|
||||
|
||||
cmd &= &"\"{fullpath}\""
|
||||
return staticExec(cmd)
|
||||
Loading…
Add table
Add a link
Reference in a new issue