diff options
Diffstat (limited to 'nimlib')
-rwxr-xr-x | nimlib/pure/variants.nim | 22 | ||||
-rwxr-xr-x | nimlib/system/sysstr.nim | 10 |
2 files changed, 16 insertions, 16 deletions
diff --git a/nimlib/pure/variants.nim b/nimlib/pure/variants.nim index f661f81a6..40679c779 100755 --- a/nimlib/pure/variants.nim +++ b/nimlib/pure/variants.nim @@ -9,12 +9,12 @@ ## This module implements Nimrod's support for the ``variant`` datatype. ## `TVariant` shows how the flexibility of dynamic typing is achieved -## within a static type system. +## within a static type system. type TVarType* = enum vtNone, - vtBool, + vtBool, vtChar, vtEnum, vtInt, @@ -31,7 +31,7 @@ type of vtString: vstring: string of vtSet, vtSeq: q: seq[TVariant] of vtDict: d: seq[tuple[key, val: TVariant]] - + iterator objectFields*[T](x: T, skipInherited: bool): tuple[ key: string, val: TVariant] {.magic: "ObjectFields"} @@ -74,10 +74,10 @@ proc `<>`* [T: object](x: T): TVariant {.magic: "ToVariant".} proc `><`*[T](v: TVariant, typ: T): T {.magic: "FromVariant".} -[<>5, <>67, <>"hallo"] +[<>5, <>67, <>"hello"] myVar><int - + proc `==`* (x, y: TVariant): bool = if x.vtype == y.vtype: case x.vtype @@ -139,7 +139,7 @@ proc `[]=`* (a, b, c: TVariant) = a.d[b.vint].val = c variantError() else: variantError() - + proc `[]`* (a: TVariant, b: int): TVariant {.inline} = return a[<>b] proc `[]`* (a: TVariant, b: string): TVariant {.inline} = return a[<>b] proc `[]=`* (a: TVariant, b: int, c: TVariant) {.inline} = a[<>b] = c @@ -154,9 +154,9 @@ proc `+`* (x, y: TVariant): TVariant = else: case y.vtype of vtBool, vtChar, vtEnum, vtInt: - - - + + + vint: int64 of vtFloat: vfloat: float64 of vtString: vstring: string @@ -171,11 +171,11 @@ proc `mod`* (x, y: TVariant): TVariant proc `&`* (x, y: TVariant): TVariant proc `$`* (x: TVariant): string = # uses JS notation - + proc parseVariant*(s: string): TVariant proc `<`* (x, y: TVariant): bool proc `<=`* (x, y: TVariant): bool proc hash*(x: TVariant): int = - + diff --git a/nimlib/system/sysstr.nim b/nimlib/system/sysstr.nim index 808941c06..20a49093b 100755 --- a/nimlib/system/sysstr.nim +++ b/nimlib/system/sysstr.nim @@ -104,7 +104,7 @@ proc addChar(s: NimString, c: char): NimString {.compilerProc.} = # These routines should be used like following: # <Nimrod code> -# s &= "hallo " & name & " how do you feel?" +# s &= "Hello " & name & ", how do you feel?" # # <generated C code> # { @@ -115,7 +115,7 @@ proc addChar(s: NimString, c: char): NimString {.compilerProc.} = # } # # <Nimrod code> -# s = "hallo " & name & " how do you feel?" +# s = "Hello " & name & ", how do you feel?" # # <generated C code> # { @@ -180,8 +180,8 @@ proc incrSeq(seq: PGenericSeq, elemSize: int): PGenericSeq {.compilerProc.} = result = cast[PGenericSeq](newSeq(extGetCellType(seq), s)) genericSeqAssign(result, seq, XXX) #copyMem(result, seq, seq.len * elemSize + GenericSeqSize) - inc(result.len) - else: + inc(result.len) + else: result = seq if result.len >= result.space: result.space = resize(result.space) @@ -214,7 +214,7 @@ proc setLengthSeq(seq: PGenericSeq, elemSize, newLen: int): PGenericSeq {. # we need to decref here, otherwise the GC leaks! when not defined(boehmGC) and not defined(nogc): for i in newLen..result.len-1: - forAllChildrenAux(cast[pointer](cast[TAddress](result) +% + forAllChildrenAux(cast[pointer](cast[TAddress](result) +% GenericSeqSize +% (i*%elemSize)), extGetCellType(result).base, waZctDecRef) # and set the memory to nil: |