Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2017
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nim 0.48 KB | None | 0 0
  1. import tables
  2. import macros
  3.  
  4. type
  5.   UIWidget = object
  6.     test: int
  7.   UICustom = proc(widget: UIWidget): NimNode
  8.  
  9. static:
  10.   var custom: Table[string, proc(): UICustom]
  11.   custom = initTable[string, proc(): UICustom]()
  12.  
  13. macro registerCustom(creator: static[proc(): UICustom]): untyped =
  14.   result = newStmtList()
  15.   custom["Hello"] = creator
  16.  
  17. proc myType(): UICustom {.compileTime.} =
  18.   result = (proc(widget: UIWidget): NimNode =
  19.     newStmtList()
  20.   )
  21.  
  22. registerCustom(myType)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement