This module implements an interface to Nim's runtime type information (RTTI). Note that even though Any
and its operations hide the nasty low level details from its clients, it remains inherently unsafe!
See the marshal module for what this module allows you to do.
AnyKind = 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
any
it is Any = object value: pointer when defined(js): rawType: PNimType else: rawTypePtr: pointer
Any
keeps a non-traced pointer to its wrapped value and must not live longer than its wrapped value. proc toAny[T](x: var T): Any {.inline.}
Any
object from x. This captures x's address, so x can be modified with its Any
wrapper! The client needs to ensure that the wrapper does not live longer than x! proc kind(x: Any): AnyKind {.inline, raises: [], tags: [].}
proc size(x: Any): int {.inline, raises: [], tags: [].}
proc baseTypeKind(x: Any): AnyKind {.inline, raises: [], tags: [].}
akNone
is returned if x has no base type. proc baseTypeSize(x: Any): int {.inline, raises: [], tags: [].}
proc invokeNew(x: Any) {.raises: [], tags: [].}
new(x)
. x needs to represent a ref
. proc invokeNewSeq(x: Any; len: int) {.raises: [], tags: [].}
newSeq(x, len)
. x needs to represent a seq
. proc extendSeq(x: Any) {.raises: [], tags: [].}
setLen(x, x.len+1)
. x needs to represent a seq
. proc setObjectRuntimeType(x: Any) {.raises: [], tags: [].}
proc `[]`(x: Any; i: int): Any {.raises: [IndexError, ValueError], tags: [].}
proc `[]=`(x: Any; i: int; y: Any) {.raises: [IndexError, ValueError], tags: [].}
proc len(x: Any): int {.raises: [], tags: [].}
proc base(x: Any): Any {.raises: [], tags: [].}
proc isNil(x: Any): bool {.raises: [], tags: [].}
proc getPointer(x: Any): pointer {.raises: [], tags: [].}
x
needs to be of kind akString
, akCString
, akProc
, akRef
, akPtr
, akPointer
, akSequence
. proc setPointer(x: Any; y: pointer) {.raises: [], tags: [].}
x
needs to be of kind akString
, akCString
, akProc
, akRef
, akPtr
, akPointer
, akSequence
. proc `[]=`(x: Any; fieldName: string; value: Any) {.raises: [ValueError], tags: [].}
proc `[]`(x: Any; fieldName: string): Any {.raises: [ValueError], tags: [].}
proc `[]`(x: Any): Any {.raises: [], tags: [].}
proc `[]=`(x, y: Any) {.raises: [], tags: [].}
proc getInt(x: Any): int {.raises: [], tags: [].}
proc getInt8(x: Any): int8 {.raises: [], tags: [].}
proc getInt16(x: Any): int16 {.raises: [], tags: [].}
proc getInt32(x: Any): int32 {.raises: [], tags: [].}
proc getInt64(x: Any): int64 {.raises: [], tags: [].}
proc getBiggestInt(x: Any): BiggestInt {.raises: [], tags: [].}
BiggestInt
. proc setBiggestInt(x: Any; y: BiggestInt) {.raises: [], tags: [].}
proc getUInt(x: Any): uint {.raises: [], tags: [].}
proc getUInt8(x: Any): uint8 {.raises: [], tags: [].}
proc getUInt16(x: Any): uint16 {.raises: [], tags: [].}
proc getUInt32(x: Any): uint32 {.raises: [], tags: [].}
proc getUInt64(x: Any): uint64 {.raises: [], tags: [].}
proc getBiggestUint(x: Any): uint64 {.raises: [], tags: [].}
proc setBiggestUint(x: Any; y: uint64) {.raises: [], tags: [].}
proc getChar(x: Any): char {.raises: [], tags: [].}
proc getBool(x: Any): bool {.raises: [], tags: [].}
proc skipRange(x: Any): Any {.raises: [], tags: [].}
proc getEnumOrdinal(x: Any; name: string): int {.raises: [], tags: [].}
low(int)
is returned. proc getEnumField(x: Any; ordinalValue: int): string {.raises: [], tags: [].}
proc getEnumField(x: Any): string {.raises: [], tags: [].}
proc getFloat(x: Any): float {.raises: [], tags: [].}
proc getFloat32(x: Any): float32 {.raises: [], tags: [].}
proc getFloat64(x: Any): float64 {.raises: [], tags: [].}
proc getBiggestFloat(x: Any): BiggestFloat {.raises: [], tags: [].}
BiggestFloat
. proc setBiggestFloat(x: Any; y: BiggestFloat) {.raises: [], tags: [].}
proc getString(x: Any): string {.raises: [], tags: [].}
proc setString(x: Any; y: string) {.raises: [], tags: [].}
proc getCString(x: Any): cstring {.raises: [], tags: [].}
proc assign(x, y: Any) {.raises: [], tags: [].}
Any
does NOT do this; it performs a shallow copy instead! proc inclSetElement(x: Any; elem: int) {.raises: [], tags: [].}
iterator fields(x: Any): tuple[name: string, any: Any] {.raises: [], tags: [].}
iterator elements(x: Any): int {.raises: [], tags: [].}
© 2006–2017 Andreas Rumpf
Licensed under the MIT License.
https://nim-lang.org/docs/typeinfo.html