add gensym in hygienic template fix thanks to demotohiro (#55)

Add gensym in hygienic template fix thanks to demotohiro
This commit is contained in:
zetashift 2020-02-05 05:35:50 +01:00 • committed by GitHub
commit 157a90e4a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -396,10 +396,9 @@ template registerGodotField(classNameLit, classNameIdent, propNameLit,
getFunc: getFuncIdent
)
mixin godotTypeInfo
static:
var typeInfo: GodotTypeInfo
when compiles(godotTypeInfo(propTypeIdent)):
typeInfo = godotTypeInfo(propTypeIdent)
const typeInfo = when compiles(godotTypeInfo(propTypeIdent)):
godotTypeInfo(propTypeIdent)
else: GodotTypeInfo()
const hintStr = when hintStrLit != "NIM":
hintStrLit
else:
@ -455,7 +454,8 @@ proc genType(obj: ObjectDecl): NimNode {.compileTime.} =
let initBody = newStmtList()
for decl in obj.fields:
if not decl.defaultValue.isNil and decl.defaultValue.kind != nnkEmpty:
initBody.add(newNimNode(nnkAsgn).add(newDotExpr(ident("self"), decl.name), decl.defaultValue))
initBody.add(newNimNode(nnkAsgn).add(newDotExpr(ident("self"), decl.name),
decl.defaultValue))
let name = if not decl.isExported: decl.name
else: postfix(decl.name, "*")
recList.add(newIdentDefs(name, decl.typ))
@ -605,7 +605,7 @@ N_NOINLINE(void, setStackBottom)(void* thestackbottom);
else: toGodotStyle(meth.name)
let hasReturnValueBool = not (meth.returnType.isNil or
meth.returnType.kind == nnkEmpty or
(meth.returnType.kind == nnkIdent and
(meth.returnType.kind == nnkIdent and
meth.returnType.strVal == "void"))
let hasReturnValue = if hasReturnValueBool: ident("true")
else: ident("false")