Compare commits
1 commit
master
...
fix_cast_e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4f6cec613f |
5 changed files with 5 additions and 58 deletions
|
|
@ -9,7 +9,7 @@ bin = @["nimterop/toast", "nimterop/loaf"]
|
||||||
installDirs = @["nimterop"]
|
installDirs = @["nimterop"]
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
requires "nim >= 0.20.2", "regex >= 0.15.0", "cligen >= 1.5.3"
|
requires "nim >= 0.20.2", "regex >= 0.15.0", "cligen >= 1.0.0"
|
||||||
|
|
||||||
import nimterop/docs
|
import nimterop/docs
|
||||||
import os
|
import os
|
||||||
|
|
|
||||||
|
|
@ -59,17 +59,6 @@ macro isDefined*(def: untyped): untyped =
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
|
|
||||||
macro getDefine*(def: untyped): untyped =
|
|
||||||
let version = newIdentNode(def.strVal())
|
|
||||||
let verVal =
|
|
||||||
if gDefines.hasKey(def.strVal()):
|
|
||||||
gDefines[def.strVal()]
|
|
||||||
else:
|
|
||||||
""
|
|
||||||
result = quote do:
|
|
||||||
const `version` {.strdefine.} = `verVal`
|
|
||||||
`version`
|
|
||||||
|
|
||||||
proc getDynlibExt(): string =
|
proc getDynlibExt(): string =
|
||||||
when defined(Windows):
|
when defined(Windows):
|
||||||
result = "[0-9.\\-]*\\.dll"
|
result = "[0-9.\\-]*\\.dll"
|
||||||
|
|
|
||||||
|
|
@ -206,13 +206,13 @@ proc getFileDate*(fullpath: string): string =
|
||||||
when defined(Windows):
|
when defined(Windows):
|
||||||
let
|
let
|
||||||
(head, tail) = fullpath.splitPath()
|
(head, tail) = fullpath.splitPath()
|
||||||
&"forfiles /P {head.sanitizePath()} /M {tail.sanitizePath} /C \"cmd /c echo @fdate @ftime\""
|
&"cmd /c forfiles /P {head.sanitizePath()} /M {tail.sanitizePath} /C \"cmd /c echo @fdate @ftime @fsize\""
|
||||||
elif defined(Linux):
|
elif defined(Linux):
|
||||||
&"stat -c %Y {fullpath.sanitizePath}"
|
&"stat -c %y {fullpath.sanitizePath}"
|
||||||
elif defined(OSX) or defined(FreeBSD):
|
elif defined(OSX) or defined(FreeBSD):
|
||||||
&"stat -f %m {fullpath.sanitizePath}"
|
&"stat -f %m {fullpath.sanitizePath}"
|
||||||
|
|
||||||
(result, ret) = execAction(cmd, die=false)
|
(result, ret) = execAction(cmd)
|
||||||
|
|
||||||
proc touchFile*(fullpath: string) =
|
proc touchFile*(fullpath: string) =
|
||||||
## Touch file to update modified date
|
## Touch file to update modified date
|
||||||
|
|
|
||||||
|
|
@ -1,42 +0,0 @@
|
||||||
import macros
|
|
||||||
|
|
||||||
macro defineEnum*(typ: untyped): untyped =
|
|
||||||
result = newNimNode(nnkStmtList)
|
|
||||||
|
|
||||||
# Enum mapped to distinct cint
|
|
||||||
result.add quote do:
|
|
||||||
type `typ`* = distinct cint
|
|
||||||
|
|
||||||
for i in ["+", "-", "*", "div", "mod", "shl", "shr", "or", "and", "xor", "<", "<=", "==", ">", ">="]:
|
|
||||||
let
|
|
||||||
ni = newIdentNode(i)
|
|
||||||
typout = if i[0] in "<=>": newIdentNode("bool") else: typ # comparisons return bool
|
|
||||||
if i[0] == '>': # cannot borrow `>` and `>=` from templates
|
|
||||||
let
|
|
||||||
nopp = if i.len == 2: newIdentNode("<=") else: newIdentNode("<")
|
|
||||||
result.add quote do:
|
|
||||||
proc `ni`*(x: `typ`, y: cint): `typout` = `nopp`(y, x)
|
|
||||||
proc `ni`*(x: cint, y: `typ`): `typout` = `nopp`(y, x)
|
|
||||||
proc `ni`*(x, y: `typ`): `typout` = `nopp`(y, x)
|
|
||||||
else:
|
|
||||||
result.add quote do:
|
|
||||||
proc `ni`*(x: `typ`, y: cint): `typout` {.borrow.}
|
|
||||||
proc `ni`*(x: cint, y: `typ`): `typout` {.borrow.}
|
|
||||||
proc `ni`*(x, y: `typ`): `typout` {.borrow.}
|
|
||||||
result.add quote do:
|
|
||||||
proc `ni`*(x: `typ`, y: int): `typout` = `ni`(x, y.cint)
|
|
||||||
proc `ni`*(x: int, y: `typ`): `typout` = `ni`(x.cint, y)
|
|
||||||
|
|
||||||
let
|
|
||||||
divop = newIdentNode("/") # `/`()
|
|
||||||
dlrop = newIdentNode("$") # `$`()
|
|
||||||
notop = newIdentNode("not") # `not`()
|
|
||||||
result.add quote do:
|
|
||||||
proc `divop`*(x, y: `typ`): `typ` = `typ`((x.float / y.float).cint)
|
|
||||||
proc `divop`*(x: `typ`, y: cint): `typ` = `divop`(x, `typ`(y))
|
|
||||||
proc `divop`*(x: cint, y: `typ`): `typ` = `divop`(`typ`(x), y)
|
|
||||||
proc `divop`*(x: `typ`, y: int): `typ` = `divop`(x, y.cint)
|
|
||||||
proc `divop`*(x: int, y: `typ`): `typ` = `divop`(x.cint, y)
|
|
||||||
|
|
||||||
proc `dlrop`*(x: `typ`): string {.borrow.}
|
|
||||||
proc `notop`*(x: `typ`): `typ` {.borrow.}
|
|
||||||
|
|
@ -31,7 +31,7 @@ yield""".split(Whitespace).toHashSet()
|
||||||
|
|
||||||
const
|
const
|
||||||
# Enum macro read from file - written into wrapper when required
|
# Enum macro read from file - written into wrapper when required
|
||||||
gEnumMacroConst = "import nimterop / enumtypepub"
|
gEnumMacroConst = staticRead(currentSourcePath.parentDir().parentDir() / "enumtype.nim")
|
||||||
|
|
||||||
var
|
var
|
||||||
gEnumMacro* = gEnumMacroConst
|
gEnumMacro* = gEnumMacroConst
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue