remove workaround for unsupported Nim 0.19 and earlier (#200)
* remove workaround for unsupported Nim 0.19 and earlier * replace some proc with func
This commit is contained in:
parent
65ce2203f0
commit
9958aac68a
|
@ -52,10 +52,10 @@ when defined(windows):
|
|||
else:
|
||||
proc alloca(n: int): pointer {.importc, header: "<alloca.h>".}
|
||||
|
||||
proc raiseRangeError(s: string) =
|
||||
func raiseRangeError(s: string) =
|
||||
raise newException(RangeDefect, s)
|
||||
|
||||
proc raiseOutOfRange =
|
||||
func raiseOutOfRange =
|
||||
raiseRangeError "index out of range"
|
||||
|
||||
template len*(a: StackArray): int =
|
||||
|
@ -71,7 +71,7 @@ template `[]`*(a: StackArray, i: int): auto =
|
|||
if i < 0 or i >= a.len: raiseOutOfRange()
|
||||
a.buffer[i]
|
||||
|
||||
proc `[]=`*(a: StackArray, i: int, val: a.T) {.inline.} =
|
||||
func `[]=`*(a: StackArray, i: int, val: a.T) {.inline.} =
|
||||
if i < 0 or i >= a.len: raiseOutOfRange()
|
||||
a.buffer[i] = val
|
||||
|
||||
|
@ -79,7 +79,7 @@ template `[]`*(a: StackArray, i: BackwardsIndex): auto =
|
|||
if int(i) < 1 or int(i) > a.len: raiseOutOfRange()
|
||||
a.buffer[a.len - int(i)]
|
||||
|
||||
proc `[]=`*(a: StackArray, i: BackwardsIndex, val: a.T) =
|
||||
func `[]=`*(a: StackArray, i: BackwardsIndex, val: a.T) =
|
||||
if int(i) < 1 or int(i) > a.len: raiseOutOfRange()
|
||||
a.buffer[a.len - int(i)] = val
|
||||
|
||||
|
@ -121,10 +121,7 @@ template allocStackArrayNoInit*(T: typedesc, size: int): StackArray[T] =
|
|||
allocStackArrayAux(T, size, false)
|
||||
|
||||
template getBuffer*(a: StackArray): untyped =
|
||||
when (NimMajor,NimMinor,NimPatch)>=(0,19,9):
|
||||
a.buffer
|
||||
else:
|
||||
a.buffer[]
|
||||
a.buffer
|
||||
|
||||
template toOpenArray*(a: StackArray): auto =
|
||||
toOpenArray(a.getBuffer, 0, a.high)
|
||||
|
|
Loading…
Reference in New Issue