preparations for 0.8.12

This commit is contained in:
Araq
2011-07-10 15:48:13 +02:00
parent 2565ff8dde
commit 5b96eaa953
81 changed files with 2355 additions and 826 deletions

16
lib/core/typeinfo.nim Normal file → Executable file
View File

@@ -45,8 +45,8 @@ type
TAny* = object {.pure.} ## 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.
## wrapped value and **must not** live longer than
## its wrapped value.
value: pointer
rawType: PNimType
@@ -97,7 +97,7 @@ proc newAny(value: pointer, rawType: PNimType): TAny =
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`!
## that the wrapper **does not** live longer than `x`!
result.value = addr(x)
result.rawType = cast[PNimType](getTypeInfo(x))
@@ -106,7 +106,7 @@ proc kind*(x: TAny): TAnyKind {.inline.} =
result = TAnyKind(ord(x.rawType.kind))
proc baseTypeKind*(x: TAny): TAnyKind {.inline.} =
## get the base type's kind; akNone is returned if `x` has no base type.
## get the base type's kind; ``akNone`` is returned if `x` has no base type.
if x.rawType.base != nil:
result = TAnyKind(ord(x.rawType.base.kind))
@@ -586,13 +586,13 @@ when isMainModule:
block:
# gimme a new scope dammit
var myarr: array[0..4, array[0..4, string]] = [
["test", "1", "2", "3", "4"], ["test", "1", "2", "3", "4"],
["test", "1", "2", "3", "4"], ["test", "1", "2", "3", "4"],
var myarr: array[0..4, array[0..4, string]] = [
["test", "1", "2", "3", "4"], ["test", "1", "2", "3", "4"],
["test", "1", "2", "3", "4"], ["test", "1", "2", "3", "4"],
["test", "1", "2", "3", "4"]]
var m = toAny(myArr)
for i in 0 .. m.len-1:
for j in 0 .. m[i].len-1:
echo getString(m[i][j])