macros: take multiple arguments at assert
The assertion record may have multiple fields, so take multiple arguments.
This commit is contained in:
parent
50afa0107f
commit
3de97c5cf1
|
@ -156,11 +156,23 @@ macro onRetracted*(class: static[RecordClass]; doHandler: untyped) =
|
|||
macro onMessage*(class: static[RecordClass]; doHandler: untyped) =
|
||||
onEvent(messageEvent, class, doHandler)
|
||||
|
||||
template assert*(class: RecordClass; field: untyped): untyped =
|
||||
template onStart*(body: untyped): untyped =
|
||||
mixin getCurrentFacet
|
||||
getCurrentFacet().addStartScript do (facet: Facet):
|
||||
proc getCurrentFacet(): Facet {.inject, used.} = facet
|
||||
body
|
||||
|
||||
template onStop*(body: untyped): untyped =
|
||||
mixin getCurrentFacet
|
||||
getCurrentFacet().addStopScript do (facet: Facet):
|
||||
proc getCurrentFacet(): Facet {.inject, used.} = facet
|
||||
body
|
||||
|
||||
template assert*(class: RecordClass; fields: varargs[Preserve, toPreserve]): untyped =
|
||||
mixin getCurrentFacet
|
||||
let facet = getCurrentFacet()
|
||||
discard facet.addEndpoint do (_: Facet) -> EndpointSpec:
|
||||
let a = init(class, getPreserve(field))
|
||||
let a = init(class, fields)
|
||||
result.assertion = some(a)
|
||||
|
||||
template field*(F: untyped; T: typedesc; initial: T): untyped =
|
||||
|
|
Loading…
Reference in New Issue