Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tables
- import macros
- type
- UIWidget = object
- test: int
- UICustom = proc(widget: UIWidget): NimNode
- static:
- var custom: Table[string, proc(): UICustom]
- custom = initTable[string, proc(): UICustom]()
- macro registerCustom(creator: static[proc(): UICustom]): untyped =
- result = newStmtList()
- custom["Hello"] = creator
- proc myType(): UICustom {.compileTime.} =
- result = (proc(widget: UIWidget): NimNode =
- newStmtList()
- )
- registerCustom(myType)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement