src/threadButler/register

Source   Edit  

Deals with storing procs and types in the CacheTables types (typeTable) and routes (routeTable). Abstracts them away in order to hide the logic needed to store and retrieve multiple NimNodes for a single key.

Types

ThreadName = distinct string
Source   Edit  

Procs

proc `==`(x, y: ThreadName): bool {.borrow, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc addProperty(name: ThreadName; property: NimNode) {....raises: [ValueError],
    tags: [], forbids: [].}
Source   Edit  
proc addRoute(name: ThreadName; procDef: NimNode) {....raises: [ValueError],
    tags: [], forbids: [].}
Stores the nnkProcDef NimNode procDef for name in the CacheTable routes. Raises a compile-time error if:
  • No type was registered matching the first parameter type of procDef
  • A handler proc with the same first parameter type was already registered for name
Source   Edit  
proc addType(name: ThreadName; typeDef: NimNode) {....raises: [ValueError],
    tags: [], forbids: [].}
Stores the nnkTypeDef NimNode typeDef for name in the CacheTable types. Raises a compile-time error if a type with the same name was already registered for name. Source   Edit  
proc firstParamType(node: NimNode): NimNode {....raises: [ValueError], tags: [],
    forbids: [].}
Extracts the nnkTypeDef NimNode of the first parameter from an nnkProcDef NimNode Source   Edit  
proc getProcForType(name: ThreadName; typName: string): Option[NimNode] {.
    ...raises: [ValueError], tags: [], forbids: [].}
Fetches the nnkProcDef NimNode of a handler proc whose first parameter type name is typName registered for name. Source   Edit  
proc getProperties(name: ThreadName): seq[NimNode] {....raises: [], tags: [],
    forbids: [].}
Returns a list of all registered properties for name Returns an empty list if no properties were ever registered for name. Source   Edit  
proc getRegisteredThreadnames(): seq[ThreadName] {....raises: [], tags: [],
    forbids: [].}
Source   Edit  
proc getRoutes(name: ThreadName): seq[NimNode] {....raises: [], tags: [],
    forbids: [].}
Returns a list of all registered routes for name Returns an empty list if no routes were ever registered for name. Source   Edit  
proc getTypeOfName(name: ThreadName; typName: string): Option[NimNode] {.
    ...raises: [ValueError], tags: [], forbids: [].}
Fetches the nnkTypeDef NimNode of a type with the name typName registered for name. Source   Edit  
proc getTypes(name: ThreadName): seq[NimNode] {....raises: [], tags: [],
    forbids: [].}
Returns a list of all registered types for name Returns an empty list if no types were ever registered for name. Source   Edit  
proc hasProcForType(name: ThreadName; typName: string): bool {.
    ...raises: [ValueError], tags: [], forbids: [].}
Checks if a handler proc whose first parameter type is typName is already registered for name. Source   Edit  
proc hasRoutes(name: ThreadName): bool {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc hasTypeOfName(name: ThreadName; typName: string): bool {.
    ...raises: [ValueError], tags: [], forbids: [].}
Checks if a type of name typName is already registered for name. Source   Edit  
proc hasTypes(name: ThreadName): bool {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc registerThread(name: ThreadName) {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc typeName(node: NimNode): string {....raises: [ValueError], tags: [],
                                       forbids: [].}
Extracts the name of a type from an nnkTypeDef NimNode Source   Edit