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 getFunc: getFuncIdent
) )
mixin godotTypeInfo mixin godotTypeInfo
static: const typeInfo = when compiles(godotTypeInfo(propTypeIdent)):
var typeInfo: GodotTypeInfo godotTypeInfo(propTypeIdent)
when compiles(godotTypeInfo(propTypeIdent)): else: GodotTypeInfo()
typeInfo = godotTypeInfo(propTypeIdent)
const hintStr = when hintStrLit != "NIM": const hintStr = when hintStrLit != "NIM":
hintStrLit hintStrLit
else: else:
@ -455,7 +454,8 @@ proc genType(obj: ObjectDecl): NimNode {.compileTime.} =
let initBody = newStmtList() let initBody = newStmtList()
for decl in obj.fields: for decl in obj.fields:
if not decl.defaultValue.isNil and decl.defaultValue.kind != nnkEmpty: 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 let name = if not decl.isExported: decl.name
else: postfix(decl.name, "*") else: postfix(decl.name, "*")
recList.add(newIdentDefs(name, decl.typ)) recList.add(newIdentDefs(name, decl.typ))