src/pylib/Lib/time_impl/private/macro_utils

Source   Edit  

Types

CmpStragy = enum
  csEq, csLhs, csRhs, csShorter ## stop on the shorter one.
Source   Edit  

Macros

macro addFields(res: string; obj: typed; noMoreThan: static[int] = int.high)

obj is of object or ref object. when obj is of object and noMoreThan is not given, it's roughly equal to:

let startLen = res.len
for k, v in o.fieldPairs:
  res.addSep(sep=", ", startLen = startLen)
  res.add k & '=' & repr v

Source   Edit  
macro asgSeqToObj(tup, obj: typed)
obj can be of ref object or object Retionale: there is fields/fieldPairs iterator in std/system, but for tuple/object only, not for ref object. Source   Edit  
macro cmpOnField(a, b: typed): int
Source   Edit  
macro declTupleWithNFieldsFrom(name: untyped; Cls: typedesc; n: static[int];
                               exported: static[bool] = true)
Source   Edit  
macro mixinOrderOnFields(lhs, rhs: typed; cmpOp;
                         cmpStragy: static[CmpStragy] = csEq): bool

cmpOnFields but a b can be of different types.

e.g. a is tuple and b is object; or a, b are different objects.

Source   Edit  
macro orderOnFields[T](a, b: T; cmpOp): bool

mainly for checking if ref objects are equal on fields

when for object/tuple and cmpOp is ==, roughly equal to: a == b

but system.== for ref just compare the address.

Source   Edit