Fix compilation errors in generated API
This commit is contained in:
parent
8d8d095af9
commit
0ad22b7b7c
3 changed files with 19 additions and 16 deletions
|
|
@ -474,7 +474,7 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string],
|
||||||
newNode(nkBracketExpr).addChain(
|
newNode(nkBracketExpr).addChain(
|
||||||
ident("array"), newIntLit(staticArgsLen), ident("pointer")),
|
ident("array"), newIntLit(staticArgsLen), ident("pointer")),
|
||||||
newNode(nkEmpty)))
|
newNode(nkEmpty)))
|
||||||
argsAlloc.add(newCommand(ident("addr"), ident("argsStatic")))
|
argsAlloc.add(newDotExpr(ident("argsStatic"), ident("addr")))
|
||||||
vars.add(newIdentDefs(argsName, newNode(nkEmpty), argsAlloc))
|
vars.add(newIdentDefs(argsName, newNode(nkEmpty), argsAlloc))
|
||||||
|
|
||||||
let argConversions = newNode(nkStmtList)
|
let argConversions = newNode(nkStmtList)
|
||||||
|
|
|
||||||
|
|
@ -197,7 +197,7 @@ proc parseType(definition, callSite: NimNode): ObjectDecl =
|
||||||
parseError(option, "valid type specifier expected")
|
parseError(option, "valid type specifier expected")
|
||||||
result.isTool = isTool
|
result.isTool = isTool
|
||||||
|
|
||||||
if result.parentName == "": result.parentName = "Object"
|
if result.parentName.len == 0: result.parentName = "Object"
|
||||||
for statement in body:
|
for statement in body:
|
||||||
case statement.kind:
|
case statement.kind:
|
||||||
of nnkVarSection:
|
of nnkVarSection:
|
||||||
|
|
@ -444,7 +444,7 @@ proc genType(obj: ObjectDecl): NimNode {.compileTime.} =
|
||||||
let objTy = newNimNode(nnkObjectTy)
|
let objTy = newNimNode(nnkObjectTy)
|
||||||
typeDef.add(newNimNode(nnkRefTy).add(objTy))
|
typeDef.add(newNimNode(nnkRefTy).add(objTy))
|
||||||
objTy.add(newEmptyNode())
|
objTy.add(newEmptyNode())
|
||||||
if obj.parentName == "":
|
if obj.parentName.len == 0:
|
||||||
objTy.add(newEmptyNode())
|
objTy.add(newEmptyNode())
|
||||||
else:
|
else:
|
||||||
objTy.add(newNimNode(nnkOfInherit).add(ident(obj.parentName)))
|
objTy.add(newNimNode(nnkOfInherit).add(ident(obj.parentName)))
|
||||||
|
|
@ -503,11 +503,11 @@ proc genType(obj: ObjectDecl): NimNode {.compileTime.} =
|
||||||
result.add(meth.nimNode)
|
result.add(meth.nimNode)
|
||||||
|
|
||||||
# Register Godot object
|
# Register Godot object
|
||||||
let parentName = if obj.parentName == "": newStrLitNode("Object")
|
let parentName = if obj.parentName.len == 0: newStrLitNode("Object")
|
||||||
else: newStrLitNode(obj.parentName)
|
else: newStrLitNode(obj.parentName)
|
||||||
let classNameLit = newStrLitNode(obj.name)
|
let classNameLit = newStrLitNode(obj.name)
|
||||||
let classNameIdent = ident(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
|
else: obj.parentName in refClasses
|
||||||
# Wrapping bools with a newLit is required as a temporary workaround for
|
# Wrapping bools with a newLit is required as a temporary workaround for
|
||||||
# https://github.com/nim-lang/Nim/issues/7375
|
# https://github.com/nim-lang/Nim/issues/7375
|
||||||
|
|
|
||||||
|
|
@ -202,7 +202,7 @@ macro baseNativeType(T: typedesc): cstring =
|
||||||
if typeName == "NimGodotObject":
|
if typeName == "NimGodotObject":
|
||||||
break
|
break
|
||||||
t = getType(t[1][1])
|
t = getType(t[1][1])
|
||||||
if baseT == "":
|
if baseT.len == 0:
|
||||||
result = newNilLit()
|
result = newNilLit()
|
||||||
else:
|
else:
|
||||||
let rStr = newNimNode(nnkRStrLit)
|
let rStr = newNimNode(nnkRStrLit)
|
||||||
|
|
@ -343,20 +343,23 @@ proc newRStrLit(s: string): NimNode {.compileTime.} =
|
||||||
result = newNimNode(nnkRStrLit)
|
result = newNimNode(nnkRStrLit)
|
||||||
result.strVal = s
|
result.strVal = s
|
||||||
|
|
||||||
proc toGodotName(T: typedesc): string =
|
macro toGodotName(T: typedesc): string =
|
||||||
|
var godotName: string
|
||||||
if T is GodotString or T is string:
|
if T is GodotString or T is string:
|
||||||
"String"
|
godotName = "String"
|
||||||
elif T is SomeFloat:
|
elif T is SomeFloat:
|
||||||
"float"
|
godotName = "float"
|
||||||
elif T is SomeUnsignedInt or T is SomeSignedInt:
|
elif T is SomeUnsignedInt or T is SomeSignedInt:
|
||||||
"int"
|
godotName = "int"
|
||||||
else:
|
if godotName.len == 0:
|
||||||
let nameStr = (($T.getType()[1][1].symbol).split(':')[0])
|
let nameStr = (($T.getType()[1][1].symbol).split(':')[0])
|
||||||
case nameStr:
|
godotName = case nameStr:
|
||||||
of "File", "Directory", "Thread", "Mutex", "Semaphore":
|
of "File", "Directory", "Thread", "Mutex", "Semaphore":
|
||||||
"_" & nameStr
|
"_" & nameStr
|
||||||
else:
|
else:
|
||||||
nameStr
|
nameStr
|
||||||
|
|
||||||
|
result = newLit(godotName)
|
||||||
|
|
||||||
macro asCString(s: static[string]): cstring =
|
macro asCString(s: static[string]): cstring =
|
||||||
result = newNimNode(nnkCallStrLit).add(
|
result = newNimNode(nnkCallStrLit).add(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue