Update for latest Nim

This commit is contained in:
Ruslan Mustakov 2017-11-22 16:36:39 +07:00
commit e2049ff1a7
5 changed files with 14 additions and 13 deletions

View file

@ -55,7 +55,7 @@ about compiling Godot can be found in `Godot documentation
Installing Nim Installing Nim
------------- -------------
The library requires Nim version 0.17.2 or newer, which you can get here: The library requires Nim version 0.18.0 or newer, which you can get here:
https://nim-lang.org/install.html https://nim-lang.org/install.html
Make sure you also have ``nimble`` (Nim's package manager) installed. Make sure you also have ``nimble`` (Nim's package manager) installed.

View file

@ -1,4 +1,4 @@
version = "0.6.7" version = "0.6.8"
author = "Xored Software, Inc." author = "Xored Software, Inc."
description = "Godot Engine bindings" description = "Godot Engine bindings"
license = "MIT" license = "MIT"

View file

@ -136,20 +136,20 @@ proc binarySearchCustom*(self: var GodotArray, val: ptr GodotVariant,
getGDNativeAPI().arrayBSearchCustom(self, val, obj, funcName, before) getGDNativeAPI().arrayBSearchCustom(self, val, obj, funcName, before)
iterator items*(self: GodotArray): GodotVariant = iterator items*(self: GodotArray): GodotVariant =
for i in 0..<self.len: for i in 0.cint..<self.len:
yield self[i] yield self[i]
iterator mitems*(self: var GodotArray): var GodotVariant = iterator mitems*(self: var GodotArray): var GodotVariant =
for i in 0..<self.len: for i in 0.cint..<self.len:
yield self.mget(i)[] yield self.mget(i)[]
iterator pairs*(self: GodotArray): tuple[key: cint, val: GodotVariant] = iterator pairs*(self: GodotArray): tuple[key: cint, val: GodotVariant] =
for i in 0..<self.len: for i in 0.cint..<self.len:
yield (i, self[i]) yield (i, self[i])
iterator mpairs*(self: var GodotArray): tuple[key: cint, iterator mpairs*(self: var GodotArray): tuple[key: cint,
val: var GodotVariant] = val: var GodotVariant] =
for i in 0..<self.len: for i in 0.cint..<self.len:
yield (i, self.mget(i)[]) yield (i, self.mget(i)[])
proc `$`*(self: GodotArray): string = proc `$`*(self: GodotArray): string =

View file

@ -49,11 +49,11 @@ template genPoolArrayAPI(ArrayT, initIdent, DataT,
getGDNativeAPI().sizeProc(self) getGDNativeAPI().sizeProc(self)
iterator items*(arr: ArrayT): DataT = iterator items*(arr: ArrayT): DataT =
for i in 0..<arr.len: for i in 0.cint..<arr.len:
yield arr[i] yield arr[i]
iterator pairs*(arr: ArrayT): tuple[key: cint, val: DataT] = iterator pairs*(arr: ArrayT): tuple[key: cint, val: DataT] =
for i in 0..<arr.len: for i in 0.cint..<arr.len:
yield (i, arr[i]) yield (i, arr[i])
genPoolArrayAPI(GodotPoolByteArray, initGodotPoolByteArray, byte, genPoolArrayAPI(GodotPoolByteArray, initGodotPoolByteArray, byte,

View file

@ -53,7 +53,8 @@ proc extractNames(definition: NimNode):
if definition.kind == nnkIdent: if definition.kind == nnkIdent:
result.name = $(definition.ident) result.name = $(definition.ident)
else: else:
if not (definition.kind == nnkInfix and definition[0].ident == !"of"): if not (definition.kind == nnkInfix and
definition[0].ident == toNimIdent("of")):
parseError(definition, "invalid type definition") parseError(definition, "invalid type definition")
result.name = $(definition[1].ident) result.name = $(definition[1].ident)
case definition[2].kind: case definition[2].kind:
@ -90,7 +91,7 @@ proc removePragmaNode(statement: NimNode,
result = nil result = nil
var pragmas = if RoutineNodes.contains(statement.kind): statement.pragma() var pragmas = if RoutineNodes.contains(statement.kind): statement.pragma()
else: statement[1] else: statement[1]
let pnameIdent = !pname let pnameIdent = toNimIdent(pname)
for ident, val, i in pragmas(pragmas): for ident, val, i in pragmas(pragmas):
if ident == pnameIdent: if ident == pnameIdent:
pragmas.del(i) pragmas.del(i)
@ -103,7 +104,7 @@ proc removePragma(statement: NimNode, pname: string): bool =
return false return false
var pragmas = if RoutineNodes.contains(statement.kind): statement.pragma() var pragmas = if RoutineNodes.contains(statement.kind): statement.pragma()
else: statement[1] else: statement[1]
let pnameIdent = !pname let pnameIdent = toNimIdent(pname)
for ident, val, i in pragmas(pragmas): for ident, val, i in pragmas(pragmas):
if ident == pnameIdent: if ident == pnameIdent:
pragmas.del(i) pragmas.del(i)
@ -186,7 +187,7 @@ proc parseType(definition, callSite: NimNode): ObjectDecl =
let option = callSite[i] let option = callSite[i]
if option.kind != nnkIdent: if option.kind != nnkIdent:
parseError(option, "type specifier expected") parseError(option, "type specifier expected")
if option.ident == !"tool": if option.ident == toNimIdent("tool"):
isTool = true isTool = true
else: else:
parseError(option, "valid type specifier expected") parseError(option, "valid type specifier expected")
@ -587,7 +588,7 @@ proc genType(obj: ObjectDecl): NimNode {.compileTime.} =
let hasReturnValueBool = not (meth.returnType.isNil or let hasReturnValueBool = not (meth.returnType.isNil or
meth.returnType.kind == nnkEmpty or meth.returnType.kind == nnkEmpty or
(meth.returnType.kind == nnkIdent and (meth.returnType.kind == nnkIdent and
meth.returnType.ident == !"void")) meth.returnType.ident == toNimIdent("void")))
let hasReturnValue = if hasReturnValueBool: ident("true") let hasReturnValue = if hasReturnValueBool: ident("true")
else: ident("false") else: ident("false")
result.add(getAst( result.add(getAst(