diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2010-02-24 01:04:39 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2010-02-24 01:04:39 +0100 |
commit | f41bd71e6152174c3b0819c7549fa431e8a01222 (patch) | |
tree | 35bec88bad6f84e9551316888744037e8d15e598 /lib/pure/variants.nim | |
parent | 6da95ed9ca899db702c6a7b17d2d7db14dbb0de4 (diff) | |
download | Nim-f41bd71e6152174c3b0819c7549fa431e8a01222.tar.gz |
SQLite wrapper
Diffstat (limited to 'lib/pure/variants.nim')
-rw-r--r-- | lib/pure/variants.nim | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/lib/pure/variants.nim b/lib/pure/variants.nim index 61b4bf163..0b4f078e7 100644 --- a/lib/pure/variants.nim +++ b/lib/pure/variants.nim @@ -1,7 +1,7 @@ # # # Nimrod's Runtime Library -# (c) Copyright 2009 Andreas Rumpf +# (c) Copyright 2010 Andreas Rumpf # # See the file "copying.txt", included in this # distribution, for details about the copyright. @@ -35,41 +35,41 @@ type iterator objectFields*[T](x: T, skipInherited: bool): tuple[ key: string, val: TVariant] {.magic: "ObjectFields"} -proc `<>`*(x: ordinal): TVariant = +proc `?`*(x: ordinal): TVariant = result.kind = vtEnum result.vint = x -proc `<>`*(x: biggestInt): TVariant = +proc `?`*(x: biggestInt): TVariant = result.kind = vtInt result.vint = x -proc `<>`*(x: char): TVariant = +proc `?`*(x: char): TVariant = result.kind = vtChar result.vint = ord(x) -proc `<>`*(x: bool): TVariant = +proc `?`*(x: bool): TVariant = result.kind = vtBool result.vint = ord(x) -proc `<>`*(x: biggestFloat): TVariant = +proc `?`*(x: biggestFloat): TVariant = result.kind = vtFloat result.vfloat = x -proc `<>`*(x: string): TVariant = +proc `?`*(x: string): TVariant = result.kind = vtString result.vstring = x -proc `<>`*[T](x: openArray[T]): TVariant = +proc `?`*[T](x: openArray[T]): TVariant = result.kind = vtSeq newSeq(result.q, x.len) for i in 0..x.len-1: result.q[i] = <>x[i] -proc `<>`*[T](x: set[T]): TVariant = +proc `?`*[T](x: set[T]): TVariant = result.kind = vtSet result.q = @[] for a in items(x): result.q.add(<>a) -proc `<>`* [T: object](x: T): TVariant {.magic: "ToVariant".} +proc `?`* [T: object](x: T): TVariant {.magic: "ToVariant".} ## this converts a value to a variant ("boxing") proc `><`*[T](v: TVariant, typ: T): T {.magic: "FromVariant".} @@ -140,10 +140,10 @@ proc `[]=`* (a, b, c: TVariant) = 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 -proc `[]=`* (a: TVariant, b: string, c: TVariant) {.inline} = a[<>b] = c +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 +proc `[]=`* (a: TVariant, b: string, c: TVariant) {.inline} = a[?b] = c proc `+`* (x, y: TVariant): TVariant = case x.vtype |