mirror of
https://github.com/zedeus/nitter
synced 2026-09-05 22:59:31 +00:00
Generate preference type
This commit is contained in:
parent
f1d566fff6
commit
8208676e6e
2 changed files with 16 additions and 13 deletions
|
|
@ -105,3 +105,16 @@ macro genUpdatePrefs*(): untyped =
|
|||
result.add quote do:
|
||||
cache(prefs)
|
||||
|
||||
macro genPrefsType*(): untyped =
|
||||
let name = nnkPostfix.newTree(ident("*"), ident("Prefs"))
|
||||
result = quote do:
|
||||
type `name` = object
|
||||
id* {.pk, ro.}: int
|
||||
|
||||
for pref in allPrefs():
|
||||
result[0][2][2].add nnkIdentDefs.newTree(
|
||||
nnkPostfix.newTree(ident("*"), ident(pref.name)),
|
||||
(case pref.kind
|
||||
of checkbox: ident("bool")
|
||||
of input, select: ident("string")),
|
||||
newEmptyNode())
|
||||
|
|
|
|||
Loading…
Reference in a new issue