src/threadButler/utils

Source   Edit  

Defines utilities for making validation of individual steps in code-generation easy.

This module is only intended for use within threadButler and for integrations.

Procs

proc assertKind(node: NimNode; kind: NimNodeKind; msg: string = "") {.
    ...raises: [ValueError], tags: [], forbids: [].}
Source   Edit  
proc assertKind(node: NimNode; kind: seq[NimNodeKind]; msg: string = "") {.
    ...raises: [ValueError], tags: [], forbids: [].}
Custom version of expectKind, uses doAssert which can never be turned off. Use this throughout procs to validate that the nodes they get are of specific kinds. Also enables custom error messages. Source   Edit  
proc expectKind(node: NimNode; kinds: seq[NimNodeKind]; msg: string) {.
    ...raises: [ValueError], tags: [], forbids: [].}
Custom version of expectKind, uses "error" which can be turned off. Use this within every macro to validate the user input Also enforces custom error messages to be helpful to users. Source   Edit  
proc getNodesOfKind(node: NimNode; nodeKind: NimNodeKind): seq[NimNode] {.
    ...raises: [], tags: [], forbids: [].}
Recursively traverses the AST in node and returns all nodes of the given nodeKind. Source   Edit  
proc isAsyncProc(procDef: NimNode): bool {....raises: [ValueError], tags: [],
    forbids: [].}
Checks if a given procDef represents an async proc Source   Edit