initial support for user defined helpers from within QtType. Implemented by delaying the definition of user deined items (procs, methods, etc.) until after create. This was necessary as create is currently defined as a template and we can't use a forward declaration.

This commit is contained in:
Will Szumski 2015-01-04 19:22:05 +00:00
parent 17eb1e748e
commit 4f1da7957b
1 changed files with 10 additions and 1 deletions

View File

@ -13,7 +13,6 @@ template debug(body: stmt): stmt =
else: else:
{.pop.} {.pop.}
let nimFromQtVariant {.compileTime.} = { let nimFromQtVariant {.compileTime.} = {
"int" : "intVal", "int" : "intVal",
"string" : "stringVal", "string" : "stringVal",
@ -235,6 +234,8 @@ macro QtType*(qtDecl: stmt): stmt {.immediate.} =
var slots = newSeq[PNimrodNode]() var slots = newSeq[PNimrodNode]()
var properties = newSeq[PNimrodNode]() var properties = newSeq[PNimrodNode]()
var signals = newSeq[PNimrodNode]() var signals = newSeq[PNimrodNode]()
# holds all user defined procedures so we can add them after create
var userDefined = newSeq[PNimrodNode]()
# assume only one type per section for now # assume only one type per section for now
var typ: PNimrodNode var typ: PNimrodNode
for it in qtDecl.children(): for it in qtDecl.children():
@ -267,6 +268,10 @@ macro QtType*(qtDecl: stmt): stmt {.immediate.} =
it.body = addSignalBody(it) it.body = addSignalBody(it)
result.add it result.add it
signals.add it signals.add it
else:
userDefined.add it
elif it.kind == nnkProcDef:
userDefined.add it
else: else:
# everything else should pass through unchanged # everything else should pass through unchanged
result.add it result.add it
@ -368,5 +373,9 @@ macro QtType*(qtDecl: stmt): stmt {.immediate.} =
#echo repr createProto #echo repr createProto
result.add createProto result.add createProto
for fn in userDefined:
result.add fn
debug: debug:
echo repr result echo repr result