# Module typeinfo

This module implements an interface to Nimrod's runtime type information. Note that even though `TAny` and its operations hide the nasty low level details from its clients, it remains inherently unsafe!

# Types

    TAnyKind* = enum
      akNone = 0,                 ## invalid any
      akBool = 1,                 ## any represents a ``bool``
      akChar = 2,                 ## any represents a ``char``
      akEnum = 14,                ## any represents an enum
      akArray = 16,               ## any represents an array
      akObject = 17,              ## any represents an object
      akTuple = 18,               ## any represents a tuple
      akSet = 19,                 ## any represents a set
      akRange = 20,               ## any represents a range
      akPtr = 21,                 ## any represents a ptr
      akRef = 22,                 ## any represents a ref
      akSequence = 24,            ## any represents a sequence
      akProc = 25,                ## any represents a proc
      akPointer = 26,             ## any represents a pointer
      akString = 28,              ## any represents a string
      akCString = 29,             ## any represents a cstring
      akInt = 31,                 ## any represents an int
      akInt8 = 32,                ## any represents an int8
      akInt16 = 33,               ## any represents an int16
      akInt32 = 34,               ## any represents an int32
      akInt64 = 35,               ## any represents an int64
      akFloat = 36,               ## any represents a float
      akFloat32 = 37,             ## any represents a float32
      akFloat64 = 38,             ## any represents a float64
      akFloat128 = 39,            ## any represents a float128
      akUInt = 40,                ## any represents an unsigned int
      akUInt8 = 41,               ## any represents an unsigned int8
      akUInt16 = 42,              ## any represents an unsigned in16
      akUInt32 = 43,              ## any represents an unsigned int32
      akUInt64 = 44               ## any represents an unsigned int64

  what kind of `any` it is

    TAny* = object  {.pure.}
      value: pointer
      rawType: PNimType

  can represent any nimrod value; NOTE: the wrapped value can be modified with its wrapper! This means that `TAny` keeps a non-traced pointer to its wrapped value and must not live longer than its wrapped value.

# Procs

    proc toAny*[T](x: var T): TAny {.inline.}

  constructs a `TAny` object from x. This captures x's address, so x can be modified with its `TAny` wrapper! The client needs to ensure that the wrapper does not live longer than x!

    proc kind*(x: TAny): TAnyKind {.inline.}

  get the type kind

    proc size*(x: TAny): int {.inline.}

  returns the size of x's type.

    proc baseTypeKind*(x: TAny): TAnyKind {.inline.}

  get the base type's kind; `akNone` is returned if x has no base type.

    proc baseTypeSize*(x: TAny): int {.inline.}

  returns the size of x's basetype.

    proc invokeNew*(x: TAny)

  performs `new(x)`. x needs to represent a `ref`.

    proc invokeNewSeq*(x: TAny; len: int)

  performs `newSeq(x, len)`. x needs to represent a `seq`.

    proc extendSeq*(x: TAny; elems = 1)

  performs `setLen(x, x.len+elems)`. x needs to represent a `seq`.

    proc setObjectRuntimeType*(x: TAny)

  this needs to be called to set x's runtime object type field.

    proc `[]`*(x: TAny; i: int): TAny

  accessor for an any x that represents an array or a sequence.

    proc `[] =`*(x: TAny; i: int; y: TAny)

  accessor for an any x that represents an array or a sequence.

    proc len*(x: TAny): int

  len for an any x that represents an array or a sequence.

    proc isNil*(x: TAny): bool

  isNil for an any x that represents a sequence, string, cstring, proc or some pointer type.

    proc getPointer*(x: TAny): pointer

  retrieve the pointer value out of x. `x` needs to be of kind `akString`, `akCString`, `akProc`, `akRef`, `akPtr`, `akPointer`, `akSequence`.

    proc setPointer*(x: TAny; y: pointer)

  sets the pointer value of x. `x` needs to be of kind `akString`, `akCString`, `akProc`, `akRef`, `akPtr`, `akPointer`, `akSequence`.

    proc `[] =`*(x: TAny; fieldName: string; value: TAny)

  sets a field of x; x represents an object or a tuple.

    proc `[]`*(x: TAny; fieldName: string): TAny

  gets a field of x; x represents an object or a tuple.

    proc `[]`*(x: TAny): TAny

  dereference operation for the any x that represents a ptr or a ref.

    proc `[] =`*(x, y: TAny)

  dereference operation for the any x that represents a ptr or a ref.

    proc getInt*(x: TAny): int

  retrieve the int value out of x. x needs to represent an int.

    proc getInt8*(x: TAny): int8

  retrieve the int8 value out of x. x needs to represent an int8.

    proc getInt16*(x: TAny): int16

  retrieve the int16 value out of x. x needs to represent an int16.

    proc getInt32*(x: TAny): int32

  retrieve the int32 value out of x. x needs to represent an int32.

    proc getInt64*(x: TAny): int64

  retrieve the int64 value out of x. x needs to represent an int64.

    proc getBiggestInt*(x: TAny): biggestInt

  retrieve the integer value out of x. x needs to represent some integer, a bool, a char, an enum or a small enough bit set. The value might be sign-extended to `biggestInt`.

    proc setBiggestInt*(x: TAny; y: biggestInt)

  sets the integer value of x. x needs to represent some integer, a bool, a char, an enum or a small enough bit set.

    proc getChar*(x: TAny): char

  retrieve the char value out of x. x needs to represent a char.

    proc getBool*(x: TAny): bool

  retrieve the bool value out of x. x needs to represent a bool.

    proc skipRange*(x: TAny): TAny

  skips the range information of x.

    proc getEnumOrdinal*(x: TAny; name: string): int

  gets the enum field ordinal from name. x needs to represent an enum but is only used to access the type information. In case of an error `low(int)` is returned.

    proc getEnumField*(x: TAny; ordinalValue: int): string

  gets the enum field name as a string. x needs to represent an enum but is only used to access the type information. The field name of ordinalValue is returned.

    proc getEnumField*(x: TAny): string

  gets the enum field name as a string. x needs to represent an enum.

    proc getFloat*(x: TAny): float

  retrieve the float value out of x. x needs to represent an float.

    proc getFloat32*(x: TAny): float32

  retrieve the float32 value out of x. x needs to represent an float32.

    proc getFloat64*(x: TAny): float64

  retrieve the float64 value out of x. x needs to represent an float64.

    proc getBiggestFloat*(x: TAny): biggestFloat

  retrieve the float value out of x. x needs to represent some float. The value is extended to `biggestFloat`.

    proc setBiggestFloat*(x: TAny; y: biggestFloat)

  sets the float value of x. x needs to represent some float.

    proc getString*(x: TAny): string

  retrieve the string value out of x. x needs to represent a string.

    proc setString*(x: TAny; y: string)

  sets the string value of x. x needs to represent a string.

    proc getCString*(x: TAny): cstring

  retrieve the cstring value out of x. x needs to represent a cstring.

    proc assign*(x, y: TAny)

  copies the value of y to x. The assignment operator for `TAny` does NOT do this; it performs a shallow copy instead!

    proc inclSetElement*(x: TAny; elem: int)

  includes an element elem in x. x needs to represent a Nimrod bitset.

# Iterators

    iterator fields*(x: TAny): tuple[name: string, any: TAny]

  iterates over every active field of the any x that represents an object or a tuple.

    iterator elements*(x: TAny): int

  iterates over every element of x that represents a Nimrod bitset.

Generated: 2012-09-23 21:47:53 UTC