Small changes to add 0.18.0 compatibility

Change toGodotName back to macro because that got fixed in devel

change isSome to isNone in godotapigen
This commit is contained in:
zetashift 2019-03-01 02:18:00 +01:00 • committed by Ruslan Mustakov
commit 34fda99def
3 changed files with 33 additions and 15 deletions

View file

@ -197,7 +197,7 @@ proc parseType(definition, callSite: NimNode): ObjectDecl =
parseError(option, "valid type specifier expected")
result.isTool = isTool
if result.parentName == "": result.parentName = "Object"
if result.parentName.len == 0: result.parentName = "Object"
for statement in body:
case statement.kind:
of nnkVarSection:
@ -444,7 +444,7 @@ proc genType(obj: ObjectDecl): NimNode {.compileTime.} =
let objTy = newNimNode(nnkObjectTy)
typeDef.add(newNimNode(nnkRefTy).add(objTy))
objTy.add(newEmptyNode())
if obj.parentName == "":
if obj.parentName.len == 0:
objTy.add(newEmptyNode())
else:
objTy.add(newNimNode(nnkOfInherit).add(ident(obj.parentName)))
@ -503,11 +503,11 @@ proc genType(obj: ObjectDecl): NimNode {.compileTime.} =
result.add(meth.nimNode)
# Register Godot object
let parentName = if obj.parentName == "": newStrLitNode("Object")
let parentName = if obj.parentName.len == 0: newStrLitNode("Object")
else: newStrLitNode(obj.parentName)
let classNameLit = newStrLitNode(obj.name)
let classNameIdent = ident(obj.name)
let isRef: bool = if obj.parentName == "": false
let isRef: bool = if obj.parentName.len == 0: false
else: obj.parentName in refClasses
# Wrapping bools with a newLit is required as a temporary workaround for
# https://github.com/nim-lang/Nim/issues/7375
@ -544,9 +544,15 @@ proc genType(obj: ObjectDecl): NimNode {.compileTime.} =
template registerGodotMethod(classNameLit, classNameIdent, methodNameIdent,
methodNameLit, minArgs, maxArgs,
argTypes, methFuncIdent, hasReturnValue) =
{.emit: """/*TYPESECTION*/
when (NimMajor, NimMinor, NimPatch) < (0, 19, 0):
{.emit: """/*TYPESECTION*/
N_NOINLINE(void, setStackBottom)(void* thestackbottom);
""".}
else:
{.emit: """
N_NOINLINE(void, nimGC_setStackBottom)(void* thestackbottom);
""".}
proc methFuncIdent(obj: ptr GodotObject, methodData: pointer,
userData: pointer, numArgs: cint,
args: var array[MAX_ARG_COUNT, ptr GodotVariant]):