Skip to content

openpeeps/voodoo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation


Working with Nim's macros πŸ‘‘ is just Voodoo

nimble install voodoo

API reference
Github Actions Github Actions

😍 Key Features

  • Compile-time utility tool
  • Helps reduce code size & repetitive tasks
  • Generate fast getters/setters
  • Callee Introspection

Examples

Getters

Generate fast getters from object fields. Excluding fields is also possible.

import pkg/voodoo

type
  Price* {.getters.} = object
    net, gross: string

  Product* {.getters: [id].} = object # exclude one or more fields
    id: string
    title, short_description: string
    prices: Price

expandGetters() # is required to expand generated procs.

Output:

proc getNet*(price: Price): string =
  ## Get `net` from `Price`
  result = price.net

proc getGross*(price: Price): string =
  ## Get `gross` from `Price`
  result = price.gross

proc getTitle*(product: Product): string =
  ## Get `title` from `Product`
  result = product.title

proc getShortDescription*(product: Product): string =
  ## Get `short_description` from `Product`
  result = product.short_description

proc getPrices*(product: Product): seq[Price] =
  ## Get `prices` from `Product`
  result = product.prices

Setters

todo

Callee

todo

❀ Contributions & Support

🎩 License

MIT license. Made by Humans from OpenPeeps.
Copyright Β© 2024 OpenPeeps & Contributors β€” All rights reserved.

Releases

No releases published

Packages

No packages published

Languages