From d68181246571de5799059cf6402f1c578cd9421c Mon Sep 17 00:00:00 2001 From: Adam Strzelecki Date: Fri, 4 Sep 2015 23:02:43 +0200 Subject: [PATCH 01/11] compiler: Trim .nim files trailing whitespace via OSX: find . -name '*.nim' -exec sed -i '' -E 's/[[:space:]]+$//' {} + --- compiler/aliases.nim | 60 ++++++++--------- compiler/bitsets.nim | 40 +++++------ compiler/canonicalizer.nim | 132 ++++++++++++++++++------------------- compiler/cgmeth.nim | 84 +++++++++++------------ compiler/docgen2.nim | 10 +-- compiler/evaltempl.nim | 6 +- compiler/filter_tmpl.nim | 98 +++++++++++++-------------- compiler/filters.nim | 38 +++++------ compiler/forloops.nim | 10 +-- compiler/hlo.nim | 4 +- compiler/idents.nim | 34 +++++----- compiler/lists.nim | 48 +++++++------- compiler/magicsys.nim | 26 ++++---- compiler/nimblecmd.nim | 6 +- compiler/nimeval.nim | 2 +- compiler/nimlexbase.nim | 70 ++++++++++---------- compiler/nimsets.nim | 82 +++++++++++------------ compiler/nversion.nim | 2 +- compiler/passaux.nim | 24 +++---- compiler/patterns.nim | 10 +-- compiler/pbraces.nim | 6 +- compiler/procfind.nim | 22 +++---- compiler/rodutils.nim | 34 +++++----- compiler/ropes.nim | 2 +- compiler/saturate.nim | 2 +- compiler/semcall.nim | 2 +- compiler/semfields.nim | 10 +-- compiler/sigmatch.nim | 2 +- compiler/suggest.nim | 74 ++++++++++----------- compiler/syntaxes.nim | 102 ++++++++++++++-------------- compiler/tccgen.nim | 22 +++---- compiler/treetab.nim | 76 ++++++++++----------- 32 files changed, 570 insertions(+), 570 deletions(-) diff --git a/compiler/aliases.nim b/compiler/aliases.nim index 3f3d45ff74..3d3fc9a793 100644 --- a/compiler/aliases.nim +++ b/compiler/aliases.nim @@ -11,7 +11,7 @@ import ast, astalgo, types, trees, intsets, msgs - + type TAnalysisResult* = enum arNo, arMaybe, arYes @@ -21,42 +21,42 @@ proc isPartOfAux(a, b: PType, marker: var IntSet): TAnalysisResult proc isPartOfAux(n: PNode, b: PType, marker: var IntSet): TAnalysisResult = result = arNo case n.kind - of nkRecList: - for i in countup(0, sonsLen(n) - 1): + of nkRecList: + for i in countup(0, sonsLen(n) - 1): result = isPartOfAux(n.sons[i], b, marker) if result == arYes: return of nkRecCase: assert(n.sons[0].kind == nkSym) result = isPartOfAux(n.sons[0], b, marker) if result == arYes: return - for i in countup(1, sonsLen(n) - 1): + for i in countup(1, sonsLen(n) - 1): case n.sons[i].kind - of nkOfBranch, nkElse: + of nkOfBranch, nkElse: result = isPartOfAux(lastSon(n.sons[i]), b, marker) if result == arYes: return else: internalError("isPartOfAux(record case branch)") of nkSym: result = isPartOfAux(n.sym.typ, b, marker) else: internalError(n.info, "isPartOfAux()") - -proc isPartOfAux(a, b: PType, marker: var IntSet): TAnalysisResult = + +proc isPartOfAux(a, b: PType, marker: var IntSet): TAnalysisResult = result = arNo - if a == nil or b == nil: return - if containsOrIncl(marker, a.id): return + if a == nil or b == nil: return + if containsOrIncl(marker, a.id): return if compareTypes(a, b, dcEqIgnoreDistinct): return arYes case a.kind - of tyObject: + of tyObject: result = isPartOfAux(a.sons[0], b, marker) if result == arNo: result = isPartOfAux(a.n, b, marker) of tyGenericInst, tyDistinct: result = isPartOfAux(lastSon(a), b, marker) - of tyArray, tyArrayConstr, tySet, tyTuple: - for i in countup(0, sonsLen(a) - 1): + of tyArray, tyArrayConstr, tySet, tyTuple: + for i in countup(0, sonsLen(a) - 1): result = isPartOfAux(a.sons[i], b, marker) - if result == arYes: return + if result == arYes: return else: discard -proc isPartOf(a, b: PType): TAnalysisResult = +proc isPartOf(a, b: PType): TAnalysisResult = ## checks iff 'a' can be part of 'b'. Iterates over VALUE types! var marker = initIntSet() # watch out: parameters reversed because I'm too lazy to change the code... @@ -70,14 +70,14 @@ proc isPartOf*(a, b: PNode): TAnalysisResult = ## type. Since however type analysis is more expensive, we perform it only ## if necessary. ## - ## cases: + ## cases: ## ## YES-cases: ## x <| x # for general trees ## x[] <| x ## x[i] <| x ## x.f <| x - ## + ## ## NO-cases: ## x !<| y # depending on type and symbol kind ## x[constA] !<| x[constB] @@ -88,16 +88,16 @@ proc isPartOf*(a, b: PNode): TAnalysisResult = ## ## x[] ?<| y[] iff compatible type ## - ## + ## ## x[] ?<| y depending on type - ## + ## if a.kind == b.kind: case a.kind of nkSym: const varKinds = {skVar, skTemp, skProc} # same symbol: aliasing: if a.sym.id == b.sym.id: result = arYes - elif a.sym.kind in varKinds or b.sym.kind in varKinds: + elif a.sym.kind in varKinds or b.sym.kind in varKinds: # actually, a param could alias a var but we know that cannot happen # here. XXX make this more generic result = arNo @@ -110,11 +110,11 @@ proc isPartOf*(a, b: PNode): TAnalysisResult = if len(a) >= 2 and len(b) >= 2: # array accesses: if result == arYes and isDeepConstExpr(a[1]) and isDeepConstExpr(b[1]): - # we know it's the same array and we have 2 constant indexes; - # if they are + # we know it's the same array and we have 2 constant indexes; + # if they are var x = if a[1].kind == nkHiddenStdConv: a[1][1] else: a[1] var y = if b[1].kind == nkHiddenStdConv: b[1][1] else: b[1] - + if sameValue(x, y): result = arYes else: result = arNo # else: maybe and no are accurate @@ -122,7 +122,7 @@ proc isPartOf*(a, b: PNode): TAnalysisResult = # pointer derefs: if result != arYes: if isPartOf(a.typ, b.typ) != arNo: result = arMaybe - + of nkDotExpr: result = isPartOf(a[0], b[0]) if result != arNo: @@ -135,7 +135,7 @@ proc isPartOf*(a, b: PNode): TAnalysisResult = # weaken because of indirection: if result != arYes: if isPartOf(a.typ, b.typ) != arNo: result = arMaybe - + of nkHiddenStdConv, nkHiddenSubConv, nkConv: result = isPartOf(a[1], b[1]) of nkObjUpConv, nkObjDownConv, nkCheckedFieldExpr: @@ -144,7 +144,7 @@ proc isPartOf*(a, b: PNode): TAnalysisResult = # Calls return a new location, so a default of ``arNo`` is fine. else: # go down recursively; this is quite demanding: - const + const Ix0Kinds = {nkDotExpr, nkBracketExpr, nkObjUpConv, nkObjDownConv, nkCheckedFieldExpr} Ix1Kinds = {nkHiddenStdConv, nkHiddenSubConv, nkConv} @@ -153,17 +153,17 @@ proc isPartOf*(a, b: PNode): TAnalysisResult = of Ix0Kinds: # a* !<| b.f iff a* !<| b result = isPartOf(a, b[0]) - + of DerefKinds: - # a* !<| b[] iff + # a* !<| b[] iff if isPartOf(a.typ, b.typ) != arNo: result = isPartOf(a, b[0]) if result == arNo: result = arMaybe - + of Ix1Kinds: # a* !<| T(b) iff a* !<| b result = isPartOf(a, b[1]) - + of nkSym: # b is an atom, so we have to check a: case a.kind @@ -172,7 +172,7 @@ proc isPartOf*(a, b: PNode): TAnalysisResult = result = isPartOf(a[0], b) of Ix1Kinds: result = isPartOf(a[1], b) - + of DerefKinds: if isPartOf(a.typ, b.typ) != arNo: result = isPartOf(a[0], b) diff --git a/compiler/bitsets.nim b/compiler/bitsets.nim index a2324f4e2b..5454ef5e70 100644 --- a/compiler/bitsets.nim +++ b/compiler/bitsets.nim @@ -10,12 +10,12 @@ # this unit handles Nim sets; it implements bit sets # the code here should be reused in the Nim standard library -type +type TBitSet* = seq[int8] # we use byte here to avoid issues with # cross-compiling; uint would be more efficient # however -const +const ElemSize* = sizeof(int8) * 8 proc bitSetInit*(b: var TBitSet, length: int) @@ -30,42 +30,42 @@ proc bitSetEquals*(x, y: TBitSet): bool proc bitSetContains*(x, y: TBitSet): bool # implementation -proc bitSetIn(x: TBitSet, e: BiggestInt): bool = +proc bitSetIn(x: TBitSet, e: BiggestInt): bool = result = (x[int(e div ElemSize)] and toU8(int(1 shl (e mod ElemSize)))) != toU8(0) -proc bitSetIncl(x: var TBitSet, elem: BiggestInt) = +proc bitSetIncl(x: var TBitSet, elem: BiggestInt) = assert(elem >= 0) x[int(elem div ElemSize)] = x[int(elem div ElemSize)] or toU8(int(1 shl (elem mod ElemSize))) -proc bitSetExcl(x: var TBitSet, elem: BiggestInt) = +proc bitSetExcl(x: var TBitSet, elem: BiggestInt) = x[int(elem div ElemSize)] = x[int(elem div ElemSize)] and not toU8(int(1 shl (elem mod ElemSize))) -proc bitSetInit(b: var TBitSet, length: int) = +proc bitSetInit(b: var TBitSet, length: int) = newSeq(b, length) -proc bitSetUnion(x: var TBitSet, y: TBitSet) = +proc bitSetUnion(x: var TBitSet, y: TBitSet) = for i in countup(0, high(x)): x[i] = x[i] or y[i] - -proc bitSetDiff(x: var TBitSet, y: TBitSet) = + +proc bitSetDiff(x: var TBitSet, y: TBitSet) = for i in countup(0, high(x)): x[i] = x[i] and not y[i] - -proc bitSetSymDiff(x: var TBitSet, y: TBitSet) = + +proc bitSetSymDiff(x: var TBitSet, y: TBitSet) = for i in countup(0, high(x)): x[i] = x[i] xor y[i] - -proc bitSetIntersect(x: var TBitSet, y: TBitSet) = + +proc bitSetIntersect(x: var TBitSet, y: TBitSet) = for i in countup(0, high(x)): x[i] = x[i] and y[i] - -proc bitSetEquals(x, y: TBitSet): bool = - for i in countup(0, high(x)): - if x[i] != y[i]: + +proc bitSetEquals(x, y: TBitSet): bool = + for i in countup(0, high(x)): + if x[i] != y[i]: return false result = true -proc bitSetContains(x, y: TBitSet): bool = - for i in countup(0, high(x)): - if (x[i] and not y[i]) != int8(0): +proc bitSetContains(x, y: TBitSet): bool = + for i in countup(0, high(x)): + if (x[i] and not y[i]) != int8(0): return false result = true diff --git a/compiler/canonicalizer.nim b/compiler/canonicalizer.nim index 6fcc57a913..dc64450351 100644 --- a/compiler/canonicalizer.nim +++ b/compiler/canonicalizer.nim @@ -30,39 +30,39 @@ type # # This is a good compromise between correctness and brevity. ;-) -const +const cb64 = [ "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", - "O", "P", "Q", "R", "S", "T" "U", "V", "W", "X", "Y", "Z", - "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", - "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", + "O", "P", "Q", "R", "S", "T" "U", "V", "W", "X", "Y", "Z", + "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", + "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", - "_A", "_B"] - -proc toBase64a(s: cstring, len: int): string = - ## encodes `s` into base64 representation. After `lineLen` characters, a - ## `newline` is added. - result = newStringOfCap(((len + 2) div 3) * 4) - var i = 0 - while i < s.len - 2: - let a = ord(s[i]) - let b = ord(s[i+1]) - let c = ord(s[i+2]) - result.add cb64[a shr 2] - result.add cb64[((a and 3) shl 4) or ((b and 0xF0) shr 4)] - result.add cb64[((b and 0x0F) shl 2) or ((c and 0xC0) shr 6)] - result.add cb64[c and 0x3F] - inc(i, 3) - if i < s.len-1: - let a = ord(s[i]) - let b = ord(s[i+1]) - result.add cb64[a shr 2] - result.add cb64[((a and 3) shl 4) or ((b and 0xF0) shr 4)] - result.add cb64[((b and 0x0F) shl 2)] - elif i < s.len: - let a = ord(s[i]) - result.add cb64[a shr 2] - result.add cb64[(a and 3) shl 4] + "_A", "_B"] + +proc toBase64a(s: cstring, len: int): string = + ## encodes `s` into base64 representation. After `lineLen` characters, a + ## `newline` is added. + result = newStringOfCap(((len + 2) div 3) * 4) + var i = 0 + while i < s.len - 2: + let a = ord(s[i]) + let b = ord(s[i+1]) + let c = ord(s[i+2]) + result.add cb64[a shr 2] + result.add cb64[((a and 3) shl 4) or ((b and 0xF0) shr 4)] + result.add cb64[((b and 0x0F) shl 2) or ((c and 0xC0) shr 6)] + result.add cb64[c and 0x3F] + inc(i, 3) + if i < s.len-1: + let a = ord(s[i]) + let b = ord(s[i+1]) + result.add cb64[a shr 2] + result.add cb64[((a and 3) shl 4) or ((b and 0xF0) shr 4)] + result.add cb64[((b and 0x0F) shl 2)] + elif i < s.len: + let a = ord(s[i]) + result.add cb64[a shr 2] + result.add cb64[(a and 3) shl 4] proc toBase64a(u: TUid): string = toBase64a(cast[cstring](u), sizeof(u)) @@ -73,7 +73,7 @@ proc hashSym(c: var MD5Context, s: PSym) = c &= ":anon" else: var it = s.owner - while it != nil: + while it != nil: hashSym(c, it) c &= "." it = s.owner @@ -106,18 +106,18 @@ proc hashTree(c: var MD5Context, n: PNode) = proc hashType(c: var MD5Context, t: PType) = # modelled after 'typeToString' - if t == nil: + if t == nil: c &= "\254" return var k = t.kind md5Update(c, cast[cstring](addr(k)), 1) - + if t.sym != nil and sfAnon notin t.sym.flags: # t.n for literals, but not for e.g. objects! if t.kind in {tyFloat, tyInt}: c.hashNode(t.n) c.hashSym(t.sym) - + case t.kind of tyGenericBody, tyGenericInst, tyGenericInvocation: for i in countup(0, sonsLen(t) -1 -ord(t.kind != tyGenericInvocation)): @@ -135,10 +135,10 @@ proc hashType(c: var MD5Context, t: PType) = of tyArrayConstr: c.hashTree(t.sons[0].n) c.hashType(t.sons[1]) - of tyTuple: + of tyTuple: if t.n != nil: assert(sonsLen(t.n) == sonsLen(t)) - for i in countup(0, sonsLen(t.n) - 1): + for i in countup(0, sonsLen(t.n) - 1): assert(t.n.sons[i].kind == nkSym) c &= t.n.sons[i].sym.name.s c &= ":" @@ -184,18 +184,18 @@ proc pushSym(w: PRodWriter, s: PSym) = if iiTableGet(w.index.tab, s.id) == InvalidKey: w.sstack.add(s) -proc encodeNode(w: PRodWriter, fInfo: TLineInfo, n: PNode, - result: var string) = - if n == nil: +proc encodeNode(w: PRodWriter, fInfo: TLineInfo, n: PNode, + result: var string) = + if n == nil: # nil nodes have to be stored too: result.add("()") return result.add('(') - encodeVInt(ord(n.kind), result) + encodeVInt(ord(n.kind), result) # we do not write comments for now # Line information takes easily 20% or more of the filesize! Therefore we # omit line information if it is the same as the father's line information: - if fInfo.fileIndex != n.info.fileIndex: + if fInfo.fileIndex != n.info.fileIndex: result.add('?') encodeVInt(n.info.col, result) result.add(',') @@ -211,7 +211,7 @@ proc encodeNode(w: PRodWriter, fInfo: TLineInfo, n: PNode, result.add('?') encodeVInt(n.info.col, result) var f = n.flags * PersistentNodeFlags - if f != {}: + if f != {}: result.add('$') encodeVInt(cast[int32](f), result) if n.typ != nil: @@ -219,16 +219,16 @@ proc encodeNode(w: PRodWriter, fInfo: TLineInfo, n: PNode, encodeVInt(n.typ.id, result) pushType(w, n.typ) case n.kind - of nkCharLit..nkInt64Lit: + of nkCharLit..nkInt64Lit: if n.intVal != 0: result.add('!') encodeVBiggestInt(n.intVal, result) - of nkFloatLit..nkFloat64Lit: - if n.floatVal != 0.0: + of nkFloatLit..nkFloat64Lit: + if n.floatVal != 0.0: result.add('!') encodeStr($n.floatVal, result) of nkStrLit..nkTripleStrLit: - if n.strVal != "": + if n.strVal != "": result.add('!') encodeStr(n.strVal, result) of nkIdent: @@ -239,7 +239,7 @@ proc encodeNode(w: PRodWriter, fInfo: TLineInfo, n: PNode, encodeVInt(n.sym.id, result) pushSym(w, n.sym) else: - for i in countup(0, sonsLen(n) - 1): + for i in countup(0, sonsLen(n) - 1): encodeNode(w, n.info, n.sons[i], result) add(result, ')') @@ -268,9 +268,9 @@ proc encodeLoc(w: PRodWriter, loc: TLoc, result: var string) = setLen(result, oldLen) else: add(result, '>') - -proc encodeType(w: PRodWriter, t: PType, result: var string) = - if t == nil: + +proc encodeType(w: PRodWriter, t: PType, result: var string) = + if t == nil: # nil nodes have to be stored too: result.add("[]") return @@ -282,38 +282,38 @@ proc encodeType(w: PRodWriter, t: PType, result: var string) = encodeVInt(ord(t.kind), result) add(result, '+') encodeVInt(t.id, result) - if t.n != nil: + if t.n != nil: encodeNode(w, unknownLineInfo(), t.n, result) - if t.flags != {}: + if t.flags != {}: add(result, '$') encodeVInt(cast[int32](t.flags), result) - if t.callConv != low(t.callConv): + if t.callConv != low(t.callConv): add(result, '?') encodeVInt(ord(t.callConv), result) - if t.owner != nil: + if t.owner != nil: add(result, '*') encodeVInt(t.owner.id, result) pushSym(w, t.owner) - if t.sym != nil: + if t.sym != nil: add(result, '&') encodeVInt(t.sym.id, result) pushSym(w, t.sym) - if t.size != - 1: + if t.size != - 1: add(result, '/') encodeVBiggestInt(t.size, result) - if t.align != 2: + if t.align != 2: add(result, '=') encodeVInt(t.align, result) encodeLoc(w, t.loc, result) - for i in countup(0, sonsLen(t) - 1): - if t.sons[i] == nil: + for i in countup(0, sonsLen(t) - 1): + if t.sons[i] == nil: add(result, "^()") - else: - add(result, '^') + else: + add(result, '^') encodeVInt(t.sons[i].id, result) pushType(w, t.sons[i]) -proc encodeLib(w: PRodWriter, lib: PLib, info: TLineInfo, result: var string) = +proc encodeLib(w: PRodWriter, lib: PLib, info: TLineInfo, result: var string) = add(result, '|') encodeVInt(ord(lib.kind), result) add(result, '|') @@ -352,10 +352,10 @@ proc encodeSym(w: PRodWriter, s: PSym, result: var string) = if s.magic != mNone: result.add('@') encodeVInt(ord(s.magic), result) - if s.options != w.options: + if s.options != w.options: result.add('!') encodeVInt(cast[int32](s.options), result) - if s.position != 0: + if s.position != 0: result.add('%') encodeVInt(s.position, result) if s.offset != - 1: @@ -383,7 +383,7 @@ proc createDb() = fullpath varchar(256) not null, interfHash varchar(256) not null, fullHash varchar(256) not null, - + created timestamp not null default (DATETIME('now')), );""") @@ -397,7 +397,7 @@ proc createDb() = foreign key (module) references module(id) );""") - + db.exec(sql""" create table if not exists Type( id integer primary key, diff --git a/compiler/cgmeth.nim b/compiler/cgmeth.nim index 6c997b9837..adb4f1f929 100644 --- a/compiler/cgmeth.nim +++ b/compiler/cgmeth.nim @@ -9,33 +9,33 @@ ## This module implements code generation for multi methods. -import +import intsets, options, ast, astalgo, msgs, idents, renderer, types, magicsys, sempass2, strutils -proc genConv(n: PNode, d: PType, downcast: bool): PNode = +proc genConv(n: PNode, d: PType, downcast: bool): PNode = var dest = skipTypes(d, abstractPtrs) var source = skipTypes(n.typ, abstractPtrs) - if (source.kind == tyObject) and (dest.kind == tyObject): + if (source.kind == tyObject) and (dest.kind == tyObject): var diff = inheritanceDiff(dest, source) if diff == high(int): internalError(n.info, "cgmeth.genConv") - if diff < 0: + if diff < 0: result = newNodeIT(nkObjUpConv, n.info, d) addSon(result, n) if downcast: internalError(n.info, "cgmeth.genConv: no upcast allowed") - elif diff > 0: + elif diff > 0: result = newNodeIT(nkObjDownConv, n.info, d) addSon(result, n) - if not downcast: + if not downcast: internalError(n.info, "cgmeth.genConv: no downcast allowed") - else: + else: result = n - else: + else: result = n - -proc methodCall*(n: PNode): PNode = + +proc methodCall*(n: PNode): PNode = result = n - # replace ordinary method by dispatcher method: + # replace ordinary method by dispatcher method: var disp = lastSon(result.sons[0].sym.ast).sym assert sfDispatcher in disp.flags result.sons[0].sym = disp @@ -47,23 +47,23 @@ proc methodCall*(n: PNode): PNode = var gMethods: seq[tuple[methods: TSymSeq, dispatcher: PSym]] = @[] -proc sameMethodBucket(a, b: PSym): bool = +proc sameMethodBucket(a, b: PSym): bool = result = false - if a.name.id != b.name.id: return - if sonsLen(a.typ) != sonsLen(b.typ): + if a.name.id != b.name.id: return + if sonsLen(a.typ) != sonsLen(b.typ): return # check for return type: - if not sameTypeOrNil(a.typ.sons[0], b.typ.sons[0]): return - for i in countup(1, sonsLen(a.typ) - 1): + if not sameTypeOrNil(a.typ.sons[0], b.typ.sons[0]): return + for i in countup(1, sonsLen(a.typ) - 1): var aa = a.typ.sons[i] var bb = b.typ.sons[i] - while true: + while true: aa = skipTypes(aa, {tyGenericInst}) bb = skipTypes(bb, {tyGenericInst}) - if (aa.kind == bb.kind) and (aa.kind in {tyVar, tyPtr, tyRef}): + if (aa.kind == bb.kind) and (aa.kind in {tyVar, tyPtr, tyRef}): aa = aa.lastSon bb = bb.lastSon - else: - break + else: + break if sameType(aa, bb) or (aa.kind == tyObject) and (bb.kind == tyObject) and (inheritanceDiff(bb, aa) < 0): @@ -140,7 +140,7 @@ proc methodDef*(s: PSym, fromCache: bool) = attachDispatcher(s, lastSon(disp.ast)) fixupDispatcher(s, disp) when useEffectSystem: checkMethodEffects(disp, s) - return + return # create a new dispatcher: add(gMethods, (methods: @[s], dispatcher: createDispatcher(s))) if fromCache: @@ -154,35 +154,35 @@ proc relevantCol(methods: TSymSeq, col: int): bool = let t2 = skipTypes(methods[i].typ.sons[col], skipPtrs) if not sameType(t2, t): return true - -proc cmpSignatures(a, b: PSym, relevantCols: IntSet): int = - for col in countup(1, sonsLen(a.typ) - 1): - if contains(relevantCols, col): + +proc cmpSignatures(a, b: PSym, relevantCols: IntSet): int = + for col in countup(1, sonsLen(a.typ) - 1): + if contains(relevantCols, col): var aa = skipTypes(a.typ.sons[col], skipPtrs) var bb = skipTypes(b.typ.sons[col], skipPtrs) var d = inheritanceDiff(aa, bb) - if (d != high(int)): + if (d != high(int)): return d - -proc sortBucket(a: var TSymSeq, relevantCols: IntSet) = + +proc sortBucket(a: var TSymSeq, relevantCols: IntSet) = # we use shellsort here; fast and simple var n = len(a) var h = 1 - while true: + while true: h = 3 * h + 1 - if h > n: break - while true: + if h > n: break + while true: h = h div 3 - for i in countup(h, n - 1): + for i in countup(h, n - 1): var v = a[i] var j = i - while cmpSignatures(a[j - h], v, relevantCols) >= 0: + while cmpSignatures(a[j - h], v, relevantCols) >= 0: a[j] = a[j - h] j = j - h - if j < h: break + if j < h: break a[j] = v - if h == 1: break - + if h == 1: break + proc genDispatcher(methods: TSymSeq, relevantCols: IntSet): PSym = var base = lastSon(methods[0].ast).sym result = base @@ -199,7 +199,7 @@ proc genDispatcher(methods: TSymSeq, relevantCols: IntSet): PSym = addSon(isn, newSymNode(iss)) addSon(isn, newSymNode(base.typ.n.sons[col].sym)) addSon(isn, newNodeIT(nkType, base.info, curr.typ.sons[col])) - if cond != nil: + if cond != nil: var a = newNodeIT(nkCall, base.info, getSysType(tyBool)) addSon(a, newSymNode(ands)) addSon(a, cond) @@ -209,8 +209,8 @@ proc genDispatcher(methods: TSymSeq, relevantCols: IntSet): PSym = cond = isn var call = newNodeI(nkCall, base.info) addSon(call, newSymNode(curr)) - for col in countup(1, paramLen - 1): - addSon(call, genConv(newSymNode(base.typ.n.sons[col].sym), + for col in countup(1, paramLen - 1): + addSon(call, genConv(newSymNode(base.typ.n.sons[col].sym), curr.typ.sons[col], false)) var ret: PNode if base.typ.sons[0] != nil: @@ -230,11 +230,11 @@ proc genDispatcher(methods: TSymSeq, relevantCols: IntSet): PSym = disp = ret result.ast.sons[bodyPos] = disp -proc generateMethodDispatchers*(): PNode = +proc generateMethodDispatchers*(): PNode = result = newNode(nkStmtList) - for bucket in countup(0, len(gMethods) - 1): + for bucket in countup(0, len(gMethods) - 1): var relevantCols = initIntSet() - for col in countup(1, sonsLen(gMethods[bucket].methods[0].typ) - 1): + for col in countup(1, sonsLen(gMethods[bucket].methods[0].typ) - 1): if relevantCol(gMethods[bucket].methods, col): incl(relevantCols, col) sortBucket(gMethods[bucket].methods, relevantCols) addSon(result, diff --git a/compiler/docgen2.nim b/compiler/docgen2.nim index aa832b6df2..27de068116 100644 --- a/compiler/docgen2.nim +++ b/compiler/docgen2.nim @@ -10,10 +10,10 @@ # This module implements a new documentation generator that runs after # semantic checking. -import +import os, options, ast, astalgo, msgs, ropes, idents, passes, docgen -type +type TGen = object of TPassContext doc: PDoc module: PSym @@ -29,12 +29,12 @@ proc close(p: PPassContext, n: PNode): PNode = except IOError: discard -proc processNode(c: PPassContext, n: PNode): PNode = +proc processNode(c: PPassContext, n: PNode): PNode = result = n var g = PGen(c) generateDoc(g.doc, n) -proc myOpen(module: PSym): PPassContext = +proc myOpen(module: PSym): PPassContext = var g: PGen new(g) g.module = module @@ -45,5 +45,5 @@ proc myOpen(module: PSym): PPassContext = const docgen2Pass* = makePass(open = myOpen, process = processNode, close = close) -proc finishDoc2Pass*(project: string) = +proc finishDoc2Pass*(project: string) = discard diff --git a/compiler/evaltempl.nim b/compiler/evaltempl.nim index 82c4e8f573..58594a8b7a 100644 --- a/compiler/evaltempl.nim +++ b/compiler/evaltempl.nim @@ -31,7 +31,7 @@ proc evalTemplateAux(templ, actual: PNode, c: var TemplCtx, result: PNode) = for y in items(x): result.add(y) else: result.add copyTree(x) - + case templ.kind of nkSym: var s = templ.sym @@ -81,7 +81,7 @@ proc evalTemplateArgs(n: PNode, s: PSym): PNode = if totalParams > expectedRegularParams + genericParams: globalError(n.info, errWrongNumberOfArguments) - + result = newNodeI(nkArgList, n.info) for i in 1 .. givenRegularParams: result.addSon n.sons[i] @@ -96,7 +96,7 @@ proc evalTemplateArgs(n: PNode, s: PSym): PNode = addSon(result, ast.emptyNode) else: addSon(result, default.copyTree) - + # add any generic paramaters for i in 1 .. genericParams: result.addSon n.sons[givenRegularParams + i] diff --git a/compiler/filter_tmpl.nim b/compiler/filter_tmpl.nim index 5d1f73be4a..d3ab1728c5 100644 --- a/compiler/filter_tmpl.nim +++ b/compiler/filter_tmpl.nim @@ -9,18 +9,18 @@ # This module implements Nim's standard template filter. -import - llstream, os, wordrecg, idents, strutils, ast, astalgo, msgs, options, +import + llstream, os, wordrecg, idents, strutils, ast, astalgo, msgs, options, renderer, filters proc filterTmpl*(stdin: PLLStream, filename: string, call: PNode): PLLStream # #! template(subsChar='$', metaChar='#') | standard(version="0.7.2") # implementation -type - TParseState = enum +type + TParseState = enum psDirective, psTempl - TTmplParser{.final.} = object + TTmplParser{.final.} = object inp: PLLStream state: TParseState info: TLineInfo @@ -33,18 +33,18 @@ type pendingExprLine: bool -const +const PatternChars = {'a'..'z', 'A'..'Z', '0'..'9', '\x80'..'\xFF', '.', '_'} -proc newLine(p: var TTmplParser) = +proc newLine(p: var TTmplParser) = llStreamWrite(p.outp, repeat(')', p.emitPar)) p.emitPar = 0 if p.info.line > int16(1): llStreamWrite(p.outp, "\n") if p.pendingExprLine: llStreamWrite(p.outp, spaces(2)) p.pendingExprLine = false - -proc scanPar(p: var TTmplParser, d: int) = + +proc scanPar(p: var TTmplParser, d: int) = var i = d while true: case p.x[i] @@ -58,44 +58,44 @@ proc scanPar(p: var TTmplParser, d: int) = else: discard inc(i) -proc withInExpr(p: TTmplParser): bool {.inline.} = +proc withInExpr(p: TTmplParser): bool {.inline.} = result = p.par > 0 or p.bracket > 0 or p.curly > 0 - -proc parseLine(p: var TTmplParser) = - var + +proc parseLine(p: var TTmplParser) = + var d, j, curly: int keyw: string j = 0 while p.x[j] == ' ': inc(j) - if (p.x[0] == p.nimDirective) and (p.x[0 + 1] == '!'): + if (p.x[0] == p.nimDirective) and (p.x[0 + 1] == '!'): newLine(p) - elif (p.x[j] == p.nimDirective): + elif (p.x[j] == p.nimDirective): newLine(p) inc(j) while p.x[j] == ' ': inc(j) d = j keyw = "" - while p.x[j] in PatternChars: + while p.x[j] in PatternChars: add(keyw, p.x[j]) inc(j) - + scanPar(p, j) p.pendingExprLine = withInExpr(p) or llstream.endsWithOpr(p.x) case whichKeyword(keyw) - of wEnd: - if p.indent >= 2: + of wEnd: + if p.indent >= 2: dec(p.indent, 2) - else: + else: p.info.col = int16(j) localError(p.info, errXNotAllowedHere, "end") llStreamWrite(p.outp, spaces(p.indent)) llStreamWrite(p.outp, "#end") - of wIf, wWhen, wTry, wWhile, wFor, wBlock, wCase, wProc, wIterator, - wConverter, wMacro, wTemplate, wMethod: + of wIf, wWhen, wTry, wWhile, wFor, wBlock, wCase, wProc, wIterator, + wConverter, wMacro, wTemplate, wMethod: llStreamWrite(p.outp, spaces(p.indent)) llStreamWrite(p.outp, substr(p.x, d)) inc(p.indent, 2) - of wElif, wOf, wElse, wExcept, wFinally: + of wElif, wOf, wElse, wExcept, wFinally: llStreamWrite(p.outp, spaces(p.indent - 2)) llStreamWrite(p.outp, substr(p.x, d)) of wLet, wVar, wConst, wType: @@ -108,7 +108,7 @@ proc parseLine(p: var TTmplParser) = llStreamWrite(p.outp, spaces(p.indent)) llStreamWrite(p.outp, substr(p.x, d)) p.state = psDirective - else: + else: # data line # reset counters p.par = 0 @@ -116,42 +116,42 @@ proc parseLine(p: var TTmplParser) = p.bracket = 0 j = 0 case p.state - of psTempl: + of psTempl: # next line of string literal: llStreamWrite(p.outp, p.conc) llStreamWrite(p.outp, "\n") llStreamWrite(p.outp, spaces(p.indent + 2)) llStreamWrite(p.outp, "\"") - of psDirective: + of psDirective: newLine(p) llStreamWrite(p.outp, spaces(p.indent)) llStreamWrite(p.outp, p.emit) llStreamWrite(p.outp, "(\"") inc(p.emitPar) p.state = psTempl - while true: + while true: case p.x[j] - of '\0': - break - of '\x01'..'\x1F', '\x80'..'\xFF': + of '\0': + break + of '\x01'..'\x1F', '\x80'..'\xFF': llStreamWrite(p.outp, "\\x") llStreamWrite(p.outp, toHex(ord(p.x[j]), 2)) inc(j) - of '\\': + of '\\': llStreamWrite(p.outp, "\\\\") inc(j) - of '\'': + of '\'': llStreamWrite(p.outp, "\\\'") inc(j) - of '\"': + of '\"': llStreamWrite(p.outp, "\\\"") inc(j) - else: - if p.x[j] == p.subsChar: + else: + if p.x[j] == p.subsChar: # parse Nim expression: inc(j) case p.x[j] - of '{': + of '{': p.info.col = int16(j) llStreamWrite(p.outp, '\"') llStreamWrite(p.outp, p.conc) @@ -159,50 +159,50 @@ proc parseLine(p: var TTmplParser) = llStreamWrite(p.outp, '(') inc(j) curly = 0 - while true: + while true: case p.x[j] - of '\0': + of '\0': localError(p.info, errXExpected, "}") break - of '{': + of '{': inc(j) inc(curly) llStreamWrite(p.outp, '{') - of '}': + of '}': inc(j) - if curly == 0: break + if curly == 0: break if curly > 0: dec(curly) llStreamWrite(p.outp, '}') - else: + else: llStreamWrite(p.outp, p.x[j]) inc(j) llStreamWrite(p.outp, ')') llStreamWrite(p.outp, p.conc) llStreamWrite(p.outp, '\"') - of 'a'..'z', 'A'..'Z', '\x80'..'\xFF': + of 'a'..'z', 'A'..'Z', '\x80'..'\xFF': llStreamWrite(p.outp, '\"') llStreamWrite(p.outp, p.conc) llStreamWrite(p.outp, p.toStr) llStreamWrite(p.outp, '(') - while p.x[j] in PatternChars: + while p.x[j] in PatternChars: llStreamWrite(p.outp, p.x[j]) inc(j) llStreamWrite(p.outp, ')') llStreamWrite(p.outp, p.conc) llStreamWrite(p.outp, '\"') - else: - if p.x[j] == p.subsChar: + else: + if p.x[j] == p.subsChar: llStreamWrite(p.outp, p.subsChar) inc(j) - else: + else: p.info.col = int16(j) localError(p.info, errInvalidExpression, "$") - else: + else: llStreamWrite(p.outp, p.x[j]) inc(j) llStreamWrite(p.outp, "\\n\"") -proc filterTmpl(stdin: PLLStream, filename: string, call: PNode): PLLStream = +proc filterTmpl(stdin: PLLStream, filename: string, call: PNode): PLLStream = var p: TTmplParser p.info = newLineInfo(filename, 0, 0) p.outp = llStreamOpen("") diff --git a/compiler/filters.nim b/compiler/filters.nim index 783a320a40..adafe464ea 100644 --- a/compiler/filters.nim +++ b/compiler/filters.nim @@ -10,7 +10,7 @@ # This module implements Nim's simple filters and helpers for filters. import - llstream, os, wordrecg, idents, strutils, ast, astalgo, msgs, options, + llstream, os, wordrecg, idents, strutils, ast, astalgo, msgs, options, renderer proc filterReplace*(stdin: PLLStream, filename: string, call: PNode): PLLStream @@ -21,40 +21,40 @@ proc strArg*(n: PNode, name: string, pos: int, default: string): string proc boolArg*(n: PNode, name: string, pos: int, default: bool): bool # implementation -proc invalidPragma(n: PNode) = +proc invalidPragma(n: PNode) = localError(n.info, errXNotAllowedHere, renderTree(n, {renderNoComments})) -proc getArg(n: PNode, name: string, pos: int): PNode = +proc getArg(n: PNode, name: string, pos: int): PNode = result = nil - if n.kind in {nkEmpty..nkNilLit}: return - for i in countup(1, sonsLen(n) - 1): - if n.sons[i].kind == nkExprEqExpr: + if n.kind in {nkEmpty..nkNilLit}: return + for i in countup(1, sonsLen(n) - 1): + if n.sons[i].kind == nkExprEqExpr: if n.sons[i].sons[0].kind != nkIdent: invalidPragma(n) - if identEq(n.sons[i].sons[0].ident, name): + if identEq(n.sons[i].sons[0].ident, name): return n.sons[i].sons[1] - elif i == pos: + elif i == pos: return n.sons[i] - -proc charArg(n: PNode, name: string, pos: int, default: char): char = + +proc charArg(n: PNode, name: string, pos: int, default: char): char = var x = getArg(n, name, pos) if x == nil: result = default elif x.kind == nkCharLit: result = chr(int(x.intVal)) else: invalidPragma(n) - -proc strArg(n: PNode, name: string, pos: int, default: string): string = + +proc strArg(n: PNode, name: string, pos: int, default: string): string = var x = getArg(n, name, pos) if x == nil: result = default elif x.kind in {nkStrLit..nkTripleStrLit}: result = x.strVal else: invalidPragma(n) - -proc boolArg(n: PNode, name: string, pos: int, default: bool): bool = + +proc boolArg(n: PNode, name: string, pos: int, default: bool): bool = var x = getArg(n, name, pos) if x == nil: result = default elif (x.kind == nkIdent) and identEq(x.ident, "true"): result = true elif (x.kind == nkIdent) and identEq(x.ident, "false"): result = false else: invalidPragma(n) - -proc filterStrip(stdin: PLLStream, filename: string, call: PNode): PLLStream = + +proc filterStrip(stdin: PLLStream, filename: string, call: PNode): PLLStream = var pattern = strArg(call, "startswith", 1, "") var leading = boolArg(call, "leading", 2, true) var trailing = boolArg(call, "trailing", 3, true) @@ -62,13 +62,13 @@ proc filterStrip(stdin: PLLStream, filename: string, call: PNode): PLLStream = var line = newStringOfCap(80) while llStreamReadLine(stdin, line): var stripped = strip(line, leading, trailing) - if (len(pattern) == 0) or startsWith(stripped, pattern): + if (len(pattern) == 0) or startsWith(stripped, pattern): llStreamWriteln(result, stripped) - else: + else: llStreamWriteln(result, line) llStreamClose(stdin) -proc filterReplace(stdin: PLLStream, filename: string, call: PNode): PLLStream = +proc filterReplace(stdin: PLLStream, filename: string, call: PNode): PLLStream = var sub = strArg(call, "sub", 1, "") if len(sub) == 0: invalidPragma(call) var by = strArg(call, "by", 2, "") diff --git a/compiler/forloops.nim b/compiler/forloops.nim index 949b7d8c67..5074d79d53 100644 --- a/compiler/forloops.nim +++ b/compiler/forloops.nim @@ -14,11 +14,11 @@ import ast, astalgo const someCmp = {mEqI, mEqF64, mEqEnum, mEqCh, mEqB, mEqRef, mEqProc, mEqUntracedRef, mLeI, mLeF64, mLeU, mLeU64, mLeEnum, - mLeCh, mLeB, mLePtr, mLtI, mLtF64, mLtU, mLtU64, mLtEnum, + mLeCh, mLeB, mLePtr, mLtI, mLtF64, mLtU, mLtU64, mLtEnum, mLtCh, mLtB, mLtPtr} proc isCounter(s: PSym): bool {.inline.} = - s.kind in {skResult, skVar, skLet, skTemp} and + s.kind in {skResult, skVar, skLet, skTemp} and {sfGlobal, sfAddrTaken} * s.flags == {} proc isCall(n: PNode): bool {.inline.} = @@ -29,7 +29,7 @@ proc fromSystem(op: PSym): bool = sfSystemModule in getModule(op).flags proc getCounter(lastStmt: PNode): PSym = if lastStmt.isCall: let op = lastStmt.sym - if op.magic in {mDec, mInc} or + if op.magic in {mDec, mInc} or ((op.name.s == "+=" or op.name.s == "-=") and op.fromSystem): if op[1].kind == nkSym and isCounter(op[1].sym): result = op[1].sym @@ -67,7 +67,7 @@ proc extractForLoop*(loop, fullTree: PNode): ForLoop = if not cond.isCall: return if cond[0].sym.magic notin someCmp: return - + var lastStmt = loop[1] while lastStmt.kind in {nkStmtList, nkStmtListExpr}: lastStmt = lastStmt.lastSon @@ -76,7 +76,7 @@ proc extractForLoop*(loop, fullTree: PNode): ForLoop = if counter.isNil or counter.ast.isNil: return template `=~`(a, b): expr = a.kind == nkSym and a.sym == b - + if cond[1] =~ counter or cond[2] =~ counter: # ok, now check 'counter' is not used *after* the loop if counterInTree(fullTree, loop, counter): return diff --git a/compiler/hlo.nim b/compiler/hlo.nim index 363d100be6..6cc9567af7 100644 --- a/compiler/hlo.nim +++ b/compiler/hlo.nim @@ -28,7 +28,7 @@ proc evalPattern(c: PContext, n, orig: PNode): PNode = else: result = semDirectOp(c, n, {}) if optHints in gOptions and hintPattern in gNotes: - message(orig.info, hintPattern, rule & " --> '" & + message(orig.info, hintPattern, rule & " --> '" & renderTree(result, {renderNoComments}) & "'") proc applyPatterns(c: PContext, n: PNode): PNode = @@ -68,7 +68,7 @@ proc hlo(c: PContext, n: PNode): PNode = result = n else: if n.kind in {nkFastAsgn, nkAsgn, nkIdentDefs, nkVarTuple} and - n.sons[0].kind == nkSym and + n.sons[0].kind == nkSym and {sfGlobal, sfPure} * n.sons[0].sym.flags == {sfGlobal, sfPure}: # do not optimize 'var g {.global} = re(...)' again! return n diff --git a/compiler/idents.nim b/compiler/idents.nim index 6986800cf6..d9b72baf07 100644 --- a/compiler/idents.nim +++ b/compiler/idents.nim @@ -11,13 +11,13 @@ # An identifier is a shared immutable string that can be compared by its # id. This module is essential for the compiler's performance. -import +import hashes, strutils, etcpriv -type +type TIdObj* = object of RootObj id*: int # unique id; use this for comparisons and not the pointers - + PIdObj* = ref TIdObj PIdent* = ref TIdent TIdent*{.acyclic.} = object of TIdObj @@ -45,12 +45,12 @@ proc cmpIgnoreStyle(a, b: cstring, blen: int): int = if aa >= 'A' and aa <= 'Z': aa = chr(ord(aa) + (ord('a') - ord('A'))) if bb >= 'A' and bb <= 'Z': bb = chr(ord(bb) + (ord('a') - ord('A'))) result = ord(aa) - ord(bb) - if (result != 0) or (aa == '\0'): break + if (result != 0) or (aa == '\0'): break inc(i) inc(j) if result == 0: if a[i] != '\0': result = 1 - + proc cmpExact(a, b: cstring, blen: int): int = var i = 0 var j = 0 @@ -59,10 +59,10 @@ proc cmpExact(a, b: cstring, blen: int): int = var aa = a[i] var bb = b[j] result = ord(aa) - ord(bb) - if (result != 0) or (aa == '\0'): break + if (result != 0) or (aa == '\0'): break inc(i) inc(j) - if result == 0: + if result == 0: if a[i] != '\0': result = 1 var wordCounter = 1 @@ -72,14 +72,14 @@ proc getIdent*(identifier: cstring, length: int, h: Hash): PIdent = result = buckets[idx] var last: PIdent = nil var id = 0 - while result != nil: - if cmpExact(cstring(result.s), identifier, length) == 0: - if last != nil: + while result != nil: + if cmpExact(cstring(result.s), identifier, length) == 0: + if last != nil: # make access to last looked up identifier faster: last.next = result.next result.next = buckets[idx] buckets[idx] = result - return + return elif cmpIgnoreStyle(cstring(result.s), identifier, length) == 0: assert((id == 0) or (id == result.id)) id = result.id @@ -91,20 +91,20 @@ proc getIdent*(identifier: cstring, length: int, h: Hash): PIdent = for i in countup(0, length - 1): result.s[i] = identifier[i] result.next = buckets[idx] buckets[idx] = result - if id == 0: + if id == 0: inc(wordCounter) result.id = -wordCounter - else: + else: result.id = id -proc getIdent*(identifier: string): PIdent = - result = getIdent(cstring(identifier), len(identifier), +proc getIdent*(identifier: string): PIdent = + result = getIdent(cstring(identifier), len(identifier), hashIgnoreStyle(identifier)) -proc getIdent*(identifier: string, h: Hash): PIdent = +proc getIdent*(identifier: string, h: Hash): PIdent = result = getIdent(cstring(identifier), len(identifier), h) -proc identEq*(id: PIdent, name: string): bool = +proc identEq*(id: PIdent, name: string): bool = result = id.id == getIdent(name).id var idAnon* = getIdent":anonymous" diff --git a/compiler/lists.nim b/compiler/lists.nim index 1b2b91bff6..27e3733425 100644 --- a/compiler/lists.nim +++ b/compiler/lists.nim @@ -10,7 +10,7 @@ # This module implements a generic doubled linked list. # TODO Remove this and replace it with something sensible import os -type +type PListEntry* = ref TListEntry TListEntry* = object of RootObj prev*, next*: PListEntry @@ -25,68 +25,68 @@ type TCompareProc* = proc (entry: PListEntry, closure: pointer): bool {.nimcall.} -proc initLinkedList*(list: var TLinkedList) = +proc initLinkedList*(list: var TLinkedList) = list.counter = 0 list.head = nil list.tail = nil -proc append*(list: var TLinkedList, entry: PListEntry) = +proc append*(list: var TLinkedList, entry: PListEntry) = inc(list.counter) entry.next = nil entry.prev = list.tail - if list.tail != nil: + if list.tail != nil: assert(list.tail.next == nil) list.tail.next = entry list.tail = entry if list.head == nil: list.head = entry - -proc contains*(list: TLinkedList, data: string): bool = + +proc contains*(list: TLinkedList, data: string): bool = var it = list.head - while it != nil: - if PStrEntry(it).data == data: + while it != nil: + if PStrEntry(it).data == data: return true it = it.next - -proc newStrEntry(data: string): PStrEntry = + +proc newStrEntry(data: string): PStrEntry = new(result) result.data = data -proc appendStr*(list: var TLinkedList, data: string) = +proc appendStr*(list: var TLinkedList, data: string) = append(list, newStrEntry(data)) -proc includeStr*(list: var TLinkedList, data: string): bool = +proc includeStr*(list: var TLinkedList, data: string): bool = if contains(list, data): return true appendStr(list, data) # else: add to list -proc prepend*(list: var TLinkedList, entry: PListEntry) = +proc prepend*(list: var TLinkedList, entry: PListEntry) = inc(list.counter) entry.prev = nil entry.next = list.head - if list.head != nil: + if list.head != nil: assert(list.head.prev == nil) list.head.prev = entry list.head = entry if list.tail == nil: list.tail = entry -proc prependStr*(list: var TLinkedList, data: string) = +proc prependStr*(list: var TLinkedList, data: string) = prepend(list, newStrEntry(data)) -proc insertBefore*(list: var TLinkedList, pos, entry: PListEntry) = +proc insertBefore*(list: var TLinkedList, pos, entry: PListEntry) = assert(pos != nil) - if pos == list.head: + if pos == list.head: prepend(list, entry) - else: + else: inc(list.counter) entry.next = pos entry.prev = pos.prev if pos.prev != nil: pos.prev.next = entry pos.prev = entry - -proc remove*(list: var TLinkedList, entry: PListEntry) = + +proc remove*(list: var TLinkedList, entry: PListEntry) = dec(list.counter) - if entry == list.tail: + if entry == list.tail: list.tail = entry.prev - if entry == list.head: + if entry == list.head: list.head = entry.next if entry.next != nil: entry.next.prev = entry.prev if entry.prev != nil: entry.prev.next = entry.next @@ -112,8 +112,8 @@ proc excludePath*(list: var TLinkedList, data: string) = remove(list, it) it = nxt -proc find*(list: TLinkedList, fn: TCompareProc, closure: pointer): PListEntry = +proc find*(list: TLinkedList, fn: TCompareProc, closure: pointer): PListEntry = result = list.head while result != nil: - if fn(result, closure): return + if fn(result, closure): return result = result.next diff --git a/compiler/magicsys.nim b/compiler/magicsys.nim index 6d4c652680..98a4b08bf3 100644 --- a/compiler/magicsys.nim +++ b/compiler/magicsys.nim @@ -9,7 +9,7 @@ # Built-in types and compilerprocs are registered here. -import +import ast, astalgo, hashes, msgs, platform, nversion, times, idents, rodread var systemModule*: PSym @@ -29,23 +29,23 @@ var proc nilOrSysInt*: PType = gSysTypes[tyInt] -proc registerSysType(t: PType) = +proc registerSysType(t: PType) = if gSysTypes[t.kind] == nil: gSysTypes[t.kind] = t - -proc newSysType(kind: TTypeKind, size: int): PType = + +proc newSysType(kind: TTypeKind, size: int): PType = result = newType(kind, systemModule) result.size = size result.align = size.int16 -proc getSysSym(name: string): PSym = +proc getSysSym(name: string): PSym = result = strTableGet(systemModule.tab, getIdent(name)) - if result == nil: + if result == nil: rawMessage(errSystemNeeds, name) result = newSym(skError, getIdent(name), systemModule, systemModule.info) result.typ = newType(tyError, systemModule) if result.kind == skStub: loadStub(result) if result.kind == skAlias: result = result.owner - + proc getSysMagic*(name: string, m: TMagic): PSym = var ti: TIdentIter let id = getIdent(name) @@ -57,13 +57,13 @@ proc getSysMagic*(name: string, m: TMagic): PSym = rawMessage(errSystemNeeds, name) result = newSym(skError, id, systemModule, systemModule.info) result.typ = newType(tyError, systemModule) - -proc sysTypeFromName*(name: string): PType = + +proc sysTypeFromName*(name: string): PType = result = getSysSym(name).typ -proc getSysType(kind: TTypeKind): PType = +proc getSysType(kind: TTypeKind): PType = result = gSysTypes[kind] - if result == nil: + if result == nil: case kind of tyInt: result = sysTypeFromName("int") of tyInt8: result = sysTypeFromName("int8") @@ -87,7 +87,7 @@ proc getSysType(kind: TTypeKind): PType = of tyNil: result = newSysType(tyNil, ptrSize) else: internalError("request for typekind: " & $kind) gSysTypes[kind] = result - if result.kind != kind: + if result.kind != kind: internalError("wanted: " & $kind & " got: " & $result.kind) if result == nil: internalError("type not found: " & $kind) @@ -163,7 +163,7 @@ proc setIntLitType*(result: PNode) = result.typ = getSysType(tyInt64) else: internalError(result.info, "invalid int size") -proc getCompilerProc(name: string): PSym = +proc getCompilerProc(name: string): PSym = var ident = getIdent(name, hashIgnoreStyle(name)) result = strTableGet(compilerprocs, ident) if result == nil: diff --git a/compiler/nimblecmd.nim b/compiler/nimblecmd.nim index 2044f104f7..9b647e67d7 100644 --- a/compiler/nimblecmd.nim +++ b/compiler/nimblecmd.nim @@ -11,8 +11,8 @@ import parseutils, strutils, strtabs, os, options, msgs, lists -proc addPath*(path: string, info: TLineInfo) = - if not contains(options.searchPaths, path): +proc addPath*(path: string, info: TLineInfo) = + if not contains(options.searchPaths, path): lists.prependStr(options.searchPaths, path) proc versionSplitPos(s: string): int = @@ -23,7 +23,7 @@ proc versionSplitPos(s: string): int = const latest = "head" -proc `<.`(a, b: string): bool = +proc `<.`(a, b: string): bool = # wether a has a smaller version than b: if a == latest: return false var i = 0 diff --git a/compiler/nimeval.nim b/compiler/nimeval.nim index 197e8bf86d..2bddb76e7a 100644 --- a/compiler/nimeval.nim +++ b/compiler/nimeval.nim @@ -10,7 +10,7 @@ ## exposes the Nim VM to clients. import - ast, modules, passes, passaux, condsyms, + ast, modules, passes, passaux, condsyms, options, nimconf, lists, sem, semdata, llstream, vm proc execute*(program: string) = diff --git a/compiler/nimlexbase.nim b/compiler/nimlexbase.nim index f5db5ca4f6..047890c447 100644 --- a/compiler/nimlexbase.nim +++ b/compiler/nimlexbase.nim @@ -12,10 +12,10 @@ # handling that exists! Only at line endings checks are necessary # if the buffer needs refilling. -import +import llstream, strutils -const +const Lrz* = ' ' Apo* = '\'' Tabulator* = '\x09' @@ -27,7 +27,7 @@ const BACKSPACE* = '\x08' VT* = '\x0B' -const +const EndOfFile* = '\0' # end of file marker # A little picture makes everything clear :-) # buf: @@ -36,7 +36,7 @@ const # NewLines* = {CR, LF} -type +type TBaseLexer* = object of RootObj bufpos*: int buf*: cstring @@ -46,9 +46,9 @@ type # private data: sentinel*: int lineStart*: int # index of last line start in buffer - -proc openBaseLexer*(L: var TBaseLexer, inputstream: PLLStream, + +proc openBaseLexer*(L: var TBaseLexer, inputstream: PLLStream, bufLen: int = 8192) # 8K is a reasonable buffer size proc closeBaseLexer*(L: var TBaseLexer) @@ -64,15 +64,15 @@ proc handleLF*(L: var TBaseLexer, pos: int): int # of the LF. # implementation -const +const chrSize = sizeof(char) -proc closeBaseLexer(L: var TBaseLexer) = +proc closeBaseLexer(L: var TBaseLexer) = dealloc(L.buf) llStreamClose(L.stream) -proc fillBuffer(L: var TBaseLexer) = - var +proc fillBuffer(L: var TBaseLexer) = + var charsRead, toCopy, s: int # all are in characters, # not bytes (in case this # is not the same) @@ -82,68 +82,68 @@ proc fillBuffer(L: var TBaseLexer) = assert(L.sentinel < L.bufLen) toCopy = L.bufLen - L.sentinel - 1 assert(toCopy >= 0) - if toCopy > 0: - moveMem(L.buf, addr(L.buf[L.sentinel + 1]), toCopy * chrSize) + if toCopy > 0: + moveMem(L.buf, addr(L.buf[L.sentinel + 1]), toCopy * chrSize) # "moveMem" handles overlapping regions - charsRead = llStreamRead(L.stream, addr(L.buf[toCopy]), + charsRead = llStreamRead(L.stream, addr(L.buf[toCopy]), (L.sentinel + 1) * chrSize) div chrSize s = toCopy + charsRead - if charsRead < L.sentinel + 1: + if charsRead < L.sentinel + 1: L.buf[s] = EndOfFile # set end marker L.sentinel = s - else: + else: # compute sentinel: dec(s) # BUGFIX (valgrind) - while true: + while true: assert(s < L.bufLen) while (s >= 0) and not (L.buf[s] in NewLines): dec(s) - if s >= 0: + if s >= 0: # we found an appropriate character for a sentinel: L.sentinel = s - break - else: + break + else: # rather than to give up here because the line is too long, # double the buffer's size and try again: oldBufLen = L.bufLen L.bufLen = L.bufLen * 2 L.buf = cast[cstring](realloc(L.buf, L.bufLen * chrSize)) assert(L.bufLen - oldBufLen == oldBufLen) - charsRead = llStreamRead(L.stream, addr(L.buf[oldBufLen]), + charsRead = llStreamRead(L.stream, addr(L.buf[oldBufLen]), oldBufLen * chrSize) div chrSize - if charsRead < oldBufLen: + if charsRead < oldBufLen: L.buf[oldBufLen + charsRead] = EndOfFile L.sentinel = oldBufLen + charsRead - break + break s = L.bufLen - 1 -proc fillBaseLexer(L: var TBaseLexer, pos: int): int = +proc fillBaseLexer(L: var TBaseLexer, pos: int): int = assert(pos <= L.sentinel) - if pos < L.sentinel: + if pos < L.sentinel: result = pos + 1 # nothing to do - else: + else: fillBuffer(L) L.bufpos = 0 # XXX: is this really correct? result = 0 L.lineStart = result -proc handleCR(L: var TBaseLexer, pos: int): int = +proc handleCR(L: var TBaseLexer, pos: int): int = assert(L.buf[pos] == CR) inc(L.lineNumber) result = fillBaseLexer(L, pos) - if L.buf[result] == LF: + if L.buf[result] == LF: result = fillBaseLexer(L, result) -proc handleLF(L: var TBaseLexer, pos: int): int = +proc handleLF(L: var TBaseLexer, pos: int): int = assert(L.buf[pos] == LF) inc(L.lineNumber) result = fillBaseLexer(L, pos) #L.lastNL := result-1; // BUGFIX: was: result; - -proc skipUTF8BOM(L: var TBaseLexer) = + +proc skipUTF8BOM(L: var TBaseLexer) = if L.buf[0] == '\xEF' and L.buf[1] == '\xBB' and L.buf[2] == '\xBF': inc(L.bufpos, 3) inc(L.lineStart, 3) -proc openBaseLexer(L: var TBaseLexer, inputstream: PLLStream, bufLen = 8192) = +proc openBaseLexer(L: var TBaseLexer, inputstream: PLLStream, bufLen = 8192) = assert(bufLen > 0) L.bufpos = 0 L.bufLen = bufLen @@ -155,15 +155,15 @@ proc openBaseLexer(L: var TBaseLexer, inputstream: PLLStream, bufLen = 8192) = fillBuffer(L) skipUTF8BOM(L) -proc getColNumber(L: TBaseLexer, pos: int): int = +proc getColNumber(L: TBaseLexer, pos: int): int = result = abs(pos - L.lineStart) -proc getCurrentLine(L: TBaseLexer, marker: bool = true): string = +proc getCurrentLine(L: TBaseLexer, marker: bool = true): string = result = "" var i = L.lineStart - while not (L.buf[i] in {CR, LF, EndOfFile}): + while not (L.buf[i] in {CR, LF, EndOfFile}): add(result, L.buf[i]) inc(i) result.add("\n") - if marker: + if marker: result.add(spaces(getColNumber(L, L.bufpos)) & '^' & "\n") diff --git a/compiler/nimsets.nim b/compiler/nimsets.nim index aa7686d309..055bae9092 100644 --- a/compiler/nimsets.nim +++ b/compiler/nimsets.nim @@ -9,7 +9,7 @@ # this unit handles Nim sets; it implements symbolic sets -import +import ast, astalgo, trees, nversion, msgs, platform, bitsets, types, renderer proc toBitSet*(s: PNode, b: var TBitSet) @@ -30,17 +30,17 @@ proc equalSets*(a, b: PNode): bool proc cardSet*(s: PNode): BiggestInt # implementation -proc inSet(s: PNode, elem: PNode): bool = - if s.kind != nkCurly: +proc inSet(s: PNode, elem: PNode): bool = + if s.kind != nkCurly: internalError(s.info, "inSet") return false - for i in countup(0, sonsLen(s) - 1): - if s.sons[i].kind == nkRange: + for i in countup(0, sonsLen(s) - 1): + if s.sons[i].kind == nkRange: if leValue(s.sons[i].sons[0], elem) and - leValue(elem, s.sons[i].sons[1]): + leValue(elem, s.sons[i].sons[1]): return true - else: - if sameValue(s.sons[i], elem): + else: + if sameValue(s.sons[i], elem): return true result = false @@ -58,37 +58,37 @@ proc overlap(a, b: PNode): bool = else: result = sameValue(a, b) -proc someInSet(s: PNode, a, b: PNode): bool = +proc someInSet(s: PNode, a, b: PNode): bool = # checks if some element of a..b is in the set s if s.kind != nkCurly: internalError(s.info, "SomeInSet") return false - for i in countup(0, sonsLen(s) - 1): - if s.sons[i].kind == nkRange: + for i in countup(0, sonsLen(s) - 1): + if s.sons[i].kind == nkRange: if leValue(s.sons[i].sons[0], b) and leValue(b, s.sons[i].sons[1]) or - leValue(s.sons[i].sons[0], a) and leValue(a, s.sons[i].sons[1]): + leValue(s.sons[i].sons[0], a) and leValue(a, s.sons[i].sons[1]): return true - else: + else: # a <= elem <= b - if leValue(a, s.sons[i]) and leValue(s.sons[i], b): + if leValue(a, s.sons[i]) and leValue(s.sons[i], b): return true result = false -proc toBitSet(s: PNode, b: var TBitSet) = +proc toBitSet(s: PNode, b: var TBitSet) = var first, j: BiggestInt first = firstOrd(s.typ.sons[0]) bitSetInit(b, int(getSize(s.typ))) - for i in countup(0, sonsLen(s) - 1): - if s.sons[i].kind == nkRange: + for i in countup(0, sonsLen(s) - 1): + if s.sons[i].kind == nkRange: j = getOrdValue(s.sons[i].sons[0]) - while j <= getOrdValue(s.sons[i].sons[1]): + while j <= getOrdValue(s.sons[i].sons[1]): bitSetIncl(b, j - first) inc(j) - else: + else: bitSetIncl(b, getOrdValue(s.sons[i]) - first) - -proc toTreeSet(s: TBitSet, settype: PType, info: TLineInfo): PNode = - var + +proc toTreeSet(s: TBitSet, settype: PType, info: TLineInfo): PNode = + var a, b, e, first: BiggestInt # a, b are interval borders elemType: PType n: PNode @@ -98,17 +98,17 @@ proc toTreeSet(s: TBitSet, settype: PType, info: TLineInfo): PNode = result.typ = settype result.info = info e = 0 - while e < len(s) * ElemSize: - if bitSetIn(s, e): + while e < len(s) * ElemSize: + if bitSetIn(s, e): a = e b = e - while true: + while true: inc(b) - if (b >= len(s) * ElemSize) or not bitSetIn(s, b): break + if (b >= len(s) * ElemSize) or not bitSetIn(s, b): break dec(b) - if a == b: + if a == b: addSon(result, newIntTypeNode(nkIntLit, a + first, elemType)) - else: + else: n = newNodeI(nkRange, info) n.typ = elemType addSon(n, newIntTypeNode(nkIntLit, a + first, elemType)) @@ -117,7 +117,7 @@ proc toTreeSet(s: TBitSet, settype: PType, info: TLineInfo): PNode = e = b inc(e) -template nodeSetOp(a, b: PNode, op: expr) {.dirty.} = +template nodeSetOp(a, b: PNode, op: expr) {.dirty.} = var x, y: TBitSet toBitSet(a, x) toBitSet(b, y) @@ -129,13 +129,13 @@ proc diffSets(a, b: PNode): PNode = nodeSetOp(a, b, bitSetDiff) proc intersectSets(a, b: PNode): PNode = nodeSetOp(a, b, bitSetIntersect) proc symdiffSets(a, b: PNode): PNode = nodeSetOp(a, b, bitSetSymDiff) -proc containsSets(a, b: PNode): bool = +proc containsSets(a, b: PNode): bool = var x, y: TBitSet toBitSet(a, x) toBitSet(b, y) result = bitSetContains(x, y) -proc equalSets(a, b: PNode): bool = +proc equalSets(a, b: PNode): bool = var x, y: TBitSet toBitSet(a, x) toBitSet(b, y) @@ -147,26 +147,26 @@ proc complement*(a: PNode): PNode = for i in countup(0, high(x)): x[i] = not x[i] result = toTreeSet(x, a.typ, a.info) -proc cardSet(s: PNode): BiggestInt = +proc cardSet(s: PNode): BiggestInt = # here we can do better than converting it into a compact set # we just count the elements directly result = 0 - for i in countup(0, sonsLen(s) - 1): - if s.sons[i].kind == nkRange: + for i in countup(0, sonsLen(s) - 1): + if s.sons[i].kind == nkRange: result = result + getOrdValue(s.sons[i].sons[1]) - getOrdValue(s.sons[i].sons[0]) + 1 - else: + else: inc(result) - -proc setHasRange(s: PNode): bool = + +proc setHasRange(s: PNode): bool = if s.kind != nkCurly: internalError(s.info, "SetHasRange") return false - for i in countup(0, sonsLen(s) - 1): - if s.sons[i].kind == nkRange: + for i in countup(0, sonsLen(s) - 1): + if s.sons[i].kind == nkRange: return true result = false -proc emptyRange(a, b: PNode): bool = +proc emptyRange(a, b: PNode): bool = result = not leValue(a, b) # a > b iff not (a <= b) - + diff --git a/compiler/nversion.nim b/compiler/nversion.nim index 4dea628766..adeb0fb6d3 100644 --- a/compiler/nversion.nim +++ b/compiler/nversion.nim @@ -10,7 +10,7 @@ # This module contains Nim's version. It is the only place where it needs # to be changed. -const +const MaxSetElements* = 1 shl 16 # (2^16) to support unicode character sets? VersionAsString* = system.NimVersion RodFileVersion* = "1215" # modify this if the rod-format changes! diff --git a/compiler/passaux.nim b/compiler/passaux.nim index c3bafe7dfd..9b9fdca4eb 100644 --- a/compiler/passaux.nim +++ b/compiler/passaux.nim @@ -9,38 +9,38 @@ ## implements some little helper passes -import +import strutils, ast, astalgo, passes, msgs, options, idgen proc verboseOpen(s: PSym): PPassContext = #MessageOut('compiling ' + s.name.s); result = nil # we don't need a context rawMessage(hintProcessing, s.name.s) - -proc verboseProcess(context: PPassContext, n: PNode): PNode = + +proc verboseProcess(context: PPassContext, n: PNode): PNode = result = n if context != nil: internalError("logpass: context is not nil") - if gVerbosity == 3: + if gVerbosity == 3: # system.nim deactivates all hints, for verbosity:3 we want the processing # messages nonetheless, so we activate them again unconditionally: incl(msgs.gNotes, hintProcessing) message(n.info, hintProcessing, $idgen.gBackendId) - + const verbosePass* = makePass(open = verboseOpen, process = verboseProcess) -proc cleanUp(c: PPassContext, n: PNode): PNode = +proc cleanUp(c: PPassContext, n: PNode): PNode = result = n # we cannot clean up if dead code elimination is activated - if optDeadCodeElim in gGlobalOptions or n == nil: return + if optDeadCodeElim in gGlobalOptions or n == nil: return case n.kind - of nkStmtList: + of nkStmtList: for i in countup(0, sonsLen(n) - 1): discard cleanUp(c, n.sons[i]) - of nkProcDef, nkMethodDef: - if n.sons[namePos].kind == nkSym: + of nkProcDef, nkMethodDef: + if n.sons[namePos].kind == nkSym: var s = n.sons[namePos].sym - if sfDeadCodeElim notin getModule(s).flags and not astNeeded(s): + if sfDeadCodeElim notin getModule(s).flags and not astNeeded(s): s.ast.sons[bodyPos] = ast.emptyNode # free the memory - else: + else: discard const cleanupPass* = makePass(process = cleanUp, close = cleanUp) diff --git a/compiler/patterns.nim b/compiler/patterns.nim index 3f8b05940c..604d3521db 100644 --- a/compiler/patterns.nim +++ b/compiler/patterns.nim @@ -68,7 +68,7 @@ proc inSymChoice(sc, x: PNode): bool = elif sc.kind == nkOpenSymChoice: # same name suffices for open sym choices! result = sc.sons[0].sym.name.id == x.sym.name.id - + proc checkTypes(c: PPatternContext, p: PSym, n: PNode): bool = # check param constraints first here as this is quite optimized: if p.constraint != nil: @@ -115,13 +115,13 @@ proc matchNested(c: PPatternContext, p, n: PNode, rpn: bool): bool = if rpn: arglist.add(n.sons[0]) elif n.kind == nkHiddenStdConv and n.sons[1].kind == nkBracket: let n = n.sons[1] - for i in 0.. ", nodecl, varargs.} -proc toStrMaxPrecision*(f: BiggestFloat): string = +proc toStrMaxPrecision*(f: BiggestFloat): string = if f != f: result = "NAN" elif f == 0.0: @@ -21,17 +21,17 @@ proc toStrMaxPrecision*(f: BiggestFloat): string = if f > 0.0: result = "INF" else: result = "-INF" else: - var buf: array [0..80, char] - c_sprintf(buf, "%#.16e", f) + var buf: array [0..80, char] + c_sprintf(buf, "%#.16e", f) result = $buf proc encodeStr*(s: string, result: var string) = - for i in countup(0, len(s) - 1): + for i in countup(0, len(s) - 1): case s[i] of 'a'..'z', 'A'..'Z', '0'..'9', '_': add(result, s[i]) else: add(result, '\\' & toHex(ord(s[i]), 2)) -proc hexChar(c: char, xi: var int) = +proc hexChar(c: char, xi: var int) = case c of '0'..'9': xi = (xi shl 4) or (ord(c) - ord('0')) of 'a'..'f': xi = (xi shl 4) or (ord(c) - ord('a') + 10) @@ -41,18 +41,18 @@ proc hexChar(c: char, xi: var int) = proc decodeStr*(s: cstring, pos: var int): string = var i = pos result = "" - while true: + while true: case s[i] - of '\\': + of '\\': inc(i, 3) var xi = 0 hexChar(s[i-2], xi) hexChar(s[i-1], xi) add(result, chr(xi)) - of 'a'..'z', 'A'..'Z', '0'..'9', '_': + of 'a'..'z', 'A'..'Z', '0'..'9', '_': add(result, s[i]) inc(i) - else: break + else: break pos = i const @@ -68,11 +68,11 @@ template encodeIntImpl(self: expr) = var d: char var v = x var rem = v mod 190 - if rem < 0: + if rem < 0: add(result, '-') v = - (v div 190) rem = - rem - else: + else: v = v div 190 var idx = int(rem) if idx < 62: d = chars[idx] @@ -89,11 +89,11 @@ proc encodeVBiggestInt*(x: BiggestInt, result: var string) = encodeVBiggestIntAux(x +% vintDelta, result) # encodeIntImpl(encodeVBiggestInt) -proc encodeVIntAux(x: int, result: var string) = +proc encodeVIntAux(x: int, result: var string) = ## encode an int as a variable length base 190 int. encodeIntImpl(encodeVIntAux) - -proc encodeVInt*(x: int, result: var string) = + +proc encodeVInt*(x: int, result: var string) = ## encode an int as a variable length base 190 int. encodeVIntAux(x +% vintDelta, result) @@ -101,11 +101,11 @@ template decodeIntImpl() = var i = pos var sign = - 1 assert(s[i] in {'a'..'z', 'A'..'Z', '0'..'9', '-', '\x80'..'\xFF'}) - if s[i] == '-': + if s[i] == '-': inc(i) sign = 1 result = 0 - while true: + while true: case s[i] of '0'..'9': result = result * 190 - (ord(s[i]) - ord('0')) of 'a'..'z': result = result * 190 - (ord(s[i]) - ord('a') + 10) @@ -116,7 +116,7 @@ template decodeIntImpl() = result = result * sign -% vintDelta pos = i -proc decodeVInt*(s: cstring, pos: var int): int = +proc decodeVInt*(s: cstring, pos: var int): int = decodeIntImpl() proc decodeVBiggestInt*(s: cstring, pos: var int): BiggestInt = diff --git a/compiler/ropes.nim b/compiler/ropes.nim index edac8e9d0c..bfae7aaa41 100644 --- a/compiler/ropes.nim +++ b/compiler/ropes.nim @@ -306,7 +306,7 @@ const proc equalsFile*(r: Rope, f: File): bool = ## returns true if the contents of the file `f` equal `r`. - var + var buf: array[bufSize, char] bpos = buf.len blen = buf.len diff --git a/compiler/saturate.nim b/compiler/saturate.nim index f4fe29a206..065cb51284 100644 --- a/compiler/saturate.nim +++ b/compiler/saturate.nim @@ -72,7 +72,7 @@ proc `|*|`*(a, b: BiggestInt): BiggestInt = # 32 * abs(diff) <= abs(prod) -- 5 good bits is "close enough" if 32.0 * abs(resAsFloat - floatProd) <= abs(floatProd): return result - + if floatProd >= 0.0: result = high(result) else: diff --git a/compiler/semcall.nim b/compiler/semcall.nim index e2ff16c6e2..2f181b5f37 100644 --- a/compiler/semcall.nim +++ b/compiler/semcall.nim @@ -320,7 +320,7 @@ proc semResolvedCall(c: PContext, n: PNode, x: TCandidate): PNode = x.call.add newSymNode(s, n.info) else: internalAssert false - + result = x.call instGenericConvertersSons(c, result, x) result.sons[0] = newSymNode(finalCallee, result.sons[0].info) diff --git a/compiler/semfields.nim b/compiler/semfields.nim index e086e73f81..2e6c6c3ea3 100644 --- a/compiler/semfields.nim +++ b/compiler/semfields.nim @@ -76,7 +76,7 @@ proc semForObjectFields(c: TFieldsCtx, typ, forLoop, father: PNode) = let L = forLoop.len let call = forLoop.sons[L-2] if call.len > 2: - localError(forLoop.info, errGenerated, + localError(forLoop.info, errGenerated, "parallel 'fields' iterator does not work for 'case' objects") return # iterate over the selector: @@ -106,7 +106,7 @@ proc semForFields(c: PContext, n: PNode, m: TMagic): PNode = # a 'while true: stmt; break' loop ... result = newNodeI(nkWhileStmt, n.info, 2) var trueSymbol = strTableGet(magicsys.systemModule.tab, getIdent"true") - if trueSymbol == nil: + if trueSymbol == nil: localError(n.info, errSystemNeeds, "true") trueSymbol = newSym(skUnknown, getIdent"true", getCurrOwner(), n.info) trueSymbol.typ = getSysType(tyBool) @@ -114,13 +114,13 @@ proc semForFields(c: PContext, n: PNode, m: TMagic): PNode = result.sons[0] = newSymNode(trueSymbol, n.info) var stmts = newNodeI(nkStmtList, n.info) result.sons[1] = stmts - + var length = sonsLen(n) var call = n.sons[length-2] if length-2 != sonsLen(call)-1 + ord(m==mFieldPairs): localError(n.info, errWrongNumberOfVariables) return result - + var tupleTypeA = skipTypes(call.sons[1].typ, abstractVar-{tyTypeDesc}) if tupleTypeA.kind notin {tyTuple, tyObject}: localError(n.info, errGenerated, "no object or tuple type") @@ -129,7 +129,7 @@ proc semForFields(c: PContext, n: PNode, m: TMagic): PNode = var tupleTypeB = skipTypes(call.sons[i].typ, abstractVar-{tyTypeDesc}) if not sameType(tupleTypeA, tupleTypeB): typeMismatch(call.sons[i], tupleTypeA, tupleTypeB) - + inc(c.p.nestedLoopCounter) if tupleTypeA.kind == tyTuple: var loopBody = n.sons[length-1] diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index 357c6cf32f..61f1a74440 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -1327,7 +1327,7 @@ proc paramTypesMatchAux(m: var TCandidate, f, argType: PType, # because in that case there is no point in continuing. var bothMetaCounter = 0 var lastBindingsLength = -1 - while r == isBothMetaConvertible and + while r == isBothMetaConvertible and lastBindingsLength != m.bindings.counter and bothMetaCounter < 100: lastBindingsLength = m.bindings.counter diff --git a/compiler/suggest.nim b/compiler/suggest.nim index 659f1fa166..c15a56c54c 100644 --- a/compiler/suggest.nim +++ b/compiler/suggest.nim @@ -34,7 +34,7 @@ var template origModuleName(m: PSym): string = m.name.s -proc symToSuggest(s: PSym, isLocal: bool, section: string, li: TLineInfo): Suggest = +proc symToSuggest(s: PSym, isLocal: bool, section: string, li: TLineInfo): Suggest = result.section = parseIdeCmd(section) if optIdeTerse in gGlobalOptions: result.symkind = s.kind @@ -52,7 +52,7 @@ proc symToSuggest(s: PSym, isLocal: bool, section: string, li: TLineInfo): Sugge result.qualifiedPath.add(ow.origModuleName) result.qualifiedPath.add(s.name.s) - if s.typ != nil: + if s.typ != nil: result.forth = typeToString(s.typ) else: result.forth = "" @@ -62,7 +62,7 @@ proc symToSuggest(s: PSym, isLocal: bool, section: string, li: TLineInfo): Sugge when not defined(noDocgen): result.doc = s.extractDocComment -proc `$`(suggest: Suggest): string = +proc `$`(suggest: Suggest): string = result = $suggest.section result.add(sep) result.add($suggest.symkind) @@ -80,7 +80,7 @@ proc `$`(suggest: Suggest): string = when not defined(noDocgen): result.add(suggest.doc.escape) -proc symToSuggest(s: PSym, isLocal: bool, section: string): Suggest = +proc symToSuggest(s: PSym, isLocal: bool, section: string): Suggest = result = symToSuggest(s, isLocal, section, s.info) proc suggestResult(s: Suggest) = @@ -104,7 +104,7 @@ proc fieldVisible*(c: PContext, f: PSym): bool {.inline.} = result = true break -proc suggestField(c: PContext, s: PSym, outputs: var int) = +proc suggestField(c: PContext, s: PSym, outputs: var int) = if filterSym(s) and fieldVisible(c, s): suggestResult(symToSuggest(s, isLocal=true, $ideSug)) inc outputs @@ -122,17 +122,17 @@ template wholeSymTab(cond, section: expr) {.immediate.} = suggestResult(symToSuggest(it, isLocal = isLocal, section)) inc outputs -proc suggestSymList(c: PContext, list: PNode, outputs: var int) = - for i in countup(0, sonsLen(list) - 1): +proc suggestSymList(c: PContext, list: PNode, outputs: var int) = + for i in countup(0, sonsLen(list) - 1): if list.sons[i].kind == nkSym: suggestField(c, list.sons[i].sym, outputs) #else: InternalError(list.info, "getSymFromList") -proc suggestObject(c: PContext, n: PNode, outputs: var int) = +proc suggestObject(c: PContext, n: PNode, outputs: var int) = case n.kind - of nkRecList: + of nkRecList: for i in countup(0, sonsLen(n)-1): suggestObject(c, n.sons[i], outputs) - of nkRecCase: + of nkRecCase: var L = sonsLen(n) if L > 0: suggestObject(c, n.sons[0], outputs) @@ -140,7 +140,7 @@ proc suggestObject(c: PContext, n: PNode, outputs: var int) = of nkSym: suggestField(c, n.sym, outputs) else: discard -proc nameFits(c: PContext, s: PSym, n: PNode): bool = +proc nameFits(c: PContext, s: PSym, n: PNode): bool = var op = n.sons[0] if op.kind in {nkOpenSymChoice, nkClosedSymChoice}: op = op.sons[0] var opr: PIdent @@ -150,8 +150,8 @@ proc nameFits(c: PContext, s: PSym, n: PNode): bool = else: return false result = opr.id == s.name.id -proc argsFit(c: PContext, candidate: PSym, n, nOrig: PNode): bool = - case candidate.kind +proc argsFit(c: PContext, candidate: PSym, n, nOrig: PNode): bool = + case candidate.kind of OverloadableSyms: var m: TCandidate initCandidate(c, m, candidate, nil) @@ -160,11 +160,11 @@ proc argsFit(c: PContext, candidate: PSym, n, nOrig: PNode): bool = else: result = false -proc suggestCall(c: PContext, n, nOrig: PNode, outputs: var int) = +proc suggestCall(c: PContext, n, nOrig: PNode, outputs: var int) = wholeSymTab(filterSym(it) and nameFits(c, it, n) and argsFit(c, it, n, nOrig), $ideCon) -proc typeFits(c: PContext, s: PSym, firstArg: PType): bool {.inline.} = +proc typeFits(c: PContext, s: PSym, firstArg: PType): bool {.inline.} = if s.typ != nil and sonsLen(s.typ) > 1 and s.typ.sons[1] != nil: # special rule: if system and some weird generic match via 'tyExpr' # or 'tyGenericParam' we won't list it either to reduce the noise (nobody @@ -198,48 +198,48 @@ proc suggestFieldAccess(c: PContext, n: PNode, outputs: var int) = var typ = n.typ if typ == nil: # a module symbol has no type for example: - if n.kind == nkSym and n.sym.kind == skModule: - if n.sym == c.module: + if n.kind == nkSym and n.sym.kind == skModule: + if n.sym == c.module: # all symbols accessible, because we are in the current module: for it in items(c.topLevelScope.symbols): - if filterSym(it): + if filterSym(it): suggestResult(symToSuggest(it, isLocal=false, $ideSug)) inc outputs - else: - for it in items(n.sym.tab): - if filterSym(it): + else: + for it in items(n.sym.tab): + if filterSym(it): suggestResult(symToSuggest(it, isLocal=false, $ideSug)) inc outputs else: # fallback: suggestEverything(c, n, outputs) - elif typ.kind == tyEnum and n.kind == nkSym and n.sym.kind == skType: + elif typ.kind == tyEnum and n.kind == nkSym and n.sym.kind == skType: # look up if the identifier belongs to the enum: var t = typ - while t != nil: + while t != nil: suggestSymList(c, t.n, outputs) t = t.sons[0] suggestOperations(c, n, typ, outputs) else: typ = skipTypes(typ, {tyGenericInst, tyVar, tyPtr, tyRef}) - if typ.kind == tyObject: + if typ.kind == tyObject: var t = typ - while true: + while true: suggestObject(c, t.n, outputs) - if t.sons[0] == nil: break + if t.sons[0] == nil: break t = skipTypes(t.sons[0], {tyGenericInst}) suggestOperations(c, n, typ, outputs) - elif typ.kind == tyTuple and typ.n != nil: + elif typ.kind == tyTuple and typ.n != nil: suggestSymList(c, typ.n, outputs) suggestOperations(c, n, typ, outputs) else: suggestOperations(c, n, typ, outputs) type - TCheckPointResult = enum + TCheckPointResult = enum cpNone, cpFuzzy, cpExact -proc inCheckpoint(current: TLineInfo): TCheckPointResult = +proc inCheckpoint(current: TLineInfo): TCheckPointResult = if current.fileIndex == gTrackPos.fileIndex: if current.line == gTrackPos.line and abs(current.col-gTrackPos.col) < 4: @@ -255,8 +255,8 @@ proc findClosestDot(n: PNode): PNode = result = findClosestDot(n.sons[i]) if result != nil: return -proc findClosestCall(n: PNode): PNode = - if n.kind in nkCallKinds and inCheckpoint(n.info) == cpExact: +proc findClosestCall(n: PNode): PNode = + if n.kind in nkCallKinds and inCheckpoint(n.info) == cpExact: result = n else: for i in 0.. = current.col and col <= current.col+tokenLen-1: return true -proc findClosestSym(n: PNode): PNode = - if n.kind == nkSym and inCheckpoint(n.info) == cpExact: +proc findClosestSym(n: PNode): PNode = + if n.kind == nkSym and inCheckpoint(n.info) == cpExact: result = n elif n.kind notin {nkNone..nkNilLit}: for i in 0.. 0 and gIdeCmd != ideUse: suggestQuit() -proc suggestStmt*(c: PContext, n: PNode) = +proc suggestStmt*(c: PContext, n: PNode) = suggestExpr(c, n) diff --git a/compiler/syntaxes.nim b/compiler/syntaxes.nim index 5fd81d87e3..91cfdbefdc 100644 --- a/compiler/syntaxes.nim +++ b/compiler/syntaxes.nim @@ -9,24 +9,24 @@ ## Implements the dispatcher for the different parsers. -import - strutils, llstream, ast, astalgo, idents, lexer, options, msgs, parser, +import + strutils, llstream, ast, astalgo, idents, lexer, options, msgs, parser, pbraces, filters, filter_tmpl, renderer -type - TFilterKind* = enum +type + TFilterKind* = enum filtNone, filtTemplate, filtReplace, filtStrip - TParserKind* = enum + TParserKind* = enum skinStandard, skinStrongSpaces, skinBraces, skinEndX -const +const parserNames*: array[TParserKind, string] = ["standard", "strongspaces", "braces", "endx"] filterNames*: array[TFilterKind, string] = ["none", "stdtmpl", "replace", "strip"] type - TParsers*{.final.} = object + TParsers*{.final.} = object skin*: TParserKind parser*: TParser @@ -42,53 +42,53 @@ proc parseTopLevelStmt*(p: var TParsers): PNode # implementation proc parseFile(fileIdx: int32): PNode = - var + var p: TParsers f: File let filename = fileIdx.toFullPathConsiderDirty if not open(f, filename): rawMessage(errCannotOpenFile, filename) - return + return openParsers(p, fileIdx, llStreamOpen(f)) result = parseAll(p) closeParsers(p) -proc parseAll(p: var TParsers): PNode = +proc parseAll(p: var TParsers): PNode = case p.skin of skinStandard, skinStrongSpaces: result = parser.parseAll(p.parser) - of skinBraces: + of skinBraces: result = pbraces.parseAll(p.parser) - of skinEndX: - internalError("parser to implement") + of skinEndX: + internalError("parser to implement") result = ast.emptyNode - -proc parseTopLevelStmt(p: var TParsers): PNode = + +proc parseTopLevelStmt(p: var TParsers): PNode = case p.skin of skinStandard, skinStrongSpaces: result = parser.parseTopLevelStmt(p.parser) - of skinBraces: + of skinBraces: result = pbraces.parseTopLevelStmt(p.parser) - of skinEndX: - internalError("parser to implement") + of skinEndX: + internalError("parser to implement") result = ast.emptyNode - -proc utf8Bom(s: string): int = - if (s[0] == '\xEF') and (s[1] == '\xBB') and (s[2] == '\xBF'): + +proc utf8Bom(s: string): int = + if (s[0] == '\xEF') and (s[1] == '\xBB') and (s[2] == '\xBF'): result = 3 - else: + else: result = 0 - -proc containsShebang(s: string, i: int): bool = - if (s[i] == '#') and (s[i + 1] == '!'): + +proc containsShebang(s: string, i: int): bool = + if (s[i] == '#') and (s[i + 1] == '!'): var j = i + 2 while s[j] in Whitespace: inc(j) result = s[j] == '/' -proc parsePipe(filename: string, inputStream: PLLStream): PNode = +proc parsePipe(filename: string, inputStream: PLLStream): PNode = result = ast.emptyNode var s = llStreamOpen(filename, fmRead) - if s != nil: + if s != nil: var line = newStringOfCap(80) discard llStreamReadLine(s, line) var i = utf8Bom(line) @@ -104,50 +104,50 @@ proc parsePipe(filename: string, inputStream: PLLStream): PNode = closeParser(q) llStreamClose(s) -proc getFilter(ident: PIdent): TFilterKind = - for i in countup(low(TFilterKind), high(TFilterKind)): - if identEq(ident, filterNames[i]): +proc getFilter(ident: PIdent): TFilterKind = + for i in countup(low(TFilterKind), high(TFilterKind)): + if identEq(ident, filterNames[i]): return i result = filtNone -proc getParser(ident: PIdent): TParserKind = - for i in countup(low(TParserKind), high(TParserKind)): - if identEq(ident, parserNames[i]): +proc getParser(ident: PIdent): TParserKind = + for i in countup(low(TParserKind), high(TParserKind)): + if identEq(ident, parserNames[i]): return i rawMessage(errInvalidDirectiveX, ident.s) -proc getCallee(n: PNode): PIdent = - if n.kind in nkCallKinds and n.sons[0].kind == nkIdent: +proc getCallee(n: PNode): PIdent = + if n.kind in nkCallKinds and n.sons[0].kind == nkIdent: result = n.sons[0].ident - elif n.kind == nkIdent: + elif n.kind == nkIdent: result = n.ident - else: + else: rawMessage(errXNotAllowedHere, renderTree(n)) - -proc applyFilter(p: var TParsers, n: PNode, filename: string, - stdin: PLLStream): PLLStream = + +proc applyFilter(p: var TParsers, n: PNode, filename: string, + stdin: PLLStream): PLLStream = var ident = getCallee(n) var f = getFilter(ident) case f - of filtNone: + of filtNone: p.skin = getParser(ident) result = stdin - of filtTemplate: + of filtTemplate: result = filterTmpl(stdin, filename, n) - of filtStrip: + of filtStrip: result = filterStrip(stdin, filename, n) - of filtReplace: + of filtReplace: result = filterReplace(stdin, filename, n) - if f != filtNone: + if f != filtNone: if hintCodeBegin in gNotes: rawMessage(hintCodeBegin, []) msgWriteln(result.s) rawMessage(hintCodeEnd, []) -proc evalPipe(p: var TParsers, n: PNode, filename: string, - start: PLLStream): PLLStream = +proc evalPipe(p: var TParsers, n: PNode, filename: string, + start: PLLStream): PLLStream = result = start - if n.kind == nkEmpty: return + if n.kind == nkEmpty: return if n.kind == nkInfix and n.sons[0].kind == nkIdent and identEq(n.sons[0].ident, "|"): for i in countup(1, 2): @@ -159,8 +159,8 @@ proc evalPipe(p: var TParsers, n: PNode, filename: string, result = evalPipe(p, n.sons[0], filename, result) else: result = applyFilter(p, n, filename, result) - -proc openParsers(p: var TParsers, fileIdx: int32, inputstream: PLLStream) = + +proc openParsers(p: var TParsers, fileIdx: int32, inputstream: PLLStream) = var s: PLLStream p.skin = skinStandard let filename = fileIdx.toFullPathConsiderDirty @@ -172,6 +172,6 @@ proc openParsers(p: var TParsers, fileIdx: int32, inputstream: PLLStream) = parser.openParser(p.parser, fileIdx, s, false) of skinStrongSpaces: parser.openParser(p.parser, fileIdx, s, true) - + proc closeParsers(p: var TParsers) = parser.closeParser(p.parser) diff --git a/compiler/tccgen.nim b/compiler/tccgen.nim index 0082dfcbb3..7616641fc4 100644 --- a/compiler/tccgen.nim +++ b/compiler/tccgen.nim @@ -12,10 +12,10 @@ import {.compile: "../tinyc/libtcc.c".} -proc tinyCErrorHandler(closure: pointer, msg: cstring) {.cdecl.} = +proc tinyCErrorHandler(closure: pointer, msg: cstring) {.cdecl.} = rawMessage(errGenerated, $msg) - -proc initTinyCState: PccState = + +proc initTinyCState: PccState = result = openCCState() setErrorFunc(result, nil, tinyCErrorHandler) @@ -23,25 +23,25 @@ var gTinyC = initTinyCState() libIncluded = false -proc addFile(filename: string) = +proc addFile(filename: string) = if addFile(gTinyC, filename) != 0'i32: rawMessage(errCannotOpenFile, filename) -proc setupEnvironment = +proc setupEnvironment = when defined(amd64): defineSymbol(gTinyC, "__x86_64__", nil) elif defined(i386): - defineSymbol(gTinyC, "__i386__", nil) + defineSymbol(gTinyC, "__i386__", nil) when defined(linux): defineSymbol(gTinyC, "__linux__", nil) defineSymbol(gTinyC, "__linux", nil) var nimrodDir = getPrefixDir() addIncludePath(gTinyC, libpath) - when defined(windows): + when defined(windows): addSysincludePath(gTinyC, nimrodDir / "tinyc/win32/include") addSysincludePath(gTinyC, nimrodDir / "tinyc/include") - when defined(windows): + when defined(windows): defineSymbol(gTinyC, "_WIN32", nil) # we need Mingw's headers too: var gccbin = getConfigVar("gcc.path") % ["nimrod", nimrodDir] @@ -54,7 +54,7 @@ proc setupEnvironment = #addFile(nimrodDir / r"tinyc\win32\dllcrt1.o") #addFile(nimrodDir / r"tinyc\win32\dllmain.o") addFile(nimrodDir / r"tinyc\win32\libtcc1.o") - + #addFile(nimrodDir / r"tinyc\win32\lib\crt1.c") #addFile(nimrodDir / r"tinyc\lib\libtcc1.c") else: @@ -62,12 +62,12 @@ proc setupEnvironment = when defined(amd64): addSysincludePath(gTinyC, "/usr/include/x86_64-linux-gnu") -proc compileCCode*(ccode: string) = +proc compileCCode*(ccode: string) = if not libIncluded: libIncluded = true setupEnvironment() discard compileString(gTinyC, ccode) - + proc run*(args: string) = var s = @[cstring(gProjectName)] & map(split(args), proc(x: string): cstring = cstring(x)) var err = tinyc.run(gTinyC, cint(len(s)), cast[cstringArray](addr(s[0]))) != 0'i32 diff --git a/compiler/treetab.nim b/compiler/treetab.nim index adfc7b2ce2..e6eb8c666a 100644 --- a/compiler/treetab.nim +++ b/compiler/treetab.nim @@ -9,36 +9,36 @@ # Implements a table from trees to trees. Does structural equivalence checking. -import +import hashes, ast, astalgo, types -proc hashTree(n: PNode): Hash = - if n == nil: return +proc hashTree(n: PNode): Hash = + if n == nil: return result = ord(n.kind) case n.kind - of nkEmpty, nkNilLit, nkType: + of nkEmpty, nkNilLit, nkType: discard - of nkIdent: + of nkIdent: result = result !& n.ident.h of nkSym: result = result !& n.sym.name.h - of nkCharLit..nkUInt64Lit: - if (n.intVal >= low(int)) and (n.intVal <= high(int)): + of nkCharLit..nkUInt64Lit: + if (n.intVal >= low(int)) and (n.intVal <= high(int)): result = result !& int(n.intVal) of nkFloatLit..nkFloat64Lit: - if (n.floatVal >= - 1000000.0) and (n.floatVal <= 1000000.0): + if (n.floatVal >= - 1000000.0) and (n.floatVal <= 1000000.0): result = result !& toInt(n.floatVal) of nkStrLit..nkTripleStrLit: if not n.strVal.isNil: result = result !& hash(n.strVal) - else: - for i in countup(0, sonsLen(n) - 1): + else: + for i in countup(0, sonsLen(n) - 1): result = result !& hashTree(n.sons[i]) - -proc treesEquivalent(a, b: PNode): bool = - if a == b: + +proc treesEquivalent(a, b: PNode): bool = + if a == b: result = true - elif (a != nil) and (b != nil) and (a.kind == b.kind): + elif (a != nil) and (b != nil) and (a.kind == b.kind): case a.kind of nkEmpty, nkNilLit, nkType: result = true of nkSym: result = a.sym.id == b.sym.id @@ -46,28 +46,28 @@ proc treesEquivalent(a, b: PNode): bool = of nkCharLit..nkUInt64Lit: result = a.intVal == b.intVal of nkFloatLit..nkFloat64Lit: result = a.floatVal == b.floatVal of nkStrLit..nkTripleStrLit: result = a.strVal == b.strVal - else: - if sonsLen(a) == sonsLen(b): - for i in countup(0, sonsLen(a) - 1): - if not treesEquivalent(a.sons[i], b.sons[i]): return + else: + if sonsLen(a) == sonsLen(b): + for i in countup(0, sonsLen(a) - 1): + if not treesEquivalent(a.sons[i], b.sons[i]): return result = true if result: result = sameTypeOrNil(a.typ, b.typ) - -proc nodeTableRawGet(t: TNodeTable, k: Hash, key: PNode): int = + +proc nodeTableRawGet(t: TNodeTable, k: Hash, key: PNode): int = var h: Hash = k and high(t.data) - while t.data[h].key != nil: - if (t.data[h].h == k) and treesEquivalent(t.data[h].key, key): + while t.data[h].key != nil: + if (t.data[h].h == k) and treesEquivalent(t.data[h].key, key): return h h = nextTry(h, high(t.data)) result = -1 -proc nodeTableGet*(t: TNodeTable, key: PNode): int = +proc nodeTableGet*(t: TNodeTable, key: PNode): int = var index = nodeTableRawGet(t, hashTree(key), key) if index >= 0: result = t.data[index].val else: result = low(int) - -proc nodeTableRawInsert(data: var TNodePairSeq, k: Hash, key: PNode, - val: int) = + +proc nodeTableRawInsert(data: var TNodePairSeq, k: Hash, key: PNode, + val: int) = var h: Hash = k and high(data) while data[h].key != nil: h = nextTry(h, high(data)) assert(data[h].key == nil) @@ -75,35 +75,35 @@ proc nodeTableRawInsert(data: var TNodePairSeq, k: Hash, key: PNode, data[h].key = key data[h].val = val -proc nodeTablePut*(t: var TNodeTable, key: PNode, val: int) = +proc nodeTablePut*(t: var TNodeTable, key: PNode, val: int) = var n: TNodePairSeq var k: Hash = hashTree(key) var index = nodeTableRawGet(t, k, key) - if index >= 0: + if index >= 0: assert(t.data[index].key != nil) t.data[index].val = val - else: - if mustRehash(len(t.data), t.counter): + else: + if mustRehash(len(t.data), t.counter): newSeq(n, len(t.data) * GrowthFactor) - for i in countup(0, high(t.data)): - if t.data[i].key != nil: + for i in countup(0, high(t.data)): + if t.data[i].key != nil: nodeTableRawInsert(n, t.data[i].h, t.data[i].key, t.data[i].val) swap(t.data, n) nodeTableRawInsert(t.data, k, key, val) inc(t.counter) -proc nodeTableTestOrSet*(t: var TNodeTable, key: PNode, val: int): int = +proc nodeTableTestOrSet*(t: var TNodeTable, key: PNode, val: int): int = var n: TNodePairSeq var k: Hash = hashTree(key) var index = nodeTableRawGet(t, k, key) - if index >= 0: + if index >= 0: assert(t.data[index].key != nil) result = t.data[index].val - else: - if mustRehash(len(t.data), t.counter): + else: + if mustRehash(len(t.data), t.counter): newSeq(n, len(t.data) * GrowthFactor) - for i in countup(0, high(t.data)): - if t.data[i].key != nil: + for i in countup(0, high(t.data)): + if t.data[i].key != nil: nodeTableRawInsert(n, t.data[i].h, t.data[i].key, t.data[i].val) swap(t.data, n) nodeTableRawInsert(t.data, k, key, val) From 43bddf62dd982e64cd7350eabbbc5d04c5adab21 Mon Sep 17 00:00:00 2001 From: Adam Strzelecki Date: Fri, 4 Sep 2015 23:03:56 +0200 Subject: [PATCH 02/11] lib: Trim .nim files trailing whitespace via OSX: find . -name '*.nim' -exec sed -i '' -E 's/[[:space:]]+$//' {} + --- lib/impure/db_mysql.nim | 70 ++-- lib/impure/db_postgres.nim | 36 +- lib/impure/db_sqlite.nim | 84 ++-- lib/impure/graphics.nim | 110 +++--- lib/impure/re.nim | 6 +- lib/impure/ssl.nim | 26 +- lib/nimrtl.nim | 8 +- lib/posix/epoll.nim | 36 +- lib/posix/inotify.nim | 94 ++--- lib/posix/linux.nim | 2 +- lib/pure/actors.nim | 10 +- lib/pure/asyncfile.nim | 10 +- lib/pure/base64.nim | 42 +- lib/pure/basic2d.nim | 234 ++++++------ lib/pure/collections/LockFreeHash.nim | 364 +++++++++--------- lib/pure/collections/critbits.nim | 16 +- lib/pure/collections/lists.nim | 94 ++--- lib/pure/collections/queues.nim | 4 +- lib/pure/colors.nim | 44 +-- lib/pure/complex.nim | 8 +- lib/pure/concurrency/cpuinfo.nim | 2 +- lib/pure/cookies.nim | 10 +- lib/pure/encodings.nim | 366 +++++++++--------- lib/pure/endians.nim | 6 +- lib/pure/etcpriv.nim | 2 +- lib/pure/events.nim | 12 +- lib/pure/fsmonitor.nim | 30 +- lib/pure/httpserver.nim | 48 +-- lib/pure/matchers.nim | 12 +- lib/pure/memfiles.nim | 10 +- lib/pure/mersenne.nim | 2 +- lib/pure/numeric.nim | 20 +- lib/pure/oids.nim | 18 +- lib/pure/parsecfg.nim | 200 +++++----- lib/pure/parsecsv.nim | 40 +- lib/pure/parsesql.nim | 218 +++++------ lib/pure/parseurl.nim | 22 +- lib/pure/poly.nim | 90 ++--- lib/pure/rationals.nim | 2 +- lib/pure/redis.nim | 146 +++---- lib/pure/romans.nim | 4 +- lib/pure/ropes.nim | 20 +- lib/pure/scgi.nim | 68 ++-- lib/pure/smtp.nim | 60 +-- lib/pure/sockets.nim | 240 ++++++------ lib/pure/subexes.nim | 48 +-- lib/pure/unicode.nim | 2 +- lib/pure/unidecode/unidecode.nim | 22 +- lib/pure/xmldomparser.nim | 44 +-- lib/pure/xmlparser.nim | 38 +- lib/system/ansi_c.nim | 22 +- lib/system/avltree.nim | 4 +- lib/system/cellsets.nim | 10 +- lib/system/channels.nim | 522 ++++++++++++------------- lib/system/deepcopy.nim | 10 +- lib/system/gc2.nim | 140 +++---- lib/system/gc_common.nim | 4 +- lib/system/inclrtl.nim | 8 +- lib/system/profiler.nim | 2 +- lib/system/syslocks.nim | 20 +- lib/system/sysspawn.nim | 2 +- lib/system/timers.nim | 24 +- lib/system/widestrs.nim | 6 +- lib/wrappers/libsvm.nim | 108 +++--- lib/wrappers/mysql.nim | 530 +++++++++++++------------- lib/wrappers/sqlite3.nim | 334 ++++++++-------- lib/wrappers/tinyc.nim | 24 +- 67 files changed, 2435 insertions(+), 2435 deletions(-) diff --git a/lib/impure/db_mysql.nim b/lib/impure/db_mysql.nim index 197286f29a..d61d951ba4 100644 --- a/lib/impure/db_mysql.nim +++ b/lib/impure/db_mysql.nim @@ -7,7 +7,7 @@ # distribution, for details about the copyright. # -## A higher level `mySQL`:idx: database wrapper. The same interface is +## A higher level `mySQL`:idx: database wrapper. The same interface is ## implemented for other databases too. import strutils, mysql @@ -29,22 +29,22 @@ type {.deprecated: [TRow: Row, TSqlQuery: SqlQuery, TDbConn: DbConn].} proc sql*(query: string): SqlQuery {.noSideEffect, inline.} = - ## constructs a SqlQuery from the string `query`. This is supposed to be + ## constructs a SqlQuery from the string `query`. This is supposed to be ## used as a raw-string-literal modifier: ## ``sql"update user set counter = counter + 1"`` ## - ## If assertions are turned off, it does nothing. If assertions are turned + ## If assertions are turned off, it does nothing. If assertions are turned ## on, later versions will check the string for valid syntax. result = SqlQuery(query) -proc dbError(db: DbConn) {.noreturn.} = +proc dbError(db: DbConn) {.noreturn.} = ## raises an EDb exception. var e: ref EDb new(e) e.msg = $mysql.error(db) raise e -proc dbError*(msg: string) {.noreturn.} = +proc dbError*(msg: string) {.noreturn.} = ## raises an EDb exception with message `msg`. var e: ref EDb new(e) @@ -55,9 +55,9 @@ when false: proc dbQueryOpt*(db: DbConn, query: string, args: varargs[string, `$`]) = var stmt = mysql_stmt_init(db) if stmt == nil: dbError(db) - if mysql_stmt_prepare(stmt, query, len(query)) != 0: + if mysql_stmt_prepare(stmt, query, len(query)) != 0: dbError(db) - var + var binding: seq[MYSQL_BIND] discard mysql_stmt_close(stmt) @@ -79,9 +79,9 @@ proc dbFormat(formatstr: SqlQuery, args: varargs[string]): string = else: add(result, dbQuote(args[a])) inc(a) - else: + else: add(result, c) - + proc tryExec*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]): bool {. tags: [FReadDB, FWriteDb].} = ## tries to execute the query and returns true if successful, false otherwise. @@ -97,19 +97,19 @@ proc exec*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]) {. ## executes the query and raises EDB if not successful. var q = dbFormat(query, args) if mysql.realQuery(db, q, q.len) != 0'i32: dbError(db) - -proc newRow(L: int): Row = + +proc newRow(L: int): Row = newSeq(result, L) for i in 0..L-1: result[i] = "" - -proc properFreeResult(sqlres: mysql.PRES, row: cstringArray) = + +proc properFreeResult(sqlres: mysql.PRES, row: cstringArray) = if row != nil: while mysql.fetchRow(sqlres) != nil: discard mysql.freeResult(sqlres) - + iterator fastRows*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]): Row {.tags: [FReadDB].} = - ## executes the query and iterates over the result dataset. This is very + ## executes the query and iterates over the result dataset. This is very ## fast, but potenially dangerous: If the for-loop-body executes another ## query, the results can be undefined. For MySQL this is the case!. rawExec(db, query, args) @@ -121,7 +121,7 @@ iterator fastRows*(db: DbConn, query: SqlQuery, while true: row = mysql.fetchRow(sqlres) if row == nil: break - for i in 0..L-1: + for i in 0..L-1: setLen(result[i], 0) if row[i] == nil: result[i] = nil @@ -164,8 +164,8 @@ proc getRow*(db: DbConn, query: SqlQuery, var L = int(mysql.numFields(sqlres)) result = newRow(L) var row = mysql.fetchRow(sqlres) - if row != nil: - for i in 0..L-1: + if row != nil: + for i in 0..L-1: setLen(result[i], 0) if row[i] == nil: result[i] = nil @@ -173,7 +173,7 @@ proc getRow*(db: DbConn, query: SqlQuery, add(result[i], row[i]) properFreeResult(sqlres, row) -proc getAllRows*(db: DbConn, query: SqlQuery, +proc getAllRows*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]): seq[Row] {.tags: [FReadDB].} = ## executes the query and returns the whole result dataset. result = @[] @@ -196,44 +196,44 @@ proc getAllRows*(db: DbConn, query: SqlQuery, inc(j) mysql.freeResult(sqlres) -iterator rows*(db: DbConn, query: SqlQuery, +iterator rows*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]): Row {.tags: [FReadDB].} = ## same as `fastRows`, but slower and safe. for r in items(getAllRows(db, query, args)): yield r -proc getValue*(db: DbConn, query: SqlQuery, - args: varargs[string, `$`]): string {.tags: [FReadDB].} = +proc getValue*(db: DbConn, query: SqlQuery, + args: varargs[string, `$`]): string {.tags: [FReadDB].} = ## executes the query and returns the first column of the first row of the ## result dataset. Returns "" if the dataset contains no rows or the database ## value is NULL. result = getRow(db, query, args)[0] -proc tryInsertId*(db: DbConn, query: SqlQuery, +proc tryInsertId*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]): int64 {.tags: [FWriteDb].} = - ## executes the query (typically "INSERT") and returns the + ## executes the query (typically "INSERT") and returns the ## generated ID for the row or -1 in case of an error. var q = dbFormat(query, args) - if mysql.realQuery(db, q, q.len) != 0'i32: + if mysql.realQuery(db, q, q.len) != 0'i32: result = -1'i64 else: result = mysql.insertId(db) - -proc insertId*(db: DbConn, query: SqlQuery, - args: varargs[string, `$`]): int64 {.tags: [FWriteDb].} = - ## executes the query (typically "INSERT") and returns the + +proc insertId*(db: DbConn, query: SqlQuery, + args: varargs[string, `$`]): int64 {.tags: [FWriteDb].} = + ## executes the query (typically "INSERT") and returns the ## generated ID for the row. result = tryInsertID(db, query, args) if result < 0: dbError(db) -proc execAffectedRows*(db: DbConn, query: SqlQuery, +proc execAffectedRows*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]): int64 {. - tags: [FReadDB, FWriteDb].} = + tags: [FReadDB, FWriteDb].} = ## runs the query (typically "UPDATE") and returns the ## number of affected rows rawExec(db, query, args) result = mysql.affectedRows(db) -proc close*(db: DbConn) {.tags: [FDb].} = +proc close*(db: DbConn) {.tags: [FDb].} = ## closes the database connection. if db != nil: mysql.close(db) @@ -242,14 +242,14 @@ proc open*(connection, user, password, database: string): DbConn {. ## opens a database connection. Raises `EDb` if the connection could not ## be established. result = mysql.init(nil) - if result == nil: dbError("could not open database connection") + if result == nil: dbError("could not open database connection") let colonPos = connection.find(':') host = if colonPos < 0: connection else: substr(connection, 0, colonPos-1) port: int32 = if colonPos < 0: 0'i32 else: substr(connection, colonPos+1).parseInt.int32 - if mysql.realConnect(result, host, user, password, database, + if mysql.realConnect(result, host, user, password, database, port, nil, 0) == nil: var errmsg = $mysql.error(result) db_mysql.close(result) @@ -257,6 +257,6 @@ proc open*(connection, user, password, database: string): DbConn {. proc setEncoding*(connection: DbConn, encoding: string): bool {. tags: [FDb].} = - ## sets the encoding of a database connection, returns true for + ## sets the encoding of a database connection, returns true for ## success, false for failure. result = mysql.set_character_set(connection, encoding) == 0 diff --git a/lib/impure/db_postgres.nim b/lib/impure/db_postgres.nim index c88e660f4b..b75915a723 100644 --- a/lib/impure/db_postgres.nim +++ b/lib/impure/db_postgres.nim @@ -7,7 +7,7 @@ # distribution, for details about the copyright. # -## A higher level `PostgreSQL`:idx: database wrapper. This interface +## A higher level `PostgreSQL`:idx: database wrapper. This interface ## is implemented for other databases too. import strutils, postgres @@ -20,7 +20,7 @@ type ## used to get a row's ## column text on demand EDb* = object of IOError ## exception that is raised if a database error occurs - + SqlQuery* = distinct string ## an SQL query string SqlPrepared* = distinct string ## a identifier for the prepared queries @@ -30,15 +30,15 @@ type {.deprecated: [TRow: Row, TSqlQuery: SqlQuery, TDbConn: DbConn, TSqlPrepared: SqlPrepared].} -proc sql*(query: string): SqlQuery {.noSideEffect, inline.} = - ## constructs a SqlQuery from the string `query`. This is supposed to be +proc sql*(query: string): SqlQuery {.noSideEffect, inline.} = + ## constructs a SqlQuery from the string `query`. This is supposed to be ## used as a raw-string-literal modifier: ## ``sql"update user set counter = counter + 1"`` ## - ## If assertions are turned off, it does nothing. If assertions are turned + ## If assertions are turned off, it does nothing. If assertions are turned ## on, later versions will check the string for valid syntax. result = SqlQuery(query) - + proc dbError*(db: DbConn) {.noreturn.} = ## raises an EDb exception. var e: ref EDb @@ -73,7 +73,7 @@ proc dbFormat(formatstr: SqlQuery, args: varargs[string]): string = inc(a) else: add(result, c) - + proc tryExec*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]): bool {.tags: [FReadDB, FWriteDb].} = ## tries to execute the query and returns true if successful, false otherwise. @@ -106,7 +106,7 @@ proc exec*(db: DbConn, stmtName: SqlPrepared, proc newRow(L: int): Row = newSeq(result, L) for i in 0..L-1: result[i] = "" - + proc setupQuery(db: DbConn, query: SqlQuery, args: varargs[string]): PPGresult = var arr = allocCStringArray(args) @@ -128,7 +128,7 @@ proc prepare*(db: DbConn; stmtName: string, query: SqlQuery; var res = pqprepare(db, stmtName, query.string, int32(nParams), nil) if pqResultStatus(res) != PGRES_COMMAND_OK: dbError(db) return SqlPrepared(stmtName) - + proc setRow(res: PPGresult, r: var Row, line, cols: int32) = for col in 0..cols-1: setLen(r[col], 0) @@ -140,7 +140,7 @@ proc setRow(res: PPGresult, r: var Row, line, cols: int32) = iterator fastRows*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]): Row {.tags: [FReadDB].} = - ## executes the query and iterates over the result dataset. This is very + ## executes the query and iterates over the result dataset. This is very ## fast, but potenially dangerous: If the for-loop-body executes another ## query, the results can be undefined. For Postgres it is safe though. var res = setupQuery(db, query, args) @@ -224,14 +224,14 @@ proc getValue*(db: DbConn, query: SqlQuery, ## value is NULL. var x = pqgetvalue(setupQuery(db, query, args), 0, 0) result = if isNil(x): "" else: $x - + proc tryInsertID*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]): int64 {.tags: [FWriteDb].}= - ## executes the query (typically "INSERT") and returns the + ## executes the query (typically "INSERT") and returns the ## generated ID for the row or -1 in case of an error. For Postgre this adds ## ``RETURNING id`` to the query, so it only works if your primary key is - ## named ``id``. - var x = pqgetvalue(setupQuery(db, SqlQuery(string(query) & " RETURNING id"), + ## named ``id``. + var x = pqgetvalue(setupQuery(db, SqlQuery(string(query) & " RETURNING id"), args), 0, 0) if not isNil(x): result = parseBiggestInt($x) @@ -240,13 +240,13 @@ proc tryInsertID*(db: DbConn, query: SqlQuery, proc insertID*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]): int64 {.tags: [FWriteDb].} = - ## executes the query (typically "INSERT") and returns the + ## executes the query (typically "INSERT") and returns the ## generated ID for the row. For Postgre this adds ## ``RETURNING id`` to the query, so it only works if your primary key is - ## named ``id``. + ## named ``id``. result = tryInsertID(db, query, args) if result < 0: dbError(db) - + proc execAffectedRows*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]): int64 {.tags: [ FReadDB, FWriteDb].} = @@ -286,6 +286,6 @@ proc open*(connection, user, password, database: string): DbConn {. proc setEncoding*(connection: DbConn, encoding: string): bool {. tags: [FDb].} = - ## sets the encoding of a database connection, returns true for + ## sets the encoding of a database connection, returns true for ## success, false for failure. return pqsetClientEncoding(connection, encoding) == 0 diff --git a/lib/impure/db_sqlite.nim b/lib/impure/db_sqlite.nim index 1a037beccd..66276e9a45 100644 --- a/lib/impure/db_sqlite.nim +++ b/lib/impure/db_sqlite.nim @@ -7,7 +7,7 @@ # distribution, for details about the copyright. # -## A higher level `SQLite`:idx: database wrapper. This interface +## A higher level `SQLite`:idx: database wrapper. This interface ## is implemented for other databases too. import strutils, sqlite3 @@ -19,31 +19,31 @@ type InstantRow* = Pstmt ## a handle that can be used to get a row's column ## text on demand EDb* = object of IOError ## exception that is raised if a database error occurs - + SqlQuery* = distinct string ## an SQL query string - + FDb* = object of IOEffect ## effect that denotes a database operation FReadDb* = object of FDb ## effect that denotes a read operation FWriteDb* = object of FDb ## effect that denotes a write operation {.deprecated: [TRow: Row, TSqlQuery: SqlQuery, TDbConn: DbConn].} - -proc sql*(query: string): SqlQuery {.noSideEffect, inline.} = - ## constructs a SqlQuery from the string `query`. This is supposed to be + +proc sql*(query: string): SqlQuery {.noSideEffect, inline.} = + ## constructs a SqlQuery from the string `query`. This is supposed to be ## used as a raw-string-literal modifier: ## ``sql"update user set counter = counter + 1"`` ## - ## If assertions are turned off, it does nothing. If assertions are turned + ## If assertions are turned off, it does nothing. If assertions are turned ## on, later versions will check the string for valid syntax. result = SqlQuery(query) - -proc dbError(db: DbConn) {.noreturn.} = + +proc dbError(db: DbConn) {.noreturn.} = ## raises an EDb exception. var e: ref EDb new(e) e.msg = $sqlite3.errmsg(db) raise e -proc dbError*(msg: string) {.noreturn.} = +proc dbError*(msg: string) {.noreturn.} = ## raises an EDb exception with message `msg`. var e: ref EDb new(e) @@ -67,8 +67,8 @@ proc dbFormat(formatstr: SqlQuery, args: varargs[string]): string = inc(a) else: add(result, c) - -proc tryExec*(db: DbConn, query: SqlQuery, + +proc tryExec*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]): bool {.tags: [FReadDb, FWriteDb].} = ## tries to execute the query and returns true if successful, false otherwise. var q = dbFormat(query, args) @@ -81,32 +81,32 @@ proc exec*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]) {. tags: [FReadDb, FWriteDb].} = ## executes the query and raises EDB if not successful. if not tryExec(db, query, args): dbError(db) - + proc newRow(L: int): Row = newSeq(result, L) for i in 0..L-1: result[i] = "" - -proc setupQuery(db: DbConn, query: SqlQuery, - args: varargs[string]): Pstmt = + +proc setupQuery(db: DbConn, query: SqlQuery, + args: varargs[string]): Pstmt = var q = dbFormat(query, args) if prepare_v2(db, q, q.len.cint, result, nil) != SQLITE_OK: dbError(db) - + proc setRow(stmt: Pstmt, r: var Row, cols: cint) = for col in 0..cols-1: setLen(r[col], column_bytes(stmt, col)) # set capacity setLen(r[col], 0) let x = column_text(stmt, col) if not isNil(x): add(r[col], x) - + iterator fastRows*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]): Row {.tags: [FReadDb].} = - ## executes the query and iterates over the result dataset. This is very + ## executes the query and iterates over the result dataset. This is very ## fast, but potenially dangerous: If the for-loop-body executes another ## query, the results can be undefined. For Sqlite it is safe though. var stmt = setupQuery(db, query, args) var L = (column_count(stmt)) var result = newRow(L) - while step(stmt) == SQLITE_ROW: + while step(stmt) == SQLITE_ROW: setRow(stmt, result, L) yield result if finalize(stmt) != SQLITE_OK: dbError(db) @@ -136,31 +136,31 @@ proc getRow*(db: DbConn, query: SqlQuery, var stmt = setupQuery(db, query, args) var L = (column_count(stmt)) result = newRow(L) - if step(stmt) == SQLITE_ROW: + if step(stmt) == SQLITE_ROW: setRow(stmt, result, L) if finalize(stmt) != SQLITE_OK: dbError(db) -proc getAllRows*(db: DbConn, query: SqlQuery, +proc getAllRows*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]): seq[Row] {.tags: [FReadDb].} = ## executes the query and returns the whole result dataset. result = @[] for r in fastRows(db, query, args): result.add(r) -iterator rows*(db: DbConn, query: SqlQuery, +iterator rows*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]): Row {.tags: [FReadDb].} = ## same as `FastRows`, but slower and safe. for r in fastRows(db, query, args): yield r -proc getValue*(db: DbConn, query: SqlQuery, - args: varargs[string, `$`]): string {.tags: [FReadDb].} = +proc getValue*(db: DbConn, query: SqlQuery, + args: varargs[string, `$`]): string {.tags: [FReadDb].} = ## executes the query and returns the first column of the first row of the ## result dataset. Returns "" if the dataset contains no rows or the database ## value is NULL. var stmt = setupQuery(db, query, args) if step(stmt) == SQLITE_ROW: let cb = column_bytes(stmt, 0) - if cb == 0: + if cb == 0: result = "" else: result = newStringOfCap(cb) @@ -168,12 +168,12 @@ proc getValue*(db: DbConn, query: SqlQuery, else: result = "" if finalize(stmt) != SQLITE_OK: dbError(db) - -proc tryInsertID*(db: DbConn, query: SqlQuery, + +proc tryInsertID*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]): int64 {.tags: [FWriteDb], raises: [].} = - ## executes the query (typically "INSERT") and returns the - ## generated ID for the row or -1 in case of an error. + ## executes the query (typically "INSERT") and returns the + ## generated ID for the row or -1 in case of an error. var q = dbFormat(query, args) var stmt: sqlite3.Pstmt result = -1 @@ -183,27 +183,27 @@ proc tryInsertID*(db: DbConn, query: SqlQuery, if finalize(stmt) != SQLITE_OK: result = -1 -proc insertID*(db: DbConn, query: SqlQuery, - args: varargs[string, `$`]): int64 {.tags: [FWriteDb].} = - ## executes the query (typically "INSERT") and returns the +proc insertID*(db: DbConn, query: SqlQuery, + args: varargs[string, `$`]): int64 {.tags: [FWriteDb].} = + ## executes the query (typically "INSERT") and returns the ## generated ID for the row. For Postgre this adds ## ``RETURNING id`` to the query, so it only works if your primary key is - ## named ``id``. + ## named ``id``. result = tryInsertID(db, query, args) if result < 0: dbError(db) - -proc execAffectedRows*(db: DbConn, query: SqlQuery, + +proc execAffectedRows*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]): int64 {. - tags: [FReadDb, FWriteDb].} = + tags: [FReadDb, FWriteDb].} = ## executes the query (typically "UPDATE") and returns the ## number of affected rows. exec(db, query, args) result = changes(db) -proc close*(db: DbConn) {.tags: [FDb].} = +proc close*(db: DbConn) {.tags: [FDb].} = ## closes the database connection. if sqlite3.close(db) != SQLITE_OK: dbError(db) - + proc open*(connection, user, password, database: string): DbConn {. tags: [FDb].} = ## opens a database connection. Raises `EDb` if the connection could not @@ -216,12 +216,12 @@ proc open*(connection, user, password, database: string): DbConn {. proc setEncoding*(connection: DbConn, encoding: string): bool {. tags: [FDb].} = - ## sets the encoding of a database connection, returns true for + ## sets the encoding of a database connection, returns true for ## success, false for failure. ## ## Note that the encoding cannot be changed once it's been set. - ## According to SQLite3 documentation, any attempt to change - ## the encoding after the database is created will be silently + ## According to SQLite3 documentation, any attempt to change + ## the encoding after the database is created will be silently ## ignored. exec(connection, sql"PRAGMA encoding = ?", [encoding]) result = connection.getValue(sql"PRAGMA encoding") == encoding diff --git a/lib/impure/graphics.nim b/lib/impure/graphics.nim index 1b3d1d5b60..8bd769fd8a 100644 --- a/lib/impure/graphics.nim +++ b/lib/impure/graphics.nim @@ -9,7 +9,7 @@ ## This module implements graphical output for Nim; the current ## implementation uses SDL but the interface is meant to support multiple -## backends some day. There is no need to init SDL as this module does that +## backends some day. There is no need to init SDL as this module does that ## implicitly. import colors, math @@ -24,7 +24,7 @@ type Surface* {.pure, final.} = object w*, h*: Natural s*: sdl.PSurface - + EGraphics* = object of IOError Font {.pure, final.} = object @@ -35,7 +35,7 @@ type proc toSdlColor*(c: Color): sdl.Color = ## Convert colors.Color to sdl.Color - var x = c.extractRGB + var x = c.extractRGB result.r = x.r and 0xff result.g = x.g and 0xff result.b = x.b and 0xff @@ -43,7 +43,7 @@ proc toSdlColor*(c: Color): sdl.Color = proc createSdlColor*(sur: PSurface, c: Color, alpha: int = 0): int32 = ## Creates a color using ``sdl.MapRGBA``. var x = c.extractRGB - return sdl.mapRGBA(sur.s.format, x.r and 0xff, x.g and 0xff, + return sdl.mapRGBA(sur.s.format, x.r and 0xff, x.g and 0xff, x.b and 0xff, alpha and 0xff) proc toSdlRect*(r: Rect): sdl.Rect = @@ -53,26 +53,26 @@ proc toSdlRect*(r: Rect): sdl.Rect = result.w = uint16(r.width) result.h = uint16(r.height) -proc raiseEGraphics = +proc raiseEGraphics = raise newException(EGraphics, $sdl.getError()) - + proc surfaceFinalizer(s: PSurface) = sdl.freeSurface(s.s) - + proc newSurface*(width, height: int): PSurface = ## creates a new surface. new(result, surfaceFinalizer) result.w = width result.h = height - result.s = sdl.createRGBSurface(sdl.SWSURFACE, width, height, + result.s = sdl.createRGBSurface(sdl.SWSURFACE, width, height, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0) if result.s == nil: raiseEGraphics() - + assert(not sdl.mustLock(result.s)) proc fontFinalizer(f: PFont) = closeFont(f.f) -proc newFont*(name = "VeraMono.ttf", size = 9, color = colBlack): PFont = +proc newFont*(name = "VeraMono.ttf", size = 9, color = colBlack): PFont = ## Creates a new font object. Raises ``EIO`` if the font cannot be loaded. new(result, fontFinalizer) result.f = openFont(name, size.cint) @@ -84,7 +84,7 @@ var defaultFont*: PFont ## default font that is used; this needs to initialized ## by the client! -proc initDefaultFont*(name = "VeraMono.ttf", size = 9, color = colBlack) = +proc initDefaultFont*(name = "VeraMono.ttf", size = 9, color = colBlack) = ## initializes the `defaultFont` var. defaultFont = newFont(name, size, color) @@ -98,7 +98,7 @@ proc newScreenSurface*(width, height: int): PSurface = raiseEGraphics() proc writeToBMP*(sur: PSurface, filename: string) = - ## Saves the contents of the surface `sur` to the file `filename` as a + ## Saves the contents of the surface `sur` to the file `filename` as a ## BMP file. if sdl.saveBMP(sur.s, filename) != 0: raise newException(IOError, "cannot write: " & filename) @@ -111,7 +111,7 @@ type template setPix(video, pitch, x, y, col: expr): stmt = video[y * pitch + x] = int32(col) -template getPix(video, pitch, x, y: expr): expr = +template getPix(video, pitch, x, y: expr): expr = colors.Color(video[y * pitch + x]) const @@ -120,7 +120,7 @@ const proc getPixel(sur: PSurface, x, y: Natural): colors.Color {.inline.} = assert x <% sur.w assert y <% sur.h - result = getPix(cast[PPixels](sur.s.pixels), sur.s.pitch.int div ColSize, + result = getPix(cast[PPixels](sur.s.pixels), sur.s.pitch.int div ColSize, x, y) proc setPixel(sur: PSurface, x, y: Natural, col: colors.Color) {.inline.} = @@ -146,7 +146,7 @@ proc `[]=`*(sur: PSurface, x, y: int, col: Color) = ## set the pixel at position ``(x, y)``. No range checking is done! setPixel(sur, x, y, col) -proc blit*(destSurf: PSurface, destRect: Rect, srcSurf: PSurface, +proc blit*(destSurf: PSurface, destRect: Rect, srcSurf: PSurface, srcRect: Rect) = ## Copies ``srcSurf`` into ``destSurf`` var destTRect, srcTRect: sdl.Rect @@ -175,7 +175,7 @@ proc drawText*(sur: PSurface, p: Point, text: string, font = defaultFont) = ## font. var textSur: PSurface # This surface will have the text drawn on it new(textSur, surfaceFinalizer) - + # Render the text textSur.s = sdl_ttf.renderTextBlended(font.f, text, font.color) # Merge the text surface with sur @@ -183,14 +183,14 @@ proc drawText*(sur: PSurface, p: Point, text: string, font = defaultFont) = proc drawText*(sur: PSurface, p: Point, text: string, bg: Color, font = defaultFont) = - ## Draws text, at location ``p`` with font ``font``. ``bg`` + ## Draws text, at location ``p`` with font ``font``. ``bg`` ## is the background color. var textSur: PSurface # This surface will have the text drawn on it new(textSur, surfaceFinalizer) textSur.s = sdl_ttf.renderTextShaded(font.f, text, font.color, toSdlColor(bg)) # Merge the text surface with sur sur.blit((p.x, p.y, sur.w, sur.h), textSur, (0, 0, sur.w, sur.h)) - + proc drawCircle*(sur: PSurface, p: Point, r: Natural, color: Color) = ## draws a circle with center `p` and radius `r` with the given color ## onto the surface `sur`. @@ -205,7 +205,7 @@ proc drawCircle*(sur: PSurface, p: Point, r: Natural, color: Color) = if x+px <% sur.w: if y+py <% sur.h: setPix(video, pitch, x+px, y+py, color) if y-py <% sur.h: setPix(video, pitch, x+px, y-py, color) - + if x-px <% sur.w: if y+py <% sur.h: setPix(video, pitch, x-px, y+py, color) if y-py <% sur.h: setPix(video, pitch, x-px, y-py, color) @@ -213,7 +213,7 @@ proc drawCircle*(sur: PSurface, p: Point, r: Natural, color: Color) = if x+py <% sur.w: if y+px <% sur.h: setPix(video, pitch, x+py, y+px, color) if y-px <% sur.h: setPix(video, pitch, x+py, y-px, color) - + if x-py <% sur.w: if y+px <% sur.h: setPix(video, pitch, x-py, y+px, color) if y-px <% sur.h: setPix(video, pitch, x-py, y-px, color) @@ -225,10 +225,10 @@ proc drawCircle*(sur: PSurface, p: Point, r: Natural, color: Color) = py = py - 1 px = px + 1 -proc `>-<`(val: int, s: PSurface): int {.inline.} = +proc `>-<`(val: int, s: PSurface): int {.inline.} = return if val < 0: 0 elif val >= s.w: s.w-1 else: val -proc `>|<`(val: int, s: PSurface): int {.inline.} = +proc `>|<`(val: int, s: PSurface): int {.inline.} = return if val < 0: 0 elif val >= s.h: s.h-1 else: val proc drawLine*(sur: PSurface, p1, p2: Point, color: Color) = @@ -242,7 +242,7 @@ proc drawLine*(sur: PSurface, p1, p2: Point, color: Color) = var dy = y1 - y0 var dx = x1 - x0 if dy < 0: - dy = -dy + dy = -dy stepy = -1 else: stepy = 1 @@ -251,7 +251,7 @@ proc drawLine*(sur: PSurface, p1, p2: Point, color: Color) = stepx = -1 else: stepx = 1 - dy = dy * 2 + dy = dy * 2 dx = dx * 2 var video = cast[PPixels](sur.s.pixels) var pitch = sur.s.pitch.int div ColSize @@ -328,17 +328,17 @@ proc drawRect*(sur: PSurface, r: Rect, color: Color) = if (r.x >= 0 and r.x <= sur.s.w) and (r.y >= 0 and r.y <= sur.s.h): var minW = min(sur.s.w - r.x, r.width) var minH = min(sur.s.h - r.y, r.height) - + # Draw Top for i in 0 .. minW - 1: setPix(video, pitch, r.x + i, r.y, color) setPix(video, pitch, r.x + i, r.y + minH - 1, color) # Draw bottom - + # Draw left side for i in 0 .. minH - 1: setPix(video, pitch, r.x, r.y + i, color) setPix(video, pitch, r.x + minW - 1, r.y + i, color) # Draw right side - + proc fillRect*(sur: PSurface, r: Rect, col: Color) = ## Fills a rectangle using sdl's ``FillRect`` function. var rect = toSdlRect(r) @@ -350,23 +350,23 @@ proc plot4EllipsePoints(sur: PSurface, cx, cy, x, y: Natural, col: Color) = var pitch = sur.s.pitch.int div ColSize if cx+x <= sur.s.w-1: if cy+y <= sur.s.h-1: setPix(video, pitch, cx+x, cy+y, col) - if cy-y <= sur.s.h-1: setPix(video, pitch, cx+x, cy-y, col) + if cy-y <= sur.s.h-1: setPix(video, pitch, cx+x, cy-y, col) if cx-x <= sur.s.w-1: if cy+y <= sur.s.h-1: setPix(video, pitch, cx-x, cy+y, col) if cy-y <= sur.s.h-1: setPix(video, pitch, cx-x, cy-y, col) -proc drawEllipse*(sur: PSurface, cx, cy, xRadius, yRadius: Natural, +proc drawEllipse*(sur: PSurface, cx, cy, xRadius, yRadius: Natural, col: Color) = - ## Draws an ellipse, ``CX`` and ``CY`` specify the center X and Y of the + ## Draws an ellipse, ``CX`` and ``CY`` specify the center X and Y of the ## ellipse, ``XRadius`` and ``YRadius`` specify half the width and height ## of the ellipse. - var + var x, y: Natural xChange, yChange: int ellipseError: Natural twoASquare, twoBSquare: Natural stoppingX, stoppingY: Natural - + twoASquare = 2 * xRadius * xRadius twoBSquare = 2 * yRadius * yRadius x = xRadius @@ -376,7 +376,7 @@ proc drawEllipse*(sur: PSurface, cx, cy, xRadius, yRadius: Natural, ellipseError = 0 stoppingX = twoBSquare * xRadius stoppingY = 0 - + while stoppingX >= stoppingY: # 1st set of points, y` > - 1 sur.plot4EllipsePoints(cx, cy, x, y, col) inc(y) @@ -388,7 +388,7 @@ proc drawEllipse*(sur: PSurface, cx, cy, xRadius, yRadius: Natural, dec(stoppingX, twoBSquare) inc(ellipseError, xChange) inc(xChange, twoBSquare) - + # 1st point set is done; start the 2nd set of points x = 0 y = yRadius @@ -408,7 +408,7 @@ proc drawEllipse*(sur: PSurface, cx, cy, xRadius, yRadius: Natural, dec(stoppingY, twoASquare) inc(ellipseError, yChange) inc(yChange,twoASquare) - + proc plotAA(sur: PSurface, x, y: int, c: float, color: Color) = if (x > 0 and x < sur.s.w) and (y > 0 and y < sur.s.h): @@ -419,43 +419,43 @@ proc plotAA(sur: PSurface, x, y: int, c: float, color: Color) = setPix(video, pitch, x, y, pixColor.intensity(1.0 - c) + color.intensity(c)) - -template ipart(x: expr): expr = floor(x) + +template ipart(x: expr): expr = floor(x) template cround(x: expr): expr = ipart(x + 0.5) template fpart(x: expr): expr = x - ipart(x) template rfpart(x: expr): expr = 1.0 - fpart(x) proc drawLineAA*(sur: PSurface, p1, p2: Point, color: Color) = - ## Draws a anti-aliased line from ``p1`` to ``p2``, using Xiaolin Wu's + ## Draws a anti-aliased line from ``p1`` to ``p2``, using Xiaolin Wu's ## line algorithm - var (x1, x2, y1, y2) = (p1.x.toFloat(), p2.x.toFloat(), + var (x1, x2, y1, y2) = (p1.x.toFloat(), p2.x.toFloat(), p1.y.toFloat(), p2.y.toFloat()) var dx = x2 - x1 var dy = y2 - y1 - + var ax = dx if ax < 0'f64: ax = 0'f64 - ax var ay = dy if ay < 0'f64: ay = 0'f64 - ay - + if ax < ay: swap(x1, y1) swap(x2, y2) swap(dx, dy) - + template doPlot(x, y: int, c: float, color: Color): stmt = if ax < ay: sur.plotAA(y, x, c, color) else: sur.plotAA(x, y, c, color) - + if x2 < x1: swap(x1, x2) swap(y1, y2) - + var gradient = dy / dx # handle first endpoint var xend = cround(x1) @@ -509,19 +509,19 @@ when not defined(testing) and isMainModule: # Draw the shapes surf.drawLineAA((150, 170), (400, 471), colTan) surf.drawLine((100, 170), (400, 471), colRed) - + surf.drawEllipse(200, 300, 200, 30, colSeaGreen) - surf.drawHorLine(1, 300, 400, colViolet) + surf.drawHorLine(1, 300, 400, colViolet) # Check if the ellipse is the size it's suppose to be. surf.drawVerLine(200, 300 - 30 + 1, 60, colViolet) # ^^ | i suppose it is - + surf.drawEllipse(400, 300, 300, 300, colOrange) surf.drawEllipse(5, 5, 5, 5, colGreen) - + surf.drawHorLine(5, 5, 900, colRed) surf.drawVerLine(5, 60, 800, colRed) surf.drawCircle((600, 500), 60, colRed) - + surf.fillRect((50, 50, 100, 100), colFuchsia) surf.fillRect((150, 50, 100, 100), colGreen) surf.drawRect((50, 150, 100, 100), colGreen) @@ -530,12 +530,12 @@ when not defined(testing) and isMainModule: surf.drawHorLine(250, 150, 100, colRed) surf.drawLineAA((592, 160), (592, 280), colPurple) - + #surf.drawText((300, 300), "TEST", colMidnightBlue) #var textSize = textBounds("TEST") #surf.drawText((300, 300 + textSize.height), $textSize.width & ", " & # $textSize.height, colDarkGreen) - + var mouseStartX = -1 var mouseStartY = -1 withEvents(surf, event): @@ -561,17 +561,17 @@ when not defined(testing) and isMainModule: surf.drawLineAA((mouseStartX, mouseStartY), (int(mbd.x), int(mbd.y)), colPurple) mouseStartX = -1 mouseStartY = -1 - + of sdl.MOUSEMOTION: var mm = sdl.evMouseMotion(eventp) if mouseStartX != -1 and mouseStartY != -1: surf.drawLineAA((mouseStartX, mouseStartY), (int(mm.x), int(mm.y)), colPurple) #echo(mm.x, " ", mm.y, " ", mm.yrel) - + else: discard "echo(event.kind)" - + sdl.updateRect(surf.s, 0, 0, 800, 600) - + surf.writeToBMP("test.bmp") sdl.quit() diff --git a/lib/impure/re.nim b/lib/impure/re.nim index 0df8d4a9cf..30081bb192 100644 --- a/lib/impure/re.nim +++ b/lib/impure/re.nim @@ -41,11 +41,11 @@ type reExtended = 3, ## ignore whitespace and ``#`` comments reStudy = 4 ## study the expression (may be omitted if the ## expression will be used only once) - - RegexDesc = object + + RegexDesc = object h: ptr Pcre e: ptr ExtraData - + Regex* {.deprecated.} = ref RegexDesc ## a compiled regular expression RegexError* = object of ValueError diff --git a/lib/impure/ssl.nim b/lib/impure/ssl.nim index 079a2c3a25..721e5ce51c 100644 --- a/lib/impure/ssl.nim +++ b/lib/impure/ssl.nim @@ -7,7 +7,7 @@ # distribution, for details about the copyright. # -## This module provides an easy to use sockets-style +## This module provides an easy to use sockets-style ## nim interface to the OpenSSL library. {.deprecated.} @@ -20,37 +20,37 @@ type bio: BIO {.deprecated: [TSecureSocket: SecureSocket].} -proc connect*(sock: var SecureSocket, address: string, +proc connect*(sock: var SecureSocket, address: string, port: int): int = ## Connects to the specified `address` on the specified `port`. ## Returns the result of the certificate validation. SslLoadErrorStrings() ERR_load_BIO_strings() - + if SSL_library_init() != 1: raiseOSError(osLastError()) - + var ctx = SSL_CTX_new(SSLv23_client_method()) if ctx == nil: ERR_print_errors_fp(stderr) raiseOSError(osLastError()) - - #if SSL_CTX_load_verify_locations(ctx, + + #if SSL_CTX_load_verify_locations(ctx, # "/tmp/openssl-0.9.8e/certs/vsign1.pem", NIL) == 0: # echo("Failed load verify locations") # ERR_print_errors_fp(stderr) - + sock.bio = BIO_new_ssl_connect(ctx) if BIO_get_ssl(sock.bio, addr(sock.ssl)) == 0: raiseOSError(osLastError()) if BIO_set_conn_hostname(sock.bio, address & ":" & $port) != 1: raiseOSError(osLastError()) - + if BIO_do_connect(sock.bio) <= 0: ERR_print_errors_fp(stderr) raiseOSError(osLastError()) - + result = SSL_get_verify_result(sock.ssl) proc recvLine*(sock: SecureSocket, line: var TaintedString): bool = @@ -86,12 +86,12 @@ proc close*(sock: SecureSocket) = when not defined(testing) and isMainModule: var s: SecureSocket echo connect(s, "smtp.gmail.com", 465) - + #var buffer: array[0..255, char] #echo BIO_read(bio, buffer, buffer.len) var buffer: string = "" - + echo s.recvLine(buffer) - echo buffer + echo buffer echo buffer.len - + diff --git a/lib/nimrtl.nim b/lib/nimrtl.nim index 96dab12841..4e4cf7e0e4 100644 --- a/lib/nimrtl.nim +++ b/lib/nimrtl.nim @@ -7,8 +7,8 @@ # distribution, for details about the copyright. # -## Main file to generate a DLL from the standard library. -## The default Nimrtl does not only contain the ``system`` module, but these +## Main file to generate a DLL from the standard library. +## The default Nimrtl does not only contain the ``system`` module, but these ## too: ## ## * parseutils @@ -22,12 +22,12 @@ ## * unicode ## * pegs ## * ropes -## +## when system.appType != "lib": {.error: "This file has to be compiled as a library!".} -when not defined(createNimRtl): +when not defined(createNimRtl): {.error: "This file has to be compiled with '-d:createNimRtl'".} import diff --git a/lib/posix/epoll.nim b/lib/posix/epoll.nim index bc84611a60..276dd812db 100644 --- a/lib/posix/epoll.nim +++ b/lib/posix/epoll.nim @@ -29,34 +29,34 @@ const # Valid opcodes ( "op" parameter ) to issue to epoll_ctl(). -const - EPOLL_CTL_ADD* = 1 # Add a file descriptor to the interface. - EPOLL_CTL_DEL* = 2 # Remove a file descriptor from the interface. - EPOLL_CTL_MOD* = 3 # Change file descriptor epoll_event structure. +const + EPOLL_CTL_ADD* = 1 # Add a file descriptor to the interface. + EPOLL_CTL_DEL* = 2 # Remove a file descriptor from the interface. + EPOLL_CTL_MOD* = 3 # Change file descriptor epoll_event structure. -type - epoll_data* {.importc: "union epoll_data", +type + epoll_data* {.importc: "union epoll_data", header: "", pure, final.} = object # TODO: This is actually a union. #thePtr* {.importc: "ptr".}: pointer fd* {.importc: "fd".}: cint # \ #u32*: uint32 #u64*: uint64 - epoll_event* {.importc: "struct epoll_event", header: "", pure, final.} = object - events*: uint32 # Epoll events - data*: epoll_data # User data variable + epoll_event* {.importc: "struct epoll_event", header: "", pure, final.} = object + events*: uint32 # Epoll events + data*: epoll_data # User data variable -proc epoll_create*(size: cint): cint {.importc: "epoll_create", +proc epoll_create*(size: cint): cint {.importc: "epoll_create", header: "".} ## Creates an epoll instance. Returns an fd for the new instance. ## The "size" parameter is a hint specifying the number of file ## descriptors to be associated with the new instance. The fd - ## returned by epoll_create() should be closed with close(). + ## returned by epoll_create() should be closed with close(). -proc epoll_create1*(flags: cint): cint {.importc: "epoll_create1", +proc epoll_create1*(flags: cint): cint {.importc: "epoll_create1", header: "".} ## Same as epoll_create but with an FLAGS parameter. The unused SIZE - ## parameter has been dropped. + ## parameter has been dropped. proc epoll_ctl*(epfd: cint; op: cint; fd: cint | SocketHandle; event: ptr epoll_event): cint {. importc: "epoll_ctl", header: "".} @@ -65,10 +65,10 @@ proc epoll_ctl*(epfd: cint; op: cint; fd: cint | SocketHandle; event: ptr epoll_ ## specific error code ) The "op" parameter is one of the EPOLL_CTL_* ## constants defined above. The "fd" parameter is the target of the ## operation. The "event" parameter describes which events the caller - ## is interested in and any associated user data. + ## is interested in and any associated user data. -proc epoll_wait*(epfd: cint; events: ptr epoll_event; maxevents: cint; - timeout: cint): cint {.importc: "epoll_wait", +proc epoll_wait*(epfd: cint; events: ptr epoll_event; maxevents: cint; + timeout: cint): cint {.importc: "epoll_wait", header: "".} ## Wait for events on an epoll instance "epfd". Returns the number of ## triggered events returned in "events" buffer. Or -1 in case of @@ -82,11 +82,11 @@ proc epoll_wait*(epfd: cint; events: ptr epoll_event; maxevents: cint; ## __THROW. -#proc epoll_pwait*(epfd: cint; events: ptr epoll_event; maxevents: cint; +#proc epoll_pwait*(epfd: cint; events: ptr epoll_event; maxevents: cint; # timeout: cint; ss: ptr sigset_t): cint {. # importc: "epoll_pwait", header: "".} # Same as epoll_wait, but the thread's signal mask is temporarily # and atomically replaced with the one provided as parameter. # # This function is a cancellation point and therefore not marked with -# __THROW. +# __THROW. diff --git a/lib/posix/inotify.nim b/lib/posix/inotify.nim index 14cac4d72c..a206f80671 100644 --- a/lib/posix/inotify.nim +++ b/lib/posix/inotify.nim @@ -9,65 +9,65 @@ {.deadCodeElim:on.} -# Get the platform-dependent flags. -# Structure describing an inotify event. -type - InotifyEvent*{.pure, final, importc: "struct inotify_event", - header: "".} = object - wd*{.importc: "wd".}: cint # Watch descriptor. - mask*{.importc: "mask".}: uint32 # Watch mask. - cookie*{.importc: "cookie".}: uint32 # Cookie to synchronize two events. - len*{.importc: "len".}: uint32 # Length (including NULs) of name. - name*{.importc: "name".}: char # Name. +# Get the platform-dependent flags. +# Structure describing an inotify event. +type + InotifyEvent*{.pure, final, importc: "struct inotify_event", + header: "".} = object + wd*{.importc: "wd".}: cint # Watch descriptor. + mask*{.importc: "mask".}: uint32 # Watch mask. + cookie*{.importc: "cookie".}: uint32 # Cookie to synchronize two events. + len*{.importc: "len".}: uint32 # Length (including NULs) of name. + name*{.importc: "name".}: char # Name. {.deprecated: [Tinotify_event: InotifyEvent].} -# Supported events suitable for MASK parameter of INOTIFY_ADD_WATCH. -const - IN_ACCESS* = 0x00000001 # File was accessed. - IN_MODIFY* = 0x00000002 # File was modified. - IN_ATTRIB* = 0x00000004 # Metadata changed. - IN_CLOSE_WRITE* = 0x00000008 # Writtable file was closed. - IN_CLOSE_NOWRITE* = 0x00000010 # Unwrittable file closed. - IN_CLOSE* = (IN_CLOSE_WRITE or IN_CLOSE_NOWRITE) # Close. - IN_OPEN* = 0x00000020 # File was opened. - IN_MOVED_FROM* = 0x00000040 # File was moved from X. - IN_MOVED_TO* = 0x00000080 # File was moved to Y. - IN_MOVE* = (IN_MOVED_FROM or IN_MOVED_TO) # Moves. - IN_CREATE* = 0x00000100 # Subfile was created. - IN_DELETE* = 0x00000200 # Subfile was deleted. - IN_DELETE_SELF* = 0x00000400 # Self was deleted. - IN_MOVE_SELF* = 0x00000800 # Self was moved. -# Events sent by the kernel. -const - IN_UNMOUNT* = 0x00002000 # Backing fs was unmounted. - IN_Q_OVERFLOW* = 0x00004000 # Event queued overflowed. - IN_IGNORED* = 0x00008000 # File was ignored. -# Special flags. -const +# Supported events suitable for MASK parameter of INOTIFY_ADD_WATCH. +const + IN_ACCESS* = 0x00000001 # File was accessed. + IN_MODIFY* = 0x00000002 # File was modified. + IN_ATTRIB* = 0x00000004 # Metadata changed. + IN_CLOSE_WRITE* = 0x00000008 # Writtable file was closed. + IN_CLOSE_NOWRITE* = 0x00000010 # Unwrittable file closed. + IN_CLOSE* = (IN_CLOSE_WRITE or IN_CLOSE_NOWRITE) # Close. + IN_OPEN* = 0x00000020 # File was opened. + IN_MOVED_FROM* = 0x00000040 # File was moved from X. + IN_MOVED_TO* = 0x00000080 # File was moved to Y. + IN_MOVE* = (IN_MOVED_FROM or IN_MOVED_TO) # Moves. + IN_CREATE* = 0x00000100 # Subfile was created. + IN_DELETE* = 0x00000200 # Subfile was deleted. + IN_DELETE_SELF* = 0x00000400 # Self was deleted. + IN_MOVE_SELF* = 0x00000800 # Self was moved. +# Events sent by the kernel. +const + IN_UNMOUNT* = 0x00002000 # Backing fs was unmounted. + IN_Q_OVERFLOW* = 0x00004000 # Event queued overflowed. + IN_IGNORED* = 0x00008000 # File was ignored. +# Special flags. +const IN_ONLYDIR* = 0x01000000 # Only watch the path if it is a - # directory. - IN_DONT_FOLLOW* = 0x02000000 # Do not follow a sym link. + # directory. + IN_DONT_FOLLOW* = 0x02000000 # Do not follow a sym link. IN_EXCL_UNLINK* = 0x04000000 # Exclude events on unlinked - # objects. + # objects. IN_MASK_ADD* = 0x20000000 # Add to the mask of an already - # existing watch. - IN_ISDIR* = 0x40000000 # Event occurred against dir. - IN_ONESHOT* = 0x80000000 # Only send event once. -# All events which a program can wait on. -const + # existing watch. + IN_ISDIR* = 0x40000000 # Event occurred against dir. + IN_ONESHOT* = 0x80000000 # Only send event once. +# All events which a program can wait on. +const IN_ALL_EVENTS* = (IN_ACCESS or IN_MODIFY or IN_ATTRIB or IN_CLOSE_WRITE or IN_CLOSE_NOWRITE or IN_OPEN or IN_MOVED_FROM or IN_MOVED_TO or IN_CREATE or IN_DELETE or IN_DELETE_SELF or IN_MOVE_SELF) # Create and initialize inotify instance. -proc inotify_init*(): cint{.cdecl, importc: "inotify_init", +proc inotify_init*(): cint{.cdecl, importc: "inotify_init", header: "".} -# Create and initialize inotify instance. -proc inotify_init1*(flags: cint): cint{.cdecl, importc: "inotify_init1", +# Create and initialize inotify instance. +proc inotify_init1*(flags: cint): cint{.cdecl, importc: "inotify_init1", header: "".} # Add watch of object NAME to inotify instance FD. Notify about -# events specified by MASK. +# events specified by MASK. proc inotify_add_watch*(fd: cint; name: cstring; mask: uint32): cint{. cdecl, importc: "inotify_add_watch", header: "".} -# Remove the watch specified by WD from the inotify instance FD. -proc inotify_rm_watch*(fd: cint; wd: cint): cint{.cdecl, +# Remove the watch specified by WD from the inotify instance FD. +proc inotify_rm_watch*(fd: cint; wd: cint): cint{.cdecl, importc: "inotify_rm_watch", header: "".} diff --git a/lib/posix/linux.nim b/lib/posix/linux.nim index 05eab52bc6..01d5e57de0 100644 --- a/lib/posix/linux.nim +++ b/lib/posix/linux.nim @@ -24,5 +24,5 @@ const # fn should be of type proc (a2: pointer): void {.cdecl.} proc clone*(fn: pointer; child_stack: pointer; flags: cint; - arg: pointer; ptid: ptr Pid; tls: pointer; + arg: pointer; ptid: ptr Pid; tls: pointer; ctid: ptr Pid): cint {.importc, header: "".} diff --git a/lib/pure/actors.nim b/lib/pure/actors.nim index da90372855..f0791f954f 100644 --- a/lib/pure/actors.nim +++ b/lib/pure/actors.nim @@ -41,7 +41,7 @@ type Actor[In, Out] = object{.pure, final.} i: Channel[Task[In, Out]] t: TThread[ptr Actor[In, Out]] - + PActor*[In, Out] = ptr Actor[In, Out] ## an actor {.deprecated: [TTask: Task, TActor: Actor].} @@ -83,7 +83,7 @@ proc send*[In, Out, X, Y](receiver: PActor[In, Out], msg: In, shallowCopy(t.data, msg) send(receiver.i, t) -proc send*[In, Out](receiver: PActor[In, Out], msg: In, +proc send*[In, Out](receiver: PActor[In, Out], msg: In, sender: ptr Channel[Out] = nil) = ## sends a message to `receiver`'s inbox. var t: Task[In, Out] @@ -138,7 +138,7 @@ proc createActorPool*[In, Out](a: var ActorPool[In, Out], poolSize = 4) = proc sync*[In, Out](a: var ActorPool[In, Out], polling=50) = ## waits for every actor of `a` to finish with its work. Currently this is - ## implemented as polling every `polling` ms and has a slight chance + ## implemented as polling every `polling` ms and has a slight chance ## of failing since we check for every actor to be in `ready` state and not ## for messages still in ether. This will change in a later ## version, however. @@ -146,7 +146,7 @@ proc sync*[In, Out](a: var ActorPool[In, Out], polling=50) = while true: var wait = false for i in 0..high(a.actors): - if not a.actors[i].i.ready: + if not a.actors[i].i.ready: wait = true allReadyCount = 0 break @@ -222,7 +222,7 @@ proc spawn*[In](p: var ActorPool[In, void], input: In, var t: Task[In, void] setupTask() schedule() - + when not defined(testing) and isMainModule: var a: ActorPool[int, void] diff --git a/lib/pure/asyncfile.nim b/lib/pure/asyncfile.nim index ece9b4dfbf..c7b9fac189 100644 --- a/lib/pure/asyncfile.nim +++ b/lib/pure/asyncfile.nim @@ -195,10 +195,10 @@ proc read*(f: AsyncFile, size: int): Future[string] = readBuffer.setLen(res) f.offset.inc(res) retFuture.complete(readBuffer) - + if not cb(f.fd): addRead(f.fd, cb) - + return retFuture proc readLine*(f: AsyncFile): Future[string] {.async.} = @@ -222,7 +222,7 @@ proc getFilePos*(f: AsyncFile): int64 = proc setFilePos*(f: AsyncFile, pos: int64) = ## Sets the position of the file pointer that is used for read/write - ## operations. The file's first byte has the index zero. + ## operations. The file's first byte has the index zero. f.offset = pos when not defined(windows) and not defined(nimdoc): let ret = lseek(f.fd.cint, pos, SEEK_SET) @@ -291,7 +291,7 @@ proc write*(f: AsyncFile, data: string): Future[void] = retFuture.complete() else: var written = 0 - + proc cb(fd: AsyncFD): bool = result = true let remainderSize = data.len-written @@ -309,7 +309,7 @@ proc write*(f: AsyncFile, data: string): Future[void] = result = false # We still have data to write. else: retFuture.complete() - + if not cb(f.fd): addWrite(f.fd, cb) return retFuture diff --git a/lib/pure/base64.nim b/lib/pure/base64.nim index 41d19dc0f3..deab39c7c6 100644 --- a/lib/pure/base64.nim +++ b/lib/pure/base64.nim @@ -9,11 +9,11 @@ ## This module implements a base64 encoder and decoder. -const +const cb64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" -template encodeInternal(s: expr, lineLen: int, newLine: string): stmt {.immediate.} = - ## encodes `s` into base64 representation. After `lineLen` characters, a +template encodeInternal(s: expr, lineLen: int, newLine: string): stmt {.immediate.} = + ## encodes `s` into base64 representation. After `lineLen` characters, a ## `newline` is added. var total = ((len(s) + 2) div 3) * 4 var numLines = (total + lineLen - 1) div lineLen @@ -29,13 +29,13 @@ template encodeInternal(s: expr, lineLen: int, newLine: string): stmt {.immediat var c = ord(s[i+2]) result[r] = cb64[a shr 2] result[r+1] = cb64[((a and 3) shl 4) or ((b and 0xF0) shr 4)] - result[r+2] = cb64[((b and 0x0F) shl 2) or ((c and 0xC0) shr 6)] - result[r+3] = cb64[c and 0x3F] + result[r+2] = cb64[((b and 0x0F) shl 2) or ((c and 0xC0) shr 6)] + result[r+3] = cb64[c and 0x3F] inc(r, 4) inc(i, 3) inc(currLine, 4) - if currLine >= lineLen and i != s.len-2: - for x in items(newLine): + if currLine >= lineLen and i != s.len-2: + for x in items(newLine): result[r] = x inc(r) currLine = 0 @@ -45,7 +45,7 @@ template encodeInternal(s: expr, lineLen: int, newLine: string): stmt {.immediat var b = ord(s[i+1]) result[r] = cb64[a shr 2] result[r+1] = cb64[((a and 3) shl 4) or ((b and 0xF0) shr 4)] - result[r+2] = cb64[((b and 0x0F) shl 2)] + result[r+2] = cb64[((b and 0x0F) shl 2)] result[r+3] = '=' if r+4 != result.len: setLen(result, r+4) @@ -61,17 +61,17 @@ template encodeInternal(s: expr, lineLen: int, newLine: string): stmt {.immediat #assert(r == result.len) discard -proc encode*[T:SomeInteger|char](s: openarray[T], lineLen = 75, newLine="\13\10"): string = - ## encodes `s` into base64 representation. After `lineLen` characters, a +proc encode*[T:SomeInteger|char](s: openarray[T], lineLen = 75, newLine="\13\10"): string = + ## encodes `s` into base64 representation. After `lineLen` characters, a ## `newline` is added. encodeInternal(s, lineLen, newLine) - -proc encode*(s: string, lineLen = 75, newLine="\13\10"): string = - ## encodes `s` into base64 representation. After `lineLen` characters, a + +proc encode*(s: string, lineLen = 75, newLine="\13\10"): string = + ## encodes `s` into base64 representation. After `lineLen` characters, a ## `newline` is added. encodeInternal(s, lineLen, newLine) - -proc decodeByte(b: char): int {.inline.} = + +proc decodeByte(b: char): int {.inline.} = case b of '+': result = ord('>') of '0'..'9': result = ord(b) + 4 @@ -79,7 +79,7 @@ proc decodeByte(b: char): int {.inline.} = of 'a'..'z': result = ord(b) - 71 else: result = 63 -proc decode*(s: string): string = +proc decode*(s: string): string = ## decodes a string in base64 representation back into its original form. ## Whitespace is skipped. const Whitespace = {' ', '\t', '\v', '\r', '\l', '\f'} @@ -96,7 +96,7 @@ proc decode*(s: string): string = var b = s[i+1].decodeByte var c = s[i+2].decodeByte var d = s[i+3].decodeByte - + result[r] = chr((a shl 2) and 0xff or ((b shr 4) and 0x03)) result[r+1] = chr((b shl 4) and 0xff or ((c shr 2) and 0x0F)) result[r+2] = chr((c shl 6) and 0xff or (d and 0x3F)) @@ -105,19 +105,19 @@ proc decode*(s: string): string = else: break assert i == s.len # adjust the length: - if i > 0 and s[i-1] == '=': + if i > 0 and s[i-1] == '=': dec(r) if i > 1 and s[i-2] == '=': dec(r) setLen(result, r) - + when isMainModule: assert encode("leasure.") == "bGVhc3VyZS4=" assert encode("easure.") == "ZWFzdXJlLg==" assert encode("asure.") == "YXN1cmUu" assert encode("sure.") == "c3VyZS4=" - + const longText = """Man is distinguished, not only by his reason, but by this - singular passion from other animals, which is a lust of the mind, + singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure.""" diff --git a/lib/pure/basic2d.nim b/lib/pure/basic2d.nim index 1392fdebae..ad8f8653dc 100644 --- a/lib/pure/basic2d.nim +++ b/lib/pure/basic2d.nim @@ -13,26 +13,26 @@ import strutils ## Basic 2d support with vectors, points, matrices and some basic utilities. ## Vectors are implemented as direction vectors, ie. when transformed with a matrix -## the translation part of matrix is ignored. +## the translation part of matrix is ignored. ## Operators `+` , `-` , `*` , `/` , `+=` , `-=` , `*=` and `/=` are implemented for vectors and scalars. ## ## Quick start example: -## +## ## # Create a matrix which first rotates, then scales and at last translates -## +## ## var m:Matrix2d=rotate(DEG90) & scale(2.0) & move(100.0,200.0) -## +## ## # Create a 2d point at (100,0) and a vector (5,2) -## -## var pt:Point2d=point2d(100.0,0.0) -## +## +## var pt:Point2d=point2d(100.0,0.0) +## ## var vec:Vector2d=vector2d(5.0,2.0) -## -## +## +## ## pt &= m # transforms pt in place -## +## ## var pt2:Point2d=pt & m #concatenates pt with m and returns a new point -## +## ## var vec2:Vector2d=vec & m #concatenates vec with m and returns a new vector @@ -64,12 +64,12 @@ type ## not used for geometric transformations in 2d. ax*,ay*,bx*,by*,tx*,ty*:float Point2d* = object - ## Implements a non-homogeneous 2d point stored as + ## Implements a non-homogeneous 2d point stored as ## an `x` coordinate and an `y` coordinate. x*,y*:float - Vector2d* = object - ## Implements a 2d **direction vector** stored as - ## an `x` coordinate and an `y` coordinate. Direction vector means, + Vector2d* = object + ## Implements a 2d **direction vector** stored as + ## an `x` coordinate and an `y` coordinate. Direction vector means, ## that when transforming a vector with a matrix, the translational ## part of the matrix is ignored. x*,y*:float @@ -78,7 +78,7 @@ type # Some forward declarations... proc matrix2d*(ax,ay,bx,by,tx,ty:float):Matrix2d {.noInit.} - ## Creates a new matrix. + ## Creates a new matrix. ## `ax`,`ay` is the local x axis ## `bx`,`by` is the local y axis ## `tx`,`ty` is the translation @@ -99,7 +99,7 @@ let YAXIS*:Vector2d=vector2d(0.0,1.0) ## Quick acces to an 2d y-axis unit vector - + # *************************************** # Private utils # *************************************** @@ -114,13 +114,13 @@ proc safeArccos(v:float):float= return arccos(clamp(v,-1.0,1.0)) -template makeBinOpVector(s:expr)= +template makeBinOpVector(s:expr)= ## implements binary operators + , - , * and / for vectors proc s*(a,b:Vector2d):Vector2d {.inline,noInit.} = vector2d(s(a.x,b.x),s(a.y,b.y)) proc s*(a:Vector2d,b:float):Vector2d {.inline,noInit.} = vector2d(s(a.x,b),s(a.y,b)) proc s*(a:float,b:Vector2d):Vector2d {.inline,noInit.} = vector2d(s(a,b.x),s(a,b.y)) - -template makeBinOpAssignVector(s:expr)= + +template makeBinOpAssignVector(s:expr)= ## implements inplace binary operators += , -= , /= and *= for vectors proc s*(a:var Vector2d,b:Vector2d) {.inline.} = s(a.x,b.x) ; s(a.y,b.y) proc s*(a:var Vector2d,b:float) {.inline.} = s(a.x,b) ; s(a.y,b) @@ -144,7 +144,7 @@ proc matrix2d*(ax,ay,bx,by,tx,ty:float):Matrix2d = proc `&`*(a,b:Matrix2d):Matrix2d {.noInit.} = #concatenate matrices ## Concatenates matrices returning a new matrix. - + # | a.AX a.AY 0 | | b.AX b.AY 0 | # | a.BX a.BY 0 | * | b.BX b.BY 0 | # | a.TX a.TY 1 | | b.TX b.TY 1 | @@ -153,7 +153,7 @@ proc `&`*(a,b:Matrix2d):Matrix2d {.noInit.} = #concatenate matrices a.ax * b.ay + a.ay * b.by, a.bx * b.ax + a.by * b.bx, a.bx * b.ay + a.by * b.by, - a.tx * b.ax + a.ty * b.bx + b.tx, + a.tx * b.ax + a.ty * b.bx + b.tx, a.tx * b.ay + a.ty * b.by + b.ty) @@ -169,13 +169,13 @@ proc stretch*(sx,sy:float):Matrix2d {.noInit.} = ## Returns new a stretch matrix, which is a ## scale matrix with non uniform scale in x and y. result.setElements(sx,0,0,sy,0,0) - + proc stretch*(sx,sy:float,org:Point2d):Matrix2d {.noInit.} = ## Returns a new stretch matrix, which is a ## scale matrix with non uniform scale in x and y. ## `org` is used as stretch origin. result.setElements(sx,0,0,sy,org.x-sx*org.x,org.y-sy*org.y) - + proc move*(dx,dy:float):Matrix2d {.noInit.} = ## Returns a new translation matrix. result.setElements(1,0,0,1,dx,dy) @@ -187,7 +187,7 @@ proc move*(v:Vector2d):Matrix2d {.noInit.} = proc rotate*(rad:float):Matrix2d {.noInit.} = ## Returns a new rotation matrix, which ## represents a rotation by `rad` radians - let + let s=sin(rad) c=cos(rad) result.setElements(c,s,-s,c,0,0) @@ -200,7 +200,7 @@ proc rotate*(rad:float,org:Point2d):Matrix2d {.noInit.} = s=sin(rad) c=cos(rad) result.setElements(c,s,-s,c,org.x+s*org.y-c*org.x,org.y-c*org.y-s*org.x) - + proc mirror*(v:Vector2d):Matrix2d {.noInit.} = ## Returns a new mirror matrix, mirroring ## around the line that passes through origo and @@ -211,7 +211,7 @@ proc mirror*(v:Vector2d):Matrix2d {.noInit.} = nd=1.0/(sqx+sqy) #used to normalize invector xy2=v.x*v.y*2.0*nd sqd=nd*(sqx-sqy) - + if nd==Inf or nd==NegInf: return IDMATRIX #mirroring around a zero vector is arbitrary=>just use identity @@ -230,7 +230,7 @@ proc mirror*(org:Point2d,v:Vector2d):Matrix2d {.noInit.} = nd=1.0/(sqx+sqy) #used to normalize invector xy2=v.x*v.y*2.0*nd sqd=nd*(sqx-sqy) - + if nd==Inf or nd==NegInf: return IDMATRIX #mirroring around a zero vector is arbitrary=>just use identity @@ -238,47 +238,47 @@ proc mirror*(org:Point2d,v:Vector2d):Matrix2d {.noInit.} = sqd,xy2, xy2,-sqd, org.x-org.y*xy2-org.x*sqd,org.y-org.x*xy2+org.y*sqd) - + proc skew*(xskew,yskew:float):Matrix2d {.noInit.} = - ## Returns a new skew matrix, which has its + ## Returns a new skew matrix, which has its ## x axis rotated `xskew` radians from the local x axis, and ## y axis rotated `yskew` radians from the local y axis result.setElements(cos(yskew),sin(yskew),-sin(xskew),cos(xskew),0,0) - + proc `$`* (t:Matrix2d):string {.noInit.} = ## Returns a string representation of the matrix return rtos(t.ax) & "," & rtos(t.ay) & - "," & rtos(t.bx) & "," & rtos(t.by) & + "," & rtos(t.bx) & "," & rtos(t.by) & "," & rtos(t.tx) & "," & rtos(t.ty) proc isUniform*(t:Matrix2d,tol=1.0e-6):bool= - ## Checks if the transform is uniform, that is + ## Checks if the transform is uniform, that is ## perpendicular axes of equal length, which means (for example) ## it cannot transform a circle into an ellipse. - ## `tol` is used as tolerance for both equal length comparison + ## `tol` is used as tolerance for both equal length comparison ## and perp. comparison. - + #dot product=0 means perpendicular coord. system: - if abs(t.ax*t.bx+t.ay*t.by)<=tol: + if abs(t.ax*t.bx+t.ay*t.by)<=tol: #subtract squared lengths of axes to check if uniform scaling: if abs((t.ax*t.ax+t.ay*t.ay)-(t.bx*t.bx+t.by*t.by))<=tol: return true return false - + proc determinant*(t:Matrix2d):float= ## Computes the determinant of the matrix. - + #NOTE: equivalent with perp.dot product for two 2d vectors - return t.ax*t.by-t.bx*t.ay + return t.ax*t.by-t.bx*t.ay proc isMirroring* (m:Matrix2d):bool= ## Checks if the `m` is a mirroring matrix, ## which means it will reverse direction of a curve transformed with it return m.determinant<0.0 - + proc inverse*(m:Matrix2d):Matrix2d {.noInit.} = ## Returns a new matrix, which is the inverse of the matrix ## If the matrix is not invertible (determinant=0), an EDivByZero @@ -286,7 +286,7 @@ proc inverse*(m:Matrix2d):Matrix2d {.noInit.} = let d=m.determinant if d==0.0: raise newException(DivByZeroError,"Cannot invert a zero determinant matrix") - + result.setElements( m.by/d,-m.ay/d, -m.bx/d,m.ax/d, @@ -296,14 +296,14 @@ proc inverse*(m:Matrix2d):Matrix2d {.noInit.} = proc equals*(m1:Matrix2d,m2:Matrix2d,tol=1.0e-6):bool= ## Checks if all elements of `m1`and `m2` is equal within ## a given tolerance `tol`. - return + return abs(m1.ax-m2.ax)<=tol and abs(m1.ay-m2.ay)<=tol and abs(m1.bx-m2.bx)<=tol and abs(m1.by-m2.by)<=tol and abs(m1.tx-m2.tx)<=tol and abs(m1.ty-m2.ty)<=tol - + proc `=~`*(m1,m2:Matrix2d):bool= ## Checks if `m1`and `m2` is approximately equal, using a ## tolerance of 1e-6. @@ -350,16 +350,16 @@ proc slopeVector2d*(slope:float,len:float):Vector2d {.noInit.} = proc len*(v:Vector2d):float {.inline.}= ## Returns the length of the vector. sqrt(v.x*v.x+v.y*v.y) - + proc `len=`*(v:var Vector2d,newlen:float) {.noInit.} = ## Sets the length of the vector, keeping its angle. let fac=newlen/v.len - + if newlen==0.0: v.x=0.0 v.y=0.0 return - + if fac==Inf or fac==NegInf: #to short for float accuracy #do as good as possible: @@ -368,30 +368,30 @@ proc `len=`*(v:var Vector2d,newlen:float) {.noInit.} = else: v.x*=fac v.y*=fac - + proc sqrLen*(v:Vector2d):float {.inline.}= ## Computes the squared length of the vector, which is ## faster than computing the absolute length. v.x*v.x+v.y*v.y - + proc angle*(v:Vector2d):float= - ## Returns the angle of the vector. + ## Returns the angle of the vector. ## (The counter clockwise plane angle between posetive x axis and `v`) result=arctan2(v.y,v.x) if result<0.0: result+=DEG360 - + proc `$` *(v:Vector2d):string= ## String representation of `v` result=rtos(v.x) result.add(",") result.add(rtos(v.y)) - - + + proc `&` *(v:Vector2d,m:Matrix2d):Vector2d {.noInit.} = ## Concatenate vector `v` with a transformation matrix. ## Transforming a vector ignores the translational part ## of the matrix. - + # | AX AY 0 | # | X Y 1 | * | BX BY 0 | # | 0 0 1 | @@ -403,7 +403,7 @@ proc `&=`*(v:var Vector2d,m:Matrix2d) {.inline.}= ## Applies transformation `m` onto `v` in place. ## Transforming a vector ignores the translational part ## of the matrix. - + # | AX AY 0 | # | X Y 1 | * | BX BY 0 | # | 0 0 1 | @@ -412,31 +412,31 @@ proc `&=`*(v:var Vector2d,m:Matrix2d) {.inline.}= v.x=newx -proc tryNormalize*(v:var Vector2d):bool= +proc tryNormalize*(v:var Vector2d):bool= ## Modifies `v` to have a length of 1.0, keeping its angle. - ## If `v` has zero length (and thus no angle), it is left unmodified and + ## If `v` has zero length (and thus no angle), it is left unmodified and ## false is returned, otherwise true is returned. let mag=v.len if mag==0.0: return false - + v.x/=mag v.y/=mag return true -proc normalize*(v:var Vector2d) {.inline.}= +proc normalize*(v:var Vector2d) {.inline.}= ## Modifies `v` to have a length of 1.0, keeping its angle. ## If `v` has zero length, an EDivByZero will be raised. if not tryNormalize(v): raise newException(DivByZeroError,"Cannot normalize zero length vector") - + proc transformNorm*(v:var Vector2d,t:Matrix2d)= ## Applies a normal direction transformation `t` onto `v` in place. - ## The resulting vector is *not* normalized. Transforming a vector ignores the - ## translational part of the matrix. If the matrix is not invertible + ## The resulting vector is *not* normalized. Transforming a vector ignores the + ## translational part of the matrix. If the matrix is not invertible ## (determinant=0), an EDivByZero will be raised. # transforming a normal is done by transforming @@ -469,16 +469,16 @@ proc transformInv*(v:var Vector2d,t:Matrix2d)= proc transformNormInv*(v:var Vector2d,t:Matrix2d)= ## Applies an inverse normal direction transformation `t` onto `v` in place. - ## This is faster than creating an inverse - ## matrix and transformNorm(...) it. Transforming a vector ignores the + ## This is faster than creating an inverse + ## matrix and transformNorm(...) it. Transforming a vector ignores the ## translational part of the matrix. # normal inverse transform is done by transforming # by the inverse of the transpose of the inverse of the org. matrix # which is equivalent with transforming with the transpose. # | | | AX AY 0 |^-1|^T|^-1 | AX BX 0 | - # | X Y 1 | * | | | BX BY 0 | | | = | X Y 1 | * | AY BY 0 | - # | | | 0 0 1 | | | | 0 0 1 | + # | X Y 1 | * | | | BX BY 0 | | | = | X Y 1 | * | AY BY 0 | + # | | | 0 0 1 | | | | 0 0 1 | # This can be heavily reduced to: let newx=t.ay*v.y+t.ax*v.x v.y=t.by*v.y+t.bx*v.x @@ -489,19 +489,19 @@ proc rotate90*(v:var Vector2d) {.inline.}= ## without using any trigonometrics. swap(v.x,v.y) v.x= -v.x - + proc rotate180*(v:var Vector2d){.inline.}= ## Quickly rotates vector `v` 180 degrees counter clockwise, ## without using any trigonometrics. v.x= -v.x v.y= -v.y - + proc rotate270*(v:var Vector2d) {.inline.}= ## Quickly rotates vector `v` 270 degrees counter clockwise, ## without using any trigonometrics. swap(v.x,v.y) v.y= -v.y - + proc rotate*(v:var Vector2d,rad:float) = ## Rotates vector `v` `rad` radians in place. let @@ -510,18 +510,18 @@ proc rotate*(v:var Vector2d,rad:float) = newx=c*v.x-s*v.y v.y=c*v.y+s*v.x v.x=newx - + proc scale*(v:var Vector2d,fac:float){.inline.}= ## Scales vector `v` `rad` radians in place. v.x*=fac v.y*=fac - + proc stretch*(v:var Vector2d,facx,facy:float){.inline.}= ## Stretches vector `v` `facx` times horizontally, ## and `facy` times vertically. v.x*=facx v.y*=facy - + proc mirror*(v:var Vector2d,mirrvec:Vector2d)= ## Mirrors vector `v` using `mirrvec` as mirror direction. let @@ -530,20 +530,20 @@ proc mirror*(v:var Vector2d,mirrvec:Vector2d)= nd=1.0/(sqx+sqy) #used to normalize invector xy2=mirrvec.x*mirrvec.y*2.0*nd sqd=nd*(sqx-sqy) - + if nd==Inf or nd==NegInf: return #mirroring around a zero vector is arbitrary=>keep as is is fastest - + let newx=xy2*v.y+sqd*v.x v.y=v.x*xy2-sqd*v.y v.x=newx - - + + proc `-` *(v:Vector2d):Vector2d= ## Negates a vector result.x= -v.x result.y= -v.y - + # declare templated binary operators makeBinOpVector(`+`) makeBinOpVector(`-`) @@ -556,27 +556,27 @@ makeBinOpAssignVector(`/=`) proc dot*(v1,v2:Vector2d):float= - ## Computes the dot product of two vectors. + ## Computes the dot product of two vectors. ## Returns 0.0 if the vectors are perpendicular. return v1.x*v2.x+v1.y*v2.y - + proc cross*(v1,v2:Vector2d):float= ## Computes the cross product of two vectors, also called ## the 'perpendicular dot product' in 2d. Returns 0.0 if the vectors ## are parallel. return v1.x*v2.y-v1.y*v2.x - + proc equals*(v1,v2:Vector2d,tol=1.0e-6):bool= ## Checks if two vectors approximately equals with a tolerance. return abs(v2.x-v1.x)<=tol and abs(v2.y-v1.y)<=tol - + proc `=~` *(v1,v2:Vector2d):bool= - ## Checks if two vectors approximately equals with a + ## Checks if two vectors approximately equals with a ## hardcoded tolerance 1e-6 equals(v1,v2) - + proc angleTo*(v1,v2:Vector2d):float= - ## Returns the smallest of the two possible angles + ## Returns the smallest of the two possible angles ## between `v1` and `v2` in radians. var nv1=v1 @@ -584,7 +584,7 @@ proc angleTo*(v1,v2:Vector2d):float= if not nv1.tryNormalize or not nv2.tryNormalize: return 0.0 # zero length vector has zero angle to any other vector return safeArccos(dot(nv1,nv2)) - + proc angleCCW*(v1,v2:Vector2d):float= ## Returns the counter clockwise plane angle from `v1` to `v2`, ## in range 0 - 2*PI @@ -592,7 +592,7 @@ proc angleCCW*(v1,v2:Vector2d):float= if v1.cross(v2)>=0.0: return a return DEG360-a - + proc angleCW*(v1,v2:Vector2d):float= ## Returns the clockwise plane angle from `v1` to `v2`, ## in range 0 - 2*PI @@ -612,32 +612,32 @@ proc turnAngle*(v1,v2:Vector2d):float= proc bisect*(v1,v2:Vector2d):Vector2d {.noInit.}= ## Computes the bisector between v1 and v2 as a normalized vector. ## If one of the input vectors has zero length, a normalized version - ## of the other is returned. If both input vectors has zero length, + ## of the other is returned. If both input vectors has zero length, ## an arbitrary normalized vector is returned. var vmag1=v1.len vmag2=v2.len - + # zero length vector equals arbitrary vector, just change to magnitude to one to # avoid zero division - if vmag1==0.0: + if vmag1==0.0: if vmag2==0: #both are zero length return any normalized vector return XAXIS vmag1=1.0 - if vmag2==0.0: vmag2=1.0 - + if vmag2==0.0: vmag2=1.0 + let x1=v1.x/vmag1 y1=v1.y/vmag1 x2=v2.x/vmag2 y2=v2.y/vmag2 - + result.x=(x1 + x2) * 0.5 result.y=(y1 + y2) * 0.5 - + if not result.tryNormalize(): # This can happen if vectors are colinear. In this special case - # there are actually two bisectors, we select just + # there are actually two bisectors, we select just # one of them (x1,y1 rotated 90 degrees ccw). result.x = -y1 result.y = x1 @@ -651,13 +651,13 @@ proc bisect*(v1,v2:Vector2d):Vector2d {.noInit.}= proc point2d*(x,y:float):Point2d = result.x=x result.y=y - + proc sqrDist*(a,b:Point2d):float= ## Computes the squared distance between `a` and `b` let dx=b.x-a.x let dy=b.y-a.y result=dx*dx+dy*dy - + proc dist*(a,b:Point2d):float {.inline.}= ## Computes the absolute distance between `a` and `b` result=sqrt(sqrDist(a,b)) @@ -675,11 +675,11 @@ proc `$` *(p:Point2d):string= result=rtos(p.x) result.add(",") result.add(rtos(p.y)) - + proc `&`*(p:Point2d,t:Matrix2d):Point2d {.noInit,inline.} = ## Concatenates a point `p` with a transform `t`, ## resulting in a new, transformed point. - + # | AX AY 0 | # | X Y 1 | * | BX BY 0 | # | TX TY 1 | @@ -697,21 +697,21 @@ proc transformInv*(p:var Point2d,t:Matrix2d){.inline.}= ## Applies the inverse of transformation `t` onto `p` in place. ## If the matrix is not invertable (determinant=0) , EDivByZero will ## be raised. - + # | AX AY 0 | ^-1 # | X Y 1 | * | BX BY 0 | # | TX TY 1 | let d=t.determinant if d==0.0: raise newException(DivByZeroError,"Cannot invert a zero determinant matrix") - let + let newx= (t.bx*t.ty-t.by*t.tx+p.x*t.by-p.y*t.bx)/d p.y = -(t.ax*t.ty-t.ay*t.tx+p.x*t.ay-p.y*t.ax)/d p.x=newx - - + + proc `+`*(p:Point2d,v:Vector2d):Point2d {.noInit,inline.} = - ## Adds a vector `v` to a point `p`, resulting + ## Adds a vector `v` to a point `p`, resulting ## in a new point. result.x=p.x+v.x result.y=p.y+v.y @@ -722,7 +722,7 @@ proc `+=`*(p:var Point2d,v:Vector2d) {.noInit,inline.} = p.y+=v.y proc `-`*(p:Point2d,v:Vector2d):Point2d {.noInit,inline.} = - ## Subtracts a vector `v` from a point `p`, resulting + ## Subtracts a vector `v` from a point `p`, resulting ## in a new point. result.x=p.x-v.x result.y=p.y-v.y @@ -736,13 +736,13 @@ proc `-=`*(p:var Point2d,v:Vector2d) {.noInit,inline.} = ## Subtracts a vector `v` from a point `p` in place. p.x-=v.x p.y-=v.y - + proc equals(p1,p2:Point2d,tol=1.0e-6):bool {.inline.}= ## Checks if two points approximately equals with a tolerance. return abs(p2.x-p1.x)<=tol and abs(p2.y-p1.y)<=tol proc `=~`*(p1,p2:Point2d):bool {.inline.}= - ## Checks if two vectors approximately equals with a + ## Checks if two vectors approximately equals with a ## hardcoded tolerance 1e-6 equals(p1,p2) @@ -759,7 +759,7 @@ proc rotate*(p:var Point2d,rad:float)= newx=p.x*c-p.y*s p.y=p.y*c+p.x*s p.x=newx - + proc rotate*(p:var Point2d,rad:float,org:Point2d)= ## Rotates a point in place `rad` radians using `org` as ## center of rotation. @@ -769,25 +769,25 @@ proc rotate*(p:var Point2d,rad:float,org:Point2d)= newx=(p.x - org.x) * c - (p.y - org.y) * s + org.x p.y=(p.y - org.y) * c + (p.x - org.x) * s + org.y p.x=newx - + proc scale*(p:var Point2d,fac:float) {.inline.}= ## Scales a point in place `fac` times with world origo as origin. p.x*=fac p.y*=fac - + proc scale*(p:var Point2d,fac:float,org:Point2d){.inline.}= ## Scales the point in place `fac` times with `org` as origin. p.x=(p.x - org.x) * fac + org.x p.y=(p.y - org.y) * fac + org.y proc stretch*(p:var Point2d,facx,facy:float){.inline.}= - ## Scales a point in place non uniformly `facx` and `facy` times with + ## Scales a point in place non uniformly `facx` and `facy` times with ## world origo as origin. p.x*=facx p.y*=facy proc stretch*(p:var Point2d,facx,facy:float,org:Point2d){.inline.}= - ## Scales the point in place non uniformly `facx` and `facy` times with + ## Scales the point in place non uniformly `facx` and `facy` times with ## `org` as origin. p.x=(p.x - org.x) * facx + org.x p.y=(p.y - org.y) * facy + org.y @@ -814,21 +814,21 @@ proc area*(a,b,c:Point2d):float= return abs(sgnArea(a,b,c)) proc closestPoint*(p:Point2d,pts:varargs[Point2d]):Point2d= - ## Returns a point selected from `pts`, that has the closest + ## Returns a point selected from `pts`, that has the closest ## euclidean distance to `p` assert(pts.len>0) # must have at least one point - - var + + var bestidx=0 bestdist=p.sqrDist(pts[0]) curdist:float - + for idx in 1..high(pts): curdist=p.sqrDist(pts[idx]) if curdist ", result) -# Pop the flags off returning a 4 byte aligned ptr to our Key or Val +# Pop the flags off returning a 4 byte aligned ptr to our Key or Val proc pop(x: int): int {.inline.} = result = x and 0xFFFFFFFC'i32 -# Pop the raw value off of our Key or Val +# Pop the raw value off of our Key or Val proc popRaw(x: int): int {.inline.} = - result = x shr 2 + result = x shr 2 -# Pop the flags off returning a 4 byte aligned ptr to our Key or Val +# Pop the flags off returning a 4 byte aligned ptr to our Key or Val proc popPtr[V](x: int): ptr V {.inline.} = result = cast[ptr V](pop(x)) #echo("popPtr " & $x & " -> " & $cast[int](result)) @@ -136,34 +136,34 @@ proc popPtr[V](x: int): ptr V {.inline.} = # K or V is no longer valid use new table const Ghost = 0xFFFFFFFC proc isGhost(x: int): bool {.inline.} = - result = x == 0xFFFFFFFC + result = x == 0xFFFFFFFC -# Tombstone -# applied to V = K is dead -proc isTomb(x: int): bool {.inline.} = +# Tombstone +# applied to V = K is dead +proc isTomb(x: int): bool {.inline.} = result = (x and 0x00000002) != 0 proc setTomb(x: int): int {.inline.} = result = x or 0x00000002 # Prime -# K or V is in new table copied from old -proc isPrime(x: int): bool {.inline.} = +# K or V is in new table copied from old +proc isPrime(x: int): bool {.inline.} = result = (x and 0x00000001) != 0 proc setPrime(x: int): int {.inline.} = result = x or 0x00000001 -#------------------------------------------------------------------------------ +#------------------------------------------------------------------------------ ##This is for i32 only need to override for i64 -proc hashInt(x: int):int {.inline.} = - var h = uint32(x) #shr 2'u32 +proc hashInt(x: int):int {.inline.} = + var h = uint32(x) #shr 2'u32 h = h xor (h shr 16'u32) h *= 0x85ebca6b'u32 h = h xor (h shr 13'u32) h *= 0xc2b2ae35'u32 - h = h xor (h shr 16'u32) + h = h xor (h shr 16'u32) result = int(h) #------------------------------------------------------------------------------ @@ -175,31 +175,31 @@ proc resize[K,V](self: PConcTable[K,V]): PConcTable[K,V] = #echo("A new table already exists, copy in progress") return next var - oldLen = atomic_load_n(self.len.addr, ATOMIC_RELAXED) + oldLen = atomic_load_n(self.len.addr, ATOMIC_RELAXED) newTable = newLFTable[K,V](oldLen*2) success = atomic_compare_exchange_n(self.next.addr, next.addr, newTable, false, ATOMIC_RELAXED, ATOMIC_RELAXED) if not success: echo("someone beat us to it! delete table we just created and return his " & $cast[int](next)) - deleteConcTable(newTable) - return next + deleteConcTable(newTable) + return next else: echo("Created New Table! " & $cast[int](newTable) & " Size = " & $newTable.len) return newTable - + #------------------------------------------------------------------------------ -#proc keyEQ[K](key1: ptr K, key2: ptr K): bool {.inline.} = -proc keyEQ[K](key1: int, key2: int): bool {.inline.} = +#proc keyEQ[K](key1: ptr K, key2: ptr K): bool {.inline.} = +proc keyEQ[K](key1: int, key2: int): bool {.inline.} = result = false when K is Raw: - if key1 == key2: + if key1 == key2: result = true else: - var + var p1 = popPtr[K](key1) p2 = popPtr[K](key2) - if p1 != nil and p2 != nil: + if p1 != nil and p2 != nil: if cast[int](p1) == cast[int](p2): return true if p1[] == p2[]: @@ -214,53 +214,53 @@ proc keyEQ[K](key1: int, key2: int): bool {.inline.} = proc copySlot[K,V](idx: int, oldTbl: var PConcTable[K,V], newTbl: var PConcTable[K,V]): bool = #echo("Copy idx " & $idx) - var + var oldVal = 0 - oldkey = 0 + oldkey = 0 ok = false result = false #Block the key so no other threads waste time here while not ok: - ok = atomic_compare_exchange_n(oldTbl[idx].key.addr, oldKey.addr, + ok = atomic_compare_exchange_n(oldTbl[idx].key.addr, oldKey.addr, setTomb(oldKey), false, ATOMIC_RELAXED, ATOMIC_RELAXED) - #echo("oldKey was = " & $oldKey & " set it to tomb " & $setTomb(oldKey)) - #Prevent new values from appearing in the old table by priming + #echo("oldKey was = " & $oldKey & " set it to tomb " & $setTomb(oldKey)) + #Prevent new values from appearing in the old table by priming oldVal = atomic_load_n(oldTbl[idx].value.addr, ATOMIC_RELAXED) while not isPrime(oldVal): - var box = if oldVal == 0 or isTomb(oldVal) : oldVal.setTomb.setPrime - else: oldVal.setPrime - if atomic_compare_exchange_n(oldTbl[idx].value.addr, oldVal.addr, + var box = if oldVal == 0 or isTomb(oldVal) : oldVal.setTomb.setPrime + else: oldVal.setPrime + if atomic_compare_exchange_n(oldTbl[idx].value.addr, oldVal.addr, box, false, ATOMIC_RELAXED, ATOMIC_RELAXED): - if isPrime(box) and isTomb(box): + if isPrime(box) and isTomb(box): return true oldVal = box break #echo("oldVal was = ", oldVal, " set it to prime ", box) - if isPrime(oldVal) and isTomb(oldVal): + if isPrime(oldVal) and isTomb(oldVal): #when not (K is Raw): - # deallocShared(popPtr[K](oldKey)) + # deallocShared(popPtr[K](oldKey)) return false - if isTomb(oldVal): + if isTomb(oldVal): echo("oldVal is Tomb!!!, should not happen") - if pop(oldVal) != 0: + if pop(oldVal) != 0: result = setVal(newTbl, pop(oldKey), pop(oldVal), 0, true) == 0 - if result: - #echo("Copied a Slot! idx= " & $idx & " key= " & $oldKey & " val= " & $oldVal) - else: - #echo("copy slot failed") + if result: + #echo("Copied a Slot! idx= " & $idx & " key= " & $oldKey & " val= " & $oldVal) + else: + #echo("copy slot failed") # Our copy is done so we disable the old slot while not ok: - ok = atomic_compare_exchange_n(oldTbl[idx].value.addr, oldVal.addr, + ok = atomic_compare_exchange_n(oldTbl[idx].value.addr, oldVal.addr, oldVal.setTomb.setPrime , false, ATOMIC_RELAXED, ATOMIC_RELAXED) - #echo("disabled old slot") - #echo"---------------------" + #echo("disabled old slot") + #echo"---------------------" #------------------------------------------------------------------------------ proc promote[K,V](table: var PConcTable[K,V]) = var newData = atomic_load_n(table.next.data.addr, ATOMIC_RELAXED) - newLen = atomic_load_n(table.next.len.addr, ATOMIC_RELAXED) + newLen = atomic_load_n(table.next.len.addr, ATOMIC_RELAXED) newUsed = atomic_load_n(table.next.used.addr, ATOMIC_RELAXED) deallocShared(table.data) @@ -270,52 +270,52 @@ proc promote[K,V](table: var PConcTable[K,V]) = atomic_store_n(table.copyIdx.addr, 0, ATOMIC_RELAXED) atomic_store_n(table.copyDone.addr, 0, ATOMIC_RELAXED) deallocShared(table.next) - atomic_store_n(table.next.addr, nil, ATOMIC_RELAXED) + atomic_store_n(table.next.addr, nil, ATOMIC_RELAXED) echo("new table swapped!") #------------------------------------------------------------------------------ - -proc checkAndPromote[K,V](table: var PConcTable[K,V], workDone: int): bool = - var + +proc checkAndPromote[K,V](table: var PConcTable[K,V], workDone: int): bool = + var oldLen = atomic_load_n(table.len.addr, ATOMIC_RELAXED) copyDone = atomic_load_n(table.copyDone.addr, ATOMIC_RELAXED) ok: bool - result = false + result = false if workDone > 0: #echo("len to copy =" & $oldLen) - #echo("copyDone + workDone = " & $copyDone & " + " & $workDone) + #echo("copyDone + workDone = " & $copyDone & " + " & $workDone) while not ok: - ok = atomic_compare_exchange_n(table.copyDone.addr, copyDone.addr, + ok = atomic_compare_exchange_n(table.copyDone.addr, copyDone.addr, copyDone + workDone, false, ATOMIC_RELAXED, ATOMIC_RELAXED) - #if ok: echo("set copyDone") - # If the copy is done we can promote this table + #if ok: echo("set copyDone") + # If the copy is done we can promote this table if copyDone + workDone >= oldLen: # Swap new data - #echo("work is done!") + #echo("work is done!") table.promote result = true - + #------------------------------------------------------------------------------ proc copySlotAndCheck[K,V](table: var PConcTable[K,V], idx: int): PConcTable[K,V] = var newTable = cast[PConcTable[K,V]](atomic_load_n(table.next.addr, ATOMIC_RELAXED)) - result = newTable - if newTable != nil and copySlot(idx, table, newTable): - #echo("copied a single slot, idx = " & $idx) + result = newTable + if newTable != nil and copySlot(idx, table, newTable): + #echo("copied a single slot, idx = " & $idx) if checkAndPromote(table, 1): return table - + #------------------------------------------------------------------------------ - + proc helpCopy[K,V](table: var PConcTable[K,V]): PConcTable[K,V] = var - newTable = cast[PConcTable[K,V]](atomic_load_n(table.next.addr, ATOMIC_RELAXED)) - result = newTable - if newTable != nil: - var - oldLen = atomic_load_n(table.len.addr, ATOMIC_RELAXED) + newTable = cast[PConcTable[K,V]](atomic_load_n(table.next.addr, ATOMIC_RELAXED)) + result = newTable + if newTable != nil: + var + oldLen = atomic_load_n(table.len.addr, ATOMIC_RELAXED) copyDone = atomic_load_n(table.copyDone.addr, ATOMIC_RELAXED) copyIdx = 0 work = min(oldLen, minCopyWork) @@ -324,54 +324,54 @@ proc helpCopy[K,V](table: var PConcTable[K,V]): PConcTable[K,V] = if copyDone < oldLen: var ok: bool while not ok: - ok = atomic_compare_exchange_n(table.copyIdx.addr, copyIdx.addr, + ok = atomic_compare_exchange_n(table.copyIdx.addr, copyIdx.addr, copyIdx + work, false, ATOMIC_RELAXED, ATOMIC_RELAXED) - #echo("copy idx = ", copyIdx) + #echo("copy idx = ", copyIdx) for i in 0..work-1: - var idx = (copyIdx + i) and (oldLen - 1) + var idx = (copyIdx + i) and (oldLen - 1) if copySlot(idx, table, newTable): workDone += 1 if workDone > 0: #echo("did work ", workDone, " on thread ", cast[int](myThreadID[pointer]())) if checkAndPromote(table, workDone): return table - # In case a thread finished all the work then got stalled before promotion + # In case a thread finished all the work then got stalled before promotion if checkAndPromote(table, 0): return table - - + + #------------------------------------------------------------------------------ proc setVal[K,V](table: var PConcTable[K,V], key: int, val: int, expVal: int, match: bool): int = - #echo("-try set- in table ", " key = ", (popPtr[K](key)[]), " val = ", val) - when K is Raw: - var idx = hashInt(key) + #echo("-try set- in table ", " key = ", (popPtr[K](key)[]), " val = ", val) + when K is Raw: + var idx = hashInt(key) else: - var idx = popPtr[K](key)[].hash - var - nextTable: PConcTable[K,V] + var idx = popPtr[K](key)[].hash + var + nextTable: PConcTable[K,V] probes = 1 - # spin until we find a key slot or build and jump to next table - while true: - idx = idx and (table.len - 1) + # spin until we find a key slot or build and jump to next table + while true: + idx = idx and (table.len - 1) #echo("try set idx = " & $idx & "for" & $key) var - probedKey = 0 - openKey = atomic_compare_exchange_n(table[idx].key.addr, probedKey.addr, - key, false, ATOMIC_RELAXED, ATOMIC_RELAXED) + probedKey = 0 + openKey = atomic_compare_exchange_n(table[idx].key.addr, probedKey.addr, + key, false, ATOMIC_RELAXED, ATOMIC_RELAXED) if openKey: if val.isTomb: #echo("val was tomb, bail, no reason to set an open slot to tomb") return val - #increment used slots - #echo("found an open slot, total used = " & + #increment used slots + #echo("found an open slot, total used = " & #$atomic_add_fetch(table.used.addr, 1, ATOMIC_RELAXED)) discard atomic_add_fetch(table.used.addr, 1, ATOMIC_RELAXED) - break # We found an open slot - #echo("set idx ", idx, " key = ", key, " probed = ", probedKey) + break # We found an open slot + #echo("set idx ", idx, " key = ", key, " probed = ", probedKey) if keyEQ[K](probedKey, key): - #echo("we found the matching slot") - break # We found a matching slot + #echo("we found the matching slot") + break # We found a matching slot if (not(expVal != 0 and match)) and (probes >= reProbeLimit or key.isTomb): if key.isTomb: echo("Key is Tombstone") #if probes >= reProbeLimit: echo("Too much probing " & $probes) @@ -379,22 +379,22 @@ proc setVal[K,V](table: var PConcTable[K,V], key: int, val: int, #create next bigger table nextTable = resize(table) #help do some copying - #echo("help copy old table to new") - nextTable = helpCopy(table) + #echo("help copy old table to new") + nextTable = helpCopy(table) #now setVal in the new table instead - #echo("jumping to next table to set val") - return setVal(nextTable, key, val, expVal, match) + #echo("jumping to next table to set val") + return setVal(nextTable, key, val, expVal, match) else: idx += 1 probes += 1 # Done spinning for a new slot - var oldVal = atomic_load_n(table[idx].value.addr, ATOMIC_RELAXED) + var oldVal = atomic_load_n(table[idx].value.addr, ATOMIC_RELAXED) if val == oldVal: - #echo("this val is alredy in the slot") + #echo("this val is alredy in the slot") return oldVal - nextTable = atomic_load_n(table.next.addr, ATOMIC_SEQ_CST) - if nextTable == nil and - ((oldVal == 0 and + nextTable = atomic_load_n(table.next.addr, ATOMIC_SEQ_CST) + if nextTable == nil and + ((oldVal == 0 and (probes >= reProbeLimit or table.used / table.len > 0.8)) or (isPrime(oldVal))): if table.used / table.len > 0.8: echo("resize because usage ratio = " & @@ -402,7 +402,7 @@ proc setVal[K,V](table: var PConcTable[K,V], key: int, val: int, if isPrime(oldVal): echo("old val isPrime, should be a rare mem ordering event") nextTable = resize(table) if nextTable != nil: - #echo("tomb old slot then set in new table") + #echo("tomb old slot then set in new table") nextTable = copySlotAndCheck(table,idx) return setVal(nextTable, key, val, expVal, match) # Finally ready to add new val to table @@ -410,7 +410,7 @@ proc setVal[K,V](table: var PConcTable[K,V], key: int, val: int, if match and oldVal != expVal: #echo("set failed, no match oldVal= " & $oldVal & " expVal= " & $expVal) return oldVal - if atomic_compare_exchange_n(table[idx].value.addr, oldVal.addr, + if atomic_compare_exchange_n(table[idx].value.addr, oldVal.addr, val, false, ATOMIC_RELEASE, ATOMIC_RELAXED): #echo("val set at table " & $cast[int](table)) if expVal != 0: @@ -427,48 +427,48 @@ proc setVal[K,V](table: var PConcTable[K,V], key: int, val: int, #------------------------------------------------------------------------------ -proc getVal[K,V](table: var PConcTable[K,V], key: int): int = +proc getVal[K,V](table: var PConcTable[K,V], key: int): int = #echo("-try get- key = " & $key) - when K is Raw: + when K is Raw: var idx = hashInt(key) else: - var idx = popPtr[K](key)[].hash - #echo("get idx ", idx) - var + var idx = popPtr[K](key)[].hash + #echo("get idx ", idx) + var probes = 0 - val: int + val: int while true: - idx = idx and (table.len - 1) - var + idx = idx and (table.len - 1) + var newTable: PConcTable[K,V] # = atomic_load_n(table.next.addr, ATOMIC_ACQUIRE) - probedKey = atomic_load_n(table[idx].key.addr, ATOMIC_SEQ_CST) + probedKey = atomic_load_n(table[idx].key.addr, ATOMIC_SEQ_CST) if keyEQ[K](probedKey, key): #echo("found key after ", probes+1) val = atomic_load_n(table[idx].value.addr, ATOMIC_ACQUIRE) if not isPrime(val): if isTomb(val): - #echo("val was tomb but not prime") + #echo("val was tomb but not prime") return 0 else: - #echo("-GotIt- idx = ", idx, " key = ", key, " val ", val ) + #echo("-GotIt- idx = ", idx, " key = ", key, " val ", val ) return val else: newTable = copySlotAndCheck(table, idx) - return getVal(newTable, key) + return getVal(newTable, key) else: - #echo("probe ", probes, " idx = ", idx, " key = ", key, " found ", probedKey ) + #echo("probe ", probes, " idx = ", idx, " key = ", key, " found ", probedKey ) if probes >= reProbeLimit*4 or key.isTomb: if newTable == nil: #echo("too many probes and no new table ", key, " ", idx ) return 0 - else: + else: newTable = helpCopy(table) return getVal(newTable, key) idx += 1 probes += 1 #------------------------------------------------------------------------------ - + #proc set*(table: var PConcTable[Raw,Raw], key: Raw, val: Raw) = # discard setVal(table, pack(key), pack(key), 0, false) @@ -476,33 +476,34 @@ proc getVal[K,V](table: var PConcTable[K,V], key: int): int = # discard setVal(table, pack(key), cast[int](val), 0, false) proc set*[K,V](table: var PConcTable[K,V], key: var K, val: var V) = - when not (K is Raw): + when not (K is Raw): var newKey = cast[int](copyShared(key)) - else: + else: var newKey = pack(key) - when not (V is Raw): + when not (V is Raw): var newVal = cast[int](copyShared(val)) - else: + else: var newVal = pack(val) var oldPtr = pop(setVal(table, newKey, newVal, 0, false)) #echo("oldPtr = ", cast[int](oldPtr), " newPtr = ", cast[int](newPtr)) - when not (V is Raw): - if newVal != oldPtr and oldPtr != 0: + when not (V is Raw): + if newVal != oldPtr and oldPtr != 0: deallocShared(cast[ptr V](oldPtr)) - - + + proc get*[K,V](table: var PConcTable[K,V], key: var K): V = when not (V is Raw): when not (K is Raw): return popPtr[V](getVal(table, cast[int](key.addr)))[] - else: + else: return popPtr[V](getVal(table, pack(key)))[] else: when not (K is Raw): return popRaw(getVal(table, cast[int](key.addr))) - else: - return popRaw(getVal(table, pack(key))) + else: + return popRaw(getVal(table, pack(key))) + @@ -512,7 +513,6 @@ proc get*[K,V](table: var PConcTable[K,V], key: var K): V = - #proc `[]`[K,V](table: var PConcTable[K,V], key: K): PEntry[K,V] {.inline.} = # getVal(table, key) @@ -528,16 +528,16 @@ proc get*[K,V](table: var PConcTable[K,V], key: var K): V = #Tests ---------------------------- when not defined(testing) and isMainModule: import locks, times, mersenne - - const + + const numTests = 100000 numThreads = 10 - + type TestObj = tuple - thr: int + thr: int f0: int f1: int @@ -545,63 +545,63 @@ when not defined(testing) and isMainModule: PDataArr = array[0..numTests-1, Data] Dict = PConcTable[string,TestObj] {.deprecated: [TTestObj: TestObj, TData: Data].} - - var + + var thr: array[0..numThreads-1, Thread[Dict]] - - table = newLFTable[string,TestObj](8) + + table = newLFTable[string,TestObj](8) rand = newMersenneTwister(2525) - proc createSampleData(len: int): PDataArr = - #result = cast[PDataArr](allocShared0(sizeof(Data)*numTests)) + proc createSampleData(len: int): PDataArr = + #result = cast[PDataArr](allocShared0(sizeof(Data)*numTests)) for i in 0..len-1: result[i].k = "mark" & $(i+1) - #echo("mark" & $(i+1), " ", hash("mark" & $(i+1))) + #echo("mark" & $(i+1), " ", hash("mark" & $(i+1))) result[i].v.thr = 0 - result[i].v.f0 = i+1 - result[i].v.f1 = 0 + result[i].v.f0 = i+1 + result[i].v.f1 = 0 #echo("key = " & $(i+1) & " Val ptr = " & $cast[int](result[i].v.addr)) - proc threadProc(tp: Dict) {.thread.} = - var t = cpuTime(); + proc threadProc(tp: Dict) {.thread.} = + var t = cpuTime(); for i in 1..numTests: var key = "mark" & $(i) - var got = table.get(key) + var got = table.get(key) got.thr = cast[int](myThreadID[pointer]()) - got.f1 = got.f1 + 1 + got.f1 = got.f1 + 1 table.set(key, got) t = cpuTime() - t - echo t - + echo t + var testData = createSampleData(numTests) for i in 0..numTests-1: table.set(testData[i].k, testData[i].v) - + var i = 0 while i < numThreads: createThread(thr[i], threadProc, table) i += 1 - joinThreads(thr) + joinThreads(thr) + - var fails = 0 - for i in 0..numTests-1: - var got = table.get(testData[i].k) + for i in 0..numTests-1: + var got = table.get(testData[i].k) if got.f0 != i+1 or got.f1 != numThreads: fails += 1 echo(got) echo("Failed read or write = ", fails) - + #for i in 1..numTests: # echo(i, " = ", hashInt(i) and 8191) diff --git a/lib/pure/collections/critbits.nim b/lib/pure/collections/critbits.nim index 7e3f238512..424bcdcca7 100644 --- a/lib/pure/collections/critbits.nim +++ b/lib/pure/collections/critbits.nim @@ -17,11 +17,11 @@ type otherbits: char case isLeaf: bool of false: child: array[0..1, ref NodeObj[T]] - of true: + of true: key: string when T isnot void: val: T - + Node[T] = ref NodeObj[T] CritBitTree*[T] = object ## The crit bit tree can either be used ## as a mapping from strings to @@ -66,7 +66,7 @@ proc rawInsert[T](c: var CritBitTree[T], key: string): Node[T] = let ch = if it.byte < key.len: key[it.byte] else: '\0' let dir = (1 + (ch.ord or it.otherBits.ord)) shr 8 it = it.child[dir] - + var newOtherBits = 0 var newByte = 0 block blockX: @@ -84,7 +84,7 @@ proc rawInsert[T](c: var CritBitTree[T], key: string): Node[T] = newOtherBits = newOtherBits xor 255 let ch = it.key[newByte] let dir = (1 + (ord(ch) or newOtherBits)) shr 8 - + var inner: Node[T] new inner new result @@ -93,7 +93,7 @@ proc rawInsert[T](c: var CritBitTree[T], key: string): Node[T] = inner.otherBits = chr(newOtherBits) inner.byte = newByte inner.child[1 - dir] = result - + var wherep = addr(c.root) while true: var p = wherep[] @@ -176,7 +176,7 @@ iterator leaves[T](n: Node[T]): Node[T] = # XXX actually we could compute the necessary stack size in advance: # it's roughly log2(c.count). var stack = @[n] - while stack.len > 0: + while stack.len > 0: var it = stack.pop while not it.isLeaf: stack.add(it.child[1]) @@ -205,7 +205,7 @@ iterator items*[T](c: CritBitTree[T]): string = iterator pairs*[T](c: CritBitTree[T]): tuple[key: string, val: T] = ## yields all (key, value)-pairs of `c`. for x in leaves(c.root): yield (x.key, x.val) - + iterator mpairs*[T](c: var CritBitTree[T]): tuple[key: string, val: var T] = ## yields all (key, value)-pairs of `c`. The yielded values can be modified. for x in leaves(c.root): yield (x.key, x.val) @@ -251,7 +251,7 @@ iterator pairsWithPrefix*[T](c: CritBitTree[T], ## yields all (key, value)-pairs of `c` starting with `prefix`. let top = allprefixedAux(c, prefix) for x in leaves(top): yield (x.key, x.val) - + iterator mpairsWithPrefix*[T](c: var CritBitTree[T], prefix: string): tuple[key: string, val: var T] = ## yields all (key, value)-pairs of `c` starting with `prefix`. diff --git a/lib/pure/collections/lists.nim b/lib/pure/collections/lists.nim index 535d5e21d6..f847ddd581 100644 --- a/lib/pure/collections/lists.nim +++ b/lib/pure/collections/lists.nim @@ -27,18 +27,18 @@ type SinglyLinkedList*[T] = object ## a singly linked list head*, tail*: SinglyLinkedNode[T] - + DoublyLinkedList*[T] = object ## a doubly linked list head*, tail*: DoublyLinkedNode[T] SinglyLinkedRing*[T] = object ## a singly linked ring head*, tail*: SinglyLinkedNode[T] - + DoublyLinkedRing*[T] = object ## a doubly linked ring head*: DoublyLinkedNode[T] {.deprecated: [TDoublyLinkedNode: DoublyLinkedNodeObj, - PDoublyLinkedNode: DoublyLinkedNode, + PDoublyLinkedNode: DoublyLinkedNode, TSinglyLinkedNode: SinglyLinkedNodeObj, PSinglyLinkedNode: SinglyLinkedNode, TDoublyLinkedList: DoublyLinkedList, @@ -106,19 +106,19 @@ template findImpl() {.dirty.} = for x in nodes(L): if x.value == value: return x -iterator items*[T](L: DoublyLinkedList[T]): T = +iterator items*[T](L: DoublyLinkedList[T]): T = ## yields every value of `L`. itemsListImpl() -iterator items*[T](L: SinglyLinkedList[T]): T = +iterator items*[T](L: SinglyLinkedList[T]): T = ## yields every value of `L`. itemsListImpl() -iterator items*[T](L: SinglyLinkedRing[T]): T = +iterator items*[T](L: SinglyLinkedRing[T]): T = ## yields every value of `L`. itemsRingImpl() -iterator items*[T](L: DoublyLinkedRing[T]): T = +iterator items*[T](L: DoublyLinkedRing[T]): T = ## yields every value of `L`. itemsRingImpl() @@ -138,22 +138,22 @@ iterator mitems*[T](L: var DoublyLinkedRing[T]): var T = ## yields every value of `L` so that you can modify it. itemsRingImpl() -iterator nodes*[T](L: SinglyLinkedList[T]): SinglyLinkedNode[T] = +iterator nodes*[T](L: SinglyLinkedList[T]): SinglyLinkedNode[T] = ## iterates over every node of `x`. Removing the current node from the ## list during traversal is supported. nodesListImpl() -iterator nodes*[T](L: DoublyLinkedList[T]): DoublyLinkedNode[T] = +iterator nodes*[T](L: DoublyLinkedList[T]): DoublyLinkedNode[T] = ## iterates over every node of `x`. Removing the current node from the ## list during traversal is supported. nodesListImpl() -iterator nodes*[T](L: SinglyLinkedRing[T]): SinglyLinkedNode[T] = +iterator nodes*[T](L: SinglyLinkedRing[T]): SinglyLinkedNode[T] = ## iterates over every node of `x`. Removing the current node from the ## list during traversal is supported. nodesRingImpl() -iterator nodes*[T](L: DoublyLinkedRing[T]): DoublyLinkedNode[T] = +iterator nodes*[T](L: DoublyLinkedRing[T]): DoublyLinkedNode[T] = ## iterates over every node of `x`. Removing the current node from the ## list during traversal is supported. nodesRingImpl() @@ -165,87 +165,87 @@ template dollarImpl() {.dirty.} = result.add($x.value) result.add("]") -proc `$`*[T](L: SinglyLinkedList[T]): string = +proc `$`*[T](L: SinglyLinkedList[T]): string = ## turns a list into its string representation. dollarImpl() -proc `$`*[T](L: DoublyLinkedList[T]): string = +proc `$`*[T](L: DoublyLinkedList[T]): string = ## turns a list into its string representation. dollarImpl() -proc `$`*[T](L: SinglyLinkedRing[T]): string = +proc `$`*[T](L: SinglyLinkedRing[T]): string = ## turns a list into its string representation. dollarImpl() -proc `$`*[T](L: DoublyLinkedRing[T]): string = +proc `$`*[T](L: DoublyLinkedRing[T]): string = ## turns a list into its string representation. dollarImpl() -proc find*[T](L: SinglyLinkedList[T], value: T): SinglyLinkedNode[T] = +proc find*[T](L: SinglyLinkedList[T], value: T): SinglyLinkedNode[T] = ## searches in the list for a value. Returns nil if the value does not ## exist. findImpl() -proc find*[T](L: DoublyLinkedList[T], value: T): DoublyLinkedNode[T] = +proc find*[T](L: DoublyLinkedList[T], value: T): DoublyLinkedNode[T] = ## searches in the list for a value. Returns nil if the value does not ## exist. findImpl() -proc find*[T](L: SinglyLinkedRing[T], value: T): SinglyLinkedNode[T] = +proc find*[T](L: SinglyLinkedRing[T], value: T): SinglyLinkedNode[T] = ## searches in the list for a value. Returns nil if the value does not ## exist. findImpl() -proc find*[T](L: DoublyLinkedRing[T], value: T): DoublyLinkedNode[T] = +proc find*[T](L: DoublyLinkedRing[T], value: T): DoublyLinkedNode[T] = ## searches in the list for a value. Returns nil if the value does not ## exist. findImpl() -proc contains*[T](L: SinglyLinkedList[T], value: T): bool {.inline.} = +proc contains*[T](L: SinglyLinkedList[T], value: T): bool {.inline.} = ## searches in the list for a value. Returns false if the value does not ## exist, true otherwise. result = find(L, value) != nil -proc contains*[T](L: DoublyLinkedList[T], value: T): bool {.inline.} = +proc contains*[T](L: DoublyLinkedList[T], value: T): bool {.inline.} = ## searches in the list for a value. Returns false if the value does not ## exist, true otherwise. result = find(L, value) != nil -proc contains*[T](L: SinglyLinkedRing[T], value: T): bool {.inline.} = +proc contains*[T](L: SinglyLinkedRing[T], value: T): bool {.inline.} = ## searches in the list for a value. Returns false if the value does not ## exist, true otherwise. result = find(L, value) != nil -proc contains*[T](L: DoublyLinkedRing[T], value: T): bool {.inline.} = +proc contains*[T](L: DoublyLinkedRing[T], value: T): bool {.inline.} = ## searches in the list for a value. Returns false if the value does not ## exist, true otherwise. result = find(L, value) != nil -proc prepend*[T](L: var SinglyLinkedList[T], - n: SinglyLinkedNode[T]) {.inline.} = +proc prepend*[T](L: var SinglyLinkedList[T], + n: SinglyLinkedNode[T]) {.inline.} = ## prepends a node to `L`. Efficiency: O(1). n.next = L.head L.head = n -proc prepend*[T](L: var SinglyLinkedList[T], value: T) {.inline.} = +proc prepend*[T](L: var SinglyLinkedList[T], value: T) {.inline.} = ## prepends a node to `L`. Efficiency: O(1). prepend(L, newSinglyLinkedNode(value)) - -proc append*[T](L: var DoublyLinkedList[T], n: DoublyLinkedNode[T]) = + +proc append*[T](L: var DoublyLinkedList[T], n: DoublyLinkedNode[T]) = ## appends a node `n` to `L`. Efficiency: O(1). n.next = nil n.prev = L.tail - if L.tail != nil: + if L.tail != nil: assert(L.tail.next == nil) L.tail.next = n L.tail = n if L.head == nil: L.head = n -proc append*[T](L: var DoublyLinkedList[T], value: T) = +proc append*[T](L: var DoublyLinkedList[T], value: T) = ## appends a value to `L`. Efficiency: O(1). append(L, newDoublyLinkedNode(value)) -proc prepend*[T](L: var DoublyLinkedList[T], n: DoublyLinkedNode[T]) = +proc prepend*[T](L: var DoublyLinkedList[T], n: DoublyLinkedNode[T]) = ## prepends a node `n` to `L`. Efficiency: O(1). n.prev = nil n.next = L.head @@ -255,11 +255,11 @@ proc prepend*[T](L: var DoublyLinkedList[T], n: DoublyLinkedNode[T]) = L.head = n if L.tail == nil: L.tail = n -proc prepend*[T](L: var DoublyLinkedList[T], value: T) = +proc prepend*[T](L: var DoublyLinkedList[T], value: T) = ## prepends a value to `L`. Efficiency: O(1). prepend(L, newDoublyLinkedNode(value)) - -proc remove*[T](L: var DoublyLinkedList[T], n: DoublyLinkedNode[T]) = + +proc remove*[T](L: var DoublyLinkedList[T], n: DoublyLinkedNode[T]) = ## removes `n` from `L`. Efficiency: O(1). if n == L.tail: L.tail = n.prev if n == L.head: L.head = n.next @@ -267,7 +267,7 @@ proc remove*[T](L: var DoublyLinkedList[T], n: DoublyLinkedNode[T]) = if n.prev != nil: n.prev.next = n.next -proc append*[T](L: var SinglyLinkedRing[T], n: SinglyLinkedNode[T]) = +proc append*[T](L: var SinglyLinkedRing[T], n: SinglyLinkedNode[T]) = ## appends a node `n` to `L`. Efficiency: O(1). if L.head != nil: n.next = L.head @@ -279,11 +279,11 @@ proc append*[T](L: var SinglyLinkedRing[T], n: SinglyLinkedNode[T]) = L.head = n L.tail = n -proc append*[T](L: var SinglyLinkedRing[T], value: T) = +proc append*[T](L: var SinglyLinkedRing[T], value: T) = ## appends a value to `L`. Efficiency: O(1). append(L, newSinglyLinkedNode(value)) -proc prepend*[T](L: var SinglyLinkedRing[T], n: SinglyLinkedNode[T]) = +proc prepend*[T](L: var SinglyLinkedRing[T], n: SinglyLinkedNode[T]) = ## prepends a node `n` to `L`. Efficiency: O(1). if L.head != nil: n.next = L.head @@ -294,11 +294,11 @@ proc prepend*[T](L: var SinglyLinkedRing[T], n: SinglyLinkedNode[T]) = L.tail = n L.head = n -proc prepend*[T](L: var SinglyLinkedRing[T], value: T) = +proc prepend*[T](L: var SinglyLinkedRing[T], value: T) = ## prepends a value to `L`. Efficiency: O(1). prepend(L, newSinglyLinkedNode(value)) -proc append*[T](L: var DoublyLinkedRing[T], n: DoublyLinkedNode[T]) = +proc append*[T](L: var DoublyLinkedRing[T], n: DoublyLinkedNode[T]) = ## appends a node `n` to `L`. Efficiency: O(1). if L.head != nil: n.next = L.head @@ -310,13 +310,13 @@ proc append*[T](L: var DoublyLinkedRing[T], n: DoublyLinkedNode[T]) = n.next = n L.head = n -proc append*[T](L: var DoublyLinkedRing[T], value: T) = +proc append*[T](L: var DoublyLinkedRing[T], value: T) = ## appends a value to `L`. Efficiency: O(1). append(L, newDoublyLinkedNode(value)) -proc prepend*[T](L: var DoublyLinkedRing[T], n: DoublyLinkedNode[T]) = +proc prepend*[T](L: var DoublyLinkedRing[T], n: DoublyLinkedNode[T]) = ## prepends a node `n` to `L`. Efficiency: O(1). - if L.head != nil: + if L.head != nil: n.next = L.head n.prev = L.head.prev L.head.prev.next = n @@ -326,17 +326,17 @@ proc prepend*[T](L: var DoublyLinkedRing[T], n: DoublyLinkedNode[T]) = n.next = n L.head = n -proc prepend*[T](L: var DoublyLinkedRing[T], value: T) = +proc prepend*[T](L: var DoublyLinkedRing[T], value: T) = ## prepends a value to `L`. Efficiency: O(1). prepend(L, newDoublyLinkedNode(value)) - -proc remove*[T](L: var DoublyLinkedRing[T], n: DoublyLinkedNode[T]) = + +proc remove*[T](L: var DoublyLinkedRing[T], n: DoublyLinkedNode[T]) = ## removes `n` from `L`. Efficiency: O(1). n.next.prev = n.prev n.prev.next = n.next - if n == L.head: + if n == L.head: var p = L.head.prev - if p == L.head: + if p == L.head: # only one element left: L.head = nil else: diff --git a/lib/pure/collections/queues.nim b/lib/pure/collections/queues.nim index af5e7b6cd7..c35a2dc295 100644 --- a/lib/pure/collections/queues.nim +++ b/lib/pure/collections/queues.nim @@ -77,7 +77,7 @@ proc dequeue*[T](q: var Queue[T]): T = result = q.data[q.rd] q.rd = (q.rd + 1) and q.mask -proc `$`*[T](q: Queue[T]): string = +proc `$`*[T](q: Queue[T]): string = ## turns a queue into its string representation. result = "[" for x in items(q): @@ -95,7 +95,7 @@ when isMainModule: q.add(6) var second = q.dequeue q.add(789) - + assert first == 123 assert second == 9 assert($q == "[4, 56, 6, 789]") diff --git a/lib/pure/colors.nim b/lib/pure/colors.nim index f24cc0072f..7328f7c248 100644 --- a/lib/pure/colors.nim +++ b/lib/pure/colors.nim @@ -6,7 +6,7 @@ # distribution, for details about the copyright. # -## This module implements color handling for Nimrod. It is used by +## This module implements color handling for Nimrod. It is used by ## the ``graphics`` module. import strutils @@ -18,15 +18,15 @@ type proc `==` *(a, b: Color): bool {.borrow.} ## compares two colors. - + template extract(a: Color, r, g, b: expr) {.immediate.}= var r = a.int shr 16 and 0xff var g = a.int shr 8 and 0xff var b = a.int and 0xff - + template rawRGB(r, g, b: int): expr = Color(r shl 16 or g shl 8 or b) - + template colorOp(op: expr) {.immediate.} = extract(a, ar, ag, ab) extract(b, br, bg, bb) @@ -39,24 +39,24 @@ proc satPlus(a, b: int): int {.inline.} = proc satMinus(a, b: int): int {.inline.} = result = a -% b if result < 0: result = 0 - + proc `+`*(a, b: Color): Color = ## adds two colors: This uses saturated artithmetic, so that each color ## component cannot overflow (255 is used as a maximum). colorOp(satPlus) - + proc `-`*(a, b: Color): Color = ## subtracts two colors: This uses saturated artithmetic, so that each color ## component cannot overflow (255 is used as a maximum). colorOp(satMinus) - + proc extractRGB*(a: Color): tuple[r, g, b: range[0..255]] = ## extracts the red/green/blue components of the color `a`. result.r = a.int shr 16 and 0xff result.g = a.int shr 8 and 0xff result.b = a.int and 0xff - -proc intensity*(a: Color, f: float): Color = + +proc intensity*(a: Color, f: float): Color = ## returns `a` with intensity `f`. `f` should be a float from 0.0 (completely ## dark) to 1.0 (full color intensity). var r = toInt(toFloat(a.int shr 16 and 0xff) * f) @@ -66,7 +66,7 @@ proc intensity*(a: Color, f: float): Color = if g >% 255: g = 255 if b >% 255: b = 255 result = rawRGB(r, g, b) - + template mix*(a, b: Color, fn: expr): expr = ## uses `fn` to mix the colors `a` and `b`. `fn` is invoked for each component ## R, G, and B. This is a template because `fn` should be inlined and the @@ -79,7 +79,7 @@ template mix*(a, b: Color, fn: expr): expr = if y >% 255: y = if y < 0: 0 else: 255 y - + (bind extract)(a, ar, ag, ab) (bind extract)(b, br, bg, bb) (bind rawRGB)(> 0: b = mid - 1 else: return mid result = - 1 - -proc parseColor*(name: string): Color = - ## parses `name` to a color value. If no valid color could be + +proc parseColor*(name: string): Color = + ## parses `name` to a color value. If no valid color could be ## parsed ``EInvalidValue`` is raised. if name[0] == '#': result = Color(parseHexInt(name)) @@ -396,10 +396,10 @@ proc parseColor*(name: string): Color = result = colorNames[idx][1] proc isColor*(name: string): bool = - ## returns true if `name` is a known color name or a hexadecimal color + ## returns true if `name` is a known color name or a hexadecimal color ## prefixed with ``#``. - if name[0] == '#': - for i in 1 .. name.len-1: + if name[0] == '#': + for i in 1 .. name.len-1: if name[i] notin {'0'..'9', 'a'..'f', 'A'..'F'}: return false result = true else: diff --git a/lib/pure/complex.nim b/lib/pure/complex.nim index 8577bf7a15..ccde5ee0a8 100644 --- a/lib/pure/complex.nim +++ b/lib/pure/complex.nim @@ -17,7 +17,7 @@ import math - + const EPS = 1.0e-7 ## Epsilon used for float comparisons. @@ -248,7 +248,7 @@ proc pow*(x, y: Complex): Complex = var r = y.re*theta + y.im*ln(rho) result.re = s*cos(r) result.im = s*sin(r) - + proc sin*(z: Complex): Complex = ## Returns the sine of `z`. @@ -387,7 +387,7 @@ when isMainModule: var one = (1.0,0.0) var tt = (10.0, 20.0) var ipi = (0.0, -PI) - + assert( a == a ) assert( (a-a) == z ) assert( (a+b) == z ) @@ -403,7 +403,7 @@ when isMainModule: assert( conjugate(a) == (1.0, -2.0) ) assert( sqrt(m1) == i ) assert( exp(ipi) =~ m1 ) - + assert( pow(a,b) =~ (-3.72999124927876, -1.68815826725068) ) assert( pow(z,a) =~ (0.0, 0.0) ) assert( pow(z,z) =~ (1.0, 0.0) ) diff --git a/lib/pure/concurrency/cpuinfo.nim b/lib/pure/concurrency/cpuinfo.nim index 6f2bc44910..8c87c77df5 100644 --- a/lib/pure/concurrency/cpuinfo.nim +++ b/lib/pure/concurrency/cpuinfo.nim @@ -18,7 +18,7 @@ when not defined(windows): when defined(linux): import linux - + when defined(freebsd) or defined(macosx): {.emit:"#include ".} diff --git a/lib/pure/cookies.nim b/lib/pure/cookies.nim index 9983c4a041..8090cd49df 100644 --- a/lib/pure/cookies.nim +++ b/lib/pure/cookies.nim @@ -11,7 +11,7 @@ import strtabs, times -proc parseCookies*(s: string): StringTableRef = +proc parseCookies*(s: string): StringTableRef = ## parses cookies into a string table. result = newStringTable(modeCaseInsensitive) var i = 0 @@ -31,7 +31,7 @@ proc parseCookies*(s: string): StringTableRef = proc setCookie*(key, value: string, domain = "", path = "", expires = "", noName = false, secure = false, httpOnly = false): string = - ## Creates a command in the format of + ## Creates a command in the format of ## ``Set-Cookie: key=value; Domain=...; ...`` result = "" if not noName: result.add("Set-Cookie: ") @@ -45,10 +45,10 @@ proc setCookie*(key, value: string, domain = "", path = "", proc setCookie*(key, value: string, expires: TimeInfo, domain = "", path = "", noName = false, secure = false, httpOnly = false): string = - ## Creates a command in the format of + ## Creates a command in the format of ## ``Set-Cookie: key=value; Domain=...; ...`` ## - ## **Note:** UTC is assumed as the timezone for ``expires``. + ## **Note:** UTC is assumed as the timezone for ``expires``. return setCookie(key, value, domain, path, format(expires, "ddd',' dd MMM yyyy HH:mm:ss 'UTC'"), noname, secure, httpOnly) @@ -61,7 +61,7 @@ when isMainModule: echo cookie let start = "Set-Cookie: test=value; Expires=" assert cookie[0..start.high] == start - + let table = parseCookies("uid=1; kp=2") assert table["uid"] == "1" assert table["kp"] == "2" diff --git a/lib/pure/encodings.nim b/lib/pure/encodings.nim index e427b585d6..2d305ea425 100644 --- a/lib/pure/encodings.nim +++ b/lib/pure/encodings.nim @@ -7,7 +7,7 @@ # distribution, for details about the copyright. # -## Converts between different character encodings. On UNIX, this uses +## Converts between different character encodings. On UNIX, this uses ## the `iconv`:idx: library, on Windows the Windows API. import os, parseutils, strutils @@ -41,173 +41,173 @@ when defined(windows): inc j result = i == a.len and j == b.len - const + const winEncodings = [ (1, "OEMCP"), # current OEM codepage - (037, "IBM037"), # IBM EBCDIC US-Canada - (437, "IBM437"), # OEM United States - (500, "IBM500"), # IBM EBCDIC International - (708, "ASMO-708"), # Arabic (ASMO 708) - (709, "ASMO_449"), # Arabic (ASMO-449+, BCON V4) - (710, ""), # Arabic - Transparent Arabic - (720, "DOS-720"), # Arabic (Transparent ASMO); Arabic (DOS) - (737, "ibm737"), # OEM Greek (formerly 437G); Greek (DOS) - (775, "ibm775"), # OEM Baltic; Baltic (DOS) - (850, "ibm850"), # OEM Multilingual Latin 1; Western European (DOS) - (852, "ibm852"), # OEM Latin 2; Central European (DOS) - (855, "IBM855"), # OEM Cyrillic (primarily Russian) - (857, "ibm857"), # OEM Turkish; Turkish (DOS) - (858, "IBM00858"), # OEM Multilingual Latin 1 + Euro symbol - (860, "IBM860"), # OEM Portuguese; Portuguese (DOS) - (861, "ibm861"), # OEM Icelandic; Icelandic (DOS) - (862, "DOS-862"), # OEM Hebrew; Hebrew (DOS) - (863, "IBM863"), # OEM French Canadian; French Canadian (DOS) - (864, "IBM864"), # OEM Arabic; Arabic (864) - (865, "IBM865"), # OEM Nordic; Nordic (DOS) - (866, "cp866"), # OEM Russian; Cyrillic (DOS) - (869, "ibm869"), # OEM Modern Greek; Greek, Modern (DOS) - (870, "IBM870"), # IBM EBCDIC Multilingual/ROECE (Latin 2); IBM EBCDIC Multilingual Latin 2 - (874, "windows-874"), # ANSI/OEM Thai (same as 28605, ISO 8859-15); Thai (Windows) - (875, "cp875"), # IBM EBCDIC Greek Modern - (932, "shift_jis"), # ANSI/OEM Japanese; Japanese (Shift-JIS) - (936, "gb2312"), # ANSI/OEM Simplified Chinese (PRC, Singapore); Chinese Simplified (GB2312) - (949, "ks_c_5601-1987"), # ANSI/OEM Korean (Unified Hangul Code) - (950, "big5"), # ANSI/OEM Traditional Chinese (Taiwan; Hong Kong SAR, PRC); Chinese Traditional (Big5) - (1026, "IBM1026"), # IBM EBCDIC Turkish (Latin 5) - (1047, "IBM01047"), # IBM EBCDIC Latin 1/Open System - (1140, "IBM01140"), # IBM EBCDIC US-Canada (037 + Euro symbol); IBM EBCDIC (US-Canada-Euro) - (1141, "IBM01141"), # IBM EBCDIC Germany (20273 + Euro symbol); IBM EBCDIC (Germany-Euro) - (1142, "IBM01142"), # IBM EBCDIC Denmark-Norway (20277 + Euro symbol); IBM EBCDIC (Denmark-Norway-Euro) - (1143, "IBM01143"), # IBM EBCDIC Finland-Sweden (20278 + Euro symbol); IBM EBCDIC (Finland-Sweden-Euro) - (1144, "IBM01144"), # IBM EBCDIC Italy (20280 + Euro symbol); IBM EBCDIC (Italy-Euro) - (1145, "IBM01145"), # IBM EBCDIC Latin America-Spain (20284 + Euro symbol); IBM EBCDIC (Spain-Euro) - (1146, "IBM01146"), # IBM EBCDIC United Kingdom (20285 + Euro symbol); IBM EBCDIC (UK-Euro) - (1147, "IBM01147"), # IBM EBCDIC France (20297 + Euro symbol); IBM EBCDIC (France-Euro) - (1148, "IBM01148"), # IBM EBCDIC International (500 + Euro symbol); IBM EBCDIC (International-Euro) - (1149, "IBM01149"), # IBM EBCDIC Icelandic (20871 + Euro symbol); IBM EBCDIC (Icelandic-Euro) - (1200, "utf-16"), # Unicode UTF-16, little endian byte order (BMP of ISO 10646); available only to managed applications - (1201, "unicodeFFFE"), # Unicode UTF-16, big endian byte order; available only to managed applications - (1250, "windows-1250"), # ANSI Central European; Central European (Windows) - (1251, "windows-1251"), # ANSI Cyrillic; Cyrillic (Windows) - (1252, "windows-1252"), # ANSI Latin 1; Western European (Windows) - (1253, "windows-1253"), # ANSI Greek; Greek (Windows) - (1254, "windows-1254"), # ANSI Turkish; Turkish (Windows) - (1255, "windows-1255"), # ANSI Hebrew; Hebrew (Windows) - (1256, "windows-1256"), # ANSI Arabic; Arabic (Windows) - (1257, "windows-1257"), # ANSI Baltic; Baltic (Windows) - (1258, "windows-1258"), # ANSI/OEM Vietnamese; Vietnamese (Windows) + (037, "IBM037"), # IBM EBCDIC US-Canada + (437, "IBM437"), # OEM United States + (500, "IBM500"), # IBM EBCDIC International + (708, "ASMO-708"), # Arabic (ASMO 708) + (709, "ASMO_449"), # Arabic (ASMO-449+, BCON V4) + (710, ""), # Arabic - Transparent Arabic + (720, "DOS-720"), # Arabic (Transparent ASMO); Arabic (DOS) + (737, "ibm737"), # OEM Greek (formerly 437G); Greek (DOS) + (775, "ibm775"), # OEM Baltic; Baltic (DOS) + (850, "ibm850"), # OEM Multilingual Latin 1; Western European (DOS) + (852, "ibm852"), # OEM Latin 2; Central European (DOS) + (855, "IBM855"), # OEM Cyrillic (primarily Russian) + (857, "ibm857"), # OEM Turkish; Turkish (DOS) + (858, "IBM00858"), # OEM Multilingual Latin 1 + Euro symbol + (860, "IBM860"), # OEM Portuguese; Portuguese (DOS) + (861, "ibm861"), # OEM Icelandic; Icelandic (DOS) + (862, "DOS-862"), # OEM Hebrew; Hebrew (DOS) + (863, "IBM863"), # OEM French Canadian; French Canadian (DOS) + (864, "IBM864"), # OEM Arabic; Arabic (864) + (865, "IBM865"), # OEM Nordic; Nordic (DOS) + (866, "cp866"), # OEM Russian; Cyrillic (DOS) + (869, "ibm869"), # OEM Modern Greek; Greek, Modern (DOS) + (870, "IBM870"), # IBM EBCDIC Multilingual/ROECE (Latin 2); IBM EBCDIC Multilingual Latin 2 + (874, "windows-874"), # ANSI/OEM Thai (same as 28605, ISO 8859-15); Thai (Windows) + (875, "cp875"), # IBM EBCDIC Greek Modern + (932, "shift_jis"), # ANSI/OEM Japanese; Japanese (Shift-JIS) + (936, "gb2312"), # ANSI/OEM Simplified Chinese (PRC, Singapore); Chinese Simplified (GB2312) + (949, "ks_c_5601-1987"), # ANSI/OEM Korean (Unified Hangul Code) + (950, "big5"), # ANSI/OEM Traditional Chinese (Taiwan; Hong Kong SAR, PRC); Chinese Traditional (Big5) + (1026, "IBM1026"), # IBM EBCDIC Turkish (Latin 5) + (1047, "IBM01047"), # IBM EBCDIC Latin 1/Open System + (1140, "IBM01140"), # IBM EBCDIC US-Canada (037 + Euro symbol); IBM EBCDIC (US-Canada-Euro) + (1141, "IBM01141"), # IBM EBCDIC Germany (20273 + Euro symbol); IBM EBCDIC (Germany-Euro) + (1142, "IBM01142"), # IBM EBCDIC Denmark-Norway (20277 + Euro symbol); IBM EBCDIC (Denmark-Norway-Euro) + (1143, "IBM01143"), # IBM EBCDIC Finland-Sweden (20278 + Euro symbol); IBM EBCDIC (Finland-Sweden-Euro) + (1144, "IBM01144"), # IBM EBCDIC Italy (20280 + Euro symbol); IBM EBCDIC (Italy-Euro) + (1145, "IBM01145"), # IBM EBCDIC Latin America-Spain (20284 + Euro symbol); IBM EBCDIC (Spain-Euro) + (1146, "IBM01146"), # IBM EBCDIC United Kingdom (20285 + Euro symbol); IBM EBCDIC (UK-Euro) + (1147, "IBM01147"), # IBM EBCDIC France (20297 + Euro symbol); IBM EBCDIC (France-Euro) + (1148, "IBM01148"), # IBM EBCDIC International (500 + Euro symbol); IBM EBCDIC (International-Euro) + (1149, "IBM01149"), # IBM EBCDIC Icelandic (20871 + Euro symbol); IBM EBCDIC (Icelandic-Euro) + (1200, "utf-16"), # Unicode UTF-16, little endian byte order (BMP of ISO 10646); available only to managed applications + (1201, "unicodeFFFE"), # Unicode UTF-16, big endian byte order; available only to managed applications + (1250, "windows-1250"), # ANSI Central European; Central European (Windows) + (1251, "windows-1251"), # ANSI Cyrillic; Cyrillic (Windows) + (1252, "windows-1252"), # ANSI Latin 1; Western European (Windows) + (1253, "windows-1253"), # ANSI Greek; Greek (Windows) + (1254, "windows-1254"), # ANSI Turkish; Turkish (Windows) + (1255, "windows-1255"), # ANSI Hebrew; Hebrew (Windows) + (1256, "windows-1256"), # ANSI Arabic; Arabic (Windows) + (1257, "windows-1257"), # ANSI Baltic; Baltic (Windows) + (1258, "windows-1258"), # ANSI/OEM Vietnamese; Vietnamese (Windows) - (1250, "cp-1250"), # ANSI Central European; Central European (Windows) - (1251, "cp-1251"), # ANSI Cyrillic; Cyrillic (Windows) - (1252, "cp-1252"), # ANSI Latin 1; Western European (Windows) - (1253, "cp-1253"), # ANSI Greek; Greek (Windows) - (1254, "cp-1254"), # ANSI Turkish; Turkish (Windows) - (1255, "cp-1255"), # ANSI Hebrew; Hebrew (Windows) - (1256, "cp-1256"), # ANSI Arabic; Arabic (Windows) - (1257, "cp-1257"), # ANSI Baltic; Baltic (Windows) - (1258, "cp-1258"), # ANSI/OEM Vietnamese; Vietnamese (Windows) + (1250, "cp-1250"), # ANSI Central European; Central European (Windows) + (1251, "cp-1251"), # ANSI Cyrillic; Cyrillic (Windows) + (1252, "cp-1252"), # ANSI Latin 1; Western European (Windows) + (1253, "cp-1253"), # ANSI Greek; Greek (Windows) + (1254, "cp-1254"), # ANSI Turkish; Turkish (Windows) + (1255, "cp-1255"), # ANSI Hebrew; Hebrew (Windows) + (1256, "cp-1256"), # ANSI Arabic; Arabic (Windows) + (1257, "cp-1257"), # ANSI Baltic; Baltic (Windows) + (1258, "cp-1258"), # ANSI/OEM Vietnamese; Vietnamese (Windows) + + (1361, "Johab"), # Korean (Johab) + (10000, "macintosh"), # MAC Roman; Western European (Mac) + (10001, "x-mac-japanese"), # Japanese (Mac) + (10002, "x-mac-chinesetrad"), # MAC Traditional Chinese (Big5); Chinese Traditional (Mac) + (10003, "x-mac-korean"), # Korean (Mac) + (10004, "x-mac-arabic"), # Arabic (Mac) + (10005, "x-mac-hebrew"), # Hebrew (Mac) + (10006, "x-mac-greek"), # Greek (Mac) + (10007, "x-mac-cyrillic"), # Cyrillic (Mac) + (10008, "x-mac-chinesesimp"), # MAC Simplified Chinese (GB 2312); Chinese Simplified (Mac) + (10010, "x-mac-romanian"), # Romanian (Mac) + (10017, "x-mac-ukrainian"), # Ukrainian (Mac) + (10021, "x-mac-thai"), # Thai (Mac) + (10029, "x-mac-ce"), # MAC Latin 2; Central European (Mac) + (10079, "x-mac-icelandic"), # Icelandic (Mac) + (10081, "x-mac-turkish"), # Turkish (Mac) + (10082, "x-mac-croatian"), # Croatian (Mac) + (12000, "utf-32"), # Unicode UTF-32, little endian byte order; available only to managed applications + (12001, "utf-32BE"), # Unicode UTF-32, big endian byte order; available only to managed applications + (20000, "x-Chinese_CNS"), # CNS Taiwan; Chinese Traditional (CNS) + (20001, "x-cp20001"), # TCA Taiwan + (20002, "x_Chinese-Eten"), # Eten Taiwan; Chinese Traditional (Eten) + (20003, "x-cp20003"), # IBM5550 Taiwan + (20004, "x-cp20004"), # TeleText Taiwan + (20005, "x-cp20005"), # Wang Taiwan + (20105, "x-IA5"), # IA5 (IRV International Alphabet No. 5, 7-bit); Western European (IA5) + (20106, "x-IA5-German"), # IA5 German (7-bit) + (20107, "x-IA5-Swedish"), # IA5 Swedish (7-bit) + (20108, "x-IA5-Norwegian"), # IA5 Norwegian (7-bit) + (20127, "us-ascii"), # US-ASCII (7-bit) + (20261, "x-cp20261"), # T.61 + (20269, "x-cp20269"), # ISO 6937 Non-Spacing Accent + (20273, "IBM273"), # IBM EBCDIC Germany + (20277, "IBM277"), # IBM EBCDIC Denmark-Norway + (20278, "IBM278"), # IBM EBCDIC Finland-Sweden + (20280, "IBM280"), # IBM EBCDIC Italy + (20284, "IBM284"), # IBM EBCDIC Latin America-Spain + (20285, "IBM285"), # IBM EBCDIC United Kingdom + (20290, "IBM290"), # IBM EBCDIC Japanese Katakana Extended + (20297, "IBM297"), # IBM EBCDIC France + (20420, "IBM420"), # IBM EBCDIC Arabic + (20423, "IBM423"), # IBM EBCDIC Greek + (20424, "IBM424"), # IBM EBCDIC Hebrew + (20833, "x-EBCDIC-KoreanExtended"), # IBM EBCDIC Korean Extended + (20838, "IBM-Thai"), # IBM EBCDIC Thai + (20866, "koi8-r"), # Russian (KOI8-R); Cyrillic (KOI8-R) + (20871, "IBM871"), # IBM EBCDIC Icelandic + (20880, "IBM880"), # IBM EBCDIC Cyrillic Russian + (20905, "IBM905"), # IBM EBCDIC Turkish + (20924, "IBM00924"), # IBM EBCDIC Latin 1/Open System (1047 + Euro symbol) + (20932, "EUC-JP"), # Japanese (JIS 0208-1990 and 0121-1990) + (20936, "x-cp20936"), # Simplified Chinese (GB2312); Chinese Simplified (GB2312-80) + (20949, "x-cp20949"), # Korean Wansung + (21025, "cp1025"), # IBM EBCDIC Cyrillic Serbian-Bulgarian + (21027, ""), # (deprecated) + (21866, "koi8-u"), # Ukrainian (KOI8-U); Cyrillic (KOI8-U) + (28591, "iso-8859-1"), # ISO 8859-1 Latin 1; Western European (ISO) + (28592, "iso-8859-2"), # ISO 8859-2 Central European; Central European (ISO) + (28593, "iso-8859-3"), # ISO 8859-3 Latin 3 + (28594, "iso-8859-4"), # ISO 8859-4 Baltic + (28595, "iso-8859-5"), # ISO 8859-5 Cyrillic + (28596, "iso-8859-6"), # ISO 8859-6 Arabic + (28597, "iso-8859-7"), # ISO 8859-7 Greek + (28598, "iso-8859-8"), # ISO 8859-8 Hebrew; Hebrew (ISO-Visual) + (28599, "iso-8859-9"), # ISO 8859-9 Turkish + (28603, "iso-8859-13"), # ISO 8859-13 Estonian + (28605, "iso-8859-15"), # ISO 8859-15 Latin 9 + (29001, "x-Europa"), # Europa 3 + (38598, "iso-8859-8-i"), # ISO 8859-8 Hebrew; Hebrew (ISO-Logical) + (50220, "iso-2022-jp"), # ISO 2022 Japanese with no halfwidth Katakana; Japanese (JIS) + (50221, "csISO2022JP"), # ISO 2022 Japanese with halfwidth Katakana; Japanese (JIS-Allow 1 byte Kana) + (50222, "iso-2022-jp"), # ISO 2022 Japanese JIS X 0201-1989; Japanese (JIS-Allow 1 byte Kana - SO/SI) + (50225, "iso-2022-kr"), # ISO 2022 Korean + (50227, "x-cp50227"), # ISO 2022 Simplified Chinese; Chinese Simplified (ISO 2022) + (50229, ""), # ISO 2022 Traditional Chinese + (50930, ""), # EBCDIC Japanese (Katakana) Extended + (50931, ""), # EBCDIC US-Canada and Japanese + (50933, ""), # EBCDIC Korean Extended and Korean + (50935, ""), # EBCDIC Simplified Chinese Extended and Simplified Chinese + (50936, ""), # EBCDIC Simplified Chinese + (50937, ""), # EBCDIC US-Canada and Traditional Chinese + (50939, ""), # EBCDIC Japanese (Latin) Extended and Japanese + (51932, "euc-jp"), # EUC Japanese + (51936, "EUC-CN"), # EUC Simplified Chinese; Chinese Simplified (EUC) + (51949, "euc-kr"), # EUC Korean + (51950, ""), # EUC Traditional Chinese + (52936, "hz-gb-2312"), # HZ-GB2312 Simplified Chinese; Chinese Simplified (HZ) + (54936, "GB18030"), # Windows XP and later: GB18030 Simplified Chinese (4 byte); Chinese Simplified (GB18030) + (57002, "x-iscii-de"), # ISCII Devanagari + (57003, "x-iscii-be"), # ISCII Bengali + (57004, "x-iscii-ta"), # ISCII Tamil + (57005, "x-iscii-te"), # ISCII Telugu + (57006, "x-iscii-as"), # ISCII Assamese + (57007, "x-iscii-or"), # ISCII Oriya + (57008, "x-iscii-ka"), # ISCII Kannada + (57009, "x-iscii-ma"), # ISCII Malayalam + (57010, "x-iscii-gu"), # ISCII Gujarati + (57011, "x-iscii-pa"), # ISCII Punjabi + (65000, "utf-7"), # Unicode (UTF-7) + (65001, "utf-8")] # Unicode (UTF-8) - (1361, "Johab"), # Korean (Johab) - (10000, "macintosh"), # MAC Roman; Western European (Mac) - (10001, "x-mac-japanese"), # Japanese (Mac) - (10002, "x-mac-chinesetrad"), # MAC Traditional Chinese (Big5); Chinese Traditional (Mac) - (10003, "x-mac-korean"), # Korean (Mac) - (10004, "x-mac-arabic"), # Arabic (Mac) - (10005, "x-mac-hebrew"), # Hebrew (Mac) - (10006, "x-mac-greek"), # Greek (Mac) - (10007, "x-mac-cyrillic"), # Cyrillic (Mac) - (10008, "x-mac-chinesesimp"), # MAC Simplified Chinese (GB 2312); Chinese Simplified (Mac) - (10010, "x-mac-romanian"), # Romanian (Mac) - (10017, "x-mac-ukrainian"), # Ukrainian (Mac) - (10021, "x-mac-thai"), # Thai (Mac) - (10029, "x-mac-ce"), # MAC Latin 2; Central European (Mac) - (10079, "x-mac-icelandic"), # Icelandic (Mac) - (10081, "x-mac-turkish"), # Turkish (Mac) - (10082, "x-mac-croatian"), # Croatian (Mac) - (12000, "utf-32"), # Unicode UTF-32, little endian byte order; available only to managed applications - (12001, "utf-32BE"), # Unicode UTF-32, big endian byte order; available only to managed applications - (20000, "x-Chinese_CNS"), # CNS Taiwan; Chinese Traditional (CNS) - (20001, "x-cp20001"), # TCA Taiwan - (20002, "x_Chinese-Eten"), # Eten Taiwan; Chinese Traditional (Eten) - (20003, "x-cp20003"), # IBM5550 Taiwan - (20004, "x-cp20004"), # TeleText Taiwan - (20005, "x-cp20005"), # Wang Taiwan - (20105, "x-IA5"), # IA5 (IRV International Alphabet No. 5, 7-bit); Western European (IA5) - (20106, "x-IA5-German"), # IA5 German (7-bit) - (20107, "x-IA5-Swedish"), # IA5 Swedish (7-bit) - (20108, "x-IA5-Norwegian"), # IA5 Norwegian (7-bit) - (20127, "us-ascii"), # US-ASCII (7-bit) - (20261, "x-cp20261"), # T.61 - (20269, "x-cp20269"), # ISO 6937 Non-Spacing Accent - (20273, "IBM273"), # IBM EBCDIC Germany - (20277, "IBM277"), # IBM EBCDIC Denmark-Norway - (20278, "IBM278"), # IBM EBCDIC Finland-Sweden - (20280, "IBM280"), # IBM EBCDIC Italy - (20284, "IBM284"), # IBM EBCDIC Latin America-Spain - (20285, "IBM285"), # IBM EBCDIC United Kingdom - (20290, "IBM290"), # IBM EBCDIC Japanese Katakana Extended - (20297, "IBM297"), # IBM EBCDIC France - (20420, "IBM420"), # IBM EBCDIC Arabic - (20423, "IBM423"), # IBM EBCDIC Greek - (20424, "IBM424"), # IBM EBCDIC Hebrew - (20833, "x-EBCDIC-KoreanExtended"), # IBM EBCDIC Korean Extended - (20838, "IBM-Thai"), # IBM EBCDIC Thai - (20866, "koi8-r"), # Russian (KOI8-R); Cyrillic (KOI8-R) - (20871, "IBM871"), # IBM EBCDIC Icelandic - (20880, "IBM880"), # IBM EBCDIC Cyrillic Russian - (20905, "IBM905"), # IBM EBCDIC Turkish - (20924, "IBM00924"), # IBM EBCDIC Latin 1/Open System (1047 + Euro symbol) - (20932, "EUC-JP"), # Japanese (JIS 0208-1990 and 0121-1990) - (20936, "x-cp20936"), # Simplified Chinese (GB2312); Chinese Simplified (GB2312-80) - (20949, "x-cp20949"), # Korean Wansung - (21025, "cp1025"), # IBM EBCDIC Cyrillic Serbian-Bulgarian - (21027, ""), # (deprecated) - (21866, "koi8-u"), # Ukrainian (KOI8-U); Cyrillic (KOI8-U) - (28591, "iso-8859-1"), # ISO 8859-1 Latin 1; Western European (ISO) - (28592, "iso-8859-2"), # ISO 8859-2 Central European; Central European (ISO) - (28593, "iso-8859-3"), # ISO 8859-3 Latin 3 - (28594, "iso-8859-4"), # ISO 8859-4 Baltic - (28595, "iso-8859-5"), # ISO 8859-5 Cyrillic - (28596, "iso-8859-6"), # ISO 8859-6 Arabic - (28597, "iso-8859-7"), # ISO 8859-7 Greek - (28598, "iso-8859-8"), # ISO 8859-8 Hebrew; Hebrew (ISO-Visual) - (28599, "iso-8859-9"), # ISO 8859-9 Turkish - (28603, "iso-8859-13"), # ISO 8859-13 Estonian - (28605, "iso-8859-15"), # ISO 8859-15 Latin 9 - (29001, "x-Europa"), # Europa 3 - (38598, "iso-8859-8-i"), # ISO 8859-8 Hebrew; Hebrew (ISO-Logical) - (50220, "iso-2022-jp"), # ISO 2022 Japanese with no halfwidth Katakana; Japanese (JIS) - (50221, "csISO2022JP"), # ISO 2022 Japanese with halfwidth Katakana; Japanese (JIS-Allow 1 byte Kana) - (50222, "iso-2022-jp"), # ISO 2022 Japanese JIS X 0201-1989; Japanese (JIS-Allow 1 byte Kana - SO/SI) - (50225, "iso-2022-kr"), # ISO 2022 Korean - (50227, "x-cp50227"), # ISO 2022 Simplified Chinese; Chinese Simplified (ISO 2022) - (50229, ""), # ISO 2022 Traditional Chinese - (50930, ""), # EBCDIC Japanese (Katakana) Extended - (50931, ""), # EBCDIC US-Canada and Japanese - (50933, ""), # EBCDIC Korean Extended and Korean - (50935, ""), # EBCDIC Simplified Chinese Extended and Simplified Chinese - (50936, ""), # EBCDIC Simplified Chinese - (50937, ""), # EBCDIC US-Canada and Traditional Chinese - (50939, ""), # EBCDIC Japanese (Latin) Extended and Japanese - (51932, "euc-jp"), # EUC Japanese - (51936, "EUC-CN"), # EUC Simplified Chinese; Chinese Simplified (EUC) - (51949, "euc-kr"), # EUC Korean - (51950, ""), # EUC Traditional Chinese - (52936, "hz-gb-2312"), # HZ-GB2312 Simplified Chinese; Chinese Simplified (HZ) - (54936, "GB18030"), # Windows XP and later: GB18030 Simplified Chinese (4 byte); Chinese Simplified (GB18030) - (57002, "x-iscii-de"), # ISCII Devanagari - (57003, "x-iscii-be"), # ISCII Bengali - (57004, "x-iscii-ta"), # ISCII Tamil - (57005, "x-iscii-te"), # ISCII Telugu - (57006, "x-iscii-as"), # ISCII Assamese - (57007, "x-iscii-or"), # ISCII Oriya - (57008, "x-iscii-ka"), # ISCII Kannada - (57009, "x-iscii-ma"), # ISCII Malayalam - (57010, "x-iscii-gu"), # ISCII Gujarati - (57011, "x-iscii-pa"), # ISCII Punjabi - (65000, "utf-7"), # Unicode (UTF-7) - (65001, "utf-8")] # Unicode (UTF-8) - when false: # not needed yet: type @@ -219,22 +219,22 @@ when defined(windows): proc getCPInfo(codePage: CodePage, lpCPInfo: var CpInfo): int32 {. stdcall, importc: "GetCPInfo", dynlib: "kernel32".} - + proc nameToCodePage(name: string): CodePage = var nameAsInt: int if parseInt(name, nameAsInt) == 0: nameAsInt = -1 for no, na in items(winEncodings): if no == nameAsInt or eqEncodingNames(na, name): return CodePage(no) result = CodePage(-1) - + proc codePageToName(c: CodePage): string = for no, na in items(winEncodings): if no == int(c): return if na.len != 0: na else: $no result = "" - + proc getACP(): CodePage {.stdcall, importc: "GetACP", dynlib: "kernel32".} - + proc multiByteToWideChar( codePage: CodePage, dwFlags: int32, @@ -254,7 +254,7 @@ when defined(windows): lpDefaultChar: cstring=nil, lpUsedDefaultChar: pointer=nil): cint {. stdcall, importc: "WideCharToMultiByte", dynlib: "kernel32".} - + else: when defined(haiku): const iconvDll = "(libc.so.6|libiconv.so|libtextencoding.so)" @@ -292,31 +292,31 @@ else: proc iconv(c: EncodingConverter, inbuf: pointer, inbytesLeft: pointer, outbuf: var cstring, outbytesLeft: var int): int {. importc: prefix & "iconv", cdecl, dynlib: iconvDll.} - + proc getCurrentEncoding*(): string = ## retrieves the current encoding. On Unix, always "UTF-8" is returned. when defined(windows): result = codePageToName(getACP()) else: result = "UTF-8" - + proc open*(destEncoding = "UTF-8", srcEncoding = "CP1252"): EncodingConverter = ## opens a converter that can convert from `srcEncoding` to `destEncoding`. ## Raises `EIO` if it cannot fulfill the request. when not defined(windows): result = iconvOpen(destEncoding, srcEncoding) if result == nil: - raise newException(EncodingError, - "cannot create encoding converter from " & + raise newException(EncodingError, + "cannot create encoding converter from " & srcEncoding & " to " & destEncoding) else: result.dest = nameToCodePage(destEncoding) result.src = nameToCodePage(srcEncoding) if int(result.dest) == -1: - raise newException(EncodingError, + raise newException(EncodingError, "cannot find encoding " & destEncoding) if int(result.src) == -1: - raise newException(EncodingError, + raise newException(EncodingError, "cannot find encoding " & srcEncoding) proc close*(c: EncodingConverter) = @@ -328,7 +328,7 @@ when defined(windows): proc convert*(c: EncodingConverter, s: string): string = ## converts `s` to `destEncoding` that was given to the converter `c`. It ## assumed that `s` is in `srcEncoding`. - + # special case: empty string: needed because MultiByteToWideChar # return 0 in case of error: if s.len == 0: return "" @@ -336,21 +336,21 @@ when defined(windows): var cap = s.len + s.len shr 2 result = newStringOfCap(cap*2) # convert to utf-16 LE - var m = multiByteToWideChar(codePage = c.src, dwFlags = 0'i32, + var m = multiByteToWideChar(codePage = c.src, dwFlags = 0'i32, lpMultiByteStr = cstring(s), cbMultiByte = cint(s.len), lpWideCharStr = cstring(result), cchWideChar = cint(cap)) - if m == 0: + if m == 0: # try again; ask for capacity: - cap = multiByteToWideChar(codePage = c.src, dwFlags = 0'i32, + cap = multiByteToWideChar(codePage = c.src, dwFlags = 0'i32, lpMultiByteStr = cstring(s), cbMultiByte = cint(s.len), lpWideCharStr = nil, cchWideChar = cint(0)) # and do the conversion properly: result = newStringOfCap(cap*2) - m = multiByteToWideChar(codePage = c.src, dwFlags = 0'i32, + m = multiByteToWideChar(codePage = c.src, dwFlags = 0'i32, lpMultiByteStr = cstring(s), cbMultiByte = cint(s.len), lpWideCharStr = cstring(result), @@ -361,7 +361,7 @@ when defined(windows): setLen(result, m*2) else: assert(false) # cannot happen - + # if already utf-16 LE, no further need to do something: if int(c.dest) == 1200: return # otherwise the fun starts again: @@ -428,7 +428,7 @@ else: outLen = len(result) - offset else: raiseOSError(lerr.OSErrorCode) - # iconv has a buffer that needs flushing, specially if the last char is + # iconv has a buffer that needs flushing, specially if the last char is # not '\0' discard iconv(c, nil, nil, dst, outLen) if iconvres == cint(-1) and errno == E2BIG: @@ -441,7 +441,7 @@ else: # trim output buffer setLen(result, len(result) - outLen) -proc convert*(s: string, destEncoding = "UTF-8", +proc convert*(s: string, destEncoding = "UTF-8", srcEncoding = "CP1252"): string = ## converts `s` to `destEncoding`. It assumed that `s` is in `srcEncoding`. ## This opens a converter, uses it and closes it again and is thus more diff --git a/lib/pure/endians.nim b/lib/pure/endians.nim index 6e33d46242..5a23169d41 100644 --- a/lib/pure/endians.nim +++ b/lib/pure/endians.nim @@ -24,7 +24,7 @@ proc swapEndian64*(outp, inp: pointer) = o[6] = i[1] o[7] = i[0] -proc swapEndian32*(outp, inp: pointer) = +proc swapEndian32*(outp, inp: pointer) = ## copies `inp` to `outp` swapping bytes. Both buffers are supposed to ## contain at least 4 bytes. var i = cast[cstring](inp) @@ -34,7 +34,7 @@ proc swapEndian32*(outp, inp: pointer) = o[2] = i[1] o[3] = i[0] -proc swapEndian16*(outp, inp: pointer) = +proc swapEndian16*(outp, inp: pointer) = ## copies `inp` to `outp` swapping bytes. Both buffers are supposed to ## contain at least 2 bytes. var @@ -50,7 +50,7 @@ when system.cpuEndian == bigEndian: proc bigEndian64*(outp, inp: pointer) {.inline.} = copyMem(outp, inp, 8) proc bigEndian32*(outp, inp: pointer) {.inline.} = copyMem(outp, inp, 4) proc bigEndian16*(outp, inp: pointer) {.inline.} = copyMem(outp, inp, 2) -else: +else: proc littleEndian64*(outp, inp: pointer) {.inline.} = copyMem(outp, inp, 8) proc littleEndian32*(outp, inp: pointer) {.inline.} = copyMem(outp, inp, 4) proc littleEndian16*(outp, inp: pointer){.inline.} = copyMem(outp, inp, 2) diff --git a/lib/pure/etcpriv.nim b/lib/pure/etcpriv.nim index e7a525e4d4..5b785b0519 100644 --- a/lib/pure/etcpriv.nim +++ b/lib/pure/etcpriv.nim @@ -18,6 +18,6 @@ const magicIdentSeparatorRuneByteWidth* = 3 # Used by pure/hashes.nim, and the compiler parsing proc isMagicIdentSeparatorRune*(cs: cstring, i: int): bool {. inline } = - result = cs[i] == '\226' and + result = cs[i] == '\226' and cs[i + 1] == '\128' and cs[i + 2] == '\147' # en-dash # 145 = nb-hyphen diff --git a/lib/pure/events.nim b/lib/pure/events.nim index 44e9ed2865..01b64c545a 100644 --- a/lib/pure/events.nim +++ b/lib/pure/events.nim @@ -10,7 +10,7 @@ ## :Author: Alex Mitchell ## ## This module implements an event system that is not dependent on external -## graphical toolkits. It was originally called ``NimEE`` because +## graphical toolkits. It was originally called ``NimEE`` because ## it was inspired by Python's PyEE module. There are two ways you can use ## events: one is a python-inspired way; the other is more of a C-style way. ## @@ -23,7 +23,7 @@ ## # Python way ## ee.on("EventName", handleevent) ## ee.emit("EventName", genericargs) -## +## ## # C/Java way ## # Declare a type ## type @@ -45,7 +45,7 @@ type {.deprecated: [TEventArgs: EventArgs, TEventHandler: EventHandler, TEventEmitter: EventEmitter, EInvalidEvent: EventError].} - + proc initEventHandler*(name: string): EventHandler = ## Initializes an EventHandler with the specified name and returns it. result.handlers = @[] @@ -61,7 +61,7 @@ proc removeHandler*(handler: var EventHandler, fn: proc(e: EventArgs) {.closure. if fn == handler.handlers[i]: handler.handlers.del(i) break - + proc containsHandler*(handler: var EventHandler, fn: proc(e: EventArgs) {.closure.}): bool = ## Checks if a callback is registered to this event handler. return handler.handlers.contains(fn) @@ -86,8 +86,8 @@ proc on*(emitter: var EventEmitter, event: string, fn: proc(e: EventArgs) {.clos emitter.s.add(eh) else: addHandler(emitter.s[i], fn) - -proc emit*(emitter: var EventEmitter, eventhandler: var EventHandler, + +proc emit*(emitter: var EventEmitter, eventhandler: var EventHandler, args: EventArgs) = ## Fires an event handler with specified event arguments. for fn in items(eventhandler.handlers): fn(args) diff --git a/lib/pure/fsmonitor.nim b/lib/pure/fsmonitor.nim index 229df80b52..787acb5d4d 100644 --- a/lib/pure/fsmonitor.nim +++ b/lib/pure/fsmonitor.nim @@ -30,7 +30,7 @@ type fd: cint handleEvent: proc (m: FSMonitor, ev: MonitorEvent) {.closure.} targets: Table[cint, string] - + MonitorEventType* = enum ## Monitor event type MonitorAccess, ## File was accessed. MonitorAttrib, ## Metadata changed. @@ -44,7 +44,7 @@ type MonitorMoved, ## File was moved. MonitorOpen, ## File was opened. MonitorAll ## Filter for all event types. - + MonitorEvent* = object case kind*: MonitorEventType ## Type of the event. of MonitorMoveSelf, MonitorMoved: @@ -77,7 +77,7 @@ proc add*(monitor: FSMonitor, target: string, ## Adds ``target`` which may be a directory or a file to the list of ## watched paths of ``monitor``. ## You can specify the events to report using the ``filters`` parameter. - + var INFilter = -1 for f in filters: case f @@ -93,7 +93,7 @@ proc add*(monitor: FSMonitor, target: string, of MonitorMoved: INFilter = INFilter and IN_MOVED_FROM and IN_MOVED_TO of MonitorOpen: INFilter = INFilter and IN_OPEN of MonitorAll: INFilter = INFilter and IN_ALL_EVENTS - + result = inotifyAddWatch(monitor.fd, target, INFilter.uint32) if result < 0: raiseOSError(osLastError()) @@ -125,13 +125,13 @@ proc getEvent(m: FSMonitor, fd: cint): seq[MonitorEvent] = mev.name = $cstr else: mev.name = "" - - if (event.mask.int and IN_MOVED_FROM) != 0: + + if (event.mask.int and IN_MOVED_FROM) != 0: # Moved from event, add to m's collection movedFrom.add(event.cookie.cint, (mev.wd, mev.name)) inc(i, sizeof(INotifyEvent) + event.len.int) continue - elif (event.mask.int and IN_MOVED_TO) != 0: + elif (event.mask.int and IN_MOVED_TO) != 0: mev.kind = MonitorMoved assert movedFrom.hasKey(event.cookie.cint) # Find the MovedFrom event. @@ -141,23 +141,23 @@ proc getEvent(m: FSMonitor, fd: cint): seq[MonitorEvent] = movedFrom.del(event.cookie.cint) elif (event.mask.int and IN_ACCESS) != 0: mev.kind = MonitorAccess elif (event.mask.int and IN_ATTRIB) != 0: mev.kind = MonitorAttrib - elif (event.mask.int and IN_CLOSE_WRITE) != 0: + elif (event.mask.int and IN_CLOSE_WRITE) != 0: mev.kind = MonitorCloseWrite - elif (event.mask.int and IN_CLOSE_NOWRITE) != 0: + elif (event.mask.int and IN_CLOSE_NOWRITE) != 0: mev.kind = MonitorCloseNoWrite elif (event.mask.int and IN_CREATE) != 0: mev.kind = MonitorCreate - elif (event.mask.int and IN_DELETE) != 0: + elif (event.mask.int and IN_DELETE) != 0: mev.kind = MonitorDelete - elif (event.mask.int and IN_DELETE_SELF) != 0: + elif (event.mask.int and IN_DELETE_SELF) != 0: mev.kind = MonitorDeleteSelf elif (event.mask.int and IN_MODIFY) != 0: mev.kind = MonitorModify - elif (event.mask.int and IN_MOVE_SELF) != 0: + elif (event.mask.int and IN_MOVE_SELF) != 0: mev.kind = MonitorMoveSelf elif (event.mask.int and IN_OPEN) != 0: mev.kind = MonitorOpen - + if mev.kind != MonitorMoved: mev.fullname = "" - + result.add(mev) inc(i, sizeof(INotifyEvent) + event.len.int) @@ -211,7 +211,7 @@ when not defined(testing) and isMainModule: echo("Name is ", ev.name) else: echo("Name ", ev.name, " fullname ", ev.fullName)) - + while true: if not disp.poll(): break main() diff --git a/lib/pure/httpserver.nim b/lib/pure/httpserver.nim index 9818912272..71ba049919 100644 --- a/lib/pure/httpserver.nim +++ b/lib/pure/httpserver.nim @@ -142,7 +142,7 @@ when false: if meth == reqPost: # get from client and post to CGI program: var buf = alloc(contentLength) - if recv(client, buf, contentLength) != contentLength: + if recv(client, buf, contentLength) != contentLength: dealloc(buf) raiseOSError() var inp = process.inputStream @@ -177,7 +177,7 @@ when false: else: path = "." & data[1] # path starts with "/", by adding "." in front of it we serve files from cwd - + if cmpIgnoreCase(data[0], "GET") == 0: if q >= 0: cgi = true @@ -218,12 +218,12 @@ type headers*: StringTableRef ## headers with which the client made the request body*: string ## only set with POST requests ip*: string ## ip address of the requesting client - + PAsyncHTTPServer* = ref AsyncHTTPServer AsyncHTTPServer = object of Server asyncSocket: AsyncSocket {.deprecated: [TAsyncHTTPServer: AsyncHTTPServer, TServer: Server].} - + proc open*(s: var Server, port = Port(80), reuseAddr = false) = ## creates a new server at port `port`. If ``port == 0`` a free port is ## acquired that can be accessed later by the ``port`` proc. @@ -262,7 +262,7 @@ proc next*(s: var Server) = var data = "" s.client.readLine(data) if data == "": - # Socket disconnected + # Socket disconnected s.client.close() next(s) return @@ -283,9 +283,9 @@ proc next*(s: var Server) = s.client.close() next(s) return - + var i = skipWhitespace(data) - if skipIgnoreCase(data, "GET") > 0: + if skipIgnoreCase(data, "GET") > 0: s.reqMethod = "GET" inc(i, 3) elif skipIgnoreCase(data, "POST") > 0: @@ -296,7 +296,7 @@ proc next*(s: var Server) = s.client.close() next(s) return - + if s.reqMethod == "POST": # Check for Expect header if s.headers.hasKey("Expect"): @@ -304,7 +304,7 @@ proc next*(s: var Server) = s.client.sendStatus("100 Continue") else: s.client.sendStatus("417 Expectation Failed") - + # Read the body # - Check for Content-length header if s.headers.hasKey("Content-Length"): @@ -340,13 +340,13 @@ proc next*(s: var Server) = s.client.close() next(s) return - + var L = skipWhitespace(data, i) inc(i, L) # XXX we ignore "HTTP/1.1" etc. for now here var query = 0 var last = i - while last < data.len and data[last] notin Whitespace: + while last < data.len and data[last] notin Whitespace: if data[last] == '?' and query == 0: query = last inc(last) if query > 0: @@ -360,7 +360,7 @@ proc close*(s: Server) = ## closes the server (and the socket the server uses). close(s.socket) -proc run*(handleRequest: proc (client: Socket, +proc run*(handleRequest: proc (client: Socket, path, query: string): bool {.closure.}, port = Port(80)) = ## encapsulates the server object and main loop @@ -388,7 +388,7 @@ proc nextAsync(s: PAsyncHTTPServer) = var data = "" s.client.readLine(data) if data == "": - # Socket disconnected + # Socket disconnected s.client.close() return var header = "" @@ -408,9 +408,9 @@ proc nextAsync(s: PAsyncHTTPServer) = else: s.client.close() return - + var i = skipWhitespace(data) - if skipIgnoreCase(data, "GET") > 0: + if skipIgnoreCase(data, "GET") > 0: s.reqMethod = "GET" inc(i, 3) elif skipIgnoreCase(data, "POST") > 0: @@ -420,7 +420,7 @@ proc nextAsync(s: PAsyncHTTPServer) = unimplemented(s.client) s.client.close() return - + if s.reqMethod == "POST": # Check for Expect header if s.headers.hasKey("Expect"): @@ -428,7 +428,7 @@ proc nextAsync(s: PAsyncHTTPServer) = s.client.sendStatus("100 Continue") else: s.client.sendStatus("417 Expectation Failed") - + # Read the body # - Check for Content-length header if s.headers.hasKey("Content-Length"): @@ -460,13 +460,13 @@ proc nextAsync(s: PAsyncHTTPServer) = badRequest(s.client) s.client.close() return - + var L = skipWhitespace(data, i) inc(i, L) # XXX we ignore "HTTP/1.1" etc. for now here var query = 0 var last = i - while last < data.len and data[last] notin Whitespace: + while last < data.len and data[last] notin Whitespace: if data[last] == '?' and query == 0: query = last inc(last) if query > 0: @@ -476,7 +476,7 @@ proc nextAsync(s: PAsyncHTTPServer) = s.query = "" s.path = data.substr(i, last-1) -proc asyncHTTPServer*(handleRequest: proc (server: PAsyncHTTPServer, client: Socket, +proc asyncHTTPServer*(handleRequest: proc (server: PAsyncHTTPServer, client: Socket, path, query: string): bool {.closure, gcsafe.}, port = Port(80), address = "", reuseAddr = false): PAsyncHTTPServer = @@ -492,14 +492,14 @@ proc asyncHTTPServer*(handleRequest: proc (server: PAsyncHTTPServer, client: Soc if quit: capturedRet.asyncSocket.close() if reuseAddr: capturedRet.asyncSocket.setSockOpt(OptReuseAddr, true) - + capturedRet.asyncSocket.bindAddr(port, address) capturedRet.asyncSocket.listen() if port == Port(0): capturedRet.port = getSockName(capturedRet.asyncSocket) else: capturedRet.port = port - + capturedRet.client = invalidSocket capturedRet.reqMethod = "" capturedRet.body = "" @@ -524,11 +524,11 @@ when not defined(testing) and isMainModule: echo("httpserver running on port ", s.port) while true: next(s) - + inc(counter) s.client.send("Hello, Andreas, for the $#th time. $# ? $#" % [ $counter, s.path, s.query] & wwwNL) - + close(s.client) close(s) diff --git a/lib/pure/matchers.nim b/lib/pure/matchers.nim index d55963c155..5c28f65a08 100644 --- a/lib/pure/matchers.nim +++ b/lib/pure/matchers.nim @@ -18,15 +18,15 @@ include "system/inclrtl" import parseutils, strutils proc validEmailAddress*(s: string): bool {.noSideEffect, - rtl, extern: "nsuValidEmailAddress".} = - ## returns true if `s` seems to be a valid e-mail address. + rtl, extern: "nsuValidEmailAddress".} = + ## returns true if `s` seems to be a valid e-mail address. ## The checking also uses a domain list. const chars = Letters + Digits + {'!','#','$','%','&', '\'','*','+','/','=','?','^','_','`','{','}','|','~','-','.'} var i = 0 if s[i] notin chars or s[i] == '.': return false - while s[i] in chars: + while s[i] in chars: if s[i] == '.' and s[i+1] == '.': return false inc(i) if s[i] != '@': return false @@ -34,9 +34,9 @@ proc validEmailAddress*(s: string): bool {.noSideEffect, if s[j] notin Letters: return false while j >= i and s[j] in Letters: dec(j) inc(i) # skip '@' - while s[i] in {'0'..'9', 'a'..'z', '-', '.'}: inc(i) + while s[i] in {'0'..'9', 'a'..'z', '-', '.'}: inc(i) if s[i] != '\0': return false - + var x = substr(s, j+1) if len(x) == 2 and x[0] in Letters and x[1] in Letters: return true case toLower(x) @@ -59,6 +59,6 @@ proc parseInt*(s: string, value: var int, validRange: Slice[int]) {. when isMainModule: doAssert "wuseldusel@codehome.com".validEmailAddress - + {.pop.} diff --git a/lib/pure/memfiles.nim b/lib/pure/memfiles.nim index 00929eaa24..27b9895974 100644 --- a/lib/pure/memfiles.nim +++ b/lib/pure/memfiles.nim @@ -33,7 +33,7 @@ type when defined(windows): fHandle: int - mapHandle: int + mapHandle: int else: handle: cint @@ -131,7 +131,7 @@ proc open*(filename: string, mode: FileMode = fmRead, fail(osLastError(), "error opening file") if newFileSize != -1: - var + var sizeHigh = int32(newFileSize shr 32) sizeLow = int32(newFileSize and 0xffffffff) @@ -177,7 +177,7 @@ proc open*(filename: string, mode: FileMode = fmRead, rollback() if result.handle != 0: discard close(result.handle) raiseOSError(errCode) - + var flags = if readonly: O_RDONLY else: O_RDWR if newFileSize != -1: @@ -221,7 +221,7 @@ proc open*(filename: string, mode: FileMode = fmRead, proc close*(f: var MemFile) = ## closes the memory mapped file `f`. All changes are written back to the ## file system, if `f` was opened with write access. - + var error = false var lastErr: OSErrorCode @@ -245,7 +245,7 @@ proc close*(f: var MemFile) = f.mapHandle = 0 else: f.handle = 0 - + if error: raiseOSError(lastErr) type MemSlice* = object ## represent slice of a MemFile for iteration over delimited lines/records diff --git a/lib/pure/mersenne.nim b/lib/pure/mersenne.nim index 74112e3045..c8090dc6a4 100644 --- a/lib/pure/mersenne.nim +++ b/lib/pure/mersenne.nim @@ -7,7 +7,7 @@ type {.deprecated: [TMersenneTwister: MersenneTwister].} -proc newMersenneTwister*(seed: int): MersenneTwister = +proc newMersenneTwister*(seed: int): MersenneTwister = result.index = 0 result.mt[0]= uint32(seed) for i in 1..623'u32: diff --git a/lib/pure/numeric.nim b/lib/pure/numeric.nim index 9b298c0a0a..71adf19b36 100644 --- a/lib/pure/numeric.nim +++ b/lib/pure/numeric.nim @@ -11,23 +11,23 @@ type OneVarFunction* = proc (x: float): float {.deprecated: [TOneVarFunction: OneVarFunction].} -proc brent*(xmin,xmax:float, function:OneVarFunction, tol:float,maxiter=1000): +proc brent*(xmin,xmax:float, function:OneVarFunction, tol:float,maxiter=1000): tuple[rootx, rooty: float, success: bool]= - ## Searches `function` for a root between `xmin` and `xmax` + ## Searches `function` for a root between `xmin` and `xmax` ## using brents method. If the function value at `xmin`and `xmax` has the ## same sign, `rootx`/`rooty` is set too the extrema value closest to x-axis ## and succes is set to false. ## Otherwise there exists at least one root and success is set to true. ## This root is searched for at most `maxiter` iterations. - ## If `tol` tolerance is reached within `maxiter` iterations + ## If `tol` tolerance is reached within `maxiter` iterations ## the root refinement stops and success=true. # see http://en.wikipedia.org/wiki/Brent%27s_method - var + var a=xmin b=xmax c=a - d=1.0e308 + d=1.0e308 fa=function(a) fb=function(b) fc=fa @@ -42,19 +42,19 @@ proc brent*(xmin,xmax:float, function:OneVarFunction, tol:float,maxiter=1000): return (a,fa,false) else: return (b,fb,false) - + if abs(fa)tol: if fa!=fc and fb!=fc: # inverse quadratic interpolation s = a * fb * fc / (fa - fb) / (fa - fc) + b * fa * fc / (fb - fa) / (fb - fc) + c * fa * fb / (fc - fa) / (fc - fb) else: #secant rule s = b - fb * (b - a) / (fb - fa) tmp2 = (3.0 * a + b) / 4.0 - if not((s > tmp2 and s < b) or (s < tmp2 and s > b)) or - (mflag and abs(s - b) >= (abs(b - c) / 2.0)) or + if not((s > tmp2 and s < b) or (s < tmp2 and s > b)) or + (mflag and abs(s - b) >= (abs(b - c) / 2.0)) or (not mflag and abs(s - b) >= abs(c - d) / 2.0): s=(a+b)/2.0 mflag=true @@ -80,5 +80,5 @@ proc brent*(xmin,xmax:float, function:OneVarFunction, tol:float,maxiter=1000): inc i if i>maxiter: break - + return (b,fb,true) diff --git a/lib/pure/oids.nim b/lib/pure/oids.nim index ac90dd16b2..174922223d 100644 --- a/lib/pure/oids.nim +++ b/lib/pure/oids.nim @@ -8,7 +8,7 @@ # ## Nim OID support. An OID is a global ID that consists of a timestamp, -## a unique counter and a random value. This combination should suffice to +## a unique counter and a random value. This combination should suffice to ## produce a globally distributed unique ID. This implementation was extracted ## from the Mongodb interface and it thus binary compatible with a Mongo OID. ## @@ -19,13 +19,13 @@ import times, endians type Oid* = object ## an OID - time: int32 ## - fuzz: int32 ## - count: int32 ## + time: int32 ## + fuzz: int32 ## + count: int32 ## {.deprecated: [Toid: Oid].} -proc hexbyte*(hex: char): int = +proc hexbyte*(hex: char): int = case hex of '0'..'9': result = (ord(hex) - ord('0')) of 'a'..'f': result = (ord(hex) - ord('a') + 10) @@ -40,7 +40,7 @@ proc parseOid*(str: cstring): Oid = bytes[i] = chr((hexbyte(str[2 * i]) shl 4) or hexbyte(str[2 * i + 1])) inc(i) -proc oidToString*(oid: Oid, str: cstring) = +proc oidToString*(oid: Oid, str: cstring) = const hex = "0123456789abcdef" # work around a compiler bug: var str = str @@ -59,7 +59,7 @@ proc `$`*(oid: Oid): string = oidToString(oid, result) var - incr: int + incr: int fuzz: int32 proc genOid*(): Oid = @@ -69,10 +69,10 @@ proc genOid*(): Oid = proc srand(seed: cint) {.importc: "srand", header: "", nodecl.} var t = gettime(nil) - + var i = int32(incr) atomicInc(incr) - + if fuzz == 0: # racy, but fine semantically: srand(t) diff --git a/lib/pure/parsecfg.nim b/lib/pure/parsecfg.nim index bb64c8134f..f680d4fefc 100644 --- a/lib/pure/parsecfg.nim +++ b/lib/pure/parsecfg.nim @@ -7,17 +7,17 @@ # distribution, for details about the copyright. # -## The ``parsecfg`` module implements a high performance configuration file -## parser. The configuration file's syntax is similar to the Windows ``.ini`` -## format, but much more powerful, as it is not a line based parser. String -## literals, raw string literals and triple quoted string literals are supported +## The ``parsecfg`` module implements a high performance configuration file +## parser. The configuration file's syntax is similar to the Windows ``.ini`` +## format, but much more powerful, as it is not a line based parser. String +## literals, raw string literals and triple quoted string literals are supported ## as in the Nim programming language. ## This is an example of how a configuration file may look like: ## ## .. include:: doc/mytest.cfg ## :literal: -## The file ``examples/parsecfgex.nim`` demonstrates how to use the +## The file ``examples/parsecfgex.nim`` demonstrates how to use the ## configuration file parser: ## ## .. code-block:: nim @@ -36,14 +36,14 @@ type cfgKeyValuePair, ## a ``key=value`` pair has been detected cfgOption, ## a ``--key=value`` command line option cfgError ## an error occurred during parsing - + CfgEvent* = object of RootObj ## describes a parsing event case kind*: CfgEventKind ## the kind of the event of cfgEof: nil - of cfgSectionStart: - section*: string ## `section` contains the name of the + of cfgSectionStart: + section*: string ## `section` contains the name of the ## parsed section start (syntax: ``[section]``) - of cfgKeyValuePair, cfgOption: + of cfgKeyValuePair, cfgOption: key*, value*: string ## contains the (key, value) pair if an option ## of the form ``--key: value`` or an ordinary ## ``key= value`` pair has been parsed. @@ -52,14 +52,14 @@ type of cfgError: ## the parser encountered an error: `msg` msg*: string ## contains the error message. No exceptions ## are thrown if a parse error occurs. - - TokKind = enum - tkInvalid, tkEof, + + TokKind = enum + tkInvalid, tkEof, tkSymbol, tkEquals, tkColon, tkBracketLe, tkBracketRi, tkDashDash Token = object # a token kind: TokKind # the type of the token literal: string # the parsed (string) literal - + CfgParser* = object of BaseLexer ## the parser object. tok: Token filename: string @@ -69,12 +69,12 @@ type # implementation -const - SymChars = {'a'..'z', 'A'..'Z', '0'..'9', '_', '\x80'..'\xFF', '.', '/', '\\'} - +const + SymChars = {'a'..'z', 'A'..'Z', '0'..'9', '_', '\x80'..'\xFF', '.', '/', '\\'} + proc rawGetTok(c: var CfgParser, tok: var Token) {.gcsafe.} -proc open*(c: var CfgParser, input: Stream, filename: string, +proc open*(c: var CfgParser, input: Stream, filename: string, lineOffset = 0) {.rtl, extern: "npc$1".} = ## initializes the parser with an input stream. `Filename` is only used ## for nice error messages. `lineOffset` can be used to influence the line @@ -85,7 +85,7 @@ proc open*(c: var CfgParser, input: Stream, filename: string, c.tok.literal = "" inc(c.lineNumber, lineOffset) rawGetTok(c, c.tok) - + proc close*(c: var CfgParser) {.rtl, extern: "npc$1".} = ## closes the parser `c` and its associated input stream. lexbase.close(c) @@ -102,260 +102,260 @@ proc getFilename*(c: CfgParser): string {.rtl, extern: "npc$1".} = ## get the filename of the file that the parser processes. result = c.filename -proc handleHexChar(c: var CfgParser, xi: var int) = +proc handleHexChar(c: var CfgParser, xi: var int) = case c.buf[c.bufpos] - of '0'..'9': + of '0'..'9': xi = (xi shl 4) or (ord(c.buf[c.bufpos]) - ord('0')) inc(c.bufpos) - of 'a'..'f': + of 'a'..'f': xi = (xi shl 4) or (ord(c.buf[c.bufpos]) - ord('a') + 10) inc(c.bufpos) - of 'A'..'F': + of 'A'..'F': xi = (xi shl 4) or (ord(c.buf[c.bufpos]) - ord('A') + 10) inc(c.bufpos) - else: + else: discard -proc handleDecChars(c: var CfgParser, xi: var int) = - while c.buf[c.bufpos] in {'0'..'9'}: +proc handleDecChars(c: var CfgParser, xi: var int) = + while c.buf[c.bufpos] in {'0'..'9'}: xi = (xi * 10) + (ord(c.buf[c.bufpos]) - ord('0')) inc(c.bufpos) -proc getEscapedChar(c: var CfgParser, tok: var Token) = +proc getEscapedChar(c: var CfgParser, tok: var Token) = inc(c.bufpos) # skip '\' case c.buf[c.bufpos] - of 'n', 'N': + of 'n', 'N': add(tok.literal, "\n") inc(c.bufpos) - of 'r', 'R', 'c', 'C': + of 'r', 'R', 'c', 'C': add(tok.literal, '\c') inc(c.bufpos) - of 'l', 'L': + of 'l', 'L': add(tok.literal, '\L') inc(c.bufpos) - of 'f', 'F': + of 'f', 'F': add(tok.literal, '\f') inc(c.bufpos) - of 'e', 'E': + of 'e', 'E': add(tok.literal, '\e') inc(c.bufpos) - of 'a', 'A': + of 'a', 'A': add(tok.literal, '\a') inc(c.bufpos) - of 'b', 'B': + of 'b', 'B': add(tok.literal, '\b') inc(c.bufpos) - of 'v', 'V': + of 'v', 'V': add(tok.literal, '\v') inc(c.bufpos) - of 't', 'T': + of 't', 'T': add(tok.literal, '\t') inc(c.bufpos) - of '\'', '"': + of '\'', '"': add(tok.literal, c.buf[c.bufpos]) inc(c.bufpos) - of '\\': + of '\\': add(tok.literal, '\\') inc(c.bufpos) - of 'x', 'X': + of 'x', 'X': inc(c.bufpos) var xi = 0 handleHexChar(c, xi) handleHexChar(c, xi) add(tok.literal, chr(xi)) - of '0'..'9': + of '0'..'9': var xi = 0 handleDecChars(c, xi) if (xi <= 255): add(tok.literal, chr(xi)) else: tok.kind = tkInvalid else: tok.kind = tkInvalid - -proc handleCRLF(c: var CfgParser, pos: int): int = + +proc handleCRLF(c: var CfgParser, pos: int): int = case c.buf[pos] of '\c': result = lexbase.handleCR(c, pos) of '\L': result = lexbase.handleLF(c, pos) else: result = pos - -proc getString(c: var CfgParser, tok: var Token, rawMode: bool) = + +proc getString(c: var CfgParser, tok: var Token, rawMode: bool) = var pos = c.bufpos + 1 # skip " var buf = c.buf # put `buf` in a register tok.kind = tkSymbol - if (buf[pos] == '"') and (buf[pos + 1] == '"'): + if (buf[pos] == '"') and (buf[pos + 1] == '"'): # long string literal: inc(pos, 2) # skip "" # skip leading newline: pos = handleCRLF(c, pos) buf = c.buf - while true: + while true: case buf[pos] - of '"': - if (buf[pos + 1] == '"') and (buf[pos + 2] == '"'): break + of '"': + if (buf[pos + 1] == '"') and (buf[pos + 2] == '"'): break add(tok.literal, '"') inc(pos) - of '\c', '\L': + of '\c', '\L': pos = handleCRLF(c, pos) buf = c.buf add(tok.literal, "\n") - of lexbase.EndOfFile: + of lexbase.EndOfFile: tok.kind = tkInvalid - break - else: + break + else: add(tok.literal, buf[pos]) inc(pos) c.bufpos = pos + 3 # skip the three """ - else: + else: # ordinary string literal - while true: + while true: var ch = buf[pos] - if ch == '"': + if ch == '"': inc(pos) # skip '"' - break - if ch in {'\c', '\L', lexbase.EndOfFile}: + break + if ch in {'\c', '\L', lexbase.EndOfFile}: tok.kind = tkInvalid - break - if (ch == '\\') and not rawMode: + break + if (ch == '\\') and not rawMode: c.bufpos = pos getEscapedChar(c, tok) pos = c.bufpos - else: + else: add(tok.literal, ch) inc(pos) c.bufpos = pos -proc getSymbol(c: var CfgParser, tok: var Token) = +proc getSymbol(c: var CfgParser, tok: var Token) = var pos = c.bufpos var buf = c.buf - while true: + while true: add(tok.literal, buf[pos]) inc(pos) - if not (buf[pos] in SymChars): break + if not (buf[pos] in SymChars): break c.bufpos = pos tok.kind = tkSymbol -proc skip(c: var CfgParser) = +proc skip(c: var CfgParser) = var pos = c.bufpos var buf = c.buf - while true: + while true: case buf[pos] - of ' ', '\t': + of ' ', '\t': inc(pos) - of '#', ';': + of '#', ';': while not (buf[pos] in {'\c', '\L', lexbase.EndOfFile}): inc(pos) - of '\c', '\L': + of '\c', '\L': pos = handleCRLF(c, pos) buf = c.buf - else: + else: break # EndOfFile also leaves the loop c.bufpos = pos -proc rawGetTok(c: var CfgParser, tok: var Token) = +proc rawGetTok(c: var CfgParser, tok: var Token) = tok.kind = tkInvalid setLen(tok.literal, 0) skip(c) case c.buf[c.bufpos] - of '=': + of '=': tok.kind = tkEquals inc(c.bufpos) tok.literal = "=" - of '-': + of '-': inc(c.bufpos) if c.buf[c.bufpos] == '-': inc(c.bufpos) tok.kind = tkDashDash tok.literal = "--" - of ':': + of ':': tok.kind = tkColon inc(c.bufpos) tok.literal = ":" - of 'r', 'R': - if c.buf[c.bufpos + 1] == '\"': + of 'r', 'R': + if c.buf[c.bufpos + 1] == '\"': inc(c.bufpos) getString(c, tok, true) - else: + else: getSymbol(c, tok) - of '[': + of '[': tok.kind = tkBracketLe inc(c.bufpos) tok.literal = "]" - of ']': + of ']': tok.kind = tkBracketRi inc(c.bufpos) tok.literal = "]" - of '"': + of '"': getString(c, tok, false) - of lexbase.EndOfFile: + of lexbase.EndOfFile: tok.kind = tkEof tok.literal = "[EOF]" else: getSymbol(c, tok) - + proc errorStr*(c: CfgParser, msg: string): string {.rtl, extern: "npc$1".} = ## returns a properly formated error message containing current line and ## column information. - result = `%`("$1($2, $3) Error: $4", + result = `%`("$1($2, $3) Error: $4", [c.filename, $getLine(c), $getColumn(c), msg]) - + proc warningStr*(c: CfgParser, msg: string): string {.rtl, extern: "npc$1".} = ## returns a properly formated warning message containing current line and ## column information. - result = `%`("$1($2, $3) Warning: $4", + result = `%`("$1($2, $3) Warning: $4", [c.filename, $getLine(c), $getColumn(c), msg]) proc ignoreMsg*(c: CfgParser, e: CfgEvent): string {.rtl, extern: "npc$1".} = ## returns a properly formated warning message containing that ## an entry is ignored. - case e.kind + case e.kind of cfgSectionStart: result = c.warningStr("section ignored: " & e.section) of cfgKeyValuePair: result = c.warningStr("key ignored: " & e.key) - of cfgOption: + of cfgOption: result = c.warningStr("command ignored: " & e.key & ": " & e.value) of cfgError: result = e.msg of cfgEof: result = "" -proc getKeyValPair(c: var CfgParser, kind: CfgEventKind): CfgEvent = - if c.tok.kind == tkSymbol: +proc getKeyValPair(c: var CfgParser, kind: CfgEventKind): CfgEvent = + if c.tok.kind == tkSymbol: result.kind = kind result.key = c.tok.literal result.value = "" rawGetTok(c, c.tok) - if c.tok.kind in {tkEquals, tkColon}: + if c.tok.kind in {tkEquals, tkColon}: rawGetTok(c, c.tok) - if c.tok.kind == tkSymbol: + if c.tok.kind == tkSymbol: result.value = c.tok.literal - else: + else: reset result result.kind = cfgError result.msg = errorStr(c, "symbol expected, but found: " & c.tok.literal) rawGetTok(c, c.tok) - else: + else: result.kind = cfgError result.msg = errorStr(c, "symbol expected, but found: " & c.tok.literal) rawGetTok(c, c.tok) proc next*(c: var CfgParser): CfgEvent {.rtl, extern: "npc$1".} = ## retrieves the first/next event. This controls the parser. - case c.tok.kind - of tkEof: + case c.tok.kind + of tkEof: result.kind = cfgEof - of tkDashDash: + of tkDashDash: rawGetTok(c, c.tok) result = getKeyValPair(c, cfgOption) - of tkSymbol: + of tkSymbol: result = getKeyValPair(c, cfgKeyValuePair) - of tkBracketLe: + of tkBracketLe: rawGetTok(c, c.tok) - if c.tok.kind == tkSymbol: + if c.tok.kind == tkSymbol: result.kind = cfgSectionStart result.section = c.tok.literal - else: + else: result.kind = cfgError result.msg = errorStr(c, "symbol expected, but found: " & c.tok.literal) rawGetTok(c, c.tok) - if c.tok.kind == tkBracketRi: + if c.tok.kind == tkBracketRi: rawGetTok(c, c.tok) else: reset(result) result.kind = cfgError result.msg = errorStr(c, "']' expected, but found: " & c.tok.literal) - of tkInvalid, tkEquals, tkColon, tkBracketRi: + of tkInvalid, tkEquals, tkColon, tkBracketRi: result.kind = cfgError result.msg = errorStr(c, "invalid token: " & c.tok.literal) rawGetTok(c, c.tok) diff --git a/lib/pure/parsecsv.nim b/lib/pure/parsecsv.nim index 117d75cfa7..af51e12012 100644 --- a/lib/pure/parsecsv.nim +++ b/lib/pure/parsecsv.nim @@ -8,7 +8,7 @@ # ## This module implements a simple high performance `CSV`:idx: -## (`comma separated value`:idx:) parser. +## (`comma separated value`:idx:) parser. ## ## Example: How to use the parser ## ============================== @@ -43,7 +43,7 @@ type {.deprecated: [TCsvRow: CsvRow, TCsvParser: CsvParser, EInvalidCsv: CsvError].} -proc raiseEInvalidCsv(filename: string, line, col: int, +proc raiseEInvalidCsv(filename: string, line, col: int, msg: string) {.noreturn.} = var e: ref CsvError new(e) @@ -60,13 +60,13 @@ proc open*(my: var CsvParser, input: Stream, filename: string, ## for nice error messages. The parser's behaviour can be controlled by ## the diverse optional parameters: ## - `separator`: character used to separate fields - ## - `quote`: Used to quote fields containing special characters like + ## - `quote`: Used to quote fields containing special characters like ## `separator`, `quote` or new-line characters. '\0' disables the parsing ## of quotes. - ## - `escape`: removes any special meaning from the following character; + ## - `escape`: removes any special meaning from the following character; ## '\0' disables escaping; if escaping is disabled and `quote` is not '\0', ## two `quote` characters are parsed one literal `quote` character. - ## - `skipInitialSpace`: If true, whitespace immediately following the + ## - `skipInitialSpace`: If true, whitespace immediately following the ## `separator` is ignored. lexbase.open(my, input) my.filename = filename @@ -77,13 +77,13 @@ proc open*(my: var CsvParser, input: Stream, filename: string, my.row = @[] my.currRow = 0 -proc parseField(my: var CsvParser, a: var string) = +proc parseField(my: var CsvParser, a: var string) = var pos = my.bufpos var buf = my.buf if my.skipWhite: while buf[pos] in {' ', '\t'}: inc(pos) setLen(a, 0) # reuse memory - if buf[pos] == my.quote and my.quote != '\0': + if buf[pos] == my.quote and my.quote != '\0': inc(pos) while true: var c = buf[pos] @@ -91,7 +91,7 @@ proc parseField(my: var CsvParser, a: var string) = my.bufpos = pos # can continue after exception? error(my, pos, my.quote & " expected") break - elif c == my.quote: + elif c == my.quote: if my.esc == '\0' and buf[pos+1] == my.quote: add(a, my.quote) inc(pos, 2) @@ -103,11 +103,11 @@ proc parseField(my: var CsvParser, a: var string) = inc(pos, 2) else: case c - of '\c': + of '\c': pos = handleCR(my, pos) buf = my.buf add(a, "\n") - of '\l': + of '\l': pos = handleLF(my, pos) buf = my.buf add(a, "\n") @@ -123,11 +123,11 @@ proc parseField(my: var CsvParser, a: var string) = inc(pos) my.bufpos = pos -proc processedRows*(my: var CsvParser): int = +proc processedRows*(my: var CsvParser): int = ## returns number of the processed rows return my.currRow -proc readRow*(my: var CsvParser, columns = 0): bool = +proc readRow*(my: var CsvParser, columns = 0): bool = ## reads the next row; if `columns` > 0, it expects the row to have ## exactly this many columns. Returns false if the end of the file ## has been encountered else true. @@ -140,13 +140,13 @@ proc readRow*(my: var CsvParser, columns = 0): bool = my.row[col] = "" parseField(my, my.row[col]) inc(col) - if my.buf[my.bufpos] == my.sep: + if my.buf[my.bufpos] == my.sep: inc(my.bufpos) else: case my.buf[my.bufpos] - of '\c', '\l': + of '\c', '\l': # skip empty lines: - while true: + while true: case my.buf[my.bufpos] of '\c': my.bufpos = handleCR(my, my.bufpos) of '\l': my.bufpos = handleLF(my, my.bufpos) @@ -154,15 +154,15 @@ proc readRow*(my: var CsvParser, columns = 0): bool = of '\0': discard else: error(my, my.bufpos, my.sep & " expected") break - + setLen(my.row, col) result = col > 0 - if result and col != columns and columns > 0: - error(my, oldpos+1, $columns & " columns expected, but found " & + if result and col != columns and columns > 0: + error(my, oldpos+1, $columns & " columns expected, but found " & $col & " columns") inc(my.currRow) - -proc close*(my: var CsvParser) {.inline.} = + +proc close*(my: var CsvParser) {.inline.} = ## closes the parser `my` and its associated input stream. lexbase.close(my) diff --git a/lib/pure/parsesql.nim b/lib/pure/parsesql.nim index cfa60094d1..d6fafec08a 100644 --- a/lib/pure/parsesql.nim +++ b/lib/pure/parsesql.nim @@ -7,7 +7,7 @@ # distribution, for details about the copyright. # -## The ``parsesql`` module implements a high performance SQL file +## The ``parsesql`` module implements a high performance SQL file ## parser. It parses PostgreSQL syntax and the SQL ANSI standard. import @@ -37,11 +37,11 @@ type tkBracketLe, ## '[' tkBracketRi, ## ']' tkDot ## '.' - + Token = object # a token kind: TokKind # the type of the token literal: string # the parsed (string) literal - + SqlLexer* = object of BaseLexer ## the parser object. filename: string @@ -55,82 +55,82 @@ const ";", ":", ",", "(", ")", "[", "]", "." ] -proc open(L: var SqlLexer, input: Stream, filename: string) = +proc open(L: var SqlLexer, input: Stream, filename: string) = lexbase.open(L, input) L.filename = filename - -proc close(L: var SqlLexer) = + +proc close(L: var SqlLexer) = lexbase.close(L) -proc getColumn(L: SqlLexer): int = +proc getColumn(L: SqlLexer): int = ## get the current column the parser has arrived at. result = getColNumber(L, L.bufpos) -proc getLine(L: SqlLexer): int = +proc getLine(L: SqlLexer): int = result = L.lineNumber -proc handleHexChar(c: var SqlLexer, xi: var int) = +proc handleHexChar(c: var SqlLexer, xi: var int) = case c.buf[c.bufpos] - of '0'..'9': + of '0'..'9': xi = (xi shl 4) or (ord(c.buf[c.bufpos]) - ord('0')) inc(c.bufpos) - of 'a'..'f': + of 'a'..'f': xi = (xi shl 4) or (ord(c.buf[c.bufpos]) - ord('a') + 10) inc(c.bufpos) - of 'A'..'F': + of 'A'..'F': xi = (xi shl 4) or (ord(c.buf[c.bufpos]) - ord('A') + 10) inc(c.bufpos) - else: + else: discard -proc handleOctChar(c: var SqlLexer, xi: var int) = +proc handleOctChar(c: var SqlLexer, xi: var int) = if c.buf[c.bufpos] in {'0'..'7'}: xi = (xi shl 3) or (ord(c.buf[c.bufpos]) - ord('0')) inc(c.bufpos) -proc getEscapedChar(c: var SqlLexer, tok: var Token) = +proc getEscapedChar(c: var SqlLexer, tok: var Token) = inc(c.bufpos) case c.buf[c.bufpos] - of 'n', 'N': + of 'n', 'N': add(tok.literal, '\L') inc(c.bufpos) - of 'r', 'R', 'c', 'C': + of 'r', 'R', 'c', 'C': add(tok.literal, '\c') inc(c.bufpos) - of 'l', 'L': + of 'l', 'L': add(tok.literal, '\L') inc(c.bufpos) - of 'f', 'F': + of 'f', 'F': add(tok.literal, '\f') inc(c.bufpos) - of 'e', 'E': + of 'e', 'E': add(tok.literal, '\e') inc(c.bufpos) - of 'a', 'A': + of 'a', 'A': add(tok.literal, '\a') inc(c.bufpos) - of 'b', 'B': + of 'b', 'B': add(tok.literal, '\b') inc(c.bufpos) - of 'v', 'V': + of 'v', 'V': add(tok.literal, '\v') inc(c.bufpos) - of 't', 'T': + of 't', 'T': add(tok.literal, '\t') inc(c.bufpos) - of '\'', '\"': + of '\'', '\"': add(tok.literal, c.buf[c.bufpos]) inc(c.bufpos) - of '\\': + of '\\': add(tok.literal, '\\') inc(c.bufpos) - of 'x', 'X': + of 'x', 'X': inc(c.bufpos) var xi = 0 handleHexChar(c, xi) handleHexChar(c, xi) add(tok.literal, chr(xi)) - of '0'..'7': + of '0'..'7': var xi = 0 handleOctChar(c, xi) handleOctChar(c, xi) @@ -138,20 +138,20 @@ proc getEscapedChar(c: var SqlLexer, tok: var Token) = if (xi <= 255): add(tok.literal, chr(xi)) else: tok.kind = tkInvalid else: tok.kind = tkInvalid - -proc handleCRLF(c: var SqlLexer, pos: int): int = + +proc handleCRLF(c: var SqlLexer, pos: int): int = case c.buf[pos] of '\c': result = lexbase.handleCR(c, pos) of '\L': result = lexbase.handleLF(c, pos) else: result = pos -proc skip(c: var SqlLexer) = +proc skip(c: var SqlLexer) = var pos = c.bufpos var buf = c.buf var nested = 0 - while true: + while true: case buf[pos] - of ' ', '\t': + of ' ', '\t': inc(pos) of '-': if buf[pos+1] == '-': @@ -164,7 +164,7 @@ proc skip(c: var SqlLexer) = while true: case buf[pos] of '\0': break - of '\c', '\L': + of '\c', '\L': pos = handleCRLF(c, pos) buf = c.buf of '*': @@ -182,20 +182,20 @@ proc skip(c: var SqlLexer) = inc(pos) else: inc(pos) else: break - of '\c', '\L': + of '\c', '\L': pos = handleCRLF(c, pos) buf = c.buf - else: + else: break # EndOfFile also leaves the loop c.bufpos = pos - -proc getString(c: var SqlLexer, tok: var Token, kind: TokKind) = + +proc getString(c: var SqlLexer, tok: var Token, kind: TokKind) = var pos = c.bufpos + 1 var buf = c.buf tok.kind = kind block parseLoop: while true: - while true: + while true: var ch = buf[pos] if ch == '\'': if buf[pos+1] == '\'': @@ -203,15 +203,15 @@ proc getString(c: var SqlLexer, tok: var Token, kind: TokKind) = add(tok.literal, '\'') else: inc(pos) - break - elif ch in {'\c', '\L', lexbase.EndOfFile}: + break + elif ch in {'\c', '\L', lexbase.EndOfFile}: tok.kind = tkInvalid break parseLoop - elif (ch == '\\') and kind == tkEscapeConstant: + elif (ch == '\\') and kind == tkEscapeConstant: c.bufpos = pos getEscapedChar(c, tok) pos = c.bufpos - else: + else: add(tok.literal, ch) inc(pos) c.bufpos = pos @@ -227,7 +227,7 @@ proc getString(c: var SqlLexer, tok: var Token, kind: TokKind) = else: break parseLoop c.bufpos = pos -proc getDollarString(c: var SqlLexer, tok: var Token) = +proc getDollarString(c: var SqlLexer, tok: var Token) = var pos = c.bufpos + 1 var buf = c.buf tok.kind = tkDollarQuotedConstant @@ -241,7 +241,7 @@ proc getDollarString(c: var SqlLexer, tok: var Token) = return while true: case buf[pos] - of '\c', '\L': + of '\c', '\L': pos = handleCRLF(c, pos) buf = c.buf add(tok.literal, "\L") @@ -263,10 +263,10 @@ proc getDollarString(c: var SqlLexer, tok: var Token) = inc(pos) c.bufpos = pos -proc getSymbol(c: var SqlLexer, tok: var Token) = +proc getSymbol(c: var SqlLexer, tok: var Token) = var pos = c.bufpos var buf = c.buf - while true: + while true: add(tok.literal, buf[pos]) inc(pos) if buf[pos] notin {'a'..'z','A'..'Z','0'..'9','_','$', '\128'..'\255'}: @@ -274,7 +274,7 @@ proc getSymbol(c: var SqlLexer, tok: var Token) = c.bufpos = pos tok.kind = tkIdentifier -proc getQuotedIdentifier(c: var SqlLexer, tok: var Token) = +proc getQuotedIdentifier(c: var SqlLexer, tok: var Token) = var pos = c.bufpos + 1 var buf = c.buf tok.kind = tkQuotedIdentifier @@ -287,7 +287,7 @@ proc getQuotedIdentifier(c: var SqlLexer, tok: var Token) = else: inc(pos) break - elif ch in {'\c', '\L', lexbase.EndOfFile}: + elif ch in {'\c', '\L', lexbase.EndOfFile}: tok.kind = tkInvalid break else: @@ -300,15 +300,15 @@ proc getBitHexString(c: var SqlLexer, tok: var Token, validChars: set[char]) = var buf = c.buf block parseLoop: while true: - while true: + while true: var ch = buf[pos] if ch in validChars: add(tok.literal, ch) - inc(pos) + inc(pos) elif ch == '\'': inc(pos) break - else: + else: tok.kind = tkInvalid break parseLoop c.bufpos = pos @@ -353,7 +353,7 @@ proc getNumeric(c: var SqlLexer, tok: var Token) = inc(pos) else: tok.kind = tkInvalid - c.bufpos = pos + c.bufpos = pos proc getOperator(c: var SqlLexer, tok: var Token) = const operators = {'+', '-', '*', '/', '<', '>', '=', '~', '!', '@', '#', '%', @@ -381,12 +381,12 @@ proc getOperator(c: var SqlLexer, tok: var Token) = inc(pos) c.bufpos = pos -proc getTok(c: var SqlLexer, tok: var Token) = +proc getTok(c: var SqlLexer, tok: var Token) = tok.kind = tkInvalid setLen(tok.literal, 0) skip(c) case c.buf[c.bufpos] - of ';': + of ';': tok.kind = tkSemicolon inc(c.bufpos) add(tok.literal, ';') @@ -394,15 +394,15 @@ proc getTok(c: var SqlLexer, tok: var Token) = tok.kind = tkComma inc(c.bufpos) add(tok.literal, ',') - of ':': + of ':': tok.kind = tkColon inc(c.bufpos) add(tok.literal, ':') - of 'e', 'E': - if c.buf[c.bufpos + 1] == '\'': + of 'e', 'E': + if c.buf[c.bufpos + 1] == '\'': inc(c.bufpos) getString(c, tok, tkEscapeConstant) - else: + else: getSymbol(c, tok) of 'b', 'B': if c.buf[c.bufpos + 1] == '\'': @@ -417,11 +417,11 @@ proc getTok(c: var SqlLexer, tok: var Token) = else: getSymbol(c, tok) of '$': getDollarString(c, tok) - of '[': + of '[': tok.kind = tkBracketLe inc(c.bufpos) add(tok.literal, '[') - of ']': + of ']': tok.kind = tkBracketRi inc(c.bufpos) add(tok.literal, ']') @@ -433,7 +433,7 @@ proc getTok(c: var SqlLexer, tok: var Token) = tok.kind = tkParRi inc(c.bufpos) add(tok.literal, ')') - of '.': + of '.': if c.buf[c.bufpos + 1] in Digits: getNumeric(c, tok) else: @@ -443,7 +443,7 @@ proc getTok(c: var SqlLexer, tok: var Token) = of '0'..'9': getNumeric(c, tok) of '\'': getString(c, tok, tkStringConstant) of '"': getQuotedIdentifier(c, tok) - of lexbase.EndOfFile: + of lexbase.EndOfFile: tok.kind = tkEof tok.literal = "[EOF]" of 'a', 'c', 'd', 'f'..'w', 'y', 'z', 'A', 'C', 'D', 'F'..'W', 'Y', 'Z', '_', @@ -455,8 +455,8 @@ proc getTok(c: var SqlLexer, tok: var Token) = else: add(tok.literal, c.buf[c.bufpos]) inc(c.bufpos) - -proc errorStr(L: SqlLexer, msg: string): string = + +proc errorStr(L: SqlLexer, msg: string): string = result = "$1($2, $3) Error: $4" % [L.filename, $getLine(L), $getColumn(L), msg] @@ -496,7 +496,7 @@ type nkPrimaryKey, nkForeignKey, nkNotNull, - + nkStmtList, nkDot, nkDotDot, @@ -530,13 +530,13 @@ type nkValueList, nkWhere, nkCreateTable, - nkCreateTableIfNotExists, + nkCreateTableIfNotExists, nkCreateType, nkCreateTypeIfNotExists, nkCreateIndex, nkCreateIndexIfNotExists, nkEnumDef - + type SqlParseError* = object of ValueError ## Invalid SQL encountered SqlNode* = ref SqlNodeObj ## an SQL abstract syntax tree node @@ -563,11 +563,11 @@ proc newNode(k: SqlNodeKind, s: string): SqlNode = new(result) result.kind = k result.strVal = s - + proc len*(n: SqlNode): int = if isNil(n.sons): result = 0 else: result = n.sons.len - + proc add*(father, n: SqlNode) = if isNil(father.sons): father.sons = @[] add(father.sons, n) @@ -641,11 +641,11 @@ proc parseDataType(p: var SqlParser): SqlNode = getTok(p) eat(p, tkParRi) -proc getPrecedence(p: SqlParser): int = +proc getPrecedence(p: SqlParser): int = if isOpr(p, "*") or isOpr(p, "/") or isOpr(p, "%"): result = 6 elif isOpr(p, "+") or isOpr(p, "-"): - result = 5 + result = 5 elif isOpr(p, "=") or isOpr(p, "<") or isOpr(p, ">") or isOpr(p, ">=") or isOpr(p, "<=") or isOpr(p, "<>") or isOpr(p, "!=") or isKeyw(p, "is") or isKeyw(p, "like"): @@ -664,7 +664,7 @@ proc parseExpr(p: var SqlParser): SqlNode proc identOrLiteral(p: var SqlParser): SqlNode = case p.tok.kind - of tkIdentifier, tkQuotedIdentifier: + of tkIdentifier, tkQuotedIdentifier: result = newNode(nkIdent, p.tok.literal) getTok(p) of tkStringConstant, tkEscapeConstant, tkDollarQuotedConstant: @@ -686,21 +686,21 @@ proc identOrLiteral(p: var SqlParser): SqlNode = getTok(p) result = parseExpr(p) eat(p, tkParRi) - else: + else: sqlError(p, "expression expected") getTok(p) # we must consume a token here to prevend endless loops! -proc primary(p: var SqlParser): SqlNode = - if p.tok.kind == tkOperator or isKeyw(p, "not"): +proc primary(p: var SqlParser): SqlNode = + if p.tok.kind == tkOperator or isKeyw(p, "not"): result = newNode(nkPrefix) result.add(newNode(nkIdent, p.tok.literal)) getTok(p) result.add(primary(p)) return result = identOrLiteral(p) - while true: + while true: case p.tok.kind - of tkParLe: + of tkParLe: var a = result result = newNode(nkCall) result.add(a) @@ -710,7 +710,7 @@ proc primary(p: var SqlParser): SqlNode = if p.tok.kind == tkComma: getTok(p) else: break eat(p, tkParRi) - of tkDot: + of tkDot: getTok(p) var a = result if p.tok.kind == tkDot: @@ -727,14 +727,14 @@ proc primary(p: var SqlParser): SqlNode = sqlError(p, "identifier expected") getTok(p) else: break - -proc lowestExprAux(p: var SqlParser, v: var SqlNode, limit: int): int = + +proc lowestExprAux(p: var SqlParser, v: var SqlNode, limit: int): int = var v2, node, opNode: SqlNode v = primary(p) # expand while operators have priorities higher than 'limit' var opPred = getPrecedence(p) result = opPred - while opPred > limit: + while opPred > limit: node = newNode(nkInfix) opNode = newNode(nkIdent, p.tok.literal) getTok(p) @@ -744,8 +744,8 @@ proc lowestExprAux(p: var SqlParser, v: var SqlNode, limit: int): int = node.add(v2) v = node opPred = getPrecedence(p) - -proc parseExpr(p: var SqlParser): SqlNode = + +proc parseExpr(p: var SqlParser): SqlNode = discard lowestExprAux(p, result, - 1) proc parseTableName(p: var SqlParser): SqlNode = @@ -765,7 +765,7 @@ proc parseColumnReference(p: var SqlParser): SqlNode = result.add(parseTableName(p)) eat(p, tkParRi) -proc parseCheck(p: var SqlParser): SqlNode = +proc parseCheck(p: var SqlParser): SqlNode = getTok(p) result = newNode(nkCheck) result.add(parseExpr(p)) @@ -817,9 +817,9 @@ proc parseColumnDef(p: var SqlParser): SqlNode = result.add(newNode(nkIdent, p.tok.literal)) getTok(p) result.add(parseDataType(p)) - parseColumnConstraints(p, result) + parseColumnConstraints(p, result) -proc parseIfNotExists(p: var SqlParser, k: SqlNodeKind): SqlNode = +proc parseIfNotExists(p: var SqlParser, k: SqlNodeKind): SqlNode = getTok(p) if isKeyw(p, "if"): getTok(p) @@ -880,7 +880,7 @@ proc parseTableDef(p: var SqlParser): SqlNode = result.add(parseTableConstraint(p)) if p.tok.kind != tkComma: break eat(p, tkParRi) - + proc parseTypeDef(p: var SqlParser): SqlNode = result = parseIfNotExists(p, nkCreateType) expectIdent(p) @@ -966,7 +966,7 @@ proc parseUpdate(p: var SqlParser): SqlNode = result.add(parseWhere(p)) else: result.add(nil) - + proc parseDelete(p: var SqlParser): SqlNode = getTok(p) result = newNode(nkDelete) @@ -1018,14 +1018,14 @@ proc parseSelect(p: var SqlParser): SqlNode = while true: getTok(p) h.add(parseExpr(p)) - if p.tok.kind != tkComma: break + if p.tok.kind != tkComma: break result.add(h) if isKeyw(p, "union"): result.add(newNode(nkUnion)) getTok(p) elif isKeyw(p, "intersect"): result.add(newNode(nkIntersect)) - getTok(p) + getTok(p) elif isKeyw(p, "except"): result.add(newNode(nkExcept)) getTok(p) @@ -1083,7 +1083,7 @@ proc open(p: var SqlParser, input: Stream, filename: string) = p.tok.kind = tkInvalid p.tok.literal = "" getTok(p) - + proc parse(p: var SqlParser): SqlNode = ## parses the content of `p`'s input stream and returns the SQL AST. ## Syntax errors raise an `EInvalidSql` exception. @@ -1094,13 +1094,13 @@ proc parse(p: var SqlParser): SqlNode = result.add(s) if result.len == 1: result = result.sons[0] - + proc close(p: var SqlParser) = ## closes the parser `p`. The associated input stream is closed too. close(SqlLexer(p)) proc parseSQL*(input: Stream, filename: string): SqlNode = - ## parses the SQL from `input` into an AST and returns the AST. + ## parses the SQL from `input` into an AST and returns the AST. ## `filename` is only used for error messages. ## Syntax errors raise an `EInvalidSql` exception. var p: SqlParser @@ -1114,7 +1114,7 @@ proc ra(n: SqlNode, s: var string, indent: int) proc rs(n: SqlNode, s: var string, indent: int, prefix = "(", suffix = ")", - sep = ", ") = + sep = ", ") = if n.len > 0: s.add(prefix) for i in 0 .. n.len-1: @@ -1162,7 +1162,7 @@ proc ra(n: SqlNode, s: var string, indent: int) = ra(n.sons[1], s, indent) s.add(')') of nkInfix: - s.add('(') + s.add('(') ra(n.sons[1], s, indent) s.add(' ') ra(n.sons[0], s, indent) @@ -1207,13 +1207,13 @@ proc ra(n: SqlNode, s: var string, indent: int) = s.add("insert into ") ra(n.sons[0], s, indent) ra(n.sons[1], s, indent) - if n.sons[2].kind == nkDefault: + if n.sons[2].kind == nkDefault: s.add("default values") else: s.add("\nvalues ") ra(n.sons[2], s, indent) s.add(';') - of nkUpdate: + of nkUpdate: s.add("update ") ra(n.sons[0], s, indent) s.add(" set ") @@ -1225,7 +1225,7 @@ proc ra(n: SqlNode, s: var string, indent: int) = ra(it, s, indent) ra(n.sons[L-1], s, indent) s.add(';') - of nkDelete: + of nkDelete: s.add("delete from ") ra(n.sons[0], s, indent) ra(n.sons[1], s, indent) @@ -1237,12 +1237,12 @@ proc ra(n: SqlNode, s: var string, indent: int) = rs(n.sons[0], s, indent, "", "", ", ") for i in 1 .. n.len-1: ra(n.sons[i], s, indent) s.add(';') - of nkSelectColumns: + of nkSelectColumns: assert(false) of nkAsgn: ra(n.sons[0], s, indent) s.add(" = ") - ra(n.sons[1], s, indent) + ra(n.sons[1], s, indent) of nkFrom: s.add("\nfrom ") rs(n, s, indent, "", "", ", ") @@ -1306,23 +1306,23 @@ proc ra(n: SqlNode, s: var string, indent: int) = s.add("enum ") rs(n, s, indent) -# What I want: +# What I want: # -#select(columns = [T1.all, T2.name], +#select(columns = [T1.all, T2.name], # fromm = [T1, T2], # where = T1.name ==. T2.name, # orderby = [name]): -# -#for row in dbQuery(db, """select x, y, z -# from a, b +# +#for row in dbQuery(db, """select x, y, z +# from a, b # where a.name = b.name"""): -# +# #select x, y, z: # fromm: Table1, Table2 # where: x.name == y.name #db.select(fromm = [t1, t2], where = t1.name == t2.name): -#for x, y, z in db.select(fromm = a, b where = a.name == b.name): +#for x, y, z in db.select(fromm = a, b where = a.name == b.name): # writeLine x, y, z proc renderSQL*(n: SqlNode): string = @@ -1338,7 +1338,7 @@ when not defined(testing) and isMainModule: happiness happiness ); CREATE INDEX table1_attr1 ON table1(attr1); - + SELECT * FROM myTab WHERE col1 = 'happy'; """), "stdin"))) diff --git a/lib/pure/parseurl.nim b/lib/pure/parseurl.nim index 56bf107688..6d58e8a73c 100644 --- a/lib/pure/parseurl.nim +++ b/lib/pure/parseurl.nim @@ -19,7 +19,7 @@ import strutils type Url* = tuple[ ## represents a *Uniform Resource Locator* (URL) ## any optional component is "" if it does not exist - scheme, username, password, + scheme, username, password, hostname, port, path, query, anchor: string] {.deprecated: [TUrl: Url].} @@ -31,7 +31,7 @@ proc parseUrl*(url: string): Url {.deprecated.} = var hostname, port, path, query, anchor: string = "" var temp = "" - + if url[i] != '/': # url isn't a relative path while true: # Scheme @@ -48,7 +48,7 @@ proc parseUrl*(url: string): Url {.deprecated.} = password = username.substr(colon+1) username = username.substr(0, colon-1) temp.setLen(0) - inc(i) #Skip the @ + inc(i) #Skip the @ # hostname(subdomain, domain, port) if url[i] == '/' or url[i] == '\0': hostname = temp @@ -56,10 +56,10 @@ proc parseUrl*(url: string): Url {.deprecated.} = if colon >= 0: port = hostname.substr(colon+1) hostname = hostname.substr(0, colon-1) - + temp.setLen(0) break - + temp.add(url[i]) inc(i) @@ -75,7 +75,7 @@ proc parseUrl*(url: string): Url {.deprecated.} = else: path = temp temp.setLen(0) - + if url[i] == '\0': if temp[0] == '?': query = temp @@ -84,10 +84,10 @@ proc parseUrl*(url: string): Url {.deprecated.} = else: path = temp break - + temp.add(url[i]) inc(i) - + return (scheme, username, password, hostname, port, path, query, anchor) proc `$`*(u: Url): string {.deprecated.} = @@ -103,12 +103,12 @@ proc `$`*(u: Url): string {.deprecated.} = result.add(u.password) result.add("@") result.add(u.hostname) - if u.port.len > 0: + if u.port.len > 0: result.add(":") result.add(u.port) - if u.path.len > 0: + if u.path.len > 0: result.add("/") result.add(u.path) result.add(u.query) result.add(u.anchor) - + diff --git a/lib/pure/poly.nim b/lib/pure/poly.nim index 58dcdc1ad7..c523004005 100644 --- a/lib/pure/poly.nim +++ b/lib/pure/poly.nim @@ -11,7 +11,7 @@ import math import strutils import numeric -type +type Poly* = object cofs:seq[float] @@ -40,7 +40,7 @@ proc `[]` *(p:Poly;idx:int):float= if idx<0 or idx>p.degree: return 0.0 return p.cofs[idx] - + proc `[]=` *(p:var Poly;idx:int,v:float)= ## Sets an coefficient of the polynomial by index. ## p[2] set the quadric term, p[3] the cubic etc. @@ -55,15 +55,15 @@ proc `[]=` *(p:var Poly;idx:int,v:float)= p.cofs[q]=0.0 #new-grown coefficients set to zero p.cofs[idx]=v - - + + iterator items*(p:Poly):float= ## Iterates through the coefficients of the polynomial. var i=p.degree while i>=0: yield p[i] - dec i - + dec i + proc clean*(p:var Poly;zerotol=0.0)= ## Removes leading zero coefficients of the polynomial. ## An optional tolerance can be given for what's considered zero. @@ -77,19 +77,19 @@ proc clean*(p:var Poly;zerotol=0.0)= if relen: p.cofs.setLen(n+1) -proc `$` *(p:Poly):string = +proc `$` *(p:Poly):string = ## Gets a somewhat reasonable string representation of the polynomial ## The format should be compatible with most online function plotters, ## for example directly in google search result="" var first=true #might skip + sign if first coefficient - + for idx in countdown(p.degree,0): let a=p[idx] - + if a==0.0: continue - + if a>= 0.0 and not first: result.add('+') first=false @@ -103,14 +103,14 @@ proc `$` *(p:Poly):string = if result=="": result="0" - + proc derivative*(p: Poly): Poly= ## Returns a new polynomial, which is the derivative of `p` newSeq[float](result.cofs,p.degree) for idx in 0..high(result.cofs): result.cofs[idx]=p.cofs[idx+1]*float(idx+1) - + proc diff*(p:Poly,x:float):float= ## Evaluates the differentiation of a polynomial with ## respect to `x` quickly using a modifed Horners method @@ -128,7 +128,7 @@ proc integral*(p:Poly):Poly= result.cofs[0]=0.0 #constant arbitrary term, use 0.0 for i in 1..high(result.cofs): result.cofs[i]=p.cofs[i-1]/float(i) - + proc integrate*(p:Poly;xmin,xmax:float):float= ## Computes the definite integral of `p` between `xmin` and `xmax` @@ -145,9 +145,9 @@ proc integrate*(p:Poly;xmin,xmax:float):float= s1 = s1*xmin+fac s2 = s2*xmax+fac dec n - + result=s2*xmax-s1*xmin - + proc initPoly*(cofs:varargs[float]):Poly= ## Initializes a polynomial with given coefficients. ## The most significant coefficient is first, so to create x^2-2x+3: @@ -158,7 +158,7 @@ proc initPoly*(cofs:varargs[float]):Poly= # reverse order of coefficients so indexing matches degree of # coefficient... result.cofs= @[] - for idx in countdown(cofs.len-1,0): + for idx in countdown(cofs.len-1,0): result.cofs.add(cofs[idx]) result.clean #remove leading zero terms @@ -167,49 +167,49 @@ proc initPoly*(cofs:varargs[float]):Poly= proc divMod*(p,d:Poly;q,r:var Poly)= ## Divides `p` with `d`, and stores the quotinent in `q` and ## the remainder in `d` - var + var pdeg=p.degree ddeg=d.degree power=p.degree-d.degree ratio:float - + r.cofs = p.cofs #initial remainder=numerator if power<0: #denominator is larger than numerator q.cofs= @ [0.0] #quotinent is 0.0 return # keep remainder as numerator - + q.cofs=newSeq[float](power+1) - + for i in countdown(pdeg,ddeg): ratio=r.cofs[i]/d.cofs[ddeg] - + q.cofs[i-ddeg]=ratio r.cofs[i]=0.0 - + for j in countup(0,=res[high(res)]+mergetol: #dont add equal roots. - res.add(br.rootx) + res.add(br.rootx) else: #this might be a 'touching' case, check function value against #zero tolerance if abs(br.rooty)<=zerotol: if res.len==0 or br.rootx>=res[high(res)]+mergetol: #dont add equal roots. - res.add(br.rootx) + res.add(br.rootx) proc roots*(p:Poly,tol=1.0e-9,zerotol=1.0e-6,mergetol=1.0e-12,maxiter=1000):seq[float]= diff --git a/lib/pure/rationals.nim b/lib/pure/rationals.nim index 8e1dbe4641..60d09c71ac 100644 --- a/lib/pure/rationals.nim +++ b/lib/pure/rationals.nim @@ -216,7 +216,7 @@ proc hash*[T](x: Rational[T]): Hash = h = h !& hash(copy.num) h = h !& hash(copy.den) result = !$h - + when isMainModule: var z = Rational[int](num: 0, den: 1) diff --git a/lib/pure/redis.nim b/lib/pure/redis.nim index b738e40949..e3f18a4966 100644 --- a/lib/pure/redis.nim +++ b/lib/pure/redis.nim @@ -11,7 +11,7 @@ ## redis-server instance, send commands and receive replies. ## ## **Beware**: Most (if not all) functions that return a ``RedisString`` may -## return ``redisNil``, and functions which return a ``RedisList`` +## return ``redisNil``, and functions which return a ``RedisList`` ## may return ``nil``. import sockets, os, strutils, parseutils @@ -19,7 +19,7 @@ import sockets, os, strutils, parseutils const redisNil* = "\0\0" -type +type Pipeline = ref object enabled: bool buffer: string @@ -34,7 +34,7 @@ type socket: Socket connected: bool pipeline: Pipeline - + RedisStatus* = string RedisInteger* = BiggestInt RedisString* = string ## Bulk reply @@ -59,10 +59,10 @@ proc open*(host = "localhost", port = 6379.Port): Redis = if result.socket == invalidSocket: raiseOSError(osLastError()) result.socket.connect(host, port) - result.pipeline = newPipeline() + result.pipeline = newPipeline() proc raiseInvalidReply(expected, got: char) = - raise newException(ReplyError, + raise newException(ReplyError, "Expected '$1' at the beginning of a status reply got '$2'" % [$expected, $got]) @@ -90,16 +90,16 @@ proc parseStatus(r: Redis, line: string = ""): RedisStatus = raise newException(RedisError, strip(line)) if line[0] != '+': raiseInvalidReply('+', line[0]) - + return line.substr(1) # Strip '+' proc readStatus(r:Redis): RedisStatus = r.readSocket("PIPELINED") return r.parseStatus(line) - + proc parseInteger(r: Redis, line: string = ""): RedisInteger = if r.pipeline.enabled: return -1 - + #if line == "+QUEUED": # inside of multi # return -1 @@ -110,10 +110,10 @@ proc parseInteger(r: Redis, line: string = ""): RedisInteger = raise newException(RedisError, strip(line)) if line[0] != ':': raiseInvalidReply(':', line[0]) - + # Strip ':' if parseBiggestInt(line, result, 1) == 0: - raise newException(ReplyError, "Unable to parse integer.") + raise newException(ReplyError, "Unable to parse integer.") proc readInteger(r: Redis): RedisInteger = r.readSocket(-1) @@ -126,19 +126,19 @@ proc recv(sock: Socket, size: int): TaintedString = proc parseSingleString(r: Redis, line:string, allowMBNil = false): RedisString = if r.pipeline.enabled: return "" - + # Error. if line[0] == '-': raise newException(RedisError, strip(line)) - + # Some commands return a /bulk/ value or a /multi-bulk/ nil. Odd. if allowMBNil: if line == "*-1": return redisNil - + if line[0] != '$': raiseInvalidReply('$', line[0]) - + var numBytes = parseInt(line.substr(1)) if numBytes == -1: return redisNil @@ -168,7 +168,7 @@ proc parseArrayLines(r: Redis, countLine:string): RedisList = proc readArrayLines(r: Redis): RedisList = r.readSocket(nil) - return r.parseArrayLines(line) + return r.parseArrayLines(line) proc parseBulkString(r: Redis, allowMBNil = false, line:string = ""): RedisString = if r.pipeline.enabled: return "" @@ -191,7 +191,7 @@ proc readNext(r: Redis): RedisList = of ':': @[$(r.parseInteger(line))] of '$': @[r.parseBulkString(true,line)] of '*': r.parseArrayLines(line) - else: + else: raise newException(ReplyError, "readNext failed on line: " & line) nil r.pipeline.expected -= 1 @@ -202,10 +202,10 @@ proc flushPipeline*(r: Redis, wasMulti = false): RedisList = if r.pipeline.buffer.len > 0: r.socket.send(r.pipeline.buffer) r.pipeline.buffer = "" - + r.pipeline.enabled = false result = @[] - + var tot = r.pipeline.expected for i in 0..tot-1: @@ -232,7 +232,7 @@ proc sendCommand(r: Redis, cmd: string, args: varargs[string]) = for i in items(args): request.add("$" & $i.len() & "\c\L") request.add(i & "\c\L") - + if r.pipeline.enabled: r.pipeline.buffer.add(request) r.pipeline.expected += 1 @@ -249,7 +249,7 @@ proc sendCommand(r: Redis, cmd: string, arg1: string, for i in items(args): request.add("$" & $i.len() & "\c\L") request.add(i & "\c\L") - + if r.pipeline.enabled: r.pipeline.expected += 1 r.pipeline.buffer.add(request) @@ -275,7 +275,7 @@ proc expire*(r: Redis, key: string, seconds: int): bool = return r.readInteger() == 1 proc expireAt*(r: Redis, key: string, timestamp: int): bool = - ## Set the expiration for a key as a UNIX timestamp. Returns `false` + ## Set the expiration for a key as a UNIX timestamp. Returns `false` ## if the key could not be found or the timeout could not be set. r.sendCommand("EXPIREAT", key, $timestamp) return r.readInteger() == 1 @@ -301,7 +301,7 @@ proc scan*(r: Redis, cursor: var BiggestInt, pattern: string): RedisList = cursor = strutils.parseBiggestInt(reply[0]) return reply[1..high(reply)] -proc scan*(r: Redis, cursor: var BiggestInt, pattern: string, count: int): RedisList = +proc scan*(r: Redis, cursor: var BiggestInt, pattern: string, count: int): RedisList = ## Find all keys matching the given pattern and yield it to client in portions ## using cursor as a client query identifier. r.sendCommand("SCAN", $cursor, ["MATCH", pattern, "COUNT", $count]) @@ -315,11 +315,11 @@ proc move*(r: Redis, key: string, db: int): bool = return r.readInteger() == 1 proc persist*(r: Redis, key: string): bool = - ## Remove the expiration from a key. + ## Remove the expiration from a key. ## Returns `true` when the timeout was removed. r.sendCommand("PERSIST", key) return r.readInteger() == 1 - + proc randomKey*(r: Redis): RedisString = ## Return a random key from the keyspace r.sendCommand("RANDOMKEY") @@ -327,11 +327,11 @@ proc randomKey*(r: Redis): RedisString = proc rename*(r: Redis, key, newkey: string): RedisStatus = ## Rename a key. - ## + ## ## **WARNING:** Overwrites `newkey` if it exists! r.sendCommand("RENAME", key, newkey) raiseNoOK(r.readStatus(), r.pipeline.enabled) - + proc renameNX*(r: Redis, key, newkey: string): bool = ## Same as ``rename`` but doesn't continue if `newkey` exists. ## Returns `true` if key was renamed. @@ -342,12 +342,12 @@ proc ttl*(r: Redis, key: string): RedisInteger = ## Get the time to live for a key r.sendCommand("TTL", key) return r.readInteger() - + proc keyType*(r: Redis, key: string): RedisStatus = ## Determine the type stored at key r.sendCommand("TYPE", key) return r.readStatus() - + # Strings @@ -360,12 +360,12 @@ proc decr*(r: Redis, key: string): RedisInteger = ## Decrement the integer value of a key by one r.sendCommand("DECR", key) return r.readInteger() - + proc decrBy*(r: Redis, key: string, decrement: int): RedisInteger = ## Decrement the integer value of a key by the given number r.sendCommand("DECRBY", key, $decrement) return r.readInteger() - + proc get*(r: Redis, key: string): RedisString = ## Get the value of a key. Returns `redisNil` when `key` doesn't exist. r.sendCommand("GET", key) @@ -397,7 +397,7 @@ proc incrBy*(r: Redis, key: string, increment: int): RedisInteger = r.sendCommand("INCRBY", key, $increment) return r.readInteger() -proc setk*(r: Redis, key, value: string) = +proc setk*(r: Redis, key, value: string) = ## Set the string value of a key. ## ## NOTE: This function had to be renamed due to a clash with the `set` type. @@ -410,18 +410,18 @@ proc setNX*(r: Redis, key, value: string): bool = r.sendCommand("SETNX", key, value) return r.readInteger() == 1 -proc setBit*(r: Redis, key: string, offset: int, +proc setBit*(r: Redis, key: string, offset: int, value: string): RedisInteger = ## Sets or clears the bit at offset in the string value stored at key r.sendCommand("SETBIT", key, $offset, value) return r.readInteger() - + proc setEx*(r: Redis, key: string, seconds: int, value: string): RedisStatus = ## Set the value and expiration of a key r.sendCommand("SETEX", key, $seconds, value) raiseNoOK(r.readStatus(), r.pipeline.enabled) -proc setRange*(r: Redis, key: string, offset: int, +proc setRange*(r: Redis, key: string, offset: int, value: string): RedisInteger = ## Overwrite part of a string at key starting at the specified offset r.sendCommand("SETRANGE", key, $offset, value) @@ -474,7 +474,7 @@ proc hMGet*(r: Redis, key: string, fields: varargs[string]): RedisList = r.sendCommand("HMGET", key, fields) return r.readArray() -proc hMSet*(r: Redis, key: string, +proc hMSet*(r: Redis, key: string, fieldValues: openArray[tuple[field, value: string]]) = ## Set multiple hash fields to multiple values var args = @[key] @@ -488,7 +488,7 @@ proc hSet*(r: Redis, key, field, value: string): RedisInteger = ## Set the string value of a hash field r.sendCommand("HSET", key, field, value) return r.readInteger() - + proc hSetNX*(r: Redis, key, field, value: string): RedisInteger = ## Set the value of a hash field, only if the field does **not** exist r.sendCommand("HSETNX", key, field, value) @@ -498,11 +498,11 @@ proc hVals*(r: Redis, key: string): RedisList = ## Get all the values in a hash r.sendCommand("HVALS", key) return r.readArray() - + # Lists proc bLPop*(r: Redis, keys: varargs[string], timeout: int): RedisList = - ## Remove and get the *first* element in a list, or block until + ## Remove and get the *first* element in a list, or block until ## one is available var args: seq[string] = @[] for i in items(keys): args.add(i) @@ -511,7 +511,7 @@ proc bLPop*(r: Redis, keys: varargs[string], timeout: int): RedisList = return r.readArray() proc bRPop*(r: Redis, keys: varargs[string], timeout: int): RedisList = - ## Remove and get the *last* element in a list, or block until one + ## Remove and get the *last* element in a list, or block until one ## is available. var args: seq[string] = @[] for i in items(keys): args.add(i) @@ -539,7 +539,7 @@ proc lInsert*(r: Redis, key: string, before: bool, pivot, value: string): var pos = if before: "BEFORE" else: "AFTER" r.sendCommand("LINSERT", key, pos, pivot, value) return r.readInteger() - + proc lLen*(r: Redis, key: string): RedisInteger = ## Get the length of a list r.sendCommand("LLEN", key) @@ -553,7 +553,7 @@ proc lPop*(r: Redis, key: string): RedisString = proc lPush*(r: Redis, key, value: string, create: bool = true): RedisInteger = ## Prepend a value to a list. Returns the length of the list after the push. ## The ``create`` param specifies whether a list should be created if it - ## doesn't exist at ``key``. More specifically if ``create`` is true, `LPUSH` + ## doesn't exist at ``key``. More specifically if ``create`` is true, `LPUSH` ## will be used, otherwise `LPUSHX`. if create: r.sendCommand("LPUSH", key, value) @@ -562,7 +562,7 @@ proc lPush*(r: Redis, key, value: string, create: bool = true): RedisInteger = return r.readInteger() proc lRange*(r: Redis, key: string, start, stop: int): RedisList = - ## Get a range of elements from a list. Returns `nil` when `key` + ## Get a range of elements from a list. Returns `nil` when `key` ## doesn't exist. r.sendCommand("LRANGE", key, $start, $stop) return r.readArray() @@ -587,16 +587,16 @@ proc rPop*(r: Redis, key: string): RedisString = ## Remove and get the last element in a list r.sendCommand("RPOP", key) return r.readBulkString() - + proc rPopLPush*(r: Redis, source, destination: string): RedisString = ## Remove the last element in a list, append it to another list and return it r.sendCommand("RPOPLPUSH", source, destination) return r.readBulkString() - + proc rPush*(r: Redis, key, value: string, create: bool = true): RedisInteger = ## Append a value to a list. Returns the length of the list after the push. ## The ``create`` param specifies whether a list should be created if it - ## doesn't exist at ``key``. More specifically if ``create`` is true, `RPUSH` + ## doesn't exist at ``key``. More specifically if ``create`` is true, `RPUSH` ## will be used, otherwise `RPUSHX`. if create: r.sendCommand("RPUSH", key, value) @@ -676,7 +676,7 @@ proc sunion*(r: Redis, keys: varargs[string]): RedisList = proc sunionstore*(r: Redis, destination: string, key: varargs[string]): RedisInteger = - ## Add multiple sets and store the resulting set in a key + ## Add multiple sets and store the resulting set in a key r.sendCommand("SUNIONSTORE", destination, key) return r.readInteger() @@ -710,16 +710,16 @@ proc zinterstore*(r: Redis, destination: string, numkeys: string, ## a new key var args = @[destination, numkeys] for i in items(keys): args.add(i) - + if weights.len != 0: args.add("WITHSCORE") for i in items(weights): args.add(i) if aggregate.len != 0: args.add("AGGREGATE") args.add(aggregate) - + r.sendCommand("ZINTERSTORE", args) - + return r.readInteger() proc zrange*(r: Redis, key: string, start: string, stop: string, @@ -731,18 +731,18 @@ proc zrange*(r: Redis, key: string, start: string, stop: string, r.sendCommand("ZRANGE", "WITHSCORES", key, start, stop) return r.readArray() -proc zrangebyscore*(r: Redis, key: string, min: string, max: string, +proc zrangebyscore*(r: Redis, key: string, min: string, max: string, withScore: bool = false, limit: bool = false, limitOffset: int = 0, limitCount: int = 0): RedisList = ## Return a range of members in a sorted set, by score var args = @[key, min, max] - + if withScore: args.add("WITHSCORE") - if limit: + if limit: args.add("LIMIT") args.add($limitOffset) args.add($limitCount) - + r.sendCommand("ZRANGEBYSCORE", args) return r.readArray() @@ -770,26 +770,26 @@ proc zremrangebyscore*(r: Redis, key: string, min: string, proc zrevrange*(r: Redis, key: string, start: string, stop: string, withScore: bool): RedisList = - ## Return a range of members in a sorted set, by index, + ## Return a range of members in a sorted set, by index, ## with scores ordered from high to low if withScore: r.sendCommand("ZREVRANGE", "WITHSCORE", key, start, stop) else: r.sendCommand("ZREVRANGE", key, start, stop) return r.readArray() -proc zrevrangebyscore*(r: Redis, key: string, min: string, max: string, +proc zrevrangebyscore*(r: Redis, key: string, min: string, max: string, withScore: bool = false, limit: bool = false, limitOffset: int = 0, limitCount: int = 0): RedisList = ## Return a range of members in a sorted set, by score, with ## scores ordered from high to low var args = @[key, min, max] - + if withScore: args.add("WITHSCORE") - if limit: + if limit: args.add("LIMIT") args.add($limitOffset) args.add($limitCount) - + r.sendCommand("ZREVRANGEBYSCORE", args) return r.readArray() @@ -807,24 +807,24 @@ proc zscore*(r: Redis, key: string, member: string): RedisString = proc zunionstore*(r: Redis, destination: string, numkeys: string, keys: openArray[string], weights: openArray[string] = [], aggregate: string = ""): RedisInteger = - ## Add multiple sorted sets and store the resulting sorted set in a new key + ## Add multiple sorted sets and store the resulting sorted set in a new key var args = @[destination, numkeys] for i in items(keys): args.add(i) - + if weights.len != 0: args.add("WEIGHTS") for i in items(weights): args.add(i) if aggregate.len != 0: args.add("AGGREGATE") args.add(aggregate) - + r.sendCommand("ZUNIONSTORE", args) - + return r.readInteger() # HyperLogLog -proc pfadd*(r: Redis, key: string, elements: varargs[string]): RedisInteger = +proc pfadd*(r: Redis, key: string, elements: varargs[string]): RedisInteger = ## Add variable number of elements into special 'HyperLogLog' set type r.sendCommand("PFADD", key, elements) return r.readInteger() @@ -864,7 +864,7 @@ proc subscribe*(r: Redis, channel: openarray[string]): ???? = return ??? proc unsubscribe*(r: Redis, [channel: openarray[string], : string): ???? = - ## Stop listening for messages posted to the given channels + ## Stop listening for messages posted to the given channels r.socket.send("UNSUBSCRIBE $# $#\c\L" % [[channel.join(), ]) return ??? @@ -879,12 +879,12 @@ proc discardMulti*(r: Redis) = proc exec*(r: Redis): RedisList = ## Execute all commands issued after MULTI - r.sendCommand("EXEC") + r.sendCommand("EXEC") r.pipeline.enabled = false # Will reply with +OK for MULTI/EXEC and +QUEUED for every command # between, then with the results return r.flushPipeline(true) - + proc multi*(r: Redis) = ## Mark the start of a transaction block @@ -898,7 +898,7 @@ proc unwatch*(r: Redis) = raiseNoOK(r.readStatus(), r.pipeline.enabled) proc watch*(r: Redis, key: varargs[string]) = - ## Watch the given keys to determine execution of the MULTI/EXEC block + ## Watch the given keys to determine execution of the MULTI/EXEC block r.sendCommand("WATCH", key) raiseNoOK(r.readStatus(), r.pipeline.enabled) @@ -925,7 +925,7 @@ proc quit*(r: Redis) = raiseNoOK(r.readStatus(), r.pipeline.enabled) proc select*(r: Redis, index: int): RedisStatus = - ## Change the selected database for the current connection + ## Change the selected database for the current connection r.sendCommand("SELECT", $index) return r.readStatus() @@ -1016,7 +1016,7 @@ proc slaveof*(r: Redis, host: string, port: string) = iterator hPairs*(r: Redis, key: string): tuple[key, value: string] = ## Iterator for keys and values in a hash. - var + var contents = r.hGetAll(key) k = "" for i in items(contents): @@ -1031,9 +1031,9 @@ proc someTests(r: Redis, how: SendMode):seq[string] = if how == pipelined: r.startPipelining() - elif how == multiple: + elif how == multiple: r.multi() - + r.setk("nim:test", "Testing something.") r.setk("nim:utf8", "ã“ã‚“ã«ã¡ã¯") r.setk("nim:esc", "\\ths Ä…gt\\") @@ -1054,7 +1054,7 @@ proc someTests(r: Redis, how: SendMode):seq[string] = for i in items(p): if not isNil(i): - list.add(i) + list.add(i) list.add(r.debugObject("mylist")) @@ -1079,7 +1079,7 @@ proc assertListsIdentical(listA, listB: seq[string]) = for item in listA: assert(item == listB[i]) i = i + 1 - + when not defined(testing) and isMainModule: when false: var r = open() diff --git a/lib/pure/romans.nim b/lib/pure/romans.nim index 0c182843a1..18c04ef58e 100644 --- a/lib/pure/romans.nim +++ b/lib/pure/romans.nim @@ -11,7 +11,7 @@ ## See http://en.wikipedia.org/wiki/Roman_numerals for reference. const - RomanNumeralDigits* = {'I', 'i', 'V', 'v', 'X', 'x', 'L', 'l', 'C', 'c', + RomanNumeralDigits* = {'I', 'i', 'V', 'v', 'X', 'x', 'L', 'l', 'C', 'c', 'D', 'd', 'M', 'm'} ## set of all characters a Roman numeral may consist of proc romanToDecimal*(romanVal: string): int = @@ -28,7 +28,7 @@ proc romanToDecimal*(romanVal: string): int = of 'C', 'c': val = 100 of 'D', 'd': val = 500 of 'M', 'm': val = 1000 - else: + else: raise newException(EInvalidValue, "invalid roman numeral: " & $romanVal) if val >= prevVal: inc(result, val) diff --git a/lib/pure/ropes.nim b/lib/pure/ropes.nim index 5c7fedfe35..df7071642b 100644 --- a/lib/pure/ropes.nim +++ b/lib/pure/ropes.nim @@ -29,7 +29,7 @@ const var cacheEnabled = false -type +type Rope* = ref RopeObj ## empty rope is represented by nil RopeObj {.acyclic.} = object left, right: Rope @@ -59,7 +59,7 @@ proc newRope(data: string): Rope = result.length = len(data) result.data = data -var +var cache {.threadvar.}: Rope # the root of the cache tree N {.threadvar.}: Rope # dummy rope needed for splay algorithm @@ -81,7 +81,7 @@ proc splay(s: string, tree: Rope, cmpres: var int): Rope = t.left = y.right y.right = t t = y - if t.left == nil: break + if t.left == nil: break r.left = t r = t t = t.left @@ -91,7 +91,7 @@ proc splay(s: string, tree: Rope, cmpres: var int): Rope = t.right = y.left y.left = t t = y - if t.right == nil: break + if t.right == nil: break le.right = t le = t t = t.right @@ -109,7 +109,7 @@ proc insertInCache(s: string, tree: Rope): Rope = if t == nil: result = newRope(s) when countCacheMisses: inc(misses) - return + return var cmp: int t = splay(s, t, cmp) if cmp == 0: @@ -197,7 +197,7 @@ proc add*(a: var Rope, b: Rope) {.rtl, extern: "nro$1Rope".} = proc add*(a: var Rope, b: string) {.rtl, extern: "nro$1Str".} = ## adds `b` to the rope `a`. a = a & b - + proc `[]`*(r: Rope, i: int): char {.rtl, extern: "nroCharAt".} = ## returns the character at position `i` in the rope `r`. This is quite ## expensive! Worst-case: O(n). If ``i >= r.len``, ``\0`` is returned. @@ -250,7 +250,7 @@ when false: proc compiledArg(idx: int): Rope = new(result) result.length = -idx - + proc compileFrmt(frmt: string): Rope = var i = 0 var length = len(frmt) @@ -272,7 +272,7 @@ when false: while true: j = j * 10 + ord(frmt[i]) - ord('0') inc(i) - if frmt[i] notin {'0'..'9'}: break + if frmt[i] notin {'0'..'9'}: break add(s, compiledArg(j)) of '{': inc(i) @@ -345,7 +345,7 @@ const proc equalsFile*(r: Rope, f: File): bool {.rtl, extern: "nro$1File".} = ## returns true if the contents of the file `f` equal `r`. - var + var buf: array[bufSize, char] bpos = buf.len blen = buf.len @@ -363,7 +363,7 @@ proc equalsFile*(r: Rope, f: File): bool {.rtl, extern: "nro$1File".} = return let n = min(blen - bpos, slen - spos) # TODO There's gotta be a better way of comparing here... - if not equalMem(addr(buf[bpos]), + if not equalMem(addr(buf[bpos]), cast[pointer](cast[int](cstring(s))+spos), n): result = false return diff --git a/lib/pure/scgi.nim b/lib/pure/scgi.nim index 3de422c879..1d54b45917 100644 --- a/lib/pure/scgi.nim +++ b/lib/pure/scgi.nim @@ -8,13 +8,13 @@ # ## This module implements helper procs for SCGI applications. Example: -## +## ## .. code-block:: Nim ## ## import strtabs, sockets, scgi ## ## var counter = 0 -## proc handleRequest(client: Socket, input: string, +## proc handleRequest(client: Socket, input: string, ## headers: StringTableRef): bool {.procvar.} = ## inc(counter) ## client.writeStatusOkTextContent() @@ -37,19 +37,19 @@ import sockets, strutils, os, strtabs, asyncio type ScgiError* = object of IOError ## the exception that is raised, if a SCGI error occurs -proc raiseScgiError*(msg: string) {.noreturn.} = +proc raiseScgiError*(msg: string) {.noreturn.} = ## raises an ScgiError exception with message `msg`. var e: ref ScgiError new(e) e.msg = msg raise e -proc parseWord(inp: string, outp: var string, start: int): int = +proc parseWord(inp: string, outp: var string, start: int): int = result = start while inp[result] != '\0': inc(result) outp = substr(inp, start, result-1) -proc parseHeaders(s: string, L: int): StringTableRef = +proc parseHeaders(s: string, L: int): StringTableRef = result = newStringTable() var i = 0 while i < L: @@ -59,12 +59,12 @@ proc parseHeaders(s: string, L: int): StringTableRef = result[key] = val if s[i] == ',': inc(i) else: raiseScgiError("',' after netstring expected") - -proc recvChar(s: Socket): char = + +proc recvChar(s: Socket): char = var c: char - if recv(s, addr(c), sizeof(c)) == sizeof(c): + if recv(s, addr(c), sizeof(c)) == sizeof(c): result = c - + type ScgiState* = object of RootObj ## SCGI state object server: Socket @@ -72,22 +72,22 @@ type client*: Socket ## the client socket to send data to headers*: StringTableRef ## the parsed headers input*: string ## the input buffer - - + + # Async - + ClientMode = enum ClientReadChar, ClientReadHeaders, ClientReadContent - + AsyncClient = ref object c: AsyncSocket mode: ClientMode dataLen: int headers: StringTableRef ## the parsed headers input: string ## the input buffer - + AsyncScgiStateObj = object - handleRequest: proc (client: AsyncSocket, + handleRequest: proc (client: AsyncSocket, input: string, headers: StringTableRef) {.closure, gcsafe.} asyncServer: AsyncSocket @@ -98,19 +98,19 @@ type PAsyncScgiState: AsyncScgiState, scgiError: raiseScgiError].} proc recvBuffer(s: var ScgiState, L: int) = - if L > s.bufLen: + if L > s.bufLen: s.bufLen = L s.input = newString(L) - if L > 0 and recv(s.client, cstring(s.input), L) != L: + if L > 0 and recv(s.client, cstring(s.input), L) != L: raiseScgiError("could not read all data") setLen(s.input, L) - + proc open*(s: var ScgiState, port = Port(4000), address = "127.0.0.1", - reuseAddr = false) = + reuseAddr = false) = ## opens a connection. s.bufLen = 4000 s.input = newString(s.bufLen) # will be reused - + s.server = socket() if s.server == invalidSocket: raiseOSError(osLastError()) new(s.client) # Initialise s.client for `next` @@ -120,12 +120,12 @@ proc open*(s: var ScgiState, port = Port(4000), address = "127.0.0.1", s.server.setSockOpt(OptReuseAddr, true) bindAddr(s.server, port, address) listen(s.server) - -proc close*(s: var ScgiState) = + +proc close*(s: var ScgiState) = ## closes the connection. s.server.close() -proc next*(s: var ScgiState, timeout: int = -1): bool = +proc next*(s: var ScgiState, timeout: int = -1): bool = ## proceed to the first/next request. Waits ``timeout`` milliseconds for a ## request, if ``timeout`` is `-1` then this function will never time out. ## Returns `true` if a new request has been processed. @@ -139,18 +139,18 @@ proc next*(s: var ScgiState, timeout: int = -1): bool = if d == '\0': s.client.close() return false - if d notin strutils.Digits: + if d notin strutils.Digits: if d != ':': raiseScgiError("':' after length expected") break - L = L * 10 + ord(d) - ord('0') + L = L * 10 + ord(d) - ord('0') recvBuffer(s, L+1) s.headers = parseHeaders(s.input, L) if s.headers["SCGI"] != "1": raiseScgiError("SCGI Version 1 expected") L = parseInt(s.headers["CONTENT_LENGTH"]) recvBuffer(s, L) return true - -proc writeStatusOkTextContent*(c: Socket, contentType = "text/html") = + +proc writeStatusOkTextContent*(c: Socket, contentType = "text/html") = ## sends the following string to the socket `c`:: ## ## Status: 200 OK\r\LContent-Type: text/html\r\L\r\L @@ -159,9 +159,9 @@ proc writeStatusOkTextContent*(c: Socket, contentType = "text/html") = c.send("Status: 200 OK\r\L" & "Content-Type: $1\r\L\r\L" % contentType) -proc run*(handleRequest: proc (client: Socket, input: string, +proc run*(handleRequest: proc (client: Socket, input: string, headers: StringTableRef): bool {.nimcall,gcsafe.}, - port = Port(4000)) = + port = Port(4000)) = ## encapsulates the SCGI object and main loop. var s: ScgiState s.open(port) @@ -197,7 +197,7 @@ proc checkCloseSocket(client: AsyncClient) = s.close() s.delHandleWrite() else: client.c.close() - + proc handleClientRead(client: AsyncClient, s: AsyncScgiState) = case client.mode of ClientReadChar: @@ -223,7 +223,7 @@ proc handleClientRead(client: AsyncClient, s: AsyncScgiState) = client.headers = parseHeaders(client.input, client.input.len-1) if client.headers["SCGI"] != "1": raiseScgiError("SCGI Version 1 expected") client.input = "" # For next part - + let contentLen = parseInt(client.headers["CONTENT_LENGTH"]) if contentLen > 0: client.mode = ClientReadContent @@ -250,12 +250,12 @@ proc handleAccept(sock: AsyncSocket, s: AsyncScgiState) = accept(s.asyncServer, client) var asyncClient = AsyncClient(c: client, mode: ClientReadChar, dataLen: 0, headers: newStringTable(), input: "") - client.handleRead = + client.handleRead = proc (sock: AsyncSocket) = handleClientRead(asyncClient, s) s.disp.register(client) -proc open*(handleRequest: proc (client: AsyncSocket, +proc open*(handleRequest: proc (client: AsyncSocket, input: string, headers: StringTableRef) {. closure, gcsafe.}, port = Port(4000), address = "127.0.0.1", @@ -286,7 +286,7 @@ proc close*(s: AsyncScgiState) = when false: var counter = 0 - proc handleRequest(client: Socket, input: string, + proc handleRequest(client: Socket, input: string, headers: StringTableRef): bool {.procvar.} = inc(counter) client.writeStatusOkTextContent() diff --git a/lib/pure/smtp.nim b/lib/pure/smtp.nim index c1bc259a54..b2adac2f3d 100644 --- a/lib/pure/smtp.nim +++ b/lib/pure/smtp.nim @@ -7,25 +7,25 @@ # distribution, for details about the copyright. # -## This module implements the SMTP client protocol as specified by RFC 5321, +## This module implements the SMTP client protocol as specified by RFC 5321, ## this can be used to send mail to any SMTP Server. -## -## This module also implements the protocol used to format messages, +## +## This module also implements the protocol used to format messages, ## as specified by RFC 2822. -## +## ## Example gmail use: -## -## +## +## ## .. code-block:: Nim -## var msg = createMessage("Hello from Nim's SMTP", -## "Hello!.\n Is this awesome or what?", +## var msg = createMessage("Hello from Nim's SMTP", +## "Hello!.\n Is this awesome or what?", ## @["foo@gmail.com"]) ## var smtp = connect("smtp.gmail.com", 465, true, true) ## smtp.auth("username", "password") ## smtp.sendmail("username@gmail.com", @["foo@gmail.com"], $msg) -## -## -## For SSL support this module relies on OpenSSL. If you want to +## +## +## For SSL support this module relies on OpenSSL. If you want to ## enable SSL, compile with ``-d:ssl``. import net, strutils, strtabs, base64, os @@ -35,14 +35,14 @@ type Smtp* = object sock: Socket debug: bool - + Message* = object msgTo: seq[string] msgCc: seq[string] msgSubject: string msgOtherHeaders: StringTableRef msgBody: string - + ReplyError* = object of IOError AsyncSmtp* = ref object @@ -84,7 +84,7 @@ when not defined(ssl): else: let defaultSSLContext = newContext(verifyMode = CVerifyNone) -proc connect*(address: string, port = Port(25), +proc connect*(address: string, port = Port(25), ssl = false, debug = false, sslContext = defaultSSLContext): Smtp = ## Establishes a connection with a SMTP server. @@ -94,17 +94,17 @@ proc connect*(address: string, port = Port(25), when compiledWithSsl: sslContext.wrapSocket(result.sock) else: - raise newException(ESystem, + raise newException(ESystem, "SMTP module compiled without SSL support") result.sock.connect(address, port) result.debug = debug - + result.checkReply("220") result.debugSend("HELO " & address & "\c\L") result.checkReply("250") proc auth*(smtp: var Smtp, username, password: string) = - ## Sends an AUTH command to the server to login as the `username` + ## Sends an AUTH command to the server to login as the `username` ## using `password`. ## May fail with ReplyError. @@ -113,13 +113,13 @@ proc auth*(smtp: var Smtp, username, password: string) = # i.e "334 VXNlcm5hbWU6" smtp.debugSend(encode(username) & "\c\L") smtp.checkReply("334") # TODO: Same as above, only "Password:" (I think?) - + smtp.debugSend(encode(password) & "\c\L") smtp.checkReply("235") # Check whether the authentification was successful. proc sendmail*(smtp: var Smtp, fromaddr: string, toaddrs: seq[string], msg: string) = - ## Sends `msg` from `fromaddr` to `toaddr`. + ## Sends `msg` from `fromaddr` to `toaddr`. ## Messages may be formed using ``createMessage`` by converting the ## Message into a string. @@ -128,7 +128,7 @@ proc sendmail*(smtp: var Smtp, fromaddr: string, for address in items(toaddrs): smtp.debugSend("RCPT TO:<" & address & ">\c\L") smtp.checkReply("250") - + # Send the message smtp.debugSend("DATA " & "\c\L") smtp.checkReply("354") @@ -175,7 +175,7 @@ proc `$`*(msg: Message): string = result.add("\c\L") result.add(msg.msgBody) - + proc newAsyncSmtp*(address: string, port: Port, useSsl = false, sslContext = defaultSslContext): AsyncSmtp = ## Creates a new ``AsyncSmtp`` instance. @@ -189,7 +189,7 @@ proc newAsyncSmtp*(address: string, port: Port, useSsl = false, when compiledWithSsl: sslContext.wrapSocket(result.sock) else: - raise newException(ESystem, + raise newException(ESystem, "SMTP module compiled without SSL support") proc quitExcpt(smtp: AsyncSmtp, msg: string): Future[void] = @@ -216,7 +216,7 @@ proc connect*(smtp: AsyncSmtp) {.async.} = await smtp.checkReply("250") proc auth*(smtp: AsyncSmtp, username, password: string) {.async.} = - ## Sends an AUTH command to the server to login as the `username` + ## Sends an AUTH command to the server to login as the `username` ## using `password`. ## May fail with ReplyError. @@ -225,7 +225,7 @@ proc auth*(smtp: AsyncSmtp, username, password: string) {.async.} = # i.e "334 VXNlcm5hbWU6" await smtp.sock.send(encode(username) & "\c\L") await smtp.checkReply("334") # TODO: Same as above, only "Password:" (I think?) - + await smtp.sock.send(encode(password) & "\c\L") await smtp.checkReply("235") # Check whether the authentification was successful. @@ -240,7 +240,7 @@ proc sendMail*(smtp: AsyncSmtp, fromAddr: string, for address in items(toAddrs): await smtp.sock.send("RCPT TO:<" & address & ">\c\L") await smtp.checkReply("250") - + # Send the message await smtp.sock.send("DATA " & "\c\L") await smtp.checkReply("354") @@ -254,24 +254,24 @@ proc close*(smtp: AsyncSmtp) {.async.} = smtp.sock.close() when not defined(testing) and isMainModule: - #var msg = createMessage("Test subject!", + #var msg = createMessage("Test subject!", # "Hello, my name is dom96.\n What\'s yours?", @["dominik@localhost"]) #echo(msg) #var smtp = connect("localhost", 25, False, True) #smtp.sendmail("root@localhost", @["dominik@localhost"], $msg) - + #echo(decode("a17sm3701420wbe.12")) proc main() {.async.} = var client = newAsyncSmtp("smtp.gmail.com", Port(465), true) await client.connect() await client.auth("johndoe", "foo") - var msg = createMessage("Hello from Nim's SMTP!", - "Hello!!!!.\n Is this awesome or what?", + var msg = createMessage("Hello from Nim's SMTP!", + "Hello!!!!.\n Is this awesome or what?", @["blah@gmail.com"]) echo(msg) await client.sendMail("blah@gmail.com", @["blah@gmail.com"], $msg) await client.close() - + waitFor main() diff --git a/lib/pure/sockets.nim b/lib/pure/sockets.nim index 18b2ab1e9f..29f0bf87d1 100644 --- a/lib/pure/sockets.nim +++ b/lib/pure/sockets.nim @@ -51,17 +51,17 @@ else: # Note: The enumerations are mapped to Window's constants. -when defined(ssl): +when defined(ssl): type SSLError* = object of Exception SSLCVerifyMode* = enum CVerifyNone, CVerifyPeer - + SSLProtVersion* = enum protSSLv2, protSSLv3, protTLSv1, protSSLv23 - + SSLContext* = distinct SSLCTX SSLAcceptResult* = enum @@ -93,11 +93,11 @@ type sslPeekChar: char of false: nil nonblocking: bool - + Socket* = ref SocketImpl - + Port* = distinct uint16 ## port type - + Domain* = enum ## domain, which specifies the protocol family of the ## created socket. Other domains than those that are listed ## here are unsupported. @@ -112,7 +112,7 @@ type SOCK_SEQPACKET = 5 ## reliable sequenced packet service Protocol* = enum ## third argument to `socket` proc - IPPROTO_TCP = 6, ## Transmission control protocol. + IPPROTO_TCP = 6, ## Transmission control protocol. IPPROTO_UDP = 17, ## User datagram protocol. IPPROTO_IP, ## Internet protocol. Unsupported on Windows. IPPROTO_IPV6, ## Internet Protocol Version 6. Unsupported on Windows. @@ -178,7 +178,7 @@ proc `==`*(a, b: Port): bool {.borrow.} proc `$`*(p: Port): string {.borrow.} ## returns the port number as a string -proc ntohl*(x: int32): int32 = +proc ntohl*(x: int32): int32 = ## Converts 32-bit integers from network to host byte order. ## On machines where the host byte order is the same as network byte order, ## this is a no-op; otherwise, it performs a 4-byte swap operation. @@ -206,7 +206,7 @@ proc htons*(x: int16): int16 = ## On machines where the host byte order is the same as network byte ## order, this is a no-op; otherwise, it performs a 2-byte swap operation. result = sockets.ntohs(x) - + when defined(Posix): proc toInt(domain: Domain): cint = case domain @@ -234,19 +234,19 @@ when defined(Posix): else: discard else: - proc toInt(domain: Domain): cint = + proc toInt(domain: Domain): cint = result = toU16(ord(domain)) proc toInt(typ: SockType): cint = result = cint(ord(typ)) - + proc toInt(p: Protocol): cint = result = cint(ord(p)) proc socket*(domain: Domain = AF_INET, typ: SockType = SOCK_STREAM, protocol: Protocol = IPPROTO_TCP, buffered = true): Socket = ## Creates a new socket; returns `InvalidSocket` if an error occurs. - + # TODO: Perhaps this should just raise EOS when an error occurs. when defined(Windows): result = newTSocket(winlean.socket(ord(domain), ord(typ), ord(protocol)), buffered) @@ -277,27 +277,27 @@ when defined(ssl): raise newException(system.IOError, "Certificate file could not be found: " & certFile) if keyFile != "" and not existsFile(keyFile): raise newException(system.IOError, "Key file could not be found: " & keyFile) - + if certFile != "": var ret = SSLCTXUseCertificateChainFile(ctx, certFile) if ret != 1: raiseSslError() - + # TODO: Password? www.rtfm.com/openssl-examples/part1.pdf if keyFile != "": if SSL_CTX_use_PrivateKey_file(ctx, keyFile, SSL_FILETYPE_PEM) != 1: raiseSslError() - + if SSL_CTX_check_private_key(ctx) != 1: raiseSslError("Verification of private key file failed.") proc newContext*(protVersion = protSSLv23, verifyMode = CVerifyPeer, certFile = "", keyFile = ""): SSLContext = ## Creates an SSL context. - ## - ## Protocol version specifies the protocol to use. SSLv2, SSLv3, TLSv1 are - ## are available with the addition of ``ProtSSLv23`` which allows for + ## + ## Protocol version specifies the protocol to use. SSLv2, SSLv3, TLSv1 are + ## are available with the addition of ``ProtSSLv23`` which allows for ## compatibility with all of them. ## ## There are currently only two options for verify mode; @@ -322,7 +322,7 @@ when defined(ssl): newCTX = SSL_CTX_new(SSLv3_method()) of protTLSv1: newCTX = SSL_CTX_new(TLSv1_method()) - + if newCTX.SSLCTXSetCipherList("ALL") != 1: raiseSslError() case verifyMode @@ -343,7 +343,7 @@ when defined(ssl): ## ## **Disclaimer**: This code is not well tested, may be very unsafe and ## prone to security vulnerabilities. - + socket.isSSL = true socket.sslContext = ctx socket.sslHandle = SSLNew(SSLCTX(socket.sslContext)) @@ -351,7 +351,7 @@ when defined(ssl): socket.sslHasPeekChar = false if socket.sslHandle == nil: raiseSslError() - + if SSLSetFd(socket.sslHandle, socket.fd) != 1: raiseSslError() @@ -382,7 +382,7 @@ proc raiseSocketError*(socket: Socket, err: int = -1, async = false) = of SSL_ERROR_SYSCALL, SSL_ERROR_SSL: raiseSslError() else: raiseSslError("Unknown Error") - + if err == -1 and not (when defined(ssl): socket.isSSL else: false): let lastError = osLastError() if async: @@ -397,15 +397,15 @@ proc raiseSocketError*(socket: Socket, err: int = -1, async = false) = else: raiseOSError(lastError) proc listen*(socket: Socket, backlog = SOMAXCONN) {.tags: [ReadIOEffect].} = - ## Marks ``socket`` as accepting connections. - ## ``Backlog`` specifies the maximum length of the + ## Marks ``socket`` as accepting connections. + ## ``Backlog`` specifies the maximum length of the ## queue of pending connections. if listen(socket.fd, cint(backlog)) < 0'i32: raiseOSError(osLastError()) proc invalidIp4(s: string) {.noreturn, noinline.} = raise newException(ValueError, "invalid ip4 address: " & s) -proc parseIp4*(s: string): BiggestInt = +proc parseIp4*(s: string): BiggestInt = ## parses an IP version 4 in dotted decimal form like "a.b.c.d". ## ## This is equivalent to `inet_ntoa`:idx:. @@ -469,8 +469,8 @@ proc bindAddr*(socket: Socket, port = Port(0), address = "") {. gaiNim(address, port, hints, aiList) if bindSocket(socket.fd, aiList.ai_addr, aiList.ai_addrlen.SockLen) < 0'i32: raiseOSError(osLastError()) - -proc getSockName*(socket: Socket): Port = + +proc getSockName*(socket: Socket): Port = ## returns the socket's associated port number. var name: Sockaddr_in when defined(Windows): @@ -485,14 +485,14 @@ proc getSockName*(socket: Socket): Port = raiseOSError(osLastError()) result = Port(sockets.ntohs(name.sin_port)) -template acceptAddrPlain(noClientRet, successRet: expr, +template acceptAddrPlain(noClientRet, successRet: expr, sslImplementation: stmt): stmt {.immediate.} = assert(client != nil) var sockAddress: Sockaddr_in var addrLen = sizeof(sockAddress).SockLen var sock = accept(server.fd, cast[ptr SockAddr](addr(sockAddress)), addr(addrLen)) - + if sock == osInvalidSocket: let err = osLastError() when defined(windows): @@ -537,7 +537,7 @@ proc acceptAddr*(server: Socket, client: var Socket, address: var string) {. ## The resulting client will inherit any properties of the server socket. For ## example: whether the socket is buffered or not. ## - ## **Note**: ``client`` must be initialised (with ``new``), this function + ## **Note**: ``client`` must be initialised (with ``new``), this function ## makes no effort to initialise the ``client`` variable. ## ## **Warning:** When using SSL with non-blocking sockets, it is best to use @@ -546,7 +546,7 @@ proc acceptAddr*(server: Socket, client: var Socket, address: var string) {. when defined(ssl): if server.isSSL: # We must wrap the client sock in a ssl context. - + server.sslContext.wrapSocket(client) let ret = SSLAccept(client.sslHandle) while ret <= 0: @@ -572,9 +572,9 @@ when defined(ssl): proc acceptAddrSSL*(server: Socket, client: var Socket, address: var string): SSLAcceptResult {. tags: [ReadIOEffect].} = - ## This procedure should only be used for non-blocking **SSL** sockets. + ## This procedure should only be used for non-blocking **SSL** sockets. ## It will immediately return with one of the following values: - ## + ## ## ``AcceptSuccess`` will be returned when a client has been successfully ## accepted and the handshake has been successfully performed between ## ``server`` and the newly connected client. @@ -591,7 +591,7 @@ when defined(ssl): if server.isSSL: client.setBlocking(false) # We must wrap the client sock in a ssl context. - + if not client.isSSL or client.sslHandle == nil: server.sslContext.wrapSocket(client) let ret = SSLAccept(client.sslHandle) @@ -623,10 +623,10 @@ when defined(ssl): proc accept*(server: Socket, client: var Socket) {.tags: [ReadIOEffect].} = ## Equivalent to ``acceptAddr`` but doesn't return the address, only the ## socket. - ## + ## ## **Note**: ``client`` must be initialised (with ``new``), this function ## makes no effort to initialise the ``client`` variable. - + var addrDummy = "" acceptAddr(server, client, addrDummy) @@ -662,7 +662,7 @@ proc close*(socket: Socket) = socket.sslHandle = nil proc getServByName*(name, proto: string): Servent {.tags: [ReadIOEffect].} = - ## Searches the database from the beginning and finds the first entry for + ## Searches the database from the beginning and finds the first entry for ## which the service name specified by ``name`` matches the s_name member ## and the protocol name specified by ``proto`` matches the s_proto member. ## @@ -676,10 +676,10 @@ proc getServByName*(name, proto: string): Servent {.tags: [ReadIOEffect].} = result.aliases = cstringArrayToSeq(s.s_aliases) result.port = Port(s.s_port) result.proto = $s.s_proto - -proc getServByPort*(port: Port, proto: string): Servent {.tags: [ReadIOEffect].} = - ## Searches the database from the beginning and finds the first entry for - ## which the port specified by ``port`` matches the s_port member and the + +proc getServByPort*(port: Port, proto: string): Servent {.tags: [ReadIOEffect].} = + ## Searches the database from the beginning and finds the first entry for + ## which the port specified by ``port`` matches the s_port member and the ## protocol name specified by ``proto`` matches the s_proto member. ## ## On posix this will search through the ``/etc/services`` file. @@ -697,20 +697,20 @@ proc getHostByAddr*(ip: string): Hostent {.tags: [ReadIOEffect].} = ## This function will lookup the hostname of an IP Address. var myaddr: InAddr myaddr.s_addr = inet_addr(ip) - + when defined(windows): var s = winlean.gethostbyaddr(addr(myaddr), sizeof(myaddr).cuint, cint(sockets.AF_INET)) if s == nil: raiseOSError(osLastError()) else: - var s = posix.gethostbyaddr(addr(myaddr), sizeof(myaddr).Socklen, + var s = posix.gethostbyaddr(addr(myaddr), sizeof(myaddr).Socklen, cint(posix.AF_INET)) if s == nil: raiseOSError(osLastError(), $hstrerror(h_errno)) - + result.name = $s.h_name result.aliases = cstringArrayToSeq(s.h_aliases) - when defined(windows): + when defined(windows): result.addrtype = Domain(s.h_addrtype) else: if s.h_addrtype == posix.AF_INET: @@ -722,7 +722,7 @@ proc getHostByAddr*(ip: string): Hostent {.tags: [ReadIOEffect].} = result.addrList = cstringArrayToSeq(s.h_addr_list) result.length = int(s.h_length) -proc getHostByName*(name: string): Hostent {.tags: [ReadIOEffect].} = +proc getHostByName*(name: string): Hostent {.tags: [ReadIOEffect].} = ## This function will lookup the IP address of a hostname. when defined(Windows): var s = winlean.gethostbyname(name) @@ -731,7 +731,7 @@ proc getHostByName*(name: string): Hostent {.tags: [ReadIOEffect].} = if s == nil: raiseOSError(osLastError()) result.name = $s.h_name result.aliases = cstringArrayToSeq(s.h_aliases) - when defined(windows): + when defined(windows): result.addrtype = Domain(s.h_addrtype) else: if s.h_addrtype == posix.AF_INET: @@ -744,11 +744,11 @@ proc getHostByName*(name: string): Hostent {.tags: [ReadIOEffect].} = result.length = int(s.h_length) proc getSockOptInt*(socket: Socket, level, optname: int): int {. - tags: [ReadIOEffect].} = + tags: [ReadIOEffect].} = ## getsockopt for integer options. var res: cint var size = sizeof(res).SockLen - if getsockopt(socket.fd, cint(level), cint(optname), + if getsockopt(socket.fd, cint(level), cint(optname), addr(res), addr(size)) < 0'i32: raiseOSError(osLastError()) result = int(res) @@ -757,7 +757,7 @@ proc setSockOptInt*(socket: Socket, level, optname, optval: int) {. tags: [WriteIOEffect].} = ## setsockopt for integer options. var value = cint(optval) - if setsockopt(socket.fd, cint(level), cint(optname), addr(value), + if setsockopt(socket.fd, cint(level), cint(optname), addr(value), sizeof(value).SockLen) < 0'i32: raiseOSError(osLastError()) @@ -776,7 +776,7 @@ proc getSockOpt*(socket: Socket, opt: SOBool, level = SOL_SOCKET): bool {. ## Retrieves option ``opt`` as a boolean value. var res: cint var size = sizeof(res).SockLen - if getsockopt(socket.fd, cint(level), toCInt(opt), + if getsockopt(socket.fd, cint(level), toCInt(opt), addr(res), addr(size)) < 0'i32: raiseOSError(osLastError()) result = res != 0 @@ -785,11 +785,11 @@ proc setSockOpt*(socket: Socket, opt: SOBool, value: bool, level = SOL_SOCKET) { tags: [WriteIOEffect].} = ## Sets option ``opt`` to a boolean value specified by ``value``. var valuei = cint(if value: 1 else: 0) - if setsockopt(socket.fd, cint(level), toCInt(opt), addr(valuei), + if setsockopt(socket.fd, cint(level), toCInt(opt), addr(valuei), sizeof(valuei).SockLen) < 0'i32: raiseOSError(osLastError()) -proc connect*(socket: Socket, address: string, port = Port(0), +proc connect*(socket: Socket, address: string, port = Port(0), af: Domain = AF_INET) {.tags: [ReadIOEffect].} = ## Connects socket to ``address``:``port``. ``Address`` can be an IP address or a ## host name. If ``address`` is a host name, this function will try each IP @@ -816,7 +816,7 @@ proc connect*(socket: Socket, address: string, port = Port(0), freeaddrinfo(aiList) if not success: raiseOSError(lastError) - + when defined(ssl): if socket.isSSL: let ret = SSLConnect(socket.sslHandle) @@ -825,7 +825,7 @@ proc connect*(socket: Socket, address: string, port = Port(0), case err of SSL_ERROR_ZERO_RETURN: raiseSslError("TLS/SSL connection failed to initiate, socket closed prematurely.") - of SSL_ERROR_WANT_READ, SSL_ERROR_WANT_WRITE, SSL_ERROR_WANT_CONNECT, + of SSL_ERROR_WANT_READ, SSL_ERROR_WANT_WRITE, SSL_ERROR_WANT_CONNECT, SSL_ERROR_WANT_ACCEPT: raiseSslError("The operation did not complete. Perhaps you should use connectAsync?") of SSL_ERROR_WANT_X509_LOOKUP: @@ -834,7 +834,7 @@ proc connect*(socket: Socket, address: string, port = Port(0), raiseSslError() else: raiseSslError("Unknown error") - + when false: var s: TSockAddrIn s.sin_addr.s_addr = inet_addr(address) @@ -842,7 +842,7 @@ proc connect*(socket: Socket, address: string, port = Port(0), when defined(windows): s.sin_family = toU16(ord(af)) else: - case af + case af of AF_UNIX: s.sin_family = posix.AF_UNIX of AF_INET: s.sin_family = posix.AF_INET of AF_INET6: s.sin_family = posix.AF_INET6 @@ -886,7 +886,7 @@ proc connectAsync*(socket: Socket, name: string, port = Port(0), if lastError.int32 == EINTR or lastError.int32 == EINPROGRESS: success = true break - + it = it.ai_next freeaddrinfo(aiList) @@ -942,12 +942,12 @@ proc timeValFromMilliseconds(timeout = 500): Timeval = result.tv_sec = seconds.int32 result.tv_usec = ((timeout - seconds * 1000) * 1000).int32 -proc createFdSet(fd: var TFdSet, s: seq[Socket], m: var int) = +proc createFdSet(fd: var TFdSet, s: seq[Socket], m: var int) = FD_ZERO(fd) - for i in items(s): + for i in items(s): m = max(m, int(i.fd)) FD_SET(i.fd, fd) - + proc pruneSocketSet(s: var seq[Socket], fd: var TFdSet) = var i = 0 var L = s.len @@ -982,13 +982,13 @@ proc checkBuffer(readfds: var seq[Socket]): int = if result > 0: readfds = res -proc select*(readfds, writefds, exceptfds: var seq[Socket], - timeout = 500): int {.tags: [ReadIOEffect].} = +proc select*(readfds, writefds, exceptfds: var seq[Socket], + timeout = 500): int {.tags: [ReadIOEffect].} = ## Traditional select function. This function will return the number of ## sockets that are ready to be read from, written to, or which have errors. - ## If there are none; 0 is returned. + ## If there are none; 0 is returned. ## ``Timeout`` is in milliseconds and -1 can be specified for no timeout. - ## + ## ## Sockets which are **not** ready for reading, writing or which don't have ## errors waiting on them are removed from the ``readfds``, ``writefds``, ## ``exceptfds`` sequences respectively. @@ -997,44 +997,44 @@ proc select*(readfds, writefds, exceptfds: var seq[Socket], return buffersFilled var tv {.noInit.}: Timeval = timeValFromMilliseconds(timeout) - + var rd, wr, ex: TFdSet var m = 0 createFdSet((rd), readfds, m) createFdSet((wr), writefds, m) createFdSet((ex), exceptfds, m) - + if timeout != -1: result = int(select(cint(m+1), addr(rd), addr(wr), addr(ex), addr(tv))) else: result = int(select(cint(m+1), addr(rd), addr(wr), addr(ex), nil)) - + pruneSocketSet(readfds, (rd)) pruneSocketSet(writefds, (wr)) pruneSocketSet(exceptfds, (ex)) -proc select*(readfds, writefds: var seq[Socket], +proc select*(readfds, writefds: var seq[Socket], timeout = 500): int {.tags: [ReadIOEffect].} = ## Variant of select with only a read and write list. let buffersFilled = checkBuffer(readfds) if buffersFilled > 0: return buffersFilled var tv {.noInit.}: Timeval = timeValFromMilliseconds(timeout) - + var rd, wr: TFdSet var m = 0 createFdSet((rd), readfds, m) createFdSet((wr), writefds, m) - + if timeout != -1: result = int(select(cint(m+1), addr(rd), addr(wr), nil, addr(tv))) else: result = int(select(cint(m+1), addr(rd), addr(wr), nil, nil)) - + pruneSocketSet(readfds, (rd)) pruneSocketSet(writefds, (wr)) -proc selectWrite*(writefds: var seq[Socket], +proc selectWrite*(writefds: var seq[Socket], timeout = 500): int {.tags: [ReadIOEffect].} = ## When a socket in ``writefds`` is ready to be written to then a non-zero ## value will be returned specifying the count of the sockets which can be @@ -1044,16 +1044,16 @@ proc selectWrite*(writefds: var seq[Socket], ## ``timeout`` is specified in milliseconds and ``-1`` can be specified for ## an unlimited time. var tv {.noInit.}: Timeval = timeValFromMilliseconds(timeout) - + var wr: TFdSet var m = 0 createFdSet((wr), writefds, m) - + if timeout != -1: result = int(select(cint(m+1), nil, addr(wr), nil, addr(tv))) else: result = int(select(cint(m+1), nil, addr(wr), nil, nil)) - + pruneSocketSet(writefds, (wr)) proc select*(readfds: var seq[Socket], timeout = 500): int = @@ -1062,16 +1062,16 @@ proc select*(readfds: var seq[Socket], timeout = 500): int = if buffersFilled > 0: return buffersFilled var tv {.noInit.}: Timeval = timeValFromMilliseconds(timeout) - + var rd: TFdSet var m = 0 createFdSet((rd), readfds, m) - + if timeout != -1: result = int(select(cint(m+1), addr(rd), nil, nil, addr(tv))) else: result = int(select(cint(m+1), addr(rd), nil, nil, nil)) - + pruneSocketSet(readfds, (rd)) proc readIntoBuf(socket: Socket, flags: int32): int = @@ -1107,12 +1107,12 @@ proc recv*(socket: Socket, data: pointer, size: int): int {.tags: [ReadIOEffect] if socket.isBuffered: if socket.bufLen == 0: retRead(0'i32, 0) - + var read = 0 while read < size: if socket.currPos >= socket.bufLen: retRead(0'i32, read) - + let chunk = min(socket.bufLen-socket.currPos, size-read) var d = cast[cstring](data) copyMem(addr(d[read]), addr(socket.buffer[socket.currPos]), chunk) @@ -1155,7 +1155,7 @@ proc waitFor(socket: Socket, waited: var float, timeout, size: int, else: if timeout - int(waited * 1000.0) < 1: raise newException(TimeoutError, "Call to '" & funcName & "' timed out.") - + when defined(ssl): if socket.isSSL: if socket.hasDataBuffered: @@ -1164,7 +1164,7 @@ proc waitFor(socket: Socket, waited: var float, timeout, size: int, let sslPending = SSLPending(socket.sslHandle) if sslPending != 0: return sslPending - + var s = @[socket] var startTime = epochTime() let selRet = select(s, timeout - int(waited * 1000.0)) @@ -1176,8 +1176,8 @@ proc waitFor(socket: Socket, waited: var float, timeout, size: int, proc recv*(socket: Socket, data: pointer, size: int, timeout: int): int {. tags: [ReadIOEffect, TimeEffect].} = ## overload with a ``timeout`` parameter in milliseconds. - var waited = 0.0 # number of seconds already waited - + var waited = 0.0 # number of seconds already waited + var read = 0 while read < size: let avail = waitFor(socket, waited, timeout, size-read, "recv") @@ -1187,7 +1187,7 @@ proc recv*(socket: Socket, data: pointer, size: int, timeout: int): int {. if result < 0: return result inc(read, result) - + result = read proc recv*(socket: Socket, data: var string, size: int, timeout = -1): int = @@ -1231,7 +1231,7 @@ proc peekChar(socket: Socket, c: var char): int {.tags: [ReadIOEffect].} = var res = socket.readIntoBuf(0'i32) if res <= 0: result = res - + c = socket.buffer[socket.currPos] else: when defined(ssl): @@ -1239,7 +1239,7 @@ proc peekChar(socket: Socket, c: var char): int {.tags: [ReadIOEffect].} = if not socket.sslHasPeekChar: result = SSLRead(socket.sslHandle, addr(socket.sslPeekChar), 1) socket.sslHasPeekChar = true - + c = socket.sslPeekChar return result = recv(socket.fd, addr(c), 1, MSG_PEEK) @@ -1251,11 +1251,11 @@ proc recvLine*(socket: Socket, line: var TaintedString, timeout = -1): bool {. ## If a full line is received ``\r\L`` is not ## added to ``line``, however if solely ``\r\L`` is received then ``line`` ## will be set to it. - ## + ## ## ``True`` is returned if data is available. ``False`` suggests an ## error, EOS exceptions are not raised and ``False`` is simply returned ## instead. - ## + ## ## If the socket is disconnected, ``line`` will be set to ``""`` and ``True`` ## will be returned. ## @@ -1264,7 +1264,7 @@ proc recvLine*(socket: Socket, line: var TaintedString, timeout = -1): bool {. ## ## **Deprecated since version 0.9.2**: This function has been deprecated in ## favour of readLine. - + template addNLIfEmpty(): stmt = if line.len == 0: line.add("\c\L") @@ -1286,7 +1286,7 @@ proc recvLine*(socket: Socket, line: var TaintedString, timeout = -1): bool {. elif n <= 0: return false addNLIfEmpty() return true - elif c == '\L': + elif c == '\L': addNLIfEmpty() return true add(line.string, c) @@ -1298,14 +1298,14 @@ proc readLine*(socket: Socket, line: var TaintedString, timeout = -1) {. ## If a full line is read ``\r\L`` is not ## added to ``line``, however if solely ``\r\L`` is read then ``line`` ## will be set to it. - ## + ## ## If the socket is disconnected, ``line`` will be set to ``""``. ## ## An EOS exception will be raised in the case of a socket error. ## ## A timeout can be specified in milliseconds, if data is not received within ## the specified time an ETimeout exception will be raised. - + template addNLIfEmpty(): stmt = if line.len == 0: line.add("\c\L") @@ -1327,12 +1327,12 @@ proc readLine*(socket: Socket, line: var TaintedString, timeout = -1) {. elif n <= 0: socket.raiseSocketError() addNLIfEmpty() return - elif c == '\L': + elif c == '\L': addNLIfEmpty() return add(line.string, c) -proc recvLineAsync*(socket: Socket, +proc recvLineAsync*(socket: Socket, line: var TaintedString): RecvLineResult {.tags: [ReadIOEffect], deprecated.} = ## Similar to ``recvLine`` but designed for non-blocking sockets. ## @@ -1350,21 +1350,21 @@ proc recvLineAsync*(socket: Socket, while true: var c: char var n = recv(socket, addr(c), 1) - if n < 0: + if n < 0: return (if line.len == 0: RecvFail else: RecvPartialLine) - elif n == 0: + elif n == 0: return (if line.len == 0: RecvDisconnected else: RecvPartialLine) if c == '\r': n = peekChar(socket, c) if n > 0 and c == '\L': discard recv(socket, addr(c), 1) - elif n <= 0: + elif n <= 0: return (if line.len == 0: RecvFail else: RecvPartialLine) return RecvFullLine elif c == '\L': return RecvFullLine add(line.string, c) -proc readLineAsync*(socket: Socket, +proc readLineAsync*(socket: Socket, line: var TaintedString): ReadLineResult {.tags: [ReadIOEffect].} = ## Similar to ``recvLine`` but designed for non-blocking sockets. ## @@ -1376,24 +1376,24 @@ proc readLineAsync*(socket: Socket, ## * If no data could be retrieved; ``ReadNone`` is returned. ## * If call to ``recv`` failed; **an EOS exception is raised.** setLen(line.string, 0) - + template errorOrNone = socket.raiseSocketError(async = true) return ReadNone - + while true: var c: char var n = recv(socket, addr(c), 1) #echo(n) if n < 0: if line.len == 0: errorOrNone else: return ReadPartialLine - elif n == 0: + elif n == 0: return (if line.len == 0: ReadDisconnected else: ReadPartialLine) if c == '\r': n = peekChar(socket, c) if n > 0 and c == '\L': discard recv(socket, addr(c), 1) - elif n <= 0: + elif n <= 0: if line.len == 0: errorOrNone else: return ReadPartialLine return ReadFullLine elif c == '\L': return ReadFullLine @@ -1424,7 +1424,7 @@ proc recv*(socket: Socket): TaintedString {.tags: [ReadIOEffect], deprecated.} = var bytesRead = recv(socket, cstring(buf), bufSize-1) # Error if bytesRead == -1: OSError(osLastError()) - + buf[bytesRead] = '\0' # might not be necessary setLen(buf, bytesRead) add(result.string, buf) @@ -1442,13 +1442,13 @@ proc recvTimeout*(socket: Socket, timeout: int): TaintedString {. var s = @[socket] if s.select(timeout) != 1: raise newException(TimeoutError, "Call to recv() timed out.") - + return socket.recv {.pop.} proc recvAsync*(socket: Socket, s: var TaintedString): bool {. tags: [ReadIOEffect], deprecated.} = - ## receives all the data from a non-blocking socket. If socket is non-blocking + ## receives all the data from a non-blocking socket. If socket is non-blocking ## and there are no messages available, `False` will be returned. ## Other socket errors will result in an ``EOS`` error. ## If socket is not a connectionless socket and socket is not connected @@ -1478,7 +1478,7 @@ proc recvAsync*(socket: Socket, s: var TaintedString): bool {. of SSL_ERROR_SYSCALL, SSL_ERROR_SSL: raiseSslError() else: raiseSslError("Unknown Error") - + if bytesRead == -1 and not (when defined(ssl): socket.isSSL else: false): let err = osLastError() when defined(windows): @@ -1510,7 +1510,7 @@ proc recvFrom*(socket: Socket, data: var string, length: int, ## so when ``socket`` is buffered the non-buffered implementation will be ## used. Therefore if ``socket`` contains something in its buffer this ## function will make no effort to return it. - + # TODO: Buffered sockets data.setLen(length) var sockAddress: Sockaddr_in @@ -1524,7 +1524,7 @@ proc recvFrom*(socket: Socket, data: var string, length: int, port = ntohs(sockAddress.sin_port).Port proc recvFromAsync*(socket: Socket, data: var string, length: int, - address: var string, port: var Port, + address: var string, port: var Port, flags = 0'i32): bool {.tags: [ReadIOEffect].} = ## Variant of ``recvFrom`` for non-blocking sockets. Unlike ``recvFrom``, ## this function will raise an EOS error whenever a socket error occurs. @@ -1573,11 +1573,11 @@ proc send*(socket: Socket, data: pointer, size: int): int {. when defined(ssl): if socket.isSSL: return SSLWrite(socket.sslHandle, cast[cstring](data), size) - + when defined(windows) or defined(macosx): result = send(socket.fd, data, size.cint, 0'i32) else: - when defined(solaris): + when defined(solaris): const MSG_NOSIGNAL = 0 result = send(socket.fd, data, size, int32(MSG_NOSIGNAL)) @@ -1590,7 +1590,7 @@ proc send*(socket: Socket, data: string) {.tags: [WriteIOEffect].} = when defined(ssl): if socket.isSSL: raiseSslError() - + raiseOSError(osLastError()) if sent != data.len: @@ -1633,7 +1633,7 @@ proc sendAsync*(socket: Socket, data: string): int {.tags: [WriteIOEffect].} = if err.int32 == EAGAIN or err.int32 == EWOULDBLOCK: return 0 else: raiseOSError(err) - + proc trySend*(socket: Socket, data: string): bool {.tags: [WriteIOEffect].} = ## safe alternative to ``send``. Does not raise an EOS when an error occurs, @@ -1644,7 +1644,7 @@ proc sendTo*(socket: Socket, address: string, port: Port, data: pointer, size: int, af: Domain = AF_INET, flags = 0'i32): int {. tags: [WriteIOEffect].} = ## low-level sendTo proc. This proc sends ``data`` to the specified ``address``, - ## which may be an IP address or a hostname, if a hostname is specified + ## which may be an IP address or a hostname, if a hostname is specified ## this function will try each IP of that hostname. ## ## **Note:** This proc is not available for SSL sockets. @@ -1654,7 +1654,7 @@ proc sendTo*(socket: Socket, address: string, port: Port, data: pointer, hints.ai_socktype = toInt(SOCK_STREAM) hints.ai_protocol = toInt(IPPROTO_TCP) gaiNim(address, port, hints, aiList) - + # try all possibilities: var success = false var it = aiList @@ -1668,7 +1668,7 @@ proc sendTo*(socket: Socket, address: string, port: Port, data: pointer, freeaddrinfo(aiList) -proc sendTo*(socket: Socket, address: string, port: Port, +proc sendTo*(socket: Socket, address: string, port: Port, data: string): int {.tags: [WriteIOEffect].} = ## Friendlier version of the low-level ``sendTo``. result = socket.sendTo(address, port, cstring(data), data.len) @@ -1677,10 +1677,10 @@ when defined(Windows): const IOCPARM_MASK = 127 IOC_IN = int(-2147483648) - FIONBIO = IOC_IN.int32 or ((sizeof(int32) and IOCPARM_MASK) shl 16) or + FIONBIO = IOC_IN.int32 or ((sizeof(int32) and IOCPARM_MASK) shl 16) or (102 shl 8) or 126 - proc ioctlsocket(s: SocketHandle, cmd: clong, + proc ioctlsocket(s: SocketHandle, cmd: clong, argptr: ptr clong): cint {. stdcall, importc:"ioctlsocket", dynlib: "ws2_32.dll".} @@ -1713,7 +1713,7 @@ proc connect*(socket: Socket, address: string, port = Port(0), timeout: int, ## the connection to the server to be made. let originalStatus = not socket.nonblocking socket.setBlocking(false) - + socket.connectAsync(address, port, af) var s: seq[Socket] = @[socket] if selectWrite(s, timeout) != 1: diff --git a/lib/pure/subexes.nim b/lib/pure/subexes.nim index 46824645da..2d1adc0ebe 100644 --- a/lib/pure/subexes.nim +++ b/lib/pure/subexes.nim @@ -77,7 +77,7 @@ proc getFormatArg(p: var FormatParser, a: openArray[string]): int = result = if not negative: j-1 else: a.len-j of 'a'..'z', 'A'..'Z', '\128'..'\255', '_': var name = "" - while f[i] in PatternChars: + while f[i] in PatternChars: name.add(f[i]) inc(i) result = findNormalized(name, a)+1 @@ -131,7 +131,7 @@ proc scanBranch(p: var FormatParser, a: openArray[string], while true: case f[i] of ']': break - of '|': + of '|': inc i elsePart = i inc c @@ -172,7 +172,7 @@ proc scanSlice(p: var FormatParser, a: openarray[string]): tuple[x, y: int] = var slice = false var i = p.i var f = p.f - + if f[i] == '{': inc i else: raiseInvalidFormat("'{' expected") if f[i] == '.' and f[i+1] == '.': @@ -193,12 +193,12 @@ proc scanSlice(p: var FormatParser, a: openarray[string]): tuple[x, y: int] = if f[i] != '}': raiseInvalidFormat("'}' expected") inc i p.i = i - + proc scanDollar(p: var FormatParser, a: openarray[string], s: var string) = var i = p.i var f = p.f case f[i] - of '$': + of '$': emitChar p, s, '$' inc i of '*': @@ -232,7 +232,7 @@ proc scanDollar(p: var FormatParser, a: openarray[string], s: var string) = # $' '~{1..3} # insert space followed by 1..3 if not empty inc i - call: + call: let (x, y) = scanSlice(p, a) var L = 0 for j in x..y: inc L, a[j].len @@ -258,7 +258,7 @@ proc scanDollar(p: var FormatParser, a: openarray[string], s: var string) = of 'i': inc i callNoLineLenTracking: scanQuote(p, indent, true) - + call: let (x, y) = scanSlice(p, a) if maxLen < 1: emitStrLinear(p, s, indent) @@ -266,7 +266,7 @@ proc scanDollar(p: var FormatParser, a: openarray[string], s: var string) = emitStr p, s, a[x] for j in x+1..y: emitStr p, s, sep - if items >= maxLen: + if items >= maxLen: emitStrLinear p, s, indent items = 0 emitStr p, s, a[j] @@ -274,7 +274,7 @@ proc scanDollar(p: var FormatParser, a: openarray[string], s: var string) = of 'c': inc i callNoLineLenTracking: scanQuote(p, indent, true) - + call: let (x, y) = scanSlice(p, a) if p.lineLen + a[x].len > maxLen: emitStrLinear(p, s, indent) @@ -283,7 +283,7 @@ proc scanDollar(p: var FormatParser, a: openarray[string], s: var string) = emitStr p, s, sep if p.lineLen + a[j].len > maxLen: emitStrLinear(p, s, indent) emitStr p, s, a[j] - + else: raiseInvalidFormat("unit 'c' (chars) or 'i' (items) expected") break StringJoin @@ -294,7 +294,7 @@ proc scanDollar(p: var FormatParser, a: openarray[string], s: var string) = emitStr p, s, sep emitStr p, s, a[j] else: - call: + call: var x = getFormatArg(p, a) emitStr p, s, a[x] p.i = i @@ -375,38 +375,38 @@ when isMainModule: doAssert "$1($', '{2..})" % ["f", "a", "b"] == "f(a, b)" doAssert "$[$1($', '{2..})|''''|fg'$3']1" % ["7", "a", "b"] == "fg$3" - + doAssert "$[$#($', '{#..})|''''|$3]1" % ["0", "a", "b"] == "0(a, b)" doAssert "$' '~{..}" % "" == "" doAssert "$' '~{..}" % "P0" == " P0" doAssert "${$1}" % "1" == "1" doAssert "${$$-1} $$1" % "1" == "1 $1" - + doAssert "$#($', '10c'\n '{#..})" % ["doAssert", "longishA", "longish"] == """doAssert( - longishA, + longishA, longish)""" - + assert "type MyEnum* = enum\n $', '2i'\n '{..}" % ["fieldA", "fieldB", "FiledClkad", "fieldD", "fieldE", "longishFieldName"] == strutils.unindent """ type MyEnum* = enum - fieldA, fieldB, - FiledClkad, fieldD, + fieldA, fieldB, + FiledClkad, fieldD, fieldE, longishFieldName""" - + doAssert subex"$1($', '{2..})" % ["f", "a", "b", "c"] == "f(a, b, c)" - + doAssert subex"$1 $[files|file|files]{1} copied" % ["1"] == "1 file copied" - + doAssert subex"$['''|'|''''|']']#" % "0" == "'|" - + assert subex("type\n Enum = enum\n $', '40c'\n '{..}") % [ "fieldNameA", "fieldNameB", "fieldNameC", "fieldNameD"] == strutils.unindent """ type Enum = enum - fieldNameA, fieldNameB, fieldNameC, + fieldNameA, fieldNameB, fieldNameC, fieldNameD""" - - + + diff --git a/lib/pure/unicode.nim b/lib/pure/unicode.nim index 5e20db32b0..396957f6ce 100644 --- a/lib/pure/unicode.nim +++ b/lib/pure/unicode.nim @@ -1285,7 +1285,7 @@ proc cmpRunesIgnoreCase*(a, b: string): int {.rtl, extern: "nuc$1", procvar.} = result = a.len - b.len proc reversed*(s: string): string = - ## Returns the reverse of ``s``, interpreting it as Unicode characters. + ## Returns the reverse of ``s``, interpreting it as Unicode characters. ## Unicode combining characters are correctly interpreted as well: ## ## .. code-block:: nim diff --git a/lib/pure/unidecode/unidecode.nim b/lib/pure/unidecode/unidecode.nim index a83b9be0f9..9d8843f064 100644 --- a/lib/pure/unidecode/unidecode.nim +++ b/lib/pure/unidecode/unidecode.nim @@ -7,19 +7,19 @@ # distribution, for details about the copyright. # -## This module is based on Python's Unidecode module by Tomaz Solc, -## which in turn is based on the ``Text::Unidecode`` Perl module by -## Sean M. Burke +## This module is based on Python's Unidecode module by Tomaz Solc, +## which in turn is based on the ``Text::Unidecode`` Perl module by +## Sean M. Burke ## (http://search.cpan.org/~sburke/Text-Unidecode-0.04/lib/Text/Unidecode.pm ). ## ## It provides a single proc that does Unicode to ASCII transliterations: ## It finds the sequence of ASCII characters that is the closest approximation ## to the Unicode string. ## -## For example, the closest to string "Äußerst" in ASCII is "Ausserst". Some -## information is lost in this transformation, of course, since several Unicode +## For example, the closest to string "Äußerst" in ASCII is "Ausserst". Some +## information is lost in this transformation, of course, since several Unicode ## strings can be transformed in the same ASCII representation. So this is a -## strictly one-way transformation. However a human reader will probably +## strictly one-way transformation. However a human reader will probably ## still be able to guess what original string was meant from the context. ## ## This module needs the data file "unidecode.dat" to work: You can either @@ -31,7 +31,7 @@ import unicode when defined(embedUnidecodeTable): import strutils - + const translationTable = splitLines(slurp"unidecode/unidecode.dat") else: # shared is fine for threading: @@ -49,12 +49,12 @@ proc loadUnidecodeTable*(datafile = "unidecode.dat") = translationTable[i] = line.string inc(i) -proc unidecode*(s: string): string = +proc unidecode*(s: string): string = ## Finds the sequence of ASCII characters that is the closest approximation ## to the UTF-8 string `s`. ## - ## Example: - ## + ## Example: + ## ## ..code-block:: nim ## ## unidecode("\x53\x17\x4E\xB0") @@ -63,7 +63,7 @@ proc unidecode*(s: string): string = ## assert(not isNil(translationTable)) result = "" - for r in runes(s): + for r in runes(s): var c = int(r) if c <=% 127: add(result, chr(c)) elif c <% translationTable.len: add(result, translationTable[c-128]) diff --git a/lib/pure/xmldomparser.nim b/lib/pure/xmldomparser.nim index 0503624357..7c7f7b99ce 100644 --- a/lib/pure/xmldomparser.nim +++ b/lib/pure/xmldomparser.nim @@ -30,19 +30,19 @@ proc getNS(prefix: string): string = if ":" in key: if key.split(':')[1] == prefix: return value - + if key == "xmlns": defaultNS.add(value) - + # Don't return the default namespaces # in the loop, because then they would have a precedence # over normal namespaces if defaultNS.len() > 0: return defaultNS[0] # Return the first found default namespace # if none are specified for this prefix - + return "" - + proc parseText(x: var XmlParser, doc: var PDocument): PText = result = doc.createTextNode(x.charData()) @@ -58,19 +58,19 @@ proc parseElement(x: var XmlParser, doc: var PDocument): PElement = n.appendChild(parseElement(x, doc)) else: n = doc.createElementNS("", x.elementName) - + of xmlElementEnd: if x.elementName == n.nodeName: # n.normalize() # Remove any whitespace etc. - + var ns: string if x.elementName.contains(':'): ns = getNS(x.elementName.split(':')[0]) else: ns = getNS("") - + n.namespaceURI = ns - + # Remove any namespaces this element declared var count = 0 # Variable which keeps the index # We need to edit it.. @@ -82,15 +82,15 @@ proc parseElement(x: var XmlParser, doc: var PDocument): PElement = return n else: #The wrong element is ended - raise newException(EMismatchedTag, "Mismatched tag at line " & + raise newException(EMismatchedTag, "Mismatched tag at line " & $x.getLine() & " column " & $x.getColumn) - + of xmlCharData: n.appendChild(parseText(x, doc)) of xmlAttribute: if x.attrKey == "xmlns" or x.attrKey.startsWith("xmlns:"): nsList.add((x.attrKey, x.attrValue, n)) - + if x.attrKey.contains(':'): var ns = getNS(x.attrKey) n.setAttributeNS(ns, x.attrKey, x.attrValue) @@ -103,7 +103,7 @@ proc parseElement(x: var XmlParser, doc: var PDocument): PElement = n.appendChild(doc.createComment(x.charData())) of xmlPI: n.appendChild(doc.createProcessingInstruction(x.piName(), x.piRest())) - + of xmlWhitespace, xmlElementClose, xmlEntity, xmlSpecial: discard " Unused \'events\'" @@ -111,19 +111,19 @@ proc parseElement(x: var XmlParser, doc: var PDocument): PElement = raise newException(EParserError, "Unexpected XML Parser event") x.next() - raise newException(EMismatchedTag, + raise newException(EMismatchedTag, "Mismatched tag at line " & $x.getLine() & " column " & $x.getColumn) proc loadXMLStream*(stream: Stream): PDocument = - ## Loads and parses XML from a stream specified by ``stream``, and returns + ## Loads and parses XML from a stream specified by ``stream``, and returns ## a ``PDocument`` var x: XmlParser open(x, stream, nil, {reportComments}) - + var xmlDoc: PDocument var dom: PDOMImplementation = getDOM() - + while true: x.next() case x.kind() @@ -140,16 +140,16 @@ proc loadXMLStream*(stream: Stream): PDocument = return xmlDoc proc loadXML*(xml: string): PDocument = - ## Loads and parses XML from a string specified by ``xml``, and returns + ## Loads and parses XML from a string specified by ``xml``, and returns ## a ``PDocument`` var s = newStringStream(xml) return loadXMLStream(s) - - + + proc loadXMLFile*(path: string): PDocument = - ## Loads and parses XML from a file specified by ``path``, and returns + ## Loads and parses XML from a file specified by ``path``, and returns ## a ``PDocument`` - + var s = newFileStream(path, fmRead) if s == nil: raise newException(IOError, "Unable to read file " & path) return loadXMLStream(s) @@ -164,5 +164,5 @@ when not defined(testing) and isMainModule: if i.namespaceURI != nil: echo(i.nodeName, "=", i.namespaceURI) - + echo($xml) diff --git a/lib/pure/xmlparser.nim b/lib/pure/xmlparser.nim index 840cae7341..56b1220008 100644 --- a/lib/pure/xmlparser.nim +++ b/lib/pure/xmlparser.nim @@ -18,24 +18,24 @@ type {.deprecated: [EInvalidXml: XmlError].} -proc raiseInvalidXml(errors: seq[string]) = +proc raiseInvalidXml(errors: seq[string]) = var e: ref XmlError new(e) e.msg = errors[0] e.errors = errors raise e -proc addNode(father, son: XmlNode) = +proc addNode(father, son: XmlNode) = if son != nil: add(father, son) proc parse(x: var XmlParser, errors: var seq[string]): XmlNode -proc untilElementEnd(x: var XmlParser, result: XmlNode, +proc untilElementEnd(x: var XmlParser, result: XmlNode, errors: var seq[string]) = while true: case x.kind - of xmlElementEnd: - if x.elementName == result.tag: + of xmlElementEnd: + if x.elementName == result.tag: next(x) else: errors.add(errorMsg(x, " expected")) @@ -49,7 +49,7 @@ proc untilElementEnd(x: var XmlParser, result: XmlNode, proc parse(x: var XmlParser, errors: var seq[string]): XmlNode = case x.kind - of xmlComment: + of xmlComment: result = newComment(x.charData) next(x) of xmlCharData, xmlWhitespace: @@ -67,11 +67,11 @@ proc parse(x: var XmlParser, errors: var seq[string]): XmlNode = untilElementEnd(x, result, errors) of xmlElementEnd: errors.add(errorMsg(x, "unexpected ending tag: " & x.elementName)) - of xmlElementOpen: + of xmlElementOpen: result = newElement(x.elementName) next(x) result.attrs = newStringTable() - while true: + while true: case x.kind of xmlAttribute: result.attrs[x.attrKey] = x.attrValue @@ -91,7 +91,7 @@ proc parse(x: var XmlParser, errors: var seq[string]): XmlNode = of xmlAttribute, xmlElementClose: errors.add(errorMsg(x, " expected")) next(x) - of xmlCData: + of xmlCData: result = newCData(x.charData) next(x) of xmlEntity: @@ -100,8 +100,8 @@ proc parse(x: var XmlParser, errors: var seq[string]): XmlNode = next(x) of xmlEof: discard -proc parseXml*(s: Stream, filename: string, - errors: var seq[string]): XmlNode = +proc parseXml*(s: Stream, filename: string, + errors: var seq[string]): XmlNode = ## parses the XML from stream `s` and returns a ``PXmlNode``. Every ## occurred parsing error is added to the `errors` sequence. var x: XmlParser @@ -109,7 +109,7 @@ proc parseXml*(s: Stream, filename: string, while true: x.next() case x.kind - of xmlElementOpen, xmlElementStart: + of xmlElementOpen, xmlElementStart: result = parse(x, errors) break of xmlComment, xmlWhitespace, xmlSpecial, xmlPI: discard # just skip it @@ -120,7 +120,7 @@ proc parseXml*(s: Stream, filename: string, break close(x) -proc parseXml*(s: Stream): XmlNode = +proc parseXml*(s: Stream): XmlNode = ## parses the XTML from stream `s` and returns a ``PXmlNode``. All parsing ## errors are turned into an ``EInvalidXML`` exception. var errors: seq[string] = @[] @@ -128,7 +128,7 @@ proc parseXml*(s: Stream): XmlNode = if errors.len > 0: raiseInvalidXml(errors) proc loadXml*(path: string, errors: var seq[string]): XmlNode = - ## Loads and parses XML from file specified by ``path``, and returns + ## Loads and parses XML from file specified by ``path``, and returns ## a ``PXmlNode``. Every occurred parsing error is added to the `errors` ## sequence. var s = newFileStream(path, fmRead) @@ -136,9 +136,9 @@ proc loadXml*(path: string, errors: var seq[string]): XmlNode = result = parseXml(s, path, errors) proc loadXml*(path: string): XmlNode = - ## Loads and parses XML from file specified by ``path``, and returns + ## Loads and parses XML from file specified by ``path``, and returns ## a ``PXmlNode``. All parsing errors are turned into an ``EInvalidXML`` - ## exception. + ## exception. var errors: seq[string] = @[] result = loadXml(path, errors) if errors.len > 0: raiseInvalidXml(errors) @@ -146,14 +146,14 @@ proc loadXml*(path: string): XmlNode = when not defined(testing) and isMainModule: import os - var errors: seq[string] = @[] + var errors: seq[string] = @[] var x = loadXml(paramStr(1), errors) for e in items(errors): echo e - + var f: File if open(f, "xmltest.txt", fmWrite): f.write($x) f.close() else: quit("cannot write test.txt") - + diff --git a/lib/system/ansi_c.nim b/lib/system/ansi_c.nim index 9406f26c92..7025590344 100644 --- a/lib/system/ansi_c.nim +++ b/lib/system/ansi_c.nim @@ -13,20 +13,20 @@ {.push hints:off} -proc c_strcmp(a, b: cstring): cint {.header: "", +proc c_strcmp(a, b: cstring): cint {.header: "", noSideEffect, importc: "strcmp".} -proc c_memcmp(a, b: cstring, size: int): cint {.header: "", +proc c_memcmp(a, b: cstring, size: int): cint {.header: "", noSideEffect, importc: "memcmp".} proc c_memcpy(a, b: cstring, size: int) {.header: "", importc: "memcpy".} -proc c_strlen(a: cstring): int {.header: "", +proc c_strlen(a: cstring): int {.header: "", noSideEffect, importc: "strlen".} proc c_memset(p: pointer, value: cint, size: int) {. header: "", importc: "memset".} type - C_TextFile {.importc: "FILE", header: "", + C_TextFile {.importc: "FILE", header: "", final, incompleteStruct.} = object - C_BinaryFile {.importc: "FILE", header: "", + C_BinaryFile {.importc: "FILE", header: "", final, incompleteStruct.} = object C_TextFileStar = ptr C_TextFile C_BinaryFileStar = ptr C_BinaryFile @@ -101,15 +101,15 @@ proc c_signal(sig: cint, handler: proc (a: cint) {.noconv.}) {. importc: "signal", header: "".} proc c_raise(sig: cint) {.importc: "raise", header: "".} -proc c_fputs(c: cstring, f: C_TextFileStar) {.importc: "fputs", +proc c_fputs(c: cstring, f: C_TextFileStar) {.importc: "fputs", header: "".} proc c_fgets(c: cstring, n: int, f: C_TextFileStar): cstring {. importc: "fgets", header: "".} -proc c_fgetc(stream: C_TextFileStar): int {.importc: "fgetc", +proc c_fgetc(stream: C_TextFileStar): int {.importc: "fgetc", header: "".} -proc c_ungetc(c: int, f: C_TextFileStar) {.importc: "ungetc", +proc c_ungetc(c: int, f: C_TextFileStar) {.importc: "ungetc", header: "".} -proc c_putc(c: char, stream: C_TextFileStar) {.importc: "putc", +proc c_putc(c: char, stream: C_TextFileStar) {.importc: "putc", header: "".} proc c_fprintf(f: C_TextFileStar, frmt: cstring) {. importc: "fprintf", header: "", varargs.} @@ -120,7 +120,7 @@ proc c_fopen(filename, mode: cstring): C_TextFileStar {. importc: "fopen", header: "".} proc c_fclose(f: C_TextFileStar) {.importc: "fclose", header: "".} -proc c_sprintf(buf, frmt: cstring): cint {.header: "", +proc c_sprintf(buf, frmt: cstring): cint {.header: "", importc: "sprintf", varargs, noSideEffect.} # we use it only in a way that cannot lead to security issues @@ -149,7 +149,7 @@ when hostOS != "standalone": when not declared(errno): when defined(NimrodVM): var vmErrnoWrapper {.importc.}: ptr cint - template errno: expr = + template errno: expr = bind vmErrnoWrapper vmErrnoWrapper[] else: diff --git a/lib/system/avltree.nim b/lib/system/avltree.nim index 5ee37d3ebe..d5c9015425 100644 --- a/lib/system/avltree.nim +++ b/lib/system/avltree.nim @@ -16,7 +16,7 @@ proc lowGauge(n: PAvlNode): int = while not isBottom(it): result = it.key it = it.link[0] - + proc highGauge(n: PAvlNode): int = result = -1 var it = n @@ -24,7 +24,7 @@ proc highGauge(n: PAvlNode): int = result = it.upperBound it = it.link[1] -proc find(root: PAvlNode, key: int): PAvlNode = +proc find(root: PAvlNode, key: int): PAvlNode = var it = root while not isBottom(it): if it.key == key: return it diff --git a/lib/system/cellsets.nim b/lib/system/cellsets.nim index 93c49483b2..bb5de6f42c 100644 --- a/lib/system/cellsets.nim +++ b/lib/system/cellsets.nim @@ -65,7 +65,7 @@ proc init(s: var CellSeq, cap: int = 1024) = s.cap = cap s.d = cast[PCellArray](alloc0(cap * sizeof(PCell))) -proc deinit(s: var CellSeq) = +proc deinit(s: var CellSeq) = dealloc(s.d) s.d = nil s.len = 0 @@ -98,7 +98,7 @@ proc nextTry(h, maxHash: int): int {.inline.} = # For any initial h in range(maxHash), repeating that maxHash times # generates each int in range(maxHash) exactly once (see any text on # random-number generation for proof). - + proc cellSetGet(t: CellSet, key: ByteAddress): PPageDesc = var h = cast[int](key) and t.max while t.data[h] != nil: @@ -170,16 +170,16 @@ proc excl(s: var CellSet, cell: PCell) = t.bits[u shr IntShift] = (t.bits[u shr IntShift] and not (1 shl (u and IntMask))) -proc containsOrIncl(s: var CellSet, cell: PCell): bool = +proc containsOrIncl(s: var CellSet, cell: PCell): bool = var u = cast[ByteAddress](cell) var t = cellSetGet(s, u shr PageShift) if t != nil: u = (u %% PageSize) /% MemAlign result = (t.bits[u shr IntShift] and (1 shl (u and IntMask))) != 0 - if not result: + if not result: t.bits[u shr IntShift] = t.bits[u shr IntShift] or (1 shl (u and IntMask)) - else: + else: incl(s, cell) result = false diff --git a/lib/system/channels.nim b/lib/system/channels.nim index 6739fb83e2..68c0e32d23 100644 --- a/lib/system/channels.nim +++ b/lib/system/channels.nim @@ -1,267 +1,267 @@ -# -# -# Nim's Runtime Library +# +# +# Nim's Runtime Library # (c) Copyright 2015 Andreas Rumpf -# -# See the file "copying.txt", included in this -# distribution, for details about the copyright. -# - -## Channel support for threads. **Note**: This is part of the system module. -## Do not import it directly. To activate thread support you need to compile -## with the ``--threads:on`` command line switch. -## -## **Note:** The current implementation of message passing is slow and does -## not work with cyclic data structures. - -when not declared(NimString): - {.error: "You must not import this module explicitly".} - -type - pbytes = ptr array[0.. 0xffff, byte] - RawChannel {.pure, final.} = object ## msg queue for a thread - rd, wr, count, mask: int - data: pbytes - lock: SysLock - cond: SysCond - elemType: PNimType - ready: bool - region: MemRegion - PRawChannel = ptr RawChannel - LoadStoreMode = enum mStore, mLoad +# +# See the file "copying.txt", included in this +# distribution, for details about the copyright. +# + +## Channel support for threads. **Note**: This is part of the system module. +## Do not import it directly. To activate thread support you need to compile +## with the ``--threads:on`` command line switch. +## +## **Note:** The current implementation of message passing is slow and does +## not work with cyclic data structures. + +when not declared(NimString): + {.error: "You must not import this module explicitly".} + +type + pbytes = ptr array[0.. 0xffff, byte] + RawChannel {.pure, final.} = object ## msg queue for a thread + rd, wr, count, mask: int + data: pbytes + lock: SysLock + cond: SysCond + elemType: PNimType + ready: bool + region: MemRegion + PRawChannel = ptr RawChannel + LoadStoreMode = enum mStore, mLoad Channel* {.gcsafe.}[TMsg] = RawChannel ## a channel for thread communication {.deprecated: [TRawChannel: RawChannel, TLoadStoreMode: LoadStoreMode, TChannel: Channel].} -const ChannelDeadMask = -2 - -proc initRawChannel(p: pointer) = - var c = cast[PRawChannel](p) - initSysLock(c.lock) - initSysCond(c.cond) - c.mask = -1 - -proc deinitRawChannel(p: pointer) = - var c = cast[PRawChannel](p) - # we need to grab the lock to be safe against sending threads! - acquireSys(c.lock) - c.mask = ChannelDeadMask - deallocOsPages(c.region) - deinitSys(c.lock) - deinitSysCond(c.cond) - -proc storeAux(dest, src: pointer, mt: PNimType, t: PRawChannel, - mode: LoadStoreMode) {.benign.} -proc storeAux(dest, src: pointer, n: ptr TNimNode, t: PRawChannel, - mode: LoadStoreMode) {.benign.} = - var - d = cast[ByteAddress](dest) - s = cast[ByteAddress](src) - case n.kind - of nkSlot: storeAux(cast[pointer](d +% n.offset), - cast[pointer](s +% n.offset), n.typ, t, mode) - of nkList: - for i in 0..n.len-1: storeAux(dest, src, n.sons[i], t, mode) - of nkCase: - copyMem(cast[pointer](d +% n.offset), cast[pointer](s +% n.offset), - n.typ.size) - var m = selectBranch(src, n) - if m != nil: storeAux(dest, src, m, t, mode) - of nkNone: sysAssert(false, "storeAux") - -proc storeAux(dest, src: pointer, mt: PNimType, t: PRawChannel, - mode: LoadStoreMode) = - var - d = cast[ByteAddress](dest) - s = cast[ByteAddress](src) - sysAssert(mt != nil, "mt == nil") - case mt.kind - of tyString: - if mode == mStore: - var x = cast[PPointer](dest) - var s2 = cast[PPointer](s)[] - if s2 == nil: - x[] = nil - else: - var ss = cast[NimString](s2) - var ns = cast[NimString](alloc(t.region, ss.len+1 + GenericSeqSize)) - copyMem(ns, ss, ss.len+1 + GenericSeqSize) - x[] = ns - else: - var x = cast[PPointer](dest) - var s2 = cast[PPointer](s)[] - if s2 == nil: - unsureAsgnRef(x, s2) - else: - unsureAsgnRef(x, copyString(cast[NimString](s2))) - dealloc(t.region, s2) - of tySequence: - var s2 = cast[PPointer](src)[] - var seq = cast[PGenericSeq](s2) - var x = cast[PPointer](dest) - if s2 == nil: - if mode == mStore: - x[] = nil - else: - unsureAsgnRef(x, nil) - else: - sysAssert(dest != nil, "dest == nil") - if mode == mStore: - x[] = alloc(t.region, seq.len *% mt.base.size +% GenericSeqSize) - else: - unsureAsgnRef(x, newObj(mt, seq.len * mt.base.size + GenericSeqSize)) - var dst = cast[ByteAddress](cast[PPointer](dest)[]) - for i in 0..seq.len-1: - storeAux( - cast[pointer](dst +% i*% mt.base.size +% GenericSeqSize), - cast[pointer](cast[ByteAddress](s2) +% i *% mt.base.size +% - GenericSeqSize), - mt.base, t, mode) - var dstseq = cast[PGenericSeq](dst) - dstseq.len = seq.len - dstseq.reserved = seq.len - if mode != mStore: dealloc(t.region, s2) - of tyObject: - # copy type field: - var pint = cast[ptr PNimType](dest) - # XXX use dynamic type here! - pint[] = mt - if mt.base != nil: - storeAux(dest, src, mt.base, t, mode) - storeAux(dest, src, mt.node, t, mode) - of tyTuple: - storeAux(dest, src, mt.node, t, mode) - of tyArray, tyArrayConstr: - for i in 0..(mt.size div mt.base.size)-1: - storeAux(cast[pointer](d +% i*% mt.base.size), - cast[pointer](s +% i*% mt.base.size), mt.base, t, mode) - of tyRef: - var s = cast[PPointer](src)[] - var x = cast[PPointer](dest) - if s == nil: - if mode == mStore: - x[] = nil - else: - unsureAsgnRef(x, nil) - else: - if mode == mStore: - x[] = alloc(t.region, mt.base.size) - else: - # XXX we should use the dynamic type here too, but that is not stored - # in the inbox at all --> use source[]'s object type? but how? we need - # a tyRef to the object! - var obj = newObj(mt, mt.base.size) - unsureAsgnRef(x, obj) - storeAux(x[], s, mt.base, t, mode) - if mode != mStore: dealloc(t.region, s) - else: - copyMem(dest, src, mt.size) # copy raw bits - -proc rawSend(q: PRawChannel, data: pointer, typ: PNimType) = - ## adds an `item` to the end of the queue `q`. - var cap = q.mask+1 - if q.count >= cap: - # start with capacity for 2 entries in the queue: - if cap == 0: cap = 1 - var n = cast[pbytes](alloc0(q.region, cap*2*typ.size)) - var z = 0 - var i = q.rd - var c = q.count - while c > 0: - dec c - copyMem(addr(n[z*typ.size]), addr(q.data[i*typ.size]), typ.size) - i = (i + 1) and q.mask - inc z - if q.data != nil: dealloc(q.region, q.data) - q.data = n - q.mask = cap*2 - 1 - q.wr = q.count - q.rd = 0 - storeAux(addr(q.data[q.wr * typ.size]), data, typ, q, mStore) - inc q.count - q.wr = (q.wr + 1) and q.mask - -proc rawRecv(q: PRawChannel, data: pointer, typ: PNimType) = - sysAssert q.count > 0, "rawRecv" - dec q.count - storeAux(data, addr(q.data[q.rd * typ.size]), typ, q, mLoad) - q.rd = (q.rd + 1) and q.mask - -template lockChannel(q: expr, action: stmt) {.immediate.} = - acquireSys(q.lock) - action - releaseSys(q.lock) - -template sendImpl(q: expr) {.immediate.} = - if q.mask == ChannelDeadMask: - sysFatal(DeadThreadError, "cannot send message; thread died") - acquireSys(q.lock) - var m: TMsg - shallowCopy(m, msg) - var typ = cast[PNimType](getTypeInfo(msg)) - rawSend(q, addr(m), typ) - q.elemType = typ - releaseSys(q.lock) - signalSysCond(q.cond) - -proc send*[TMsg](c: var Channel[TMsg], msg: TMsg) = - ## sends a message to a thread. `msg` is deeply copied. - var q = cast[PRawChannel](addr(c)) - sendImpl(q) - -proc llRecv(q: PRawChannel, res: pointer, typ: PNimType) = - # to save space, the generic is as small as possible - q.ready = true - while q.count <= 0: - waitSysCond(q.cond, q.lock) - q.ready = false - if typ != q.elemType: - releaseSys(q.lock) - sysFatal(ValueError, "cannot receive message of wrong type") - rawRecv(q, res, typ) - -proc recv*[TMsg](c: var Channel[TMsg]): TMsg = - ## receives a message from the channel `c`. This blocks until - ## a message has arrived! You may use ``peek`` to avoid the blocking. - var q = cast[PRawChannel](addr(c)) - acquireSys(q.lock) - llRecv(q, addr(result), cast[PNimType](getTypeInfo(result))) - releaseSys(q.lock) - -proc tryRecv*[TMsg](c: var Channel[TMsg]): tuple[dataAvailable: bool, - msg: TMsg] = - ## try to receives a message from the channel `c` if available. Otherwise - ## it returns ``(false, default(msg))``. - var q = cast[PRawChannel](addr(c)) - if q.mask != ChannelDeadMask: +const ChannelDeadMask = -2 + +proc initRawChannel(p: pointer) = + var c = cast[PRawChannel](p) + initSysLock(c.lock) + initSysCond(c.cond) + c.mask = -1 + +proc deinitRawChannel(p: pointer) = + var c = cast[PRawChannel](p) + # we need to grab the lock to be safe against sending threads! + acquireSys(c.lock) + c.mask = ChannelDeadMask + deallocOsPages(c.region) + deinitSys(c.lock) + deinitSysCond(c.cond) + +proc storeAux(dest, src: pointer, mt: PNimType, t: PRawChannel, + mode: LoadStoreMode) {.benign.} +proc storeAux(dest, src: pointer, n: ptr TNimNode, t: PRawChannel, + mode: LoadStoreMode) {.benign.} = + var + d = cast[ByteAddress](dest) + s = cast[ByteAddress](src) + case n.kind + of nkSlot: storeAux(cast[pointer](d +% n.offset), + cast[pointer](s +% n.offset), n.typ, t, mode) + of nkList: + for i in 0..n.len-1: storeAux(dest, src, n.sons[i], t, mode) + of nkCase: + copyMem(cast[pointer](d +% n.offset), cast[pointer](s +% n.offset), + n.typ.size) + var m = selectBranch(src, n) + if m != nil: storeAux(dest, src, m, t, mode) + of nkNone: sysAssert(false, "storeAux") + +proc storeAux(dest, src: pointer, mt: PNimType, t: PRawChannel, + mode: LoadStoreMode) = + var + d = cast[ByteAddress](dest) + s = cast[ByteAddress](src) + sysAssert(mt != nil, "mt == nil") + case mt.kind + of tyString: + if mode == mStore: + var x = cast[PPointer](dest) + var s2 = cast[PPointer](s)[] + if s2 == nil: + x[] = nil + else: + var ss = cast[NimString](s2) + var ns = cast[NimString](alloc(t.region, ss.len+1 + GenericSeqSize)) + copyMem(ns, ss, ss.len+1 + GenericSeqSize) + x[] = ns + else: + var x = cast[PPointer](dest) + var s2 = cast[PPointer](s)[] + if s2 == nil: + unsureAsgnRef(x, s2) + else: + unsureAsgnRef(x, copyString(cast[NimString](s2))) + dealloc(t.region, s2) + of tySequence: + var s2 = cast[PPointer](src)[] + var seq = cast[PGenericSeq](s2) + var x = cast[PPointer](dest) + if s2 == nil: + if mode == mStore: + x[] = nil + else: + unsureAsgnRef(x, nil) + else: + sysAssert(dest != nil, "dest == nil") + if mode == mStore: + x[] = alloc(t.region, seq.len *% mt.base.size +% GenericSeqSize) + else: + unsureAsgnRef(x, newObj(mt, seq.len * mt.base.size + GenericSeqSize)) + var dst = cast[ByteAddress](cast[PPointer](dest)[]) + for i in 0..seq.len-1: + storeAux( + cast[pointer](dst +% i*% mt.base.size +% GenericSeqSize), + cast[pointer](cast[ByteAddress](s2) +% i *% mt.base.size +% + GenericSeqSize), + mt.base, t, mode) + var dstseq = cast[PGenericSeq](dst) + dstseq.len = seq.len + dstseq.reserved = seq.len + if mode != mStore: dealloc(t.region, s2) + of tyObject: + # copy type field: + var pint = cast[ptr PNimType](dest) + # XXX use dynamic type here! + pint[] = mt + if mt.base != nil: + storeAux(dest, src, mt.base, t, mode) + storeAux(dest, src, mt.node, t, mode) + of tyTuple: + storeAux(dest, src, mt.node, t, mode) + of tyArray, tyArrayConstr: + for i in 0..(mt.size div mt.base.size)-1: + storeAux(cast[pointer](d +% i*% mt.base.size), + cast[pointer](s +% i*% mt.base.size), mt.base, t, mode) + of tyRef: + var s = cast[PPointer](src)[] + var x = cast[PPointer](dest) + if s == nil: + if mode == mStore: + x[] = nil + else: + unsureAsgnRef(x, nil) + else: + if mode == mStore: + x[] = alloc(t.region, mt.base.size) + else: + # XXX we should use the dynamic type here too, but that is not stored + # in the inbox at all --> use source[]'s object type? but how? we need + # a tyRef to the object! + var obj = newObj(mt, mt.base.size) + unsureAsgnRef(x, obj) + storeAux(x[], s, mt.base, t, mode) + if mode != mStore: dealloc(t.region, s) + else: + copyMem(dest, src, mt.size) # copy raw bits + +proc rawSend(q: PRawChannel, data: pointer, typ: PNimType) = + ## adds an `item` to the end of the queue `q`. + var cap = q.mask+1 + if q.count >= cap: + # start with capacity for 2 entries in the queue: + if cap == 0: cap = 1 + var n = cast[pbytes](alloc0(q.region, cap*2*typ.size)) + var z = 0 + var i = q.rd + var c = q.count + while c > 0: + dec c + copyMem(addr(n[z*typ.size]), addr(q.data[i*typ.size]), typ.size) + i = (i + 1) and q.mask + inc z + if q.data != nil: dealloc(q.region, q.data) + q.data = n + q.mask = cap*2 - 1 + q.wr = q.count + q.rd = 0 + storeAux(addr(q.data[q.wr * typ.size]), data, typ, q, mStore) + inc q.count + q.wr = (q.wr + 1) and q.mask + +proc rawRecv(q: PRawChannel, data: pointer, typ: PNimType) = + sysAssert q.count > 0, "rawRecv" + dec q.count + storeAux(data, addr(q.data[q.rd * typ.size]), typ, q, mLoad) + q.rd = (q.rd + 1) and q.mask + +template lockChannel(q: expr, action: stmt) {.immediate.} = + acquireSys(q.lock) + action + releaseSys(q.lock) + +template sendImpl(q: expr) {.immediate.} = + if q.mask == ChannelDeadMask: + sysFatal(DeadThreadError, "cannot send message; thread died") + acquireSys(q.lock) + var m: TMsg + shallowCopy(m, msg) + var typ = cast[PNimType](getTypeInfo(msg)) + rawSend(q, addr(m), typ) + q.elemType = typ + releaseSys(q.lock) + signalSysCond(q.cond) + +proc send*[TMsg](c: var Channel[TMsg], msg: TMsg) = + ## sends a message to a thread. `msg` is deeply copied. + var q = cast[PRawChannel](addr(c)) + sendImpl(q) + +proc llRecv(q: PRawChannel, res: pointer, typ: PNimType) = + # to save space, the generic is as small as possible + q.ready = true + while q.count <= 0: + waitSysCond(q.cond, q.lock) + q.ready = false + if typ != q.elemType: + releaseSys(q.lock) + sysFatal(ValueError, "cannot receive message of wrong type") + rawRecv(q, res, typ) + +proc recv*[TMsg](c: var Channel[TMsg]): TMsg = + ## receives a message from the channel `c`. This blocks until + ## a message has arrived! You may use ``peek`` to avoid the blocking. + var q = cast[PRawChannel](addr(c)) + acquireSys(q.lock) + llRecv(q, addr(result), cast[PNimType](getTypeInfo(result))) + releaseSys(q.lock) + +proc tryRecv*[TMsg](c: var Channel[TMsg]): tuple[dataAvailable: bool, + msg: TMsg] = + ## try to receives a message from the channel `c` if available. Otherwise + ## it returns ``(false, default(msg))``. + var q = cast[PRawChannel](addr(c)) + if q.mask != ChannelDeadMask: if tryAcquireSys(q.lock): - if q.count > 0: - llRecv(q, addr(result.msg), cast[PNimType](getTypeInfo(result.msg))) - result.dataAvailable = true - releaseSys(q.lock) - -proc peek*[TMsg](c: var Channel[TMsg]): int = - ## returns the current number of messages in the channel `c`. Returns -1 - ## if the channel has been closed. **Note**: This is dangerous to use - ## as it encourages races. It's much better to use ``tryRecv`` instead. - var q = cast[PRawChannel](addr(c)) - if q.mask != ChannelDeadMask: - lockChannel(q): - result = q.count - else: - result = -1 - -proc open*[TMsg](c: var Channel[TMsg]) = - ## opens a channel `c` for inter thread communication. - initRawChannel(addr(c)) - -proc close*[TMsg](c: var Channel[TMsg]) = - ## closes a channel `c` and frees its associated resources. - deinitRawChannel(addr(c)) - -proc ready*[TMsg](c: var Channel[TMsg]): bool = - ## returns true iff some thread is waiting on the channel `c` for - ## new messages. - var q = cast[PRawChannel](addr(c)) - result = q.ready - + if q.count > 0: + llRecv(q, addr(result.msg), cast[PNimType](getTypeInfo(result.msg))) + result.dataAvailable = true + releaseSys(q.lock) + +proc peek*[TMsg](c: var Channel[TMsg]): int = + ## returns the current number of messages in the channel `c`. Returns -1 + ## if the channel has been closed. **Note**: This is dangerous to use + ## as it encourages races. It's much better to use ``tryRecv`` instead. + var q = cast[PRawChannel](addr(c)) + if q.mask != ChannelDeadMask: + lockChannel(q): + result = q.count + else: + result = -1 + +proc open*[TMsg](c: var Channel[TMsg]) = + ## opens a channel `c` for inter thread communication. + initRawChannel(addr(c)) + +proc close*[TMsg](c: var Channel[TMsg]) = + ## closes a channel `c` and frees its associated resources. + deinitRawChannel(addr(c)) + +proc ready*[TMsg](c: var Channel[TMsg]): bool = + ## returns true iff some thread is waiting on the channel `c` for + ## new messages. + var q = cast[PRawChannel](addr(c)) + result = q.ready + diff --git a/lib/system/deepcopy.nim b/lib/system/deepcopy.nim index 093c0f3a7f..03230e541a 100644 --- a/lib/system/deepcopy.nim +++ b/lib/system/deepcopy.nim @@ -14,7 +14,7 @@ proc genericDeepCopyAux(dest, src: pointer, n: ptr TNimNode) {.benign.} = s = cast[ByteAddress](src) case n.kind of nkSlot: - genericDeepCopyAux(cast[pointer](d +% n.offset), + genericDeepCopyAux(cast[pointer](d +% n.offset), cast[pointer](s +% n.offset), n.typ) of nkList: for i in 0..n.len-1: @@ -24,7 +24,7 @@ proc genericDeepCopyAux(dest, src: pointer, n: ptr TNimNode) {.benign.} = var m = selectBranch(src, n) # reset if different branches are in use; note different branches also # imply that's not self-assignment (``x = x``)! - if m != dd and dd != nil: + if m != dd and dd != nil: genericResetAux(dest, dd) copyMem(cast[pointer](d +% n.offset), cast[pointer](s +% n.offset), n.typ.size) @@ -103,16 +103,16 @@ proc genericDeepCopyAux(dest, src: pointer, mt: PNimType) = else: let realType = x.typ let z = newObj(realType, realType.base.size) - + unsureAsgnRef(cast[PPointer](dest), z) x.typ = cast[PNimType](cast[int](z) or 1) genericDeepCopyAux(z, s2, realType.base) x.typ = realType else: let realType = mt - let z = newObj(realType, realType.base.size) + let z = newObj(realType, realType.base.size) unsureAsgnRef(cast[PPointer](dest), z) - genericDeepCopyAux(z, s2, realType.base) + genericDeepCopyAux(z, s2, realType.base) of tyPtr: # no cycle check here, but also not really required let s2 = cast[PPointer](src)[] diff --git a/lib/system/gc2.nim b/lib/system/gc2.nim index 015e08c9e1..4ca0d144fc 100644 --- a/lib/system/gc2.nim +++ b/lib/system/gc2.nim @@ -37,19 +37,19 @@ const rcAlive = 0b00000 # object is reachable. # color *black* in the original paper - + rcCycleCandidate = 0b00001 # possible root of a cycle. *purple* rcDecRefApplied = 0b00010 # the first dec-ref phase of the # collector was already applied to this # object. *gray* - + rcMaybeDead = 0b00011 # this object is a candidate for deletion # during the collect cycles algorithm. # *white*. - + rcReallyDead = 0b00100 # this is proved to be garbage - + rcRetiredBuffer = 0b00101 # this is a seq or string buffer that # was replaced by a resize operation. # see growObj for details @@ -80,14 +80,14 @@ const # The bit must also be set for new objects that are not rc1 and it must be # examined in the decref loop in collectCycles. # XXX: not implemented yet as tests didn't show any improvement from this - + MarkingSkipsAcyclicObjects = true - # Acyclic objects can be safely ignored in the mark and scan phases, + # Acyclic objects can be safely ignored in the mark and scan phases, # because they cannot contribute to the internal count. # XXX: if we generate specialized `markCyclic` and `markAcyclic` # procs we can further optimize this as there won't be need for any # checks in the code - + MinimumStackMarking = false # Try to scan only the user stack and ignore the part of the stack # belonging to the GC itself. see setStackTop for further info. @@ -110,9 +110,9 @@ type maxThreshold: int # max threshold that has been set maxStackSize: int # max stack size maxStackCells: int # max stack cells in ``decStack`` - cycleTableSize: int # max entries in cycle table + cycleTableSize: int # max entries in cycle table maxPause: int64 # max measured GC pause in nanoseconds - + GcHeap {.final, pure.} = object # this contains the zero count and # non-zero count table stackBottom: pointer @@ -124,7 +124,7 @@ type tempStack: CellSeq # temporary stack for recursion elimination freeStack: CellSeq # objects ready to be freed recGcLock: int # prevent recursion via finalizers; no thread lock - cycleRootsTrimIdx: int # Trimming is a light-weight collection of the + cycleRootsTrimIdx: int # Trimming is a light-weight collection of the # cycle roots table that uses a cheap linear scan # to find only possitively dead objects. # One strategy is to perform it only for new objects @@ -143,11 +143,11 @@ var when not defined(useNimRtl): instantiateForRegion(gch.region) -template acquire(gch: GcHeap) = +template acquire(gch: GcHeap) = when hasThreadSupport and hasSharedHeap: AcquireSys(HeapLock) -template release(gch: GcHeap) = +template release(gch: GcHeap) = when hasThreadSupport and hasSharedHeap: releaseSys(HeapLock) @@ -185,7 +185,7 @@ when debugGC: of rcRetiredBuffer: return "retired" of rcReallyDead: return "dead" else: return "unknown?" - + proc inCycleRootsStr(c: PCell): cstring = if c.isBitUp(rcInCycleRoots): result = "cycleroot" else: result = "" @@ -225,7 +225,7 @@ template setStackTop(gch) = template addCycleRoot(cycleRoots: var CellSeq, c: PCell) = if c.color != rcCycleCandidate: c.setColor rcCycleCandidate - + # the object may be buffered already. for example, consider: # decref; incref; decref if c.isBitDown(rcInCycleRoots): @@ -307,7 +307,7 @@ when traceGC: let startLen = gch.tempStack.len c.forAllChildren waPush - + while startLen != gch.tempStack.len: dec gch.tempStack.len var c = gch.tempStack.d[gch.tempStack.len] @@ -331,7 +331,7 @@ when traceGC: if c.isBitUp(rcMarkBit) and not isMarked: writecell("cyclic cell", cell) cprintf "Weight %d\n", cell.computeCellWeight - + proc writeLeakage(onlyRoots: bool) = if onlyRoots: for c in elements(states[csAllocated]): @@ -356,7 +356,7 @@ template WithHeapLock(blk: stmt): stmt = blk when hasThreadSupport and hasSharedHeap: ReleaseSys(HeapLock) -proc rtlAddCycleRoot(c: PCell) {.rtl, inl.} = +proc rtlAddCycleRoot(c: PCell) {.rtl, inl.} = # we MUST access gch as a global here, because this crosses DLL boundaries! WithHeapLock: addCycleRoot(gch.cycleRoots, c) @@ -423,7 +423,7 @@ template doIncRef(cc: PCell, elif IncRefRemovesCandidates: c.setColor rcAlive # XXX: this is not really atomic enough! - + proc nimGCref(p: pointer) {.compilerProc, inline.} = doIncRef(usrToCell(p)) proc nimGCunref(p: pointer) {.compilerProc, inline.} = doDecRef(usrToCell(p)) @@ -449,7 +449,7 @@ proc asgnRef(dest: PPointer, src: pointer) {.compilerProc, inline.} = doAsgnRef(dest, src, LocalHeap, MaybeCyclic) proc asgnRefNoCycle(dest: PPointer, src: pointer) {.compilerProc, inline.} = - # the code generator calls this proc if it is known at compile time that no + # the code generator calls this proc if it is known at compile time that no # cycle is possible. doAsgnRef(dest, src, LocalHeap, Acyclic) @@ -509,7 +509,7 @@ proc forAllSlotsAux(dest: pointer, n: ptr TNimNode, op: WalkOp) = if n.sons[i].typ.kind in {tyRef, tyString, tySequence}: doOperation(cast[PPointer](d +% n.sons[i].offset)[], op) else: - forAllChildrenAux(cast[pointer](d +% n.sons[i].offset), + forAllChildrenAux(cast[pointer](d +% n.sons[i].offset), n.sons[i].typ, op) else: forAllSlotsAux(dest, n.sons[i], op) @@ -557,7 +557,7 @@ proc addNewObjToZCT(res: PCell, gch: var GcHeap) {.inline.} = # we check the last 8 entries (cache line) for a slot that could be reused. # In 63% of all cases we succeed here! But we have to optimize the heck # out of this small linear search so that ``newObj`` is not slowed down. - # + # # Slots to try cache hit # 1 32% # 4 59% @@ -602,7 +602,7 @@ proc rawNewObj(typ: PNimType, size: int, gch: var GcHeap, rc1 = false): pointer acquire(gch) sysAssert(allocInv(gch.region), "rawNewObj begin") sysAssert(typ.kind in {tyRef, tyString, tySequence}, "newObj: 1") - + collectCT(gch) sysAssert(allocInv(gch.region), "rawNewObj after collect") @@ -610,16 +610,16 @@ proc rawNewObj(typ: PNimType, size: int, gch: var GcHeap, rc1 = false): pointer sysAssert(allocInv(gch.region), "rawNewObj after rawAlloc") sysAssert((cast[ByteAddress](res) and (MemAlign-1)) == 0, "newObj: 2") - + res.typ = typ - + when trackAllocationSource and not hasThreadSupport: if framePtr != nil and framePtr.prev != nil and framePtr.prev.prev != nil: res.filename = framePtr.prev.prev.filename res.line = framePtr.prev.prev.line else: res.filename = "nofile" - + if rc1: res.refcount = rcIncrement # refcount is 1 else: @@ -631,9 +631,9 @@ proc rawNewObj(typ: PNimType, size: int, gch: var GcHeap, rc1 = false): pointer res.setBit(rcInCycleRoots) res.setColor rcCycleCandidate gch.cycleRoots.add res - + sysAssert(isAllocatedPtr(gch.region, res), "newObj: 3") - + when logGC: writeCell("new cell", res) gcTrace(res, csAllocated) release(gch) @@ -711,9 +711,9 @@ proc growObj(old: pointer, newsize: int, gch: var GcHeap): pointer = var res = cast[PCell](rawAlloc(gch.region, newsize + sizeof(Cell))) var elemSize = if ol.typ.kind != tyString: ol.typ.base.size else: 1 - + var oldsize = cast[PGenericSeq](old).len*elemSize + GenericSeqSize - + # XXX: This should happen outside # call user-defined move code # call user-defined default constructor @@ -723,24 +723,24 @@ proc growObj(old: pointer, newsize: int, gch: var GcHeap): pointer = sysAssert((cast[ByteAddress](res) and (MemAlign-1)) == 0, "growObj: 3") sysAssert(res.refcount shr rcShift <=% 1, "growObj: 4") - + when false: if ol.isBitUp(rcZct): var j = gch.zct.len-1 var d = gch.zct.d - while j >= 0: + while j >= 0: if d[j] == ol: d[j] = res break dec(j) - + if ol.isBitUp(rcInCycleRoots): for i in 0 .. 0: repeat @@ -1030,12 +1030,12 @@ proc gcMark(gch: var GcHeap, p: pointer) {.inline.} = add(gch.decStack, cell) sysAssert(allocInv(gch.region), "gcMark end") -proc markThreadStacks(gch: var GcHeap) = +proc markThreadStacks(gch: var GcHeap) = when hasThreadSupport and hasSharedHeap: {.error: "not fully implemented".} var it = threadList while it != nil: - # mark registers: + # mark registers: for i in 0 .. high(it.registers): gcMark(gch, it.registers[i]) var sp = cast[ByteAddress](it.stackBottom) var max = cast[ByteAddress](it.stackTop) @@ -1121,7 +1121,7 @@ elif stackIncreases: var b = cast[ByteAddress](stackTop) var x = cast[ByteAddress](p) result = a <=% x and x <=% b - + proc markStackAndRegisters(gch: var GcHeap) {.noinline, cdecl.} = var registers: C_JmpBuf if c_setjmp(registers) == 0'i32: # To fill the C stack with registers. @@ -1156,7 +1156,7 @@ else: # mark the registers var jmpbufPtr = cast[ByteAddress](addr(registers)) var jmpbufEnd = jmpbufPtr +% jmpbufSize - + while jmpbufPtr <=% jmpbufEnd: gcMark(gch, cast[PPointer](jmpbufPtr)[]) jmpbufPtr = jmpbufPtr +% sizeof(pointer) @@ -1218,18 +1218,18 @@ proc releaseCell(gch: var GcHeap, cell: PCell) = proc collectZCT(gch: var GcHeap): bool = const workPackage = 100 var L = addr(gch.zct.len) - + when withRealtime: var steps = workPackage var t0: Ticks if gch.maxPause > 0: t0 = getticks() - + while L[] > 0: var c = gch.zct.d[0] sysAssert c.isBitUp(rcZct), "collectZCT: rcZct missing!" sysAssert(isAllocatedPtr(gch.region, c), "collectZCT: isAllocatedPtr") - - # remove from ZCT: + + # remove from ZCT: c.clearBit(rcZct) gch.zct.d[0] = gch.zct.d[L[] - 1] dec(L[]) @@ -1237,7 +1237,7 @@ proc collectZCT(gch: var GcHeap): bool = if c.refcount <% rcIncrement: # It may have a RC > 0, if it is in the hardware stack or # it has not been removed yet from the ZCT. This is because - # ``incref`` does not bother to remove the cell from the ZCT + # ``incref`` does not bother to remove the cell from the ZCT # as this might be too slow. # In any case, it should be removed from the ZCT. But not # freed. **KEEP THIS IN MIND WHEN MAKING THIS INCREMENTAL!** @@ -1252,7 +1252,7 @@ proc collectZCT(gch: var GcHeap): bool = steps = workPackage if gch.maxPause > 0: let duration = getticks() - t0 - # the GC's measuring is not accurate and needs some cleanup actions + # the GC's measuring is not accurate and needs some cleanup actions # (stack unmarking), so subtract some short amount of time in to # order to miss deadlines less often: if duration >= gch.maxPause - 50_000: @@ -1269,7 +1269,7 @@ proc unmarkStackAndRegisters(gch: var GcHeap) = # XXX: just call doDecRef? var c = d[i] sysAssert c.typ != nil, "unmarkStackAndRegisters 2" - + if c.color == rcRetiredBuffer: continue @@ -1278,7 +1278,7 @@ proc unmarkStackAndRegisters(gch: var GcHeap) = # the object survived only because of a stack reference # it still doesn't have heap references addZCT(gch.zct, c) - + if canbeCycleRoot(c): # any cyclic object reachable from the stack can be turned into # a leak if it's orphaned through the stack reference @@ -1293,7 +1293,7 @@ proc collectCTBody(gch: var GcHeap) = let t0 = getticks() when debugGC: inc gcCollectionIdx sysAssert(allocInv(gch.region), "collectCT: begin") - + gch.stat.maxStackSize = max(gch.stat.maxStackSize, stackSize()) sysAssert(gch.decStack.len == 0, "collectCT") prepareForInteriorPointerChecking(gch.region) @@ -1312,7 +1312,7 @@ proc collectCTBody(gch: var GcHeap) = gch.stat.maxThreshold = max(gch.stat.maxThreshold, gch.cycleThreshold) unmarkStackAndRegisters(gch) sysAssert(allocInv(gch.region), "collectCT: end") - + when withRealtime: let duration = getticks() - t0 gch.stat.maxPause = max(gch.stat.maxPause, duration) @@ -1322,7 +1322,7 @@ proc collectCTBody(gch: var GcHeap) = proc collectCT(gch: var GcHeap) = if (gch.zct.len >= ZctThreshold or (cycleGC and - getOccupiedMem(gch.region)>=gch.cycleThreshold) or alwaysGC) and + getOccupiedMem(gch.region)>=gch.cycleThreshold) or alwaysGC) and gch.recGcLock == 0: collectCTBody(gch) @@ -1337,7 +1337,7 @@ when withRealtime: acquire(gch) gch.maxPause = us.toNano if (gch.zct.len >= ZctThreshold or (cycleGC and - getOccupiedMem(gch.region)>=gch.cycleThreshold) or alwaysGC) or + getOccupiedMem(gch.region)>=gch.cycleThreshold) or alwaysGC) or strongAdvice: collectCTBody(gch) release(gch) @@ -1345,13 +1345,13 @@ when withRealtime: proc GC_step*(us: int, strongAdvice = false) = GC_step(gch, us, strongAdvice) when not defined(useNimRtl): - proc GC_disable() = + proc GC_disable() = when hasThreadSupport and hasSharedHeap: discard atomicInc(gch.recGcLock, 1) else: inc(gch.recGcLock) proc GC_enable() = - if gch.recGcLock > 0: + if gch.recGcLock > 0: when hasThreadSupport and hasSharedHeap: discard atomicDec(gch.recGcLock, 1) else: diff --git a/lib/system/gc_common.nim b/lib/system/gc_common.nim index c7dd667e47..ceb3623784 100644 --- a/lib/system/gc_common.nim +++ b/lib/system/gc_common.nim @@ -197,7 +197,7 @@ else: var x = cast[ByteAddress](p) if a <=% x and x <=% b: return true - + template forEachStackSlot(gch, gcMark: expr) {.immediate, dirty.} = # We use a jmp_buf buffer that is in the C stack. # Used to traverse the stack and registers assuming @@ -207,7 +207,7 @@ else: getRegisters(registers) for i in registers.low .. registers.high: gcMark(gch, cast[PPointer](registers[i])) - + for stack in items(gch.stack): stack.maxStackSize = max(stack.maxStackSize, stackSize(stack.starts)) var max = cast[ByteAddress](stack.starts) diff --git a/lib/system/inclrtl.nim b/lib/system/inclrtl.nim index d0dc38284f..201a99ca75 100644 --- a/lib/system/inclrtl.nim +++ b/lib/system/inclrtl.nim @@ -20,21 +20,21 @@ when not defined(nimNewShared): {.pragma: gcsafe.} when defined(createNimRtl): - when defined(useNimRtl): + when defined(useNimRtl): {.error: "Cannot create and use nimrtl at the same time!".} elif appType != "lib": {.error: "nimrtl must be built as a library!".} -when defined(createNimRtl): +when defined(createNimRtl): {.pragma: rtl, exportc: "nimrtl_$1", dynlib, gcsafe.} {.pragma: inl.} {.pragma: compilerRtl, compilerproc, exportc: "nimrtl_$1", dynlib.} elif defined(useNimRtl): - when defined(windows): + when defined(windows): const nimrtl* = "nimrtl.dll" elif defined(macosx): const nimrtl* = "libnimrtl.dylib" - else: + else: const nimrtl* = "libnimrtl.so" {.pragma: rtl, importc: "nimrtl_$1", dynlib: nimrtl, gcsafe.} {.pragma: inl.} diff --git a/lib/system/profiler.nim b/lib/system/profiler.nim index c93456fb32..4f600417e6 100644 --- a/lib/system/profiler.nim +++ b/lib/system/profiler.nim @@ -40,7 +40,7 @@ proc captureStackTrace(f: PFrame, st: var StackTrace) = while it != nil: inc(total) it = it.prev - for j in 1..total-i-(firstCalls-1): + for j in 1..total-i-(firstCalls-1): if b != nil: b = b.prev if total != i: st[i] = "..." diff --git a/lib/system/syslocks.nim b/lib/system/syslocks.nim index ec8c262759..7a113b9d40 100644 --- a/lib/system/syslocks.nim +++ b/lib/system/syslocks.nim @@ -23,7 +23,7 @@ when defined(Windows): SysCond = Handle {.deprecated: [THandle: Handle, TSysLock: SysLock, TSysCond: SysCond].} - + proc initSysLock(L: var SysLock) {.stdcall, noSideEffect, dynlib: "kernel32", importc: "InitializeCriticalSection".} ## Initializes the lock `L`. @@ -31,14 +31,14 @@ when defined(Windows): proc tryAcquireSysAux(L: var SysLock): int32 {.stdcall, noSideEffect, dynlib: "kernel32", importc: "TryEnterCriticalSection".} ## Tries to acquire the lock `L`. - - proc tryAcquireSys(L: var SysLock): bool {.inline.} = + + proc tryAcquireSys(L: var SysLock): bool {.inline.} = result = tryAcquireSysAux(L) != 0'i32 proc acquireSys(L: var SysLock) {.stdcall, noSideEffect, dynlib: "kernel32", importc: "EnterCriticalSection".} ## Acquires the lock `L`. - + proc releaseSys(L: var SysLock) {.stdcall, noSideEffect, dynlib: "kernel32", importc: "LeaveCriticalSection".} ## Releases the lock `L`. @@ -46,11 +46,11 @@ when defined(Windows): proc deinitSys(L: var SysLock) {.stdcall, noSideEffect, dynlib: "kernel32", importc: "DeleteCriticalSection".} - proc createEvent(lpEventAttributes: pointer, + proc createEvent(lpEventAttributes: pointer, bManualReset, bInitialState: int32, lpName: cstring): SysCond {.stdcall, noSideEffect, dynlib: "kernel32", importc: "CreateEventA".} - + proc closeHandle(hObject: Handle) {.stdcall, noSideEffect, dynlib: "kernel32", importc: "CloseHandle".} proc waitForSingleObject(hHandle: Handle, dwMilliseconds: int32): int32 {. @@ -58,7 +58,7 @@ when defined(Windows): proc signalSysCond(hEvent: SysCond) {.stdcall, noSideEffect, dynlib: "kernel32", importc: "SetEvent".} - + proc initSysCond(cond: var SysCond) {.inline.} = cond = createEvent(nil, 0'i32, 0'i32, nil) proc deinitSysCond(cond: var SysCond) {.inline.} = @@ -86,7 +86,7 @@ else: proc tryAcquireSysAux(L: var SysLock): cint {.noSideEffect, importc: "pthread_mutex_trylock", header: "".} - proc tryAcquireSys(L: var SysLock): bool {.inline.} = + proc tryAcquireSys(L: var SysLock): bool {.inline.} = result = tryAcquireSysAux(L) == 0'i32 proc releaseSys(L: var SysLock) {.noSideEffect, @@ -100,7 +100,7 @@ else: importc: "pthread_cond_wait", header: "", noSideEffect.} proc signalSysCond(cond: var SysCond) {. importc: "pthread_cond_signal", header: "", noSideEffect.} - + proc deinitSysCond(cond: var SysCond) {.noSideEffect, importc: "pthread_cond_destroy", header: "".} - + diff --git a/lib/system/sysspawn.nim b/lib/system/sysspawn.nim index 5f8f2b2c52..7aef86df99 100644 --- a/lib/system/sysspawn.nim +++ b/lib/system/sysspawn.nim @@ -9,7 +9,7 @@ ## Implements Nim's 'spawn'. -when not declared(NimString): +when not declared(NimString): {.error: "You must not import this module explicitly".} {.push stackTrace:off.} diff --git a/lib/system/timers.nim b/lib/system/timers.nim index 74748c5418..ac84188243 100644 --- a/lib/system/timers.nim +++ b/lib/system/timers.nim @@ -34,8 +34,8 @@ when defined(windows): elif defined(macosx): type - MachTimebaseInfoData {.pure, final, - importc: "mach_timebase_info_data_t", + MachTimebaseInfoData {.pure, final, + importc: "mach_timebase_info_data_t", header: "".} = object numer, denom: int32 {.deprecated: [TMachTimebaseInfoData: MachTimebaseInfoData].} @@ -46,10 +46,10 @@ elif defined(macosx): proc getTicks(): Ticks {.inline.} = result = Ticks(mach_absolute_time()) - + var timeBaseInfo: MachTimebaseInfoData mach_timebase_info(timeBaseInfo) - + proc `-`(a, b: Ticks): Nanos = result = (a.int64 - b.int64) * timeBaseInfo.numer div timeBaseInfo.denom @@ -57,10 +57,10 @@ elif defined(posixRealtime): type Clockid {.importc: "clockid_t", header: "", final.} = object - TimeSpec {.importc: "struct timespec", header: "", + TimeSpec {.importc: "struct timespec", header: "", final, pure.} = object ## struct timespec - tv_sec: int ## Seconds. - tv_nsec: int ## Nanoseconds. + tv_sec: int ## Seconds. + tv_nsec: int ## Nanoseconds. {.deprecated: [TClockid: Clickid, TTimeSpec: TimeSpec].} var @@ -77,12 +77,12 @@ elif defined(posixRealtime): proc `-`(a, b: Ticks): Nanos {.borrow.} else: - # fallback Posix implementation: + # fallback Posix implementation: type - Timeval {.importc: "struct timeval", header: "", + Timeval {.importc: "struct timeval", header: "", final, pure.} = object ## struct timeval - tv_sec: int ## Seconds. - tv_usec: int ## Microseconds. + tv_sec: int ## Seconds. + tv_usec: int ## Microseconds. {.deprecated: [Ttimeval: Timeval].} proc posix_gettimeofday(tp: var Timeval, unused: pointer = nil) {. importc: "gettimeofday", header: "".} @@ -90,7 +90,7 @@ else: proc getTicks(): Ticks = var t: Timeval posix_gettimeofday(t) - result = Ticks(int64(t.tv_sec) * 1000_000_000'i64 + + result = Ticks(int64(t.tv_sec) * 1000_000_000'i64 + int64(t.tv_usec) * 1000'i64) proc `-`(a, b: Ticks): Nanos {.borrow.} diff --git a/lib/system/widestrs.nim b/lib/system/widestrs.nim index 77310b2893..5a30a7c0f2 100644 --- a/lib/system/widestrs.nim +++ b/lib/system/widestrs.nim @@ -124,7 +124,7 @@ proc `$`*(w: WideCString, estimate: int, replacement: int = 0xFFFD): string = if ch >= UNI_SUR_HIGH_START and ch <= UNI_SUR_HIGH_END: # If the 16 bits following the high surrogate are in the source buffer... let ch2 = int(cast[uint16](w[i])) - + # If it's a low surrogate, convert to UTF32: if ch2 >= UNI_SUR_LOW_START and ch2 <= UNI_SUR_LOW_END: ch = (((ch and halfMask) shl halfShift) + (ch2 and halfMask)) + halfBase @@ -135,7 +135,7 @@ proc `$`*(w: WideCString, estimate: int, replacement: int = 0xFFFD): string = elif ch >= UNI_SUR_LOW_START and ch <= UNI_SUR_LOW_END: #invalid UTF-16 ch = replacement - + if ch < 0x80: result.add chr(ch) elif ch < 0x800: @@ -155,6 +155,6 @@ proc `$`*(w: WideCString, estimate: int, replacement: int = 0xFFFD): string = result.add chr(0xFFFD shr 12 or 0b1110_0000) result.add chr(0xFFFD shr 6 and ones(6) or 0b10_0000_00) result.add chr(0xFFFD and ones(6) or 0b10_0000_00) - + proc `$`*(s: WideCString): string = result = s $ 80 diff --git a/lib/wrappers/libsvm.nim b/lib/wrappers/libsvm.nim index 8cc3144127..ac58894100 100644 --- a/lib/wrappers/libsvm.nim +++ b/lib/wrappers/libsvm.nim @@ -10,9 +10,9 @@ ## This module is a low level wrapper for `libsvm`:idx:. {.deadCodeElim: on.} -const +const LIBSVM_VERSION* = 312 - + when defined(windows): const svmdll* = "libsvm.dll" elif defined(macosx): @@ -20,97 +20,97 @@ elif defined(macosx): else: const svmdll* = "libsvm.so" -type - Node*{.pure, final.} = object +type + Node*{.pure, final.} = object index*: cint value*: cdouble - Problem*{.pure, final.} = object + Problem*{.pure, final.} = object L*: cint y*: ptr cdouble x*: ptr ptr Node - Type*{.size: sizeof(cint).} = enum + Type*{.size: sizeof(cint).} = enum C_SVC, NU_SVC, ONE_CLASS, EPSILON_SVR, NU_SVR - - KernelType*{.size: sizeof(cint).} = enum + + KernelType*{.size: sizeof(cint).} = enum LINEAR, POLY, RBF, SIGMOID, PRECOMPUTED - - Parameter*{.pure, final.} = object + + Parameter*{.pure, final.} = object typ*: Type kernelType*: KernelType - degree*: cint # for poly - gamma*: cdouble # for poly/rbf/sigmoid - coef0*: cdouble # for poly/sigmoid - # these are for training only - cache_size*: cdouble # in MB - eps*: cdouble # stopping criteria - C*: cdouble # for C_SVC, EPSILON_SVR and NU_SVR - nr_weight*: cint # for C_SVC - weight_label*: ptr cint # for C_SVC - weight*: ptr cdouble # for C_SVC - nu*: cdouble # for NU_SVC, ONE_CLASS, and NU_SVR - p*: cdouble # for EPSILON_SVR - shrinking*: cint # use the shrinking heuristics - probability*: cint # do probability estimates + degree*: cint # for poly + gamma*: cdouble # for poly/rbf/sigmoid + coef0*: cdouble # for poly/sigmoid + # these are for training only + cache_size*: cdouble # in MB + eps*: cdouble # stopping criteria + C*: cdouble # for C_SVC, EPSILON_SVR and NU_SVR + nr_weight*: cint # for C_SVC + weight_label*: ptr cint # for C_SVC + weight*: ptr cdouble # for C_SVC + nu*: cdouble # for NU_SVC, ONE_CLASS, and NU_SVR + p*: cdouble # for EPSILON_SVR + shrinking*: cint # use the shrinking heuristics + probability*: cint # do probability estimates {.deprecated: [Tnode: Node, Tproblem: Problem, Ttype: Type, TKernelType: KernelType, Tparameter: Parameter].} # # svm_model -# +# -type - Model*{.pure, final.} = object - param*: Parameter # parameter - nr_class*: cint # number of classes, = 2 in regression/one class svm - L*: cint # total #SV +type + Model*{.pure, final.} = object + param*: Parameter # parameter + nr_class*: cint # number of classes, = 2 in regression/one class svm + L*: cint # total #SV SV*: ptr ptr Node # SVs (SV[l]) - sv_coef*: ptr ptr cdouble # coefficients for SVs in decision functions (sv_coef[k-1][l]) - rho*: ptr cdouble # constants in decision functions (rho[k*(k-1)/2]) - probA*: ptr cdouble # pariwise probability information - probB*: ptr cdouble # for classification only - label*: ptr cint # label of each class (label[k]) - nSV*: ptr cint # number of SVs for each class (nSV[k]) - # nSV[0] + nSV[1] + ... + nSV[k-1] = l - # XXX + sv_coef*: ptr ptr cdouble # coefficients for SVs in decision functions (sv_coef[k-1][l]) + rho*: ptr cdouble # constants in decision functions (rho[k*(k-1)/2]) + probA*: ptr cdouble # pariwise probability information + probB*: ptr cdouble # for classification only + label*: ptr cint # label of each class (label[k]) + nSV*: ptr cint # number of SVs for each class (nSV[k]) + # nSV[0] + nSV[1] + ... + nSV[k-1] = l + # XXX free_sv*: cint # 1 if svm_model is created by svm_load_model # 0 if svm_model is created by svm_train {.deprecated: [TModel: Model].} -proc train*(prob: ptr Problem, param: ptr Parameter): ptr Model{.cdecl, +proc train*(prob: ptr Problem, param: ptr Parameter): ptr Model{.cdecl, importc: "svm_train", dynlib: svmdll.} -proc cross_validation*(prob: ptr Problem, param: ptr Parameter, nr_fold: cint, - target: ptr cdouble){.cdecl, +proc cross_validation*(prob: ptr Problem, param: ptr Parameter, nr_fold: cint, + target: ptr cdouble){.cdecl, importc: "svm_cross_validation", dynlib: svmdll.} -proc save_model*(model_file_name: cstring, model: ptr Model): cint{.cdecl, +proc save_model*(model_file_name: cstring, model: ptr Model): cint{.cdecl, importc: "svm_save_model", dynlib: svmdll.} -proc load_model*(model_file_name: cstring): ptr Model{.cdecl, +proc load_model*(model_file_name: cstring): ptr Model{.cdecl, importc: "svm_load_model", dynlib: svmdll.} -proc get_svm_type*(model: ptr Model): cint{.cdecl, importc: "svm_get_svm_type", +proc get_svm_type*(model: ptr Model): cint{.cdecl, importc: "svm_get_svm_type", dynlib: svmdll.} -proc get_nr_class*(model: ptr Model): cint{.cdecl, importc: "svm_get_nr_class", +proc get_nr_class*(model: ptr Model): cint{.cdecl, importc: "svm_get_nr_class", dynlib: svmdll.} -proc get_labels*(model: ptr Model, label: ptr cint){.cdecl, +proc get_labels*(model: ptr Model, label: ptr cint){.cdecl, importc: "svm_get_labels", dynlib: svmdll.} -proc get_svr_probability*(model: ptr Model): cdouble{.cdecl, +proc get_svr_probability*(model: ptr Model): cdouble{.cdecl, importc: "svm_get_svr_probability", dynlib: svmdll.} proc predict_values*(model: ptr Model, x: ptr Node, dec_values: ptr cdouble): cdouble{. cdecl, importc: "svm_predict_values", dynlib: svmdll.} -proc predict*(model: ptr Model, x: ptr Node): cdouble{.cdecl, +proc predict*(model: ptr Model, x: ptr Node): cdouble{.cdecl, importc: "svm_predict", dynlib: svmdll.} -proc predict_probability*(model: ptr Model, x: ptr Node, - prob_estimates: ptr cdouble): cdouble{.cdecl, +proc predict_probability*(model: ptr Model, x: ptr Node, + prob_estimates: ptr cdouble): cdouble{.cdecl, importc: "svm_predict_probability", dynlib: svmdll.} -proc free_model_content*(model_ptr: ptr Model){.cdecl, +proc free_model_content*(model_ptr: ptr Model){.cdecl, importc: "svm_free_model_content", dynlib: svmdll.} -proc free_and_destroy_model*(model_ptr_ptr: ptr ptr Model){.cdecl, +proc free_and_destroy_model*(model_ptr_ptr: ptr ptr Model){.cdecl, importc: "svm_free_and_destroy_model", dynlib: svmdll.} -proc destroy_param*(param: ptr Parameter){.cdecl, importc: "svm_destroy_param", +proc destroy_param*(param: ptr Parameter){.cdecl, importc: "svm_destroy_param", dynlib: svmdll.} proc check_parameter*(prob: ptr Problem, param: ptr Parameter): cstring{. cdecl, importc: "svm_check_parameter", dynlib: svmdll.} -proc check_probability_model*(model: ptr Model): cint{.cdecl, +proc check_probability_model*(model: ptr Model): cint{.cdecl, importc: "svm_check_probability_model", dynlib: svmdll.} proc set_print_string_function*(print_func: proc (arg: cstring) {.cdecl.}){. diff --git a/lib/wrappers/mysql.nim b/lib/wrappers/mysql.nim index 73b82b5c68..8253e53a58 100644 --- a/lib/wrappers/mysql.nim +++ b/lib/wrappers/mysql.nim @@ -20,7 +20,7 @@ when defined(Unix): when defined(Windows): const lib = "libmysql.dll" -type +type my_bool* = bool Pmy_bool* = ptr my_bool PVIO* = pointer @@ -31,13 +31,13 @@ type PPByte* = pointer cuint* = cint -# ------------ Start of declaration in "mysql_com.h" --------------------- +# ------------ Start of declaration in "mysql_com.h" --------------------- # # ** Common definition between mysql server & client -# +# # Field/table name length -const +const NAME_LEN* = 64 HOSTNAME_LENGTH* = 60 USERNAME_LENGTH* = 16 @@ -46,27 +46,27 @@ const LOCAL_HOST* = "localhost" LOCAL_HOST_NAMEDPIPE* = '.' -const +const NAMEDPIPE* = "MySQL" SERVICENAME* = "MySQL" -type - Enum_server_command* = enum - COM_SLEEP, COM_QUIT, COM_INIT_DB, COM_QUERY, COM_FIELD_LIST, COM_CREATE_DB, - COM_DROP_DB, COM_REFRESH, COM_SHUTDOWN, COM_STATISTICS, COM_PROCESS_INFO, - COM_CONNECT, COM_PROCESS_KILL, COM_DEBUG, COM_PING, COM_TIME, - COM_DELAYED_INSERT, COM_CHANGE_USER, COM_BINLOG_DUMP, COM_TABLE_DUMP, - COM_CONNECT_OUT, COM_REGISTER_SLAVE, COM_STMT_PREPARE, COM_STMT_EXECUTE, - COM_STMT_SEND_LONG_DATA, COM_STMT_CLOSE, COM_STMT_RESET, COM_SET_OPTION, +type + Enum_server_command* = enum + COM_SLEEP, COM_QUIT, COM_INIT_DB, COM_QUERY, COM_FIELD_LIST, COM_CREATE_DB, + COM_DROP_DB, COM_REFRESH, COM_SHUTDOWN, COM_STATISTICS, COM_PROCESS_INFO, + COM_CONNECT, COM_PROCESS_KILL, COM_DEBUG, COM_PING, COM_TIME, + COM_DELAYED_INSERT, COM_CHANGE_USER, COM_BINLOG_DUMP, COM_TABLE_DUMP, + COM_CONNECT_OUT, COM_REGISTER_SLAVE, COM_STMT_PREPARE, COM_STMT_EXECUTE, + COM_STMT_SEND_LONG_DATA, COM_STMT_CLOSE, COM_STMT_RESET, COM_SET_OPTION, COM_STMT_FETCH, COM_END {.deprecated: [Tenum_server_command: Enum_server_command].} -const - SCRAMBLE_LENGTH* = 20 # Length of random string sent by server on handshake; - # this is also length of obfuscated password, +const + SCRAMBLE_LENGTH* = 20 # Length of random string sent by server on handshake; + # this is also length of obfuscated password, # received from client - SCRAMBLE_LENGTH_323* = 8 # length of password stored in the db: - # new passwords are preceded with '*' + SCRAMBLE_LENGTH_323* = 8 # length of password stored in the db: + # new passwords are preceded with '*' SCRAMBLED_PASSWORD_CHAR_LENGTH* = SCRAMBLE_LENGTH * 2 + 1 SCRAMBLED_PASSWORD_CHAR_LENGTH_323* = SCRAMBLE_LENGTH_323 * 2 NOT_NULL_FLAG* = 1 # Field can't be NULL @@ -77,7 +77,7 @@ const UNSIGNED_FLAG* = 32 # Field is unsigned ZEROFILL_FLAG* = 64 # Field is zerofill BINARY_FLAG* = 128 # Field is binary - # The following are only sent to new clients + # The following are only sent to new clients ENUM_FLAG* = 256 # field is an enum AUTO_INCREMENT_FLAG* = 512 # field is a autoincrement field TIMESTAMP_FLAG* = 1024 # Field is a timestamp @@ -96,7 +96,7 @@ const REFRESH_THREADS* = 32 # Flush thread cache REFRESH_SLAVE* = 64 # Reset master info and restart slave thread REFRESH_MASTER* = 128 # Remove all bin logs in the index and truncate the index - # The following can't be set with mysql_refresh() + # The following can't be set with mysql_refresh() REFRESH_READ_LOCK* = 16384 # Lock tables for read REFRESH_FAST* = 32768 # Intern flag REFRESH_QUERY_CACHE* = 65536 # RESET (remove all queries) from query cache @@ -129,9 +129,9 @@ const SERVER_QUERY_NO_GOOD_INDEX_USED* = 16 SERVER_QUERY_NO_INDEX_USED* = 32 # The server was able to fulfill the clients request and opened a # read-only non-scrollable cursor for a query. This flag comes - # in reply to COM_STMT_EXECUTE and COM_STMT_FETCH commands. + # in reply to COM_STMT_EXECUTE and COM_STMT_FETCH commands. SERVER_STATUS_CURSOR_EXISTS* = 64 # This flag is sent when a read-only cursor is exhausted, in reply to - # COM_STMT_FETCH command. + # COM_STMT_FETCH command. SERVER_STATUS_LAST_ROW_SENT* = 128 SERVER_STATUS_DB_DROPPED* = 256 # A database was dropped SERVER_STATUS_NO_BACKSLASH_ESCAPES* = 512 @@ -141,7 +141,7 @@ const NET_WAIT_TIMEOUT* = 8 * 60 * 60 # Wait for new query ONLY_KILL_QUERY* = 1 -const +const MAX_TINYINT_WIDTH* = 3 # Max width for a TINY w.o. sign MAX_SMALLINT_WIDTH* = 5 # Max width for a SHORT w.o. sign MAX_MEDIUMINT_WIDTH* = 8 # Max width for a INT24 w.o. sign @@ -150,9 +150,9 @@ const MAX_CHAR_WIDTH* = 255 # Max length for a CHAR column MAX_BLOB_WIDTH* = 8192 # Default width for blob -type +type Pst_net* = ptr St_net - St_net*{.final.} = object + St_net*{.final.} = object vio*: PVio buff*: cstring buff_end*: cstring @@ -169,7 +169,7 @@ type fcntl*: cint compress*: my_bool # The following variable is set if we are doing several queries in one # command ( as in LOAD TABLE ... FROM MASTER ), - # and do not want to confuse the client with OK at the wrong time + # and do not want to confuse the client with OK at the wrong time remain_in_buf*: int len*: int buf_length*: int @@ -182,7 +182,7 @@ type no_send_error*: my_bool # Set if OK packet is already sent, and # we do not need to send error messages # Pointer to query object in query cache, do not equal NULL (0) for - # queries in cache that have not stored its results yet + # queries in cache that have not stored its results yet # $endif last_error*: array[0..(ERRMSG_SIZE) - 1, char] sqlstate*: array[0..(SQLSTATE_LENGTH + 1) - 1, char] @@ -196,21 +196,21 @@ type PNET* = ptr NET {.deprecated: [Tst_net: St_net, TNET: NET].} -const +const packet_error* = - 1 -type - Enum_field_types* = enum # For backward compatibility - TYPE_DECIMAL, TYPE_TINY, TYPE_SHORT, TYPE_LONG, TYPE_FLOAT, TYPE_DOUBLE, - TYPE_NULL, TYPE_TIMESTAMP, TYPE_LONGLONG, TYPE_INT24, TYPE_DATE, TYPE_TIME, - TYPE_DATETIME, TYPE_YEAR, TYPE_NEWDATE, TYPE_VARCHAR, TYPE_BIT, - TYPE_NEWDECIMAL = 246, TYPE_ENUM = 247, TYPE_SET = 248, - TYPE_TINY_BLOB = 249, TYPE_MEDIUM_BLOB = 250, TYPE_LONG_BLOB = 251, - TYPE_BLOB = 252, TYPE_VAR_STRING = 253, TYPE_STRING = 254, +type + Enum_field_types* = enum # For backward compatibility + TYPE_DECIMAL, TYPE_TINY, TYPE_SHORT, TYPE_LONG, TYPE_FLOAT, TYPE_DOUBLE, + TYPE_NULL, TYPE_TIMESTAMP, TYPE_LONGLONG, TYPE_INT24, TYPE_DATE, TYPE_TIME, + TYPE_DATETIME, TYPE_YEAR, TYPE_NEWDATE, TYPE_VARCHAR, TYPE_BIT, + TYPE_NEWDECIMAL = 246, TYPE_ENUM = 247, TYPE_SET = 248, + TYPE_TINY_BLOB = 249, TYPE_MEDIUM_BLOB = 250, TYPE_LONG_BLOB = 251, + TYPE_BLOB = 252, TYPE_VAR_STRING = 253, TYPE_STRING = 254, TYPE_GEOMETRY = 255 {.deprecated: [Tenum_field_types: Enum_field_types].} -const +const CLIENT_MULTI_QUERIES* = CLIENT_MULTI_STATEMENTS FIELD_TYPE_DECIMAL* = TYPE_DECIMAL FIELD_TYPE_NEWDECIMAL* = TYPE_NEWDECIMAL @@ -239,67 +239,67 @@ const FIELD_TYPE_CHAR* = TYPE_TINY FIELD_TYPE_INTERVAL* = TYPE_ENUM FIELD_TYPE_GEOMETRY* = TYPE_GEOMETRY - FIELD_TYPE_BIT* = TYPE_BIT # Shutdown/kill enums and constants - # Bits for THD::killable. + FIELD_TYPE_BIT* = TYPE_BIT # Shutdown/kill enums and constants + # Bits for THD::killable. SHUTDOWN_KILLABLE_CONNECT* = chr(1 shl 0) SHUTDOWN_KILLABLE_TRANS* = chr(1 shl 1) SHUTDOWN_KILLABLE_LOCK_TABLE* = chr(1 shl 2) SHUTDOWN_KILLABLE_UPDATE* = chr(1 shl 3) -type - Enum_shutdown_level* = enum - SHUTDOWN_DEFAULT = 0, SHUTDOWN_WAIT_CONNECTIONS = 1, - SHUTDOWN_WAIT_TRANSACTIONS = 2, SHUTDOWN_WAIT_UPDATES = 8, - SHUTDOWN_WAIT_ALL_BUFFERS = 16, SHUTDOWN_WAIT_CRITICAL_BUFFERS = 17, +type + Enum_shutdown_level* = enum + SHUTDOWN_DEFAULT = 0, SHUTDOWN_WAIT_CONNECTIONS = 1, + SHUTDOWN_WAIT_TRANSACTIONS = 2, SHUTDOWN_WAIT_UPDATES = 8, + SHUTDOWN_WAIT_ALL_BUFFERS = 16, SHUTDOWN_WAIT_CRITICAL_BUFFERS = 17, KILL_QUERY = 254, KILL_CONNECTION = 255 - Enum_cursor_type* = enum # options for mysql_set_option - CURSOR_TYPE_NO_CURSOR = 0, CURSOR_TYPE_READ_ONLY = 1, + Enum_cursor_type* = enum # options for mysql_set_option + CURSOR_TYPE_NO_CURSOR = 0, CURSOR_TYPE_READ_ONLY = 1, CURSOR_TYPE_FOR_UPDATE = 2, CURSOR_TYPE_SCROLLABLE = 4 - Enum_mysql_set_option* = enum + Enum_mysql_set_option* = enum OPTION_MULTI_STATEMENTS_ON, OPTION_MULTI_STATEMENTS_OFF {.deprecated: [Tenum_shutdown_level: Enum_shutdown_level, Tenum_cursor_type: Enum_cursor_type, Tenum_mysql_set_option: Enum_mysql_set_option].} -proc my_net_init*(net: PNET, vio: PVio): my_bool{.cdecl, dynlib: lib, +proc my_net_init*(net: PNET, vio: PVio): my_bool{.cdecl, dynlib: lib, importc: "my_net_init".} -proc my_net_local_init*(net: PNET){.cdecl, dynlib: lib, +proc my_net_local_init*(net: PNET){.cdecl, dynlib: lib, importc: "my_net_local_init".} proc net_end*(net: PNET){.cdecl, dynlib: lib, importc: "net_end".} proc net_clear*(net: PNET){.cdecl, dynlib: lib, importc: "net_clear".} -proc net_realloc*(net: PNET, len: int): my_bool{.cdecl, dynlib: lib, +proc net_realloc*(net: PNET, len: int): my_bool{.cdecl, dynlib: lib, importc: "net_realloc".} proc net_flush*(net: PNET): my_bool{.cdecl, dynlib: lib, importc: "net_flush".} -proc my_net_write*(net: PNET, packet: cstring, length: int): my_bool{.cdecl, +proc my_net_write*(net: PNET, packet: cstring, length: int): my_bool{.cdecl, dynlib: lib, importc: "my_net_write".} -proc net_write_command*(net: PNET, command: char, header: cstring, +proc net_write_command*(net: PNET, command: char, header: cstring, head_len: int, packet: cstring, length: int): my_bool{. cdecl, dynlib: lib, importc: "net_write_command".} -proc net_real_write*(net: PNET, packet: cstring, length: int): cint{.cdecl, +proc net_real_write*(net: PNET, packet: cstring, length: int): cint{.cdecl, dynlib: lib, importc: "net_real_write".} proc my_net_read*(net: PNET): int{.cdecl, dynlib: lib, importc: "my_net_read".} # The following function is not meant for normal usage - # Currently it's used internally by manager.c -type + # Currently it's used internally by manager.c +type Psockaddr* = ptr Sockaddr Sockaddr*{.final.} = object # undefined structure {.deprecated: [Tsockaddr: Sockaddr].} proc my_connect*(s: my_socket, name: Psockaddr, namelen: cuint, timeout: cuint): cint{. cdecl, dynlib: lib, importc: "my_connect".} -type +type Prand_struct* = ptr Rand_struct - Rand_struct*{.final.} = object # The following is for user defined functions + Rand_struct*{.final.} = object # The following is for user defined functions seed1*: int seed2*: int max_value*: int max_value_dbl*: cdouble - Item_result* = enum + Item_result* = enum STRING_RESULT, REAL_RESULT, INT_RESULT, ROW_RESULT, DECIMAL_RESULT PItem_result* = ptr Item_result Pst_udf_args* = ptr St_udf_args - St_udf_args*{.final.} = object + St_udf_args*{.final.} = object arg_count*: cuint # Number of arguments arg_type*: PItem_result # Pointer to item_results args*: cstringArray # Pointer to item_results @@ -307,82 +307,82 @@ type maybe_null*: cstring # Length of string arguments attributes*: cstringArray # Pointer to attribute name attribute_lengths*: ptr int # Length of attribute arguments - + UDF_ARGS* = St_udf_args - PUDF_ARGS* = ptr UDF_ARGS # This holds information about the result + PUDF_ARGS* = ptr UDF_ARGS # This holds information about the result Pst_udf_init* = ptr St_udf_init - St_udf_init*{.final.} = object + St_udf_init*{.final.} = object maybe_null*: my_bool # 1 if function can return NULL decimals*: cuint # for real functions max_length*: int # For string functions theptr*: cstring # free pointer for function data const_item*: my_bool # free pointer for function data - + UDF_INIT* = St_udf_init - PUDF_INIT* = ptr UDF_INIT # Constants when using compression + PUDF_INIT* = ptr UDF_INIT # Constants when using compression {.deprecated: [Trand_stuct: Rand_struct, TItem_result: Item_result, Tst_udf_args: St_udf_args, TUDF_ARGS: UDF_ARGS, Tst_udf_init: St_udf_init, TUDF_INIT: UDF_INIT].} -const +const NET_HEADER_SIZE* = 4 # standard header size COMP_HEADER_SIZE* = 3 # compression header extra size - # Prototypes to password functions + # Prototypes to password functions # These functions are used for authentication by client and server and - # implemented in sql/password.c + # implemented in sql/password.c -proc randominit*(para1: Prand_struct, seed1: int, seed2: int){.cdecl, +proc randominit*(para1: Prand_struct, seed1: int, seed2: int){.cdecl, dynlib: lib, importc: "randominit".} -proc my_rnd*(para1: Prand_struct): cdouble{.cdecl, dynlib: lib, +proc my_rnd*(para1: Prand_struct): cdouble{.cdecl, dynlib: lib, importc: "my_rnd".} proc create_random_string*(fto: cstring, len: cuint, rand_st: Prand_struct){. cdecl, dynlib: lib, importc: "create_random_string".} -proc hash_password*(fto: int, password: cstring, password_len: cuint){.cdecl, +proc hash_password*(fto: int, password: cstring, password_len: cuint){.cdecl, dynlib: lib, importc: "hash_password".} -proc make_scrambled_password_323*(fto: cstring, password: cstring){.cdecl, +proc make_scrambled_password_323*(fto: cstring, password: cstring){.cdecl, dynlib: lib, importc: "make_scrambled_password_323".} -proc scramble_323*(fto: cstring, message: cstring, password: cstring){.cdecl, +proc scramble_323*(fto: cstring, message: cstring, password: cstring){.cdecl, dynlib: lib, importc: "scramble_323".} proc check_scramble_323*(para1: cstring, message: cstring, salt: int): my_bool{. cdecl, dynlib: lib, importc: "check_scramble_323".} -proc get_salt_from_password_323*(res: ptr int, password: cstring){.cdecl, +proc get_salt_from_password_323*(res: ptr int, password: cstring){.cdecl, dynlib: lib, importc: "get_salt_from_password_323".} -proc make_password_from_salt_323*(fto: cstring, salt: ptr int){.cdecl, +proc make_password_from_salt_323*(fto: cstring, salt: ptr int){.cdecl, dynlib: lib, importc: "make_password_from_salt_323".} -proc octet2hex*(fto: cstring, str: cstring, length: cuint): cstring{.cdecl, +proc octet2hex*(fto: cstring, str: cstring, length: cuint): cstring{.cdecl, dynlib: lib, importc: "octet2hex".} -proc make_scrambled_password*(fto: cstring, password: cstring){.cdecl, +proc make_scrambled_password*(fto: cstring, password: cstring){.cdecl, dynlib: lib, importc: "make_scrambled_password".} -proc scramble*(fto: cstring, message: cstring, password: cstring){.cdecl, +proc scramble*(fto: cstring, message: cstring, password: cstring){.cdecl, dynlib: lib, importc: "scramble".} proc check_scramble*(reply: cstring, message: cstring, hash_stage2: pointer): my_bool{. cdecl, dynlib: lib, importc: "check_scramble".} -proc get_salt_from_password*(res: pointer, password: cstring){.cdecl, +proc get_salt_from_password*(res: pointer, password: cstring){.cdecl, dynlib: lib, importc: "get_salt_from_password".} -proc make_password_from_salt*(fto: cstring, hash_stage2: pointer){.cdecl, +proc make_password_from_salt*(fto: cstring, hash_stage2: pointer){.cdecl, dynlib: lib, importc: "make_password_from_salt".} - # end of password.c -proc get_tty_password*(opt_message: cstring): cstring{.cdecl, dynlib: lib, + # end of password.c +proc get_tty_password*(opt_message: cstring): cstring{.cdecl, dynlib: lib, importc: "get_tty_password".} -proc errno_to_sqlstate*(errno: cuint): cstring{.cdecl, dynlib: lib, +proc errno_to_sqlstate*(errno: cuint): cstring{.cdecl, dynlib: lib, importc: "mysql_errno_to_sqlstate".} - # Some other useful functions -proc modify_defaults_file*(file_location: cstring, option: cstring, - option_value: cstring, section_name: cstring, - remove_option: cint): cint{.cdecl, dynlib: lib, + # Some other useful functions +proc modify_defaults_file*(file_location: cstring, option: cstring, + option_value: cstring, section_name: cstring, + remove_option: cint): cint{.cdecl, dynlib: lib, importc: "load_defaults".} -proc load_defaults*(conf_file: cstring, groups: cstringArray, argc: ptr cint, - argv: ptr cstringArray): cint{.cdecl, dynlib: lib, +proc load_defaults*(conf_file: cstring, groups: cstringArray, argc: ptr cint, + argv: ptr cstringArray): cint{.cdecl, dynlib: lib, importc: "load_defaults".} proc my_init*(): my_bool{.cdecl, dynlib: lib, importc: "my_init".} proc my_thread_init*(): my_bool{.cdecl, dynlib: lib, importc: "my_thread_init".} proc my_thread_end*(){.cdecl, dynlib: lib, importc: "my_thread_end".} -const +const NULL_LENGTH*: int = int(not (0)) # For net_store_length -const +const STMT_HEADER* = 4 - LONG_DATA_HEADER* = 6 # ------------ Stop of declaration in "mysql_com.h" ----------------------- + LONG_DATA_HEADER* = 6 # ------------ Stop of declaration in "mysql_com.h" ----------------------- # $include "mysql_time.h" # $include "mysql_version.h" # $include "typelib.h" @@ -391,13 +391,13 @@ const # mysql_port : cuint;cvar;external; # mysql_unix_port : Pchar;cvar;external; -const +const CLIENT_NET_READ_TIMEOUT* = 365 * 24 * 3600 # Timeout on read CLIENT_NET_WRITE_TIMEOUT* = 365 * 24 * 3600 # Timeout on write -type +type Pst_mysql_field* = ptr St_mysql_field - St_mysql_field*{.final.} = object + St_mysql_field*{.final.} = object name*: cstring # Name of column org_name*: cstring # Original column name, if an alias table*: cstring # Table of column if column was a field @@ -418,7 +418,7 @@ type decimals*: cuint # Number of decimals in field charsetnr*: cuint # Character set ftype*: Enum_field_types # Type of field. See mysql_com.h for types - + FIELD* = St_mysql_field PFIELD* = ptr FIELD PROW* = ptr ROW # return data as array of strings @@ -434,16 +434,16 @@ proc IS_BLOB*(n: int32): bool proc IS_NUM*(t: Enum_field_types): bool proc INTERNAL_NUM_FIELD*(f: Pst_mysql_field): bool proc IS_NUM_FIELD*(f: Pst_mysql_field): bool -type +type my_ulonglong* = int64 Pmy_ulonglong* = ptr my_ulonglong -const +const COUNT_ERROR* = not (my_ulonglong(0)) -type +type Pst_mysql_rows* = ptr St_mysql_rows - St_mysql_rows*{.final.} = object + St_mysql_rows*{.final.} = object next*: Pst_mysql_rows # list of rows data*: ROW len*: int @@ -451,25 +451,25 @@ type ROWS* = St_mysql_rows PROWS* = ptr ROWS PROW_OFFSET* = ptr ROW_OFFSET # offset to current row - ROW_OFFSET* = ROWS + ROW_OFFSET* = ROWS {.deprecated: [Tst_mysql_rows: St_mysql_rows, TROWS: ROWS, TROW_OFFSET: ROW_OFFSET].} - -const - ALLOC_MAX_BLOCK_TO_DROP* = 4096 - ALLOC_MAX_BLOCK_USAGE_BEFORE_DROP* = 10 # struct for once_alloc (block) -type +const + ALLOC_MAX_BLOCK_TO_DROP* = 4096 + ALLOC_MAX_BLOCK_USAGE_BEFORE_DROP* = 10 # struct for once_alloc (block) + +type Pst_used_mem* = ptr St_used_mem - St_used_mem*{.final.} = object + St_used_mem*{.final.} = object next*: Pst_used_mem # Next block in use left*: cuint # memory left in block size*: cuint # size of block - + USED_MEM* = St_used_mem PUSED_MEM* = ptr USED_MEM Pst_mem_root* = ptr St_mem_root - St_mem_root*{.final.} = object + St_mem_root*{.final.} = object free*: PUSED_MEM # blocks with free memory in it used*: PUSED_MEM # blocks almost without free memory pre_alloc*: PUSED_MEM # preallocated block @@ -477,18 +477,18 @@ type block_size*: cuint # initial block size block_num*: cuint # allocated blocks counter # first free block in queue test counter (if it exceed - # MAX_BLOCK_USAGE_BEFORE_DROP block will be dropped in 'used' list) + # MAX_BLOCK_USAGE_BEFORE_DROP block will be dropped in 'used' list) first_block_usage*: cuint error_handler*: proc (){.cdecl.} MEM_ROOT* = St_mem_root - PMEM_ROOT* = ptr MEM_ROOT # ------------ Stop of declaration in "my_alloc.h" ---------------------- + PMEM_ROOT* = ptr MEM_ROOT # ------------ Stop of declaration in "my_alloc.h" ---------------------- {.deprecated: [Tst_used_mem: St_used_mem, TUSED_MEM: USED_MEM, Tst_mem_root: St_mem_root, TMEM_ROOT: MEM_ROOT].} -type +type Pst_mysql_data* = ptr St_mysql_data - St_mysql_data*{.final.} = object + St_mysql_data*{.final.} = object rows*: my_ulonglong fields*: cuint data*: PROWS @@ -497,16 +497,16 @@ type DATA* = St_mysql_data PDATA* = ptr DATA - Option* = enum - OPT_CONNECT_TIMEOUT, OPT_COMPRESS, OPT_NAMED_PIPE, INIT_COMMAND, - READ_DEFAULT_FILE, READ_DEFAULT_GROUP, SET_CHARSET_DIR, SET_CHARSET_NAME, - OPT_LOCAL_INFILE, OPT_PROTOCOL, SHARED_MEMORY_BASE_NAME, OPT_READ_TIMEOUT, - OPT_WRITE_TIMEOUT, OPT_USE_RESULT, OPT_USE_REMOTE_CONNECTION, - OPT_USE_EMBEDDED_CONNECTION, OPT_GUESS_CONNECTION, SET_CLIENT_IP, + Option* = enum + OPT_CONNECT_TIMEOUT, OPT_COMPRESS, OPT_NAMED_PIPE, INIT_COMMAND, + READ_DEFAULT_FILE, READ_DEFAULT_GROUP, SET_CHARSET_DIR, SET_CHARSET_NAME, + OPT_LOCAL_INFILE, OPT_PROTOCOL, SHARED_MEMORY_BASE_NAME, OPT_READ_TIMEOUT, + OPT_WRITE_TIMEOUT, OPT_USE_RESULT, OPT_USE_REMOTE_CONNECTION, + OPT_USE_EMBEDDED_CONNECTION, OPT_GUESS_CONNECTION, SET_CLIENT_IP, SECURE_AUTH, REPORT_DATA_TRUNCATION, OPT_RECONNECT {.deprecated: [Tst_mysql_data: St_mysql_data, TDATA: DATA, Toption: Option].} -const +const MAX_MYSQL_MANAGER_ERR* = 256 MAX_MYSQL_MANAGER_MSG* = 256 MANAGER_OK* = 200 @@ -515,8 +515,8 @@ const MANAGER_CLIENT_ERR* = 450 MANAGER_INTERNAL_ERR* = 500 -type - St_dynamic_array*{.final.} = object +type + St_dynamic_array*{.final.} = object buffer*: cstring elements*: cuint max_element*: cuint @@ -526,7 +526,7 @@ type DYNAMIC_ARRAY* = St_dynamic_array Pst_dynamic_array* = ptr St_dynamic_array Pst_mysql_options* = ptr St_mysql_options - St_mysql_options*{.final.} = object + St_mysql_options*{.final.} = object connect_timeout*: cuint read_timeout*: cuint write_timeout*: cuint @@ -553,18 +553,18 @@ type use_ssl*: my_bool # if to use SSL or not compress*: my_bool named_pipe*: my_bool # On connect, find out the replication role of the server, and - # establish connections to all the peers + # establish connections to all the peers rpl_probe*: my_bool # Each call to mysql_real_query() will parse it to tell if it is a read - # or a write, and direct it to the slave or the master + # or a write, and direct it to the slave or the master rpl_parse*: my_bool # If set, never read from a master, only from slave, when doing - # a read that is replication-aware + # a read that is replication-aware no_master_reads*: my_bool separate_thread*: my_bool methods_to_use*: Option client_ip*: cstring secure_auth*: my_bool # Refuse client connecting to server if it uses old (pre-4.1.1) protocol report_data_truncation*: my_bool # 0 - never report, 1 - always report (default) - # function pointers for local infile support + # function pointers for local infile support local_infile_init*: proc (para1: var pointer, para2: cstring, para3: pointer): cint{. cdecl.} local_infile_read*: proc (para1: pointer, para2: cstring, para3: cuint): cint @@ -572,16 +572,16 @@ type local_infile_error*: proc (para1: pointer, para2: cstring, para3: cuint): cint local_infile_userdata*: pointer - Status* = enum + Status* = enum STATUS_READY, STATUS_GET_RESULT, STATUS_USE_RESULT Protocol_type* = enum # There are three types of queries - the ones that have to go to # the master, the ones that go to a slave, and the administrative - # type which must happen on the pivot connectioin - PROTOCOL_DEFAULT, PROTOCOL_TCP, PROTOCOL_SOCKET, PROTOCOL_PIPE, + # type which must happen on the pivot connectioin + PROTOCOL_DEFAULT, PROTOCOL_TCP, PROTOCOL_SOCKET, PROTOCOL_PIPE, PROTOCOL_MEMORY - Rpl_type* = enum + Rpl_type* = enum RPL_MASTER, RPL_SLAVE, RPL_ADMIN - Charset_info_st*{.final.} = object + Charset_info_st*{.final.} = object number*: cuint primary_number*: cuint binary_number*: cuint @@ -608,11 +608,11 @@ type escape_with_backslash_is_dangerous*: my_bool cset*: pointer # was ^MY_CHARSET_HANDLER coll*: pointer # was ^MY_COLLATION_HANDLER; - + CHARSET_INFO* = Charset_info_st Pcharset_info_st* = ptr Charset_info_st Pcharacter_set* = ptr Character_set - Character_set*{.final.} = object + Character_set*{.final.} = object number*: cuint state*: cuint csname*: cstring @@ -626,7 +626,7 @@ type PMY_CHARSET_INFO* = ptr MY_CHARSET_INFO Pst_mysql_methods* = ptr St_mysql_methods Pst_mysql* = ptr St_mysql - St_mysql*{.final.} = object + St_mysql*{.final.} = object net*: NET # Communication parameters connector_fd*: gptr # ConnectorFd for SSL host*: cstring @@ -659,9 +659,9 @@ type reconnect*: my_bool # set to 1 if automatic reconnect scramble*: array[0..(SCRAMBLE_LENGTH + 1) - 1, char] # session-wide random string # Set if this is the original connection, not a master or a slave we have - # added though mysql_rpl_probe() or mysql_set_master()/ mysql_add_slave() + # added though mysql_rpl_probe() or mysql_set_master()/ mysql_add_slave() rpl_pivot*: my_bool # Pointers to the master, and the next slave connections, points to - # itself if lone connection. + # itself if lone connection. master*: Pst_mysql next_slave*: Pst_mysql last_used_slave*: Pst_mysql # needed for round-robin slave pick @@ -669,13 +669,13 @@ type stmts*: pointer # was PList, list of all statements methods*: Pst_mysql_methods thd*: pointer # Points to boolean flag in MYSQL_RES or MYSQL_STMT. We set this flag - # from mysql_stmt_close if close had to cancel result set of this object. + # from mysql_stmt_close if close had to cancel result set of this object. unbuffered_fetch_owner*: Pmy_bool MySQL* = St_mysql PMySQL* = ptr MySQL Pst_mysql_res* = ptr St_mysql_res - St_mysql_res*{.final.} = object + St_mysql_res*{.final.} = object row_count*: my_ulonglong fields*: PFIELD data*: PDATA @@ -695,10 +695,10 @@ type PRES* = ptr RES Pst_mysql_stmt* = ptr St_mysql_stmt PSTMT* = ptr STMT - St_mysql_methods*{.final.} = object + St_mysql_methods*{.final.} = object read_query_result*: proc (MySQL: PMySQL): my_bool{.cdecl.} - advanced_command*: proc (MySQL: PMySQL, command: Enum_server_command, header: cstring, - header_length: int, arg: cstring, arg_length: int, + advanced_command*: proc (MySQL: PMySQL, command: Enum_server_command, header: cstring, + header_length: int, arg: cstring, arg_length: int, skip_check: my_bool): my_bool read_rows*: proc (MySQL: PMySQL, fields: PFIELD, fields_count: cuint): PDATA use_result*: proc (MySQL: PMySQL): PRES @@ -718,7 +718,7 @@ type METHODS* = St_mysql_methods PMETHODS* = ptr METHODS Pst_mysql_manager* = ptr St_mysql_manager - St_mysql_manager*{.final.} = object + St_mysql_manager*{.final.} = object net*: NET host*: cstring user*: cstring @@ -737,23 +737,23 @@ type MANAGER* = St_mysql_manager PMANAGER* = ptr MANAGER Pst_mysql_parameters* = ptr St_mysql_parameters - St_mysql_parameters*{.final.} = object + St_mysql_parameters*{.final.} = object p_max_allowed_packet*: ptr int p_net_buffer_length*: ptr int PARAMETERS* = St_mysql_parameters PPARAMETERS* = ptr PARAMETERS - Enum_mysql_stmt_state* = enum + Enum_mysql_stmt_state* = enum STMT_INIT_DONE = 1, STMT_PREPARE_DONE, STMT_EXECUTE_DONE, STMT_FETCH_DONE Pst_mysql_bind* = ptr St_mysql_bind - St_mysql_bind*{.final.} = object + St_mysql_bind*{.final.} = object len*: int # output length pointer is_null*: Pmy_bool # Pointer to null indicator buffer*: pointer # buffer to get/put data error*: PMy_bool # set this if you want to track data truncations happened during fetch buffer_type*: Enum_field_types # buffer type buffer_length*: int # buffer length, must be set for str/binary - # Following are for internal use. Set by mysql_stmt_bind_param + # Following are for internal use. Set by mysql_stmt_bind_param row_ptr*: ptr byte # for the current data position offset*: int # offset position for char/binary fetch length_value*: int # Used if length is 0 @@ -768,8 +768,8 @@ type skip_result*: proc (para1: Pst_mysql_bind, para2: PFIELD, row: PPbyte) BIND* = St_mysql_bind - PBIND* = ptr BIND # statement handler - St_mysql_stmt*{.final.} = object + PBIND* = ptr BIND # statement handler + St_mysql_stmt*{.final.} = object mem_root*: MEM_ROOT # root allocations mysql*: PMySQL # connection handle params*: PBIND # input parameters @@ -797,9 +797,9 @@ type unbuffered_fetch_cancelled*: my_bool update_max_length*: my_bool - STMT* = St_mysql_stmt - - Enum_stmt_attr_type* = enum + STMT* = St_mysql_stmt + + Enum_stmt_attr_type* = enum STMT_ATTR_UPDATE_MAX_LENGTH, STMT_ATTR_CURSOR_TYPE, STMT_ATTR_PREFETCH_ROWS {.deprecated: [Tst_dynamic_array: St_dynamic_array, Tst_mysql_options: St_mysql_options, TDYNAMIC_ARRAY: DYNAMIC_ARRAY, Tprotocol_type: Protocol_type, @@ -824,283 +824,283 @@ proc server_end*(){.cdecl, dynlib: lib, importc: "mysql_server_end".} # mysql_server_end() to free memory). The names are a bit misleading # (mysql_SERVER* to be used when using libmysqlCLIENT). So we add more general # names which suit well whether you're using libmysqld or libmysqlclient. We - # intend to promote these aliases over the mysql_server* ones. + # intend to promote these aliases over the mysql_server* ones. proc library_init*(argc: cint, argv: cstringArray, groups: cstringArray): cint{. cdecl, dynlib: lib, importc: "mysql_server_init".} proc library_end*(){.cdecl, dynlib: lib, importc: "mysql_server_end".} -proc get_parameters*(): PPARAMETERS{.stdcall, dynlib: lib, +proc get_parameters*(): PPARAMETERS{.stdcall, dynlib: lib, importc: "mysql_get_parameters".} # Set up and bring down a thread; these function should be called # for each thread in an application which opens at least one MySQL # connection. All uses of the connection(s) should be between these - # function calls. + # function calls. proc thread_init*(): my_bool{.stdcall, dynlib: lib, importc: "mysql_thread_init".} proc thread_end*(){.stdcall, dynlib: lib, importc: "mysql_thread_end".} # Functions to get information from the MYSQL and MYSQL_RES structures - # Should definitely be used if one uses shared libraries. -proc num_rows*(res: PRES): my_ulonglong{.stdcall, dynlib: lib, + # Should definitely be used if one uses shared libraries. +proc num_rows*(res: PRES): my_ulonglong{.stdcall, dynlib: lib, importc: "mysql_num_rows".} -proc num_fields*(res: PRES): cuint{.stdcall, dynlib: lib, +proc num_fields*(res: PRES): cuint{.stdcall, dynlib: lib, importc: "mysql_num_fields".} proc eof*(res: PRES): my_bool{.stdcall, dynlib: lib, importc: "mysql_eof".} -proc fetch_field_direct*(res: PRES, fieldnr: cuint): PFIELD{.stdcall, +proc fetch_field_direct*(res: PRES, fieldnr: cuint): PFIELD{.stdcall, dynlib: lib, importc: "mysql_fetch_field_direct".} -proc fetch_fields*(res: PRES): PFIELD{.stdcall, dynlib: lib, +proc fetch_fields*(res: PRES): PFIELD{.stdcall, dynlib: lib, importc: "mysql_fetch_fields".} -proc row_tell*(res: PRES): ROW_OFFSET{.stdcall, dynlib: lib, +proc row_tell*(res: PRES): ROW_OFFSET{.stdcall, dynlib: lib, importc: "mysql_row_tell".} -proc field_tell*(res: PRES): FIELD_OFFSET{.stdcall, dynlib: lib, +proc field_tell*(res: PRES): FIELD_OFFSET{.stdcall, dynlib: lib, importc: "mysql_field_tell".} -proc field_count*(MySQL: PMySQL): cuint{.stdcall, dynlib: lib, +proc field_count*(MySQL: PMySQL): cuint{.stdcall, dynlib: lib, importc: "mysql_field_count".} -proc affected_rows*(MySQL: PMySQL): my_ulonglong{.stdcall, dynlib: lib, +proc affected_rows*(MySQL: PMySQL): my_ulonglong{.stdcall, dynlib: lib, importc: "mysql_affected_rows".} -proc insert_id*(MySQL: PMySQL): my_ulonglong{.stdcall, dynlib: lib, +proc insert_id*(MySQL: PMySQL): my_ulonglong{.stdcall, dynlib: lib, importc: "mysql_insert_id".} proc errno*(MySQL: PMySQL): cuint{.stdcall, dynlib: lib, importc: "mysql_errno".} proc error*(MySQL: PMySQL): cstring{.stdcall, dynlib: lib, importc: "mysql_error".} proc sqlstate*(MySQL: PMySQL): cstring{.stdcall, dynlib: lib, importc: "mysql_sqlstate".} -proc warning_count*(MySQL: PMySQL): cuint{.stdcall, dynlib: lib, +proc warning_count*(MySQL: PMySQL): cuint{.stdcall, dynlib: lib, importc: "mysql_warning_count".} proc info*(MySQL: PMySQL): cstring{.stdcall, dynlib: lib, importc: "mysql_info".} proc thread_id*(MySQL: PMySQL): int{.stdcall, dynlib: lib, importc: "mysql_thread_id".} -proc character_set_name*(MySQL: PMySQL): cstring{.stdcall, dynlib: lib, +proc character_set_name*(MySQL: PMySQL): cstring{.stdcall, dynlib: lib, importc: "mysql_character_set_name".} -proc set_character_set*(MySQL: PMySQL, csname: cstring): int32{.stdcall, dynlib: lib, +proc set_character_set*(MySQL: PMySQL, csname: cstring): int32{.stdcall, dynlib: lib, importc: "mysql_set_character_set".} proc init*(MySQL: PMySQL): PMySQL{.stdcall, dynlib: lib, importc: "mysql_init".} -proc ssl_set*(MySQL: PMySQL, key: cstring, cert: cstring, ca: cstring, capath: cstring, - cipher: cstring): my_bool{.stdcall, dynlib: lib, +proc ssl_set*(MySQL: PMySQL, key: cstring, cert: cstring, ca: cstring, capath: cstring, + cipher: cstring): my_bool{.stdcall, dynlib: lib, importc: "mysql_ssl_set".} proc change_user*(MySQL: PMySQL, user: cstring, passwd: cstring, db: cstring): my_bool{. stdcall, dynlib: lib, importc: "mysql_change_user".} -proc real_connect*(MySQL: PMySQL, host: cstring, user: cstring, passwd: cstring, - db: cstring, port: cuint, unix_socket: cstring, - clientflag: int): PMySQL{.stdcall, dynlib: lib, +proc real_connect*(MySQL: PMySQL, host: cstring, user: cstring, passwd: cstring, + db: cstring, port: cuint, unix_socket: cstring, + clientflag: int): PMySQL{.stdcall, dynlib: lib, importc: "mysql_real_connect".} -proc select_db*(MySQL: PMySQL, db: cstring): cint{.stdcall, dynlib: lib, +proc select_db*(MySQL: PMySQL, db: cstring): cint{.stdcall, dynlib: lib, importc: "mysql_select_db".} proc query*(MySQL: PMySQL, q: cstring): cint{.stdcall, dynlib: lib, importc: "mysql_query".} -proc send_query*(MySQL: PMySQL, q: cstring, len: int): cint{.stdcall, dynlib: lib, +proc send_query*(MySQL: PMySQL, q: cstring, len: int): cint{.stdcall, dynlib: lib, importc: "mysql_send_query".} -proc real_query*(MySQL: PMySQL, q: cstring, len: int): cint{.stdcall, dynlib: lib, +proc real_query*(MySQL: PMySQL, q: cstring, len: int): cint{.stdcall, dynlib: lib, importc: "mysql_real_query".} -proc store_result*(MySQL: PMySQL): PRES{.stdcall, dynlib: lib, +proc store_result*(MySQL: PMySQL): PRES{.stdcall, dynlib: lib, importc: "mysql_store_result".} proc use_result*(MySQL: PMySQL): PRES{.stdcall, dynlib: lib, importc: "mysql_use_result".} - # perform query on master -proc master_query*(MySQL: PMySQL, q: cstring, len: int): my_bool{.stdcall, dynlib: lib, + # perform query on master +proc master_query*(MySQL: PMySQL, q: cstring, len: int): my_bool{.stdcall, dynlib: lib, importc: "mysql_master_query".} -proc master_send_query*(MySQL: PMySQL, q: cstring, len: int): my_bool{.stdcall, +proc master_send_query*(MySQL: PMySQL, q: cstring, len: int): my_bool{.stdcall, dynlib: lib, importc: "mysql_master_send_query".} - # perform query on slave -proc slave_query*(MySQL: PMySQL, q: cstring, len: int): my_bool{.stdcall, dynlib: lib, + # perform query on slave +proc slave_query*(MySQL: PMySQL, q: cstring, len: int): my_bool{.stdcall, dynlib: lib, importc: "mysql_slave_query".} -proc slave_send_query*(MySQL: PMySQL, q: cstring, len: int): my_bool{.stdcall, +proc slave_send_query*(MySQL: PMySQL, q: cstring, len: int): my_bool{.stdcall, dynlib: lib, importc: "mysql_slave_send_query".} -proc get_character_set_info*(MySQL: PMySQL, charset: PMY_CHARSET_INFO){.stdcall, +proc get_character_set_info*(MySQL: PMySQL, charset: PMY_CHARSET_INFO){.stdcall, dynlib: lib, importc: "mysql_get_character_set_info".} - # local infile support -const + # local infile support +const LOCAL_INFILE_ERROR_LEN* = 512 # procedure mysql_set_local_infile_handler(mysql:PMYSQL; local_infile_init:function (para1:Ppointer; para2:Pchar; para3:pointer):longint; local_infile_read:function (para1:pointer; para2:Pchar; para3:dword):longint; local_infile_end:procedure (_pa # para6:pointer);cdecl;external mysqllib name 'mysql_set_local_infile_handler'; -proc set_local_infile_default*(MySQL: PMySQL){.cdecl, dynlib: lib, +proc set_local_infile_default*(MySQL: PMySQL){.cdecl, dynlib: lib, importc: "mysql_set_local_infile_default".} # enable/disable parsing of all queries to decide if they go on master or - # slave -proc enable_rpl_parse*(MySQL: PMySQL){.stdcall, dynlib: lib, + # slave +proc enable_rpl_parse*(MySQL: PMySQL){.stdcall, dynlib: lib, importc: "mysql_enable_rpl_parse".} -proc disable_rpl_parse*(MySQL: PMySQL){.stdcall, dynlib: lib, +proc disable_rpl_parse*(MySQL: PMySQL){.stdcall, dynlib: lib, importc: "mysql_disable_rpl_parse".} - # get the value of the parse flag -proc rpl_parse_enabled*(MySQL: PMySQL): cint{.stdcall, dynlib: lib, + # get the value of the parse flag +proc rpl_parse_enabled*(MySQL: PMySQL): cint{.stdcall, dynlib: lib, importc: "mysql_rpl_parse_enabled".} - # enable/disable reads from master -proc enable_reads_from_master*(MySQL: PMySQL){.stdcall, dynlib: lib, + # enable/disable reads from master +proc enable_reads_from_master*(MySQL: PMySQL){.stdcall, dynlib: lib, importc: "mysql_enable_reads_from_master".} proc disable_reads_from_master*(MySQL: PMySQL){.stdcall, dynlib: lib, importc: "mysql_disable_reads_from_master".} - # get the value of the master read flag -proc reads_from_master_enabled*(MySQL: PMySQL): my_bool{.stdcall, dynlib: lib, + # get the value of the master read flag +proc reads_from_master_enabled*(MySQL: PMySQL): my_bool{.stdcall, dynlib: lib, importc: "mysql_reads_from_master_enabled".} -proc rpl_query_type*(q: cstring, length: cint): Rpl_type{.stdcall, dynlib: lib, +proc rpl_query_type*(q: cstring, length: cint): Rpl_type{.stdcall, dynlib: lib, importc: "mysql_rpl_query_type".} - # discover the master and its slaves + # discover the master and its slaves proc rpl_probe*(MySQL: PMySQL): my_bool{.stdcall, dynlib: lib, importc: "mysql_rpl_probe".} - # set the master, close/free the old one, if it is not a pivot + # set the master, close/free the old one, if it is not a pivot proc set_master*(MySQL: PMySQL, host: cstring, port: cuint, user: cstring, passwd: cstring): cint{. stdcall, dynlib: lib, importc: "mysql_set_master".} proc add_slave*(MySQL: PMySQL, host: cstring, port: cuint, user: cstring, passwd: cstring): cint{. stdcall, dynlib: lib, importc: "mysql_add_slave".} -proc shutdown*(MySQL: PMySQL, shutdown_level: Enum_shutdown_level): cint{.stdcall, +proc shutdown*(MySQL: PMySQL, shutdown_level: Enum_shutdown_level): cint{.stdcall, dynlib: lib, importc: "mysql_shutdown".} -proc dump_debug_info*(MySQL: PMySQL): cint{.stdcall, dynlib: lib, +proc dump_debug_info*(MySQL: PMySQL): cint{.stdcall, dynlib: lib, importc: "mysql_dump_debug_info".} -proc refresh*(sql: PMySQL, refresh_options: cuint): cint{.stdcall, dynlib: lib, +proc refresh*(sql: PMySQL, refresh_options: cuint): cint{.stdcall, dynlib: lib, importc: "mysql_refresh".} proc kill*(MySQL: PMySQL, pid: int): cint{.stdcall, dynlib: lib, importc: "mysql_kill".} -proc set_server_option*(MySQL: PMySQL, option: Enum_mysql_set_option): cint{.stdcall, +proc set_server_option*(MySQL: PMySQL, option: Enum_mysql_set_option): cint{.stdcall, dynlib: lib, importc: "mysql_set_server_option".} proc ping*(MySQL: PMySQL): cint{.stdcall, dynlib: lib, importc: "mysql_ping".} proc stat*(MySQL: PMySQL): cstring{.stdcall, dynlib: lib, importc: "mysql_stat".} -proc get_server_info*(MySQL: PMySQL): cstring{.stdcall, dynlib: lib, +proc get_server_info*(MySQL: PMySQL): cstring{.stdcall, dynlib: lib, importc: "mysql_get_server_info".} -proc get_client_info*(): cstring{.stdcall, dynlib: lib, +proc get_client_info*(): cstring{.stdcall, dynlib: lib, importc: "mysql_get_client_info".} -proc get_client_version*(): int{.stdcall, dynlib: lib, +proc get_client_version*(): int{.stdcall, dynlib: lib, importc: "mysql_get_client_version".} -proc get_host_info*(MySQL: PMySQL): cstring{.stdcall, dynlib: lib, +proc get_host_info*(MySQL: PMySQL): cstring{.stdcall, dynlib: lib, importc: "mysql_get_host_info".} -proc get_server_version*(MySQL: PMySQL): int{.stdcall, dynlib: lib, +proc get_server_version*(MySQL: PMySQL): int{.stdcall, dynlib: lib, importc: "mysql_get_server_version".} -proc get_proto_info*(MySQL: PMySQL): cuint{.stdcall, dynlib: lib, +proc get_proto_info*(MySQL: PMySQL): cuint{.stdcall, dynlib: lib, importc: "mysql_get_proto_info".} -proc list_dbs*(MySQL: PMySQL, wild: cstring): PRES{.stdcall, dynlib: lib, +proc list_dbs*(MySQL: PMySQL, wild: cstring): PRES{.stdcall, dynlib: lib, importc: "mysql_list_dbs".} -proc list_tables*(MySQL: PMySQL, wild: cstring): PRES{.stdcall, dynlib: lib, +proc list_tables*(MySQL: PMySQL, wild: cstring): PRES{.stdcall, dynlib: lib, importc: "mysql_list_tables".} -proc list_processes*(MySQL: PMySQL): PRES{.stdcall, dynlib: lib, +proc list_processes*(MySQL: PMySQL): PRES{.stdcall, dynlib: lib, importc: "mysql_list_processes".} -proc options*(MySQL: PMySQL, option: Option, arg: cstring): cint{.stdcall, dynlib: lib, +proc options*(MySQL: PMySQL, option: Option, arg: cstring): cint{.stdcall, dynlib: lib, importc: "mysql_options".} -proc free_result*(result: PRES){.stdcall, dynlib: lib, +proc free_result*(result: PRES){.stdcall, dynlib: lib, importc: "mysql_free_result".} -proc data_seek*(result: PRES, offset: my_ulonglong){.stdcall, dynlib: lib, +proc data_seek*(result: PRES, offset: my_ulonglong){.stdcall, dynlib: lib, importc: "mysql_data_seek".} -proc row_seek*(result: PRES, offset: ROW_OFFSET): ROW_OFFSET{.stdcall, +proc row_seek*(result: PRES, offset: ROW_OFFSET): ROW_OFFSET{.stdcall, dynlib: lib, importc: "mysql_row_seek".} -proc field_seek*(result: PRES, offset: FIELD_OFFSET): FIELD_OFFSET{.stdcall, +proc field_seek*(result: PRES, offset: FIELD_OFFSET): FIELD_OFFSET{.stdcall, dynlib: lib, importc: "mysql_field_seek".} -proc fetch_row*(result: PRES): ROW{.stdcall, dynlib: lib, +proc fetch_row*(result: PRES): ROW{.stdcall, dynlib: lib, importc: "mysql_fetch_row".} -proc fetch_lengths*(result: PRES): ptr int{.stdcall, dynlib: lib, +proc fetch_lengths*(result: PRES): ptr int{.stdcall, dynlib: lib, importc: "mysql_fetch_lengths".} -proc fetch_field*(result: PRES): PFIELD{.stdcall, dynlib: lib, +proc fetch_field*(result: PRES): PFIELD{.stdcall, dynlib: lib, importc: "mysql_fetch_field".} -proc list_fields*(MySQL: PMySQL, table: cstring, wild: cstring): PRES{.stdcall, +proc list_fields*(MySQL: PMySQL, table: cstring, wild: cstring): PRES{.stdcall, dynlib: lib, importc: "mysql_list_fields".} proc escape_string*(fto: cstring, `from`: cstring, from_length: int): int{. stdcall, dynlib: lib, importc: "mysql_escape_string".} -proc hex_string*(fto: cstring, `from`: cstring, from_length: int): int{.stdcall, +proc hex_string*(fto: cstring, `from`: cstring, from_length: int): int{.stdcall, dynlib: lib, importc: "mysql_hex_string".} proc real_escape_string*(MySQL: PMySQL, fto: cstring, `from`: cstring, len: int): int{. stdcall, dynlib: lib, importc: "mysql_real_escape_string".} proc debug*(debug: cstring){.stdcall, dynlib: lib, importc: "mysql_debug".} # function mysql_odbc_escape_string(mysql:PMYSQL; fto:Pchar; to_length:dword; from:Pchar; from_length:dword; # param:pointer; extend_buffer:function (para1:pointer; to:Pchar; length:Pdword):Pchar):Pchar;stdcall;external mysqllib name 'mysql_odbc_escape_string'; -proc myodbc_remove_escape*(MySQL: PMySQL, name: cstring){.stdcall, dynlib: lib, +proc myodbc_remove_escape*(MySQL: PMySQL, name: cstring){.stdcall, dynlib: lib, importc: "myodbc_remove_escape".} proc thread_safe*(): cuint{.stdcall, dynlib: lib, importc: "mysql_thread_safe".} proc embedded*(): my_bool{.stdcall, dynlib: lib, importc: "mysql_embedded".} -proc manager_init*(con: PMANAGER): PMANAGER{.stdcall, dynlib: lib, +proc manager_init*(con: PMANAGER): PMANAGER{.stdcall, dynlib: lib, importc: "mysql_manager_init".} -proc manager_connect*(con: PMANAGER, host: cstring, user: cstring, - passwd: cstring, port: cuint): PMANAGER{.stdcall, +proc manager_connect*(con: PMANAGER, host: cstring, user: cstring, + passwd: cstring, port: cuint): PMANAGER{.stdcall, dynlib: lib, importc: "mysql_manager_connect".} -proc manager_close*(con: PMANAGER){.stdcall, dynlib: lib, +proc manager_close*(con: PMANAGER){.stdcall, dynlib: lib, importc: "mysql_manager_close".} proc manager_command*(con: PMANAGER, cmd: cstring, cmd_len: cint): cint{. stdcall, dynlib: lib, importc: "mysql_manager_command".} proc manager_fetch_line*(con: PMANAGER, res_buf: cstring, res_buf_size: cint): cint{. stdcall, dynlib: lib, importc: "mysql_manager_fetch_line".} -proc read_query_result*(MySQL: PMySQL): my_bool{.stdcall, dynlib: lib, +proc read_query_result*(MySQL: PMySQL): my_bool{.stdcall, dynlib: lib, importc: "mysql_read_query_result".} proc stmt_init*(MySQL: PMySQL): PSTMT{.stdcall, dynlib: lib, importc: "mysql_stmt_init".} -proc stmt_prepare*(stmt: PSTMT, query: cstring, len: int): cint{.stdcall, +proc stmt_prepare*(stmt: PSTMT, query: cstring, len: int): cint{.stdcall, dynlib: lib, importc: "mysql_stmt_prepare".} -proc stmt_execute*(stmt: PSTMT): cint{.stdcall, dynlib: lib, +proc stmt_execute*(stmt: PSTMT): cint{.stdcall, dynlib: lib, importc: "mysql_stmt_execute".} -proc stmt_fetch*(stmt: PSTMT): cint{.stdcall, dynlib: lib, +proc stmt_fetch*(stmt: PSTMT): cint{.stdcall, dynlib: lib, importc: "mysql_stmt_fetch".} proc stmt_fetch_column*(stmt: PSTMT, `bind`: PBIND, column: cuint, offset: int): cint{. stdcall, dynlib: lib, importc: "mysql_stmt_fetch_column".} -proc stmt_store_result*(stmt: PSTMT): cint{.stdcall, dynlib: lib, +proc stmt_store_result*(stmt: PSTMT): cint{.stdcall, dynlib: lib, importc: "mysql_stmt_store_result".} -proc stmt_param_count*(stmt: PSTMT): int{.stdcall, dynlib: lib, +proc stmt_param_count*(stmt: PSTMT): int{.stdcall, dynlib: lib, importc: "mysql_stmt_param_count".} proc stmt_attr_set*(stmt: PSTMT, attr_type: Enum_stmt_attr_type, attr: pointer): my_bool{. stdcall, dynlib: lib, importc: "mysql_stmt_attr_set".} proc stmt_attr_get*(stmt: PSTMT, attr_type: Enum_stmt_attr_type, attr: pointer): my_bool{. stdcall, dynlib: lib, importc: "mysql_stmt_attr_get".} -proc stmt_bind_param*(stmt: PSTMT, bnd: PBIND): my_bool{.stdcall, dynlib: lib, +proc stmt_bind_param*(stmt: PSTMT, bnd: PBIND): my_bool{.stdcall, dynlib: lib, importc: "mysql_stmt_bind_param".} -proc stmt_bind_result*(stmt: PSTMT, bnd: PBIND): my_bool{.stdcall, dynlib: lib, +proc stmt_bind_result*(stmt: PSTMT, bnd: PBIND): my_bool{.stdcall, dynlib: lib, importc: "mysql_stmt_bind_result".} -proc stmt_close*(stmt: PSTMT): my_bool{.stdcall, dynlib: lib, +proc stmt_close*(stmt: PSTMT): my_bool{.stdcall, dynlib: lib, importc: "mysql_stmt_close".} -proc stmt_reset*(stmt: PSTMT): my_bool{.stdcall, dynlib: lib, +proc stmt_reset*(stmt: PSTMT): my_bool{.stdcall, dynlib: lib, importc: "mysql_stmt_reset".} -proc stmt_free_result*(stmt: PSTMT): my_bool{.stdcall, dynlib: lib, +proc stmt_free_result*(stmt: PSTMT): my_bool{.stdcall, dynlib: lib, importc: "mysql_stmt_free_result".} -proc stmt_send_long_data*(stmt: PSTMT, param_number: cuint, data: cstring, - len: int): my_bool{.stdcall, dynlib: lib, +proc stmt_send_long_data*(stmt: PSTMT, param_number: cuint, data: cstring, + len: int): my_bool{.stdcall, dynlib: lib, importc: "mysql_stmt_send_long_data".} -proc stmt_result_metadata*(stmt: PSTMT): PRES{.stdcall, dynlib: lib, +proc stmt_result_metadata*(stmt: PSTMT): PRES{.stdcall, dynlib: lib, importc: "mysql_stmt_result_metadata".} -proc stmt_param_metadata*(stmt: PSTMT): PRES{.stdcall, dynlib: lib, +proc stmt_param_metadata*(stmt: PSTMT): PRES{.stdcall, dynlib: lib, importc: "mysql_stmt_param_metadata".} -proc stmt_errno*(stmt: PSTMT): cuint{.stdcall, dynlib: lib, +proc stmt_errno*(stmt: PSTMT): cuint{.stdcall, dynlib: lib, importc: "mysql_stmt_errno".} -proc stmt_error*(stmt: PSTMT): cstring{.stdcall, dynlib: lib, +proc stmt_error*(stmt: PSTMT): cstring{.stdcall, dynlib: lib, importc: "mysql_stmt_error".} -proc stmt_sqlstate*(stmt: PSTMT): cstring{.stdcall, dynlib: lib, +proc stmt_sqlstate*(stmt: PSTMT): cstring{.stdcall, dynlib: lib, importc: "mysql_stmt_sqlstate".} -proc stmt_row_seek*(stmt: PSTMT, offset: ROW_OFFSET): ROW_OFFSET{.stdcall, +proc stmt_row_seek*(stmt: PSTMT, offset: ROW_OFFSET): ROW_OFFSET{.stdcall, dynlib: lib, importc: "mysql_stmt_row_seek".} -proc stmt_row_tell*(stmt: PSTMT): ROW_OFFSET{.stdcall, dynlib: lib, +proc stmt_row_tell*(stmt: PSTMT): ROW_OFFSET{.stdcall, dynlib: lib, importc: "mysql_stmt_row_tell".} -proc stmt_data_seek*(stmt: PSTMT, offset: my_ulonglong){.stdcall, dynlib: lib, +proc stmt_data_seek*(stmt: PSTMT, offset: my_ulonglong){.stdcall, dynlib: lib, importc: "mysql_stmt_data_seek".} -proc stmt_num_rows*(stmt: PSTMT): my_ulonglong{.stdcall, dynlib: lib, +proc stmt_num_rows*(stmt: PSTMT): my_ulonglong{.stdcall, dynlib: lib, importc: "mysql_stmt_num_rows".} -proc stmt_affected_rows*(stmt: PSTMT): my_ulonglong{.stdcall, dynlib: lib, +proc stmt_affected_rows*(stmt: PSTMT): my_ulonglong{.stdcall, dynlib: lib, importc: "mysql_stmt_affected_rows".} -proc stmt_insert_id*(stmt: PSTMT): my_ulonglong{.stdcall, dynlib: lib, +proc stmt_insert_id*(stmt: PSTMT): my_ulonglong{.stdcall, dynlib: lib, importc: "mysql_stmt_insert_id".} -proc stmt_field_count*(stmt: PSTMT): cuint{.stdcall, dynlib: lib, +proc stmt_field_count*(stmt: PSTMT): cuint{.stdcall, dynlib: lib, importc: "mysql_stmt_field_count".} proc commit*(MySQL: PMySQL): my_bool{.stdcall, dynlib: lib, importc: "mysql_commit".} proc rollback*(MySQL: PMySQL): my_bool{.stdcall, dynlib: lib, importc: "mysql_rollback".} -proc autocommit*(MySQL: PMySQL, auto_mode: my_bool): my_bool{.stdcall, dynlib: lib, +proc autocommit*(MySQL: PMySQL, auto_mode: my_bool): my_bool{.stdcall, dynlib: lib, importc: "mysql_autocommit".} -proc more_results*(MySQL: PMySQL): my_bool{.stdcall, dynlib: lib, +proc more_results*(MySQL: PMySQL): my_bool{.stdcall, dynlib: lib, importc: "mysql_more_results".} proc next_result*(MySQL: PMySQL): cint{.stdcall, dynlib: lib, importc: "mysql_next_result".} proc close*(sock: PMySQL){.stdcall, dynlib: lib, importc: "mysql_close".} - # status return codes -const + # status return codes +const NO_DATA* = 100 DATA_TRUNCATED* = 101 proc reload*(x: PMySQL): cint -when defined(USE_OLD_FUNCTIONS): - proc connect*(MySQL: PMySQL, host: cstring, user: cstring, passwd: cstring): PMySQL{.stdcall, +when defined(USE_OLD_FUNCTIONS): + proc connect*(MySQL: PMySQL, host: cstring, user: cstring, passwd: cstring): PMySQL{.stdcall, dynlib: lib, importc: "mysql_connect".} - proc create_db*(MySQL: PMySQL, DB: cstring): cint{.stdcall, dynlib: lib, + proc create_db*(MySQL: PMySQL, DB: cstring): cint{.stdcall, dynlib: lib, importc: "mysql_create_db".} - proc drop_db*(MySQL: PMySQL, DB: cstring): cint{.stdcall, dynlib: lib, + proc drop_db*(MySQL: PMySQL, DB: cstring): cint{.stdcall, dynlib: lib, importc: "mysql_drop_db".} proc net_safe_read*(MySQL: PMySQL): cuint{.cdecl, dynlib: lib, importc: "net_safe_read".} -proc IS_PRI_KEY(n: int32): bool = +proc IS_PRI_KEY(n: int32): bool = result = (n and PRI_KEY_FLAG) != 0 -proc IS_NOT_NULL(n: int32): bool = +proc IS_NOT_NULL(n: int32): bool = result = (n and NOT_NULL_FLAG) != 0 -proc IS_BLOB(n: int32): bool = +proc IS_BLOB(n: int32): bool = result = (n and BLOB_FLAG) != 0 -proc IS_NUM_FIELD(f: Pst_mysql_field): bool = +proc IS_NUM_FIELD(f: Pst_mysql_field): bool = result = (f.flags and NUM_FLAG) != 0 -proc IS_NUM(t: Enum_field_types): bool = +proc IS_NUM(t: Enum_field_types): bool = result = (t <= FIELD_TYPE_INT24) or (t == FIELD_TYPE_YEAR) or (t == FIELD_TYPE_NEWDECIMAL) -proc INTERNAL_NUM_FIELD(f: Pst_mysql_field): bool = +proc INTERNAL_NUM_FIELD(f: Pst_mysql_field): bool = result = (f.ftype <= FIELD_TYPE_INT24) and ((f.ftype != FIELD_TYPE_TIMESTAMP) or (f.len == 14) or (f.len == 8)) or (f.ftype == FIELD_TYPE_YEAR) diff --git a/lib/wrappers/sqlite3.nim b/lib/wrappers/sqlite3.nim index bd107b0bc7..24c271ab7f 100644 --- a/lib/wrappers/sqlite3.nim +++ b/lib/wrappers/sqlite3.nim @@ -8,17 +8,17 @@ # {.deadCodeElim: on.} -when defined(windows): - const +when defined(windows): + const Lib = "sqlite3.dll" -elif defined(macosx): - const +elif defined(macosx): + const Lib = "libsqlite3(|.0).dylib" -else: - const +else: + const Lib = "libsqlite3.so(|.0)" - -const + +const SQLITE_INTEGER* = 1 SQLITE_FLOAT* = 2 SQLITE_BLOB* = 4 @@ -26,38 +26,38 @@ const SQLITE_TEXT* = 3 SQLITE_UTF8* = 1 SQLITE_UTF16LE* = 2 - SQLITE_UTF16BE* = 3 # Use native byte order - SQLITE_UTF16* = 4 # sqlite3_create_function only + SQLITE_UTF16BE* = 3 # Use native byte order + SQLITE_UTF16* = 4 # sqlite3_create_function only SQLITE_ANY* = 5 #sqlite_exec return values SQLITE_OK* = 0 - SQLITE_ERROR* = 1 # SQL error or missing database - SQLITE_INTERNAL* = 2 # An internal logic error in SQLite - SQLITE_PERM* = 3 # Access permission denied - SQLITE_ABORT* = 4 # Callback routine requested an abort - SQLITE_BUSY* = 5 # The database file is locked - SQLITE_LOCKED* = 6 # A table in the database is locked - SQLITE_NOMEM* = 7 # A malloc() failed - SQLITE_READONLY* = 8 # Attempt to write a readonly database - SQLITE_INTERRUPT* = 9 # Operation terminated by sqlite3_interrupt() - SQLITE_IOERR* = 10 # Some kind of disk I/O error occurred - SQLITE_CORRUPT* = 11 # The database disk image is malformed - SQLITE_NOTFOUND* = 12 # (Internal Only) Table or record not found - SQLITE_FULL* = 13 # Insertion failed because database is full - SQLITE_CANTOPEN* = 14 # Unable to open the database file - SQLITE_PROTOCOL* = 15 # Database lock protocol error - SQLITE_EMPTY* = 16 # Database is empty - SQLITE_SCHEMA* = 17 # The database schema changed - SQLITE_TOOBIG* = 18 # Too much data for one row of a table - SQLITE_CONSTRAINT* = 19 # Abort due to contraint violation - SQLITE_MISMATCH* = 20 # Data type mismatch - SQLITE_MISUSE* = 21 # Library used incorrectly - SQLITE_NOLFS* = 22 # Uses OS features not supported on host - SQLITE_AUTH* = 23 # Authorization denied - SQLITE_FORMAT* = 24 # Auxiliary database format error - SQLITE_RANGE* = 25 # 2nd parameter to sqlite3_bind out of range - SQLITE_NOTADB* = 26 # File opened that is not a database file - SQLITE_ROW* = 100 # sqlite3_step() has another row ready - SQLITE_DONE* = 101 # sqlite3_step() has finished executing + SQLITE_ERROR* = 1 # SQL error or missing database + SQLITE_INTERNAL* = 2 # An internal logic error in SQLite + SQLITE_PERM* = 3 # Access permission denied + SQLITE_ABORT* = 4 # Callback routine requested an abort + SQLITE_BUSY* = 5 # The database file is locked + SQLITE_LOCKED* = 6 # A table in the database is locked + SQLITE_NOMEM* = 7 # A malloc() failed + SQLITE_READONLY* = 8 # Attempt to write a readonly database + SQLITE_INTERRUPT* = 9 # Operation terminated by sqlite3_interrupt() + SQLITE_IOERR* = 10 # Some kind of disk I/O error occurred + SQLITE_CORRUPT* = 11 # The database disk image is malformed + SQLITE_NOTFOUND* = 12 # (Internal Only) Table or record not found + SQLITE_FULL* = 13 # Insertion failed because database is full + SQLITE_CANTOPEN* = 14 # Unable to open the database file + SQLITE_PROTOCOL* = 15 # Database lock protocol error + SQLITE_EMPTY* = 16 # Database is empty + SQLITE_SCHEMA* = 17 # The database schema changed + SQLITE_TOOBIG* = 18 # Too much data for one row of a table + SQLITE_CONSTRAINT* = 19 # Abort due to contraint violation + SQLITE_MISMATCH* = 20 # Data type mismatch + SQLITE_MISUSE* = 21 # Library used incorrectly + SQLITE_NOLFS* = 22 # Uses OS features not supported on host + SQLITE_AUTH* = 23 # Authorization denied + SQLITE_FORMAT* = 24 # Auxiliary database format error + SQLITE_RANGE* = 25 # 2nd parameter to sqlite3_bind out of range + SQLITE_NOTADB* = 26 # File opened that is not a database file + SQLITE_ROW* = 100 # sqlite3_step() has another row ready + SQLITE_DONE* = 101 # sqlite3_step() has finished executing SQLITE_COPY* = 0 SQLITE_CREATE_INDEX* = 1 SQLITE_CREATE_TABLE* = 2 @@ -87,39 +87,39 @@ const SQLITE_ALTER_TABLE* = 26 SQLITE_REINDEX* = 27 SQLITE_DENY* = 1 - SQLITE_IGNORE* = 2 # Original from sqlite3.h: + SQLITE_IGNORE* = 2 # Original from sqlite3.h: #define SQLITE_STATIC ((void(*)(void *))0) #define SQLITE_TRANSIENT ((void(*)(void *))-1) SQLITE_DETERMINISTIC* = 0x800 -const +const SQLITE_STATIC* = nil SQLITE_TRANSIENT* = cast[pointer](- 1) -type - Sqlite3 {.pure, final.} = object +type + Sqlite3 {.pure, final.} = object PSqlite3* = ptr Sqlite3 PPSqlite3* = ptr PSqlite3 - Context{.pure, final.} = object + Context{.pure, final.} = object Pcontext* = ptr Context - Tstmt{.pure, final.} = object + Tstmt{.pure, final.} = object Pstmt* = ptr Tstmt - Value{.pure, final.} = object + Value{.pure, final.} = object Pvalue* = ptr Value PValueArg* = array[0..127, Pvalue] - - Callback* = proc (para1: pointer, para2: int32, para3, + + Callback* = proc (para1: pointer, para2: int32, para3, para4: cstringArray): int32{.cdecl.} Tbind_destructor_func* = proc (para1: pointer){.cdecl.} - Create_function_step_func* = proc (para1: Pcontext, para2: int32, + Create_function_step_func* = proc (para1: Pcontext, para2: int32, para3: PValueArg){.cdecl.} - Create_function_func_func* = proc (para1: Pcontext, para2: int32, + Create_function_func_func* = proc (para1: Pcontext, para2: int32, para3: PValueArg){.cdecl.} Create_function_final_func* = proc (para1: Pcontext){.cdecl.} Result_func* = proc (para1: pointer){.cdecl.} - Create_collation_func* = proc (para1: pointer, para2: int32, para3: pointer, + Create_collation_func* = proc (para1: pointer, para2: int32, para3: pointer, para4: int32, para5: pointer): int32{.cdecl.} - Collation_needed_func* = proc (para1: pointer, para2: PSqlite3, eTextRep: int32, + Collation_needed_func* = proc (para1: pointer, para2: PSqlite3, eTextRep: int32, para4: cstring){.cdecl.} {.deprecated: [TSqlite3: Sqlite3, TContext: Context, Tvalue: Value, Tcallback: Callback, Tcreate_function_step_func: Create_function_step_func, @@ -129,220 +129,220 @@ type Tcollation_needed_func: Collation_needed_func].} proc close*(para1: PSqlite3): int32{.cdecl, dynlib: Lib, importc: "sqlite3_close".} -proc exec*(para1: PSqlite3, sql: cstring, para3: Callback, para4: pointer, - errmsg: var cstring): int32{.cdecl, dynlib: Lib, +proc exec*(para1: PSqlite3, sql: cstring, para3: Callback, para4: pointer, + errmsg: var cstring): int32{.cdecl, dynlib: Lib, importc: "sqlite3_exec".} -proc last_insert_rowid*(para1: PSqlite3): int64{.cdecl, dynlib: Lib, +proc last_insert_rowid*(para1: PSqlite3): int64{.cdecl, dynlib: Lib, importc: "sqlite3_last_insert_rowid".} proc changes*(para1: PSqlite3): int32{.cdecl, dynlib: Lib, importc: "sqlite3_changes".} -proc total_changes*(para1: PSqlite3): int32{.cdecl, dynlib: Lib, +proc total_changes*(para1: PSqlite3): int32{.cdecl, dynlib: Lib, importc: "sqlite3_total_changes".} proc interrupt*(para1: PSqlite3){.cdecl, dynlib: Lib, importc: "sqlite3_interrupt".} -proc complete*(sql: cstring): int32{.cdecl, dynlib: Lib, +proc complete*(sql: cstring): int32{.cdecl, dynlib: Lib, importc: "sqlite3_complete".} -proc complete16*(sql: pointer): int32{.cdecl, dynlib: Lib, +proc complete16*(sql: pointer): int32{.cdecl, dynlib: Lib, importc: "sqlite3_complete16".} -proc busy_handler*(para1: PSqlite3, - para2: proc (para1: pointer, para2: int32): int32{.cdecl.}, - para3: pointer): int32{.cdecl, dynlib: Lib, +proc busy_handler*(para1: PSqlite3, + para2: proc (para1: pointer, para2: int32): int32{.cdecl.}, + para3: pointer): int32{.cdecl, dynlib: Lib, importc: "sqlite3_busy_handler".} -proc busy_timeout*(para1: PSqlite3, ms: int32): int32{.cdecl, dynlib: Lib, +proc busy_timeout*(para1: PSqlite3, ms: int32): int32{.cdecl, dynlib: Lib, importc: "sqlite3_busy_timeout".} -proc get_table*(para1: PSqlite3, sql: cstring, resultp: var cstringArray, - nrow, ncolumn: var cint, errmsg: ptr cstring): int32{.cdecl, +proc get_table*(para1: PSqlite3, sql: cstring, resultp: var cstringArray, + nrow, ncolumn: var cint, errmsg: ptr cstring): int32{.cdecl, dynlib: Lib, importc: "sqlite3_get_table".} -proc free_table*(result: cstringArray){.cdecl, dynlib: Lib, +proc free_table*(result: cstringArray){.cdecl, dynlib: Lib, importc: "sqlite3_free_table".} # Todo: see how translate sqlite3_mprintf, sqlite3_vmprintf, sqlite3_snprintf # function sqlite3_mprintf(_para1:Pchar; args:array of const):Pchar;cdecl; external Sqlite3Lib name 'sqlite3_mprintf'; -proc mprintf*(para1: cstring): cstring{.cdecl, varargs, dynlib: Lib, +proc mprintf*(para1: cstring): cstring{.cdecl, varargs, dynlib: Lib, importc: "sqlite3_mprintf".} #function sqlite3_vmprintf(_para1:Pchar; _para2:va_list):Pchar;cdecl; external Sqlite3Lib name 'sqlite3_vmprintf'; proc free*(z: cstring){.cdecl, dynlib: Lib, importc: "sqlite3_free".} #function sqlite3_snprintf(_para1:longint; _para2:Pchar; _para3:Pchar; args:array of const):Pchar;cdecl; external Sqlite3Lib name 'sqlite3_snprintf'; -proc snprintf*(para1: int32, para2: cstring, para3: cstring): cstring{.cdecl, +proc snprintf*(para1: int32, para2: cstring, para3: cstring): cstring{.cdecl, dynlib: Lib, varargs, importc: "sqlite3_snprintf".} -proc set_authorizer*(para1: PSqlite3, xAuth: proc (para1: pointer, para2: int32, +proc set_authorizer*(para1: PSqlite3, xAuth: proc (para1: pointer, para2: int32, para3: cstring, para4: cstring, para5: cstring, para6: cstring): int32{. - cdecl.}, pUserData: pointer): int32{.cdecl, dynlib: Lib, + cdecl.}, pUserData: pointer): int32{.cdecl, dynlib: Lib, importc: "sqlite3_set_authorizer".} -proc trace*(para1: PSqlite3, xTrace: proc (para1: pointer, para2: cstring){.cdecl.}, - para3: pointer): pointer{.cdecl, dynlib: Lib, +proc trace*(para1: PSqlite3, xTrace: proc (para1: pointer, para2: cstring){.cdecl.}, + para3: pointer): pointer{.cdecl, dynlib: Lib, importc: "sqlite3_trace".} -proc progress_handler*(para1: PSqlite3, para2: int32, - para3: proc (para1: pointer): int32{.cdecl.}, - para4: pointer){.cdecl, dynlib: Lib, +proc progress_handler*(para1: PSqlite3, para2: int32, + para3: proc (para1: pointer): int32{.cdecl.}, + para4: pointer){.cdecl, dynlib: Lib, importc: "sqlite3_progress_handler".} -proc commit_hook*(para1: PSqlite3, para2: proc (para1: pointer): int32{.cdecl.}, - para3: pointer): pointer{.cdecl, dynlib: Lib, +proc commit_hook*(para1: PSqlite3, para2: proc (para1: pointer): int32{.cdecl.}, + para3: pointer): pointer{.cdecl, dynlib: Lib, importc: "sqlite3_commit_hook".} -proc open*(filename: cstring, ppDb: var PSqlite3): int32{.cdecl, dynlib: Lib, +proc open*(filename: cstring, ppDb: var PSqlite3): int32{.cdecl, dynlib: Lib, importc: "sqlite3_open".} -proc open16*(filename: pointer, ppDb: var PSqlite3): int32{.cdecl, dynlib: Lib, +proc open16*(filename: pointer, ppDb: var PSqlite3): int32{.cdecl, dynlib: Lib, importc: "sqlite3_open16".} proc errcode*(db: PSqlite3): int32{.cdecl, dynlib: Lib, importc: "sqlite3_errcode".} proc errmsg*(para1: PSqlite3): cstring{.cdecl, dynlib: Lib, importc: "sqlite3_errmsg".} -proc errmsg16*(para1: PSqlite3): pointer{.cdecl, dynlib: Lib, +proc errmsg16*(para1: PSqlite3): pointer{.cdecl, dynlib: Lib, importc: "sqlite3_errmsg16".} -proc prepare*(db: PSqlite3, zSql: cstring, nBytes: int32, ppStmt: var Pstmt, - pzTail: ptr cstring): int32{.cdecl, dynlib: Lib, +proc prepare*(db: PSqlite3, zSql: cstring, nBytes: int32, ppStmt: var Pstmt, + pzTail: ptr cstring): int32{.cdecl, dynlib: Lib, importc: "sqlite3_prepare".} - + proc prepare_v2*(db: PSqlite3, zSql: cstring, nByte: cint, ppStmt: var Pstmt, pzTail: ptr cstring): cint {. importc: "sqlite3_prepare_v2", cdecl, dynlib: Lib.} - -proc prepare16*(db: PSqlite3, zSql: pointer, nBytes: int32, ppStmt: var Pstmt, - pzTail: var pointer): int32{.cdecl, dynlib: Lib, + +proc prepare16*(db: PSqlite3, zSql: pointer, nBytes: int32, ppStmt: var Pstmt, + pzTail: var pointer): int32{.cdecl, dynlib: Lib, importc: "sqlite3_prepare16".} -proc bind_blob*(para1: Pstmt, para2: int32, para3: pointer, n: int32, - para5: Tbind_destructor_func): int32{.cdecl, dynlib: Lib, +proc bind_blob*(para1: Pstmt, para2: int32, para3: pointer, n: int32, + para5: Tbind_destructor_func): int32{.cdecl, dynlib: Lib, importc: "sqlite3_bind_blob".} -proc bind_double*(para1: Pstmt, para2: int32, para3: float64): int32{.cdecl, +proc bind_double*(para1: Pstmt, para2: int32, para3: float64): int32{.cdecl, dynlib: Lib, importc: "sqlite3_bind_double".} -proc bind_int*(para1: Pstmt, para2: int32, para3: int32): int32{.cdecl, +proc bind_int*(para1: Pstmt, para2: int32, para3: int32): int32{.cdecl, dynlib: Lib, importc: "sqlite3_bind_int".} -proc bind_int64*(para1: Pstmt, para2: int32, para3: int64): int32{.cdecl, +proc bind_int64*(para1: Pstmt, para2: int32, para3: int64): int32{.cdecl, dynlib: Lib, importc: "sqlite3_bind_int64".} -proc bind_null*(para1: Pstmt, para2: int32): int32{.cdecl, dynlib: Lib, +proc bind_null*(para1: Pstmt, para2: int32): int32{.cdecl, dynlib: Lib, importc: "sqlite3_bind_null".} -proc bind_text*(para1: Pstmt, para2: int32, para3: cstring, n: int32, - para5: Tbind_destructor_func): int32{.cdecl, dynlib: Lib, +proc bind_text*(para1: Pstmt, para2: int32, para3: cstring, n: int32, + para5: Tbind_destructor_func): int32{.cdecl, dynlib: Lib, importc: "sqlite3_bind_text".} -proc bind_text16*(para1: Pstmt, para2: int32, para3: pointer, para4: int32, - para5: Tbind_destructor_func): int32{.cdecl, dynlib: Lib, +proc bind_text16*(para1: Pstmt, para2: int32, para3: pointer, para4: int32, + para5: Tbind_destructor_func): int32{.cdecl, dynlib: Lib, importc: "sqlite3_bind_text16".} #function sqlite3_bind_value(_para1:Psqlite3_stmt; _para2:longint; _para3:Psqlite3_value):longint;cdecl; external Sqlite3Lib name 'sqlite3_bind_value'; #These overloaded functions were introduced to allow the use of SQLITE_STATIC and SQLITE_TRANSIENT #It's the c world man ;-) -proc bind_blob*(para1: Pstmt, para2: int32, para3: pointer, n: int32, - para5: int32): int32{.cdecl, dynlib: Lib, +proc bind_blob*(para1: Pstmt, para2: int32, para3: pointer, n: int32, + para5: int32): int32{.cdecl, dynlib: Lib, importc: "sqlite3_bind_blob".} -proc bind_text*(para1: Pstmt, para2: int32, para3: cstring, n: int32, - para5: int32): int32{.cdecl, dynlib: Lib, +proc bind_text*(para1: Pstmt, para2: int32, para3: cstring, n: int32, + para5: int32): int32{.cdecl, dynlib: Lib, importc: "sqlite3_bind_text".} -proc bind_text16*(para1: Pstmt, para2: int32, para3: pointer, para4: int32, - para5: int32): int32{.cdecl, dynlib: Lib, +proc bind_text16*(para1: Pstmt, para2: int32, para3: pointer, para4: int32, + para5: int32): int32{.cdecl, dynlib: Lib, importc: "sqlite3_bind_text16".} -proc bind_parameter_count*(para1: Pstmt): int32{.cdecl, dynlib: Lib, +proc bind_parameter_count*(para1: Pstmt): int32{.cdecl, dynlib: Lib, importc: "sqlite3_bind_parameter_count".} -proc bind_parameter_name*(para1: Pstmt, para2: int32): cstring{.cdecl, +proc bind_parameter_name*(para1: Pstmt, para2: int32): cstring{.cdecl, dynlib: Lib, importc: "sqlite3_bind_parameter_name".} -proc bind_parameter_index*(para1: Pstmt, zName: cstring): int32{.cdecl, +proc bind_parameter_index*(para1: Pstmt, zName: cstring): int32{.cdecl, dynlib: Lib, importc: "sqlite3_bind_parameter_index".} #function sqlite3_clear_bindings(_para1:Psqlite3_stmt):longint;cdecl; external Sqlite3Lib name 'sqlite3_clear_bindings'; -proc column_count*(pStmt: Pstmt): int32{.cdecl, dynlib: Lib, +proc column_count*(pStmt: Pstmt): int32{.cdecl, dynlib: Lib, importc: "sqlite3_column_count".} -proc column_name*(para1: Pstmt, para2: int32): cstring{.cdecl, dynlib: Lib, +proc column_name*(para1: Pstmt, para2: int32): cstring{.cdecl, dynlib: Lib, importc: "sqlite3_column_name".} -proc column_name16*(para1: Pstmt, para2: int32): pointer{.cdecl, dynlib: Lib, +proc column_name16*(para1: Pstmt, para2: int32): pointer{.cdecl, dynlib: Lib, importc: "sqlite3_column_name16".} -proc column_decltype*(para1: Pstmt, i: int32): cstring{.cdecl, dynlib: Lib, +proc column_decltype*(para1: Pstmt, i: int32): cstring{.cdecl, dynlib: Lib, importc: "sqlite3_column_decltype".} -proc column_decltype16*(para1: Pstmt, para2: int32): pointer{.cdecl, +proc column_decltype16*(para1: Pstmt, para2: int32): pointer{.cdecl, dynlib: Lib, importc: "sqlite3_column_decltype16".} proc step*(para1: Pstmt): int32{.cdecl, dynlib: Lib, importc: "sqlite3_step".} -proc data_count*(pStmt: Pstmt): int32{.cdecl, dynlib: Lib, +proc data_count*(pStmt: Pstmt): int32{.cdecl, dynlib: Lib, importc: "sqlite3_data_count".} -proc column_blob*(para1: Pstmt, iCol: int32): pointer{.cdecl, dynlib: Lib, +proc column_blob*(para1: Pstmt, iCol: int32): pointer{.cdecl, dynlib: Lib, importc: "sqlite3_column_blob".} -proc column_bytes*(para1: Pstmt, iCol: int32): int32{.cdecl, dynlib: Lib, +proc column_bytes*(para1: Pstmt, iCol: int32): int32{.cdecl, dynlib: Lib, importc: "sqlite3_column_bytes".} -proc column_bytes16*(para1: Pstmt, iCol: int32): int32{.cdecl, dynlib: Lib, +proc column_bytes16*(para1: Pstmt, iCol: int32): int32{.cdecl, dynlib: Lib, importc: "sqlite3_column_bytes16".} -proc column_double*(para1: Pstmt, iCol: int32): float64{.cdecl, dynlib: Lib, +proc column_double*(para1: Pstmt, iCol: int32): float64{.cdecl, dynlib: Lib, importc: "sqlite3_column_double".} -proc column_int*(para1: Pstmt, iCol: int32): int32{.cdecl, dynlib: Lib, +proc column_int*(para1: Pstmt, iCol: int32): int32{.cdecl, dynlib: Lib, importc: "sqlite3_column_int".} -proc column_int64*(para1: Pstmt, iCol: int32): int64{.cdecl, dynlib: Lib, +proc column_int64*(para1: Pstmt, iCol: int32): int64{.cdecl, dynlib: Lib, importc: "sqlite3_column_int64".} -proc column_text*(para1: Pstmt, iCol: int32): cstring{.cdecl, dynlib: Lib, +proc column_text*(para1: Pstmt, iCol: int32): cstring{.cdecl, dynlib: Lib, importc: "sqlite3_column_text".} -proc column_text16*(para1: Pstmt, iCol: int32): pointer{.cdecl, dynlib: Lib, +proc column_text16*(para1: Pstmt, iCol: int32): pointer{.cdecl, dynlib: Lib, importc: "sqlite3_column_text16".} -proc column_type*(para1: Pstmt, iCol: int32): int32{.cdecl, dynlib: Lib, +proc column_type*(para1: Pstmt, iCol: int32): int32{.cdecl, dynlib: Lib, importc: "sqlite3_column_type".} -proc finalize*(pStmt: Pstmt): int32{.cdecl, dynlib: Lib, +proc finalize*(pStmt: Pstmt): int32{.cdecl, dynlib: Lib, importc: "sqlite3_finalize".} proc reset*(pStmt: Pstmt): int32{.cdecl, dynlib: Lib, importc: "sqlite3_reset".} -proc create_function*(para1: PSqlite3, zFunctionName: cstring, nArg: int32, - eTextRep: int32, para5: pointer, - xFunc: Create_function_func_func, - xStep: Create_function_step_func, - xFinal: Create_function_final_func): int32{.cdecl, +proc create_function*(para1: PSqlite3, zFunctionName: cstring, nArg: int32, + eTextRep: int32, para5: pointer, + xFunc: Create_function_func_func, + xStep: Create_function_step_func, + xFinal: Create_function_final_func): int32{.cdecl, dynlib: Lib, importc: "sqlite3_create_function".} -proc create_function16*(para1: PSqlite3, zFunctionName: pointer, nArg: int32, - eTextRep: int32, para5: pointer, - xFunc: Create_function_func_func, - xStep: Create_function_step_func, - xFinal: Create_function_final_func): int32{.cdecl, +proc create_function16*(para1: PSqlite3, zFunctionName: pointer, nArg: int32, + eTextRep: int32, para5: pointer, + xFunc: Create_function_func_func, + xStep: Create_function_step_func, + xFinal: Create_function_final_func): int32{.cdecl, dynlib: Lib, importc: "sqlite3_create_function16".} -proc aggregate_count*(para1: Pcontext): int32{.cdecl, dynlib: Lib, +proc aggregate_count*(para1: Pcontext): int32{.cdecl, dynlib: Lib, importc: "sqlite3_aggregate_count".} -proc value_blob*(para1: Pvalue): pointer{.cdecl, dynlib: Lib, +proc value_blob*(para1: Pvalue): pointer{.cdecl, dynlib: Lib, importc: "sqlite3_value_blob".} -proc value_bytes*(para1: Pvalue): int32{.cdecl, dynlib: Lib, +proc value_bytes*(para1: Pvalue): int32{.cdecl, dynlib: Lib, importc: "sqlite3_value_bytes".} -proc value_bytes16*(para1: Pvalue): int32{.cdecl, dynlib: Lib, +proc value_bytes16*(para1: Pvalue): int32{.cdecl, dynlib: Lib, importc: "sqlite3_value_bytes16".} -proc value_double*(para1: Pvalue): float64{.cdecl, dynlib: Lib, +proc value_double*(para1: Pvalue): float64{.cdecl, dynlib: Lib, importc: "sqlite3_value_double".} -proc value_int*(para1: Pvalue): int32{.cdecl, dynlib: Lib, +proc value_int*(para1: Pvalue): int32{.cdecl, dynlib: Lib, importc: "sqlite3_value_int".} -proc value_int64*(para1: Pvalue): int64{.cdecl, dynlib: Lib, +proc value_int64*(para1: Pvalue): int64{.cdecl, dynlib: Lib, importc: "sqlite3_value_int64".} -proc value_text*(para1: Pvalue): cstring{.cdecl, dynlib: Lib, +proc value_text*(para1: Pvalue): cstring{.cdecl, dynlib: Lib, importc: "sqlite3_value_text".} -proc value_text16*(para1: Pvalue): pointer{.cdecl, dynlib: Lib, +proc value_text16*(para1: Pvalue): pointer{.cdecl, dynlib: Lib, importc: "sqlite3_value_text16".} -proc value_text16le*(para1: Pvalue): pointer{.cdecl, dynlib: Lib, +proc value_text16le*(para1: Pvalue): pointer{.cdecl, dynlib: Lib, importc: "sqlite3_value_text16le".} -proc value_text16be*(para1: Pvalue): pointer{.cdecl, dynlib: Lib, +proc value_text16be*(para1: Pvalue): pointer{.cdecl, dynlib: Lib, importc: "sqlite3_value_text16be".} -proc value_type*(para1: Pvalue): int32{.cdecl, dynlib: Lib, +proc value_type*(para1: Pvalue): int32{.cdecl, dynlib: Lib, importc: "sqlite3_value_type".} -proc aggregate_context*(para1: Pcontext, nBytes: int32): pointer{.cdecl, +proc aggregate_context*(para1: Pcontext, nBytes: int32): pointer{.cdecl, dynlib: Lib, importc: "sqlite3_aggregate_context".} -proc user_data*(para1: Pcontext): pointer{.cdecl, dynlib: Lib, +proc user_data*(para1: Pcontext): pointer{.cdecl, dynlib: Lib, importc: "sqlite3_user_data".} -proc get_auxdata*(para1: Pcontext, para2: int32): pointer{.cdecl, dynlib: Lib, +proc get_auxdata*(para1: Pcontext, para2: int32): pointer{.cdecl, dynlib: Lib, importc: "sqlite3_get_auxdata".} -proc set_auxdata*(para1: Pcontext, para2: int32, para3: pointer, - para4: proc (para1: pointer){.cdecl.}){.cdecl, dynlib: Lib, +proc set_auxdata*(para1: Pcontext, para2: int32, para3: pointer, + para4: proc (para1: pointer){.cdecl.}){.cdecl, dynlib: Lib, importc: "sqlite3_set_auxdata".} -proc result_blob*(para1: Pcontext, para2: pointer, para3: int32, - para4: Result_func){.cdecl, dynlib: Lib, +proc result_blob*(para1: Pcontext, para2: pointer, para3: int32, + para4: Result_func){.cdecl, dynlib: Lib, importc: "sqlite3_result_blob".} -proc result_double*(para1: Pcontext, para2: float64){.cdecl, dynlib: Lib, +proc result_double*(para1: Pcontext, para2: float64){.cdecl, dynlib: Lib, importc: "sqlite3_result_double".} -proc result_error*(para1: Pcontext, para2: cstring, para3: int32){.cdecl, +proc result_error*(para1: Pcontext, para2: cstring, para3: int32){.cdecl, dynlib: Lib, importc: "sqlite3_result_error".} -proc result_error16*(para1: Pcontext, para2: pointer, para3: int32){.cdecl, +proc result_error16*(para1: Pcontext, para2: pointer, para3: int32){.cdecl, dynlib: Lib, importc: "sqlite3_result_error16".} -proc result_int*(para1: Pcontext, para2: int32){.cdecl, dynlib: Lib, +proc result_int*(para1: Pcontext, para2: int32){.cdecl, dynlib: Lib, importc: "sqlite3_result_int".} -proc result_int64*(para1: Pcontext, para2: int64){.cdecl, dynlib: Lib, +proc result_int64*(para1: Pcontext, para2: int64){.cdecl, dynlib: Lib, importc: "sqlite3_result_int64".} -proc result_null*(para1: Pcontext){.cdecl, dynlib: Lib, +proc result_null*(para1: Pcontext){.cdecl, dynlib: Lib, importc: "sqlite3_result_null".} -proc result_text*(para1: Pcontext, para2: cstring, para3: int32, - para4: Result_func){.cdecl, dynlib: Lib, +proc result_text*(para1: Pcontext, para2: cstring, para3: int32, + para4: Result_func){.cdecl, dynlib: Lib, importc: "sqlite3_result_text".} -proc result_text16*(para1: Pcontext, para2: pointer, para3: int32, - para4: Result_func){.cdecl, dynlib: Lib, +proc result_text16*(para1: Pcontext, para2: pointer, para3: int32, + para4: Result_func){.cdecl, dynlib: Lib, importc: "sqlite3_result_text16".} -proc result_text16le*(para1: Pcontext, para2: pointer, para3: int32, - para4: Result_func){.cdecl, dynlib: Lib, +proc result_text16le*(para1: Pcontext, para2: pointer, para3: int32, + para4: Result_func){.cdecl, dynlib: Lib, importc: "sqlite3_result_text16le".} -proc result_text16be*(para1: Pcontext, para2: pointer, para3: int32, - para4: Result_func){.cdecl, dynlib: Lib, +proc result_text16be*(para1: Pcontext, para2: pointer, para3: int32, + para4: Result_func){.cdecl, dynlib: Lib, importc: "sqlite3_result_text16be".} -proc result_value*(para1: Pcontext, para2: Pvalue){.cdecl, dynlib: Lib, +proc result_value*(para1: Pcontext, para2: Pvalue){.cdecl, dynlib: Lib, importc: "sqlite3_result_value".} -proc create_collation*(para1: PSqlite3, zName: cstring, eTextRep: int32, +proc create_collation*(para1: PSqlite3, zName: cstring, eTextRep: int32, para4: pointer, xCompare: Create_collation_func): int32{. cdecl, dynlib: Lib, importc: "sqlite3_create_collation".} -proc create_collation16*(para1: PSqlite3, zName: cstring, eTextRep: int32, +proc create_collation16*(para1: PSqlite3, zName: cstring, eTextRep: int32, para4: pointer, xCompare: Create_collation_func): int32{. cdecl, dynlib: Lib, importc: "sqlite3_create_collation16".} proc collation_needed*(para1: PSqlite3, para2: pointer, para3: Collation_needed_func): int32{. @@ -350,10 +350,10 @@ proc collation_needed*(para1: PSqlite3, para2: pointer, para3: Collation_needed_ proc collation_needed16*(para1: PSqlite3, para2: pointer, para3: Collation_needed_func): int32{. cdecl, dynlib: Lib, importc: "sqlite3_collation_needed16".} proc libversion*(): cstring{.cdecl, dynlib: Lib, importc: "sqlite3_libversion".} - #Alias for allowing better code portability (win32 is not working with external variables) + #Alias for allowing better code portability (win32 is not working with external variables) proc version*(): cstring{.cdecl, dynlib: Lib, importc: "sqlite3_libversion".} # Not published functions -proc libversion_number*(): int32{.cdecl, dynlib: Lib, +proc libversion_number*(): int32{.cdecl, dynlib: Lib, importc: "sqlite3_libversion_number".} #function sqlite3_key(db:Psqlite3; pKey:pointer; nKey:longint):longint;cdecl; external Sqlite3Lib name 'sqlite3_key'; #function sqlite3_rekey(db:Psqlite3; pKey:pointer; nKey:longint):longint;cdecl; external Sqlite3Lib name 'sqlite3_rekey'; diff --git a/lib/wrappers/tinyc.nim b/lib/wrappers/tinyc.nim index 05c65b12fc..47b505abcd 100644 --- a/lib/wrappers/tinyc.nim +++ b/lib/wrappers/tinyc.nim @@ -10,7 +10,7 @@ type CcState {.pure, final.} = object PccState* = ptr CcState - + ErrorFunc* = proc (opaque: pointer, msg: cstring) {.cdecl.} {.deprecated: [TccState: CcState, TErrorFunc: ErrorFunc].} @@ -31,33 +31,33 @@ proc setWarning*(s: PccState, warningName: cstring, value: int) {.cdecl, importc: "tcc_set_warning".} ## set/reset a warning -# preprocessor +# preprocessor -proc addIncludePath*(s: PccState, pathname: cstring) {.cdecl, +proc addIncludePath*(s: PccState, pathname: cstring) {.cdecl, importc: "tcc_add_include_path".} ## add include path -proc addSysincludePath*(s: PccState, pathname: cstring) {.cdecl, +proc addSysincludePath*(s: PccState, pathname: cstring) {.cdecl, importc: "tcc_add_sysinclude_path".} ## add in system include path -proc defineSymbol*(s: PccState, sym, value: cstring) {.cdecl, +proc defineSymbol*(s: PccState, sym, value: cstring) {.cdecl, importc: "tcc_define_symbol".} ## define preprocessor symbol 'sym'. Can put optional value -proc undefineSymbol*(s: PccState, sym: cstring) {.cdecl, +proc undefineSymbol*(s: PccState, sym: cstring) {.cdecl, importc: "tcc_undefine_symbol".} ## undefine preprocess symbol 'sym' -# compiling +# compiling -proc addFile*(s: PccState, filename: cstring): cint {.cdecl, +proc addFile*(s: PccState, filename: cstring): cint {.cdecl, importc: "tcc_add_file".} ## add a file (either a C file, dll, an object, a library or an ld ## script). Return -1 if error. -proc compileString*(s: PccState, buf: cstring): cint {.cdecl, +proc compileString*(s: PccState, buf: cstring): cint {.cdecl, importc: "tcc_compile_string".} ## compile a string containing a C source. Return non zero if error. @@ -71,12 +71,12 @@ const OutputDll*: cint = 2 ## dynamic library OutputObj*: cint = 3 ## object file OutputPreprocess*: cint = 4 ## preprocessed file (used internally) - + OutputFormatElf*: cint = 0 ## default output format: ELF OutputFormatBinary*: cint = 1 ## binary image output OutputFormatCoff*: cint = 2 ## COFF -proc setOutputType*(s: PCCState, outputType: cint): cint {.cdecl, +proc setOutputType*(s: PCCState, outputType: cint): cint {.cdecl, importc: "tcc_set_output_type".} ## set output type. MUST BE CALLED before any compilation @@ -115,5 +115,5 @@ proc getSymbol*(s: PccState, name: cstring): pointer {.cdecl, proc setLibPath*(s: PccState, path: cstring) {.cdecl, importc: "tcc_set_lib_path".} ## set CONFIG_TCCDIR at runtime - + From ac9c1cd6b980d4f00eeb52d1109d8e2c8cd21213 Mon Sep 17 00:00:00 2001 From: Adam Strzelecki Date: Fri, 4 Sep 2015 23:04:17 +0200 Subject: [PATCH 03/11] tools: Trim .nim files trailing whitespace via OSX: find . -name '*.nim' -exec sed -i '' -E 's/[[:space:]]+$//' {} + --- tools/cmerge.nim | 2 +- tools/detect/detect.nim | 230 +++++++++++++-------------- tools/detect/windows_i386_consts.nim | 192 +++++++++++----------- tools/fakedeps.nim | 2 +- tools/niminst/debcreation.nim | 60 +++---- tools/noprefix.nim | 4 +- tools/restorecc.nim | 12 +- 7 files changed, 251 insertions(+), 251 deletions(-) diff --git a/tools/cmerge.nim b/tools/cmerge.nim index 13bf8b64c9..15fbd8a76a 100644 --- a/tools/cmerge.nim +++ b/tools/cmerge.nim @@ -5,7 +5,7 @@ import os, sets, pegs type ProcessResult = enum prSkipIncludeDir, prAddIncludeDir -proc process(dir, infile: string, outfile: File, +proc process(dir, infile: string, outfile: File, processed: var HashSet[string]): ProcessResult = if processed.containsOrIncl(infile): return prSkipIncludeDir let toProcess = dir / infile diff --git a/tools/detect/detect.nim b/tools/detect/detect.nim index 77efdaacda..0470257eeb 100644 --- a/tools/detect/detect.nim +++ b/tools/detect/detect.nim @@ -29,18 +29,18 @@ int main() { """ type - TTypeKind = enum + TTypeKind = enum cint, cshort, clong, cstring, pointer var hd = "" tl = "" -proc myExec(cmd: string): bool = +proc myExec(cmd: string): bool = echo "CMD ", cmd return execShellCmd(cmd) == 0 -proc header(s: string): bool = +proc header(s: string): bool = const testh = "testh" var f: TFile if open(f, addFileExt(testh, "c"), fmWrite): @@ -55,10 +55,10 @@ proc header(s: string): bool = else: echo("Not found: ", s) -proc main = +proc main = const gen = "genconsts" var f: TFile - if open(f, addFileExt(gen, "c"), fmWrite): + if open(f, addFileExt(gen, "c"), fmWrite): f.write(cfile % [hd, tl, system.hostOS, system.hostCPU]) close(f) if not myExec(cc % [gen.addFileExt(ExeExt), gen]): quit(1) @@ -69,26 +69,26 @@ proc main = #removeFile(addFileExt(gen, "c")) echo("Success") -proc v(name: string, typ: TTypeKind=cint) = +proc v(name: string, typ: TTypeKind=cint) = var n = if name[0] == '_': substr(name, 1) else: name var t = $typ case typ - of pointer: - addf(tl, - "#ifdef $3\n fprintf(f, \" $1* = cast[$2](%p)\\n\", $3);\n#endif\n", + of pointer: + addf(tl, + "#ifdef $3\n fprintf(f, \" $1* = cast[$2](%p)\\n\", $3);\n#endif\n", n, t, name) - + of cstring: - addf(tl, + addf(tl, "#ifdef $3\n fprintf(f, \" $1* = $2(\\\"%s\\\")\\n\", $3);\n#endif\n", n, t, name) of clong: - addf(tl, - "#ifdef $3\n fprintf(f, \" $1* = $2(%ld)\\n\", $3);\n#endif\n", - n, t, name) - else: - addf(tl, - "#ifdef $3\n fprintf(f, \" $1* = $2(%d)\\n\", $3);\n#endif\n", + addf(tl, + "#ifdef $3\n fprintf(f, \" $1* = $2(%ld)\\n\", $3);\n#endif\n", + n, t, name) + else: + addf(tl, + "#ifdef $3\n fprintf(f, \" $1* = $2(%d)\\n\", $3);\n#endif\n", n, t, name) if header(""): @@ -187,7 +187,7 @@ if header(""): v("ETXTBSY") v("EWOULDBLOCK") v("EXDEV") - + if header(""): v("F_DUPFD") v("F_GETFD") @@ -346,7 +346,7 @@ if header(""): v("YESEXPR") v("NOEXPR") v("CRNCYSTR") - + if header(""): v("LC_ALL") #{.importc, header: .}: cint v("LC_COLLATE") #{.importc, header: "".}: cint @@ -358,20 +358,20 @@ if header(""): if header(""): v("PTHREAD_BARRIER_SERIAL_THREAD") - v("PTHREAD_CANCEL_ASYNCHRONOUS") - v("PTHREAD_CANCEL_ENABLE") + v("PTHREAD_CANCEL_ASYNCHRONOUS") + v("PTHREAD_CANCEL_ENABLE") v("PTHREAD_CANCEL_DEFERRED") - v("PTHREAD_CANCEL_DISABLE") + v("PTHREAD_CANCEL_DISABLE") #v("PTHREAD_CANCELED") - #v("PTHREAD_COND_INITIALIZER") + #v("PTHREAD_COND_INITIALIZER") v("PTHREAD_CREATE_DETACHED") v("PTHREAD_CREATE_JOINABLE") v("PTHREAD_EXPLICIT_SCHED") - v("PTHREAD_INHERIT_SCHED") - v("PTHREAD_MUTEX_DEFAULT") + v("PTHREAD_INHERIT_SCHED") + v("PTHREAD_MUTEX_DEFAULT") v("PTHREAD_MUTEX_ERRORCHECK") - #v("PTHREAD_MUTEX_INITIALIZER") - v("PTHREAD_MUTEX_NORMAL") + #v("PTHREAD_MUTEX_INITIALIZER") + v("PTHREAD_MUTEX_NORMAL") v("PTHREAD_MUTEX_RECURSIVE") #{.importc, header: "".}: cint #v("PTHREAD_ONCE_INIT") #{.importc, header: "".}: cint v("PTHREAD_PRIO_INHERIT") #{.importc, header: "".}: cint @@ -392,28 +392,28 @@ if header(""): v("X_OK") v("_CS_PATH") - v("_CS_POSIX_V6_ILP32_OFF32_CFLAGS") - v("_CS_POSIX_V6_ILP32_OFF32_LDFLAGS") - v("_CS_POSIX_V6_ILP32_OFF32_LIBS") - v("_CS_POSIX_V6_ILP32_OFFBIG_CFLAGS") - v("_CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS") - v("_CS_POSIX_V6_ILP32_OFFBIG_LIBS") - v("_CS_POSIX_V6_LP64_OFF64_CFLAGS") + v("_CS_POSIX_V6_ILP32_OFF32_CFLAGS") + v("_CS_POSIX_V6_ILP32_OFF32_LDFLAGS") + v("_CS_POSIX_V6_ILP32_OFF32_LIBS") + v("_CS_POSIX_V6_ILP32_OFFBIG_CFLAGS") + v("_CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS") + v("_CS_POSIX_V6_ILP32_OFFBIG_LIBS") + v("_CS_POSIX_V6_LP64_OFF64_CFLAGS") v("_CS_POSIX_V6_LP64_OFF64_LDFLAGS") - v("_CS_POSIX_V6_LP64_OFF64_LIBS") - v("_CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS") - v("_CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS") - v("_CS_POSIX_V6_LPBIG_OFFBIG_LIBS") + v("_CS_POSIX_V6_LP64_OFF64_LIBS") + v("_CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS") + v("_CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS") + v("_CS_POSIX_V6_LPBIG_OFFBIG_LIBS") v("_CS_POSIX_V6_WIDTH_RESTRICTED_ENVS") - v("F_LOCK") + v("F_LOCK") v("F_TEST") #{.importc: "F_TEST", header: "".}: cint v("F_TLOCK") #{.importc: "F_TLOCK", header: "".}: cint v("F_ULOCK") #{.importc: "F_ULOCK", header: "".}: cint v("_PC_2_SYMLINKS") #{.importc: "_PC_2_SYMLINKS", header: "".}: cint - v("_PC_ALLOC_SIZE_MIN") + v("_PC_ALLOC_SIZE_MIN") v("_PC_ASYNC_IO") #{.importc: "_PC_ASYNC_IO", header: "".}: cint - v("_PC_CHOWN_RESTRICTED") + v("_PC_CHOWN_RESTRICTED") v("_PC_FILESIZEBITS") #{.importc: "_PC_FILESIZEBITS", header: "".}: cint v("_PC_LINK_MAX") #{.importc: "_PC_LINK_MAX", header: "".}: cint v("_PC_MAX_CANON") #{.importc: "_PC_MAX_CANON", header: "".}: cint @@ -423,9 +423,9 @@ if header(""): v("_PC_PATH_MAX") #{.importc: "_PC_PATH_MAX", header: "".}: cint v("_PC_PIPE_BUF") #{.importc: "_PC_PIPE_BUF", header: "".}: cint v("_PC_PRIO_IO") #{.importc: "_PC_PRIO_IO", header: "".}: cint - v("_PC_REC_INCR_XFER_SIZE") - v("_PC_REC_MIN_XFER_SIZE") - v("_PC_REC_XFER_ALIGN") + v("_PC_REC_INCR_XFER_SIZE") + v("_PC_REC_MIN_XFER_SIZE") + v("_PC_REC_XFER_ALIGN") v("_PC_SYMLINK_MAX") #{.importc: "_PC_SYMLINK_MAX", header: "".}: cint v("_PC_SYNC_IO") #{.importc: "_PC_SYNC_IO", header: "".}: cint v("_PC_VDISABLE") #{.importc: "_PC_VDISABLE", header: "".}: cint @@ -436,8 +436,8 @@ if header(""): v("_SC_2_FORT_RUN") #{.importc: "_SC_2_FORT_RUN", header: "".}: cint v("_SC_2_LOCALEDEF") #{.importc: "_SC_2_LOCALEDEF", header: "".}: cint v("_SC_2_PBS") #{.importc: "_SC_2_PBS", header: "".}: cint - v("_SC_2_PBS_ACCOUNTING") - v("_SC_2_PBS_CHECKPOINT") + v("_SC_2_PBS_ACCOUNTING") + v("_SC_2_PBS_CHECKPOINT") v("_SC_2_PBS_LOCATE") #{.importc: "_SC_2_PBS_LOCATE", header: "".}: cint v("_SC_2_PBS_MESSAGE") #{.importc: "_SC_2_PBS_MESSAGE", header: "".}: cint v("_SC_2_PBS_TRACK") #{.importc: "_SC_2_PBS_TRACK", header: "".}: cint @@ -445,11 +445,11 @@ if header(""): v("_SC_2_UPE") #{.importc: "_SC_2_UPE", header: "".}: cint v("_SC_2_VERSION") #{.importc: "_SC_2_VERSION", header: "".}: cint v("_SC_ADVISORY_INFO") #{.importc: "_SC_ADVISORY_INFO", header: "".}: cint - v("_SC_AIO_LISTIO_MAX") + v("_SC_AIO_LISTIO_MAX") v("_SC_AIO_MAX") #{.importc: "_SC_AIO_MAX", header: "".}: cint - v("_SC_AIO_PRIO_DELTA_MAX") + v("_SC_AIO_PRIO_DELTA_MAX") v("_SC_ARG_MAX") #{.importc: "_SC_ARG_MAX", header: "".}: cint - v("_SC_ASYNCHRONOUS_IO") + v("_SC_ASYNCHRONOUS_IO") v("_SC_ATEXIT_MAX") #{.importc: "_SC_ATEXIT_MAX", header: "".}: cint v("_SC_BARRIERS") #{.importc: "_SC_BARRIERS", header: "".}: cint v("_SC_BC_BASE_MAX") #{.importc: "_SC_BC_BASE_MAX", header: "".}: cint @@ -458,10 +458,10 @@ if header(""): v("_SC_BC_STRING_MAX") #{.importc: "_SC_BC_STRING_MAX", header: "".}: cint v("_SC_CHILD_MAX") #{.importc: "_SC_CHILD_MAX", header: "".}: cint v("_SC_CLK_TCK") #{.importc: "_SC_CLK_TCK", header: "".}: cint - v("_SC_CLOCK_SELECTION") + v("_SC_CLOCK_SELECTION") v("_SC_COLL_WEIGHTS_MAX") v("_SC_CPUTIME") #{.importc: "_SC_CPUTIME", header: "".}: cint - v("_SC_DELAYTIMER_MAX") + v("_SC_DELAYTIMER_MAX") v("_SC_EXPR_NEST_MAX") #{.importc: "_SC_EXPR_NEST_MAX", header: "".}: cint v("_SC_FSYNC") #{.importc: "_SC_FSYNC", header: "".}: cint v("_SC_GETGR_R_SIZE_MAX") @@ -471,82 +471,82 @@ if header(""): v("_SC_IPV6") #{.importc: "_SC_IPV6", header: "".}: cint v("_SC_JOB_CONTROL") #{.importc: "_SC_JOB_CONTROL", header: "".}: cint v("_SC_LINE_MAX") #{.importc: "_SC_LINE_MAX", header: "".}: cint - v("_SC_LOGIN_NAME_MAX") + v("_SC_LOGIN_NAME_MAX") v("_SC_MAPPED_FILES") #{.importc: "_SC_MAPPED_FILES", header: "".}: cint v("_SC_MEMLOCK") #{.importc: "_SC_MEMLOCK", header: "".}: cint v("_SC_MEMLOCK_RANGE") #{.importc: "_SC_MEMLOCK_RANGE", header: "".}: cint v("_SC_MEMORY_PROTECTION") - v("_SC_MESSAGE_PASSING") - v("_SC_MONOTONIC_CLOCK") + v("_SC_MESSAGE_PASSING") + v("_SC_MONOTONIC_CLOCK") v("_SC_MQ_OPEN_MAX") #{.importc: "_SC_MQ_OPEN_MAX", header: "".}: cint v("_SC_MQ_PRIO_MAX") #{.importc: "_SC_MQ_PRIO_MAX", header: "".}: cint v("_SC_NGROUPS_MAX") #{.importc: "_SC_NGROUPS_MAX", header: "".}: cint v("_SC_OPEN_MAX") #{.importc: "_SC_OPEN_MAX", header: "".}: cint v("_SC_PAGE_SIZE") #{.importc: "_SC_PAGE_SIZE", header: "".}: cint - v("_SC_PRIORITIZED_IO") - v("_SC_PRIORITY_SCHEDULING") + v("_SC_PRIORITIZED_IO") + v("_SC_PRIORITY_SCHEDULING") v("_SC_RAW_SOCKETS") #{.importc: "_SC_RAW_SOCKETS", header: "".}: cint v("_SC_RE_DUP_MAX") #{.importc: "_SC_RE_DUP_MAX", header: "".}: cint - v("_SC_READER_WRITER_LOCKS") - v("_SC_REALTIME_SIGNALS") + v("_SC_READER_WRITER_LOCKS") + v("_SC_REALTIME_SIGNALS") v("_SC_REGEXP") #{.importc: "_SC_REGEXP", header: "".}: cint v("_SC_RTSIG_MAX") #{.importc: "_SC_RTSIG_MAX", header: "".}: cint v("_SC_SAVED_IDS") #{.importc: "_SC_SAVED_IDS", header: "".}: cint v("_SC_SEM_NSEMS_MAX") #{.importc: "_SC_SEM_NSEMS_MAX", header: "".}: cint v("_SC_SEM_VALUE_MAX") #{.importc: "_SC_SEM_VALUE_MAX", header: "".}: cint v("_SC_SEMAPHORES") #{.importc: "_SC_SEMAPHORES", header: "".}: cint - v("_SC_SHARED_MEMORY_OBJECTS") + v("_SC_SHARED_MEMORY_OBJECTS") v("_SC_SHELL") #{.importc: "_SC_SHELL", header: "".}: cint v("_SC_SIGQUEUE_MAX") #{.importc: "_SC_SIGQUEUE_MAX", header: "".}: cint v("_SC_SPAWN") #{.importc: "_SC_SPAWN", header: "".}: cint v("_SC_SPIN_LOCKS") #{.importc: "_SC_SPIN_LOCKS", header: "".}: cint - v("_SC_SPORADIC_SERVER") + v("_SC_SPORADIC_SERVER") v("_SC_SS_REPL_MAX") #{.importc: "_SC_SS_REPL_MAX", header: "".}: cint v("_SC_STREAM_MAX") #{.importc: "_SC_STREAM_MAX", header: "".}: cint v("_SC_SYMLOOP_MAX") #{.importc: "_SC_SYMLOOP_MAX", header: "".}: cint - v("_SC_SYNCHRONIZED_IO") - v("_SC_THREAD_ATTR_STACKADDR") - v("_SC_THREAD_ATTR_STACKSIZE") - v("_SC_THREAD_CPUTIME") - v("_SC_THREAD_DESTRUCTOR_ITERATIONS") - v("_SC_THREAD_KEYS_MAX") - v("_SC_THREAD_PRIO_INHERIT") - v("_SC_THREAD_PRIO_PROTECT") - v("_SC_THREAD_PRIORITY_SCHEDULING") - v("_SC_THREAD_PROCESS_SHARED") - v("_SC_THREAD_SAFE_FUNCTIONS") + v("_SC_SYNCHRONIZED_IO") + v("_SC_THREAD_ATTR_STACKADDR") + v("_SC_THREAD_ATTR_STACKSIZE") + v("_SC_THREAD_CPUTIME") + v("_SC_THREAD_DESTRUCTOR_ITERATIONS") + v("_SC_THREAD_KEYS_MAX") + v("_SC_THREAD_PRIO_INHERIT") + v("_SC_THREAD_PRIO_PROTECT") + v("_SC_THREAD_PRIORITY_SCHEDULING") + v("_SC_THREAD_PROCESS_SHARED") + v("_SC_THREAD_SAFE_FUNCTIONS") v("_SC_THREAD_SPORADIC_SERVER") - v("_SC_THREAD_STACK_MIN") - v("_SC_THREAD_THREADS_MAX") + v("_SC_THREAD_STACK_MIN") + v("_SC_THREAD_THREADS_MAX") v("_SC_THREADS") #{.importc: "_SC_THREADS", header: "".}: cint v("_SC_TIMEOUTS") #{.importc: "_SC_TIMEOUTS", header: "".}: cint v("_SC_TIMER_MAX") #{.importc: "_SC_TIMER_MAX", header: "".}: cint v("_SC_TIMERS") #{.importc: "_SC_TIMERS", header: "".}: cint v("_SC_TRACE") #{.importc: "_SC_TRACE", header: "".}: cint - v("_SC_TRACE_EVENT_FILTER") + v("_SC_TRACE_EVENT_FILTER") v("_SC_TRACE_EVENT_NAME_MAX") v("_SC_TRACE_INHERIT") #{.importc: "_SC_TRACE_INHERIT", header: "".}: cint v("_SC_TRACE_LOG") #{.importc: "_SC_TRACE_LOG", header: "".}: cint - v("_SC_TRACE_NAME_MAX") + v("_SC_TRACE_NAME_MAX") v("_SC_TRACE_SYS_MAX") #{.importc: "_SC_TRACE_SYS_MAX", header: "".}: cint - v("_SC_TRACE_USER_EVENT_MAX") + v("_SC_TRACE_USER_EVENT_MAX") v("_SC_TTY_NAME_MAX") #{.importc: "_SC_TTY_NAME_MAX", header: "".}: cint - v("_SC_TYPED_MEMORY_OBJECTS") + v("_SC_TYPED_MEMORY_OBJECTS") v("_SC_TZNAME_MAX") #{.importc: "_SC_TZNAME_MAX", header: "".}: cint - v("_SC_V6_ILP32_OFF32") - v("_SC_V6_ILP32_OFFBIG") + v("_SC_V6_ILP32_OFF32") + v("_SC_V6_ILP32_OFFBIG") v("_SC_V6_LP64_OFF64") #{.importc: "_SC_V6_LP64_OFF64", header: "".}: cint - v("_SC_V6_LPBIG_OFFBIG") + v("_SC_V6_LPBIG_OFFBIG") v("_SC_VERSION") #{.importc: "_SC_VERSION", header: "".}: cint - v("_SC_XBS5_ILP32_OFF32") - v("_SC_XBS5_ILP32_OFFBIG") - v("_SC_XBS5_LP64_OFF64") - v("_SC_XBS5_LPBIG_OFFBIG") + v("_SC_XBS5_ILP32_OFF32") + v("_SC_XBS5_ILP32_OFFBIG") + v("_SC_XBS5_LP64_OFF64") + v("_SC_XBS5_LPBIG_OFFBIG") v("_SC_XOPEN_CRYPT") #{.importc: "_SC_XOPEN_CRYPT", header: "".}: cint - v("_SC_XOPEN_ENH_I18N") + v("_SC_XOPEN_ENH_I18N") v("_SC_XOPEN_LEGACY") #{.importc: "_SC_XOPEN_LEGACY", header: "".}: cint - v("_SC_XOPEN_REALTIME") - v("_SC_XOPEN_REALTIME_THREADS") + v("_SC_XOPEN_REALTIME") + v("_SC_XOPEN_REALTIME_THREADS") v("_SC_XOPEN_SHM") #{.importc: "_SC_XOPEN_SHM", header: "".}: cint v("_SC_XOPEN_STREAMS") #{.importc: "_SC_XOPEN_STREAMS", header: "".}: cint v("_SC_XOPEN_UNIX") #{.importc: "_SC_XOPEN_UNIX", header: "".}: cint @@ -597,7 +597,7 @@ if header(""): if header(""): v("ST_RDONLY") #{.importc, header: .}: cint v("ST_NOSUID") #{.importc, header: "".}: cint - + if header(""): v("PROT_READ") #{.importc, header: .}: cint v("PROT_WRITE") #{.importc, header: "".}: cint @@ -623,31 +623,31 @@ if header(""): v("POSIX_TYPED_MEM_MAP_ALLOCATABLE") #{.importc, header: "".}: cint if header(""): - v("CLOCKS_PER_SEC", clong) + v("CLOCKS_PER_SEC", clong) v("CLOCK_PROCESS_CPUTIME_ID") v("CLOCK_THREAD_CPUTIME_ID") v("CLOCK_REALTIME") - v("TIMER_ABSTIME") - v("CLOCK_MONOTONIC") + v("TIMER_ABSTIME") + v("CLOCK_MONOTONIC") if header(""): v("WNOHANG") #{.importc, header: .}: cint v("WUNTRACED") #{.importc, header: "".}: cint - #v("WEXITSTATUS") - #v("WIFCONTINUED") - #v("WIFEXITED") + #v("WEXITSTATUS") + #v("WIFCONTINUED") + #v("WIFEXITED") #v("WIFSIGNALED") - #v("WIFSTOPPED") - #v("WSTOPSIG") - #v("WTERMSIG") + #v("WIFSTOPPED") + #v("WSTOPSIG") + #v("WTERMSIG") v("WEXITED") #{.importc, header: "".}: cint v("WSTOPPED") #{.importc, header: "".}: cint v("WCONTINUED") #{.importc, header: "".}: cint v("WNOWAIT") #{.importc, header: "".}: cint - v("P_ALL") #{.importc, header: "".}: cint - v("P_PID") #{.importc, header: "".}: cint + v("P_ALL") #{.importc, header: "".}: cint + v("P_PID") #{.importc, header: "".}: cint v("P_PGID") #{.importc, header: "".}: cint - + if header(""): v("SIGEV_NONE") #{.importc, header: "".}: cint v("SIGEV_SIGNAL") #{.importc, header: "".}: cint @@ -776,23 +776,23 @@ if header(""): v("HOST_NOT_FOUND") v("NO_DATA") - v("NO_RECOVERY") - v("TRY_AGAIN") + v("NO_RECOVERY") + v("TRY_AGAIN") - v("AI_PASSIVE") - v("AI_CANONNAME") - v("AI_NUMERICHOST") - v("AI_NUMERICSERV") - v("AI_V4MAPPED") - v("AI_ALL") - v("AI_ADDRCONFIG") + v("AI_PASSIVE") + v("AI_CANONNAME") + v("AI_NUMERICHOST") + v("AI_NUMERICSERV") + v("AI_V4MAPPED") + v("AI_ALL") + v("AI_ADDRCONFIG") - v("NI_NOFQDN") - v("NI_NUMERICHOST") - v("NI_NAMEREQD") - v("NI_NUMERICSERV") - v("NI_NUMERICSCOPE") - v("NI_DGRAM") + v("NI_NOFQDN") + v("NI_NUMERICHOST") + v("NI_NAMEREQD") + v("NI_NUMERICSERV") + v("NI_NUMERICSCOPE") + v("NI_DGRAM") v("EAI_AGAIN") v("EAI_BADFLAGS") v("EAI_FAIL") diff --git a/tools/detect/windows_i386_consts.nim b/tools/detect/windows_i386_consts.nim index cd6c475f4d..221251f810 100644 --- a/tools/detect/windows_i386_consts.nim +++ b/tools/detect/windows_i386_consts.nim @@ -1,96 +1,96 @@ -# Generated by detect.nim -const - E2BIG* = cint(7) - EACCES* = cint(13) - EAGAIN* = cint(11) - EBADF* = cint(9) - EBUSY* = cint(16) - ECHILD* = cint(10) - EDEADLK* = cint(36) - EDOM* = cint(33) - EEXIST* = cint(17) - EFAULT* = cint(14) - EFBIG* = cint(27) - EILSEQ* = cint(42) - EINTR* = cint(4) - EINVAL* = cint(22) - EIO* = cint(5) - EISDIR* = cint(21) - EMFILE* = cint(24) - EMLINK* = cint(31) - ENAMETOOLONG* = cint(38) - ENFILE* = cint(23) - ENODEV* = cint(19) - ENOENT* = cint(2) - ENOEXEC* = cint(8) - ENOLCK* = cint(39) - ENOMEM* = cint(12) - ENOSPC* = cint(28) - ENOSYS* = cint(40) - ENOTDIR* = cint(20) - ENOTEMPTY* = cint(41) - ENOTSUP* = cint(48) - ENOTTY* = cint(25) - ENXIO* = cint(6) - EPERM* = cint(1) - EPIPE* = cint(32) - ERANGE* = cint(34) - EROFS* = cint(30) - ESPIPE* = cint(29) - ESRCH* = cint(3) - ETIMEDOUT* = cint(10060) - EXDEV* = cint(18) - O_CREAT* = cint(256) - O_EXCL* = cint(1024) - O_TRUNC* = cint(512) - O_APPEND* = cint(8) - O_ACCMODE* = cint(3) - O_RDONLY* = cint(0) - O_RDWR* = cint(2) - O_WRONLY* = cint(1) - FE_DIVBYZERO* = cint(4) - FE_INEXACT* = cint(32) - FE_INVALID* = cint(1) - FE_OVERFLOW* = cint(8) - FE_UNDERFLOW* = cint(16) - FE_ALL_EXCEPT* = cint(63) - FE_DOWNWARD* = cint(1024) - FE_TONEAREST* = cint(0) - FE_TOWARDZERO* = cint(3072) - FE_UPWARD* = cint(2048) - FE_DFL_ENV* = pointer(nil) - LC_ALL* = cint(0) - LC_COLLATE* = cint(1) - LC_CTYPE* = cint(2) - LC_MONETARY* = cint(3) - LC_NUMERIC* = cint(4) - LC_TIME* = cint(5) - F_OK* = cint(0) - R_OK* = cint(4) - W_OK* = cint(2) - X_OK* = cint(1) - SEEK_SET* = cint(0) - SEEK_CUR* = cint(1) - SEEK_END* = cint(2) - S_IFMT* = cint(61440) - S_IFBLK* = cint(12288) - S_IFCHR* = cint(8192) - S_IFIFO* = cint(4096) - S_IFREG* = cint(32768) - S_IFDIR* = cint(16384) - S_IRWXU* = cint(448) - S_IRUSR* = cint(256) - S_IWUSR* = cint(128) - S_IXUSR* = cint(64) - CLOCKS_PER_SEC* = clong(1000) - SIGABRT* = cint(22) - SIGFPE* = cint(8) - SIGILL* = cint(4) - SIGINT* = cint(2) - SIGSEGV* = cint(11) - SIGTERM* = cint(15) - SIG_BLOCK* = cint(0) - SIG_UNBLOCK* = cint(1) - SIG_SETMASK* = cint(2) - IOFBF* = cint(0) - IONBF* = cint(4) +# Generated by detect.nim +const + E2BIG* = cint(7) + EACCES* = cint(13) + EAGAIN* = cint(11) + EBADF* = cint(9) + EBUSY* = cint(16) + ECHILD* = cint(10) + EDEADLK* = cint(36) + EDOM* = cint(33) + EEXIST* = cint(17) + EFAULT* = cint(14) + EFBIG* = cint(27) + EILSEQ* = cint(42) + EINTR* = cint(4) + EINVAL* = cint(22) + EIO* = cint(5) + EISDIR* = cint(21) + EMFILE* = cint(24) + EMLINK* = cint(31) + ENAMETOOLONG* = cint(38) + ENFILE* = cint(23) + ENODEV* = cint(19) + ENOENT* = cint(2) + ENOEXEC* = cint(8) + ENOLCK* = cint(39) + ENOMEM* = cint(12) + ENOSPC* = cint(28) + ENOSYS* = cint(40) + ENOTDIR* = cint(20) + ENOTEMPTY* = cint(41) + ENOTSUP* = cint(48) + ENOTTY* = cint(25) + ENXIO* = cint(6) + EPERM* = cint(1) + EPIPE* = cint(32) + ERANGE* = cint(34) + EROFS* = cint(30) + ESPIPE* = cint(29) + ESRCH* = cint(3) + ETIMEDOUT* = cint(10060) + EXDEV* = cint(18) + O_CREAT* = cint(256) + O_EXCL* = cint(1024) + O_TRUNC* = cint(512) + O_APPEND* = cint(8) + O_ACCMODE* = cint(3) + O_RDONLY* = cint(0) + O_RDWR* = cint(2) + O_WRONLY* = cint(1) + FE_DIVBYZERO* = cint(4) + FE_INEXACT* = cint(32) + FE_INVALID* = cint(1) + FE_OVERFLOW* = cint(8) + FE_UNDERFLOW* = cint(16) + FE_ALL_EXCEPT* = cint(63) + FE_DOWNWARD* = cint(1024) + FE_TONEAREST* = cint(0) + FE_TOWARDZERO* = cint(3072) + FE_UPWARD* = cint(2048) + FE_DFL_ENV* = pointer(nil) + LC_ALL* = cint(0) + LC_COLLATE* = cint(1) + LC_CTYPE* = cint(2) + LC_MONETARY* = cint(3) + LC_NUMERIC* = cint(4) + LC_TIME* = cint(5) + F_OK* = cint(0) + R_OK* = cint(4) + W_OK* = cint(2) + X_OK* = cint(1) + SEEK_SET* = cint(0) + SEEK_CUR* = cint(1) + SEEK_END* = cint(2) + S_IFMT* = cint(61440) + S_IFBLK* = cint(12288) + S_IFCHR* = cint(8192) + S_IFIFO* = cint(4096) + S_IFREG* = cint(32768) + S_IFDIR* = cint(16384) + S_IRWXU* = cint(448) + S_IRUSR* = cint(256) + S_IWUSR* = cint(128) + S_IXUSR* = cint(64) + CLOCKS_PER_SEC* = clong(1000) + SIGABRT* = cint(22) + SIGFPE* = cint(8) + SIGILL* = cint(4) + SIGINT* = cint(2) + SIGSEGV* = cint(11) + SIGTERM* = cint(15) + SIG_BLOCK* = cint(0) + SIG_UNBLOCK* = cint(1) + SIG_SETMASK* = cint(2) + IOFBF* = cint(0) + IONBF* = cint(4) diff --git a/tools/fakedeps.nim b/tools/fakedeps.nim index 80623fafb1..6963579dc7 100644 --- a/tools/fakedeps.nim +++ b/tools/fakedeps.nim @@ -15,4 +15,4 @@ proc fakedeps() = proc main = fakedeps() when isMainModule: - main() \ No newline at end of file + main() diff --git a/tools/niminst/debcreation.nim b/tools/niminst/debcreation.nim index bbd9979816..36b2a29ec9 100644 --- a/tools/niminst/debcreation.nim +++ b/tools/niminst/debcreation.nim @@ -38,33 +38,33 @@ proc createControl(pkgName, maintainer, shortDesc, desc: string, ## Multiple dependencies should be separated by commas. ## pkgDepends: Same as buildDepends except that this specifies the ## dependencies that the compiled application depends on. - - + + result = "" - + addN("Source: " & pkgName) addN("Maintainer: " & maintainer) addN("Section: misc") addN("Priority: optional") addN("Standards-Version: 3.9.2") - addN("Build-Depends: debhelper (>= 8)" & + addN("Build-Depends: debhelper (>= 8)" & (if buildDepends != "": ", " & buildDepends else: "")) addN("\n") addN("Package: " & pkgName) addN("Architecture: any") addN("Depends: ${shlibs:Depends}, ${misc:Depends}" & (if pkgDepends != "": ", " & pkgDepends else: "")) - + var formattedDesc = "" for line in splitLines(desc): if line == "": formattedDesc.add(" .\n") else: formattedDesc.add(" " & line & "\n") - + addN("Description: " & shortDesc & "\n" & formattedDesc) -proc createCopyright(pkgName, mtnName, mtnEmail, version: string, +proc createCopyright(pkgName, mtnName, mtnEmail, version: string, licenses: seq[tuple[files, license: string]]): string = ## pkgName: Package name ## mtnName: Maintainer name @@ -73,7 +73,7 @@ proc createCopyright(pkgName, mtnName, mtnEmail, version: string, ## licenses: files: This specifies the files that the `license` covers, ## for example, it might be ``lib/*`` to cover the whole ``lib`` dir ## license: This specifies the license, for example gpl2, or lgpl. - + result = "" addN("Maintainer name: " & mtnName) addN("Email-Address: " & mtnEmail) @@ -86,7 +86,7 @@ proc createCopyright(pkgName, mtnName, mtnEmail, version: string, proc formatDateTime(t: TimeInfo, timezone: string): string = var day = ($t.weekday)[0..2] & ", " - + return "$1$2 $3 $4 $5:$6:$7 $8" % [day, intToStr(t.monthday, 2), ($t.month)[0..2], $t.year, intToStr(t.hour, 2), intToStr(t.minute, 2), intToStr(t.second, 2), timezone] @@ -147,41 +147,41 @@ proc prepDeb*(packName, version, mtnName, mtnEmail, shortDesc, desc: string, buildDepends, pkgDepends = "") = ## binaries/config/docs/lib: files relative to nim's root, that need to ## be installed. - + let pkgName = packName.toLower() - + var workingDir = getTempDir() / "niminst" / "deb" var upstreamSource = (pkgName & "-" & version) - + echo("Making sure build.sh and install.sh are +x") - assertSuccess execCmd("chmod +x \"" & + assertSuccess execCmd("chmod +x \"" & (workingDir / upstreamSource / "build.sh") & "\"") - assertSuccess execCmd("chmod +x \"" & + assertSuccess execCmd("chmod +x \"" & (workingDir / upstreamSource / "install.sh") & "\"") - - var tarCmd = "tar pczf \"" & + + var tarCmd = "tar pczf \"" & (pkgName & "_" & version & ".orig.tar.gz") & - "\" \"" & upstreamSource & "\"" + "\" \"" & upstreamSource & "\"" echo(tarCmd) assertSuccess execCmd("cd \"" & workingDir & "\" && " & tarCmd) - + echo("Creating necessary files in debian/") createDir(workingDir / upstreamSource / "debian") - + template writeDebian(f, s: string): expr = writeFile(workingDir / upstreamSource / "debian" / f, s) - + var controlFile = createControl(pkgName, makeMtn(mtnName, mtnEmail), shortDesc, desc, buildDepends, pkgDepends) echo("debian/control") writeDebian("control", controlFile) - + var copyrightFile = createCopyright(pkgName, mtnName, mtnEmail, version, licenses) echo("debian/copyright") writeDebian("copyright", copyrightFile) - var changelogFile = createChangelog(pkgName, version, + var changelogFile = createChangelog(pkgName, version, makeMtn(mtnName, mtnEmail)) echo("debian/changelog") writeDebian("changelog", changelogFile) @@ -206,7 +206,7 @@ proc prepDeb*(packName, version, mtnName, mtnEmail, shortDesc, desc: string, createIncludeBinaries(binaries)) echo("All done, you can now build.") - echo("Before you do however, make sure the files in " & + echo("Before you do however, make sure the files in " & workingDir / upstreamSource / "debian" & " are correct.") echo("Change your directory to: " & workingDir / upstreamSource) echo("And execute `debuild -us -uc` to build the .deb") @@ -214,22 +214,22 @@ proc prepDeb*(packName, version, mtnName, mtnEmail, shortDesc, desc: string, when isMainModule: #var controlFile = createControl("nim", "Dominik Picheta ", # "The Nim compiler", "Compiler for the Nim programming language", "gcc (>= 4:4.3.2)", "gcc (>= 4:4.3.2)") - + #echo(controlFile) - + #var copyrightFile = createCopyright("nim", "Dominik Picheta", "morfeusz8@a.b", "0.8.14", # @[("bin/nim", "gpl2"), ("lib/*", "lgpl")]) - + #echo copyrightFile - + #var changelogFile = createChangelog("nim", "0.8.14", "Dom P ") #echo(changelogFile) - + #echo(createRules()) - prepDeb("nim", "0.9.2", "Dominik Picheta", "morfeusz8@gmail.com", + prepDeb("nim", "0.9.2", "Dominik Picheta", "morfeusz8@gmail.com", "The Nim compiler", "Compiler for the Nim programming language", - @[("bin/nim", "MIT"), ("lib/*", "MIT")], + @[("bin/nim", "MIT"), ("lib/*", "MIT")], @["bin/nim"], @["config/*"], @["doc/*"], @["lib/*"], "gcc (>= 4:4.3.2)", "gcc (>= 4:4.3.2)") diff --git a/tools/noprefix.nim b/tools/noprefix.nim index fe03a9efc4..d16c2b520f 100644 --- a/tools/noprefix.nim +++ b/tools/noprefix.nim @@ -13,12 +13,12 @@ const ("sdl/sdl_mixer", "sdl"), ("sdl/sdl_ttf", "sdl"), ("sdl/smpeg", "sdl"), - + ("libcurl", "curl"), ("mysql", "mysql"), ("postgres", ""), ("sqlite3", "sqlite3"), - + ("pcre/pcre", "pcre") ] diff --git a/tools/restorecc.nim b/tools/restorecc.nim index f5d8f0bb37..ff95427d8f 100644 --- a/tools/restorecc.nim +++ b/tools/restorecc.nim @@ -1,16 +1,16 @@ import os, strutils -proc main(dir: string, wanted: string) = - for kind, path in walkDir(dir): - case kind +proc main(dir: string, wanted: string) = + for kind, path in walkDir(dir): + case kind of pcFile: let name = extractFilename(path) if name == wanted: let newLoc = path.replace("mingw_backup", "mingw") echo "creating ", newLoc - copyFile(path, newLoc) - of pcDir: main(path, wanted) - else: discard + copyFile(path, newLoc) + of pcDir: main(path, wanted) + else: discard main("dist/mingw_backup", paramStr(1)) From e80465dacf50f260abec30ae57d37b298c93fd83 Mon Sep 17 00:00:00 2001 From: Adam Strzelecki Date: Fri, 4 Sep 2015 23:04:32 +0200 Subject: [PATCH 04/11] tests: Trim .nim files trailing whitespace via OSX: find . -name '*.nim' -exec sed -i '' -E 's/[[:space:]]+$//' {} + --- tests/actiontable/tactiontable.nim | 14 +- tests/alias/talias.nim | 14 +- tests/ambsym/mambsym1.nim | 20 +- tests/ambsym/mambsym2.nim | 6 +- tests/ambsym/mambsys1.nim | 14 +- tests/ambsym/mambsys2.nim | 8 +- tests/ambsym/tambsym.nim | 16 +- tests/ambsym/tambsym2.nim | 4 +- tests/ambsym/tambsym3.nim | 16 +- tests/array/tarray.nim | 54 +- tests/array/tarray2.nim | 2 +- tests/array/tarray3.nim | 4 +- tests/array/tarraycons.nim | 2 +- tests/array/tarraycons2.nim | 2 +- tests/array/tarrayplus.nim | 2 +- tests/array/tarrindx.nim | 26 +- tests/assert/tuserassert.nim | 4 +- tests/assign/tassign.nim | 62 +- tests/assign/tgenericassign.nim | 2 +- tests/assign/tgenericassigntuples.nim | 2 +- tests/assign/tobjasgn.nim | 2 +- tests/async/tasyncawait.nim | 2 +- tests/async/tasynceverror.nim | 2 +- tests/async/tasyncfile.nim | 6 +- tests/async/tasynciossl.nim | 4 +- tests/async/tasyncudp.nim | 10 +- tests/benchmark.nim | 2 +- tests/benchmarks/fannkuch.nim | 6 +- tests/benchmarks/quicksort.nim | 2 +- tests/bind/mbind3.nim | 2 +- tests/bind/tbind1.nim | 8 +- tests/bind/tbind2.nim | 2 +- tests/bind/tdatabind.nim | 12 +- tests/borrow/tborrow.nim | 4 +- tests/casestmt/tcaseoverlaprange.nim | 4 +- tests/casestmt/tcaseoverlaprange2.nim | 2 +- tests/casestmt/tcasestm.nim | 2 +- tests/casestmt/tlinearscanend.nim | 8 +- tests/ccgbugs/tccgen1.nim | 22 +- tests/ccgbugs/tcgbug.nim | 2 +- tests/ccgbugs/tcodegenbug1.nim | 4 +- tests/closure/tclosure.nim | 2 +- tests/closure/tclosure2.nim | 16 +- tests/closure/tclosure3.nim | 2 +- tests/closure/tclosurebug2.nim | 12 +- tests/closure/tinterf.nim | 4 +- tests/closure/tinvalidclosure2.nim | 4 +- tests/closure/tjester.nim | 2 +- tests/closure/tnestedclosure.nim | 2 +- tests/closure/tnestedproc.nim | 4 +- tests/closure/uclosures.nim | 2 +- tests/cnstseq/tcnstseq.nim | 4 +- tests/cnstseq/tcnstseq2.nim | 4 +- tests/collections/tindexby.nim | 4 +- tests/collections/ttableconstr.nim | 2 +- tests/constr/tconstr1.nim | 46 +- tests/constr/tconstr2.nim | 40 +- tests/constraints/tconstraints.nim | 2 +- tests/controlflow/tblock1.nim | 22 +- tests/controlflow/tcontinue.nim | 4 +- tests/controlflow/tnestif.nim | 36 +- tests/controlflow/tstatret.nim | 10 +- tests/converter/ttypeconverter1.nim | 2 +- tests/cpp/tthread_createthread.nim | 2 +- tests/dir with space/tspace.nim | 2 +- tests/discard/tdiscardable.nim | 4 +- tests/discard/tneedsdiscard.nim | 4 +- tests/distinct/tcurrncy.nim | 4 +- tests/dll/client.nim | 6 +- tests/dll/server.nim | 10 +- tests/effects/teffects1.nim | 6 +- tests/effects/teffects2.nim | 4 +- tests/effects/teffects3.nim | 4 +- tests/effects/teffects4.nim | 4 +- tests/effects/teffects5.nim | 2 +- tests/effects/teffects6.nim | 4 +- tests/effects/tsidee1.nim | 4 +- tests/effects/tsidee2.nim | 4 +- tests/effects/tsidee3.nim | 4 +- tests/effects/tsidee4.nim | 4 +- tests/enum/tenum.nim | 16 +- tests/enum/tenum2.nim | 6 +- tests/enum/tenum3.nim | 6 +- tests/enum/tenumhole.nim | 4 +- tests/enum/tenummix.nim | 2 +- tests/enum/toptions.nim | 36 +- tests/exception/tcontinuexc.nim | 2 +- tests/exception/tfinally.nim | 4 +- tests/exception/tfinally2.nim | 6 +- tests/exception/tfinally3.nim | 2 +- tests/exception/tnestedreturn2.nim | 2 +- tests/exception/tunhandledexc.nim | 2 +- tests/exception/twrongexc.nim | 2 +- tests/exprs/tstmtexprs.nim | 8 +- tests/fields/tfieldindex.nim | 2 +- tests/fields/tfielditerator.nim | 2 +- tests/fields/tfielditerator2.nim | 4 +- tests/float/tfloat3.nim | 2 +- tests/friends/mfriends.nim | 6 +- tests/gc/closureleak.nim | 4 +- tests/gc/gcbench.nim | 330 +-- tests/gc/gcleak2.nim | 2 +- tests/gc/gcleak4.nim | 4 +- tests/gc/gcleak5.nim | 4 +- tests/gc/refarrayleak.nim | 2 +- tests/generics/t1056.nim | 2 +- tests/generics/t1789.nim | 2 +- tests/generics/tconfusing_arrow.nim | 2 +- tests/generics/tdictdestruct.nim | 4 +- tests/generics/texplicitgeneric1.nim | 24 +- tests/generics/texplicitgeneric2.nim | 22 +- tests/generics/tgeneric1.nim | 4 +- tests/generics/tgenericdefaults.nim | 4 +- tests/generics/tgenericmatcher.nim | 2 +- tests/generics/tgenericmatcher2.nim | 2 +- tests/generics/tgenericrefs.nim | 8 +- tests/generics/tgenericshardcases.nim | 4 +- tests/generics/tgenericvariant.nim | 2 +- tests/generics/tinferredgenericprocs.nim | 2 +- tests/generics/tthread_generic.nim | 4 +- tests/generics/twrong_field_caching.nim | 10 +- tests/generics/twrong_floatlit_type.nim | 46 +- tests/global/globalaux.nim | 2 +- tests/init/tuninit1.nim | 8 +- tests/iter/tcountup.nim | 6 +- tests/iter/titer.nim | 88 +- tests/iter/titer6.nim | 8 +- tests/iter/titer8.nim | 4 +- tests/iter/titer_no_tuple_unpack.nim | 14 +- tests/js.nim | 2 +- tests/js/test2.nim | 4 +- tests/lexer/thexlit.nim | 2 +- tests/lexer/thexrange.nim | 2 +- tests/lexer/tident.nim | 18 +- tests/lexer/tind1.nim | 2 +- tests/lexer/tlexer.nim | 120 +- tests/lexer/tstrlits.nim | 4 +- tests/lexer/tunderscores.nim | 2 +- tests/lookups/tkoeniglookup.nim | 2 +- tests/lookups/tredef.nim | 4 +- tests/macros/tclosuremacro.nim | 2 +- tests/macros/tmacro2.nim | 4 +- tests/macros/tmacrogenerics.nim | 2 +- tests/macros/tmacrostmt.nim | 2 +- tests/macros/tprintf.nim | 20 +- tests/macros/tquotewords.nim | 4 +- tests/macros/tstaticparamsmacro.nim | 4 +- tests/macros/tvtable.nim | 2 +- tests/magics/tlowhigh.nim | 36 +- .../dependencies/chipmunk/chipmunk.nim | 336 +-- .../keineschweine/dependencies/enet/enet.nim | 226 +- .../dependencies/enet/testserver.nim | 12 +- .../dependencies/genpacket/streams_enh.nim | 12 +- .../keineschweine/dependencies/nake/nake.nim | 8 +- .../keineschweine/dependencies/sfml/sfml.nim | 76 +- .../dependencies/sfml/sfml_audio.nim | 24 +- .../dependencies/sfml/sfml_colors.nim | 2 +- .../keineschweine/enet_server/enet_client.nim | 30 +- .../keineschweine/enet_server/enet_server.nim | 86 +- .../enet_server/server_utils.nim | 10 +- tests/manyloc/keineschweine/keineschweine.nim | 110 +- .../keineschweine/lib/client_helpers.nim | 10 +- tests/manyloc/keineschweine/lib/estreams.nim | 8 +- tests/manyloc/keineschweine/lib/gl.nim | 346 +-- tests/manyloc/keineschweine/lib/glext.nim | 2334 ++++++++--------- tests/manyloc/keineschweine/lib/glu.nim | 134 +- tests/manyloc/keineschweine/lib/glut.nim | 140 +- tests/manyloc/keineschweine/lib/glx.nim | 60 +- tests/manyloc/keineschweine/lib/idgen.nim | 2 +- .../keineschweine/lib/input_helpers.nim | 24 +- .../manyloc/keineschweine/lib/map_filter.nim | 6 +- .../keineschweine/lib/math_helpers.nim | 2 +- .../manyloc/keineschweine/lib/sfml_stuff.nim | 2 +- tests/manyloc/keineschweine/lib/sg_assets.nim | 70 +- tests/manyloc/keineschweine/lib/sg_gui.nim | 34 +- .../manyloc/keineschweine/lib/sg_packets.nim | 10 +- tests/manyloc/keineschweine/lib/vehicles.nim | 2 +- tests/manyloc/keineschweine/lib/wingl.nim | 148 +- .../keineschweine/lib/zlib_helpers.nim | 4 +- .../keineschweine/server/old_dirserver.nim | 16 +- .../keineschweine/server/old_server_utils.nim | 4 +- .../keineschweine/server/old_sg_server.nim | 56 +- .../manyloc/keineschweine/server/sg_lobby.nim | 48 +- tests/manyloc/nake/nake.nim | 8 +- tests/manyloc/nake/nakefile.nim | 14 +- tests/metatype/tbindtypedesc.nim | 4 +- tests/metatype/tconstraints.nim | 2 +- tests/metatype/tmatrix.nim | 4 +- tests/metatype/tmatrix1.nim | 4 +- tests/metatype/tmatrix2.nim | 4 +- tests/metatype/tstaticparammacro.nim | 4 +- tests/metatype/tstaticparams.nim | 4 +- tests/metatype/ttypedesc1.nim | 10 +- tests/metatype/ttypeselectors.nim | 2 +- tests/metatype/ttypetraits.nim | 6 +- tests/method/tmethods1.nim | 2 +- tests/method/tmultim1.nim | 4 +- tests/method/tmultim2.nim | 4 +- tests/method/tmultim4.nim | 2 +- tests/method/tmultim6.nim | 4 +- tests/misc/minit.nim | 4 +- tests/misc/mvarious.nim | 12 +- tests/misc/t99bott.nim | 2 +- tests/misc/tack.nim | 30 +- tests/misc/tatomic.nim | 4 +- tests/misc/tcolonisproc.nim | 2 +- tests/misc/tdllvar.nim | 2 +- tests/misc/temit.nim | 4 +- tests/misc/teventemitter.nim | 6 +- tests/misc/tevents.nim | 4 +- tests/misc/tfib.nim | 4 +- tests/misc/tgetstartmilsecs.nim | 2 +- tests/misc/theaproots.nim | 6 +- tests/misc/thintoff.nim | 2 +- tests/misc/tinit.nim | 12 +- tests/misc/tinout.nim | 18 +- tests/misc/tinvalidnewseq.nim | 8 +- tests/misc/tlastmod.nim | 36 +- tests/misc/tlocals.nim | 4 +- tests/misc/tloops.nim | 2 +- tests/misc/tmissingnilcheck.nim | 2 +- tests/misc/tnew.nim | 98 +- tests/misc/tnewderef.nim | 2 +- tests/misc/tnewsets.nim | 12 +- tests/misc/tnewuns.nim | 24 +- tests/misc/tnoinst.nim | 2 +- tests/misc/tnot.nim | 4 +- tests/misc/tparedef.nim | 8 +- tests/misc/tpos.nim | 58 +- tests/misc/tquicksort.nim | 8 +- tests/misc/tradix.nim | 168 +- tests/misc/trawstr.nim | 10 +- tests/misc/tromans.nim | 6 +- tests/misc/tsimplesort.nim | 6 +- tests/misc/tsimtych.nim | 10 +- tests/misc/tsizeof.nim | 20 +- tests/misc/tsortdev.nim | 8 +- tests/misc/tstrace.nim | 32 +- tests/misc/tstrange.nim | 34 +- tests/misc/tstrdesc.nim | 28 +- tests/misc/tvarious1.nim | 6 +- tests/mmaptest.nim | 18 +- tests/modules/mnamspc1.nim | 4 +- tests/modules/mnamspc2.nim | 6 +- tests/modules/mopaque.nim | 10 +- tests/modules/mrecmod.nim | 2 +- tests/modules/mrecmod2.nim | 4 +- tests/modules/texport.nim | 2 +- tests/modules/tnamspc.nim | 10 +- tests/modules/trecmod.nim | 4 +- tests/namedparams/tnamedparams.nim | 6 +- tests/namedparams/tnamedparams2.nim | 6 +- tests/notnil/tnotnil.nim | 2 +- tests/notnil/tnotnil1.nim | 4 +- tests/notnil/tnotnil_in_generic.nim | 6 +- tests/objects/tobjcov.nim | 4 +- tests/objects/tobject.nim | 2 +- tests/objects/tobject3.nim | 2 +- tests/objects/tobjects.nim | 2 +- tests/objects/tobjpragma.nim | 10 +- tests/objects/tofopr.nim | 8 +- tests/objects/toop.nim | 6 +- tests/objvariant/tcheckedfield1.nim | 4 +- tests/osproc/ta.nim | 2 +- tests/overflw/tovfint.nim | 34 +- tests/overload/toverl2.nim | 6 +- tests/overload/toverl3.nim | 6 +- tests/overload/toverl4.nim | 2 +- tests/overload/toverwr.nim | 26 +- tests/parallel/treadafterwrite.nim | 2 +- tests/parallel/tuseafterdef.nim | 4 +- tests/parser/tdomulttest.nim | 2 +- tests/parser/tinvwhen.nim | 16 +- tests/parser/toprprec.nim | 8 +- tests/pragmas/tpush.nim | 30 +- tests/proc/tnestprc.nim | 8 +- tests/procvar/tprocvar.nim | 2 +- tests/procvar/tprocvar2.nim | 28 +- tests/range/tbug499771.nim | 4 +- tests/range/tcolors.nim | 28 +- tests/range/tmatrix3.nim | 8 +- tests/range/tsubrange.nim | 6 +- tests/range/tsubrange2.nim | 6 +- tests/range/tsubrange3.nim | 4 +- tests/rectest.nim | 12 +- tests/rodfiles/amethods.nim | 2 +- tests/rodfiles/bmethods.nim | 2 +- tests/rodfiles/bmethods2.nim | 2 +- tests/rodfiles/deadg.nim | 4 +- tests/rodfiles/gtkex1.nim | 28 +- tests/rodfiles/gtkex2.nim | 8 +- tests/rodfiles/hallo2.nim | 2 +- tests/seq/tseq2.nim | 4 +- tests/seq/tseqcon.nim | 90 +- tests/seq/tseqtuple.nim | 2 +- tests/seq/ttoseq.nim | 4 +- tests/sets/tsets.nim | 408 +-- tests/sets/tsets2.nim | 10 +- tests/showoff/thtml1.nim | 2 +- tests/stckovfl.nim | 4 +- tests/stdlib/nre/captures.nim | 2 +- tests/stdlib/talgorithm.nim | 2 +- tests/stdlib/tcritbits.nim | 2 +- tests/stdlib/tformat.nim | 12 +- tests/stdlib/tio.nim | 14 +- tests/stdlib/tlists.nim | 12 +- tests/stdlib/tmarshal.nim | 2 +- tests/stdlib/tmath.nim | 6 +- tests/stdlib/tmath2.nim | 170 +- tests/stdlib/tos.nim | 4 +- tests/stdlib/tosprocterminate.nim | 2 +- tests/stdlib/tparscfg.nim | 4 +- tests/stdlib/tquit.nim | 12 +- tests/stdlib/tregex.nim | 40 +- tests/stdlib/treguse.nim | 42 +- tests/stdlib/trepr.nim | 2 +- tests/stdlib/trepr2.nim | 64 +- tests/stdlib/tsplit.nim | 2 +- tests/stdlib/tstrset.nim | 6 +- tests/stdlib/tstrtabs.nim | 2 +- tests/stdlib/ttime.nim | 12 +- tests/stdlib/twalker.nim | 26 +- tests/system/io.nim | 2 +- tests/template/annotate.nim | 2 +- tests/template/mtempl5.nim | 6 +- tests/template/otests.nim | 438 ++-- tests/template/thygienictempl.nim | 4 +- tests/template/tmodulealias.nim | 4 +- tests/template/tstempl.nim | 2 +- tests/template/ttempl.nim | 4 +- tests/template/ttempl3.nim | 12 +- tests/template/twrongopensymchoice.nim | 6 +- tests/testament/backend.nim | 20 +- tests/testament/tester.nim | 4 +- tests/threads/tactors2.nim | 2 +- tests/threads/threadex.nim | 2 +- tests/threads/tthreadanalysis.nim | 4 +- tests/threads/tthreadanalysis2.nim | 4 +- tests/threads/tthreadheapviolation1.nim | 2 +- tests/threads/ttryrecv.nim | 2 +- tests/trmacros/tcse.nim | 2 +- tests/trmacros/tmatrix.nim | 2 +- tests/trmacros/tstar.nim | 2 +- tests/typerel/tno_int_in_bool_context.nim | 4 +- tests/typerel/trectuples.nim | 2 +- tests/typerel/trefs.nim | 32 +- tests/typerel/tregionptrs.nim | 2 +- tests/typerel/tregionptrs2.nim | 4 +- tests/typerel/tsecondarrayproperty.nim | 2 +- tests/typerel/ttuple1.nim | 2 +- tests/typerel/ttypenoval.nim | 4 +- tests/typerel/tvoid.nim | 4 +- tests/typerel/typalias.nim | 6 +- tests/types/tfinalobj.nim | 4 +- tests/types/tforwty.nim | 18 +- tests/types/tforwty2.nim | 44 +- tests/types/tillegaltyperecursion.nim | 16 +- tests/types/tinheritref.nim | 2 +- tests/types/tisop.nim | 2 +- tests/varres/tvarres1.nim | 4 +- tests/varres/tvarres2.nim | 4 +- tests/varres/tvarres3.nim | 4 +- tests/varres/tvartup.nim | 2 +- tests/varstmt/tlet.nim | 2 +- tests/varstmt/tvardecl.nim | 18 +- tests/vm/tarrayboundeval.nim | 4 +- tests/vm/tasmparser.nim | 12 +- tests/vm/tconsteval.nim | 2 +- tests/vm/teval1.nim | 2 +- tests/vm/tldconst.nim | 2 +- tests/vm/trgba.nim | 26 +- tests/vm/tslurp.nim | 2 +- 372 files changed, 4486 insertions(+), 4486 deletions(-) diff --git a/tests/actiontable/tactiontable.nim b/tests/actiontable/tactiontable.nim index e2f19a099e..18b0fd388d 100644 --- a/tests/actiontable/tactiontable.nim +++ b/tests/actiontable/tactiontable.nim @@ -4,23 +4,23 @@ discard """ import tables -proc action1(arg: string) = +proc action1(arg: string) = echo "action 1 ", arg -proc action2(arg: string) = +proc action2(arg: string) = echo "action 2 ", arg -proc action3(arg: string) = +proc action3(arg: string) = echo "action 3 ", arg -proc action4(arg: string) = +proc action4(arg: string) = echo "action 4 ", arg var actionTable = { - "A": action1, - "B": action2, - "C": action3, + "A": action1, + "B": action2, + "C": action3, "D": action4}.toTable actionTable["C"]("arg") diff --git a/tests/alias/talias.nim b/tests/alias/talias.nim index 819289c2e3..6addc4704f 100644 --- a/tests/alias/talias.nim +++ b/tests/alias/talias.nim @@ -6,7 +6,7 @@ type proc isPartOf*[S, T](a: S, b: T): TAnalysisResult {. magic: "IsPartOf", noSideEffect.} - ## not yet exported properly. + ## not yet exported properly. template compileTimeAssert(cond: expr) = when not cond: @@ -35,30 +35,30 @@ proc p(param1, param2: TC): TC = local: TC plocal: ptr TC plocal2: ptr TA - + local.arr <| local local.arr[0] <| local local.arr[2] !<| local.arr[1] - + plocal2[] ?<| local param1 ?<| param2 - + local.arr[0] !<| param1 local.arr !<| param1 local.le[] ?<| param1 - + param1 !<| local.arr[0] param1 !<| local.arr param1 ?<| local.le[] - + result !<| local result <| result var a, b: int x: TC - + a <| a a !<| b diff --git a/tests/ambsym/mambsym1.nim b/tests/ambsym/mambsym1.nim index d9d57b5e51..c4902b1b44 100644 --- a/tests/ambsym/mambsym1.nim +++ b/tests/ambsym/mambsym1.nim @@ -1,10 +1,10 @@ -import mambsym2 # import TExport - -type - TExport* = enum x, y, z - TOtherEnum* = enum mDec, mInc, mAssign - -proc ha() = - var - x: TExport # no error - discard +import mambsym2 # import TExport + +type + TExport* = enum x, y, z + TOtherEnum* = enum mDec, mInc, mAssign + +proc ha() = + var + x: TExport # no error + discard diff --git a/tests/ambsym/mambsym2.nim b/tests/ambsym/mambsym2.nim index eac8de6ba2..21d9800736 100644 --- a/tests/ambsym/mambsym2.nim +++ b/tests/ambsym/mambsym2.nim @@ -1,3 +1,3 @@ -type - TExport* = enum a, b, c - +type + TExport* = enum a, b, c + diff --git a/tests/ambsym/mambsys1.nim b/tests/ambsym/mambsys1.nim index 04f9561d30..22e54cb949 100644 --- a/tests/ambsym/mambsys1.nim +++ b/tests/ambsym/mambsys1.nim @@ -1,7 +1,7 @@ -import mambsys2 # import TExport - -type - TExport* = enum x, y, z - -proc foo*(x: int) = - discard +import mambsys2 # import TExport + +type + TExport* = enum x, y, z + +proc foo*(x: int) = + discard diff --git a/tests/ambsym/mambsys2.nim b/tests/ambsym/mambsys2.nim index d59706865c..ef63e4f7e5 100644 --- a/tests/ambsym/mambsys2.nim +++ b/tests/ambsym/mambsys2.nim @@ -1,4 +1,4 @@ -type - TExport* = enum x, y, z # exactly the same type! - -proc foo*(x: int) = discard +type + TExport* = enum x, y, z # exactly the same type! + +proc foo*(x: int) = discard diff --git a/tests/ambsym/tambsym.nim b/tests/ambsym/tambsym.nim index 9022746480..d9115e16d5 100644 --- a/tests/ambsym/tambsym.nim +++ b/tests/ambsym/tambsym.nim @@ -3,13 +3,13 @@ discard """ line: 11 errormsg: "ambiguous identifier" """ -# Test ambiguous symbols - -import mambsym1, mambsym2 - -var - v: TExport #ERROR_MSG ambiguous identifier - -v = y +# Test ambiguous symbols + +import mambsym1, mambsym2 + +var + v: TExport #ERROR_MSG ambiguous identifier + +v = y diff --git a/tests/ambsym/tambsym2.nim b/tests/ambsym/tambsym2.nim index c3b997549e..8e288e73a7 100644 --- a/tests/ambsym/tambsym2.nim +++ b/tests/ambsym/tambsym2.nim @@ -8,12 +8,12 @@ type TMyType = object len: int data: string - + proc len(x: TMyType): int {.inline.} = return x.len proc x(s: TMyType, len: int) = writeLine(stdout, len(s)) - + var m: TMyType m.len = 7 diff --git a/tests/ambsym/tambsym3.nim b/tests/ambsym/tambsym3.nim index ed8a3058af..b25dadfd63 100644 --- a/tests/ambsym/tambsym3.nim +++ b/tests/ambsym/tambsym3.nim @@ -3,13 +3,13 @@ discard """ line: 11 errormsg: "ambiguous identifier" """ -# Test ambiguous symbols - -import mambsym1, times - -var - v = mDec #ERROR_MSG ambiguous identifier - -writeLine(stdout, ord(v)) +# Test ambiguous symbols + +import mambsym1, times + +var + v = mDec #ERROR_MSG ambiguous identifier + +writeLine(stdout, ord(v)) diff --git a/tests/array/tarray.nim b/tests/array/tarray.nim index 01fbdf4228..9cfb758e20 100644 --- a/tests/array/tarray.nim +++ b/tests/array/tarray.nim @@ -2,33 +2,33 @@ discard """ file: "tarray.nim" output: "100124" """ -# simple check for one dimensional arrays - -type - TMyArray = array[0..2, int] - TMyRecord = tuple[x, y: int] - -proc sum(a: TMyarray): int = - result = 0 - var i = 0 - while i < len(a): - inc(result, a[i]) - inc(i) - -proc sum(a: openarray[int]): int = - result = 0 - var i = 0 - while i < len(a): - inc(result, a[i]) - inc(i) - -proc getPos(r: TMyRecord): int = - result = r.x + r.y - -write(stdout, sum([1, 2, 3, 4])) -write(stdout, sum([])) -write(stdout, getPos( (x: 5, y: 7) )) -#OUT 10012 +# simple check for one dimensional arrays + +type + TMyArray = array[0..2, int] + TMyRecord = tuple[x, y: int] + +proc sum(a: TMyarray): int = + result = 0 + var i = 0 + while i < len(a): + inc(result, a[i]) + inc(i) + +proc sum(a: openarray[int]): int = + result = 0 + var i = 0 + while i < len(a): + inc(result, a[i]) + inc(i) + +proc getPos(r: TMyRecord): int = + result = r.x + r.y + +write(stdout, sum([1, 2, 3, 4])) +write(stdout, sum([])) +write(stdout, getPos( (x: 5, y: 7) )) +#OUT 10012 # bug #1669 let filesToCreate = ["tempdir/fl1.a", "tempdir/fl2.b", diff --git a/tests/array/tarray2.nim b/tests/array/tarray2.nim index b6adabb453..1951e6e972 100644 --- a/tests/array/tarray2.nim +++ b/tests/array/tarray2.nim @@ -9,7 +9,7 @@ type TObj = object arr: TMyarray - + proc mul(a, b: TMyarray): TMyArray = result = a for i in 0..len(a)-1: diff --git a/tests/array/tarray3.nim b/tests/array/tarray3.nim index d287783574..24bf26fda3 100644 --- a/tests/array/tarray3.nim +++ b/tests/array/tarray3.nim @@ -2,9 +2,9 @@ discard """ file: "tarray3.nim" output: "3" """ -# simple check for two dimensional arrays +# simple check for two dimensional arrays -const +const myData = [[1,2,3], [4, 5, 6]] echo myData[0][2] #OUT 3 diff --git a/tests/array/tarraycons.nim b/tests/array/tarraycons.nim index 7de518b6e6..9f09fd405a 100644 --- a/tests/array/tarraycons.nim +++ b/tests/array/tarraycons.nim @@ -7,7 +7,7 @@ discard """ type TEnum = enum eA, eB, eC, eD, eE, eF - + const myMapping: array[TEnum, array[0..1, int]] = [ eA: [1, 2], diff --git a/tests/array/tarraycons2.nim b/tests/array/tarraycons2.nim index 0b2a42c2f3..72d9e374ee 100644 --- a/tests/array/tarraycons2.nim +++ b/tests/array/tarraycons2.nim @@ -6,7 +6,7 @@ discard """ type TEnum = enum eA, eB, eC, eD, eE, eF - + const myMapping: array[TEnum, array[0..1, int]] = [ eA: [1, 2], diff --git a/tests/array/tarrayplus.nim b/tests/array/tarrayplus.nim index 0ea349f4f4..33921c0e13 100644 --- a/tests/array/tarrayplus.nim +++ b/tests/array/tarrayplus.nim @@ -6,7 +6,7 @@ proc `+`*[R, T] (v1, v2: array[R, T]): array[R, T] = for i in low(v1)..high(v1): result[i] = v1[i] + v2[i] -var +var v1: array[0..2, float] = [3.0, 1.2, 3.0] v2: array[0..1, float] = [2.0, 1.0] v3 = v1 + v2 diff --git a/tests/array/tarrindx.nim b/tests/array/tarrindx.nim index 13919cc2c3..a8d72b338a 100644 --- a/tests/array/tarrindx.nim +++ b/tests/array/tarrindx.nim @@ -1,13 +1,13 @@ -# test another strange bug ... (I hate this compiler; it is much too buggy!) - -proc putEnv(key, val: string) = - # XXX: we have to leak memory here, as we cannot - # free it before the program ends (says Borland's - # documentation) - var - env: ptr array[0..500000, char] - env = cast[ptr array[0..500000, char]](alloc(len(key) + len(val) + 2)) - for i in 0..len(key)-1: env[i] = key[i] - env[len(key)] = '=' - for i in 0..len(val)-1: - env[len(key)+1+i] = val[i] +# test another strange bug ... (I hate this compiler; it is much too buggy!) + +proc putEnv(key, val: string) = + # XXX: we have to leak memory here, as we cannot + # free it before the program ends (says Borland's + # documentation) + var + env: ptr array[0..500000, char] + env = cast[ptr array[0..500000, char]](alloc(len(key) + len(val) + 2)) + for i in 0..len(key)-1: env[i] = key[i] + env[len(key)] = '=' + for i in 0..len(val)-1: + env[len(key)+1+i] = val[i] diff --git a/tests/assert/tuserassert.nim b/tests/assert/tuserassert.nim index 57b229ca91..7bb0a7fc01 100644 --- a/tests/assert/tuserassert.nim +++ b/tests/assert/tuserassert.nim @@ -2,12 +2,12 @@ discard """ output: "x == 45ugh" """ -template myAssert(cond: expr) = +template myAssert(cond: expr) = when 3 <= 3: let c = cond.astToStr if not cond: echo c, "ugh" - + var x = 454 myAssert(x == 45) diff --git a/tests/assign/tassign.nim b/tests/assign/tassign.nim index 9a4c1543bf..4c173d04f0 100644 --- a/tests/assign/tassign.nim +++ b/tests/assign/tassign.nim @@ -1,31 +1,31 @@ -# Test the assignment operator for complex types which need RTTI - -type - TRec = object - x, y: int - s: string - seq: seq[string] - arr: seq[seq[array[0..3, string]]] - TRecSeq = seq[TRec] - -proc test() = - var - a, b: TRec - a.x = 1 - a.y = 2 - a.s = "Hallo!" - a.seq = @["abc", "def", "ghi", "jkl"] - a.arr = @[] - setLen(a.arr, 4) - a.arr[0] = @[] - a.arr[1] = @[] - - b = a # perform a deep copy here! - b.seq = @["xyz", "huch", "was", "soll"] - writeLine(stdout, len(a.seq)) - writeLine(stdout, a.seq[3]) - writeLine(stdout, len(b.seq)) - writeLine(stdout, b.seq[3]) - writeLine(stdout, b.y) - -test() +# Test the assignment operator for complex types which need RTTI + +type + TRec = object + x, y: int + s: string + seq: seq[string] + arr: seq[seq[array[0..3, string]]] + TRecSeq = seq[TRec] + +proc test() = + var + a, b: TRec + a.x = 1 + a.y = 2 + a.s = "Hallo!" + a.seq = @["abc", "def", "ghi", "jkl"] + a.arr = @[] + setLen(a.arr, 4) + a.arr[0] = @[] + a.arr[1] = @[] + + b = a # perform a deep copy here! + b.seq = @["xyz", "huch", "was", "soll"] + writeLine(stdout, len(a.seq)) + writeLine(stdout, a.seq[3]) + writeLine(stdout, len(b.seq)) + writeLine(stdout, b.seq[3]) + writeLine(stdout, b.y) + +test() diff --git a/tests/assign/tgenericassign.nim b/tests/assign/tgenericassign.nim index 654b0ab8f7..bd9c6c21b3 100644 --- a/tests/assign/tgenericassign.nim +++ b/tests/assign/tgenericassign.nim @@ -6,7 +6,7 @@ type TAny* = object {.pure.} value*: pointer rawType: pointer - + proc newAny(value, rawType: pointer): TAny = result.value = value result.rawType = rawType diff --git a/tests/assign/tgenericassigntuples.nim b/tests/assign/tgenericassigntuples.nim index 6dd63a9844..cca244577a 100644 --- a/tests/assign/tgenericassigntuples.nim +++ b/tests/assign/tgenericassigntuples.nim @@ -4,7 +4,7 @@ discard """ var t, s: tuple[x: string, c: int] -proc ugh: seq[tuple[x: string, c: int]] = +proc ugh: seq[tuple[x: string, c: int]] = result = @[("abc", 232)] t = ugh()[0] diff --git a/tests/assign/tobjasgn.nim b/tests/assign/tobjasgn.nim index 23a31252df..e731d9e936 100644 --- a/tests/assign/tobjasgn.nim +++ b/tests/assign/tobjasgn.nim @@ -12,7 +12,7 @@ type a, b: int PSomeObj = ref object a, b: int - + var a = TSomeObj(a: 8) var b = PSomeObj(a: 5) echo a.a, " ", b.a, " ", a.b, " ", b.b diff --git a/tests/async/tasyncawait.nim b/tests/async/tasyncawait.nim index 13d531387f..e5895abe17 100644 --- a/tests/async/tasyncawait.nim +++ b/tests/async/tasyncawait.nim @@ -50,7 +50,7 @@ proc createServer(port: TPort) {.async.} = if bindAddr(server.SocketHandle, cast[ptr SockAddr](addr(name)), sizeof(name).Socklen) < 0'i32: raiseOSError(osLastError()) - + discard server.SocketHandle.listen() while true: asyncCheck readMessages(await accept(server)) diff --git a/tests/async/tasynceverror.nim b/tests/async/tasynceverror.nim index 3b81680cbd..5575cfe827 100644 --- a/tests/async/tasynceverror.nim +++ b/tests/async/tasynceverror.nim @@ -40,7 +40,7 @@ else: s = newAsyncSocket() await s.connect(testHost, testPort) - + var ps = await ls.accept() SocketHandle(ls).close() diff --git a/tests/async/tasyncfile.nim b/tests/async/tasyncfile.nim index c3cf33512e..05cda5e5f8 100644 --- a/tests/async/tasyncfile.nim +++ b/tests/async/tasyncfile.nim @@ -18,7 +18,7 @@ proc main() {.async.} = let data = await file.readAll() doAssert data == "foot" file.close() - + # Append test block: var file = openAsync(fn, fmAppend) @@ -29,8 +29,8 @@ proc main() {.async.} = file.close() file = openAsync(fn, fmRead) let data = await file.readAll() - + doAssert data == "foot\ntest2" file.close() - + waitFor main() diff --git a/tests/async/tasynciossl.nim b/tests/async/tasynciossl.nim index 118b9e74d9..ba856760e5 100644 --- a/tests/async/tasynciossl.nim +++ b/tests/async/tasynciossl.nim @@ -10,12 +10,12 @@ disp = newDispatcher() var msgCount = 0 when defined(ssl): - var ctx = newContext(verifyMode = CVerifyNone, + var ctx = newContext(verifyMode = CVerifyNone, certFile = "tests/testdata/mycert.pem", keyFile = "tests/testdata/mycert.pem") var ctx1 = newContext(verifyMode = CVerifyNone) -const +const swarmSize = 50 messagesToSend = 100 diff --git a/tests/async/tasyncudp.nim b/tests/async/tasyncudp.nim index 2a7ed40bf1..57e2be85df 100644 --- a/tests/async/tasyncudp.nim +++ b/tests/async/tasyncudp.nim @@ -20,12 +20,12 @@ proc serverRead(s: PAsyncSocket) = if s.recvFromAsync(data, 9, address, port): assert address == "127.0.0.1" msgCount.inc() - + discard """ - + var line = "" assert s.recvLine(line) - + if line == "": assert(false) else: @@ -66,11 +66,11 @@ while true: if not disp.poll(): break - + if (msgCount div messagesToSend) * serverCount == currentClient: createClient(disp, TPort(10335), false) createClient(disp, TPort(10336), true) - + if msgCount == messagesToSend * serverCount * swarmSize: break diff --git a/tests/benchmark.nim b/tests/benchmark.nim index 0613d1bf93..69c9a39272 100644 --- a/tests/benchmark.nim +++ b/tests/benchmark.nim @@ -44,4 +44,4 @@ when isMainModule: var b = doBench() var output = genOutput(b) writeFile("benchmarkResults.json", pretty(output)) - \ No newline at end of file + diff --git a/tests/benchmarks/fannkuch.nim b/tests/benchmarks/fannkuch.nim index 15f78f50c2..55405b3c98 100644 --- a/tests/benchmarks/fannkuch.nim +++ b/tests/benchmarks/fannkuch.nim @@ -2,7 +2,7 @@ import os import strutils proc fannkuch (n: int): int = - var + var count: seq[int] maxFlips = 0 m = n-1 @@ -58,7 +58,7 @@ proc fannkuch (n: int): int = for i in 0 .. r-1: perm1[i] = perm1[i+1] perm1[r] = tmp - + dec (count[r]) if count[r] > 0: break makePerm @@ -66,4 +66,4 @@ proc fannkuch (n: int): int = return maxFlips var n = 10 -echo ("Pfannkuchen(" & $n & ") = " & $fannkuch (n)) \ No newline at end of file +echo ("Pfannkuchen(" & $n & ") = " & $fannkuch (n)) diff --git a/tests/benchmarks/quicksort.nim b/tests/benchmarks/quicksort.nim index 599e3674c6..6a1222b9a5 100644 --- a/tests/benchmarks/quicksort.nim +++ b/tests/benchmarks/quicksort.nim @@ -51,4 +51,4 @@ proc sort (start, stop: int) = sort (0, data.len) echo (data[n div 2 - 1] and 0xFFFF_FFFF'i64, ", ", data[n div 2] and 0xFFFF_FFFF'i64, ", ", - data[n div 2 + 1] and 0xFFFF_FFFF'i64) \ No newline at end of file + data[n div 2 + 1] and 0xFFFF_FFFF'i64) diff --git a/tests/bind/mbind3.nim b/tests/bind/mbind3.nim index d02bc79d01..aad080223e 100644 --- a/tests/bind/mbind3.nim +++ b/tests/bind/mbind3.nim @@ -1,5 +1,5 @@ # Module A -var +var lastId = 0 template genId*: expr = diff --git a/tests/bind/tbind1.nim b/tests/bind/tbind1.nim index 6593b2307d..2665d0b5cf 100644 --- a/tests/bind/tbind1.nim +++ b/tests/bind/tbind1.nim @@ -6,14 +6,14 @@ discard """ proc p1(x: int8, y: int): int = return x + y -template tempBind(x, y: expr): expr = +template tempBind(x, y: expr): expr = bind p1 - p1(x, y) + p1(x, y) proc p1(x: int, y: int8): int = return x - y -# This is tricky: the call to ``p1(1'i8, 2'i8)`` should not fail in line 6, -# because it is not ambiguous there. But it is ambiguous after line 8. +# This is tricky: the call to ``p1(1'i8, 2'i8)`` should not fail in line 6, +# because it is not ambiguous there. But it is ambiguous after line 8. echo tempBind(1'i8, 2'i8) #OUT 3 diff --git a/tests/bind/tbind2.nim b/tests/bind/tbind2.nim index e8e21ad024..d2219765d0 100644 --- a/tests/bind/tbind2.nim +++ b/tests/bind/tbind2.nim @@ -8,7 +8,7 @@ discard """ proc p1(x: int8, y: int): int = return x + y proc p1(x: int, y: int8): int = return x - y -template tempBind(x, y: expr): expr = +template tempBind(x, y: expr): expr = (bind p1(x, y)) #ERROR_MSG ambiguous call echo tempBind(1'i8, 2'i8) diff --git a/tests/bind/tdatabind.nim b/tests/bind/tdatabind.nim index afa8aa47b3..124faee6f9 100644 --- a/tests/bind/tdatabind.nim +++ b/tests/bind/tdatabind.nim @@ -31,14 +31,14 @@ proc newProperty*[T](value: T): TProperty[T] = proc setter(property: var TProperty[T], v: T) = property.value = v - + # fire event here var args: TValueEventArgs[T] args.Property = property property.EEmitter.emit(property.ValueChanged, args) - + prop.setProc = setter - + return prop proc `prop`[T] (p: TProperty[T]): T = @@ -56,7 +56,7 @@ proc `$`[T] (p: TProperty[T]): string = proc propertyBind*[T](p1: var TProperty[T], p2: var TProperty[T]) = p1.Binders.add(p2) - + # make handler -> handler[T] so trigger even more generics bugs ... proc handler(e: TEventArgs) = type TEA = TValueEventArgs[T] @@ -77,9 +77,9 @@ proc `->`[T](p1: var TProperty[T], p2: var TProperty[T]) = when isMainModule: # Initial value testing var myProp = newProperty(5) - + echo(myProp) - + myProp ~= 7 # Temp operator until overloading of '=' is implemented. echo(myProp) diff --git a/tests/borrow/tborrow.nim b/tests/borrow/tborrow.nim index d4df5f524c..ee0d0194dd 100644 --- a/tests/borrow/tborrow.nim +++ b/tests/borrow/tborrow.nim @@ -6,12 +6,12 @@ discard """ proc `++`*[T: int | float](a, b: T): T = result = a + b - + type DI = distinct int DF = distinct float DS = distinct string - + proc `++`(x, y: DI): DI {.borrow.} proc `++`(x, y: DF): DF {.borrow.} diff --git a/tests/casestmt/tcaseoverlaprange.nim b/tests/casestmt/tcaseoverlaprange.nim index 5f24c3ca9a..3527c93854 100644 --- a/tests/casestmt/tcaseoverlaprange.nim +++ b/tests/casestmt/tcaseoverlaprange.nim @@ -8,8 +8,8 @@ type var e: TE - + case e -of A..D, B..C: +of A..D, B..C: echo "redundant" else: nil diff --git a/tests/casestmt/tcaseoverlaprange2.nim b/tests/casestmt/tcaseoverlaprange2.nim index d6e301508b..4a9479a5f6 100644 --- a/tests/casestmt/tcaseoverlaprange2.nim +++ b/tests/casestmt/tcaseoverlaprange2.nim @@ -6,7 +6,7 @@ discard """ -proc checkDuplicates(myval: int32): bool = +proc checkDuplicates(myval: int32): bool = case myval of 0x7B: echo "this should not compile" diff --git a/tests/casestmt/tcasestm.nim b/tests/casestmt/tcasestm.nim index a21b6be0db..7ac20bf2f6 100644 --- a/tests/casestmt/tcasestm.nim +++ b/tests/casestmt/tcasestm.nim @@ -25,7 +25,7 @@ of "will", "it", "finally", "be", "generated": discard var z = case i of 1..5, 8, 9: "aa" of 6, 7: "bb" - elif x == "Ha": + elif x == "Ha": "cc" elif x == "yyy": write(stdout, x) diff --git a/tests/casestmt/tlinearscanend.nim b/tests/casestmt/tlinearscanend.nim index 15fd0c70a1..9a984e039c 100644 --- a/tests/casestmt/tlinearscanend.nim +++ b/tests/casestmt/tlinearscanend.nim @@ -4,13 +4,13 @@ import strutils var x = 343 case stdin.readline.parseInt -of 0: +of 0: echo "most common case" -of 1: +of 1: {.linearScanEnd.} echo "second most common case" of 2: echo "unlikely: use branch table" -else: +else: echo "unlikely too: use branch table" @@ -18,7 +18,7 @@ case x of 23: echo "23" of 343: echo "343" of 21: echo "21" -else: +else: {.linearScanEnd.} echo "default" diff --git a/tests/ccgbugs/tccgen1.nim b/tests/ccgbugs/tccgen1.nim index 9234bbd6c0..4917c98483 100644 --- a/tests/ccgbugs/tccgen1.nim +++ b/tests/ccgbugs/tccgen1.nim @@ -18,21 +18,21 @@ type FOwnerDocument: PDocument # Read-Only FParentNode: PNode # Read-Only prefix*: string # Setting this should change some values... TODO! - + PElement* = ref Element Element = object of Node FTagName: string # Read-only - + PCharacterData = ref CharacterData CharacterData = object of Node data*: string - + PDocument* = ref Document Document = object of Node FImplementation: PDOMImplementation # Read-only FDocumentElement: PElement # Read-only - - PAttr* = ref Attr + + PAttr* = ref Attr Attr = object of Node FName: string # Read-only FSpecified: bool # Read-only @@ -44,22 +44,22 @@ type PText* = ref Text Text = object of CharacterData - + PComment* = ref Comment Comment = object of CharacterData - + PCDataSection* = ref CDataSection CDataSection = object of Text - + PProcessingInstruction* = ref ProcessingInstruction ProcessingInstruction = object of Node data*: string FTarget: string # Read-only -proc `namespaceURI=`*(n: var PNode, value: string) = +proc `namespaceURI=`*(n: var PNode, value: string) = n.FNamespaceURI = value - -proc main = + +proc main = var n: PNode new(n) n.namespaceURI = "test" diff --git a/tests/ccgbugs/tcgbug.nim b/tests/ccgbugs/tcgbug.nim index 92e7b3a66e..1c6466c877 100644 --- a/tests/ccgbugs/tcgbug.nim +++ b/tests/ccgbugs/tcgbug.nim @@ -14,7 +14,7 @@ proc p(a: PObj) = proc q(a: var PObj) = a.p() -var +var a: PObj new(a) q(a) diff --git a/tests/ccgbugs/tcodegenbug1.nim b/tests/ccgbugs/tcodegenbug1.nim index 9b97714851..a5cfc77cca 100644 --- a/tests/ccgbugs/tcodegenbug1.nim +++ b/tests/ccgbugs/tcodegenbug1.nim @@ -11,7 +11,7 @@ type status*: TStatusEnum desc*: string hash*: string - + proc initStatus*(): TStatus = result.status = sUnknown result.desc = "" @@ -49,7 +49,7 @@ proc `$`*(status: TStatusEnum): string = return "csource generation succeeded" of sUnknown: return "unknown" - + proc makeCommitPath*(platform, hash: string): string = return platform / "nim_" & hash.substr(0, 11) # 11 Chars. diff --git a/tests/closure/tclosure.nim b/tests/closure/tclosure.nim index 445a99b6d6..09d48436ea 100644 --- a/tests/closure/tclosure.nim +++ b/tests/closure/tclosure.nim @@ -41,7 +41,7 @@ type proc getInterf(): ITest = var shared: int - + return (setter: proc (x: int) = shared = x, getter: proc (): int = return shared) diff --git a/tests/closure/tclosure2.nim b/tests/closure/tclosure2.nim index d2c16eac96..d331388cf1 100644 --- a/tests/closure/tclosure2.nim +++ b/tests/closure/tclosure2.nim @@ -33,13 +33,13 @@ when true: for xxxx in 0..9: var i = 0 proc bx = - if i > 10: + if i > 10: echo xxxx return i += 1 #for j in 0 .. 0: echo i bx() - + bx() echo i @@ -50,11 +50,11 @@ when true: var x = start-1 #let dummy = proc = # discard start - - result = proc (): int = + + result = proc (): int = #var x = 9 for i in 0 .. 0: x = x + 1 - + return x var a = accumulator(3) @@ -69,7 +69,7 @@ when true: for i in 0..3: echo "py" py() - + outer() @@ -80,7 +80,7 @@ when true: if n < 0: result = errorValue elif n <= 1: result = 1 else: result = n * fac(n-1) - + proc px() {.closure.} = echo "px" @@ -93,7 +93,7 @@ when true: "xyz": py } mapping[0][1]() - + echo fac(3) diff --git a/tests/closure/tclosure3.nim b/tests/closure/tclosure3.nim index bb217387fb..8f6f4a70f7 100644 --- a/tests/closure/tclosure3.nim +++ b/tests/closure/tclosure3.nim @@ -13,7 +13,7 @@ proc main = for i in 0 .. n-1: let val = s[i]() if val != $(i*i): echo "bug ", val - + if getOccupiedMem() > 3000_000: quit("still a leak!") echo "success" diff --git a/tests/closure/tclosurebug2.nim b/tests/closure/tclosurebug2.nim index 12e4e3509a..581b735bfa 100644 --- a/tests/closure/tclosurebug2.nim +++ b/tests/closure/tclosurebug2.nim @@ -111,7 +111,7 @@ proc hasKey*[A, B](t: TOrderedTable[A, B], key: A): bool = ## returns true iff `key` is in the table `t`. result = rawGet(t, key) >= 0 -proc rawInsert[A, B](t: var TOrderedTable[A, B], +proc rawInsert[A, B](t: var TOrderedTable[A, B], data: var TOrderedKeyValuePairSeq[A, B], key: A, val: B) = rawInsertImpl() @@ -128,7 +128,7 @@ proc enlarge[A, B](t: var TOrderedTable[A, B]) = t.last = -1 while h >= 0: var nxt = t.data[h].next - if t.data[h].slot == seFilled: + if t.data[h].slot == seFilled: rawInsert(t, n, t.data[h].key, t.data[h].val) h = nxt swap(t.data, n) @@ -150,16 +150,16 @@ proc initOrderedTable*[A, B](initialSize=64): TOrderedTable[A, B] = result.last = -1 newSeq(result.data, initialSize) -proc toOrderedTable*[A, B](pairs: openarray[tuple[key: A, +proc toOrderedTable*[A, B](pairs: openarray[tuple[key: A, val: B]]): TOrderedTable[A, B] = ## creates a new ordered hash table that contains the given `pairs`. result = initOrderedTable[A, B](nextPowerOfTwo(pairs.len+10)) for key, val in items(pairs): result[key] = val -proc sort*[A, B](t: var TOrderedTable[A,B], +proc sort*[A, B](t: var TOrderedTable[A,B], cmp: proc (x, y: tuple[key: A, val: B]): int {.closure.}) = ## sorts the ordered table so that the entry with the highest counter comes - ## first. This is destructive (with the advantage of being efficient)! + ## first. This is destructive (with the advantage of being efficient)! ## You must not modify `t` afterwards! ## You can use the iterators `pairs`, `keys`, and `values` to iterate over ## `t` in the sorted order. @@ -186,7 +186,7 @@ proc sort*[A, B](t: var TOrderedTable[A,B], let item1 = (x.key, x.val) let item2 = (y.key, y.val) return cmp(item1, item2) - + while rawCmp(t.data[j-h], t.data[j]) <= 0: swap(t.data[j], t.data[j-h]) j = j-h diff --git a/tests/closure/tinterf.nim b/tests/closure/tinterf.nim index 726fac9f67..1ac6da9452 100644 --- a/tests/closure/tinterf.nim +++ b/tests/closure/tinterf.nim @@ -10,8 +10,8 @@ type proc getInterf(): ITest = var shared1, shared2: int - - return (setter: proc (x: int) = + + return (setter: proc (x: int) = shared1 = x shared2 = x + 10, getter1: proc (): int = result = shared1, diff --git a/tests/closure/tinvalidclosure2.nim b/tests/closure/tinvalidclosure2.nim index 20e465c124..8455593098 100644 --- a/tests/closure/tinvalidclosure2.nim +++ b/tests/closure/tinvalidclosure2.nim @@ -3,12 +3,12 @@ discard """ errormsg: "illegal capture 'A'" """ -proc outer() = +proc outer() = var A: int proc ugh[T](x: T) {.cdecl.} = echo "ugha", A, x - + ugh[int](12) outer() diff --git a/tests/closure/tjester.nim b/tests/closure/tjester.nim index 48e5186f03..3bd10120a3 100644 --- a/tests/closure/tjester.nim +++ b/tests/closure/tjester.nim @@ -17,7 +17,7 @@ proc cbOuter(response: string) {.closure, discardable.} = var iterVar = fooIter iterVar().data yield Future[int](data: foo()) - + var iterVar2 = cbIter proc cb2() {.closure.} = try: diff --git a/tests/closure/tnestedclosure.nim b/tests/closure/tnestedclosure.nim index c8f1e231ba..67e196f661 100644 --- a/tests/closure/tnestedclosure.nim +++ b/tests/closure/tnestedclosure.nim @@ -45,7 +45,7 @@ proc cbOuter() = proc fooIter() = echo response fooIter() - + cbIter() cbOuter() diff --git a/tests/closure/tnestedproc.nim b/tests/closure/tnestedproc.nim index 49ec6f9a7f..7eeeff1988 100644 --- a/tests/closure/tnestedproc.nim +++ b/tests/closure/tnestedproc.nim @@ -2,10 +2,10 @@ discard """ output: "11" """ -proc p(x, y: int): int = +proc p(x, y: int): int = result = x + y -echo p((proc (): int = +echo p((proc (): int = var x = 7 return x)(), (proc (): int = return 4)()) diff --git a/tests/closure/uclosures.nim b/tests/closure/uclosures.nim index 6eea29ca14..817bfec6b8 100644 --- a/tests/closure/uclosures.nim +++ b/tests/closure/uclosures.nim @@ -2,7 +2,7 @@ import unittest test "loop variables are captured by copy": var funcs: seq[proc (): int {.closure.}] = @[] - + for i in 0..10: let ii = i funcs.add do -> int: return ii * ii diff --git a/tests/cnstseq/tcnstseq.nim b/tests/cnstseq/tcnstseq.nim index e7d2333b4a..ad0527f10f 100644 --- a/tests/cnstseq/tcnstseq.nim +++ b/tests/cnstseq/tcnstseq.nim @@ -9,8 +9,8 @@ import strutils const myWords = "Angelika Anne Anna Anka Anja".split() - -for x in items(myWords): + +for x in items(myWords): write(stdout, x) #OUT AngelikaAnneAnnaAnkaAnja diff --git a/tests/cnstseq/tcnstseq2.nim b/tests/cnstseq/tcnstseq2.nim index 1a27b2ba77..2f364d2784 100644 --- a/tests/cnstseq/tcnstseq2.nim +++ b/tests/cnstseq/tcnstseq2.nim @@ -4,8 +4,8 @@ discard """ const myWords = @["Angelika", "Anne", "Anna", "Anka", "Anja"] - -for i in 0 .. high(myWords): + +for i in 0 .. high(myWords): write(stdout, myWords[i]) #OUT AngelikaAnneAnnaAnkaAnja diff --git a/tests/collections/tindexby.nim b/tests/collections/tindexby.nim index f374d5504c..88c0b263e9 100644 --- a/tests/collections/tindexby.nim +++ b/tests/collections/tindexby.nim @@ -11,11 +11,11 @@ type TElem = object foo: int bar: string - + let elem1 = TElem(foo: 1, bar: "bar") elem2 = TElem(foo: 2, bar: "baz") - + var tbl2 = initTable[string, TElem]() tbl2.add("bar", elem1) tbl2.add("baz", elem2) diff --git a/tests/collections/ttableconstr.nim b/tests/collections/ttableconstr.nim index 1a21a18d1a..a9262e70ee 100644 --- a/tests/collections/ttableconstr.nim +++ b/tests/collections/ttableconstr.nim @@ -3,7 +3,7 @@ template ignoreExpr(e: expr): stmt {.immediate.} = discard -# test first class '..' syntactical citizen: +# test first class '..' syntactical citizen: ignoreExpr x <> 2..4 # test table constructor: ignoreExpr({:}) diff --git a/tests/constr/tconstr1.nim b/tests/constr/tconstr1.nim index 45e3035547..28431287c1 100644 --- a/tests/constr/tconstr1.nim +++ b/tests/constr/tconstr1.nim @@ -3,28 +3,28 @@ discard """ line: 25 errormsg: "type mismatch" """ -# Test array, record constructors - -type - TComplexRecord = tuple[ - s: string, - x, y: int, - z: float, - chars: set[char]] - -proc testSem = - var - things: array [0..1, TComplexRecord] = [ - (s: "hi", x: 69, y: 45, z: 0.0, chars: {'a', 'b', 'c'}), - (s: "hi", x: 69, y: 45, z: 1.0, chars: {'a', 'b', 'c'})] - write(stdout, things[0].x) - -const - things: array [0..1, TComplexRecord] = [ - (s: "hi", x: 69, y: 45, z: 0.0, chars: {'a', 'b', 'c'}), - (s: "hi", x: 69, y: 45, z: 1.0)] #ERROR - otherThings = [ # the same - (s: "hi", x: 69, y: 45, z: 0.0, chars: {'a', 'b', 'c'}), - (s: "hi", x: 69, y: 45, z: 1.0, chars: {'a'})] +# Test array, record constructors + +type + TComplexRecord = tuple[ + s: string, + x, y: int, + z: float, + chars: set[char]] + +proc testSem = + var + things: array [0..1, TComplexRecord] = [ + (s: "hi", x: 69, y: 45, z: 0.0, chars: {'a', 'b', 'c'}), + (s: "hi", x: 69, y: 45, z: 1.0, chars: {'a', 'b', 'c'})] + write(stdout, things[0].x) + +const + things: array [0..1, TComplexRecord] = [ + (s: "hi", x: 69, y: 45, z: 0.0, chars: {'a', 'b', 'c'}), + (s: "hi", x: 69, y: 45, z: 1.0)] #ERROR + otherThings = [ # the same + (s: "hi", x: 69, y: 45, z: 0.0, chars: {'a', 'b', 'c'}), + (s: "hi", x: 69, y: 45, z: 1.0, chars: {'a'})] diff --git a/tests/constr/tconstr2.nim b/tests/constr/tconstr2.nim index 30cec5cb87..cd00681b88 100644 --- a/tests/constr/tconstr2.nim +++ b/tests/constr/tconstr2.nim @@ -2,25 +2,25 @@ discard """ file: "tconstr2.nim" output: "69" """ -# Test array, record constructors - -type - TComplexRecord = tuple[ - s: string, - x, y: int, - z: float, - chars: set[char]] - -const - things: array [0..1, TComplexRecord] = [ - (s: "hi", x: 69, y: 45, z: 0.0, chars: {'a', 'b', 'c'}), - (s: "hi", x: 69, y: 45, z: 1.0, chars: {})] - otherThings = [ # the same - (s: "hi", x: 69, y: 45, z: 0.0, chars: {'a', 'b', 'c'}), - (s: "hi", x: 69, y: 45, z: 1.0, chars: {'a'})] - -write(stdout, things[0].x) -#OUT 69 - +# Test array, record constructors + +type + TComplexRecord = tuple[ + s: string, + x, y: int, + z: float, + chars: set[char]] + +const + things: array [0..1, TComplexRecord] = [ + (s: "hi", x: 69, y: 45, z: 0.0, chars: {'a', 'b', 'c'}), + (s: "hi", x: 69, y: 45, z: 1.0, chars: {})] + otherThings = [ # the same + (s: "hi", x: 69, y: 45, z: 0.0, chars: {'a', 'b', 'c'}), + (s: "hi", x: 69, y: 45, z: 1.0, chars: {'a'})] + +write(stdout, things[0].x) +#OUT 69 + diff --git a/tests/constraints/tconstraints.nim b/tests/constraints/tconstraints.nim index e61095fffb..ea3f68fd46 100644 --- a/tests/constraints/tconstraints.nim +++ b/tests/constraints/tconstraints.nim @@ -3,7 +3,7 @@ discard """ errormsg: "type mismatch: got (int literal(232))" """ -proc myGenericProc[T: object|tuple|ptr|ref|distinct](x: T): string = +proc myGenericProc[T: object|tuple|ptr|ref|distinct](x: T): string = result = $x type diff --git a/tests/controlflow/tblock1.nim b/tests/controlflow/tblock1.nim index 5c41aaf821..e3a780dfe5 100644 --- a/tests/controlflow/tblock1.nim +++ b/tests/controlflow/tblock1.nim @@ -3,16 +3,16 @@ discard """ line: 14 errormsg: "undeclared identifier: \'ha\'" """ -# check for forward label and -# for failure when label is not declared - -proc main = - block endLess: - write(stdout, "Muaahh!\N") - break endLess - - break ha #ERROR - -main() +# check for forward label and +# for failure when label is not declared + +proc main = + block endLess: + write(stdout, "Muaahh!\N") + break endLess + + break ha #ERROR + +main() diff --git a/tests/controlflow/tcontinue.nim b/tests/controlflow/tcontinue.nim index 092026e8c4..ac4fdc2de2 100644 --- a/tests/controlflow/tcontinue.nim +++ b/tests/controlflow/tcontinue.nim @@ -6,7 +6,7 @@ var i = 0 while i < 400: if i == 10: break - elif i == 3: + elif i == 3: inc i continue inc i @@ -16,7 +16,7 @@ var j = 0 while j < 300: for x in 0..34: if j < 300: continue - if x == 10: + if x == 10: echo "failure: should never happen" break f = "came here" diff --git a/tests/controlflow/tnestif.nim b/tests/controlflow/tnestif.nim index bfcd8751c4..3d8adb3374 100644 --- a/tests/controlflow/tnestif.nim +++ b/tests/controlflow/tnestif.nim @@ -2,23 +2,23 @@ discard """ file: "tnestif.nim" output: "i == 2" """ -# test nested ifs - -var - x, y: int -x = 2 -if x == 0: - write(stdout, "i == 0") - if y == 0: - write(stdout, x) - else: - write(stdout, y) -elif x == 1: - write(stdout, "i == 1") -elif x == 2: - write(stdout, "i == 2") -else: - write(stdout, "looks like Python") -#OUT i == 2 +# test nested ifs + +var + x, y: int +x = 2 +if x == 0: + write(stdout, "i == 0") + if y == 0: + write(stdout, x) + else: + write(stdout, y) +elif x == 1: + write(stdout, "i == 1") +elif x == 2: + write(stdout, "i == 2") +else: + write(stdout, "looks like Python") +#OUT i == 2 diff --git a/tests/controlflow/tstatret.nim b/tests/controlflow/tstatret.nim index bf90255a01..d655f55953 100644 --- a/tests/controlflow/tstatret.nim +++ b/tests/controlflow/tstatret.nim @@ -3,10 +3,10 @@ discard """ line: 9 errormsg: "statement not allowed after" """ -# no statement after return -proc main() = - return - echo("huch?") #ERROR_MSG statement not allowed after - +# no statement after return +proc main() = + return + echo("huch?") #ERROR_MSG statement not allowed after + diff --git a/tests/converter/ttypeconverter1.nim b/tests/converter/ttypeconverter1.nim index 510b84700d..39eb6eff11 100644 --- a/tests/converter/ttypeconverter1.nim +++ b/tests/converter/ttypeconverter1.nim @@ -7,7 +7,7 @@ converter p(i: int): bool = return i != 0 if 1: echo if 4: "foo" else: "barr" -while 0: +while 0: echo "bar" var a: array[3, bool] diff --git a/tests/cpp/tthread_createthread.nim b/tests/cpp/tthread_createthread.nim index 0dc0812685..2c239005fe 100644 --- a/tests/cpp/tthread_createthread.nim +++ b/tests/cpp/tthread_createthread.nim @@ -11,4 +11,4 @@ proc main() = thread.createThread(threadMain, 0) thread.joinThreads() -main() \ No newline at end of file +main() diff --git a/tests/dir with space/tspace.nim b/tests/dir with space/tspace.nim index 8db4b52f22..2b74fa6290 100644 --- a/tests/dir with space/tspace.nim +++ b/tests/dir with space/tspace.nim @@ -1,3 +1,3 @@ # Test for the compiler to be able to compile a Nim file with spaces in it. -echo("Successful") \ No newline at end of file +echo("Successful") diff --git a/tests/discard/tdiscardable.nim b/tests/discard/tdiscardable.nim index a806ccdce6..99adcfd304 100644 --- a/tests/discard/tdiscardable.nim +++ b/tests/discard/tdiscardable.nim @@ -1,10 +1,10 @@ # Test the discardable pragma -proc p(x, y: int): int {.discardable.} = +proc p(x, y: int): int {.discardable.} = return x + y # test that it is inherited from generic procs too: -proc q[T](x, y: T): T {.discardable.} = +proc q[T](x, y: T): T {.discardable.} = return x + y diff --git a/tests/discard/tneedsdiscard.nim b/tests/discard/tneedsdiscard.nim index 2a7856b4aa..2df3531e73 100644 --- a/tests/discard/tneedsdiscard.nim +++ b/tests/discard/tneedsdiscard.nim @@ -6,7 +6,7 @@ discard """ proc p = var f: TFile echo "hi" - + open(f, "arg.txt") - + p() diff --git a/tests/distinct/tcurrncy.nim b/tests/distinct/tcurrncy.nim index 78dbc2a891..7ad4caea46 100644 --- a/tests/distinct/tcurrncy.nim +++ b/tests/distinct/tcurrncy.nim @@ -5,7 +5,7 @@ discard """ template Additive(typ: typeDesc): stmt = proc `+` *(x, y: typ): typ {.borrow.} proc `-` *(x, y: typ): typ {.borrow.} - + # unary operators: proc `+` *(x: typ): typ {.borrow.} proc `-` *(x: typ): typ {.borrow.} @@ -27,7 +27,7 @@ template DefineCurrency(typ, base: expr): stmt {.immediate.} = Additive(typ) Multiplicative(typ, base) Comparable(typ) - + proc `$` * (t: typ): string {.borrow.} DefineCurrency(TDollar, int) diff --git a/tests/dll/client.nim b/tests/dll/client.nim index d535e8750f..150af3a174 100644 --- a/tests/dll/client.nim +++ b/tests/dll/client.nim @@ -22,8 +22,8 @@ else: proc newLit(x: int): PNode {.importc: "newLit", dynlib: dllname.} proc newOp(k: TNodeKind, a, b: PNode): PNode {. - importc: "newOp", dynlib: dllname.} -proc buildTree(x: int): PNode {.importc: "buildTree", dynlib: dllname.} + importc: "newOp", dynlib: dllname.} +proc buildTree(x: int): PNode {.importc: "buildTree", dynlib: dllname.} proc eval(n: PNode): int = case n.k @@ -36,6 +36,6 @@ proc eval(n: PNode): int = # Test the GC: for i in 0..100_000: discard eval(buildTree(2)) - + echo "Done" diff --git a/tests/dll/server.nim b/tests/dll/server.nim index df32234446..e6b80df882 100644 --- a/tests/dll/server.nim +++ b/tests/dll/server.nim @@ -10,11 +10,11 @@ type else: a, b: ref TNode PNode = ref TNode - + proc newLit(x: int): PNode {.exportc: "newLit", dynlib.} = new(result) result.x = x - + proc newOp(k: TNodeKind, a, b: PNode): PNode {.exportc: "newOp", dynlib.} = assert a != nil assert b != nil @@ -22,13 +22,13 @@ proc newOp(k: TNodeKind, a, b: PNode): PNode {.exportc: "newOp", dynlib.} = result.k = k result.a = a result.b = b - -proc buildTree(x: int): PNode {.exportc: "buildTree", dynlib.} = + +proc buildTree(x: int): PNode {.exportc: "buildTree", dynlib.} = result = newOp(nkMul, newOp(nkAdd, newLit(x), newLit(x)), newLit(x)) when false: # Test the GC: for i in 0..100_000: discard buildTree(2) - + echo "Done" diff --git a/tests/effects/teffects1.nim b/tests/effects/teffects1.nim index fad26a8d6f..ef76c9130b 100644 --- a/tests/effects/teffects1.nim +++ b/tests/effects/teffects1.nim @@ -7,11 +7,11 @@ type TObj = object {.pure, inheritable.} TObjB = object of TObj a, b, c: string - + IO2Error = ref object of IOError - + proc forw: int {. .} - + proc lier(): int {.raises: [IO2Error].} = writeLine stdout, "arg" diff --git a/tests/effects/teffects2.nim b/tests/effects/teffects2.nim index a97eacca6c..0fa789869e 100644 --- a/tests/effects/teffects2.nim +++ b/tests/effects/teffects2.nim @@ -7,9 +7,9 @@ type TObj = object {.pure, inheritable.} TObjB = object of TObj a, b, c: string - + EIO2 = ref object of IOError - + proc forw: int {.raises: [].} proc lier(): int {.raises: [IOError].} = diff --git a/tests/effects/teffects3.nim b/tests/effects/teffects3.nim index 3d597560f4..1b18f7b6d4 100644 --- a/tests/effects/teffects3.nim +++ b/tests/effects/teffects3.nim @@ -8,9 +8,9 @@ type TObjB = object of TObj a, b, c: string fn: proc (): int {.tags: [].} - + EIO2 = ref object of EIO - + proc raiser(): int {.tags: [TObj, FWriteIO].} = writeLine stdout, "arg" diff --git a/tests/effects/teffects4.nim b/tests/effects/teffects4.nim index e2aa440a93..fd5dd49e24 100644 --- a/tests/effects/teffects4.nim +++ b/tests/effects/teffects4.nim @@ -8,12 +8,12 @@ type TObjB = object of TObj a, b, c: string fn: proc (): int {.tags: [FReadIO].} - + EIO2 = ref object of EIO proc q() {.tags: [FIO].} = nil - + proc raiser(): int = writeLine stdout, "arg" if true: diff --git a/tests/effects/teffects5.nim b/tests/effects/teffects5.nim index d630a6fc4b..779b4662c7 100644 --- a/tests/effects/teffects5.nim +++ b/tests/effects/teffects5.nim @@ -6,7 +6,7 @@ discard """ proc p(q: proc() ): proc() {.tags: [], raises: [], closure.} = return proc () = q() - + let yay = p(proc () = raise newException(EIO, "IO")) proc main() {.raises: [], tags: [].} = yay() diff --git a/tests/effects/teffects6.nim b/tests/effects/teffects6.nim index 47c85c160b..e69fe73b66 100644 --- a/tests/effects/teffects6.nim +++ b/tests/effects/teffects6.nim @@ -3,7 +3,7 @@ type PMenu = ref object PMenuItem = ref object -proc createMenuItem*(menu: PMenu, label: string, +proc createMenuItem*(menu: PMenu, label: string, action: proc (i: PMenuItem, p: pointer) {.cdecl.}) = discard var s: PMenu @@ -19,7 +19,7 @@ createMenuItem(s, "Go to definition...", proc noRaise(x: proc()) {.raises: [].} = # unknown call that might raise anything, but valid: x() - + proc doRaise() {.raises: [EIO].} = raise newException(EIO, "IO") diff --git a/tests/effects/tsidee1.nim b/tests/effects/tsidee1.nim index bd5b32dd75..e486d32e7f 100644 --- a/tests/effects/tsidee1.nim +++ b/tests/effects/tsidee1.nim @@ -11,8 +11,8 @@ proc dontcare(x: int): int = return x + global proc SideEffectLyer(x, y: int): int {.noSideEffect.} = #ERROR_MSG 'SideEffectLyer' can have side effects return x + y + dontcare(x) - -echo SideEffectLyer(1, 3) + +echo SideEffectLyer(1, 3) diff --git a/tests/effects/tsidee2.nim b/tests/effects/tsidee2.nim index e73c896080..5ed541300a 100644 --- a/tests/effects/tsidee2.nim +++ b/tests/effects/tsidee2.nim @@ -8,9 +8,9 @@ var proc dontcare(x: int): int = return x -proc SideEffectLyer(x, y: int): int {.noSideEffect.} = +proc SideEffectLyer(x, y: int): int {.noSideEffect.} = return x + y + dontcare(x) - + echo SideEffectLyer(1, 3) #OUT 5 diff --git a/tests/effects/tsidee3.nim b/tests/effects/tsidee3.nim index e0c427ab6c..e15fbc3d15 100644 --- a/tests/effects/tsidee3.nim +++ b/tests/effects/tsidee3.nim @@ -8,9 +8,9 @@ var proc dontcare(x: int): int {.noSideEffect.} = return x -proc noSideEffect(x, y: int, p: proc (a: int): int {.noSideEffect.}): int {.noSideEffect.} = +proc noSideEffect(x, y: int, p: proc (a: int): int {.noSideEffect.}): int {.noSideEffect.} = return x + y + dontcare(x) - + echo noSideEffect(1, 3, dontcare) #OUT 5 diff --git a/tests/effects/tsidee4.nim b/tests/effects/tsidee4.nim index cbebfbd369..2cb88a23ee 100644 --- a/tests/effects/tsidee4.nim +++ b/tests/effects/tsidee4.nim @@ -9,9 +9,9 @@ var proc dontcare(x: int): int = return x -proc noSideEffect(x, y: int, p: proc (a: int): int {.noSideEffect.}): int {.noSideEffect.} = +proc noSideEffect(x, y: int, p: proc (a: int): int {.noSideEffect.}): int {.noSideEffect.} = return x + y + dontcare(x) - + echo noSideEffect(1, 3, dontcare) #ERROR_MSG type mismatch diff --git a/tests/enum/tenum.nim b/tests/enum/tenum.nim index 6e53b9c083..b081212e64 100644 --- a/tests/enum/tenum.nim +++ b/tests/enum/tenum.nim @@ -1,8 +1,8 @@ -# Test enums - -type - E = enum a, b, c, x, y, z - -var - en: E -en = a +# Test enums + +type + E = enum a, b, c, x, y, z + +var + en: E +en = a diff --git a/tests/enum/tenum2.nim b/tests/enum/tenum2.nim index feba36dd69..3e34a21ce9 100644 --- a/tests/enum/tenum2.nim +++ b/tests/enum/tenum2.nim @@ -1,14 +1,14 @@ # Test that enum with holes is handled correctly by case statement type - TEnumHole = enum + TEnumHole = enum eA = 0, eB = 4, eC = 5 - + var e: TEnumHole = eB - + case e of eA: echo "A" of eB: echo "B" diff --git a/tests/enum/tenum3.nim b/tests/enum/tenum3.nim index 09a516932f..49cbf04d59 100644 --- a/tests/enum/tenum3.nim +++ b/tests/enum/tenum3.nim @@ -1,14 +1,14 @@ # Test enum with explicit size type - TEnumHole {.size: sizeof(int).} = enum + TEnumHole {.size: sizeof(int).} = enum eA = 0, eB = 4, eC = 5 - + var e: TEnumHole = eB - + case e of eA: echo "A" of eB: echo "B" diff --git a/tests/enum/tenumhole.nim b/tests/enum/tenumhole.nim index a355263783..68b82e283e 100644 --- a/tests/enum/tenumhole.nim +++ b/tests/enum/tenumhole.nim @@ -12,10 +12,10 @@ type valueB = strValB & "conc", valueC, valueD = (4, "abc") - + # test the new "proc body can be an expr" feature: proc getValue: TMyEnum = valueD - + # trick the optimizer with a variable: var x = getValue() echo valueA, ord(valueA), valueB, ord(valueB), valueC, valueD, ord(valueD), x diff --git a/tests/enum/tenummix.nim b/tests/enum/tenummix.nim index aaf0be2cb4..4352cdd813 100644 --- a/tests/enum/tenummix.nim +++ b/tests/enum/tenummix.nim @@ -7,5 +7,5 @@ discard """ type TE1 = enum eA, eB TE2 = enum eC, eD - + assert eA != eC diff --git a/tests/enum/toptions.nim b/tests/enum/toptions.nim index 3c841de2c1..e53acb2b35 100644 --- a/tests/enum/toptions.nim +++ b/tests/enum/toptions.nim @@ -1,18 +1,18 @@ - -type - # please make sure we have under 32 options (improves code efficiency!) - TOption = enum - optNone, optForceFullMake, optBoehmGC, optRefcGC, optRangeCheck, - optBoundsCheck, optOverflowCheck, optNilCheck, optAssert, optLineDir, - optWarns, optHints, optDeadCodeElim, optListCmd, optCompileOnly, - optSafeCode, # only allow safe code - optStyleCheck, optOptimizeSpeed, optOptimizeSize, optGenDynLib, - optGenGuiApp, optStackTrace - - TOptionset = set[TOption] - -var - gOptions: TOptionset = {optRefcGC, optRangeCheck, optBoundsCheck, - optOverflowCheck, optAssert, optWarns, optHints, optLineDir, optStackTrace} - compilerArgs: int - gExitcode: int8 + +type + # please make sure we have under 32 options (improves code efficiency!) + TOption = enum + optNone, optForceFullMake, optBoehmGC, optRefcGC, optRangeCheck, + optBoundsCheck, optOverflowCheck, optNilCheck, optAssert, optLineDir, + optWarns, optHints, optDeadCodeElim, optListCmd, optCompileOnly, + optSafeCode, # only allow safe code + optStyleCheck, optOptimizeSpeed, optOptimizeSize, optGenDynLib, + optGenGuiApp, optStackTrace + + TOptionset = set[TOption] + +var + gOptions: TOptionset = {optRefcGC, optRangeCheck, optBoundsCheck, + optOverflowCheck, optAssert, optWarns, optHints, optLineDir, optStackTrace} + compilerArgs: int + gExitcode: int8 diff --git a/tests/exception/tcontinuexc.nim b/tests/exception/tcontinuexc.nim index f618abc14a..fb9b523d73 100644 --- a/tests/exception/tcontinuexc.nim +++ b/tests/exception/tcontinuexc.nim @@ -21,7 +21,7 @@ try: stdout.write("E") stdout.write("C") raise newException(EsomeotherErr, "bla") -finally: +finally: echo "caught" #OUT ECcaught diff --git a/tests/exception/tfinally.nim b/tests/exception/tfinally.nim index 16fb3e7da1..aa469d9c03 100644 --- a/tests/exception/tfinally.nim +++ b/tests/exception/tfinally.nim @@ -4,14 +4,14 @@ discard """ """ # Test return in try statement: -proc main: int = +proc main: int = try: try: return 1 finally: echo("came") return 2 - finally: + finally: echo("here") return 3 diff --git a/tests/exception/tfinally2.nim b/tests/exception/tfinally2.nim index e1e8d4c7ee..f1acf2774c 100644 --- a/tests/exception/tfinally2.nim +++ b/tests/exception/tfinally2.nim @@ -7,7 +7,7 @@ D''' """ # Test break in try statement: -proc main: int = +proc main: int = try: block AB: try: @@ -16,14 +16,14 @@ proc main: int = finally: echo("A") echo("skipped") - finally: + finally: block B: echo("B") echo("skipped") echo("C") finally: echo("D") - + discard main() #OUT ABCD diff --git a/tests/exception/tfinally3.nim b/tests/exception/tfinally3.nim index e65661cd02..8bccd1a7f8 100644 --- a/tests/exception/tfinally3.nim +++ b/tests/exception/tfinally3.nim @@ -4,7 +4,7 @@ discard """ """ # Test break in try statement: -proc main: bool = +proc main: bool = while true: try: return true diff --git a/tests/exception/tnestedreturn2.nim b/tests/exception/tnestedreturn2.nim index 4bd2d535d9..79523a8835 100644 --- a/tests/exception/tnestedreturn2.nim +++ b/tests/exception/tnestedreturn2.nim @@ -14,7 +14,7 @@ proc test4() = discard # Should cause unhandled exception error, -# but could cause segmentation fault if +# but could cause segmentation fault if # exceptions are not handled properly. test4() raise newException(OSError, "Problem") diff --git a/tests/exception/tunhandledexc.nim b/tests/exception/tunhandledexc.nim index aa9d61236b..63a402414d 100644 --- a/tests/exception/tunhandledexc.nim +++ b/tests/exception/tunhandledexc.nim @@ -18,6 +18,6 @@ when true: genErrors("errssor!") except ESomething: echo("Error happened") - + diff --git a/tests/exception/twrongexc.nim b/tests/exception/twrongexc.nim index 4e921b8a39..b224d4c835 100644 --- a/tests/exception/twrongexc.nim +++ b/tests/exception/twrongexc.nim @@ -7,7 +7,7 @@ try: raise newException(ValueError, "") except OverflowError: echo("Error caught") - + diff --git a/tests/exprs/tstmtexprs.nim b/tests/exprs/tstmtexprs.nim index d6b827b6d2..b2d5db4087 100644 --- a/tests/exprs/tstmtexprs.nim +++ b/tests/exprs/tstmtexprs.nim @@ -26,16 +26,16 @@ when true: result.bar = "bar" echo($newfoo()) - - proc retInt(x, y: int): int = + + proc retInt(x, y: int): int = if (var yy = 0; yy != 0): echo yy else: echo(try: parseInt("1244") except EINvalidValue: -1) result = case x of 23: 3 - of 64: + of 64: case y of 1: 2 of 2: 3 @@ -79,7 +79,7 @@ semiProblem() # bug #844 -import json +import json proc parseResponse(): PJsonNode = result = % { "key1": % { "key2": % "value" } } for key, val in result["key1"]: diff --git a/tests/fields/tfieldindex.nim b/tests/fields/tfieldindex.nim index f0674af541..d11c1a8b27 100644 --- a/tests/fields/tfieldindex.nim +++ b/tests/fields/tfieldindex.nim @@ -14,7 +14,7 @@ proc indexOf*(t: typedesc, name: string): int = for n, x in fieldPairs(d): if n == name: return i i.inc - raise newException(EInvalidValue, "No field " & name & " in type " & + raise newException(EInvalidValue, "No field " & name & " in type " & astToStr(t)) echo TMyTuple.indexOf("b") diff --git a/tests/fields/tfielditerator.nim b/tests/fields/tfielditerator.nim index 2919aab411..6d15ea05d9 100644 --- a/tests/fields/tfielditerator.nim +++ b/tests/fields/tfielditerator.nim @@ -28,7 +28,7 @@ proc p(x: string) = echo "a string: ", x var x: TMyTuple = ('a', 'b', 5, 6, "abc") var y: TMyTuple = ('A', 'b', 5, 9, "abc") -for f in fields(x): +for f in fields(x): p f for a, b in fields(x, y): diff --git a/tests/fields/tfielditerator2.nim b/tests/fields/tfielditerator2.nim index 70ab9e2abf..c8e230cf51 100644 --- a/tests/fields/tfielditerator2.nim +++ b/tests/fields/tfielditerator2.nim @@ -32,7 +32,7 @@ type a, b: char x, y: int z: string - + TEnum = enum enA, enB, enC TMyCaseObj = object case myDisc: TEnum @@ -51,7 +51,7 @@ proc myobj(a, b: char, x, y: int, z: string): TMyObj = var x = myobj('a', 'b', 5, 6, "abc") var y = myobj('A', 'b', 5, 9, "abc") -for f in fields(x): +for f in fields(x): p f for a, b in fields(x, y): diff --git a/tests/float/tfloat3.nim b/tests/float/tfloat3.nim index a3f5a2fc75..a14c6c3960 100644 --- a/tests/float/tfloat3.nim +++ b/tests/float/tfloat3.nim @@ -8,7 +8,7 @@ import math, strutils {.emit: """ void printFloats(void) { double y = 1.234567890123456789; - + printf("C double: %.10f, %.10f ", exp(y), cos(y)); } """.} diff --git a/tests/friends/mfriends.nim b/tests/friends/mfriends.nim index f1c6636551..19672289ef 100644 --- a/tests/friends/mfriends.nim +++ b/tests/friends/mfriends.nim @@ -1,9 +1,9 @@ type - TMyObj = object + TMyObj = object x: int - -proc gen*[T](): T = + +proc gen*[T](): T = var d: TMyObj # access private field here d.x = 3 diff --git a/tests/gc/closureleak.nim b/tests/gc/closureleak.nim index 1c39f43d59..18d320bdf0 100644 --- a/tests/gc/closureleak.nim +++ b/tests/gc/closureleak.nim @@ -16,7 +16,7 @@ proc free*(some: ref TFoo) = alive_foos.del alive_foos.find(some.id) proc newFoo*(): ref TFoo = new result, free - + result.id = foo_counter alive_foos.add result.id inc foo_counter @@ -26,7 +26,7 @@ for i in 0 .. <10: for i in 0 .. <10: let f = newFoo() - f.fn = proc = + f.fn = proc = echo f.id GC_fullcollect() diff --git a/tests/gc/gcbench.nim b/tests/gc/gcbench.nim index 44d952baa4..72337911df 100644 --- a/tests/gc/gcbench.nim +++ b/tests/gc/gcbench.nim @@ -1,168 +1,168 @@ -discard """ - outputsub: "Success!" -""" - -# This is adapted from a benchmark written by John Ellis and Pete Kovac -# of Post Communications. -# It was modified by Hans Boehm of Silicon Graphics. -# -# This is no substitute for real applications. No actual application -# is likely to behave in exactly this way. However, this benchmark was -# designed to be more representative of real applications than other -# Java GC benchmarks of which we are aware. -# It attempts to model those properties of allocation requests that -# are important to current GC techniques. -# It is designed to be used either to obtain a single overall performance -# number, or to give a more detailed estimate of how collector -# performance varies with object lifetimes. It prints the time -# required to allocate and collect balanced binary trees of various -# sizes. Smaller trees result in shorter object lifetimes. Each cycle -# allocates roughly the same amount of memory. -# Two data structures are kept around during the entire process, so -# that the measured performance is representative of applications -# that maintain some live in-memory data. One of these is a tree -# containing many pointers. The other is a large array containing -# double precision floating point numbers. Both should be of comparable -# size. -# -# The results are only really meaningful together with a specification -# of how much memory was used. It is possible to trade memory for -# better time performance. This benchmark should be run in a 32 MB -# heap, though we don't currently know how to enforce that uniformly. -# -# Unlike the original Ellis and Kovac benchmark, we do not attempt -# measure pause times. This facility should eventually be added back -# in. There are several reasons for omitting it for now. The original -# implementation depended on assumptions about the thread scheduler -# that don't hold uniformly. The results really measure both the -# scheduler and GC. Pause time measurements tend to not fit well with -# current benchmark suites. As far as we know, none of the current -# commercial Java implementations seriously attempt to minimize GC pause -# times. -# -# Known deficiencies: -# - No way to check on memory use -# - No cyclic data structures -# - No attempt to measure variation with object size -# - Results are sensitive to locking cost, but we dont -# check for proper locking -# - -import - strutils, times - -type - PNode = ref TNode - TNode {.final.} = object - left, right: PNode - i, j: int - -proc newNode(L, r: PNode): PNode = - new(result) - result.left = L - result.right = r - -const - kStretchTreeDepth = 18 # about 16Mb - kLongLivedTreeDepth = 16 # about 4Mb - kArraySize = 500000 # about 4Mb - kMinTreeDepth = 4 - kMaxTreeDepth = 16 - -# Nodes used by a tree of a given size -proc TreeSize(i: int): int = return ((1 shl (i + 1)) - 1) - -# Number of iterations to use for a given tree depth -proc NumIters(i: int): int = - return 2 * TreeSize(kStretchTreeDepth) div TreeSize(i) - -# Build tree top down, assigning to older objects. -proc Populate(iDepth: int, thisNode: PNode) = - if iDepth <= 0: - return - else: - new(thisNode.left) - new(thisNode.right) - Populate(iDepth-1, thisNode.left) - Populate(iDepth-1, thisNode.right) - -# Build tree bottom-up -proc MakeTree(iDepth: int): PNode = - if iDepth <= 0: - new(result) - else: - return newNode(MakeTree(iDepth-1), MakeTree(iDepth-1)) - -proc PrintDiagnostics() = - echo("Total memory available: " & $getTotalMem() & " bytes") - echo("Free memory: " & $getFreeMem() & " bytes") - -proc TimeConstruction(depth: int) = - var - root, tempTree: PNode - iNumIters: int - - iNumIters = NumIters(depth) - - echo("Creating " & $iNumIters & " trees of depth " & $depth) - var t = epochTime() - for i in 0..iNumIters-1: - new(tempTree) - Populate(depth, tempTree) - tempTree = nil - echo("\tTop down construction took " & $(epochTime() - t) & "msecs") - t = epochTime() - for i in 0..iNumIters-1: - tempTree = MakeTree(depth) - tempTree = nil - echo("\tBottom up construction took " & $(epochTime() - t) & "msecs") - -type - tMyArray = seq[float] - -proc main() = - var - root, longLivedTree, tempTree: PNode - myarray: tMyArray - - echo("Garbage Collector Test") - echo(" Stretching memory with a binary tree of depth " & $kStretchTreeDepth) - PrintDiagnostics() - var t = epochTime() - - # Stretch the memory space quickly - tempTree = MakeTree(kStretchTreeDepth) - tempTree = nil - - # Create a long lived object - echo(" Creating a long-lived binary tree of depth " & - $kLongLivedTreeDepth) - new(longLivedTree) - Populate(kLongLivedTreeDepth, longLivedTree) - - # Create long-lived array, filling half of it - echo(" Creating a long-lived array of " & $kArraySize & " doubles") - newSeq(myarray, kArraySize) - for i in 0..kArraySize div 2 -1: - myarray[i] = 1.0 / toFloat(i) - - PrintDiagnostics() - - var d = kMinTreeDepth - while d <= kMaxTreeDepth: - TimeConstruction(d) - inc(d, 2) - - if longLivedTree == nil or myarray[1000] != 1.0/1000.0: - echo("Failed") - # fake reference to LongLivedTree - # and array to keep them from being optimized away - - var elapsed = epochTime() - t - PrintDiagnostics() - echo("Completed in " & $elapsed & "ms. Success!") +discard """ + outputsub: "Success!" +""" + +# This is adapted from a benchmark written by John Ellis and Pete Kovac +# of Post Communications. +# It was modified by Hans Boehm of Silicon Graphics. +# +# This is no substitute for real applications. No actual application +# is likely to behave in exactly this way. However, this benchmark was +# designed to be more representative of real applications than other +# Java GC benchmarks of which we are aware. +# It attempts to model those properties of allocation requests that +# are important to current GC techniques. +# It is designed to be used either to obtain a single overall performance +# number, or to give a more detailed estimate of how collector +# performance varies with object lifetimes. It prints the time +# required to allocate and collect balanced binary trees of various +# sizes. Smaller trees result in shorter object lifetimes. Each cycle +# allocates roughly the same amount of memory. +# Two data structures are kept around during the entire process, so +# that the measured performance is representative of applications +# that maintain some live in-memory data. One of these is a tree +# containing many pointers. The other is a large array containing +# double precision floating point numbers. Both should be of comparable +# size. +# +# The results are only really meaningful together with a specification +# of how much memory was used. It is possible to trade memory for +# better time performance. This benchmark should be run in a 32 MB +# heap, though we don't currently know how to enforce that uniformly. +# +# Unlike the original Ellis and Kovac benchmark, we do not attempt +# measure pause times. This facility should eventually be added back +# in. There are several reasons for omitting it for now. The original +# implementation depended on assumptions about the thread scheduler +# that don't hold uniformly. The results really measure both the +# scheduler and GC. Pause time measurements tend to not fit well with +# current benchmark suites. As far as we know, none of the current +# commercial Java implementations seriously attempt to minimize GC pause +# times. +# +# Known deficiencies: +# - No way to check on memory use +# - No cyclic data structures +# - No attempt to measure variation with object size +# - Results are sensitive to locking cost, but we dont +# check for proper locking +# + +import + strutils, times + +type + PNode = ref TNode + TNode {.final.} = object + left, right: PNode + i, j: int + +proc newNode(L, r: PNode): PNode = + new(result) + result.left = L + result.right = r + +const + kStretchTreeDepth = 18 # about 16Mb + kLongLivedTreeDepth = 16 # about 4Mb + kArraySize = 500000 # about 4Mb + kMinTreeDepth = 4 + kMaxTreeDepth = 16 + +# Nodes used by a tree of a given size +proc TreeSize(i: int): int = return ((1 shl (i + 1)) - 1) + +# Number of iterations to use for a given tree depth +proc NumIters(i: int): int = + return 2 * TreeSize(kStretchTreeDepth) div TreeSize(i) + +# Build tree top down, assigning to older objects. +proc Populate(iDepth: int, thisNode: PNode) = + if iDepth <= 0: + return + else: + new(thisNode.left) + new(thisNode.right) + Populate(iDepth-1, thisNode.left) + Populate(iDepth-1, thisNode.right) + +# Build tree bottom-up +proc MakeTree(iDepth: int): PNode = + if iDepth <= 0: + new(result) + else: + return newNode(MakeTree(iDepth-1), MakeTree(iDepth-1)) + +proc PrintDiagnostics() = + echo("Total memory available: " & $getTotalMem() & " bytes") + echo("Free memory: " & $getFreeMem() & " bytes") + +proc TimeConstruction(depth: int) = + var + root, tempTree: PNode + iNumIters: int + + iNumIters = NumIters(depth) + + echo("Creating " & $iNumIters & " trees of depth " & $depth) + var t = epochTime() + for i in 0..iNumIters-1: + new(tempTree) + Populate(depth, tempTree) + tempTree = nil + echo("\tTop down construction took " & $(epochTime() - t) & "msecs") + t = epochTime() + for i in 0..iNumIters-1: + tempTree = MakeTree(depth) + tempTree = nil + echo("\tBottom up construction took " & $(epochTime() - t) & "msecs") + +type + tMyArray = seq[float] + +proc main() = + var + root, longLivedTree, tempTree: PNode + myarray: tMyArray + + echo("Garbage Collector Test") + echo(" Stretching memory with a binary tree of depth " & $kStretchTreeDepth) + PrintDiagnostics() + var t = epochTime() + + # Stretch the memory space quickly + tempTree = MakeTree(kStretchTreeDepth) + tempTree = nil + + # Create a long lived object + echo(" Creating a long-lived binary tree of depth " & + $kLongLivedTreeDepth) + new(longLivedTree) + Populate(kLongLivedTreeDepth, longLivedTree) + + # Create long-lived array, filling half of it + echo(" Creating a long-lived array of " & $kArraySize & " doubles") + newSeq(myarray, kArraySize) + for i in 0..kArraySize div 2 -1: + myarray[i] = 1.0 / toFloat(i) + + PrintDiagnostics() + + var d = kMinTreeDepth + while d <= kMaxTreeDepth: + TimeConstruction(d) + inc(d, 2) + + if longLivedTree == nil or myarray[1000] != 1.0/1000.0: + echo("Failed") + # fake reference to LongLivedTree + # and array to keep them from being optimized away + + var elapsed = epochTime() - t + PrintDiagnostics() + echo("Completed in " & $elapsed & "ms. Success!") when defined(GC_setMaxPause): GC_setMaxPause 2_000 - -main() + +main() diff --git a/tests/gc/gcleak2.nim b/tests/gc/gcleak2.nim index 41d149bed1..1014216836 100644 --- a/tests/gc/gcleak2.nim +++ b/tests/gc/gcleak2.nim @@ -14,7 +14,7 @@ proc MakeObj(): TTestObj = result.x = "Hello" result.s = @[1,2,3] -proc inProc() = +proc inProc() = for i in 1 .. 1_000_000: when defined(gcMarkAndSweep): GC_fullcollect() diff --git a/tests/gc/gcleak4.nim b/tests/gc/gcleak4.nim index 54e74ac7b9..d93a13854e 100644 --- a/tests/gc/gcleak4.nim +++ b/tests/gc/gcleak4.nim @@ -14,7 +14,7 @@ type TPlusExpr = object of TExpr a, b: ref TExpr op2: string - + method eval(e: ref TExpr): int = # override this base method quit "to override!" @@ -30,7 +30,7 @@ proc newLit(x: int): ref TLiteral = {.watchpoint: result.} result.x = x result.op1 = $getOccupiedMem() - + proc newPlus(a, b: ref TExpr): ref TPlusExpr = new(result) {.watchpoint: result.} diff --git a/tests/gc/gcleak5.nim b/tests/gc/gcleak5.nim index 9e2948729e..6ab50e19e9 100644 --- a/tests/gc/gcleak5.nim +++ b/tests/gc/gcleak5.nim @@ -11,12 +11,12 @@ proc main = var t = getTime() var g = t.getGMTime() #echo isOnStack(addr g) - + if i mod 100 == 0: let om = getOccupiedMem() #echo "memory: ", om if om > 100_000: quit "leak" - + inc(i) sleep(1) diff --git a/tests/gc/refarrayleak.nim b/tests/gc/refarrayleak.nim index 12c9145f8c..57b489721a 100644 --- a/tests/gc/refarrayleak.nim +++ b/tests/gc/refarrayleak.nim @@ -28,7 +28,7 @@ proc newArrayHolder: ref TArrayHolder = proc loop = for i in 0..10000: discard newArrayHolder() - + if getOccupiedMem() > 300_000: echo "still a leak! ", getOccupiedMem() quit 1 diff --git a/tests/generics/t1056.nim b/tests/generics/t1056.nim index b1fe258943..de8bde8efb 100644 --- a/tests/generics/t1056.nim +++ b/tests/generics/t1056.nim @@ -17,7 +17,7 @@ proc echoMatrix(a: TMatrix) = proc echoMat2(a: TMat2) = echo TMat2.M - + var m = TMatrix[3,3,int](data: [1,2,3,4,5,6,7,8,9]) echoMatrix m diff --git a/tests/generics/t1789.nim b/tests/generics/t1789.nim index 188db88f6b..c3fe336af9 100644 --- a/tests/generics/t1789.nim +++ b/tests/generics/t1789.nim @@ -38,7 +38,7 @@ type proc `[]`*[N, T](f: Bar[N, T], n: range[0..(N - 1)]): T = assert high(n) == N-1 result = f.bar[n] - + var b: Bar[3, int] echo b[2] diff --git a/tests/generics/tconfusing_arrow.nim b/tests/generics/tconfusing_arrow.nim index 6a5a9d6824..f63a874e00 100644 --- a/tests/generics/tconfusing_arrow.nim +++ b/tests/generics/tconfusing_arrow.nim @@ -5,7 +5,7 @@ type Deck = object proc sort(h: var seq[Deck]) = # works: - h.sort(proc (x, y: Deck): auto = + h.sort(proc (x, y: Deck): auto = cmp(x.value, y.value)) # fails: h.sort((x, y: Deck) => cmp(ord(x.value), ord(y.value))) diff --git a/tests/generics/tdictdestruct.nim b/tests/generics/tdictdestruct.nim index 17ded4853d..228d93e66b 100644 --- a/tests/generics/tdictdestruct.nim +++ b/tests/generics/tdictdestruct.nim @@ -13,8 +13,8 @@ proc destroyDict[TK, TV](a: PDict[TK, TV]) = proc newDict[TK, TV](a: TK, b: TV): PDict[TK, TV] = fakeNew(result, destroyDict[TK, TV]) -# Problem: destroyDict is not instantiated when newDict is instantiated! +# Problem: destroyDict is not instantiated when newDict is instantiated! -discard newDict("a", "b") +discard newDict("a", "b") diff --git a/tests/generics/texplicitgeneric1.nim b/tests/generics/texplicitgeneric1.nim index d54044368c..ac0197c1a0 100644 --- a/tests/generics/texplicitgeneric1.nim +++ b/tests/generics/texplicitgeneric1.nim @@ -5,33 +5,33 @@ discard """ # test explicit type instantiation type - TDict*[TKey, TValue] = object + TDict*[TKey, TValue] = object data: seq[tuple[k: TKey, v: TValue]] PDict*[TKey, #with `==`(a, b: TKey): bool - # hash(a: TKey): int, + # hash(a: TKey): int, TValue] = ref TDict[TKey, TValue] - -proc newDict*[TKey, TValue](): PDict[TKey, TValue] = + +proc newDict*[TKey, TValue](): PDict[TKey, TValue] = new(result) result.data = @[] - -proc add*[TKey, TValue](d: PDict[TKey, TValue], k: TKey, v: TValue) = + +proc add*[TKey, TValue](d: PDict[TKey, TValue], k: TKey, v: TValue) = d.data.add((k, v)) - -iterator items*[Tkey, TValue](d: PDict[TKey, TValue]): tuple[k: TKey, - v: TValue] = + +iterator items*[Tkey, TValue](d: PDict[TKey, TValue]): tuple[k: TKey, + v: TValue] = for k, v in items(d.data): yield (k, v) - + var d = newDict[int, string]() d.add(12, "12") d.add(13, "13") -for k, v in items(d): +for k, v in items(d): stdout.write("Key: ", $k, " value: ", v) var c = newDict[char, string]() c.add('A', "12") c.add('B', "13") -for k, v in items(c): +for k, v in items(c): stdout.write(" Key: ", $k, " value: ", v) diff --git a/tests/generics/texplicitgeneric2.nim b/tests/generics/texplicitgeneric2.nim index 95461d0236..c4af17b7b8 100644 --- a/tests/generics/texplicitgeneric2.nim +++ b/tests/generics/texplicitgeneric2.nim @@ -6,30 +6,30 @@ discard """ # test explicit type instantiation type - TDict*[TKey, TValue] = object + TDict*[TKey, TValue] = object data: seq[tuple[k: TKey, v: TValue]] PDict*[TKey, TValue] = ref TDict[TKey, TValue] - -proc newDict*[TKey, TValue](): PDict[TKey, TValue] = + +proc newDict*[TKey, TValue](): PDict[TKey, TValue] = new(result) result.data = @[] - -proc add*(d: PDict, k: TKey, v: TValue) = - d.data.add((k, v)) - -#iterator items*(d: PDict): tuple[k: TKey, v: TValue] = +proc add*(d: PDict, k: TKey, v: TValue) = + d.data.add((k, v)) + + +#iterator items*(d: PDict): tuple[k: TKey, v: TValue] = # for k, v in items(d.data): yield (k, v) - + var d = newDict[int, string]() d.add(12, "12") d.add(13, "13") -for k, v in items(d): +for k, v in items(d): stdout.write("Key: ", $k, " value: ", v) var c = newDict[char, string]() c.add('A', "12") c.add('B', "13") -for k, v in items(c): +for k, v in items(c): stdout.write(" Key: ", $k, " value: ", v) diff --git a/tests/generics/tgeneric1.nim b/tests/generics/tgeneric1.nim index 5d20a864be..5349f8f1d0 100644 --- a/tests/generics/tgeneric1.nim +++ b/tests/generics/tgeneric1.nim @@ -9,7 +9,7 @@ type TBinHeap[T] = object heap: seq[TNode[T]] last: int - + PBinHeap[T] = ref TBinHeap[T] proc newBinHeap*[T](heap: var PBinHeap[T], size: int) = @@ -17,7 +17,7 @@ proc newBinHeap*[T](heap: var PBinHeap[T], size: int) = heap.last = 0 newSeq(heap.heap, size) #newSeq(heap.seq, size) - + proc parent(elem: int): int {.inline.} = return (elem-1) div 2 diff --git a/tests/generics/tgenericdefaults.nim b/tests/generics/tgenericdefaults.nim index ad96f18513..a4c90a8840 100644 --- a/tests/generics/tgenericdefaults.nim +++ b/tests/generics/tgenericdefaults.nim @@ -1,4 +1,4 @@ -type +type TFoo[T, U, R = int] = object x: T y: U @@ -12,7 +12,7 @@ static: assert type(x1.x) is int assert type(x1.y) is float assert type(x1.z) is int - + var x2: TFoo[string, R = float, U = seq[int]] static: diff --git a/tests/generics/tgenericmatcher.nim b/tests/generics/tgenericmatcher.nim index edd0c4cf13..2edf461873 100644 --- a/tests/generics/tgenericmatcher.nim +++ b/tests/generics/tgenericmatcher.nim @@ -16,7 +16,7 @@ type min, max: int PMatcher[T] = ref TMatcher[T] -var +var m: PMatcher[int] diff --git a/tests/generics/tgenericmatcher2.nim b/tests/generics/tgenericmatcher2.nim index aa2f9dbb32..6832f80b7b 100644 --- a/tests/generics/tgenericmatcher2.nim +++ b/tests/generics/tgenericmatcher2.nim @@ -12,7 +12,7 @@ type matcher: ref TMatcher[T] min, max: int -var +var m: ref TMatcher[int] diff --git a/tests/generics/tgenericrefs.nim b/tests/generics/tgenericrefs.nim index a44b96af9b..245789cafa 100644 --- a/tests/generics/tgenericrefs.nim +++ b/tests/generics/tgenericrefs.nim @@ -1,4 +1,4 @@ -type +type PA[T] = ref TA[T] TA[T] = object field: T @@ -20,18 +20,18 @@ foo 23 when false: # Compiles unless you use var a: PA[string] - type + type PA = ref TA TA[T] = object # Cannot instantiate: - type + type TA[T] = object a: PA[T] PA[T] = ref TA[T] - type + type PA[T] = ref TA[T] TA[T] = object diff --git a/tests/generics/tgenericshardcases.nim b/tests/generics/tgenericshardcases.nim index e3b805db6a..72a2f4ec2a 100644 --- a/tests/generics/tgenericshardcases.nim +++ b/tests/generics/tgenericshardcases.nim @@ -7,7 +7,7 @@ import typetraits proc typeNameLen(x: typedesc): int {.compileTime.} = result = x.name.len - + macro selectType(a, b: typedesc): typedesc = result = a @@ -33,7 +33,7 @@ static: assert high(f1.data2) == 5 # length of MyEnum minus one, because we used T.high assert high(f2.data1) == 126 - assert high(f2.data2) == 3 + assert high(f2.data2) == 3 assert high(f1.data3) == 6 # length of MyEnum assert high(f2.data3) == 4 # length of int8 diff --git a/tests/generics/tgenericvariant.nim b/tests/generics/tgenericvariant.nim index 0150cda8dc..348d3da6e5 100644 --- a/tests/generics/tgenericvariant.nim +++ b/tests/generics/tgenericvariant.nim @@ -1,4 +1,4 @@ -type +type TMaybe[T] = object case empty: bool of false: value: T diff --git a/tests/generics/tinferredgenericprocs.nim b/tests/generics/tinferredgenericprocs.nim index 12adfe9651..5cbeabb94c 100644 --- a/tests/generics/tinferredgenericprocs.nim +++ b/tests/generics/tinferredgenericprocs.nim @@ -8,7 +8,7 @@ discard """ # https://github.com/Araq/Nim/issues/797 proc foo[T](s:T):string = $s -type IntStringProc = proc(x: int): string +type IntStringProc = proc(x: int): string var f1 = IntStringProc(foo) var f2: proc(x: int): string = foo diff --git a/tests/generics/tthread_generic.nim b/tests/generics/tthread_generic.nim index fdd11d9d15..d34b24628e 100644 --- a/tests/generics/tthread_generic.nim +++ b/tests/generics/tthread_generic.nim @@ -13,7 +13,7 @@ proc handleThreadFunc(arg: TThreadFuncArgs[int]){.thread.} = var output = fn() callback(output) -proc `@||->`*[T](fn: proc(): T {.thread.}, +proc `@||->`*[T](fn: proc(): T {.thread.}, callback: proc(val: T){.thread.}): TThread[TThreadFuncArgs[T]] = var thr: TThread[TThreadFuncArgs[T]] var args: TThreadFuncArgs[T] @@ -31,7 +31,7 @@ when isMainModule: return 1 proc callbackFunc(val: int) {.thread.} = echo($(val)) - + var thr = (testFunc @||-> callbackFunc) echo("test") joinThread(thr) diff --git a/tests/generics/twrong_field_caching.nim b/tests/generics/twrong_field_caching.nim index 595c58eb72..667ffbbe5a 100644 --- a/tests/generics/twrong_field_caching.nim +++ b/tests/generics/twrong_field_caching.nim @@ -13,10 +13,10 @@ x32: 3x2 (3x2)''' type RectArray*[R, C: static[int], T] = distinct array[R * C, T] - + var a23: RectArray[2, 3, int] var a32: RectArray[3, 2, int] - + echo "a23: ", a23.R, "x", a23.C echo "a32: ", a32.R, "x", a32.C @@ -34,8 +34,8 @@ echo "t32: ", t32.R, "x", t32.C # Output: # t32: 3x2 - - + + # Everything is still OK. Now let's use the rectangular array inside another # generic type: type @@ -62,7 +62,7 @@ var x32 = x23.transpose echo "x23: ", x23.R, "x", x23.C, " (", x23.theArray.R, "x", x23.theArray.C, ")" echo "x32: ", x32.R, "x", x32.C, " (", x32.theArray.R, "x", x32.theArray.C, ")" - + # Output: # x23: 2x3 (2x3) # x32: 3x2 (3x2) <--- this is incorrect. R and C do not match! diff --git a/tests/generics/twrong_floatlit_type.nim b/tests/generics/twrong_floatlit_type.nim index 2db8b43535..c1830cd5aa 100644 --- a/tests/generics/twrong_floatlit_type.nim +++ b/tests/generics/twrong_floatlit_type.nim @@ -35,48 +35,48 @@ proc translation*[T](p: Vector2D[T]): Matrix2x3[T] = proc scale*[T](v: Vector2D[T]): Matrix2x3[T] = Matrix2x3[T]([v.x, T(0.0), T(0.0), T(0.0), v.y, T(0.0)]) -proc rotation*[T](th: T): Matrix2x3[T] = - let +proc rotation*[T](th: T): Matrix2x3[T] = + let c = T(cos(th.float)) s = T(sin(th.float)) - + Matrix2x3[T]([c, -s, T(0.0), s, c, T(0.0)]) - -proc `*`*[T](a, b: Matrix2x3[T]): Matrix2x3[T] = + +proc `*`*[T](a, b: Matrix2x3[T]): Matrix2x3[T] = # Here we pretend that row 3 is [0,0,0,1] without # actually storing it in the matrix. - Matrix2x3[T]([a.M11*b.M11 + a.M12*b.M21, - a.M11*b.M12 + a.M12*b.M22, - a.M11*b.M13 + a.M12*b.M23 + a.M13, - + Matrix2x3[T]([a.M11*b.M11 + a.M12*b.M21, + a.M11*b.M12 + a.M12*b.M22, + a.M11*b.M13 + a.M12*b.M23 + a.M13, + a.M21*b.M11 + a.M22*b.M21, a.M21*b.M12 + a.M22*b.M22, a.M21*b.M13 + a.M22*b.M23 + a.M23]) - -proc `*`*[T](a: Matrix2x3[T], p: Point2D[T]): Point2D[T] = - let + +proc `*`*[T](a: Matrix2x3[T], p: Point2D[T]): Point2D[T] = + let x = a.M11*p.x + a.M12*p.y + a.M13 y = a.M21*p.x + a.M22*p.y + a.M23 - + Point2D[T](x: x, y: y) - + # making these so things like "line" that need a constructor don't stick out. # 2x2 determinant: |a b| # |c d| = ad - bc - + # String rendering # -template ff[S](x: S): string = +template ff[S](x: S): string = formatFloat(float(x), ffDefault, 0) - -proc `$`*[S](p: Point2D[S]): string = + +proc `$`*[S](p: Point2D[S]): string = "P($1, $2)" % [ff(p.x), ff(p.y)] - -proc `$`*[S](p: Vector2D[S]): string = + +proc `$`*[S](p: Vector2D[S]): string = "V($1, $2)" % [ff(p.x), ff(p.y)] - + proc `$`*[S](m: Matrix2x3[S]): string = - "M($1 $2 $3/$4 $5 $6)" % [ff(m.M11), ff(m.M12), ff(m.M13), + "M($1 $2 $3/$4 $5 $6)" % [ff(m.M11), ff(m.M12), ff(m.M13), ff(m.M21), ff(m.M22), ff(m.M23)] # @@ -102,7 +102,7 @@ proc `/`*[S](v: Vector2D[S], sc: S): Vector2D[S] = proc `/`*[S](sc: S; v: Vector2D[S]): Vector2D[S] = Vector2D[S](x: sc/v.x, y: sc/v.y) -proc `/`*[S](a, b: Vector2D[S]): Vector2D[S] = +proc `/`*[S](a, b: Vector2D[S]): Vector2D[S] = Vector2D[S](x: a.x/b.x, y: a.y/b.y) #proc vec[S](x, y: S): Vector2D[S] proc vec[S](x, y: S): Vector2D[S] = diff --git a/tests/global/globalaux.nim b/tests/global/globalaux.nim index 5f6f727210..951472695e 100644 --- a/tests/global/globalaux.nim +++ b/tests/global/globalaux.nim @@ -1,4 +1,4 @@ -type +type TObj*[T] = object val*: T diff --git a/tests/init/tuninit1.nim b/tests/init/tuninit1.nim index 57443a7d3d..886a1d7660 100644 --- a/tests/init/tuninit1.nim +++ b/tests/init/tuninit1.nim @@ -11,15 +11,15 @@ proc p = var x, y, z: int if stdin.readLine == "true": x = 34 - + while false: y = 999 break - + while true: if x == 12: break y = 9999 - + try: z = parseInt("1233") except E_Base: @@ -32,5 +32,5 @@ proc p = x = 3111 z = 0 echo x, y, z - + p() diff --git a/tests/iter/tcountup.nim b/tests/iter/tcountup.nim index e68a614b0d..1559041aa3 100644 --- a/tests/iter/tcountup.nim +++ b/tests/iter/tcountup.nim @@ -3,11 +3,11 @@ discard """ output: "0123456789" """ -# Test new countup and unary < +# Test new countup and unary < -for i in 0 .. < 10'i64: +for i in 0 .. < 10'i64: stdout.write(i) - + #OUT 0123456789 diff --git a/tests/iter/titer.nim b/tests/iter/titer.nim index 19a11dc4e0..c4143ae4f1 100644 --- a/tests/iter/titer.nim +++ b/tests/iter/titer.nim @@ -1,44 +1,44 @@ -# Test the new iterators - -iterator xrange(fromm, to: int, step = 1): int = - var a = fromm - while a <= to: - yield a - inc(a, step) - -iterator interval[T](a, b: T): T = - var x = a - while x <= b: - yield x - inc(x) - -# -#iterator lines(filename: string): (line: string) = -# var -# f: tTextfile -# shouldClose = open(f, filename) -# if shouldClose: -# setSpace(line, 256) -# while readTextLine(f, line): -# yield line -# finally: -# if shouldClose: close(f) -# - -for i in xrange(0, 5): - for k in xrange(1, 7): - write(stdout, "test") - -for j in interval(45, 45): - write(stdout, "test2!") - write(stdout, "test3?") - -for x in items(["hi", "what's", "your", "name"]): - echo(x) - -const - stringArray = ["hi", "what's", "your", "name"] - -for i in 0..len(stringArray)-1: - echo(stringArray[i]) - +# Test the new iterators + +iterator xrange(fromm, to: int, step = 1): int = + var a = fromm + while a <= to: + yield a + inc(a, step) + +iterator interval[T](a, b: T): T = + var x = a + while x <= b: + yield x + inc(x) + +# +#iterator lines(filename: string): (line: string) = +# var +# f: tTextfile +# shouldClose = open(f, filename) +# if shouldClose: +# setSpace(line, 256) +# while readTextLine(f, line): +# yield line +# finally: +# if shouldClose: close(f) +# + +for i in xrange(0, 5): + for k in xrange(1, 7): + write(stdout, "test") + +for j in interval(45, 45): + write(stdout, "test2!") + write(stdout, "test3?") + +for x in items(["hi", "what's", "your", "name"]): + echo(x) + +const + stringArray = ["hi", "what's", "your", "name"] + +for i in 0..len(stringArray)-1: + echo(stringArray[i]) + diff --git a/tests/iter/titer6.nim b/tests/iter/titer6.nim index 2abfa08604..b7c8fee80d 100644 --- a/tests/iter/titer6.nim +++ b/tests/iter/titer6.nim @@ -22,16 +22,16 @@ iterator tokenize2(s: string, seps: set[char] = Whitespace): tuple[ i = j for word, isSep in tokenize2("ta da", WhiteSpace): - var titer2TestVar = 0 + var titer2TestVar = 0 stdout.write(titer2TestVar) -proc wordWrap2(s: string, maxLineWidth = 80, +proc wordWrap2(s: string, maxLineWidth = 80, splitLongWords = true, seps: set[char] = Whitespace, - newLine = "\n"): string = + newLine = "\n"): string = result = "" for word, isSep in tokenize2(s, seps): - var w = 0 + var w = 0 diff --git a/tests/iter/titer8.nim b/tests/iter/titer8.nim index 3bc01122f6..7b6d7b6dec 100644 --- a/tests/iter/titer8.nim +++ b/tests/iter/titer8.nim @@ -55,7 +55,7 @@ echo "" proc inProc() = for c in count3(): echo c - + for word, isSep in tokenize2("ta da", WhiteSpace): stdout.write(word) @@ -69,7 +69,7 @@ inProc() iterator count0(): int {.closure.} = # note: doesn't require anything in its closure (except 'state') yield 0 - + iterator count2(): int {.closure.} = # note: requires 'x' in its closure var x = 1 diff --git a/tests/iter/titer_no_tuple_unpack.nim b/tests/iter/titer_no_tuple_unpack.nim index da5e1bc46e..13ec11bd66 100644 --- a/tests/iter/titer_no_tuple_unpack.nim +++ b/tests/iter/titer_no_tuple_unpack.nim @@ -1,13 +1,13 @@ - -iterator xrange(fromm, to: int, step = 1): tuple[x, y: int] = - var a = fromm - while a <= to: - yield (a, a+1) - inc(a, step) + +iterator xrange(fromm, to: int, step = 1): tuple[x, y: int] = + var a = fromm + while a <= to: + yield (a, a+1) + inc(a, step) for a, b in xrange(3, 7): echo a, " ", b - + for tup in xrange(3, 7): echo tup diff --git a/tests/js.nim b/tests/js.nim index e5e4323667..92cb130bdc 100644 --- a/tests/js.nim +++ b/tests/js.nim @@ -20,5 +20,5 @@ proc OnButtonClick() {.exportc.} = var x = parseInt(v) echo x*x -proc OnLoad() {.exportc.} = +proc OnLoad() {.exportc.} = echo "Welcome! Please take your time to fill in this formular!" diff --git a/tests/js/test2.nim b/tests/js/test2.nim index 1a42fbfdad..f6976d0589 100644 --- a/tests/js/test2.nim +++ b/tests/js/test2.nim @@ -6,14 +6,14 @@ js 3.14 # This file tests the JavaScript generator -# #335 +# #335 proc foo() = var bar = "foo" proc baz() = echo bar baz() foo() - + # #376 when not defined(JS): proc foo(val: float): string = "no js " & $val diff --git a/tests/lexer/thexlit.nim b/tests/lexer/thexlit.nim index 04a530c9c9..2b7f0a40e0 100644 --- a/tests/lexer/thexlit.nim +++ b/tests/lexer/thexlit.nim @@ -9,4 +9,4 @@ if t==0x950412DE: echo "equal" else: echo "not equal" - + diff --git a/tests/lexer/thexrange.nim b/tests/lexer/thexrange.nim index e5e4c10c6c..461e41dfde 100644 --- a/tests/lexer/thexrange.nim +++ b/tests/lexer/thexrange.nim @@ -1,7 +1,7 @@ type TArray = array[0x0012..0x0013, int] - + var a: TArray echo a[0x0012] #OUT 0 diff --git a/tests/lexer/tident.nim b/tests/lexer/tident.nim index 1ed9894c61..68cc01e70f 100644 --- a/tests/lexer/tident.nim +++ b/tests/lexer/tident.nim @@ -1,12 +1,12 @@ type - TIdObj* = object of TObject - id*: int # unique id; use this for comparisons and not the pointers - - PIdObj* = ref TIdObj - PIdent* = ref TIdent - TIdent*{.acyclic.} = object - s*: string + TIdObj* = object of TObject + id*: int # unique id; use this for comparisons and not the pointers + + PIdObj* = ref TIdObj + PIdent* = ref TIdent + TIdent*{.acyclic.} = object + s*: string proc myNewString(L: int): string {.inline.} = result = newString(L) @@ -15,8 +15,8 @@ proc myNewString(L: int): string {.inline.} = for i in 0..L-1: if result[i] == '\0': echo("Correct") - else: + else: echo("Wrong") - + var s = myNewString(8) diff --git a/tests/lexer/tind1.nim b/tests/lexer/tind1.nim index f3fd952cc0..6a975d5beb 100644 --- a/tests/lexer/tind1.nim +++ b/tests/lexer/tind1.nim @@ -17,7 +17,7 @@ mymacro: echo "test" else: echo "else part" - + if 4 == 3: echo "bug" diff --git a/tests/lexer/tlexer.nim b/tests/lexer/tlexer.nim index 1dca6d9d04..e36220e7ad 100644 --- a/tests/lexer/tlexer.nim +++ b/tests/lexer/tlexer.nim @@ -1,60 +1,60 @@ -discard """ - disabled: true -""" - -# We start with a comment -# This is the same comment - -# This is a new one! - -import - lexbase, os, strutils - -type - TMyRec {.final.} = object - x, y: int # coordinates - c: char # a character - a: int32 # an integer - - PMyRec = ref TMyRec # a reference to `TMyRec` - -proc splitText(txt: string): seq[string] # splits a text into several lines - # the comment continues here - # this is not easy to parse! - -proc anotherSplit(txt: string): seq[string] = - # the comment should belong to `anotherSplit`! - # another problem: comments are statements! - -const - x = 0B0_10001110100_0000101001000111101011101111111011000101001101001001'f64 # x ~~ 1.72826e35 - myNan = 0B01111111100000101100000000001000'f32 # NAN - y = """ - a rather long text. - Over many - lines. - """ - s = "\xff" - a = {0..234} - b = {0..high(int)} - v = 0'i32 - z = 6767566'f32 - -# small test program for lexbase - -proc main*(infile: string, a, b: int, someverylongnamewithtype = 0, - anotherlongthingie = 3) = - var - myInt: int = 0 - s: seq[string] - # this should be an error! - if initBaseLexer(L, infile, 30): nil - else: - writeLine(stdout, "could not open: " & infile) - writeLine(stdout, "Success!") - call(3, # we use 3 - 12, # we use 12 - 43) # we use 43 - - -main(ParamStr(1), 9, 0) +discard """ + disabled: true +""" + +# We start with a comment +# This is the same comment + +# This is a new one! + +import + lexbase, os, strutils + +type + TMyRec {.final.} = object + x, y: int # coordinates + c: char # a character + a: int32 # an integer + + PMyRec = ref TMyRec # a reference to `TMyRec` + +proc splitText(txt: string): seq[string] # splits a text into several lines + # the comment continues here + # this is not easy to parse! + +proc anotherSplit(txt: string): seq[string] = + # the comment should belong to `anotherSplit`! + # another problem: comments are statements! + +const + x = 0B0_10001110100_0000101001000111101011101111111011000101001101001001'f64 # x ~~ 1.72826e35 + myNan = 0B01111111100000101100000000001000'f32 # NAN + y = """ + a rather long text. + Over many + lines. + """ + s = "\xff" + a = {0..234} + b = {0..high(int)} + v = 0'i32 + z = 6767566'f32 + +# small test program for lexbase + +proc main*(infile: string, a, b: int, someverylongnamewithtype = 0, + anotherlongthingie = 3) = + var + myInt: int = 0 + s: seq[string] + # this should be an error! + if initBaseLexer(L, infile, 30): nil + else: + writeLine(stdout, "could not open: " & infile) + writeLine(stdout, "Success!") + call(3, # we use 3 + 12, # we use 12 + 43) # we use 43 + + +main(ParamStr(1), 9, 0) diff --git a/tests/lexer/tstrlits.nim b/tests/lexer/tstrlits.nim index 1cd43975a6..f5b7ce9371 100644 --- a/tests/lexer/tstrlits.nim +++ b/tests/lexer/tstrlits.nim @@ -6,9 +6,9 @@ discard """ const tripleEmpty = """"long string"""""""" # "long string """"" - + rawQuote = r"a""" - + raw = r"abc""def" stdout.write(rawQuote) diff --git a/tests/lexer/tunderscores.nim b/tests/lexer/tunderscores.nim index 8075fdae45..e718fb40ae 100644 --- a/tests/lexer/tunderscores.nim +++ b/tests/lexer/tunderscores.nim @@ -3,7 +3,7 @@ discard """ line: 8 errormsg: "invalid token: _" """ -# Bug #502670 +# Bug #502670 var ef_ = 3 #ERROR_MSG invalid token: _ var a__b = 1 diff --git a/tests/lookups/tkoeniglookup.nim b/tests/lookups/tkoeniglookup.nim index 6c42798ae5..8b140cceb5 100644 --- a/tests/lookups/tkoeniglookup.nim +++ b/tests/lookups/tkoeniglookup.nim @@ -9,7 +9,7 @@ type TMyObj = object x, y: int -proc `$`*(a: TMyObj): string = +proc `$`*(a: TMyObj): string = result = "x: " & $a.x & " y: " & $a.y var a: TMyObj diff --git a/tests/lookups/tredef.nim b/tests/lookups/tredef.nim index a1647000cb..8f1b38bd10 100644 --- a/tests/lookups/tredef.nim +++ b/tests/lookups/tredef.nim @@ -12,13 +12,13 @@ block: template foo(a: int, b: string) = discard foo(1, "test") bar(1, "test") - + proc baz = proc foo(a: int, b: string) = discard proc foo(b: string) = template bar(a: int, b: string) = discard bar(1, "test") - + foo("test") block: diff --git a/tests/macros/tclosuremacro.nim b/tests/macros/tclosuremacro.nim index d5d9b656c5..cf51949edc 100644 --- a/tests/macros/tclosuremacro.nim +++ b/tests/macros/tclosuremacro.nim @@ -29,7 +29,7 @@ proc doWithOneAndTwo(f: (int, int) -> int): int = echo twoParams(proc (a, b): auto = a + b) echo twoParams((x, y) => x + y) -echo oneParam(x => x+5) +echo oneParam(x => x+5) echo noParams(() => 3) diff --git a/tests/macros/tmacro2.nim b/tests/macros/tmacro2.nim index 8515322d52..17f3129259 100644 --- a/tests/macros/tmacro2.nim +++ b/tests/macros/tmacro2.nim @@ -4,7 +4,7 @@ discard """ import macros, strutils -proc testBlock(): string {.compileTime.} = +proc testBlock(): string {.compileTime.} = block myBlock: while true: echo "inner block" @@ -21,7 +21,7 @@ macro mac(n: expr): expr = s = s.replace("l", "!!") result = newStrLitNode("Your value sir: '$#'" % [s]) -const s = testBlock() +const s = testBlock() const t = mac("HEllo World") echo s, " ", t diff --git a/tests/macros/tmacrogenerics.nim b/tests/macros/tmacrogenerics.nim index b886f4fa54..919a15b46c 100644 --- a/tests/macros/tmacrogenerics.nim +++ b/tests/macros/tmacrogenerics.nim @@ -16,7 +16,7 @@ macro makeBar(A, B: typedesc): typedesc = echo "instantiation ", counter, " with ", A.name, " and ", B.name result = A -type +type Bar[T, U] = makeBar(T, U) var bb1: Bar[int, float] diff --git a/tests/macros/tmacrostmt.nim b/tests/macros/tmacrostmt.nim index d9c70197dc..23e2f358cb 100644 --- a/tests/macros/tmacrostmt.nim +++ b/tests/macros/tmacrostmt.nim @@ -13,7 +13,7 @@ of r"[\+\-\*\?]+": return tkOperator else: return tkUnknown - + case_token: inc i #bug #488 diff --git a/tests/macros/tprintf.nim b/tests/macros/tprintf.nim index c8fb51cdc7..94cbfbc2bc 100644 --- a/tests/macros/tprintf.nim +++ b/tests/macros/tprintf.nim @@ -2,15 +2,15 @@ discard """ file: "tprintf.nim" output: "Andreas Rumpf" """ -# Test a printf proc - -proc printf(file: TFile, args: openarray[string]) = - var i = 0 - while i < args.len: - write(file, args[i]) - inc(i) - -printf(stdout, ["Andreas ", "Rumpf\n"]) -#OUT Andreas Rumpf +# Test a printf proc + +proc printf(file: TFile, args: openarray[string]) = + var i = 0 + while i < args.len: + write(file, args[i]) + inc(i) + +printf(stdout, ["Andreas ", "Rumpf\n"]) +#OUT Andreas Rumpf diff --git a/tests/macros/tquotewords.nim b/tests/macros/tquotewords.nim index 76b8d8af77..7a575f5417 100644 --- a/tests/macros/tquotewords.nim +++ b/tests/macros/tquotewords.nim @@ -6,13 +6,13 @@ discard """ import macros -macro quoteWords(n: expr): expr {.immediate.} = +macro quoteWords(n: expr): expr {.immediate.} = let n = callsite() result = newNimNode(nnkBracket, n) for i in 1..n.len-1: expectKind(n[i], nnkIdent) result.add(toStrLit(n[i])) - + const myWordList = quoteWords(this, an, example) diff --git a/tests/macros/tstaticparamsmacro.nim b/tests/macros/tstaticparamsmacro.nim index 1ab6383962..f6ecb3a9f0 100644 --- a/tests/macros/tstaticparamsmacro.nim +++ b/tests/macros/tstaticparamsmacro.nim @@ -5,9 +5,9 @@ bb numbers 11 22 -AST a +AST a [(11, 22), (33, 44)] -AST b +AST b (e: [55, 66], f: [77, 88]) 55 10 diff --git a/tests/macros/tvtable.nim b/tests/macros/tvtable.nim index 3e3b9c0e6e..cc5d7a5d91 100644 --- a/tests/macros/tvtable.nim +++ b/tests/macros/tvtable.nim @@ -17,7 +17,7 @@ type # an untyped table to store the proc pointers # it's also possible to use a strongly typed tuple here VTable = array[0..1, pointer] - + TBase = object {.inheritable.} vtbl: ptr VTable diff --git a/tests/magics/tlowhigh.nim b/tests/magics/tlowhigh.nim index d1cbd32726..4998b73dc8 100644 --- a/tests/magics/tlowhigh.nim +++ b/tests/magics/tlowhigh.nim @@ -2,23 +2,23 @@ discard """ file: "tlowhigh.nim" output: "10" """ -# Test the magic low() and high() procs - -type - myEnum = enum e1, e2, e3, e4, e5 - -var - a: array [myEnum, int] - -for i in low(a) .. high(a): - a[i] = 0 - -proc sum(a: openarray[int]): int = - result = 0 - for i in low(a)..high(a): - inc(result, a[i]) - -write(stdout, sum([1, 2, 3, 4])) -#OUT 10 +# Test the magic low() and high() procs + +type + myEnum = enum e1, e2, e3, e4, e5 + +var + a: array [myEnum, int] + +for i in low(a) .. high(a): + a[i] = 0 + +proc sum(a: openarray[int]): int = + result = 0 + for i in low(a)..high(a): + inc(result, a[i]) + +write(stdout, sum([1, 2, 3, 4])) +#OUT 10 diff --git a/tests/manyloc/keineschweine/dependencies/chipmunk/chipmunk.nim b/tests/manyloc/keineschweine/dependencies/chipmunk/chipmunk.nim index 493a2106cd..56d3edec49 100644 --- a/tests/manyloc/keineschweine/dependencies/chipmunk/chipmunk.nim +++ b/tests/manyloc/keineschweine/dependencies/chipmunk/chipmunk.nim @@ -1,15 +1,15 @@ # Copyright (c) 2007 Scott Lembcke -# +# # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: -# +# # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. -# +# # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -17,7 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -# +# const Lib = "libchipmunk.so.6.1.1" @@ -30,12 +30,12 @@ when defined(CpUseFloat): type CpFloat* = cfloat else: type CpFloat* = cdouble -const - CP_BUFFER_BYTES* = (32 * 1024) +const + CP_BUFFER_BYTES* = (32 * 1024) CP_MAX_CONTACTS_PER_ARBITER* = 4 CpInfinity*: CpFloat = 1.0/0 {.pragma: pf, pure, final.} -type +type Bool32* = cint #replace one day with cint-compatible bool CpDataPointer* = pointer TVector* {.final, pure.} = object @@ -44,12 +44,12 @@ type TBodyVelocityFunc* = proc(body: PBody, gravity: TVector, damping: CpFloat; dt: CpFloat){.cdecl.} TBodyPositionFunc* = proc(body: PBody; dt: CpFloat){.cdecl.} - TComponentNode*{.pf.} = object + TComponentNode*{.pf.} = object root*: PBody next*: PBody idleTime*: CpFloat - - THashValue = cuint # uintptr_t + + THashValue = cuint # uintptr_t TCollisionType* = cuint #uintptr_t TGroup * = cuint #uintptr_t TLayers* = cuint @@ -60,9 +60,9 @@ type PContact* = ptr TContact TContact*{.pure,final.} = object PArbiter* = ptr TArbiter - TArbiter*{.pf.} = object + TArbiter*{.pf.} = object e*: CpFloat - u*: CpFloat + u*: CpFloat surface_vr*: TVector a*: PShape b*: PShape @@ -77,7 +77,7 @@ type swappedColl*: Bool32 state*: TArbiterState PCollisionHandler* = ptr TCollisionHandler - TCollisionHandler*{.pf.} = object + TCollisionHandler*{.pf.} = object a*: TCollisionType b*: TCollisionType begin*: TCollisionBeginFunc @@ -85,26 +85,26 @@ type postSolve*: TCollisionPostSolveFunc separate*: TCollisionSeparateFunc data*: pointer - TArbiterState*{.size: sizeof(cint).} = enum + TArbiterState*{.size: sizeof(cint).} = enum ArbiterStateFirstColl, # Arbiter is active and its not the first collision. ArbiterStateNormal, # Collision has been explicitly ignored. # Either by returning false from a begin collision handler or calling cpArbiterIgnore(). ArbiterStateIgnore, # Collison is no longer active. A space will cache an arbiter for up to cpSpace.collisionPersistence more steps. ArbiterStateCached - TArbiterThread*{.pf.} = object + TArbiterThread*{.pf.} = object next*: PArbiter # Links to next and previous arbiters in the contact graph. prev*: PArbiter - - TContactPoint*{.pf.} = object + + TContactPoint*{.pf.} = object point*: TVector #/ The position of the contact point. normal*: TVector #/ The normal of the contact point. dist*: CpFloat #/ The depth of the contact point. #/ A struct that wraps up the important collision data for an arbiter. PContactPointSet* = ptr TContactPointSet - TContactPointSet*{.pf.} = object + TContactPointSet*{.pf.} = object count*: cint #/ The number of contact points in the set. points*: array[0..CP_MAX_CONTACTS_PER_ARBITER - 1, TContactPoint] #/ The array of contact points. - + #/ Collision begin event function callback type. #/ Returning false from a begin callback causes the collision to be ignored until #/ the the separate callback is called when the objects stop colliding. @@ -112,35 +112,35 @@ type cdecl.} #/ Collision pre-solve event function callback type. #/ Returning false from a pre-step callback causes the collision to be ignored until the next step. - TCollisionPreSolveFunc* = proc (arb: PArbiter; space: PSpace; + TCollisionPreSolveFunc* = proc (arb: PArbiter; space: PSpace; data: pointer): bool {.cdecl.} #/ Collision post-solve event function callback type. - TCollisionPostSolveFunc* = proc (arb: PArbiter; space: PSpace; + TCollisionPostSolveFunc* = proc (arb: PArbiter; space: PSpace; data: pointer){.cdecl.} #/ Collision separate event function callback type. - TCollisionSeparateFunc* = proc (arb: PArbiter; space: PSpace; + TCollisionSeparateFunc* = proc (arb: PArbiter; space: PSpace; data: pointer){.cdecl.} - + #/ Chipmunk's axis-aligned 2D bounding box type. (left, bottom, right, top) PBB* = ptr TBB - TBB* {.pf.} = object + TBB* {.pf.} = object l*, b*, r*, t*: CpFloat - + #/ Spatial index bounding box callback function type. #/ The spatial index calls this function and passes you a pointer to an object you added #/ when it needs to get the bounding box associated with that object. TSpatialIndexBBFunc* = proc (obj: pointer): TBB{.cdecl.} #/ Spatial index/object iterator callback function type. TSpatialIndexIteratorFunc* = proc (obj: pointer; data: pointer){.cdecl.} - #/ Spatial query callback function type. + #/ Spatial query callback function type. TSpatialIndexQueryFunc* = proc (obj1: pointer; obj2: pointer; data: pointer){. cdecl.} #/ Spatial segment query callback function type. - TSpatialIndexSegmentQueryFunc* = proc (obj1: pointer; obj2: pointer; + TSpatialIndexSegmentQueryFunc* = proc (obj1: pointer; obj2: pointer; data: pointer): CpFloat {.cdecl.} #/ private PSpatialIndex = ptr TSpatialIndex - TSpatialIndex{.pf.} = object + TSpatialIndex{.pf.} = object klass: PSpatialIndexClass bbfun: TSpatialIndexBBFunc staticIndex: PSpatialIndex @@ -148,31 +148,31 @@ type TSpatialIndexDestroyImpl* = proc (index: PSpatialIndex){.cdecl.} TSpatialIndexCountImpl* = proc (index: PSpatialIndex): cint{.cdecl.} - TSpatialIndexEachImpl* = proc (index: PSpatialIndex; + TSpatialIndexEachImpl* = proc (index: PSpatialIndex; fun: TSpatialIndexIteratorFunc; data: pointer){. cdecl.} - TSpatialIndexContainsImpl* = proc (index: PSpatialIndex; obj: pointer; + TSpatialIndexContainsImpl* = proc (index: PSpatialIndex; obj: pointer; hashid: THashValue): Bool32 {.cdecl.} - TSpatialIndexInsertImpl* = proc (index: PSpatialIndex; obj: pointer; + TSpatialIndexInsertImpl* = proc (index: PSpatialIndex; obj: pointer; hashid: THashValue){.cdecl.} - TSpatialIndexRemoveImpl* = proc (index: PSpatialIndex; obj: pointer; + TSpatialIndexRemoveImpl* = proc (index: PSpatialIndex; obj: pointer; hashid: THashValue){.cdecl.} TSpatialIndexReindexImpl* = proc (index: PSpatialIndex){.cdecl.} - TSpatialIndexReindexObjectImpl* = proc (index: PSpatialIndex; + TSpatialIndexReindexObjectImpl* = proc (index: PSpatialIndex; obj: pointer; hashid: THashValue){.cdecl.} - TSpatialIndexReindexQueryImpl* = proc (index: PSpatialIndex; + TSpatialIndexReindexQueryImpl* = proc (index: PSpatialIndex; fun: TSpatialIndexQueryFunc; data: pointer){.cdecl.} - TSpatialIndexPointQueryImpl* = proc (index: PSpatialIndex; point: TVector; - fun: TSpatialIndexQueryFunc; + TSpatialIndexPointQueryImpl* = proc (index: PSpatialIndex; point: TVector; + fun: TSpatialIndexQueryFunc; data: pointer){.cdecl.} - TSpatialIndexSegmentQueryImpl* = proc (index: PSpatialIndex; obj: pointer; - a: TVector; b: TVector; t_exit: CpFloat; fun: TSpatialIndexSegmentQueryFunc; + TSpatialIndexSegmentQueryImpl* = proc (index: PSpatialIndex; obj: pointer; + a: TVector; b: TVector; t_exit: CpFloat; fun: TSpatialIndexSegmentQueryFunc; data: pointer){.cdecl.} - TSpatialIndexQueryImpl* = proc (index: PSpatialIndex; obj: pointer; - bb: TBB; fun: TSpatialIndexQueryFunc; + TSpatialIndexQueryImpl* = proc (index: PSpatialIndex; obj: pointer; + bb: TBB; fun: TSpatialIndexQueryFunc; data: pointer){.cdecl.} PSpatialIndexClass* = ptr TSpatialIndexClass - TSpatialIndexClass*{.pf.} = object + TSpatialIndexClass*{.pf.} = object destroy*: TSpatialIndexDestroyImpl count*: TSpatialIndexCountImpl each*: TSpatialIndexEachImpl @@ -185,32 +185,32 @@ type pointQuery*: TSpatialIndexPointQueryImpl segmentQuery*: TSpatialIndexSegmentQueryImpl query*: TSpatialIndexQueryImpl - + PSpaceHash* = ptr TSpaceHash TSpaceHash* {.pf.} = object PBBTree* = ptr TBBTree TBBTree* {.pf.} = object PSweep1D* = ptr TSweep1D TSweep1D* {.pf.} = object - + #/ Bounding box tree velocity callback function. #/ This function should return an estimate for the object's velocity. TBBTreeVelocityFunc* = proc (obj: pointer): TVector {.cdecl.} - + PContactBufferHeader* = ptr TContentBufferHeader TContentBufferHeader* {.pf.} = object TSpaceArbiterApplyImpulseFunc* = proc (arb: PArbiter){.cdecl.} - + PSpace* = ptr TSpace TSpace* {.pf.} = object - iterations*: cint + iterations*: cint gravity*: TVector damping*: CpFloat - idleSpeedThreshold*: CpFloat - sleepTimeThreshold*: CpFloat - collisionSlop*: CpFloat + idleSpeedThreshold*: CpFloat + sleepTimeThreshold*: CpFloat + collisionSlop*: CpFloat collisionBias*: CpFloat - collisionPersistence*: TTimestamp + collisionPersistence*: TTimestamp enableContactGraph*: cint ##BOOL data*: pointer staticBody*: PBody @@ -232,24 +232,24 @@ type defaultHandler: TCollisionHandler postStepCallbacks: PHashSet arbiterApplyImpulse: TSpaceArbiterApplyImpulseFunc - staticBody2: TBody #_staticBody + staticBody2: TBody #_staticBody PBody* = ptr TBody - TBody*{.pf.} = object - velocityFunc*: TBodyVelocityFunc - positionFunc*: TBodyPositionFunc - m*: CpFloat - mInv*: CpFloat - i*: CpFloat - iInv*: CpFloat - p*: TVector - v*: TVector - f*: TVector - a*: CpFloat - w*: CpFloat - t*: CpFloat - rot*: TVector + TBody*{.pf.} = object + velocityFunc*: TBodyVelocityFunc + positionFunc*: TBodyPositionFunc + m*: CpFloat + mInv*: CpFloat + i*: CpFloat + iInv*: CpFloat + p*: TVector + v*: TVector + f*: TVector + a*: CpFloat + w*: CpFloat + t*: CpFloat + rot*: TVector data*: pointer - vLimit*: CpFloat + vLimit*: CpFloat wLimit*: CpFloat vBias*: TVector wBias*: CpFloat @@ -258,51 +258,51 @@ type arbiterList*: PArbiter constraintList*: PConstraint node*: TComponentNode - #/ Body/shape iterator callback function type. - TBodyShapeIteratorFunc* = proc (body: PBody; shape: PShape; + #/ Body/shape iterator callback function type. + TBodyShapeIteratorFunc* = proc (body: PBody; shape: PShape; data: pointer) {.cdecl.} - #/ Body/constraint iterator callback function type. - TBodyConstraintIteratorFunc* = proc (body: PBody; - constraint: PConstraint; + #/ Body/constraint iterator callback function type. + TBodyConstraintIteratorFunc* = proc (body: PBody; + constraint: PConstraint; data: pointer) {.cdecl.} - #/ Body/arbiter iterator callback function type. - TBodyArbiterIteratorFunc* = proc (body: PBody; arbiter: PArbiter; + #/ Body/arbiter iterator callback function type. + TBodyArbiterIteratorFunc* = proc (body: PBody; arbiter: PArbiter; data: pointer) {.cdecl.} - + PNearestPointQueryInfo* = ptr TNearestPointQueryInfo #/ Nearest point query info struct. TNearestPointQueryInfo*{.pf.} = object shape: PShape #/ The nearest shape, NULL if no shape was within range. p: TVector #/ The closest point on the shape's surface. (in world space coordinates) d: CpFloat #/ The distance to the point. The distance is negative if the point is inside the shape. - + PSegmentQueryInfo* = ptr TSegmentQueryInfo #/ Segment query info struct. - TSegmentQueryInfo*{.pf.} = object + TSegmentQueryInfo*{.pf.} = object shape*: PShape #/ The shape that was hit, NULL if no collision occurred. t*: CpFloat #/ The normalized distance along the query segment in the range [0, 1]. n*: TVector #/ The normal of the surface hit. - TShapeType*{.size: sizeof(cint).} = enum + TShapeType*{.size: sizeof(cint).} = enum CP_CIRCLE_SHAPE, CP_SEGMENT_SHAPE, CP_POLY_SHAPE, CP_NUM_SHAPES TShapeCacheDataImpl* = proc (shape: PShape; p: TVector; rot: TVector): TBB{.cdecl.} TShapeDestroyImpl* = proc (shape: PShape){.cdecl.} TShapePointQueryImpl* = proc (shape: PShape; p: TVector): Bool32 {.cdecl.} - TShapeSegmentQueryImpl* = proc (shape: PShape; a: TVector; b: TVector; + TShapeSegmentQueryImpl* = proc (shape: PShape; a: TVector; b: TVector; info: PSegmentQueryInfo){.cdecl.} PShapeClass* = ptr TShapeClass - TShapeClass*{.pf.} = object + TShapeClass*{.pf.} = object kind*: TShapeType cacheData*: TShapeCacheDataImpl destroy*: TShapeDestroyImpl pointQuery*: TShapePointQueryImpl segmentQuery*: TShapeSegmentQueryImpl PShape* = ptr TShape - TShape*{.pf.} = object + TShape*{.pf.} = object klass: PShapeClass #/ PRIVATE body*: PBody #/ The rigid body this collision shape is attached to. - bb*: TBB #/ The current bounding box of the shape. + bb*: TBB #/ The current bounding box of the shape. sensor*: Bool32 #/ Sensor flag. - #/ Sensor shapes call collision callbacks but don't produce collisions. + #/ Sensor shapes call collision callbacks but don't produce collisions. e*: CpFloat #/ Coefficient of restitution. (elasticity) u*: CpFloat #/ Coefficient of friction. surface_v*: TVector #/ Surface velocity used when solving for friction. @@ -336,29 +336,29 @@ type TSplittingPlane*{.pf.} = object n: TVector d: CpFloat - + #/ Post Step callback function type. TPostStepFunc* = proc (space: PSpace; obj: pointer; data: pointer){.cdecl.} #/ Point query callback function type. TSpacePointQueryFunc* = proc (shape: PShape; data: pointer){.cdecl.} #/ Segment query callback function type. - TSpaceSegmentQueryFunc* = proc (shape: PShape; t: CpFloat; n: TVector; + TSpaceSegmentQueryFunc* = proc (shape: PShape; t: CpFloat; n: TVector; data: pointer){.cdecl.} #/ Rectangle Query callback function type. TSpaceBBQueryFunc* = proc (shape: PShape; data: pointer){.cdecl.} #/ Shape query callback function type. - TSpaceShapeQueryFunc* = proc (shape: PShape; points: PContactPointSet; + TSpaceShapeQueryFunc* = proc (shape: PShape; points: PContactPointSet; data: pointer){.cdecl.} #/ Space/body iterator callback function type. TSpaceBodyIteratorFunc* = proc (body: PBody; data: pointer){.cdecl.} #/ Space/body iterator callback function type. TSpaceShapeIteratorFunc* = proc (shape: PShape; data: pointer){.cdecl.} #/ Space/constraint iterator callback function type. - TSpaceConstraintIteratorFunc* = proc (constraint: PConstraint; + TSpaceConstraintIteratorFunc* = proc (constraint: PConstraint; data: pointer){.cdecl.} #/ Opaque cpConstraint struct. PConstraint* = ptr TConstraint - TConstraint*{.pf.} = object + TConstraint*{.pf.} = object klass: PConstraintClass #/PRIVATE a*: PBody #/ The first body connected to this constraint. b*: PBody #/ The second body connected to this constraint. @@ -367,7 +367,7 @@ type next_b: PConstraint #/PRIVATE maxForce*: CpFloat #/ The maximum force that this constraint is allowed to use. Defaults to infinity. errorBias*: CpFloat #/ The rate at which joint error is corrected. Defaults to pow(1.0 - 0.1, 60.0) meaning that it will correct 10% of the error every 1/60th of a second. - maxBias*: CpFloat #/ The maximum rate at which joint error is corrected. Defaults to infinity. + maxBias*: CpFloat #/ The maximum rate at which joint error is corrected. Defaults to infinity. preSolve*: TConstraintPreSolveFunc #/ Function called before the solver runs. Animate your joint anchors, update your motor torque, etc. postSolve*: TConstraintPostSolveFunc #/ Function called after the solver runs. Use the applied impulse to perform effects like breakable joints. data*: CpDataPointer # User definable data pointer. Generally this points to your the game object class so you can access it when given a cpConstraint reference in a callback. @@ -376,7 +376,7 @@ type TConstraintApplyImpulseImpl = proc (constraint: PConstraint){.cdecl.} TConstraintGetImpulseImpl = proc (constraint: PConstraint): CpFloat{.cdecl.} PConstraintClass = ptr TConstraintClass - TConstraintClass{.pf.} = object + TConstraintClass{.pf.} = object preStep*: TConstraintPreStepImpl applyCachedImpulse*: TConstraintApplyCachedImpulseImpl applyImpulse*: TConstraintApplyImpulseImpl @@ -427,29 +427,29 @@ defGetter(PSpace, CpFloat, currDt, CurrentTimeStep) #/ returns true from inside a callback and objects cannot be added/removed. -proc isLocked*(space: PSpace): bool{.inline.} = +proc isLocked*(space: PSpace): bool{.inline.} = result = space.locked.bool #/ Set a default collision handler for this space. #/ The default collision handler is invoked for each colliding pair of shapes #/ that isn't explicitly handled by a specific collision handler. #/ You can pass NULL for any function you don't want to implement. -proc setDefaultCollisionHandler*(space: PSpace; begin: TCollisionBeginFunc; - preSolve: TCollisionPreSolveFunc; - postSolve: TCollisionPostSolveFunc; - separate: TCollisionSeparateFunc; +proc setDefaultCollisionHandler*(space: PSpace; begin: TCollisionBeginFunc; + preSolve: TCollisionPreSolveFunc; + postSolve: TCollisionPostSolveFunc; + separate: TCollisionSeparateFunc; data: pointer){. cdecl, importc: "cpSpaceSetDefaultCollisionHandler", dynlib: Lib.} #/ Set a collision handler to be used whenever the two shapes with the given collision types collide. #/ You can pass NULL for any function you don't want to implement. -proc addCollisionHandler*(space: PSpace; a, b: TCollisionType; - begin: TCollisionBeginFunc; - preSolve: TCollisionPreSolveFunc; - postSolve: TCollisionPostSolveFunc; +proc addCollisionHandler*(space: PSpace; a, b: TCollisionType; + begin: TCollisionBeginFunc; + preSolve: TCollisionPreSolveFunc; + postSolve: TCollisionPostSolveFunc; separate: TCollisionSeparateFunc; data: pointer){. cdecl, importc: "cpSpaceAddCollisionHandler", dynlib: Lib.} #/ Unset a collision handler. -proc removeCollisionHandler*(space: PSpace; a: TCollisionType; +proc removeCollisionHandler*(space: PSpace; a: TCollisionType; b: TCollisionType){. cdecl, importc: "cpSpaceRemoveCollisionHandler", dynlib: Lib.} #/ Add a collision shape to the simulation. @@ -489,34 +489,34 @@ proc containsConstraint*(space: PSpace; constraint: PConstraint): bool{. cdecl, importc: "cpSpaceContainsConstraint", dynlib: Lib.} #/ Schedule a post-step callback to be called when cpSpaceStep() finishes. #/ @c obj is used a key, you can only register one callback per unique value for @c obj -proc addPostStepCallback*(space: PSpace; fun: TPostStepFunc; +proc addPostStepCallback*(space: PSpace; fun: TPostStepFunc; obj: pointer; data: pointer){. cdecl, importc: "cpSpaceAddPostStepCallback", dynlib: Lib.} - + #/ Query the space at a point and call @c func for each shape found. -proc pointQuery*(space: PSpace; point: TVector; layers: TLayers; +proc pointQuery*(space: PSpace; point: TVector; layers: TLayers; group: TGroup; fun: TSpacePointQueryFunc; data: pointer){. cdecl, importc: "cpSpacePointQuery", dynlib: Lib.} #/ Query the space at a point and return the first shape found. Returns NULL if no shapes were found. -proc pointQueryFirst*(space: PSpace; point: TVector; layers: TLayers; +proc pointQueryFirst*(space: PSpace; point: TVector; layers: TLayers; group: TGroup): PShape{. cdecl, importc: "cpSpacePointQueryFirst", dynlib: Lib.} #/ Perform a directed line segment query (like a raycast) against the space calling @c func for each shape intersected. -proc segmentQuery*(space: PSpace; start: TVector; to: TVector; - layers: TLayers; group: TGroup; +proc segmentQuery*(space: PSpace; start: TVector; to: TVector; + layers: TLayers; group: TGroup; fun: TSpaceSegmentQueryFunc; data: pointer){. cdecl, importc: "cpSpaceSegmentQuery", dynlib: Lib.} #/ Perform a directed line segment query (like a raycast) against the space and return the first shape hit. Returns NULL if no shapes were hit. -proc segmentQueryFirst*(space: PSpace; start: TVector; to: TVector; - layers: TLayers; group: TGroup; +proc segmentQueryFirst*(space: PSpace; start: TVector; to: TVector; + layers: TLayers; group: TGroup; res: PSegmentQueryInfo): PShape{. cdecl, importc: "cpSpaceSegmentQueryFirst", dynlib: Lib.} #/ Perform a fast rectangle query on the space calling @c func for each shape found. #/ Only the shape's bounding boxes are checked for overlap, not their full shape. -proc BBQuery*(space: PSpace; bb: TBB; layers: TLayers; group: TGroup; +proc BBQuery*(space: PSpace; bb: TBB; layers: TLayers; group: TGroup; fun: TSpaceBBQueryFunc; data: pointer){. cdecl, importc: "cpSpaceBBQuery", dynlib: Lib.} @@ -532,11 +532,11 @@ proc eachBody*(space: PSpace; fun: TSpaceBodyIteratorFunc; data: pointer){. cdecl, importc: "cpSpaceEachBody", dynlib: Lib.} #/ Call @c func for each shape in the space. -proc eachShape*(space: PSpace; fun: TSpaceShapeIteratorFunc; +proc eachShape*(space: PSpace; fun: TSpaceShapeIteratorFunc; data: pointer){. cdecl, importc: "cpSpaceEachShape", dynlib: Lib.} #/ Call @c func for each shape in the space. -proc eachConstraint*(space: PSpace; fun: TSpaceConstraintIteratorFunc; +proc eachConstraint*(space: PSpace; fun: TSpaceConstraintIteratorFunc; data: pointer){. cdecl, importc: "cpSpaceEachConstraint", dynlib: Lib.} #/ Update the collision detection info for the static shapes in the space. @@ -566,7 +566,7 @@ proc newVector*(x, y: CpFloat): TVector {.inline.} = var VectorZero* = newVector(0.0, 0.0) #/ Vector dot product. -proc dot*(v1, v2: TVector): CpFloat {.inline.} = +proc dot*(v1, v2: TVector): CpFloat {.inline.} = result = v1.x * v2.x + v1.y * v2.y #/ Returns the length of v. @@ -613,7 +613,7 @@ proc `-=`*(v1: var TVector; v2: TVector) = v1.y = v1.y - v2.y #/ Negate a vector. -proc `-`*(v: TVector): TVector {.inline.} = +proc `-`*(v: TVector): TVector {.inline.} = result = newVector(- v.x, - v.y) #/ Scalar multiplication. @@ -627,54 +627,54 @@ proc `*=`*(v: var TVector; s: CpFloat) = #/ 2D vector cross product analog. #/ The cross product of 2D vectors results in a 3D vector with only a z component. #/ This function returns the magnitude of the z value. -proc cross*(v1, v2: TVector): CpFloat {.inline.} = +proc cross*(v1, v2: TVector): CpFloat {.inline.} = result = v1.x * v2.y - v1.y * v2.x #/ Returns a perpendicular vector. (90 degree rotation) -proc perp*(v: TVector): TVector {.inline.} = +proc perp*(v: TVector): TVector {.inline.} = result = newVector(- v.y, v.x) #/ Returns a perpendicular vector. (-90 degree rotation) -proc rperp*(v: TVector): TVector {.inline.} = +proc rperp*(v: TVector): TVector {.inline.} = result = newVector(v.y, - v.x) #/ Returns the vector projection of v1 onto v2. -proc project*(v1,v2: TVector): TVector {.inline.} = +proc project*(v1,v2: TVector): TVector {.inline.} = result = v2 * (v1.dot(v2) / v2.dot(v2)) #/ Uses complex number multiplication to rotate v1 by v2. Scaling will occur if v1 is not a unit vector. -proc rotate*(v1, v2: TVector): TVector {.inline.} = +proc rotate*(v1, v2: TVector): TVector {.inline.} = result = newVector(v1.x * v2.x - v1.y * v2.y, v1.x * v2.y + v1.y * v2.x) #/ Inverse of cpvrotate(). -proc unrotate*(v1, v2: TVector): TVector {.inline.} = +proc unrotate*(v1, v2: TVector): TVector {.inline.} = result = newVector(v1.x * v2.x + v1.y * v2.y, v1.y * v2.x - v1.x * v2.y) #/ Returns the squared length of v. Faster than cpvlength() when you only need to compare lengths. -proc lenSq*(v: TVector): CpFloat {.inline.} = +proc lenSq*(v: TVector): CpFloat {.inline.} = result = v.dot(v) #/ Linearly interpolate between v1 and v2. -proc lerp*(v1, v2: TVector; t: CpFloat): TVector {.inline.} = +proc lerp*(v1, v2: TVector; t: CpFloat): TVector {.inline.} = result = (v1 * (1.0 - t)) + (v2 * t) #/ Returns a normalized copy of v. -proc normalize*(v: TVector): TVector {.inline.} = +proc normalize*(v: TVector): TVector {.inline.} = result = v * (1.0 / v.len) #/ Returns a normalized copy of v or cpvzero if v was already cpvzero. Protects against divide by zero errors. -proc normalizeSafe*(v: TVector): TVector {.inline.} = +proc normalizeSafe*(v: TVector): TVector {.inline.} = result = if v.x == 0.0 and v.y == 0.0: VectorZero else: v.normalize #/ Clamp v to length len. -proc clamp*(v: TVector; len: CpFloat): TVector {.inline.} = +proc clamp*(v: TVector; len: CpFloat): TVector {.inline.} = result = if v.dot(v) > len * len: v.normalize * len else: v #/ Linearly interpolate between v1 towards v2 by distance d. -proc lerpconst*(v1, v2: TVector; d: CpFloat): TVector {.inline.} = +proc lerpconst*(v1, v2: TVector; d: CpFloat): TVector {.inline.} = result = v1 + clamp(v2 - v1, d) #vadd(v1 + vclamp(vsub(v2, v1), d)) #/ Returns the distance between v1 and v2. -proc dist*(v1, v2: TVector): CpFloat {.inline.} = +proc dist*(v1, v2: TVector): CpFloat {.inline.} = result = (v1 - v2).len #vlength(vsub(v1, v2)) #/ Returns the squared distance between v1 and v2. Faster than cpvdist() when you only need to compare distances. -proc distsq*(v1, v2: TVector): CpFloat {.inline.} = +proc distsq*(v1, v2: TVector): CpFloat {.inline.} = result = (v1 - v2).lenSq #vlengthsq(vsub(v1, v2)) #/ Returns true if the distance between v1 and v2 is less than dist. -proc near*(v1, v2: TVector; dist: CpFloat): bool{.inline.} = +proc near*(v1, v2: TVector; dist: CpFloat): bool{.inline.} = result = v1.distSq(v2) < dist * dist @@ -706,13 +706,13 @@ proc Sleep*(body: PBody){.importc: "cpBodySleep", dynlib: Lib.} proc SleepWithGroup*(body: PBody; group: PBody){. importc: "cpBodySleepWithGroup", dynlib: Lib.} #/ Returns true if the body is sleeping. -proc isSleeping*(body: PBody): bool {.inline.} = +proc isSleeping*(body: PBody): bool {.inline.} = return body.node.root != nil #/ Returns true if the body is static. -proc isStatic*(body: PBody): bool {.inline.} = +proc isStatic*(body: PBody): bool {.inline.} = return body.node.idleTime == CpInfinity #/ Returns true if the body has not been added to a space. -proc isRogue*(body: PBody): bool {.inline.} = +proc isRogue*(body: PBody): bool {.inline.} = return body.space == nil # #define CP_DefineBodyStructGetter(type, member, name) \ @@ -740,7 +740,7 @@ defGetter(PBody, CpFloat, i, Moment) #/ Set the moment of a body. when defined(MoreNim): defSetter(PBody, CpFloat, i, Moment) -else: +else: proc SetMoment*(body: PBody; i: CpFloat) {. cdecl, importc: "cpBodySetMoment", dynlib: Lib.} @@ -775,10 +775,10 @@ proc UpdateVelocity*(body: PBody; gravity: TVector; damping: CpFloat; dt: CpFloa proc UpdatePosition*(body: PBody; dt: CpFloat){. cdecl, importc: "cpBodyUpdatePosition", dynlib: Lib.} #/ Convert body relative/local coordinates to absolute/world coordinates. -proc Local2World*(body: PBody; v: TVector): TVector{.inline.} = +proc Local2World*(body: PBody; v: TVector): TVector{.inline.} = result = body.p + v.rotate(body.rot) ##return cpvadd(body.p, cpvrotate(v, body.rot)) #/ Convert body absolute/world coordinates to relative/local coordinates. -proc world2Local*(body: PBody; v: TVector): TVector{.inline.} = +proc world2Local*(body: PBody; v: TVector): TVector{.inline.} = result = (v - body.p).unrotate(body.rot) #/ Set the forces and torque or a body to zero. proc resetForces*(body: PBody){. @@ -808,26 +808,26 @@ proc kineticEnergy*(body: PBOdy): CpFloat = result = (body.v.dot(body.v) * body.m) + (body.w * body.w * body.i) #/ Call @c func once for each shape attached to @c body and added to the space. -proc eachShape*(body: PBody; fun: TBodyShapeIteratorFunc; +proc eachShape*(body: PBody; fun: TBodyShapeIteratorFunc; data: pointer){. cdecl, importc: "cpBodyEachShape", dynlib: Lib.} #/ Call @c func once for each constraint attached to @c body and added to the space. -proc eachConstraint*(body: PBody; fun: TBodyConstraintIteratorFunc; +proc eachConstraint*(body: PBody; fun: TBodyConstraintIteratorFunc; data: pointer) {. cdecl, importc: "cpBodyEachConstraint", dynlib: Lib.} #/ Call @c func once for each arbiter that is currently active on the body. -proc eachArbiter*(body: PBody; fun: TBodyArbiterIteratorFunc; +proc eachArbiter*(body: PBody; fun: TBodyArbiterIteratorFunc; data: pointer){. cdecl, importc: "cpBodyEachArbiter", dynlib: Lib.} #/ Allocate a spatial hash. proc SpaceHashAlloc*(): PSpaceHash{. cdecl, importc: "cpSpaceHashAlloc", dynlib: Lib.} -#/ Initialize a spatial hash. -proc SpaceHashInit*(hash: PSpaceHash; celldim: CpFloat; numcells: cint; +#/ Initialize a spatial hash. +proc SpaceHashInit*(hash: PSpaceHash; celldim: CpFloat; numcells: cint; bbfun: TSpatialIndexBBFunc; staticIndex: PSpatialIndex): PSpatialIndex{. cdecl, importc: "cpSpaceHashInit", dynlib: Lib.} #/ Allocate and initialize a spatial hash. -proc SpaceHashNew*(celldim: CpFloat; cells: cint; bbfun: TSpatialIndexBBFunc; +proc SpaceHashNew*(celldim: CpFloat; cells: cint; bbfun: TSpatialIndexBBFunc; staticIndex: PSpatialIndex): PSpatialIndex{. cdecl, importc: "cpSpaceHashNew", dynlib: Lib.} #/ Change the cell dimensions and table size of the spatial hash to tune it. @@ -842,8 +842,8 @@ proc SpaceHashResize*(hash: PSpaceHash; celldim: CpFloat; numcells: cint){. #/ Allocate a bounding box tree. proc BBTreeAlloc*(): PBBTree{.cdecl, importc: "cpBBTreeAlloc", dynlib: Lib.} #/ Initialize a bounding box tree. -proc BBTreeInit*(tree: PBBTree; bbfun: TSpatialIndexBBFunc; - staticIndex: ptr TSpatialIndex): ptr TSpatialIndex{.cdecl, +proc BBTreeInit*(tree: PBBTree; bbfun: TSpatialIndexBBFunc; + staticIndex: ptr TSpatialIndex): ptr TSpatialIndex{.cdecl, importc: "cpBBTreeInit", dynlib: Lib.} #/ Allocate and initialize a bounding box tree. proc BBTreeNew*(bbfun: TSpatialIndexBBFunc; staticIndex: PSpatialIndex): PSpatialIndex{. @@ -860,12 +860,12 @@ proc BBTreeSetVelocityFunc*(index: PSpatialIndex; fun: TBBTreeVelocityFunc){. #/ Allocate a 1D sort and sweep broadphase. -proc Sweep1DAlloc*(): ptr TSweep1D{.cdecl, importc: "cpSweep1DAlloc", +proc Sweep1DAlloc*(): ptr TSweep1D{.cdecl, importc: "cpSweep1DAlloc", dynlib: Lib.} #/ Initialize a 1D sort and sweep broadphase. -proc Sweep1DInit*(sweep: ptr TSweep1D; bbfun: TSpatialIndexBBFunc; - staticIndex: ptr TSpatialIndex): ptr TSpatialIndex{.cdecl, +proc Sweep1DInit*(sweep: ptr TSweep1D; bbfun: TSpatialIndexBBFunc; + staticIndex: ptr TSpatialIndex): ptr TSpatialIndex{.cdecl, importc: "cpSweep1DInit", dynlib: Lib.} #/ Allocate and initialize a 1D sort and sweep broadphase. @@ -878,7 +878,7 @@ defProp(PArbiter, CpFloat, e, Elasticity) defProp(PArbiter, CpFloat, u, Friction) defProp(PArbiter, TVector, surface_vr, SurfaceVelocity) -#/ Calculate the total impulse that was applied by this +#/ Calculate the total impulse that was applied by this #/ This function should only be called from a post-solve, post-step or cpBodyEachArbiter callback. proc totalImpulse*(obj: PArbiter): TVector {.cdecl, importc: "cpArbiterTotalImpulse", dynlib: Lib.} @@ -917,7 +917,7 @@ template getShapes*(arb: PArbiter, name1, name2: expr): stmt {.immediate.} = #/ Return the colliding bodies involved for this arbiter. #/ The order of the cpSpace.collision_type the bodies are associated with values will match #/ the order set when the collision handler was registered. -#proc getBodies*(arb: PArbiter, a, b: var PBody) {.inline.} = +#proc getBodies*(arb: PArbiter, a, b: var PBody) {.inline.} = # getShapes(arb, shape1, shape2) # a = shape1.body # b = shape2.body @@ -981,7 +981,7 @@ proc segmentQuery*(shape: PShape, a, b: TVector, info: PSegmentQueryInfo): bool cdecl, importc: "cpShapeSegmentQuery", dynlib: Lib.} #/ Get the hit point for a segment query. -## Possibly change; info to PSegmentQueryInfo +## Possibly change; info to PSegmentQueryInfo proc queryHitPoint*(start, to: TVector, info: TSegmentQueryInfo): TVector {.inline.} = result = start.lerp(to, info.t) @@ -1035,7 +1035,7 @@ proc init*(poly: PPolyShape; body: PBody, numVerts: cint; cdecl, importc: "cpPolyShapeInit", dynlib: Lib.} #/ Allocate and initialize a polygon shape. #/ A convex hull will be created from the vertexes. -proc newPolyShape*(body: PBody; numVerts: cint; verts: ptr TVector; +proc newPolyShape*(body: PBody; numVerts: cint; verts: ptr TVector; offset: TVector): PShape {. cdecl, importc: "cpPolyShapeNew", dynlib: Lib.} #/ Initialize a box shaped polygon shape. @@ -1129,11 +1129,11 @@ proc MomentForBox2*(m: CpFloat; box: TBB): CpFloat {. ##constraints -type +type #TODO: all these are private #TODO: defConstraintProp() PPinJoint = ptr TPinJoint - TPinJoint{.pf.} = object + TPinJoint{.pf.} = object constraint: PConstraint anchr1: TVector anchr2: TVector @@ -1146,7 +1146,7 @@ type jnMax: CpFloat bias: CpFloat PSlideJoint = ptr TSlideJoint - TSlideJoint{.pf.} = object + TSlideJoint{.pf.} = object constraint: PConstraint anchr1: TVector anchr2: TVector @@ -1160,7 +1160,7 @@ type jnMax: CpFloat bias: CpFloat PPivotJoint = ptr TPivotJoint - TPivotJoint{.pf.} = object + TPivotJoint{.pf.} = object constraint: PConstraint anchr1: TVector anchr2: TVector @@ -1172,7 +1172,7 @@ type jMaxLen: CpFloat bias: TVector PGrooveJoint = ptr TGrooveJoint - TGrooveJoint{.pf.} = object + TGrooveJoint{.pf.} = object constraint: PConstraint grv_n: TVector grv_a: TVector @@ -1188,7 +1188,7 @@ type jMaxLen: CpFloat bias: TVector PDampedSpring = ptr TDampedSpring - TDampedSpring{.pf.} = object + TDampedSpring{.pf.} = object constraint: PConstraint anchr1: TVector anchr2: TVector @@ -1203,7 +1203,7 @@ type nMass: CpFloat n: TVector PDampedRotarySpring = ptr TDampedRotarySpring - TDampedRotarySpring{.pf.} = object + TDampedRotarySpring{.pf.} = object constraint: PConstraint restAngle: CpFloat stiffness: CpFloat @@ -1213,7 +1213,7 @@ type w_coef: CpFloat iSum: CpFloat PRotaryLimitJoint = ptr TRotaryLimitJoint - TRotaryLimitJoint{.pf.} = object + TRotaryLimitJoint{.pf.} = object constraint: PConstraint min: CpFloat max: CpFloat @@ -1222,7 +1222,7 @@ type jAcc: CpFloat jMax: CpFloat PRatchetJoint = ptr TRatchetJoint - TRatchetJoint{.pf.} = object + TRatchetJoint{.pf.} = object constraint: PConstraint angle: CpFloat phase: CpFloat @@ -1232,7 +1232,7 @@ type jAcc: CpFloat jMax: CpFloat PGearJoint = ptr TGearJoint - TGearJoint{.pf.} = object + TGearJoint{.pf.} = object constraint: PConstraint phase: CpFloat ratio: CpFloat @@ -1242,7 +1242,7 @@ type jAcc: CpFloat jMax: CpFloat PSimpleMotor = ptr TSimpleMotor - TSimpleMotor{.pf.} = object + TSimpleMotor{.pf.} = object constraint: PConstraint rate: CpFloat iSum: CpFloat @@ -1250,7 +1250,7 @@ type jMax: CpFloat TDampedSpringForceFunc* = proc (spring: PConstraint; dist: CpFloat): CpFloat{. cdecl.} - TDampedRotarySpringTorqueFunc* = proc (spring: PConstraint; + TDampedRotarySpringTorqueFunc* = proc (spring: PConstraint; relativeAngle: CpFloat): CpFloat {.cdecl.} #/ Destroy a constraint. proc destroy*(constraint: PConstraint){. @@ -1260,7 +1260,7 @@ proc free*(constraint: PConstraint){. cdecl, importc: "cpConstraintFree", dynlib: Lib.} #/ @private -proc activateBodies(constraint: PConstraint) {.inline.} = +proc activateBodies(constraint: PConstraint) {.inline.} = if not constraint.a.isNil: constraint.a.activate() if not constraint.b.isNil: constraint.b.activate() @@ -1291,7 +1291,7 @@ defGetter(PConstraint, TConstraintPreSolveFunc, preSolve, PreSolveFunc) defGetter(PConstraint, TConstraintPostSolveFunc, postSolve, PostSolveFunc) defGetter(PConstraint, CpDataPointer, data, UserData) # Get the last impulse applied by this constraint. -proc getImpulse*(constraint: PConstraint): CpFloat {.inline.} = +proc getImpulse*(constraint: PConstraint): CpFloat {.inline.} = return constraint.klass.getImpulse(constraint) # #define cpConstraintCheckCast(constraint, struct) \ @@ -1309,7 +1309,7 @@ proc getImpulse*(constraint: PConstraint): CpFloat {.inline.} = # } template constraintCheckCast(constraint: PConstraint, ctype: expr): stmt {.immediate.} = assert(constraint.klass == `ctype getClass`(), "Constraint is the wrong class") -template defCGetter(ctype: expr, memberType: typedesc, member: expr, name: expr): stmt {.immediate.} = +template defCGetter(ctype: expr, memberType: typedesc, member: expr, name: expr): stmt {.immediate.} = proc `get ctype name`*(constraint: PConstraint): memberType {.cdecl.} = constraintCheckCast(constraint, ctype) result = cast[`P ctype`](constraint).member @@ -1330,7 +1330,7 @@ proc PinJointGetClass*(): PConstraintClass{. proc AllocPinJoint*(): PPinJoint{. cdecl, importc: "cpPinJointAlloc", dynlib: Lib.} #/ Initialize a pin joint. -proc PinJointInit*(joint: PPinJoint; a: PBody; b: PBody; anchr1: TVector; +proc PinJointInit*(joint: PPinJoint; a: PBody; b: PBody; anchr1: TVector; anchr2: TVector): PPinJoint{. cdecl, importc: "cpPinJointInit", dynlib: Lib.} #/ Allocate and initialize a pin joint. @@ -1411,7 +1411,7 @@ proc init*(joint: PDampedSpring; a, b: PBody; anchr1, anchr2: TVector; restLength, stiffness, damping: CpFloat): PDampedSpring{. cdecl, importc: "cpDampedSpringInit", dynlib: Lib.} #/ Allocate and initialize a damped spring. -proc newDampedSpring*(a, b: PBody; anchr1, anchr2: TVector; +proc newDampedSpring*(a, b: PBody; anchr1, anchr2: TVector; restLength, stiffness, damping: CpFloat): PConstraint{. cdecl, importc: "cpDampedSpringNew", dynlib: Lib.} @@ -1431,7 +1431,7 @@ proc DampedRotarySpringGetClass*(): PConstraintClass{. proc DampedRotarySpringAlloc*(): PDampedRotarySpring{. cdecl, importc: "cpDampedRotarySpringAlloc", dynlib: Lib.} #/ Initialize a damped rotary spring. -proc init*(joint: PDampedRotarySpring; a, b: PBody; +proc init*(joint: PDampedRotarySpring; a, b: PBody; restAngle, stiffness, damping: CpFloat): PDampedRotarySpring{. cdecl, importc: "cpDampedRotarySpringInit", dynlib: Lib.} #/ Allocate and initialize a damped rotary spring. @@ -1477,7 +1477,7 @@ defCProp(RatchetJoint, CpFloat, phase, Phase) defCProp(RatchetJoint, CpFloat, ratchet, Ratchet) -proc GearJointGetClass*(): PConstraintClass{.cdecl, +proc GearJointGetClass*(): PConstraintClass{.cdecl, importc: "cpGearJointGetClass", dynlib: Lib.} #/ Allocate a gear joint. proc AllocGearJoint*(): PGearJoint{. @@ -1502,7 +1502,7 @@ proc SimpleMotorGetClass*(): PConstraintClass{. proc AllocSimpleMotor*(): PSimpleMotor{. cdecl, importc: "cpSimpleMotorAlloc", dynlib: Lib.} #/ initialize a simple motor. -proc init*(joint: PSimpleMotor; a, b: PBody; +proc init*(joint: PSimpleMotor; a, b: PBody; rate: CpFloat): PSimpleMotor{. cdecl, importc: "cpSimpleMotorInit", dynlib: Lib.} #/ Allocate and initialize a simple motor. diff --git a/tests/manyloc/keineschweine/dependencies/enet/enet.nim b/tests/manyloc/keineschweine/dependencies/enet/enet.nim index 93857207a2..3c4ce2017a 100644 --- a/tests/manyloc/keineschweine/dependencies/enet/enet.nim +++ b/tests/manyloc/keineschweine/dependencies/enet/enet.nim @@ -1,52 +1,52 @@ discard """Copyright (c) 2002-2012 Lee Salzman -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ const Lib = "libenet.so.1(|.0.3)" {.deadCodeElim: on.} -const +const ENET_VERSION_MAJOR* = 1 ENET_VERSION_MINOR* = 3 ENET_VERSION_PATCH* = 3 -template ENET_VERSION_CREATE(major, minor, patch: expr): expr = +template ENET_VERSION_CREATE(major, minor, patch: expr): expr = (((major) shl 16) or ((minor) shl 8) or (patch)) -const - ENET_VERSION* = ENET_VERSION_CREATE(ENET_VERSION_MAJOR, ENET_VERSION_MINOR, +const + ENET_VERSION* = ENET_VERSION_CREATE(ENET_VERSION_MAJOR, ENET_VERSION_MINOR, ENET_VERSION_PATCH) -type +type TVersion* = cuint - TSocketType*{.size: sizeof(cint).} = enum + TSocketType*{.size: sizeof(cint).} = enum ENET_SOCKET_TYPE_STREAM = 1, ENET_SOCKET_TYPE_DATAGRAM = 2 - TSocketWait*{.size: sizeof(cint).} = enum - ENET_SOCKET_WAIT_NONE = 0, ENET_SOCKET_WAIT_SEND = (1 shl 0), + TSocketWait*{.size: sizeof(cint).} = enum + ENET_SOCKET_WAIT_NONE = 0, ENET_SOCKET_WAIT_SEND = (1 shl 0), ENET_SOCKET_WAIT_RECEIVE = (1 shl 1) - TSocketOption*{.size: sizeof(cint).} = enum - ENET_SOCKOPT_NONBLOCK = 1, ENET_SOCKOPT_BROADCAST = 2, - ENET_SOCKOPT_RCVBUF = 3, ENET_SOCKOPT_SNDBUF = 4, + TSocketOption*{.size: sizeof(cint).} = enum + ENET_SOCKOPT_NONBLOCK = 1, ENET_SOCKOPT_BROADCAST = 2, + ENET_SOCKOPT_RCVBUF = 3, ENET_SOCKOPT_SNDBUF = 4, ENET_SOCKOPT_REUSEADDR = 5 -const +const ENET_HOST_ANY* = 0 ENET_HOST_BROADCAST* = 0xFFFFFFFF ENET_PORT_ANY* = 0 - + ENET_PROTOCOL_MINIMUM_MTU* = 576 ENET_PROTOCOL_MAXIMUM_MTU* = 4096 ENET_PROTOCOL_MAXIMUM_PACKET_COMMANDS* = 32 @@ -57,29 +57,29 @@ const ENET_PROTOCOL_MAXIMUM_PEER_ID* = 0x00000FFF type PAddress* = ptr TAddress - TAddress*{.pure, final.} = object + TAddress*{.pure, final.} = object host*: cuint port*: cushort - - TPacketFlag*{.size: sizeof(cint).} = enum - FlagReliable = (1 shl 0), - FlagUnsequenced = (1 shl 1), - NoAllocate = (1 shl 2), + + TPacketFlag*{.size: sizeof(cint).} = enum + FlagReliable = (1 shl 0), + FlagUnsequenced = (1 shl 1), + NoAllocate = (1 shl 2), UnreliableFragment = (1 shl 3) - - TENetListNode*{.pure, final.} = object + + TENetListNode*{.pure, final.} = object next*: ptr T_ENetListNode previous*: ptr T_ENetListNode PENetListIterator* = ptr TENetListNode - TENetList*{.pure, final.} = object + TENetList*{.pure, final.} = object sentinel*: TENetListNode - - T_ENetPacket*{.pure, final.} = object + + T_ENetPacket*{.pure, final.} = object TPacketFreeCallback* = proc (a2: ptr T_ENetPacket){.cdecl.} - + PPacket* = ptr TPacket - TPacket*{.pure, final.} = object + TPacket*{.pure, final.} = object referenceCount: csize flags*: cint data*: cstring#ptr cuchar @@ -87,13 +87,13 @@ type freeCallback*: TPacketFreeCallback PAcknowledgement* = ptr TAcknowledgement - TAcknowledgement*{.pure, final.} = object + TAcknowledgement*{.pure, final.} = object acknowledgementList*: TEnetListNode sentTime*: cuint command*: TEnetProtocol POutgoingCommand* = ptr TOutgoingCommand - TOutgoingCommand*{.pure, final.} = object + TOutgoingCommand*{.pure, final.} = object outgoingCommandList*: TEnetListNode reliableSequenceNumber*: cushort unreliableSequenceNumber*: cushort @@ -107,7 +107,7 @@ type packet*: PPacket PIncomingCommand* = ptr TIncomingCommand - TIncomingCommand*{.pure, final.} = object + TIncomingCommand*{.pure, final.} = object incomingCommandList*: TEnetListNode reliableSequenceNumber*: cushort unreliableSequenceNumber*: cushort @@ -117,52 +117,52 @@ type fragments*: ptr cuint packet*: ptr TPacket - TPeerState*{.size: sizeof(cint).} = enum - ENET_PEER_STATE_DISCONNECTED = 0, ENET_PEER_STATE_CONNECTING = 1, - ENET_PEER_STATE_ACKNOWLEDGING_CONNECT = 2, - ENET_PEER_STATE_CONNECTION_PENDING = 3, - ENET_PEER_STATE_CONNECTION_SUCCEEDED = 4, ENET_PEER_STATE_CONNECTED = 5, - ENET_PEER_STATE_DISCONNECT_LATER = 6, ENET_PEER_STATE_DISCONNECTING = 7, + TPeerState*{.size: sizeof(cint).} = enum + ENET_PEER_STATE_DISCONNECTED = 0, ENET_PEER_STATE_CONNECTING = 1, + ENET_PEER_STATE_ACKNOWLEDGING_CONNECT = 2, + ENET_PEER_STATE_CONNECTION_PENDING = 3, + ENET_PEER_STATE_CONNECTION_SUCCEEDED = 4, ENET_PEER_STATE_CONNECTED = 5, + ENET_PEER_STATE_DISCONNECT_LATER = 6, ENET_PEER_STATE_DISCONNECTING = 7, ENET_PEER_STATE_ACKNOWLEDGING_DISCONNECT = 8, ENET_PEER_STATE_ZOMBIE = 9 - - TENetProtocolCommand*{.size: sizeof(cint).} = enum - ENET_PROTOCOL_COMMAND_NONE = 0, ENET_PROTOCOL_COMMAND_ACKNOWLEDGE = 1, - ENET_PROTOCOL_COMMAND_CONNECT = 2, - ENET_PROTOCOL_COMMAND_VERIFY_CONNECT = 3, - ENET_PROTOCOL_COMMAND_DISCONNECT = 4, ENET_PROTOCOL_COMMAND_PING = 5, - ENET_PROTOCOL_COMMAND_SEND_RELIABLE = 6, - ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE = 7, - ENET_PROTOCOL_COMMAND_SEND_FRAGMENT = 8, - ENET_PROTOCOL_COMMAND_SEND_UNSEQUENCED = 9, - ENET_PROTOCOL_COMMAND_BANDWIDTH_LIMIT = 10, - ENET_PROTOCOL_COMMAND_THROTTLE_CONFIGURE = 11, - ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE_FRAGMENT = 12, + + TENetProtocolCommand*{.size: sizeof(cint).} = enum + ENET_PROTOCOL_COMMAND_NONE = 0, ENET_PROTOCOL_COMMAND_ACKNOWLEDGE = 1, + ENET_PROTOCOL_COMMAND_CONNECT = 2, + ENET_PROTOCOL_COMMAND_VERIFY_CONNECT = 3, + ENET_PROTOCOL_COMMAND_DISCONNECT = 4, ENET_PROTOCOL_COMMAND_PING = 5, + ENET_PROTOCOL_COMMAND_SEND_RELIABLE = 6, + ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE = 7, + ENET_PROTOCOL_COMMAND_SEND_FRAGMENT = 8, + ENET_PROTOCOL_COMMAND_SEND_UNSEQUENCED = 9, + ENET_PROTOCOL_COMMAND_BANDWIDTH_LIMIT = 10, + ENET_PROTOCOL_COMMAND_THROTTLE_CONFIGURE = 11, + ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE_FRAGMENT = 12, ENET_PROTOCOL_COMMAND_COUNT = 13, ENET_PROTOCOL_COMMAND_MASK = 0x0000000F - TENetProtocolFlag*{.size: sizeof(cint).} = enum + TENetProtocolFlag*{.size: sizeof(cint).} = enum ENET_PROTOCOL_HEADER_SESSION_SHIFT = 12, - ENET_PROTOCOL_COMMAND_FLAG_UNSEQUENCED = (1 shl 6), - ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE = (1 shl 7), - ENET_PROTOCOL_HEADER_SESSION_MASK = (3 shl 12), - ENET_PROTOCOL_HEADER_FLAG_COMPRESSED = (1 shl 14), + ENET_PROTOCOL_COMMAND_FLAG_UNSEQUENCED = (1 shl 6), + ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE = (1 shl 7), + ENET_PROTOCOL_HEADER_SESSION_MASK = (3 shl 12), + ENET_PROTOCOL_HEADER_FLAG_COMPRESSED = (1 shl 14), ENET_PROTOCOL_HEADER_FLAG_SENT_TIME = (1 shl 15), ENET_PROTOCOL_HEADER_FLAG_MASK = ENET_PROTOCOL_HEADER_FLAG_COMPRESSED.cint or ENET_PROTOCOL_HEADER_FLAG_SENT_TIME.cint - - TENetProtocolHeader*{.pure, final.} = object + + TENetProtocolHeader*{.pure, final.} = object peerID*: cushort sentTime*: cushort - TENetProtocolCommandHeader*{.pure, final.} = object + TENetProtocolCommandHeader*{.pure, final.} = object command*: cuchar channelID*: cuchar reliableSequenceNumber*: cushort - TENetProtocolAcknowledge*{.pure, final.} = object + TENetProtocolAcknowledge*{.pure, final.} = object header*: TENetProtocolCommandHeader receivedReliableSequenceNumber*: cushort receivedSentTime*: cushort - TENetProtocolConnect*{.pure, final.} = object + TENetProtocolConnect*{.pure, final.} = object header*: TENetProtocolCommandHeader outgoingPeerID*: cushort incomingSessionID*: cuchar @@ -178,7 +178,7 @@ type connectID*: cuint data*: cuint - TENetProtocolVerifyConnect*{.pure, final.} = object + TENetProtocolVerifyConnect*{.pure, final.} = object header*: TENetProtocolCommandHeader outgoingPeerID*: cushort incomingSessionID*: cuchar @@ -193,39 +193,39 @@ type packetThrottleDeceleration*: cuint connectID*: cuint - TENetProtocolBandwidthLimit*{.pure, final.} = object + TENetProtocolBandwidthLimit*{.pure, final.} = object header*: TENetProtocolCommandHeader incomingBandwidth*: cuint outgoingBandwidth*: cuint - TENetProtocolThrottleConfigure*{.pure, final.} = object + TENetProtocolThrottleConfigure*{.pure, final.} = object header*: TENetProtocolCommandHeader packetThrottleInterval*: cuint packetThrottleAcceleration*: cuint packetThrottleDeceleration*: cuint - TENetProtocolDisconnect*{.pure, final.} = object + TENetProtocolDisconnect*{.pure, final.} = object header*: TENetProtocolCommandHeader data*: cuint - TENetProtocolPing*{.pure, final.} = object + TENetProtocolPing*{.pure, final.} = object header*: TENetProtocolCommandHeader - TENetProtocolSendReliable*{.pure, final.} = object + TENetProtocolSendReliable*{.pure, final.} = object header*: TENetProtocolCommandHeader dataLength*: cushort - TENetProtocolSendUnreliable*{.pure, final.} = object + TENetProtocolSendUnreliable*{.pure, final.} = object header*: TENetProtocolCommandHeader unreliableSequenceNumber*: cushort dataLength*: cushort - TENetProtocolSendUnsequenced*{.pure, final.} = object + TENetProtocolSendUnsequenced*{.pure, final.} = object header*: TENetProtocolCommandHeader unsequencedGroup*: cushort dataLength*: cushort - TENetProtocolSendFragment*{.pure, final.} = object + TENetProtocolSendFragment*{.pure, final.} = object header*: TENetProtocolCommandHeader startSequenceNumber*: cushort dataLength*: cushort @@ -233,12 +233,12 @@ type fragmentNumber*: cuint totalLength*: cuint fragmentOffset*: cuint - + ## this is incomplete; need helper templates or something ## ENetProtocol - TENetProtocol*{.pure, final.} = object + TENetProtocol*{.pure, final.} = object header*: TENetProtocolCommandHeader -const +const ENET_BUFFER_MAXIMUM* = (1 + 2 * ENET_PROTOCOL_MAXIMUM_PACKET_COMMANDS) ENET_HOST_RECEIVE_BUFFER_SIZE = 256 * 1024 ENET_HOST_SEND_BUFFER_SIZE = 256 * 1024 @@ -270,39 +270,39 @@ when defined(Linux) or true: import posix const ENET_SOCKET_NULL*: cint = -1 - type + type TENetSocket* = cint PEnetBuffer* = ptr object - TENetBuffer*{.pure, final.} = object + TENetBuffer*{.pure, final.} = object data*: pointer dataLength*: csize TENetSocketSet* = Tfd_set ## see if these are different on win32, if not then get rid of these - template ENET_HOST_TO_NET_16*(value: expr): expr = + template ENET_HOST_TO_NET_16*(value: expr): expr = (htons(value)) - template ENET_HOST_TO_NET_32*(value: expr): expr = + template ENET_HOST_TO_NET_32*(value: expr): expr = (htonl(value)) - template ENET_NET_TO_HOST_16*(value: expr): expr = + template ENET_NET_TO_HOST_16*(value: expr): expr = (ntohs(value)) - template ENET_NET_TO_HOST_32*(value: expr): expr = + template ENET_NET_TO_HOST_32*(value: expr): expr = (ntohl(value)) - template ENET_SOCKETSET_EMPTY*(sockset: expr): expr = + template ENET_SOCKETSET_EMPTY*(sockset: expr): expr = FD_ZERO(addr((sockset))) - template ENET_SOCKETSET_ADD*(sockset, socket: expr): expr = + template ENET_SOCKETSET_ADD*(sockset, socket: expr): expr = FD_SET(socket, addr((sockset))) - template ENET_SOCKETSET_REMOVE*(sockset, socket: expr): expr = + template ENET_SOCKETSET_REMOVE*(sockset, socket: expr): expr = FD_CLEAR(socket, addr((sockset))) - template ENET_SOCKETSET_CHECK*(sockset, socket: expr): expr = + template ENET_SOCKETSET_CHECK*(sockset, socket: expr): expr = FD_ISSET(socket, addr((sockset))) when defined(Windows): ## put the content of win32.h in here -type +type PChannel* = ptr TChannel - TChannel*{.pure, final.} = object + TChannel*{.pure, final.} = object outgoingReliableSequenceNumber*: cushort outgoingUnreliableSequenceNumber*: cushort usedReliableWindows*: cushort @@ -313,7 +313,7 @@ type incomingUnreliableCommands*: TENetList PPeer* = ptr TPeer - TPeer*{.pure, final.} = object + TPeer*{.pure, final.} = object dispatchList*: TEnetListNode host*: ptr THost outgoingPeerID*: cushort @@ -367,25 +367,25 @@ type needsDispatch*: cint incomingUnsequencedGroup*: cushort outgoingUnsequencedGroup*: cushort - unsequencedWindow*: array[0..ENET_PEER_UNSEQUENCED_WINDOW_SIZE div 32 - 1, + unsequencedWindow*: array[0..ENET_PEER_UNSEQUENCED_WINDOW_SIZE div 32 - 1, cuint] eventData*: cuint PCompressor* = ptr TCompressor - TCompressor*{.pure, final.} = object + TCompressor*{.pure, final.} = object context*: pointer - compress*: proc (context: pointer; inBuffers: ptr TEnetBuffer; - inBufferCount: csize; inLimit: csize; + compress*: proc (context: pointer; inBuffers: ptr TEnetBuffer; + inBufferCount: csize; inLimit: csize; outData: ptr cuchar; outLimit: csize): csize{.cdecl.} - decompress*: proc (context: pointer; inData: ptr cuchar; inLimit: csize; + decompress*: proc (context: pointer; inData: ptr cuchar; inLimit: csize; outData: ptr cuchar; outLimit: csize): csize{.cdecl.} destroy*: proc (context: pointer){.cdecl.} TChecksumCallback* = proc (buffers: ptr TEnetBuffer; bufferCount: csize): cuint{. cdecl.} - + PHost* = ptr THost - THost*{.pure, final.} = object + THost*{.pure, final.} = object socket*: TEnetSocket address*: TAddress incomingBandwidth*: cuint @@ -402,14 +402,14 @@ type continueSending*: cint packetSize*: csize headerFlags*: cushort - commands*: array[0..ENET_PROTOCOL_MAXIMUM_PACKET_COMMANDS - 1, + commands*: array[0..ENET_PROTOCOL_MAXIMUM_PACKET_COMMANDS - 1, TEnetProtocol] commandCount*: csize buffers*: array[0..ENET_BUFFER_MAXIMUM - 1, TEnetBuffer] bufferCount*: csize checksum*: TChecksumCallback compressor*: TCompressor - packetData*: array[0..ENET_PROTOCOL_MAXIMUM_MTU - 1, + packetData*: array[0..ENET_PROTOCOL_MAXIMUM_MTU - 1, array[0..2 - 1, cuchar]] receivedAddress*: TAddress receivedData*: ptr cuchar @@ -418,19 +418,19 @@ type totalSentPackets*: cuint totalReceivedData*: cuint totalReceivedPackets*: cuint - - TEventType*{.size: sizeof(cint).} = enum - EvtNone = 0, EvtConnect = 1, + + TEventType*{.size: sizeof(cint).} = enum + EvtNone = 0, EvtConnect = 1, EvtDisconnect = 2, EvtReceive = 3 PEvent* = ptr TEvent - TEvent*{.pure, final.} = object + TEvent*{.pure, final.} = object kind*: TEventType peer*: ptr TPeer channelID*: cuchar data*: cuint packet*: ptr TPacket - TENetCallbacks*{.pure, final.} = object + TENetCallbacks*{.pure, final.} = object malloc*: proc (size: csize): pointer{.cdecl.} free*: proc (memory: pointer){.cdecl.} no_memory*: proc (){.cdecl.} @@ -473,10 +473,10 @@ proc send*(socket: TEnetSocket; address: var TAddress; buffer: ptr TEnetBuffer; importc: "enet_socket_send", dynlib: Lib.} proc send*(socket: TEnetSocket; address: ptr TAddress; buffer: ptr TEnetBuffer; size: csize): cint{. importc: "enet_socket_send", dynlib: Lib.} -proc receive*(socket: TEnetSocket; address: var TAddress; +proc receive*(socket: TEnetSocket; address: var TAddress; buffer: ptr TEnetBuffer; size: csize): cint{. importc: "enet_socket_receive", dynlib: Lib.} -proc receive*(socket: TEnetSocket; address: ptr TAddress; +proc receive*(socket: TEnetSocket; address: ptr TAddress; buffer: ptr TEnetBuffer; size: csize): cint{. importc: "enet_socket_receive", dynlib: Lib.} proc wait*(socket: TEnetSocket; a3: ptr cuint; a4: cuint): cint{. @@ -485,7 +485,7 @@ proc setOption*(socket: TEnetSocket; a3: TSocketOption; a4: cint): cint{. importc: "enet_socket_set_option", dynlib: Lib.} proc destroy*(socket: TEnetSocket){. importc: "enet_socket_destroy", dynlib: Lib.} -proc select*(socket: TEnetSocket; a3: ptr TENetSocketSet; +proc select*(socket: TEnetSocket; a3: ptr TENetSocketSet; a4: ptr TENetSocketSet; a5: cuint): cint{. importc: "enet_socketset_select", dynlib: Lib.} @@ -578,13 +578,13 @@ proc resetQueues*(peer: PPeer){. proc setupOutgoingCommand*(peer: PPeer; outgoingCommand: POutgoingCommand){. importc: "enet_peer_setup_outgoing_command", dynlib: Lib.} -proc queueOutgoingCommand*(peer: PPeer; command: ptr TEnetProtocol; +proc queueOutgoingCommand*(peer: PPeer; command: ptr TEnetProtocol; packet: PPacket; offset: cuint; length: cushort): POutgoingCommand{. importc: "enet_peer_queue_outgoing_command", dynlib: Lib.} -proc queueIncomingCommand*(peer: PPeer; command: ptr TEnetProtocol; +proc queueIncomingCommand*(peer: PPeer; command: ptr TEnetProtocol; packet: PPacket; fragmentCount: cuint): PIncomingCommand{. importc: "enet_peer_queue_incoming_command", dynlib: Lib.} -proc queueAcknowledgement*(peer: PPeer; command: ptr TEnetProtocol; +proc queueAcknowledgement*(peer: PPeer; command: ptr TEnetProtocol; sentTime: cushort): PAcknowledgement{. importc: "enet_peer_queue_acknowledgement", dynlib: Lib.} proc dispatchIncomingUnreliableCommands*(peer: PPeer; channel: PChannel){. @@ -596,10 +596,10 @@ proc createRangeCoder*(): pointer{. importc: "enet_range_coder_create", dynlib: Lib.} proc rangeCoderDestroy*(context: pointer){. importc: "enet_range_coder_destroy", dynlib: Lib.} -proc rangeCoderCompress*(context: pointer; inBuffers: PEnetBuffer; inLimit, +proc rangeCoderCompress*(context: pointer; inBuffers: PEnetBuffer; inLimit, bufferCount: csize; outData: cstring; outLimit: csize): csize{. importc: "enet_range_coder_compress", dynlib: Lib.} -proc rangeCoderDecompress*(context: pointer; inData: cstring; inLimit: csize; +proc rangeCoderDecompress*(context: pointer; inData: cstring; inLimit: csize; outData: cstring; outLimit: csize): csize{. importc: "enet_range_coder_decompress", dynlib: Lib.} proc protocolCommandSize*(commandNumber: cuchar): csize{. diff --git a/tests/manyloc/keineschweine/dependencies/enet/testserver.nim b/tests/manyloc/keineschweine/dependencies/enet/testserver.nim index 28a6bd1f72..6d6de90c1b 100644 --- a/tests/manyloc/keineschweine/dependencies/enet/testserver.nim +++ b/tests/manyloc/keineschweine/dependencies/enet/testserver.nim @@ -19,11 +19,11 @@ while server.hostService(addr event, 2500) >= 0: case event.kind of EvtConnect: echo "New client from $1:$2".format(event.peer.address.host, event.peer.address.port) - + var - msg = "hello" + msg = "hello" resp = createPacket(cstring(msg), msg.len + 1, FlagReliable) - + if event.peer.send(0.cuchar, resp) < 0: echo "FAILED" else: @@ -32,9 +32,9 @@ while server.hostService(addr event, 2500) >= 0: echo "Recvd ($1) $2 ".format( event.packet.dataLength, event.packet.data) - + destroy(event.packet) - + of EvtDisconnect: echo "Disconnected" event.peer.data = nil @@ -42,4 +42,4 @@ while server.hostService(addr event, 2500) >= 0: discard server.destroy() -enetDeinit() \ No newline at end of file +enetDeinit() diff --git a/tests/manyloc/keineschweine/dependencies/genpacket/streams_enh.nim b/tests/manyloc/keineschweine/dependencies/genpacket/streams_enh.nim index 3c5a7835c6..5a1dffc93d 100644 --- a/tests/manyloc/keineschweine/dependencies/genpacket/streams_enh.nim +++ b/tests/manyloc/keineschweine/dependencies/genpacket/streams_enh.nim @@ -1,7 +1,7 @@ import streams from strutils import repeat -proc readPaddedStr*(s: PStream, length: int, padChar = '\0'): TaintedString = +proc readPaddedStr*(s: PStream, length: int, padChar = '\0'): TaintedString = var lastChr = length result = s.readStr(length) while lastChr >= 0 and result[lastChr - 1] == padChar: dec(lastChr) @@ -26,22 +26,22 @@ proc writeLEStr*(s: PStream, str: string) = when isMainModule: var testStream = newStringStream() - + testStream.writeLEStr("Hello") doAssert testStream.data == "\5\0Hello" - + testStream.setPosition 0 var res = testStream.readLEStr() doAssert res == "Hello" - + testStream.setPosition 0 testStream.writePaddedStr("Sup", 10) echo(repr(testStream), testStream.data.len) doAssert testStream.data == "Sup"&repeat('\0', 7) - + testStream.setPosition 0 res = testStream.readPaddedStr(10) doAssert res == "Sup" - + testStream.close() diff --git a/tests/manyloc/keineschweine/dependencies/nake/nake.nim b/tests/manyloc/keineschweine/dependencies/nake/nake.nim index 5828e400c7..5341c10797 100644 --- a/tests/manyloc/keineschweine/dependencies/nake/nake.nim +++ b/tests/manyloc/keineschweine/dependencies/nake/nake.nim @@ -3,7 +3,7 @@ DO AS THOU WILST PUBLIC LICENSE Whoever should stumble upon this document is henceforth and forever entitled to DO AS THOU WILST with aforementioned document and the -contents thereof. +contents thereof. As said in the Olde Country, `Keepe it Gangster'.""" @@ -14,7 +14,7 @@ type desc*: string action*: TTaskFunction TTaskFunction* = proc() {.closure.} -var +var tasks* = initTable[string, PTask](16) proc newTask*(desc: string; action: TTaskFunction): PTask @@ -61,7 +61,7 @@ when isMainModule: quit(shell("nim", "c", "-r", "nakefile.nim", args)) else: addQuitProc(proc() {.noconv.} = - var + var task: string printTaskList: bool for kind, key, val in getOpt(): @@ -70,7 +70,7 @@ else: case key.tolower of "tasks", "t": printTaskList = true - else: + else: echo "Unknown option: ", key, ": ", val of cmdArgument: task = key diff --git a/tests/manyloc/keineschweine/dependencies/sfml/sfml.nim b/tests/manyloc/keineschweine/dependencies/sfml/sfml.nim index 1071ec767c..1524f0eb46 100644 --- a/tests/manyloc/keineschweine/dependencies/sfml/sfml.nim +++ b/tests/manyloc/keineschweine/dependencies/sfml/sfml.nim @@ -1,4 +1,4 @@ -import +import strutils, math when defined(linux): const @@ -27,7 +27,7 @@ type x*, y*, z*: cfloat PInputStream* = ptr TInputStream - TInputStream* {.pf.} = object + TInputStream* {.pf.} = object read*: TInputStreamReadFunc seek*: TInputStreamSeekFunc tell*: TInputStreamTellFunc @@ -52,14 +52,14 @@ type width*: cint height*: cint bitsPerPixel*: cint - TEventType*{.size: sizeof(cint).} = enum - EvtClosed, EvtResized, EvtLostFocus, EvtGainedFocus, - EvtTextEntered, EvtKeyPressed, EvtKeyReleased, EvtMouseWheelMoved, - EvtMouseButtonPressed, EvtMouseButtonReleased, EvtMouseMoved, - EvtMouseEntered, EvtMouseLeft, EvtJoystickButtonPressed, - EvtJoystickButtonReleased, EvtJoystickMoved, EvtJoystickConnected, + TEventType*{.size: sizeof(cint).} = enum + EvtClosed, EvtResized, EvtLostFocus, EvtGainedFocus, + EvtTextEntered, EvtKeyPressed, EvtKeyReleased, EvtMouseWheelMoved, + EvtMouseButtonPressed, EvtMouseButtonReleased, EvtMouseMoved, + EvtMouseEntered, EvtMouseLeft, EvtJoystickButtonPressed, + EvtJoystickButtonReleased, EvtJoystickMoved, EvtJoystickConnected, EvtJoystickDisconnected - TKeyEvent*{.pf.} = object + TKeyEvent*{.pf.} = object code*: TKeyCode alt* : bool control*: bool @@ -74,7 +74,7 @@ type joystickId*: cint axis*: TJoystickAxis position*: cfloat - TMouseWheelEvent*{.pf.} = object + TMouseWheelEvent*{.pf.} = object delta*: cint x*: cint y*: cint @@ -90,7 +90,7 @@ type PEvent* = ptr TEvent TEvent*{.pf.} = object case kind*: TEventType - of EvtKeyPressed, EvtKeyReleased: + of EvtKeyPressed, EvtKeyReleased: key*: TKeyEvent of EvtMouseButtonPressed, EvtMouseButtonReleased: mouseButton*: TMouseButtonEvent @@ -109,16 +109,16 @@ type of EvtMouseWheelMoved: mouseWheel*: TMouseWheelEvent else: nil - TJoystickAxis*{.size: sizeof(cint).} = enum - JoystickX, JoystickY, JoystickZ, JoystickR, + TJoystickAxis*{.size: sizeof(cint).} = enum + JoystickX, JoystickY, JoystickZ, JoystickR, JoystickU, JoystickV, JoystickPovX, JoystickPovY TSizeEvent*{.pf.} = object width*: cint height*: cint - TMouseButton*{.size: sizeof(cint).} = enum - MouseLeft, MouseRight, MouseMiddle, + TMouseButton*{.size: sizeof(cint).} = enum + MouseLeft, MouseRight, MouseMiddle, MouseXButton1, MouseXButton2, MouseButtonCount - TKeyCode*{.size: sizeof(cint).} = enum + TKeyCode*{.size: sizeof(cint).} = enum KeyUnknown = - 1, KeyA, KeyB, KeyC, KeyD, KeyE, KeyF, KeyG, KeyH, KeyI, KeyJ, KeyK, KeyL, KeyM, #/< The M key KeyN, KeyO, KeyP, KeyQ, KeyR, KeyS, KeyT, KeyU, #/< The U key @@ -204,11 +204,11 @@ type PConvexShape* = ptr TConvexShape TConvexShape* {.pf.} = object - TTextStyle*{.size: sizeof(cint).} = enum - TextRegular = 0, TextBold = 1 shl 0, TextItalic = 1 shl 1, + TTextStyle*{.size: sizeof(cint).} = enum + TextRegular = 0, TextBold = 1 shl 0, TextItalic = 1 shl 1, TextUnderlined = 1 shl 2 - TBlendMode*{.size: sizeof(cint).} = enum + TBlendMode*{.size: sizeof(cint).} = enum BlendAlpha, BlendAdd, BlendMultiply, BlendNone PRenderStates* = ptr TRenderStates TRenderStates* {.pf.} = object @@ -220,19 +220,19 @@ type PTransform* = ptr TTransform TTransform* {.pf.} = object matrix*: array[0..8, cfloat] - TColor* {.pf.} = object + TColor* {.pf.} = object r*: uint8 g*: uint8 b*: uint8 a*: uint8 PFloatRect* = ptr TFloatRect - TFloatRect*{.pf.} = object + TFloatRect*{.pf.} = object left*: cfloat top*: cfloat width*: cfloat height*: cfloat PIntRect* = ptr TIntRect - TIntRect*{.pf.} = object + TIntRect*{.pf.} = object left*: cint top*: cint width*: cint @@ -246,7 +246,7 @@ type position*: TVector2f color*: TColor texCoords*: TVector2f - TPrimitiveType*{.size: sizeof(cint).} = enum + TPrimitiveType*{.size: sizeof(cint).} = enum Points, #/< List of individual points Lines, #/< List of individual lines LinesStrip, #/< List of connected lines, a point uses the previous point to form a line @@ -381,7 +381,7 @@ proc draw*(window: PRenderWindow, shape: PConvexShape, states: PRenderStates = n cdecl, importc: "sfRenderWindow_drawConvexShape", dynlib: LibG.} proc draw*(window: PRenderWindow, shape: PVertexArray, states: PRenderStates = nil) {. cdecl, importc: "sfRenderWindow_drawVertexArray", dynlib: LibG.} -proc draw*(window: PRenderWindow, vertices: PVertex, vertexCount: cint, +proc draw*(window: PRenderWindow, vertices: PVertex, vertexCount: cint, vertexType: TPrimitiveType, states: PRenderStates = nil) {. cdecl, importc: "sfRenderWindow_drawPrimitives", dynlib: LibG.} @@ -434,20 +434,20 @@ proc draw*(renderTexture: PRenderTexture; text: PText; states: PRenderStates){. cdecl, importc: "sfRenderTexture_drawText", dynlib: LibG.} proc draw*(renderTexture: PRenderTexture; shape: PShape; states: PRenderStates){. cdecl, importc: "sfRenderTexture_drawShape", dynlib: LibG.} -proc draw*(renderTexture: PRenderTexture; shape: PCircleShape; +proc draw*(renderTexture: PRenderTexture; shape: PCircleShape; states: PRenderStates){. cdecl, importc: "sfRenderTexture_drawCircleShape", dynlib: LibG.} -proc draw*(renderTexture: PRenderTexture; shape: PConvexShape; +proc draw*(renderTexture: PRenderTexture; shape: PConvexShape; states: PRenderStates){. cdecl, importc: "sfRenderTexture_drawConvexShape", dynlib: LibG.} -proc draw*(renderTexture: PRenderTexture; shape: PRectangleShape; +proc draw*(renderTexture: PRenderTexture; shape: PRectangleShape; states: PRenderStates){. cdecl, importc: "sfRenderTexture_drawRectangleShape", dynlib: LibG.} -proc draw*(renderTexture: PRenderTexture; va: PVertexArray; +proc draw*(renderTexture: PRenderTexture; va: PVertexArray; states: PRenderStates){. cdecl, importc: "sfRenderTexture_drawVertexArray", dynlib: LibG.} #Draw primitives defined by an array of vertices to a render texture -proc draw*(renderTexture: PRenderTexture; vertices: PVertex; vertexCount: cint; +proc draw*(renderTexture: PRenderTexture; vertices: PVertex; vertexCount: cint; primitiveType: TPrimitiveType; states: PRenderStates){. cdecl, importc: "sfRenderTexture_drawPrimitives", dynlib: LibG.} #Save the current OpenGL render states and matrices @@ -500,12 +500,12 @@ proc intRect*(left, top, width, height: cint): TIntRect = result.height = height proc floatRect*(left, top, width, height: cfloat): TFloatRect = result.left = left - result.top = top + result.top = top result.width = width result.height = height proc contains*(rect: PFloatRect, x, y: cfloat): bool {. cdecl, importc: "sfFloatRect_contains", dynlib: LibG.} -proc contains*(rect: PIntRect, x: cint, y: cint): bool{.cdecl, +proc contains*(rect: PIntRect, x: cint, y: cint): bool{.cdecl, importc: "sfIntRect_contains", dynlib: LibG.} proc intersects*(rect1, rect2, intersection: PFloatRect): bool {. cdecl, importc: "sfFloatRect_intersects", dynlib: LibG.} @@ -894,7 +894,7 @@ proc setColor*(text: PText, color: TColor) {. cdecl, importc: "sfText_setColor", dynlib: LibG.} proc getString*(text: PText): cstring {. cdecl, importc: "sfText_getString", dynlib: LibG.} -proc getUnicodeString*(text: PText): ptr uint32 {.cdecl, +proc getUnicodeString*(text: PText): ptr uint32 {.cdecl, importc: "sfText_getUnicodeString", dynlib: LibG.} proc getFont*(text: PText): PFont {. cdecl, importc: "sfText_getFont", dynlib: LibG.} @@ -985,7 +985,7 @@ proc `*`*(color1, color2: TColor): TColor {. cdecl, importc: "sfColor_modulate", dynlib: LibG.} proc newColor*(r,g,b: int): TColor {.inline.} = return color(r,g,b) -proc newColor*(r,g,b,a: int): TColor {.inline.} = +proc newColor*(r,g,b,a: int): TColor {.inline.} = return color(r,g,b,a) proc newClock*(): PClock {. @@ -1022,7 +1022,7 @@ proc newContextSettings*(depthBits: cint = 0, result.majorVersion = majorVersion result.minorVersion = minorVersion -proc newCircleShape*(radius: cfloat; pointCount: cint = 30): PCircleShape = +proc newCircleShape*(radius: cfloat; pointCount: cint = 30): PCircleShape = result = newCircleShape() result.setRadius radius result.setPointCount pointCount @@ -1047,13 +1047,13 @@ proc `[]`*(a: PVertexArray, index: int): PVertex = proc `$` *(a: TContextSettings): string = return "" % [ $a.stencilBits, $a.antialiasingLevel, $a.majorVersion, $a.minorVersion, $a.depthBits] -proc `$` *(a: TVideoMode): string = +proc `$` *(a: TVideoMode): string = return "" % [$a.width, $a.height, $a.bitsPerPixel] -proc `$` *(a: TFloatRect): string = +proc `$` *(a: TFloatRect): string = return "" % [$a.left, $a.top, $a.width, $a.height] -proc `$` *(a: PView): string = +proc `$` *(a: PView): string = return $a.getViewport() -proc `$` *(a: TVector2f): string = +proc `$` *(a: TVector2f): string = return "" % [$a.x, $a.y] proc vec2i*(x, y: int): TVector2i = diff --git a/tests/manyloc/keineschweine/dependencies/sfml/sfml_audio.nim b/tests/manyloc/keineschweine/dependencies/sfml/sfml_audio.nim index 5aa017ac42..6f81e50a3a 100644 --- a/tests/manyloc/keineschweine/dependencies/sfml/sfml_audio.nim +++ b/tests/manyloc/keineschweine/dependencies/sfml/sfml_audio.nim @@ -294,7 +294,7 @@ proc newSoundBuffer*(stream: PInputStream): PSoundBuffer{. #/ \return A new sfSoundBuffer object (NULL if failed) #/ #////////////////////////////////////////////////////////// -proc createFromSamples*(samples: ptr int16; sampleCount: cuint; +proc createFromSamples*(samples: ptr int16; sampleCount: cuint; channelCount: cuint; sampleRate: cuint): PSoundBuffer{. cdecl, importc: "sfSoundBuffer_createFromSamples", dynlib: Lib.} #////////////////////////////////////////////////////////// @@ -437,10 +437,10 @@ proc listenerSetDirection*(orientation: TVector3f){. proc listenerGetDirection*(): TVector3f{. cdecl, importc: "sfListener_getDirection", dynlib: Lib.} -type +type TSoundRecorderStartCallback* = proc (a2: pointer): bool {.cdecl.} - #/< Type of the callback used when starting a capture - TSoundRecorderProcessCallback* = proc(a2: ptr int16; a3: cuint; + #/< Type of the callback used when starting a capture + TSoundRecorderProcessCallback* = proc(a2: ptr int16; a3: cuint; a4: pointer): bool {.cdecl.} #/< Type of the callback used to process audio data TSoundRecorderStopCallback* = proc (a2: pointer){.cdecl.} @@ -456,9 +456,9 @@ type #/ \return A new sfSoundRecorder object (NULL if failed) #/ #////////////////////////////////////////////////////////// -proc newSoundRecorder*(onStart: TSoundRecorderStartCallback; - onProcess: TSoundRecorderProcessCallback; - onStop: TSoundRecorderStopCallback; +proc newSoundRecorder*(onStart: TSoundRecorderStartCallback; + onProcess: TSoundRecorderProcessCallback; + onStop: TSoundRecorderStopCallback; userData: pointer = nil): PSoundRecorder{. cdecl, importc: "sfSoundRecorder_create", dynlib: Lib.} #////////////////////////////////////////////////////////// @@ -595,13 +595,13 @@ proc getBuffer*(soundBufferRecorder: PSoundBufferRecorder): PSoundBuffer{. #/ \brief defines the data to fill by the OnGetData callback #/ #////////////////////////////////////////////////////////// -type +type PSoundStreamChunk* = ptr TSoundStreamChunk - TSoundStreamChunk*{.pure, final.} = object + TSoundStreamChunk*{.pure, final.} = object samples*: ptr int16 #/< Pointer to the audio samples sampleCount*: cuint #/< Number of samples pointed by Samples - - TSoundStreamGetDataCallback* = proc (a2: PSoundStreamChunk; + + TSoundStreamGetDataCallback* = proc (a2: PSoundStreamChunk; a3: pointer): bool{.cdecl.} #/< Type of the callback used to get a sound stream data TSoundStreamSeekCallback* = proc (a2: TTime; a3: pointer){.cdecl.} @@ -618,7 +618,7 @@ type #/ \return A new sfSoundStream object #/ #////////////////////////////////////////////////////////// -proc create*(onGetData: TSoundStreamGetDataCallback; onSeek: TSoundStreamSeekCallback; +proc create*(onGetData: TSoundStreamGetDataCallback; onSeek: TSoundStreamSeekCallback; channelCount: cuint; sampleRate: cuint; userData: pointer): PSoundStream{. cdecl, importc: "sfSoundStream_create", dynlib: Lib.} #////////////////////////////////////////////////////////// diff --git a/tests/manyloc/keineschweine/dependencies/sfml/sfml_colors.nim b/tests/manyloc/keineschweine/dependencies/sfml/sfml_colors.nim index 31473b17ab..95a760e1ff 100644 --- a/tests/manyloc/keineschweine/dependencies/sfml/sfml_colors.nim +++ b/tests/manyloc/keineschweine/dependencies/sfml/sfml_colors.nim @@ -12,4 +12,4 @@ let Transparent*: TColor = color(0, 0, 0, 0) Gray* = color(84, 84, 84) RoyalBlue* = color(65, 105, 225) -##todo: define more colors lul \ No newline at end of file +##todo: define more colors lul diff --git a/tests/manyloc/keineschweine/enet_server/enet_client.nim b/tests/manyloc/keineschweine/enet_server/enet_client.nim index 5ebbdb88b5..ac600c0af9 100644 --- a/tests/manyloc/keineschweine/enet_server/enet_client.nim +++ b/tests/manyloc/keineschweine/enet_server/enet_client.nim @@ -78,11 +78,11 @@ proc poll(serv: PServer; timeout: cuint = 30) = case event.kind of EvtReceive: var buf = newBuffer(event.packet) - + serv.handlePackets(buf) - + event.packet.destroy() - of EvtDisconnect: + of EvtDisconnect: dispMessage "Disconnected" serv.connected = false event.peer.data = nil @@ -111,8 +111,8 @@ proc tryConnect*(b: PButton) = if not dirServer.connected: var error: string if not dirServer.connect( - clientSettings.dirServer.host, - clientSettings.dirServer.port, + clientSettings.dirServer.host, + clientSettings.dirServer.port, error): dispError(error) else: @@ -143,16 +143,16 @@ proc lobbyInit*() = clientSettings.website = s["website"].str zonelist.setPosition(vec2f(200.0, 100.0)) connectionButtons = @[] - + var pos = vec2f(10, 10) u_alias = gui.newTextEntry( - if s.hasKey("alias"): s["alias"].str else: "alias", + if s.hasKey("alias"): s["alias"].str else: "alias", pos) pos.y += 20 u_passwd = gui.newTextEntry("buzz", pos) pos.y += 20 connectionButtons.add(gui.newButton( - text = "Login", + text = "Login", position = pos, onClick = tryLogin, startEnabled = false)) @@ -171,16 +171,16 @@ proc lobbyInit*() = connectionButtons.add(gui.newButton( text = "Test Chat", position = pos, - onClick = (proc(b: PButton) = + onClick = (proc(b: PButton) = var pkt = newCsChat(text = "ohai") dirServer.send HChat, pkt), startEnabled = false)) pos.y += 20 - downloadProgress.setPosition(pos) + downloadProgress.setPosition(pos) downloadProgress.bg.setFillColor(color(34, 139, 34)) downloadProgress.bg.setSize(vec2f(0, 0)) gui.add(downloadProgress) - + playBtn = gui.newButton( text = "Play", position = vec2f(680.0, 8.0), @@ -193,20 +193,20 @@ proc lobbyInit*() = discard """gui.newButton(text = "Scrollback + 1", position = vec2f(185, 10), onClick = proc(b: PButton) = messageArea.scrollBack += 1 update(messageArea)) - gui.newButton(text = "Scrollback - 1", position = vec2f(185+160, 10), onClick = proc(b: PButton) = + gui.newButton(text = "Scrollback - 1", position = vec2f(185+160, 10), onClick = proc(b: PButton) = messageArea.scrollBack -= 1 update(messageArea)) gui.newButton(text = "Flood msg area", position = vec2f(185, 30), onClick = proc(b: PButton) = - for i in 0.. <30: + for i in 0.. <30: dispMessage($i))""" - dirServer = newServer() + dirServer = newServer() dirServer.addHandler HChat, handleChat dirServer.addHandler HLogin, handlePlayerLogin dirServer.addHandler HFileTransfer, client_helpers.handleFilePartRecv dirServer.addHandler HChallengeResult, client_helpers.handleFileChallengeResult dirServer.addHandler HFileChallenge, client_helpers.handleFileChallenge -proc lobbyReady*() = +proc lobbyReady*() = kc.setActive() gui.setActive(u_alias) diff --git a/tests/manyloc/keineschweine/enet_server/enet_server.nim b/tests/manyloc/keineschweine/enet_server/enet_server.nim index c2e8932733..eae7c034ef 100644 --- a/tests/manyloc/keineschweine/enet_server/enet_server.nim +++ b/tests/manyloc/keineschweine/enet_server/enet_server.nim @@ -1,4 +1,4 @@ -import enet, strutils, idgen, tables, math_helpers, +import enet, strutils, idgen, tables, math_helpers, estreams, sg_packets, server_utils, sg_assets, client_helpers when appType == "gui": import sfml, sfml_colors, sg_gui, @@ -14,7 +14,7 @@ var event: enet.TEvent clientID = newIDGen[int32]() clients = initTable[int32, PClient](64) - handlers = initTable[char, TCallback](32) + handlers = initTable[char, TCallback](32) when appType == "gui": var @@ -67,7 +67,7 @@ proc flushPubChat() = handlers[HChat] = proc(client: PClient; buffer: PBuffer) = var chat = readCsChat(buffer) - + if not client.auth: client.sendError("You are not logged in.") return @@ -75,7 +75,7 @@ handlers[HChat] = proc(client: PClient; buffer: PBuffer) = # if alias2client.hasKey(chat.target): # alias2client[chat.target].forwardPrivate(client, chat.text) #else: - + dispmessage("<", client.alias, "> ", chat.text) queuePub(client, chat) @@ -104,20 +104,20 @@ handlers[HZoneJoinReq] = proc(client: PClient; buffer: PBuffer) = when isMainModule: import parseopt, matchers, os, json - - + + if enetInit() != 0: quit "Could not initialize ENet" - + var address: enet.TAddress - + block: var zoneCfgFile = "./server_settings.json" for kind, key, val in getOpt(): case kind of cmdShortOption, cmdLongOption: case key - of "f", "file": + of "f", "file": if existsFile(val): zoneCfgFile = val else: @@ -127,45 +127,45 @@ when isMainModule: else: echo("Unknown option: ", key, " ", val) var jsonSettings = parseFile(zoneCfgFile) - let + let port = uint16(jsonSettings["port"].num) zoneFile = jsonSettings["settings"].str dirServerInfo = jsonSettings["dirserver"] - + address.host = EnetHostAny address.port = port - + var path = getAppDir()/../"data"/zoneFile if not existsFile(path): echo("Zone settings file does not exist: ../data/", zoneFile) echo(path) quit(1) - + discard """block: - var + var TestFile: FileChallengePair contents = repeat("abcdefghijklmnopqrstuvwxyz", 2) - testFile.challenge = newScFileChallenge("foobar.test", FZoneCfg, contents.len.int32) + testFile.challenge = newScFileChallenge("foobar.test", FZoneCfg, contents.len.int32) testFile.file = checksumStr(contents) myAssets.add testFile""" - + setCurrentDir getAppDir().parentDir() let zonesettings = readFile(path) - var + var errors: seq[string] = @[] if not loadSettings(zoneSettings, errors): echo("You have errors in your zone settings:") for e in errors: echo("**", e) quit(1) errors.setLen 0 - + var pair: FileChallengePair pair.challenge.file = zoneFile pair.challenge.assetType = FZoneCfg pair.challenge.fullLen = zoneSettings.len.int32 pair.file = checksumStr(zoneSettings) myAssets.add pair - + allAssets: if not load(asset): echo "Invalid or missing file ", file @@ -177,11 +177,11 @@ when isMainModule: expandPath(assetType, file)).int32 pair.file = asset.contents myAssets.add pair - + echo "Zone has ", myAssets.len, " associated assets" - + dirServer = newServer() - + dirServer.addHandler HDsMsg, proc(serv: PServer; buffer: PBuffer) = var m = readDsMsg(buffer) dispMessage(" ", m.msg) @@ -189,20 +189,20 @@ when isMainModule: let loggedIn = readDsZoneLogin(buffer).status if loggedIn: #dirServerConnected = true - + if dirServerInfo.kind == JArray: var error: string if not dirServer.connect(dirServerInfo[0].str, dirServerInfo[1].num.int16, error): dispError(" "&error) - - + + server = enet.createHost(address, 32, 2, 0, 0) if server == nil: quit "Could not create the server!" - + dispMessage("Listening on port ", address.port) - - var + + var serverRunning = true when appType == "gui": var frameRate = newClock() @@ -210,11 +210,11 @@ when isMainModule: else: var frameRate = epochTime() var pubChatDelay = frameRate - + while serverRunning: when appType == "gui": let dt = frameRate.restart.asMilliseconds().float / 1000.0 - + for event in window.filterEvents(): case event.kind of sfml.EvtClosed: @@ -225,7 +225,7 @@ when isMainModule: else: let dt = epochTime() - frameRate ##is this right? probably not frameRate = epochTime() - + while server.hostService(event, 10) > 0: case event.kind of EvtConnect: @@ -234,27 +234,27 @@ when isMainModule: event.peer.data = addr client.id client.peer = event.peer - + dispMessage("New client connected ", client) - + var - msg = "hello" + msg = "hello" resp = createPacket(cstring(msg), msg.len + 1, FlagReliable) - + if event.peer.send(0.cuchar, resp) < 0: echo "FAILED" else: echo "Replied" of EvtReceive: - let client = clients[cast[ptr int32](event.peer.data)[]] - + let client = clients[cast[ptr int32](event.peer.data)[]] + var buf = newBuffer(event.packet) let k = buf.readChar() if handlers.hasKey(k): handlers[k](client, buf) else: dispError("Unknown packet from ", client) - + destroy(event.packet) of EvtDisconnect: var @@ -267,11 +267,11 @@ when isMainModule: dispMessage(clients[id], " disconnected") GCUnref(clients[id]) clients.del id - + event.peer.data = nil else: discard - + when appType == "gui": fpsText.setString(ff(1.0/dt)) if pubChatDelay.getElapsedTime.asSeconds > 0.25: @@ -281,14 +281,14 @@ when isMainModule: pubChatDelay -= dt if frameRate - pubChatDelay > 0.25: flushPubChat() - + when appType == "gui": window.clear(Black) window.draw(GUI) window.draw chatbox window.draw mousePos window.draw fpstext - window.display() + window.display() server.destroy() - enetDeinit() \ No newline at end of file + enetDeinit() diff --git a/tests/manyloc/keineschweine/enet_server/server_utils.nim b/tests/manyloc/keineschweine/enet_server/server_utils.nim index 8e81410751..1fb8326edb 100644 --- a/tests/manyloc/keineschweine/enet_server/server_utils.nim +++ b/tests/manyloc/keineschweine/enet_server/server_utils.nim @@ -6,9 +6,9 @@ type auth*: bool alias*: string peer*: PPeer - + FileChallengePair* = tuple[challenge: ScFileChallenge; file: TChecksumFile] - PFileChallengeSequence* = ref TFileChallengeSequence + PFileChallengeSequence* = ref TFileChallengeSequence TFileChallengeSequence = object index: int #which file is active transfer: ScFileTransfer @@ -73,7 +73,7 @@ proc sendChunk*(challenge: PFileChallengeSequence, client: PClient) = let size = min(FileChunkSize, challenge.transfer.fileSize - challenge.transfer.pos) challenge.transfer.data.setLen size copyMem( - addr challenge.transfer.data[0], + addr challenge.transfer.data[0], addr challenge.file.file.compressed[challenge.transfer.pos], size) client.send HFileTransfer, challenge.transfer @@ -90,7 +90,7 @@ proc startSend*(challenge: PFileChallengeSequence, client: PClient) = ## HFileTransfer proc handleFilePartAck*(client: PClient; buffer: PBuffer) = echo "got filepartack" - var + var ftrans = readCsFilepartAck(buffer) fcSeq = fileChallenges[client.id] fcSeq.transfer.pos = ftrans.lastPos @@ -99,7 +99,7 @@ proc handleFilePartAck*(client: PClient; buffer: PBuffer) = ## HFileCHallenge proc handleFileChallengeResp*(client: PClient; buffer: PBuffer) = echo "got file challenge resp" - var + var fcResp = readCsFileChallenge(buffer) fcSeq = fileChallenges[client.id] let index = $(fcSeq.index + 1) / $(myAssets.len) diff --git a/tests/manyloc/keineschweine/keineschweine.nim b/tests/manyloc/keineschweine/keineschweine.nim index 525d8a0546..49c0a24764 100644 --- a/tests/manyloc/keineschweine/keineschweine.nim +++ b/tests/manyloc/keineschweine/keineschweine.nim @@ -1,4 +1,4 @@ -import +import os, math, strutils, gl, tables, sfml, sfml_audio, sfml_colors, chipmunk, math_helpers, input_helpers, animations, game_objects, sfml_stuff, map_filter, @@ -29,7 +29,7 @@ type angle*: float PItem* = ref object record: PItemRecord - cooldown: float + cooldown: float PLiveBullet* = ref TLiveBullet ##represents a live bullet in the arena TLiveBullet* = object lifetime*: float @@ -80,7 +80,7 @@ var delObjects: seq[int] = @[] showShipSelect = false myPosition: array[0..1, TVector3f] ##for audio positioning -let +let nameTagOffset = vec2f(0.0, 1.0) when defined(escapeMenuTest): import browsers @@ -100,10 +100,10 @@ when defined(escapeMenuTest): when defined(foo): var mouseSprite: sfml.PCircleShape when defined(recordMode): - var + var snapshots: seq[PImage] = @[] isRecording = false - proc startRecording() = + proc startRecording() = if snapshots.len > 100: return echo "Started recording" isRecording = true @@ -142,26 +142,26 @@ proc mouseToSpace*(): TVector = proc explode*(b: PLiveBullet) ## TCollisionBeginFunc -proc collisionBulletPlayer(arb: PArbiter; space: PSpace; +proc collisionBulletPlayer(arb: PArbiter; space: PSpace; data: pointer): bool{.cdecl.} = - var + var bullet = cast[PLiveBullet](arb.a.data) target = cast[PVehicle](arb.b.data) if target.occupant.isNil or target.occupant == bullet.fromPlayer: return bullet.explode() proc angularDampingSim(body: PBody, gravity: TVector, damping, dt: CpFloat){.cdecl.} = - body.w -= (body.w * 0.98 * dt) + body.w -= (body.w * 0.98 * dt) body.UpdateVelocity(gravity, damping, dt) proc initLevel() = loadAllAssets() - + if not space.isNil: space.destroy() space = newSpace() space.addCollisionHandler CTBullet, CTVehicle, collisionBulletPlayer, nil, nil, nil, nil - + let levelSettings = getLevelSettings() levelArea.width = levelSettings.size.x levelArea.height= levelSettings.size.y @@ -171,8 +171,8 @@ proc initLevel() = for i in 0..3: var seg = space.addShape( newSegmentShape( - space.staticBody, - borderSeq[i], + space.staticBody, + borderSeq[i], borderSeq[(i + 1) mod 4], 8.0)) seg.setElasticity 0.96 @@ -188,8 +188,8 @@ proc initLevel() = for veh in playableVehicles(): shipSelect.newButton( veh.name, - position = pos, - onClick = proc(b: PButton) = + position = pos, + onClick = proc(b: PButton) = echo "-__-") pos.y += 18.0 @@ -199,7 +199,7 @@ proc newItem*(record: PItemRecord): PItem = result.record = record proc newItem*(name: string): PItem {.inline.} = return newItem(fetchItm(name)) -proc canUse*(itm: PItem): bool = +proc canUse*(itm: PItem): bool = if itm.cooldown > 0.0: return return true proc update*(itm: PItem; dt: float) = @@ -252,7 +252,7 @@ proc newBullet*(record: PBulletRecord; fromPlayer: PPlayer): PLiveBullet = result.shape.setLayers(LEnemyFire) result.shape.setCollisionType CTBullet result.shape.setUserData(cast[ptr TLiveBullet](result)) - let + let fireAngle = fromPlayer.vehicle.body.getAngle() fireAngleV = vectorForAngle(fireAngle) result.body.setAngle fireAngle @@ -341,14 +341,14 @@ proc update*(obj: PPlayer) = obj.nameTag.setPosition(obj.vehicle.body.getPos.floor + (nameTagOffset * (obj.vehicle.record.physics.radius + 5).cfloat)) proc draw(window: PRenderWindow, player: PPlayer) {.inline.} = - if not player.spectator: + if not player.spectator: if player.vehicle != nil: window.draw(player.vehicle.sprite) window.draw(player.nameTag) -proc setVehicle(p: PPlayer; v: PVehicle) = +proc setVehicle(p: PPlayer; v: PVehicle) = p.vehicle = v #sorry mom, this is just how things worked out ;( - if not v.isNil: + if not v.isNil: v.occupant = p proc createBot() = @@ -369,7 +369,7 @@ var inputCursor = newVertexArray(sfml.Lines, 2) inputCursor[0].position = vec2f(10.0, 10.0) inputCursor[1].position = vec2f(50.0, 90.0) -proc hasVehicle(p: PPlayer): bool {.inline.} = +proc hasVehicle(p: PPlayer): bool {.inline.} = result = not p.spectator and not p.vehicle.isNil proc setMyVehicle(v: PVehicle) {.inline.} = @@ -396,27 +396,27 @@ proc spec() = localPlayer.spectator = true specInputClient.setActive -var +var specLimiter = newClock() timeBetweenSpeccing = 1.0 #seconds proc toggleSpec() {.inline.} = if specLimiter.getElapsedTime.asSeconds < timeBetweenSpeccing: return specLimiter.restart() - if localPlayer.isNil: + if localPlayer.isNil: echo("OMG WTF PLAYER IS NILL!!") elif localPlayer.spectator: unspec() else: spec() proc addObject*(name: string) = var o = newObject(name) - if not o.isNil: + if not o.isNil: echo "Adding object ", o discard space.addBody(o.body) discard space.addShape(o.shape) o.shape.setLayers(LGrabbable) objects.add(o) -proc explode(obj: PGameObject) = +proc explode(obj: PGameObject) = echo obj, " exploded" let ind = objects.find(obj) if ind != -1: @@ -428,7 +428,7 @@ proc update(obj: PGameObject; dt: float) = obj.anim.setPos(obj.body.getPos) obj.anim.setAngle(obj.body.getAngle) -proc toggleShipSelect() = +proc toggleShipSelect() = showShipSelect = not showShipSelect proc handleLClick() = let pos = input_helpers.getMousePos() @@ -459,9 +459,9 @@ when defined(recordMode): snapshots[i].destroy() snapshots.setLen 0) when defined(DebugKeys): - ingameClient.registerHandler MouseRight, down, proc() = + ingameClient.registerHandler MouseRight, down, proc() = echo($activevehicle.body.getAngle.vectorForAngle()) - ingameClient.registerHandler KeyBackslash, down, proc() = + ingameClient.registerHandler KeyBackslash, down, proc() = createBot() ingameClient.registerHandler(KeyNum1, down, proc() = if localPlayer.items.len == 0: @@ -493,7 +493,7 @@ when defined(DebugKeys): for i, o in pairs(objects): echo i, " ", o) ingameClient.registerHandler(KeyLBracket, down, sound_buffer.report) - var + var mouseJoint: PConstraint mouseBody = space.addBody(newBody(CpInfinity, CpInfinity)) ingameClient.registerHandler(MouseMiddle, down, proc() = @@ -503,7 +503,7 @@ when defined(DebugKeys): space.removeConstraint mouseJoint mouseJoint.destroy() mouseJoint = nil - if shape.isNil: + if shape.isNil: return let body = shape.getBody() mouseJoint = space.addConstraint( @@ -564,42 +564,42 @@ proc mainUpdate(dt: float) = if keyPressed(KeyD): localPlayer.useItem 6 worldView.setCenter(activeVehicle.body.getPos.floor)#cp2sfml) - - if localPlayer != nil: + + if localPlayer != nil: localPlayer.update() localPlayer.updateItems(dt) for b in localBots: b.update() - + for o in items(objects): o.update(dt) for i in countdown(high(delObjects), 0): objects.del i delObjects.setLen 0 - + var i = 0 while i < len(liveBullets): if liveBullets[i].update(dt): liveBullets.del i - else: + else: inc i i = 0 while i < len(explosions): if explosions[i].next(dt): inc i else: explosions.del i - + when defined(DebugKeys): mouseBody.setPos(mouseToSpace()) - + space.step(dt) space.eachBody(resetForcesCB, nil) - + when defined(foo): var coords = window.convertCoords(vec2i(getMousePos()), worldView) mouseSprite.setPosition(coords) - + if localPlayer != nil and localPlayer.vehicle != nil: - let + let pos = localPlayer.vehicle.body.getPos() ang = localPlayer.vehicle.body.getAngle.vectorForAngle() myPosition[0].x = pos.x @@ -608,7 +608,7 @@ proc mainUpdate(dt: float) = myPosition[1].z = ang.y listenerSetPosition(myPosition[0]) listenerSetDirection(myPosition[1]) - + inc frameCount when defined(showFPS): if frameCount mod 60 == 0: @@ -620,25 +620,25 @@ proc mainUpdate(dt: float) = proc mainRender() = window.clear(Black) window.setView(worldView) - + if showStars: for star in stars: window.draw(star.sprite) window.draw(localPlayer) - + for b in localBots: window.draw(b) for o in objects: window.draw(o) - + for b in explosions: window.draw(b) for b in liveBullets: window.draw(b) - + when defined(Foo): window.draw(mouseSprite) - + window.setView(guiView) - + when defined(EscapeMenuTest): if escMenuOpen: window.draw escMenu @@ -646,12 +646,12 @@ proc mainRender() = window.draw(fpsText) when defined(recordMode): window.draw(recordButton) - + if localPlayer.spectator: window.draw(specGui) if showShipSelect: window.draw shipSelect window.display() - + when defined(recordMode): if isRecording: if snapshots.len < 100: @@ -664,30 +664,30 @@ proc readyMainState() = when isMainModule: import parseopt - + localPlayer = newPlayer() lobbyInit() - + videoMode = getClientSettings().resolution window = newRenderWindow(videoMode, "sup", sfDefaultStyle) window.setFrameRateLimit 60 - + worldView = window.getView.copy() guiView = worldView.copy() shipSelect.setPosition vec2f(665.0, 50.0) - + when defined(foo): mouseSprite = sfml.newCircleShape(14) mouseSprite.setFillColor Transparent mouseSprite.setOutlineColor RoyalBlue mouseSprite.setOutlineThickness 1.4 mouseSprite.setOrigin vec2f(14, 14) - + lobbyReady() playBtn = specGui.newButton( "Unspec - F12", position = vec2f(680.0, 8.0), onClick = proc(b: PButton) = toggleSpec()) - + block: var bPlayOffline = false for kind, key, val in getOpt(): @@ -698,7 +698,7 @@ when isMainModule: echo "Invalid argument ", key, " ", val if bPlayOffline: playoffline(nil) - + gameRunning = true while gameRunning: for event in window.filterEvents: diff --git a/tests/manyloc/keineschweine/lib/client_helpers.nim b/tests/manyloc/keineschweine/lib/client_helpers.nim index 84e42b62ef..f2833fe14b 100644 --- a/tests/manyloc/keineschweine/lib/client_helpers.nim +++ b/tests/manyloc/keineschweine/lib/client_helpers.nim @@ -1,4 +1,4 @@ -import +import tables, sg_packets, enet, estreams, sg_gui, sfml, zlib_helpers, md5, sg_assets, os type @@ -17,7 +17,7 @@ type pos: int32 data: string readyToSave: bool -var +var currentFileTransfer: TFileTransfer downloadProgress* = newButton(nil, "", vec2f(0,0), nil) currentFileTransfer.data = "" @@ -73,7 +73,7 @@ proc handleFilePartRecv*(serv: PServer; buffer: PBuffer) {.procvar.} = var f = readScFileTransfer(buffer) updateFileProgress() - if not(f.pos == currentFileTransfer.pos): + if not(f.pos == currentFileTransfer.pos): echo "returning early from filepartrecv" return ##issues, probably if currentFileTransfer.data.len == 0: @@ -100,7 +100,7 @@ proc handleFilePartRecv*(serv: PServer; buffer: PBuffer) {.procvar.} = proc saveCurrentFile() = if not currentFileTransfer.readyToSave: return - let + let path = expandPath(currentFileTransfer.assetType, currentFileTransfer.fileName) parent = parentDir(path) if not existsDir(parent): @@ -123,7 +123,7 @@ proc handleFileChallengeResult*(serv: PServer; buffer: PBuffer) {.procvar.} = ## HFileCHallenge proc handleFileChallenge*(serv: PServer; buffer: PBuffer) {.procvar.} = - var + var challenge = readScFileChallenge(buffer) path = expandPath(challenge) resp: CsFileChallenge diff --git a/tests/manyloc/keineschweine/lib/estreams.nim b/tests/manyloc/keineschweine/lib/estreams.nim index ecafaed890..bdf9b2bf0c 100644 --- a/tests/manyloc/keineschweine/lib/estreams.nim +++ b/tests/manyloc/keineschweine/lib/estreams.nim @@ -1,6 +1,6 @@ import endians -proc swapEndian16*(outp, inp: pointer) = +proc swapEndian16*(outp, inp: pointer) = ## copies `inp` to `outp` swapping bytes. Both buffers are supposed to ## contain at least 2 bytes. var i = cast[cstring](inp) @@ -113,10 +113,10 @@ when isMainModule: echo(repr(b)) b.pos = 0 echo(repr(b.readStr())) - + b.flush() echo "flushed" b.writeC([1,2,3]) echo(repr(b)) - - + + diff --git a/tests/manyloc/keineschweine/lib/gl.nim b/tests/manyloc/keineschweine/lib/gl.nim index c577f34046..b634a96cfb 100644 --- a/tests/manyloc/keineschweine/lib/gl.nim +++ b/tests/manyloc/keineschweine/lib/gl.nim @@ -5,24 +5,24 @@ # These units are free to use # #****************************************************************************** -# Converted to Delphi by Tom Nuydens (tom@delphi3d.net) -# For the latest updates, visit Delphi3D: http://www.delphi3d.net +# Converted to Delphi by Tom Nuydens (tom@delphi3d.net) +# For the latest updates, visit Delphi3D: http://www.delphi3d.net #****************************************************************************** -when defined(windows): +when defined(windows): {.push, callconv: stdcall.} -else: +else: {.push, callconv: cdecl.} -when defined(windows): - const +when defined(windows): + const dllname* = "opengl32.dll" -elif defined(macosx): - const +elif defined(macosx): + const dllname* = "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib" -else: - const +else: + const dllname* = "libGL.so.1" -type +type PGLenum* = ptr TGLenum PGLboolean* = ptr TGLboolean PGLbitfield* = ptr TGLbitfield @@ -983,128 +983,128 @@ const # Version GL_TEXTURE_COMPONENTS* = GL_TEXTURE_INTERNAL_FORMAT proc glAccum*(op: TGLenum, value: TGLfloat){.dynlib: dllname, importc: "glAccum".} -proc glAlphaFunc*(fun: TGLenum, theref: TGLclampf){.dynlib: dllname, +proc glAlphaFunc*(fun: TGLenum, theref: TGLclampf){.dynlib: dllname, importc: "glAlphaFunc".} -proc glAreTexturesResident*(n: TGLsizei, textures: PGLuint, +proc glAreTexturesResident*(n: TGLsizei, textures: PGLuint, residences: PGLboolean): TGLboolean{. dynlib: dllname, importc: "glAreTexturesResident".} proc glArrayElement*(i: TGLint){.dynlib: dllname, importc: "glArrayElement".} proc glBegin*(mode: TGLenum){.dynlib: dllname, importc: "glBegin".} -proc glBindTexture*(target: TGLenum, texture: TGLuint){.dynlib: dllname, +proc glBindTexture*(target: TGLenum, texture: TGLuint){.dynlib: dllname, importc: "glBindTexture".} -proc glBitmap*(width, height: TGLsizei, xorig, yorig: TGLfloat, - xmove, ymove: TGLfloat, bitmap: PGLubyte){.dynlib: dllname, +proc glBitmap*(width, height: TGLsizei, xorig, yorig: TGLfloat, + xmove, ymove: TGLfloat, bitmap: PGLubyte){.dynlib: dllname, importc: "glBitmap".} -proc glBlendFunc*(sfactor, dfactor: TGLenum){.dynlib: dllname, +proc glBlendFunc*(sfactor, dfactor: TGLenum){.dynlib: dllname, importc: "glBlendFunc".} proc glCallList*(list: TGLuint){.dynlib: dllname, importc: "glCallList".} -proc glCallLists*(n: TGLsizei, atype: TGLenum, lists: pointer){.dynlib: dllname, +proc glCallLists*(n: TGLsizei, atype: TGLenum, lists: pointer){.dynlib: dllname, importc: "glCallLists".} proc glClear*(mask: TGLbitfield){.dynlib: dllname, importc: "glClear".} -proc glClearAccum*(red, green, blue, alpha: TGLfloat){.dynlib: dllname, +proc glClearAccum*(red, green, blue, alpha: TGLfloat){.dynlib: dllname, importc: "glClearAccum".} -proc glClearColor*(red, green, blue, alpha: TGLclampf){.dynlib: dllname, +proc glClearColor*(red, green, blue, alpha: TGLclampf){.dynlib: dllname, importc: "glClearColor".} proc glClearDepth*(depth: TGLclampd){.dynlib: dllname, importc: "glClearDepth".} proc glClearIndex*(c: TGLfloat){.dynlib: dllname, importc: "glClearIndex".} proc glClearStencil*(s: TGLint){.dynlib: dllname, importc: "glClearStencil".} -proc glClipPlane*(plane: TGLenum, equation: PGLdouble){.dynlib: dllname, +proc glClipPlane*(plane: TGLenum, equation: PGLdouble){.dynlib: dllname, importc: "glClipPlane".} -proc glColor3b*(red, green, blue: TGlbyte){.dynlib: dllname, +proc glColor3b*(red, green, blue: TGlbyte){.dynlib: dllname, importc: "glColor3b".} proc glColor3bv*(v: PGLbyte){.dynlib: dllname, importc: "glColor3bv".} -proc glColor3d*(red, green, blue: TGLdouble){.dynlib: dllname, +proc glColor3d*(red, green, blue: TGLdouble){.dynlib: dllname, importc: "glColor3d".} proc glColor3dv*(v: PGLdouble){.dynlib: dllname, importc: "glColor3dv".} -proc glColor3f*(red, green, blue: TGLfloat){.dynlib: dllname, +proc glColor3f*(red, green, blue: TGLfloat){.dynlib: dllname, importc: "glColor3f".} proc glColor3fv*(v: PGLfloat){.dynlib: dllname, importc: "glColor3fv".} proc glColor3i*(red, green, blue: TGLint){.dynlib: dllname, importc: "glColor3i".} proc glColor3iv*(v: PGLint){.dynlib: dllname, importc: "glColor3iv".} -proc glColor3s*(red, green, blue: TGLshort){.dynlib: dllname, +proc glColor3s*(red, green, blue: TGLshort){.dynlib: dllname, importc: "glColor3s".} proc glColor3sv*(v: PGLshort){.dynlib: dllname, importc: "glColor3sv".} -proc glColor3ub*(red, green, blue: TGLubyte){.dynlib: dllname, +proc glColor3ub*(red, green, blue: TGLubyte){.dynlib: dllname, importc: "glColor3ub".} proc glColor3ubv*(v: PGLubyte){.dynlib: dllname, importc: "glColor3ubv".} -proc glColor3ui*(red, green, blue: TGLuint){.dynlib: dllname, +proc glColor3ui*(red, green, blue: TGLuint){.dynlib: dllname, importc: "glColor3ui".} proc glColor3uiv*(v: PGLuint){.dynlib: dllname, importc: "glColor3uiv".} -proc glColor3us*(red, green, blue: TGLushort){.dynlib: dllname, +proc glColor3us*(red, green, blue: TGLushort){.dynlib: dllname, importc: "glColor3us".} proc glColor3usv*(v: PGLushort){.dynlib: dllname, importc: "glColor3usv".} -proc glColor4b*(red, green, blue, alpha: TGlbyte){.dynlib: dllname, +proc glColor4b*(red, green, blue, alpha: TGlbyte){.dynlib: dllname, importc: "glColor4b".} proc glColor4bv*(v: PGLbyte){.dynlib: dllname, importc: "glColor4bv".} -proc glColor4d*(red, green, blue, alpha: TGLdouble){.dynlib: dllname, +proc glColor4d*(red, green, blue, alpha: TGLdouble){.dynlib: dllname, importc: "glColor4d".} proc glColor4dv*(v: PGLdouble){.dynlib: dllname, importc: "glColor4dv".} -proc glColor4f*(red, green, blue, alpha: TGLfloat){.dynlib: dllname, +proc glColor4f*(red, green, blue, alpha: TGLfloat){.dynlib: dllname, importc: "glColor4f".} proc glColor4fv*(v: PGLfloat){.dynlib: dllname, importc: "glColor4fv".} -proc glColor4i*(red, green, blue, alpha: TGLint){.dynlib: dllname, +proc glColor4i*(red, green, blue, alpha: TGLint){.dynlib: dllname, importc: "glColor4i".} proc glColor4iv*(v: PGLint){.dynlib: dllname, importc: "glColor4iv".} -proc glColor4s*(red, green, blue, alpha: TGLshort){.dynlib: dllname, +proc glColor4s*(red, green, blue, alpha: TGLshort){.dynlib: dllname, importc: "glColor4s".} proc glColor4sv*(v: PGLshort){.dynlib: dllname, importc: "glColor4sv".} -proc glColor4ub*(red, green, blue, alpha: TGLubyte){.dynlib: dllname, +proc glColor4ub*(red, green, blue, alpha: TGLubyte){.dynlib: dllname, importc: "glColor4ub".} proc glColor4ubv*(v: PGLubyte){.dynlib: dllname, importc: "glColor4ubv".} -proc glColor4ui*(red, green, blue, alpha: TGLuint){.dynlib: dllname, +proc glColor4ui*(red, green, blue, alpha: TGLuint){.dynlib: dllname, importc: "glColor4ui".} proc glColor4uiv*(v: PGLuint){.dynlib: dllname, importc: "glColor4uiv".} -proc glColor4us*(red, green, blue, alpha: TGLushort){.dynlib: dllname, +proc glColor4us*(red, green, blue, alpha: TGLushort){.dynlib: dllname, importc: "glColor4us".} proc glColor4usv*(v: PGLushort){.dynlib: dllname, importc: "glColor4usv".} -proc glColorMask*(red, green, blue, alpha: TGLboolean){.dynlib: dllname, +proc glColorMask*(red, green, blue, alpha: TGLboolean){.dynlib: dllname, importc: "glColorMask".} -proc glColorMaterial*(face, mode: TGLenum){.dynlib: dllname, +proc glColorMaterial*(face, mode: TGLenum){.dynlib: dllname, importc: "glColorMaterial".} -proc glColorPointer*(size: TGLint, atype: TGLenum, stride: TGLsizei, - p: pointer){.dynlib: dllname, +proc glColorPointer*(size: TGLint, atype: TGLenum, stride: TGLsizei, + p: pointer){.dynlib: dllname, importc: "glColorPointer".} proc glCopyPixels*(x, y: TGLint, width, height: TGLsizei, atype: TGLenum){. dynlib: dllname, importc: "glCopyPixels".} -proc glCopyTexImage1D*(target: TGLenum, level: TGLint, internalFormat: TGLenum, +proc glCopyTexImage1D*(target: TGLenum, level: TGLint, internalFormat: TGLenum, x, y: TGLint, width: TGLsizei, border: TGLint){. dynlib: dllname, importc: "glCopyTexImage1D".} -proc glCopyTexImage2D*(target: TGLenum, level: TGLint, internalFormat: TGLenum, +proc glCopyTexImage2D*(target: TGLenum, level: TGLint, internalFormat: TGLenum, x, y: TGLint, width, height: TGLsizei, border: TGLint){. dynlib: dllname, importc: "glCopyTexImage2D".} -proc glCopyTexSubImage1D*(target: TGLenum, level, xoffset, x, y: TGLint, - width: TGLsizei){.dynlib: dllname, +proc glCopyTexSubImage1D*(target: TGLenum, level, xoffset, x, y: TGLint, + width: TGLsizei){.dynlib: dllname, importc: "glCopyTexSubImage1D".} -proc glCopyTexSubImage2D*(target: TGLenum, - level, xoffset, yoffset, x, y: TGLint, - width, height: TGLsizei){.dynlib: dllname, +proc glCopyTexSubImage2D*(target: TGLenum, + level, xoffset, yoffset, x, y: TGLint, + width, height: TGLsizei){.dynlib: dllname, importc: "glCopyTexSubImage2D".} proc glCullFace*(mode: TGLenum){.dynlib: dllname, importc: "glCullFace".} -proc glDeleteLists*(list: TGLuint, range: TGLsizei){.dynlib: dllname, +proc glDeleteLists*(list: TGLuint, range: TGLsizei){.dynlib: dllname, importc: "glDeleteLists".} -proc glDeleteTextures*(n: TGLsizei, textures: PGLuint){.dynlib: dllname, +proc glDeleteTextures*(n: TGLsizei, textures: PGLuint){.dynlib: dllname, importc: "glDeleteTextures".} proc glDepthFunc*(fun: TGLenum){.dynlib: dllname, importc: "glDepthFunc".} proc glDepthMask*(flag: TGLboolean){.dynlib: dllname, importc: "glDepthMask".} -proc glDepthRange*(zNear, zFar: TGLclampd){.dynlib: dllname, +proc glDepthRange*(zNear, zFar: TGLclampd){.dynlib: dllname, importc: "glDepthRange".} proc glDisable*(cap: TGLenum){.dynlib: dllname, importc: "glDisable".} -proc glDisableClientState*(aarray: TGLenum){.dynlib: dllname, +proc glDisableClientState*(aarray: TGLenum){.dynlib: dllname, importc: "glDisableClientState".} proc glDrawArrays*(mode: TGLenum, first: TGLint, count: TGLsizei){. dynlib: dllname, importc: "glDrawArrays".} proc glDrawBuffer*(mode: TGLenum){.dynlib: dllname, importc: "glDrawBuffer".} -proc glDrawElements*(mode: TGLenum, count: TGLsizei, atype: TGLenum, - indices: pointer){.dynlib: dllname, +proc glDrawElements*(mode: TGLenum, count: TGLsizei, atype: TGLenum, + indices: pointer){.dynlib: dllname, importc: "glDrawElements".} -proc glDrawPixels*(width, height: TGLsizei, format, atype: TGLenum, +proc glDrawPixels*(width, height: TGLsizei, format, atype: TGLenum, pixels: pointer){.dynlib: dllname, importc: "glDrawPixels".} proc glEdgeFlag*(flag: TGLboolean){.dynlib: dllname, importc: "glEdgeFlag".} -proc glEdgeFlagPointer*(stride: TGLsizei, p: pointer){.dynlib: dllname, +proc glEdgeFlagPointer*(stride: TGLsizei, p: pointer){.dynlib: dllname, importc: "glEdgeFlagPointer".} proc glEdgeFlagv*(flag: PGLboolean){.dynlib: dllname, importc: "glEdgeFlagv".} proc glEnable*(cap: TGLenum){.dynlib: dllname, importc: "glEnable".} -proc glEnableClientState*(aarray: TGLenum){.dynlib: dllname, +proc glEnableClientState*(aarray: TGLenum){.dynlib: dllname, importc: "glEnableClientState".} proc glEnd*(){.dynlib: dllname, importc: "glEnd".} proc glEndList*(){.dynlib: dllname, importc: "glEndList".} @@ -1116,9 +1116,9 @@ proc glEvalCoord2d*(u, v: TGLdouble){.dynlib: dllname, importc: "glEvalCoord2d". proc glEvalCoord2dv*(u: PGLdouble){.dynlib: dllname, importc: "glEvalCoord2dv".} proc glEvalCoord2f*(u, v: TGLfloat){.dynlib: dllname, importc: "glEvalCoord2f".} proc glEvalCoord2fv*(u: PGLfloat){.dynlib: dllname, importc: "glEvalCoord2fv".} -proc glEvalMesh1*(mode: TGLenum, i1, i2: TGLint){.dynlib: dllname, +proc glEvalMesh1*(mode: TGLenum, i1, i2: TGLint){.dynlib: dllname, importc: "glEvalMesh1".} -proc glEvalMesh2*(mode: TGLenum, i1, i2, j1, j2: TGLint){.dynlib: dllname, +proc glEvalMesh2*(mode: TGLenum, i1, i2, j1, j2: TGLint){.dynlib: dllname, importc: "glEvalMesh2".} proc glEvalPoint1*(i: TGLint){.dynlib: dllname, importc: "glEvalPoint1".} proc glEvalPoint2*(i, j: TGLint){.dynlib: dllname, importc: "glEvalPoint2".} @@ -1126,75 +1126,75 @@ proc glFeedbackBuffer*(size: TGLsizei, atype: TGLenum, buffer: PGLfloat){. dynlib: dllname, importc: "glFeedbackBuffer".} proc glFinish*(){.dynlib: dllname, importc: "glFinish".} proc glFlush*(){.dynlib: dllname, importc: "glFlush".} -proc glFogf*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, +proc glFogf*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, importc: "glFogf".} -proc glFogfv*(pname: TGLenum, params: PGLfloat){.dynlib: dllname, +proc glFogfv*(pname: TGLenum, params: PGLfloat){.dynlib: dllname, importc: "glFogfv".} proc glFogi*(pname: TGLenum, param: TGLint){.dynlib: dllname, importc: "glFogi".} -proc glFogiv*(pname: TGLenum, params: PGLint){.dynlib: dllname, +proc glFogiv*(pname: TGLenum, params: PGLint){.dynlib: dllname, importc: "glFogiv".} proc glFrontFace*(mode: TGLenum){.dynlib: dllname, importc: "glFrontFace".} proc glFrustum*(left, right, bottom, top, zNear, zFar: TGLdouble){. dynlib: dllname, importc: "glFrustum".} -proc glGenLists*(range: TGLsizei): TGLuint{.dynlib: dllname, +proc glGenLists*(range: TGLsizei): TGLuint{.dynlib: dllname, importc: "glGenLists".} -proc glGenTextures*(n: TGLsizei, textures: PGLuint){.dynlib: dllname, +proc glGenTextures*(n: TGLsizei, textures: PGLuint){.dynlib: dllname, importc: "glGenTextures".} -proc glGetBooleanv*(pname: TGLenum, params: PGLboolean){.dynlib: dllname, +proc glGetBooleanv*(pname: TGLenum, params: PGLboolean){.dynlib: dllname, importc: "glGetBooleanv".} -proc glGetClipPlane*(plane: TGLenum, equation: PGLdouble){.dynlib: dllname, +proc glGetClipPlane*(plane: TGLenum, equation: PGLdouble){.dynlib: dllname, importc: "glGetClipPlane".} -proc glGetDoublev*(pname: TGLenum, params: PGLdouble){.dynlib: dllname, +proc glGetDoublev*(pname: TGLenum, params: PGLdouble){.dynlib: dllname, importc: "glGetDoublev".} proc glGetError*(): TGLenum{.dynlib: dllname, importc: "glGetError".} -proc glGetFloatv*(pname: TGLenum, params: PGLfloat){.dynlib: dllname, +proc glGetFloatv*(pname: TGLenum, params: PGLfloat){.dynlib: dllname, importc: "glGetFloatv".} -proc glGetIntegerv*(pname: TGLenum, params: PGLint){.dynlib: dllname, +proc glGetIntegerv*(pname: TGLenum, params: PGLint){.dynlib: dllname, importc: "glGetIntegerv".} -proc glGetLightfv*(light, pname: TGLenum, params: PGLfloat){.dynlib: dllname, +proc glGetLightfv*(light, pname: TGLenum, params: PGLfloat){.dynlib: dllname, importc: "glGetLightfv".} -proc glGetLightiv*(light, pname: TGLenum, params: PGLint){.dynlib: dllname, +proc glGetLightiv*(light, pname: TGLenum, params: PGLint){.dynlib: dllname, importc: "glGetLightiv".} -proc glGetMapdv*(target, query: TGLenum, v: PGLdouble){.dynlib: dllname, +proc glGetMapdv*(target, query: TGLenum, v: PGLdouble){.dynlib: dllname, importc: "glGetMapdv".} -proc glGetMapfv*(target, query: TGLenum, v: PGLfloat){.dynlib: dllname, +proc glGetMapfv*(target, query: TGLenum, v: PGLfloat){.dynlib: dllname, importc: "glGetMapfv".} -proc glGetMapiv*(target, query: TGLenum, v: PGLint){.dynlib: dllname, +proc glGetMapiv*(target, query: TGLenum, v: PGLint){.dynlib: dllname, importc: "glGetMapiv".} -proc glGetMaterialfv*(face, pname: TGLenum, params: PGLfloat){.dynlib: dllname, +proc glGetMaterialfv*(face, pname: TGLenum, params: PGLfloat){.dynlib: dllname, importc: "glGetMaterialfv".} -proc glGetMaterialiv*(face, pname: TGLenum, params: PGLint){.dynlib: dllname, +proc glGetMaterialiv*(face, pname: TGLenum, params: PGLint){.dynlib: dllname, importc: "glGetMaterialiv".} -proc glGetPixelMapfv*(map: TGLenum, values: PGLfloat){.dynlib: dllname, +proc glGetPixelMapfv*(map: TGLenum, values: PGLfloat){.dynlib: dllname, importc: "glGetPixelMapfv".} -proc glGetPixelMapuiv*(map: TGLenum, values: PGLuint){.dynlib: dllname, +proc glGetPixelMapuiv*(map: TGLenum, values: PGLuint){.dynlib: dllname, importc: "glGetPixelMapuiv".} -proc glGetPixelMapusv*(map: TGLenum, values: PGLushort){.dynlib: dllname, +proc glGetPixelMapusv*(map: TGLenum, values: PGLushort){.dynlib: dllname, importc: "glGetPixelMapusv".} -proc glGetPointerv*(pname: TGLenum, params: pointer){.dynlib: dllname, +proc glGetPointerv*(pname: TGLenum, params: pointer){.dynlib: dllname, importc: "glGetPointerv".} -proc glGetPolygonStipple*(mask: PGLubyte){.dynlib: dllname, +proc glGetPolygonStipple*(mask: PGLubyte){.dynlib: dllname, importc: "glGetPolygonStipple".} -proc glGetString*(name: TGLenum): cstring{.dynlib: dllname, +proc glGetString*(name: TGLenum): cstring{.dynlib: dllname, importc: "glGetString".} -proc glGetTexEnvfv*(target, pname: TGLenum, params: PGLfloat){.dynlib: dllname, +proc glGetTexEnvfv*(target, pname: TGLenum, params: PGLfloat){.dynlib: dllname, importc: "glGetTexEnvfv".} -proc glGetTexEnviv*(target, pname: TGLenum, params: PGLint){.dynlib: dllname, +proc glGetTexEnviv*(target, pname: TGLenum, params: PGLint){.dynlib: dllname, importc: "glGetTexEnviv".} -proc glGetTexGendv*(coord, pname: TGLenum, params: PGLdouble){.dynlib: dllname, +proc glGetTexGendv*(coord, pname: TGLenum, params: PGLdouble){.dynlib: dllname, importc: "glGetTexGendv".} -proc glGetTexGenfv*(coord, pname: TGLenum, params: PGLfloat){.dynlib: dllname, +proc glGetTexGenfv*(coord, pname: TGLenum, params: PGLfloat){.dynlib: dllname, importc: "glGetTexGenfv".} -proc glGetTexGeniv*(coord, pname: TGLenum, params: PGLint){.dynlib: dllname, +proc glGetTexGeniv*(coord, pname: TGLenum, params: PGLint){.dynlib: dllname, importc: "glGetTexGeniv".} -proc glGetTexImage*(target: TGLenum, level: TGLint, format: TGLenum, - atype: TGLenum, pixels: pointer){.dynlib: dllname, +proc glGetTexImage*(target: TGLenum, level: TGLint, format: TGLenum, + atype: TGLenum, pixels: pointer){.dynlib: dllname, importc: "glGetTexImage".} -proc glGetTexLevelParameterfv*(target: TGLenum, level: TGLint, pname: TGLenum, - params: pointer){.dynlib: dllname, +proc glGetTexLevelParameterfv*(target: TGLenum, level: TGLint, pname: TGLenum, + params: pointer){.dynlib: dllname, importc: "glGetTexLevelParameterfv".} -proc glGetTexLevelParameteriv*(target: TGLenum, level: TGLint, pname: TGLenum, - params: PGLint){.dynlib: dllname, +proc glGetTexLevelParameteriv*(target: TGLenum, level: TGLint, pname: TGLenum, + params: PGLint){.dynlib: dllname, importc: "glGetTexLevelParameteriv".} proc glGetTexParameterfv*(target, pname: TGLenum, params: PGLfloat){. dynlib: dllname, importc: "glGetTexParameterfv".} @@ -1217,28 +1217,28 @@ proc glIndexubv*(c: PGLubyte){.dynlib: dllname, importc: "glIndexubv".} proc glInitNames*(){.dynlib: dllname, importc: "glInitNames".} proc glInterleavedArrays*(format: TGLenum, stride: TGLsizei, p: pointer){. dynlib: dllname, importc: "glInterleavedArrays".} -proc glIsEnabled*(cap: TGLenum): TGLboolean{.dynlib: dllname, +proc glIsEnabled*(cap: TGLenum): TGLboolean{.dynlib: dllname, importc: "glIsEnabled".} proc glIsList*(list: TGLuint): TGLboolean{.dynlib: dllname, importc: "glIsList".} -proc glIsTexture*(texture: TGLuint): TGLboolean{.dynlib: dllname, +proc glIsTexture*(texture: TGLuint): TGLboolean{.dynlib: dllname, importc: "glIsTexture".} -proc glLightModelf*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, +proc glLightModelf*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, importc: "glLightModelf".} -proc glLightModelfv*(pname: TGLenum, params: PGLfloat){.dynlib: dllname, +proc glLightModelfv*(pname: TGLenum, params: PGLfloat){.dynlib: dllname, importc: "glLightModelfv".} -proc glLightModeli*(pname: TGLenum, param: TGLint){.dynlib: dllname, +proc glLightModeli*(pname: TGLenum, param: TGLint){.dynlib: dllname, importc: "glLightModeli".} -proc glLightModeliv*(pname: TGLenum, params: PGLint){.dynlib: dllname, +proc glLightModeliv*(pname: TGLenum, params: PGLint){.dynlib: dllname, importc: "glLightModeliv".} -proc glLightf*(light, pname: TGLenum, param: TGLfloat){.dynlib: dllname, +proc glLightf*(light, pname: TGLenum, param: TGLfloat){.dynlib: dllname, importc: "glLightf".} -proc glLightfv*(light, pname: TGLenum, params: PGLfloat){.dynlib: dllname, +proc glLightfv*(light, pname: TGLenum, params: PGLfloat){.dynlib: dllname, importc: "glLightfv".} -proc glLighti*(light, pname: TGLenum, param: TGLint){.dynlib: dllname, +proc glLighti*(light, pname: TGLenum, param: TGLint){.dynlib: dllname, importc: "glLighti".} -proc glLightiv*(light, pname: TGLenum, params: PGLint){.dynlib: dllname, +proc glLightiv*(light, pname: TGLenum, params: PGLint){.dynlib: dllname, importc: "glLightiv".} -proc glLineStipple*(factor: TGLint, pattern: TGLushort){.dynlib: dllname, +proc glLineStipple*(factor: TGLint, pattern: TGLushort){.dynlib: dllname, importc: "glLineStipple".} proc glLineWidth*(width: TGLfloat){.dynlib: dllname, importc: "glLineWidth".} proc glListBase*(base: TGLuint){.dynlib: dllname, importc: "glListBase".} @@ -1247,36 +1247,36 @@ proc glLoadMatrixd*(m: PGLdouble){.dynlib: dllname, importc: "glLoadMatrixd".} proc glLoadMatrixf*(m: PGLfloat){.dynlib: dllname, importc: "glLoadMatrixf".} proc glLoadName*(name: TGLuint){.dynlib: dllname, importc: "glLoadName".} proc glLogicOp*(opcode: TGLenum){.dynlib: dllname, importc: "glLogicOp".} -proc glMap1d*(target: TGLenum, u1, u2: TGLdouble, stride, order: TGLint, +proc glMap1d*(target: TGLenum, u1, u2: TGLdouble, stride, order: TGLint, points: PGLdouble){.dynlib: dllname, importc: "glMap1d".} -proc glMap1f*(target: TGLenum, u1, u2: TGLfloat, stride, order: TGLint, +proc glMap1f*(target: TGLenum, u1, u2: TGLfloat, stride, order: TGLint, points: PGLfloat){.dynlib: dllname, importc: "glMap1f".} -proc glMap2d*(target: TGLenum, u1, u2: TGLdouble, ustride, uorder: TGLint, +proc glMap2d*(target: TGLenum, u1, u2: TGLdouble, ustride, uorder: TGLint, v1, v2: TGLdouble, vstride, vorder: TGLint, points: PGLdouble){. dynlib: dllname, importc: "glMap2d".} -proc glMap2f*(target: TGLenum, u1, u2: TGLfloat, ustride, uorder: TGLint, +proc glMap2f*(target: TGLenum, u1, u2: TGLfloat, ustride, uorder: TGLint, v1, v2: TGLfloat, vstride, vorder: TGLint, points: PGLfloat){. dynlib: dllname, importc: "glMap2f".} -proc glMapGrid1d*(un: TGLint, u1, u2: TGLdouble){.dynlib: dllname, +proc glMapGrid1d*(un: TGLint, u1, u2: TGLdouble){.dynlib: dllname, importc: "glMapGrid1d".} -proc glMapGrid1f*(un: TGLint, u1, u2: TGLfloat){.dynlib: dllname, +proc glMapGrid1f*(un: TGLint, u1, u2: TGLfloat){.dynlib: dllname, importc: "glMapGrid1f".} proc glMapGrid2d*(un: TGLint, u1, u2: TGLdouble, vn: TGLint, v1, v2: TGLdouble){. dynlib: dllname, importc: "glMapGrid2d".} proc glMapGrid2f*(un: TGLint, u1, u2: TGLfloat, vn: TGLint, v1, v2: TGLfloat){. dynlib: dllname, importc: "glMapGrid2f".} -proc glMaterialf*(face, pname: TGLenum, param: TGLfloat){.dynlib: dllname, +proc glMaterialf*(face, pname: TGLenum, param: TGLfloat){.dynlib: dllname, importc: "glMaterialf".} -proc glMaterialfv*(face, pname: TGLenum, params: PGLfloat){.dynlib: dllname, +proc glMaterialfv*(face, pname: TGLenum, params: PGLfloat){.dynlib: dllname, importc: "glMaterialfv".} -proc glMateriali*(face, pname: TGLenum, param: TGLint){.dynlib: dllname, +proc glMateriali*(face, pname: TGLenum, param: TGLint){.dynlib: dllname, importc: "glMateriali".} -proc glMaterialiv*(face, pname: TGLenum, params: PGLint){.dynlib: dllname, +proc glMaterialiv*(face, pname: TGLenum, params: PGLint){.dynlib: dllname, importc: "glMaterialiv".} proc glMatrixMode*(mode: TGLenum){.dynlib: dllname, importc: "glMatrixMode".} proc glMultMatrixd*(m: PGLdouble){.dynlib: dllname, importc: "glMultMatrixd".} proc glMultMatrixf*(m: PGLfloat){.dynlib: dllname, importc: "glMultMatrixf".} -proc glNewList*(list: TGLuint, mode: TGLenum){.dynlib: dllname, +proc glNewList*(list: TGLuint, mode: TGLenum){.dynlib: dllname, importc: "glNewList".} proc glNormal3b*(nx, ny, nz: TGlbyte){.dynlib: dllname, importc: "glNormal3b".} proc glNormal3bv*(v: PGLbyte){.dynlib: dllname, importc: "glNormal3bv".} @@ -1299,22 +1299,22 @@ proc glPixelMapuiv*(map: TGLenum, mapsize: TGLsizei, values: PGLuint){. dynlib: dllname, importc: "glPixelMapuiv".} proc glPixelMapusv*(map: TGLenum, mapsize: TGLsizei, values: PGLushort){. dynlib: dllname, importc: "glPixelMapusv".} -proc glPixelStoref*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, +proc glPixelStoref*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, importc: "glPixelStoref".} -proc glPixelStorei*(pname: TGLenum, param: TGLint){.dynlib: dllname, +proc glPixelStorei*(pname: TGLenum, param: TGLint){.dynlib: dllname, importc: "glPixelStorei".} -proc glPixelTransferf*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, +proc glPixelTransferf*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, importc: "glPixelTransferf".} -proc glPixelTransferi*(pname: TGLenum, param: TGLint){.dynlib: dllname, +proc glPixelTransferi*(pname: TGLenum, param: TGLint){.dynlib: dllname, importc: "glPixelTransferi".} -proc glPixelZoom*(xfactor, yfactor: TGLfloat){.dynlib: dllname, +proc glPixelZoom*(xfactor, yfactor: TGLfloat){.dynlib: dllname, importc: "glPixelZoom".} proc glPointSize*(size: TGLfloat){.dynlib: dllname, importc: "glPointSize".} -proc glPolygonMode*(face, mode: TGLenum){.dynlib: dllname, +proc glPolygonMode*(face, mode: TGLenum){.dynlib: dllname, importc: "glPolygonMode".} -proc glPolygonOffset*(factor, units: TGLfloat){.dynlib: dllname, +proc glPolygonOffset*(factor, units: TGLfloat){.dynlib: dllname, importc: "glPolygonOffset".} -proc glPolygonStipple*(mask: PGLubyte){.dynlib: dllname, +proc glPolygonStipple*(mask: PGLubyte){.dynlib: dllname, importc: "glPolygonStipple".} proc glPopAttrib*(){.dynlib: dllname, importc: "glPopAttrib".} proc glPopClientAttrib*(){.dynlib: dllname, importc: "glPopClientAttrib".} @@ -1323,7 +1323,7 @@ proc glPopName*(){.dynlib: dllname, importc: "glPopName".} proc glPrioritizeTextures*(n: TGLsizei, textures: PGLuint, priorities: PGLclampf){. dynlib: dllname, importc: "glPrioritizeTextures".} proc glPushAttrib*(mask: TGLbitfield){.dynlib: dllname, importc: "glPushAttrib".} -proc glPushClientAttrib*(mask: TGLbitfield){.dynlib: dllname, +proc glPushClientAttrib*(mask: TGLbitfield){.dynlib: dllname, importc: "glPushClientAttrib".} proc glPushMatrix*(){.dynlib: dllname, importc: "glPushMatrix".} proc glPushName*(name: TGLuint){.dynlib: dllname, importc: "glPushName".} @@ -1335,35 +1335,35 @@ proc glRasterPos2i*(x, y: TGLint){.dynlib: dllname, importc: "glRasterPos2i".} proc glRasterPos2iv*(v: PGLint){.dynlib: dllname, importc: "glRasterPos2iv".} proc glRasterPos2s*(x, y: TGLshort){.dynlib: dllname, importc: "glRasterPos2s".} proc glRasterPos2sv*(v: PGLshort){.dynlib: dllname, importc: "glRasterPos2sv".} -proc glRasterPos3d*(x, y, z: TGLdouble){.dynlib: dllname, +proc glRasterPos3d*(x, y, z: TGLdouble){.dynlib: dllname, importc: "glRasterPos3d".} proc glRasterPos3dv*(v: PGLdouble){.dynlib: dllname, importc: "glRasterPos3dv".} -proc glRasterPos3f*(x, y, z: TGLfloat){.dynlib: dllname, +proc glRasterPos3f*(x, y, z: TGLfloat){.dynlib: dllname, importc: "glRasterPos3f".} proc glRasterPos3fv*(v: PGLfloat){.dynlib: dllname, importc: "glRasterPos3fv".} proc glRasterPos3i*(x, y, z: TGLint){.dynlib: dllname, importc: "glRasterPos3i".} proc glRasterPos3iv*(v: PGLint){.dynlib: dllname, importc: "glRasterPos3iv".} -proc glRasterPos3s*(x, y, z: TGLshort){.dynlib: dllname, +proc glRasterPos3s*(x, y, z: TGLshort){.dynlib: dllname, importc: "glRasterPos3s".} proc glRasterPos3sv*(v: PGLshort){.dynlib: dllname, importc: "glRasterPos3sv".} -proc glRasterPos4d*(x, y, z, w: TGLdouble){.dynlib: dllname, +proc glRasterPos4d*(x, y, z, w: TGLdouble){.dynlib: dllname, importc: "glRasterPos4d".} proc glRasterPos4dv*(v: PGLdouble){.dynlib: dllname, importc: "glRasterPos4dv".} -proc glRasterPos4f*(x, y, z, w: TGLfloat){.dynlib: dllname, +proc glRasterPos4f*(x, y, z, w: TGLfloat){.dynlib: dllname, importc: "glRasterPos4f".} proc glRasterPos4fv*(v: PGLfloat){.dynlib: dllname, importc: "glRasterPos4fv".} -proc glRasterPos4i*(x, y, z, w: TGLint){.dynlib: dllname, +proc glRasterPos4i*(x, y, z, w: TGLint){.dynlib: dllname, importc: "glRasterPos4i".} proc glRasterPos4iv*(v: PGLint){.dynlib: dllname, importc: "glRasterPos4iv".} -proc glRasterPos4s*(x, y, z, w: TGLshort){.dynlib: dllname, +proc glRasterPos4s*(x, y, z, w: TGLshort){.dynlib: dllname, importc: "glRasterPos4s".} proc glRasterPos4sv*(v: PGLshort){.dynlib: dllname, importc: "glRasterPos4sv".} proc glReadBuffer*(mode: TGLenum){.dynlib: dllname, importc: "glReadBuffer".} -proc glReadPixels*(x, y: TGLint, width, height: TGLsizei, - format, atype: TGLenum, pixels: pointer){.dynlib: dllname, +proc glReadPixels*(x, y: TGLint, width, height: TGLsizei, + format, atype: TGLenum, pixels: pointer){.dynlib: dllname, importc: "glReadPixels".} proc glRectd*(x1, y1, x2, y2: TGLdouble){.dynlib: dllname, importc: "glRectd".} -proc glRectdv*(v1: PGLdouble, v2: PGLdouble){.dynlib: dllname, +proc glRectdv*(v1: PGLdouble, v2: PGLdouble){.dynlib: dllname, importc: "glRectdv".} proc glRectf*(x1, y1, x2, y2: TGLfloat){.dynlib: dllname, importc: "glRectf".} proc glRectfv*(v1: PGLfloat, v2: PGLfloat){.dynlib: dllname, importc: "glRectfv".} @@ -1371,22 +1371,22 @@ proc glRecti*(x1, y1, x2, y2: TGLint){.dynlib: dllname, importc: "glRecti".} proc glRectiv*(v1: PGLint, v2: PGLint){.dynlib: dllname, importc: "glRectiv".} proc glRects*(x1, y1, x2, y2: TGLshort){.dynlib: dllname, importc: "glRects".} proc glRectsv*(v1: PGLshort, v2: PGLshort){.dynlib: dllname, importc: "glRectsv".} -proc glRenderMode*(mode: TGLint): TGLint{.dynlib: dllname, +proc glRenderMode*(mode: TGLint): TGLint{.dynlib: dllname, importc: "glRenderMode".} -proc glRotated*(angle, x, y, z: TGLdouble){.dynlib: dllname, +proc glRotated*(angle, x, y, z: TGLdouble){.dynlib: dllname, importc: "glRotated".} proc glRotatef*(angle, x, y, z: TGLfloat){.dynlib: dllname, importc: "glRotatef".} proc glScaled*(x, y, z: TGLdouble){.dynlib: dllname, importc: "glScaled".} proc glScalef*(x, y, z: TGLfloat){.dynlib: dllname, importc: "glScalef".} -proc glScissor*(x, y: TGLint, width, height: TGLsizei){.dynlib: dllname, +proc glScissor*(x, y: TGLint, width, height: TGLsizei){.dynlib: dllname, importc: "glScissor".} -proc glSelectBuffer*(size: TGLsizei, buffer: PGLuint){.dynlib: dllname, +proc glSelectBuffer*(size: TGLsizei, buffer: PGLuint){.dynlib: dllname, importc: "glSelectBuffer".} proc glShadeModel*(mode: TGLenum){.dynlib: dllname, importc: "glShadeModel".} proc glStencilFunc*(fun: TGLenum, theref: TGLint, mask: TGLuint){. dynlib: dllname, importc: "glStencilFunc".} proc glStencilMask*(mask: TGLuint){.dynlib: dllname, importc: "glStencilMask".} -proc glStencilOp*(fail, zfail, zpass: TGLenum){.dynlib: dllname, +proc glStencilOp*(fail, zfail, zpass: TGLenum){.dynlib: dllname, importc: "glStencilOp".} proc glTexCoord1d*(s: TGLdouble){.dynlib: dllname, importc: "glTexCoord1d".} proc glTexCoord1dv*(v: PGLdouble){.dynlib: dllname, importc: "glTexCoord1dv".} @@ -1412,19 +1412,19 @@ proc glTexCoord3i*(s, t, r: TGLint){.dynlib: dllname, importc: "glTexCoord3i".} proc glTexCoord3iv*(v: PGLint){.dynlib: dllname, importc: "glTexCoord3iv".} proc glTexCoord3s*(s, t, r: TGLshort){.dynlib: dllname, importc: "glTexCoord3s".} proc glTexCoord3sv*(v: PGLshort){.dynlib: dllname, importc: "glTexCoord3sv".} -proc glTexCoord4d*(s, t, r, q: TGLdouble){.dynlib: dllname, +proc glTexCoord4d*(s, t, r, q: TGLdouble){.dynlib: dllname, importc: "glTexCoord4d".} proc glTexCoord4dv*(v: PGLdouble){.dynlib: dllname, importc: "glTexCoord4dv".} -proc glTexCoord4f*(s, t, r, q: TGLfloat){.dynlib: dllname, +proc glTexCoord4f*(s, t, r, q: TGLfloat){.dynlib: dllname, importc: "glTexCoord4f".} proc glTexCoord4fv*(v: PGLfloat){.dynlib: dllname, importc: "glTexCoord4fv".} proc glTexCoord4i*(s, t, r, q: TGLint){.dynlib: dllname, importc: "glTexCoord4i".} proc glTexCoord4iv*(v: PGLint){.dynlib: dllname, importc: "glTexCoord4iv".} -proc glTexCoord4s*(s, t, r, q: TGLshort){.dynlib: dllname, +proc glTexCoord4s*(s, t, r, q: TGLshort){.dynlib: dllname, importc: "glTexCoord4s".} proc glTexCoord4sv*(v: PGLshort){.dynlib: dllname, importc: "glTexCoord4sv".} -proc glTexCoordPointer*(size: TGLint, atype: TGLenum, stride: TGLsizei, - p: pointer){.dynlib: dllname, +proc glTexCoordPointer*(size: TGLint, atype: TGLenum, stride: TGLsizei, + p: pointer){.dynlib: dllname, importc: "glTexCoordPointer".} proc glTexEnvf*(target: TGLenum, pname: TGLenum, param: TGLfloat){. dynlib: dllname, importc: "glTexEnvf".} @@ -1442,16 +1442,16 @@ proc glTexGenf*(coord: TGLenum, pname: TGLenum, param: TGLfloat){. dynlib: dllname, importc: "glTexGenf".} proc glTexGenfv*(coord: TGLenum, pname: TGLenum, params: PGLfloat){. dynlib: dllname, importc: "glTexGenfv".} -proc glTexGeni*(coord: TGLenum, pname: TGLenum, param: TGLint){.dynlib: dllname, +proc glTexGeni*(coord: TGLenum, pname: TGLenum, param: TGLint){.dynlib: dllname, importc: "glTexGeni".} proc glTexGeniv*(coord: TGLenum, pname: TGLenum, params: PGLint){. dynlib: dllname, importc: "glTexGeniv".} -proc glTexImage1D*(target: TGLenum, level, internalformat: TGLint, - width: TGLsizei, border: TGLint, format, atype: TGLenum, +proc glTexImage1D*(target: TGLenum, level, internalformat: TGLint, + width: TGLsizei, border: TGLint, format, atype: TGLenum, pixels: pointer){.dynlib: dllname, importc: "glTexImage1D".} -proc glTexImage2D*(target: TGLenum, level, internalformat: TGLint, - width, height: TGLsizei, border: TGLint, - format, atype: TGLenum, pixels: pointer){.dynlib: dllname, +proc glTexImage2D*(target: TGLenum, level, internalformat: TGLint, + width, height: TGLsizei, border: TGLint, + format, atype: TGLenum, pixels: pointer){.dynlib: dllname, importc: "glTexImage2D".} proc glTexParameterf*(target: TGLenum, pname: TGLenum, param: TGLfloat){. dynlib: dllname, importc: "glTexParameterf".} @@ -1461,12 +1461,12 @@ proc glTexParameteri*(target: TGLenum, pname: TGLenum, param: TGLint){. dynlib: dllname, importc: "glTexParameteri".} proc glTexParameteriv*(target: TGLenum, pname: TGLenum, params: PGLint){. dynlib: dllname, importc: "glTexParameteriv".} -proc glTexSubImage1D*(target: TGLenum, level, xoffset: TGLint, width: TGLsizei, - format, atype: TGLenum, pixels: pointer){.dynlib: dllname, +proc glTexSubImage1D*(target: TGLenum, level, xoffset: TGLint, width: TGLsizei, + format, atype: TGLenum, pixels: pointer){.dynlib: dllname, importc: "glTexSubImage1D".} -proc glTexSubImage2D*(target: TGLenum, level, xoffset, yoffset: TGLint, - width, height: TGLsizei, format, atype: TGLenum, - pixels: pointer){.dynlib: dllname, +proc glTexSubImage2D*(target: TGLenum, level, xoffset, yoffset: TGLint, + width, height: TGLsizei, format, atype: TGLenum, + pixels: pointer){.dynlib: dllname, importc: "glTexSubImage2D".} proc glTranslated*(x, y, z: TGLdouble){.dynlib: dllname, importc: "glTranslated".} proc glTranslatef*(x, y, z: TGLfloat){.dynlib: dllname, importc: "glTranslatef".} @@ -1494,42 +1494,42 @@ proc glVertex4i*(x, y, z, w: TGLint){.dynlib: dllname, importc: "glVertex4i".} proc glVertex4iv*(v: PGLint){.dynlib: dllname, importc: "glVertex4iv".} proc glVertex4s*(x, y, z, w: TGLshort){.dynlib: dllname, importc: "glVertex4s".} proc glVertex4sv*(v: PGLshort){.dynlib: dllname, importc: "glVertex4sv".} -proc glVertexPointer*(size: TGLint, atype: TGLenum, stride: TGLsizei, - p: pointer){.dynlib: dllname, +proc glVertexPointer*(size: TGLint, atype: TGLenum, stride: TGLsizei, + p: pointer){.dynlib: dllname, importc: "glVertexPointer".} -proc glViewport*(x, y: TGLint, width, height: TGLsizei){.dynlib: dllname, +proc glViewport*(x, y: TGLint, width, height: TGLsizei){.dynlib: dllname, importc: "glViewport".} -type +type PFN_GLARRAY_ELEMENT_EXTPROC* = proc (i: TGLint) - PFN_GLDRAW_ARRAYS_EXTPROC* = proc (mode: TGLenum, first: TGLint, + PFN_GLDRAW_ARRAYS_EXTPROC* = proc (mode: TGLenum, first: TGLint, count: TGLsizei) - PFN_GLVERTEX_POINTER_EXTPROC* = proc (size: TGLint, atype: TGLenum, - stride, count: TGLsizei, + PFN_GLVERTEX_POINTER_EXTPROC* = proc (size: TGLint, atype: TGLenum, + stride, count: TGLsizei, p: pointer) - PFN_GLNORMAL_POINTER_EXTPROC* = proc (atype: TGLenum, stride, count: TGLsizei, + PFN_GLNORMAL_POINTER_EXTPROC* = proc (atype: TGLenum, stride, count: TGLsizei, p: pointer) - PFN_GLCOLOR_POINTER_EXTPROC* = proc (size: TGLint, atype: TGLenum, + PFN_GLCOLOR_POINTER_EXTPROC* = proc (size: TGLint, atype: TGLenum, stride, count: TGLsizei, p: pointer) - PFN_GLINDEX_POINTER_EXTPROC* = proc (atype: TGLenum, stride, count: TGLsizei, + PFN_GLINDEX_POINTER_EXTPROC* = proc (atype: TGLenum, stride, count: TGLsizei, p: pointer) - PFN_GLTEXCOORD_POINTER_EXTPROC* = proc (size: TGLint, atype: TGLenum, + PFN_GLTEXCOORD_POINTER_EXTPROC* = proc (size: TGLint, atype: TGLenum, stride, count: TGLsizei, p: pointer) - PFN_GLEDGEFLAG_POINTER_EXTPROC* = proc (stride, count: TGLsizei, + PFN_GLEDGEFLAG_POINTER_EXTPROC* = proc (stride, count: TGLsizei, pointer: PGLboolean) PFN_GLGET_POINTER_VEXT_PROC* = proc (pname: TGLenum, params: pointer) - PFN_GLARRAY_ELEMENT_ARRAY_EXTPROC* = proc (mode: TGLenum, count: TGLsizei, + PFN_GLARRAY_ELEMENT_ARRAY_EXTPROC* = proc (mode: TGLenum, count: TGLsizei, pi: pointer) # WIN_swap_hint PFN_GLADDSWAPHINT_RECT_WINPROC* = proc (x, y: TGLint, width, height: TGLsizei) - PFN_GLCOLOR_TABLE_EXTPROC* = proc (target, internalFormat: TGLenum, - width: TGLsizei, format, atype: TGLenum, + PFN_GLCOLOR_TABLE_EXTPROC* = proc (target, internalFormat: TGLenum, + width: TGLsizei, format, atype: TGLenum, data: pointer) - PFN_GLCOLOR_SUBTABLE_EXTPROC* = proc (target: TGLenum, start, count: TGLsizei, + PFN_GLCOLOR_SUBTABLE_EXTPROC* = proc (target: TGLenum, start, count: TGLsizei, format, atype: TGLenum, data: pointer) - PFN_GLGETCOLOR_TABLE_EXTPROC* = proc (target, format, atype: TGLenum, + PFN_GLGETCOLOR_TABLE_EXTPROC* = proc (target, format, atype: TGLenum, data: pointer) - PFN_GLGETCOLOR_TABLE_PARAMETER_IVEXTPROC* = proc (target, pname: TGLenum, + PFN_GLGETCOLOR_TABLE_PARAMETER_IVEXTPROC* = proc (target, pname: TGLenum, params: PGLint) - PFN_GLGETCOLOR_TABLE_PARAMETER_FVEXTPROC* = proc (target, pname: TGLenum, + PFN_GLGETCOLOR_TABLE_PARAMETER_FVEXTPROC* = proc (target, pname: TGLenum, params: PGLfloat) {.pop.} diff --git a/tests/manyloc/keineschweine/lib/glext.nim b/tests/manyloc/keineschweine/lib/glext.nim index 32871df0e4..1e1bdb9582 100644 --- a/tests/manyloc/keineschweine/lib/glext.nim +++ b/tests/manyloc/keineschweine/lib/glext.nim @@ -13,14 +13,14 @@ # ************************************************* #*** Generated on 10/11/2002 -when defined(windows): +when defined(windows): {.push, callconv: stdcall.} -else: +else: {.push, callconv: cdecl.} -import +import gl -type +type GLcharARB* = Char TGLcharARB* = GLcharARB PGLcharARB* = ptr GLcharARB @@ -37,7 +37,7 @@ type TGLchar* = GLchar PGLchar* = cstring #***** GL_version_1_2 *****// -const +const GL_UNSIGNED_BYTE_3_3_2* = 0x00008032 GL_UNSIGNED_SHORT_4_4_4_4* = 0x00008033 GL_UNSIGNED_SHORT_5_5_5_1* = 0x00008034 @@ -79,44 +79,44 @@ const GL_TEXTURE_WRAP_R* = 0x00008072 GL_MAX_3D_TEXTURE_SIZE* = 0x00008073 -proc glBlendColor*(red: TGLclampf, green: TGLclampf, blue: TGLclampf, +proc glBlendColor*(red: TGLclampf, green: TGLclampf, blue: TGLclampf, alpha: TGLclampf){.dynlib: dllname, importc: "glBlendColor".} -proc glBlendEquation*(mode: TGLenum){.dynlib: dllname, +proc glBlendEquation*(mode: TGLenum){.dynlib: dllname, importc: "glBlendEquation".} -proc glDrawRangeElements*(mode: TGLenum, start: TGLuint, theend: TGLuint, +proc glDrawRangeElements*(mode: TGLenum, start: TGLuint, theend: TGLuint, count: TGLsizei, thetype: TGLenum, indices: PGLvoid){. dynlib: dllname, importc: "glDrawRangeElements".} -proc glColorTable*(target: TGLenum, internalformat: TGLenum, width: TGLsizei, +proc glColorTable*(target: TGLenum, internalformat: TGLenum, width: TGLsizei, format: TGLenum, thetype: TGLenum, table: PGLvoid){. dynlib: dllname, importc: "glColorTable".} proc glColorTableParameterfv*(target: TGLenum, pname: TGLenum, params: PGLfloat){. dynlib: dllname, importc: "glColorTableParameterfv".} proc glColorTableParameteriv*(target: TGLenum, pname: TGLenum, params: PGLint){. dynlib: dllname, importc: "glColorTableParameteriv".} -proc glCopyColorTable*(target: TGLenum, internalformat: TGLenum, x: TGLint, - y: TGLint, width: TGLsizei){.dynlib: dllname, +proc glCopyColorTable*(target: TGLenum, internalformat: TGLenum, x: TGLint, + y: TGLint, width: TGLsizei){.dynlib: dllname, importc: "glCopyColorTable".} -proc glGetColorTable*(target: TGLenum, format: TGLenum, thetype: TGLenum, - table: PGLvoid){.dynlib: dllname, +proc glGetColorTable*(target: TGLenum, format: TGLenum, thetype: TGLenum, + table: PGLvoid){.dynlib: dllname, importc: "glGetColorTable".} -proc glGetColorTableParameterfv*(target: TGLenum, pname: TGLenum, - params: PGLfloat){.dynlib: dllname, +proc glGetColorTableParameterfv*(target: TGLenum, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, importc: "glGetColorTableParameterfv".} proc glGetColorTableParameteriv*(target: TGLenum, pname: TGLenum, params: PGLint){. dynlib: dllname, importc: "glGetColorTableParameteriv".} -proc glColorSubTable*(target: TGLenum, start: TGLsizei, count: TGLsizei, +proc glColorSubTable*(target: TGLenum, start: TGLsizei, count: TGLsizei, format: TGLenum, thetype: TGLenum, data: PGLvoid){. dynlib: dllname, importc: "glColorSubTable".} -proc glCopyColorSubTable*(target: TGLenum, start: TGLsizei, x: TGLint, - y: TGLint, width: TGLsizei){.dynlib: dllname, +proc glCopyColorSubTable*(target: TGLenum, start: TGLsizei, x: TGLint, + y: TGLint, width: TGLsizei){.dynlib: dllname, importc: "glCopyColorSubTable".} -proc glConvolutionFilter1D*(target: TGLenum, internalformat: TGLenum, - width: TGLsizei, format: TGLenum, thetype: TGLenum, - image: PGLvoid){.dynlib: dllname, +proc glConvolutionFilter1D*(target: TGLenum, internalformat: TGLenum, + width: TGLsizei, format: TGLenum, thetype: TGLenum, + image: PGLvoid){.dynlib: dllname, importc: "glConvolutionFilter1D".} -proc glConvolutionFilter2D*(target: TGLenum, internalformat: TGLenum, - width: TGLsizei, height: TGLsizei, format: TGLenum, - thetype: TGLenum, image: PGLvoid){.dynlib: dllname, +proc glConvolutionFilter2D*(target: TGLenum, internalformat: TGLenum, + width: TGLsizei, height: TGLsizei, format: TGLenum, + thetype: TGLenum, image: PGLvoid){.dynlib: dllname, importc: "glConvolutionFilter2D".} proc glConvolutionParameterf*(target: TGLenum, pname: TGLenum, params: TGLfloat){. dynlib: dllname, importc: "glConvolutionParameterf".} @@ -126,170 +126,170 @@ proc glConvolutionParameteri*(target: TGLenum, pname: TGLenum, params: TGLint){. dynlib: dllname, importc: "glConvolutionParameteri".} proc glConvolutionParameteriv*(target: TGLenum, pname: TGLenum, params: PGLint){. dynlib: dllname, importc: "glConvolutionParameteriv".} -proc glCopyConvolutionFilter1D*(target: TGLenum, internalformat: TGLenum, +proc glCopyConvolutionFilter1D*(target: TGLenum, internalformat: TGLenum, x: TGLint, y: TGLint, width: TGLsizei){. dynlib: dllname, importc: "glCopyConvolutionFilter1D".} -proc glCopyConvolutionFilter2D*(target: TGLenum, internalformat: TGLenum, - x: TGLint, y: TGLint, width: TGLsizei, - height: TGLsizei){.dynlib: dllname, +proc glCopyConvolutionFilter2D*(target: TGLenum, internalformat: TGLenum, + x: TGLint, y: TGLint, width: TGLsizei, + height: TGLsizei){.dynlib: dllname, importc: "glCopyConvolutionFilter2D".} -proc glGetConvolutionFilter*(target: TGLenum, format: TGLenum, thetype: TGLenum, - image: PGLvoid){.dynlib: dllname, +proc glGetConvolutionFilter*(target: TGLenum, format: TGLenum, thetype: TGLenum, + image: PGLvoid){.dynlib: dllname, importc: "glGetConvolutionFilter".} -proc glGetConvolutionParameterfv*(target: TGLenum, pname: TGLenum, - params: PGLfloat){.dynlib: dllname, +proc glGetConvolutionParameterfv*(target: TGLenum, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, importc: "glGetConvolutionParameterfv".} -proc glGetConvolutionParameteriv*(target: TGLenum, pname: TGLenum, - params: PGLint){.dynlib: dllname, +proc glGetConvolutionParameteriv*(target: TGLenum, pname: TGLenum, + params: PGLint){.dynlib: dllname, importc: "glGetConvolutionParameteriv".} -proc glGetSeparableFilter*(target: TGLenum, format: TGLenum, thetype: TGLenum, +proc glGetSeparableFilter*(target: TGLenum, format: TGLenum, thetype: TGLenum, row: PGLvoid, column: PGLvoid, span: PGLvoid){. dynlib: dllname, importc: "glGetSeparableFilter".} -proc glSeparableFilter2D*(target: TGLenum, internalformat: TGLenum, - width: TGLsizei, height: TGLsizei, format: TGLenum, +proc glSeparableFilter2D*(target: TGLenum, internalformat: TGLenum, + width: TGLsizei, height: TGLsizei, format: TGLenum, thetype: TGLenum, row: PGLvoid, column: PGLvoid){. dynlib: dllname, importc: "glSeparableFilter2D".} -proc glGetHistogram*(target: TGLenum, reset: TGLboolean, format: TGLenum, - thetype: TGLenum, values: PGLvoid){.dynlib: dllname, +proc glGetHistogram*(target: TGLenum, reset: TGLboolean, format: TGLenum, + thetype: TGLenum, values: PGLvoid){.dynlib: dllname, importc: "glGetHistogram".} -proc glGetHistogramParameterfv*(target: TGLenum, pname: TGLenum, - params: PGLfloat){.dynlib: dllname, +proc glGetHistogramParameterfv*(target: TGLenum, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, importc: "glGetHistogramParameterfv".} proc glGetHistogramParameteriv*(target: TGLenum, pname: TGLenum, params: PGLint){. dynlib: dllname, importc: "glGetHistogramParameteriv".} -proc glGetMinmax*(target: TGLenum, reset: TGLboolean, format: TGLenum, - thetype: TGLenum, values: PGLvoid){.dynlib: dllname, +proc glGetMinmax*(target: TGLenum, reset: TGLboolean, format: TGLenum, + thetype: TGLenum, values: PGLvoid){.dynlib: dllname, importc: "glGetMinmax".} proc glGetMinmaxParameterfv*(target: TGLenum, pname: TGLenum, params: PGLfloat){. dynlib: dllname, importc: "glGetMinmaxParameterfv".} proc glGetMinmaxParameteriv*(target: TGLenum, pname: TGLenum, params: PGLint){. dynlib: dllname, importc: "glGetMinmaxParameteriv".} -proc glHistogram*(target: TGLenum, width: TGLsizei, internalformat: TGLenum, +proc glHistogram*(target: TGLenum, width: TGLsizei, internalformat: TGLenum, sink: TGLboolean){.dynlib: dllname, importc: "glHistogram".} proc glMinmax*(target: TGLenum, internalformat: TGLenum, sink: TGLboolean){. dynlib: dllname, importc: "glMinmax".} -proc glResetHistogram*(target: TGLenum){.dynlib: dllname, +proc glResetHistogram*(target: TGLenum){.dynlib: dllname, importc: "glResetHistogram".} proc glResetMinmax*(target: TGLenum){.dynlib: dllname, importc: "glResetMinmax".} -proc glTexImage3D*(target: TGLenum, level: TGLint, internalformat: TGLint, - width: TGLsizei, height: TGLsizei, depth: TGLsizei, - border: TGLint, format: TGLenum, thetype: TGLenum, +proc glTexImage3D*(target: TGLenum, level: TGLint, internalformat: TGLint, + width: TGLsizei, height: TGLsizei, depth: TGLsizei, + border: TGLint, format: TGLenum, thetype: TGLenum, pixels: PGLvoid){.dynlib: dllname, importc: "glTexImage3D".} -proc glTexSubImage3D*(target: TGLenum, level: TGLint, xoffset: TGLint, - yoffset: TGLint, zoffset: TGLint, width: TGLsizei, - height: TGLsizei, depth: TGLsizei, format: TGLenum, - thetype: TGLenum, pixels: PGLvoid){.dynlib: dllname, +proc glTexSubImage3D*(target: TGLenum, level: TGLint, xoffset: TGLint, + yoffset: TGLint, zoffset: TGLint, width: TGLsizei, + height: TGLsizei, depth: TGLsizei, format: TGLenum, + thetype: TGLenum, pixels: PGLvoid){.dynlib: dllname, importc: "glTexSubImage3D".} -proc glCopyTexSubImage3D*(target: TGLenum, level: TGLint, xoffset: TGLint, - yoffset: TGLint, zoffset: TGLint, x: TGLint, +proc glCopyTexSubImage3D*(target: TGLenum, level: TGLint, xoffset: TGLint, + yoffset: TGLint, zoffset: TGLint, x: TGLint, y: TGLint, width: TGLsizei, height: TGLsizei){. dynlib: dllname, importc: "glCopyTexSubImage3D".} -proc glActiveTextureARB*(texture: TGLenum){.dynlib: dllname, +proc glActiveTextureARB*(texture: TGLenum){.dynlib: dllname, importc: "glActiveTextureARB".} -proc glClientActiveTextureARB*(texture: TGLenum){.dynlib: dllname, +proc glClientActiveTextureARB*(texture: TGLenum){.dynlib: dllname, importc: "glClientActiveTextureARB".} -proc glMultiTexCoord1dARB*(target: TGLenum, s: TGLdouble){.dynlib: dllname, +proc glMultiTexCoord1dARB*(target: TGLenum, s: TGLdouble){.dynlib: dllname, importc: "glMultiTexCoord1dARB".} -proc glMultiTexCoord1dvARB*(target: TGLenum, v: PGLdouble){.dynlib: dllname, +proc glMultiTexCoord1dvARB*(target: TGLenum, v: PGLdouble){.dynlib: dllname, importc: "glMultiTexCoord1dvARB".} -proc glMultiTexCoord1fARB*(target: TGLenum, s: TGLfloat){.dynlib: dllname, +proc glMultiTexCoord1fARB*(target: TGLenum, s: TGLfloat){.dynlib: dllname, importc: "glMultiTexCoord1fARB".} -proc glMultiTexCoord1fvARB*(target: TGLenum, v: PGLfloat){.dynlib: dllname, +proc glMultiTexCoord1fvARB*(target: TGLenum, v: PGLfloat){.dynlib: dllname, importc: "glMultiTexCoord1fvARB".} -proc glMultiTexCoord1iARB*(target: TGLenum, s: TGLint){.dynlib: dllname, +proc glMultiTexCoord1iARB*(target: TGLenum, s: TGLint){.dynlib: dllname, importc: "glMultiTexCoord1iARB".} -proc glMultiTexCoord1ivARB*(target: TGLenum, v: PGLint){.dynlib: dllname, +proc glMultiTexCoord1ivARB*(target: TGLenum, v: PGLint){.dynlib: dllname, importc: "glMultiTexCoord1ivARB".} -proc glMultiTexCoord1sARB*(target: TGLenum, s: TGLshort){.dynlib: dllname, +proc glMultiTexCoord1sARB*(target: TGLenum, s: TGLshort){.dynlib: dllname, importc: "glMultiTexCoord1sARB".} -proc glMultiTexCoord1svARB*(target: TGLenum, v: PGLshort){.dynlib: dllname, +proc glMultiTexCoord1svARB*(target: TGLenum, v: PGLshort){.dynlib: dllname, importc: "glMultiTexCoord1svARB".} proc glMultiTexCoord2dARB*(target: TGLenum, s: TGLdouble, t: TGLdouble){. dynlib: dllname, importc: "glMultiTexCoord2dARB".} -proc glMultiTexCoord2dvARB*(target: TGLenum, v: PGLdouble){.dynlib: dllname, +proc glMultiTexCoord2dvARB*(target: TGLenum, v: PGLdouble){.dynlib: dllname, importc: "glMultiTexCoord2dvARB".} proc glMultiTexCoord2fARB*(target: TGLenum, s: TGLfloat, t: TGLfloat){. dynlib: dllname, importc: "glMultiTexCoord2fARB".} -proc glMultiTexCoord2fvARB*(target: TGLenum, v: PGLfloat){.dynlib: dllname, +proc glMultiTexCoord2fvARB*(target: TGLenum, v: PGLfloat){.dynlib: dllname, importc: "glMultiTexCoord2fvARB".} proc glMultiTexCoord2iARB*(target: TGLenum, s: TGLint, t: TGLint){. dynlib: dllname, importc: "glMultiTexCoord2iARB".} -proc glMultiTexCoord2ivARB*(target: TGLenum, v: PGLint){.dynlib: dllname, +proc glMultiTexCoord2ivARB*(target: TGLenum, v: PGLint){.dynlib: dllname, importc: "glMultiTexCoord2ivARB".} proc glMultiTexCoord2sARB*(target: TGLenum, s: TGLshort, t: TGLshort){. dynlib: dllname, importc: "glMultiTexCoord2sARB".} -proc glMultiTexCoord2svARB*(target: TGLenum, v: PGLshort){.dynlib: dllname, +proc glMultiTexCoord2svARB*(target: TGLenum, v: PGLshort){.dynlib: dllname, importc: "glMultiTexCoord2svARB".} -proc glMultiTexCoord3dARB*(target: TGLenum, s: TGLdouble, t: TGLdouble, - r: TGLdouble){.dynlib: dllname, +proc glMultiTexCoord3dARB*(target: TGLenum, s: TGLdouble, t: TGLdouble, + r: TGLdouble){.dynlib: dllname, importc: "glMultiTexCoord3dARB".} -proc glMultiTexCoord3dvARB*(target: TGLenum, v: PGLdouble){.dynlib: dllname, +proc glMultiTexCoord3dvARB*(target: TGLenum, v: PGLdouble){.dynlib: dllname, importc: "glMultiTexCoord3dvARB".} -proc glMultiTexCoord3fARB*(target: TGLenum, s: TGLfloat, t: TGLfloat, - r: TGLfloat){.dynlib: dllname, +proc glMultiTexCoord3fARB*(target: TGLenum, s: TGLfloat, t: TGLfloat, + r: TGLfloat){.dynlib: dllname, importc: "glMultiTexCoord3fARB".} -proc glMultiTexCoord3fvARB*(target: TGLenum, v: PGLfloat){.dynlib: dllname, +proc glMultiTexCoord3fvARB*(target: TGLenum, v: PGLfloat){.dynlib: dllname, importc: "glMultiTexCoord3fvARB".} proc glMultiTexCoord3iARB*(target: TGLenum, s: TGLint, t: TGLint, r: TGLint){. dynlib: dllname, importc: "glMultiTexCoord3iARB".} -proc glMultiTexCoord3ivARB*(target: TGLenum, v: PGLint){.dynlib: dllname, +proc glMultiTexCoord3ivARB*(target: TGLenum, v: PGLint){.dynlib: dllname, importc: "glMultiTexCoord3ivARB".} -proc glMultiTexCoord3sARB*(target: TGLenum, s: TGLshort, t: TGLshort, - r: TGLshort){.dynlib: dllname, +proc glMultiTexCoord3sARB*(target: TGLenum, s: TGLshort, t: TGLshort, + r: TGLshort){.dynlib: dllname, importc: "glMultiTexCoord3sARB".} -proc glMultiTexCoord3svARB*(target: TGLenum, v: PGLshort){.dynlib: dllname, +proc glMultiTexCoord3svARB*(target: TGLenum, v: PGLshort){.dynlib: dllname, importc: "glMultiTexCoord3svARB".} -proc glMultiTexCoord4dARB*(target: TGLenum, s: TGLdouble, t: TGLdouble, - r: TGLdouble, q: TGLdouble){.dynlib: dllname, +proc glMultiTexCoord4dARB*(target: TGLenum, s: TGLdouble, t: TGLdouble, + r: TGLdouble, q: TGLdouble){.dynlib: dllname, importc: "glMultiTexCoord4dARB".} -proc glMultiTexCoord4dvARB*(target: TGLenum, v: PGLdouble){.dynlib: dllname, +proc glMultiTexCoord4dvARB*(target: TGLenum, v: PGLdouble){.dynlib: dllname, importc: "glMultiTexCoord4dvARB".} -proc glMultiTexCoord4fARB*(target: TGLenum, s: TGLfloat, t: TGLfloat, - r: TGLfloat, q: TGLfloat){.dynlib: dllname, +proc glMultiTexCoord4fARB*(target: TGLenum, s: TGLfloat, t: TGLfloat, + r: TGLfloat, q: TGLfloat){.dynlib: dllname, importc: "glMultiTexCoord4fARB".} -proc glMultiTexCoord4fvARB*(target: TGLenum, v: PGLfloat){.dynlib: dllname, +proc glMultiTexCoord4fvARB*(target: TGLenum, v: PGLfloat){.dynlib: dllname, importc: "glMultiTexCoord4fvARB".} -proc glMultiTexCoord4iARB*(target: TGLenum, s: TGLint, t: TGLint, r: TGLint, - q: TGLint){.dynlib: dllname, +proc glMultiTexCoord4iARB*(target: TGLenum, s: TGLint, t: TGLint, r: TGLint, + q: TGLint){.dynlib: dllname, importc: "glMultiTexCoord4iARB".} -proc glMultiTexCoord4ivARB*(target: TGLenum, v: PGLint){.dynlib: dllname, +proc glMultiTexCoord4ivARB*(target: TGLenum, v: PGLint){.dynlib: dllname, importc: "glMultiTexCoord4ivARB".} -proc glMultiTexCoord4sARB*(target: TGLenum, s: TGLshort, t: TGLshort, - r: TGLshort, q: TGLshort){.dynlib: dllname, +proc glMultiTexCoord4sARB*(target: TGLenum, s: TGLshort, t: TGLshort, + r: TGLshort, q: TGLshort){.dynlib: dllname, importc: "glMultiTexCoord4sARB".} -proc glMultiTexCoord4svARB*(target: TGLenum, v: PGLshort){.dynlib: dllname, +proc glMultiTexCoord4svARB*(target: TGLenum, v: PGLshort){.dynlib: dllname, importc: "glMultiTexCoord4svARB".} proc glSampleCoverageARB*(value: TGLclampf, invert: TGLboolean){. dynlib: dllname, importc: "glSampleCoverageARB".} #***** GL_ARB_texture_env_add *****// -proc glWeightbvARB*(size: TGLint, weights: PGLbyte){.dynlib: dllname, +proc glWeightbvARB*(size: TGLint, weights: PGLbyte){.dynlib: dllname, importc: "glWeightbvARB".} -proc glWeightsvARB*(size: TGLint, weights: PGLshort){.dynlib: dllname, +proc glWeightsvARB*(size: TGLint, weights: PGLshort){.dynlib: dllname, importc: "glWeightsvARB".} -proc glWeightivARB*(size: TGLint, weights: PGLint){.dynlib: dllname, +proc glWeightivARB*(size: TGLint, weights: PGLint){.dynlib: dllname, importc: "glWeightivARB".} -proc glWeightfvARB*(size: TGLint, weights: PGLfloat){.dynlib: dllname, +proc glWeightfvARB*(size: TGLint, weights: PGLfloat){.dynlib: dllname, importc: "glWeightfvARB".} -proc glWeightdvARB*(size: TGLint, weights: PGLdouble){.dynlib: dllname, +proc glWeightdvARB*(size: TGLint, weights: PGLdouble){.dynlib: dllname, importc: "glWeightdvARB".} -proc glWeightvARB*(size: TGLint, weights: PGLdouble){.dynlib: dllname, +proc glWeightvARB*(size: TGLint, weights: PGLdouble){.dynlib: dllname, importc: "glWeightvARB".} -proc glWeightubvARB*(size: TGLint, weights: PGLubyte){.dynlib: dllname, +proc glWeightubvARB*(size: TGLint, weights: PGLubyte){.dynlib: dllname, importc: "glWeightubvARB".} -proc glWeightusvARB*(size: TGLint, weights: PGLushort){.dynlib: dllname, +proc glWeightusvARB*(size: TGLint, weights: PGLushort){.dynlib: dllname, importc: "glWeightusvARB".} -proc glWeightuivARB*(size: TGLint, weights: PGLuint){.dynlib: dllname, +proc glWeightuivARB*(size: TGLint, weights: PGLuint){.dynlib: dllname, importc: "glWeightuivARB".} -proc glWeightPointerARB*(size: TGLint, thetype: TGLenum, stride: TGLsizei, - pointer: PGLvoid){.dynlib: dllname, +proc glWeightPointerARB*(size: TGLint, thetype: TGLenum, stride: TGLsizei, + pointer: PGLvoid){.dynlib: dllname, importc: "glWeightPointerARB".} -proc glVertexBlendARB*(count: TGLint){.dynlib: dllname, +proc glVertexBlendARB*(count: TGLint){.dynlib: dllname, importc: "glVertexBlendARB".} -proc glVertexAttrib1sARB*(index: TGLuint, x: TGLshort){.dynlib: dllname, +proc glVertexAttrib1sARB*(index: TGLuint, x: TGLshort){.dynlib: dllname, importc: "glVertexAttrib1sARB".} -proc glVertexAttrib1fARB*(index: TGLuint, x: TGLfloat){.dynlib: dllname, +proc glVertexAttrib1fARB*(index: TGLuint, x: TGLfloat){.dynlib: dllname, importc: "glVertexAttrib1fARB".} -proc glVertexAttrib1dARB*(index: TGLuint, x: TGLdouble){.dynlib: dllname, +proc glVertexAttrib1dARB*(index: TGLuint, x: TGLdouble){.dynlib: dllname, importc: "glVertexAttrib1dARB".} proc glVertexAttrib2sARB*(index: TGLuint, x: TGLshort, y: TGLshort){. dynlib: dllname, importc: "glVertexAttrib2sARB".} @@ -301,120 +301,120 @@ proc glVertexAttrib3sARB*(index: TGLuint, x: TGLshort, y: TGLshort, z: TGLshort) dynlib: dllname, importc: "glVertexAttrib3sARB".} proc glVertexAttrib3fARB*(index: TGLuint, x: TGLfloat, y: TGLfloat, z: TGLfloat){. dynlib: dllname, importc: "glVertexAttrib3fARB".} -proc glVertexAttrib3dARB*(index: TGLuint, x: TGLdouble, y: TGLdouble, - z: TGLdouble){.dynlib: dllname, +proc glVertexAttrib3dARB*(index: TGLuint, x: TGLdouble, y: TGLdouble, + z: TGLdouble){.dynlib: dllname, importc: "glVertexAttrib3dARB".} -proc glVertexAttrib4sARB*(index: TGLuint, x: TGLshort, y: TGLshort, z: TGLshort, - w: TGLshort){.dynlib: dllname, +proc glVertexAttrib4sARB*(index: TGLuint, x: TGLshort, y: TGLshort, z: TGLshort, + w: TGLshort){.dynlib: dllname, importc: "glVertexAttrib4sARB".} -proc glVertexAttrib4fARB*(index: TGLuint, x: TGLfloat, y: TGLfloat, z: TGLfloat, - w: TGLfloat){.dynlib: dllname, +proc glVertexAttrib4fARB*(index: TGLuint, x: TGLfloat, y: TGLfloat, z: TGLfloat, + w: TGLfloat){.dynlib: dllname, importc: "glVertexAttrib4fARB".} -proc glVertexAttrib4dARB*(index: TGLuint, x: TGLdouble, y: TGLdouble, - z: TGLdouble, w: TGLdouble){.dynlib: dllname, +proc glVertexAttrib4dARB*(index: TGLuint, x: TGLdouble, y: TGLdouble, + z: TGLdouble, w: TGLdouble){.dynlib: dllname, importc: "glVertexAttrib4dARB".} -proc glVertexAttrib4NubARB*(index: TGLuint, x: TGLubyte, y: TGLubyte, - z: TGLubyte, w: TGLubyte){.dynlib: dllname, +proc glVertexAttrib4NubARB*(index: TGLuint, x: TGLubyte, y: TGLubyte, + z: TGLubyte, w: TGLubyte){.dynlib: dllname, importc: "glVertexAttrib4NubARB".} -proc glVertexAttrib1svARB*(index: TGLuint, v: PGLshort){.dynlib: dllname, +proc glVertexAttrib1svARB*(index: TGLuint, v: PGLshort){.dynlib: dllname, importc: "glVertexAttrib1svARB".} -proc glVertexAttrib1fvARB*(index: TGLuint, v: PGLfloat){.dynlib: dllname, +proc glVertexAttrib1fvARB*(index: TGLuint, v: PGLfloat){.dynlib: dllname, importc: "glVertexAttrib1fvARB".} -proc glVertexAttrib1dvARB*(index: TGLuint, v: PGLdouble){.dynlib: dllname, +proc glVertexAttrib1dvARB*(index: TGLuint, v: PGLdouble){.dynlib: dllname, importc: "glVertexAttrib1dvARB".} -proc glVertexAttrib2svARB*(index: TGLuint, v: PGLshort){.dynlib: dllname, +proc glVertexAttrib2svARB*(index: TGLuint, v: PGLshort){.dynlib: dllname, importc: "glVertexAttrib2svARB".} -proc glVertexAttrib2fvARB*(index: TGLuint, v: PGLfloat){.dynlib: dllname, +proc glVertexAttrib2fvARB*(index: TGLuint, v: PGLfloat){.dynlib: dllname, importc: "glVertexAttrib2fvARB".} -proc glVertexAttrib2dvARB*(index: TGLuint, v: PGLdouble){.dynlib: dllname, +proc glVertexAttrib2dvARB*(index: TGLuint, v: PGLdouble){.dynlib: dllname, importc: "glVertexAttrib2dvARB".} -proc glVertexAttrib3svARB*(index: TGLuint, v: PGLshort){.dynlib: dllname, +proc glVertexAttrib3svARB*(index: TGLuint, v: PGLshort){.dynlib: dllname, importc: "glVertexAttrib3svARB".} -proc glVertexAttrib3fvARB*(index: TGLuint, v: PGLfloat){.dynlib: dllname, +proc glVertexAttrib3fvARB*(index: TGLuint, v: PGLfloat){.dynlib: dllname, importc: "glVertexAttrib3fvARB".} -proc glVertexAttrib3dvARB*(index: TGLuint, v: PGLdouble){.dynlib: dllname, +proc glVertexAttrib3dvARB*(index: TGLuint, v: PGLdouble){.dynlib: dllname, importc: "glVertexAttrib3dvARB".} -proc glVertexAttrib4bvARB*(index: TGLuint, v: PGLbyte){.dynlib: dllname, +proc glVertexAttrib4bvARB*(index: TGLuint, v: PGLbyte){.dynlib: dllname, importc: "glVertexAttrib4bvARB".} -proc glVertexAttrib4svARB*(index: TGLuint, v: PGLshort){.dynlib: dllname, +proc glVertexAttrib4svARB*(index: TGLuint, v: PGLshort){.dynlib: dllname, importc: "glVertexAttrib4svARB".} -proc glVertexAttrib4ivARB*(index: TGLuint, v: PGLint){.dynlib: dllname, +proc glVertexAttrib4ivARB*(index: TGLuint, v: PGLint){.dynlib: dllname, importc: "glVertexAttrib4ivARB".} -proc glVertexAttrib4ubvARB*(index: TGLuint, v: PGLubyte){.dynlib: dllname, +proc glVertexAttrib4ubvARB*(index: TGLuint, v: PGLubyte){.dynlib: dllname, importc: "glVertexAttrib4ubvARB".} -proc glVertexAttrib4usvARB*(index: TGLuint, v: PGLushort){.dynlib: dllname, +proc glVertexAttrib4usvARB*(index: TGLuint, v: PGLushort){.dynlib: dllname, importc: "glVertexAttrib4usvARB".} -proc glVertexAttrib4uivARB*(index: TGLuint, v: PGLuint){.dynlib: dllname, +proc glVertexAttrib4uivARB*(index: TGLuint, v: PGLuint){.dynlib: dllname, importc: "glVertexAttrib4uivARB".} -proc glVertexAttrib4fvARB*(index: TGLuint, v: PGLfloat){.dynlib: dllname, +proc glVertexAttrib4fvARB*(index: TGLuint, v: PGLfloat){.dynlib: dllname, importc: "glVertexAttrib4fvARB".} -proc glVertexAttrib4dvARB*(index: TGLuint, v: PGLdouble){.dynlib: dllname, +proc glVertexAttrib4dvARB*(index: TGLuint, v: PGLdouble){.dynlib: dllname, importc: "glVertexAttrib4dvARB".} -proc glVertexAttrib4NbvARB*(index: TGLuint, v: PGLbyte){.dynlib: dllname, +proc glVertexAttrib4NbvARB*(index: TGLuint, v: PGLbyte){.dynlib: dllname, importc: "glVertexAttrib4NbvARB".} -proc glVertexAttrib4NsvARB*(index: TGLuint, v: PGLshort){.dynlib: dllname, +proc glVertexAttrib4NsvARB*(index: TGLuint, v: PGLshort){.dynlib: dllname, importc: "glVertexAttrib4NsvARB".} -proc glVertexAttrib4NivARB*(index: TGLuint, v: PGLint){.dynlib: dllname, +proc glVertexAttrib4NivARB*(index: TGLuint, v: PGLint){.dynlib: dllname, importc: "glVertexAttrib4NivARB".} -proc glVertexAttrib4NubvARB*(index: TGLuint, v: PGLubyte){.dynlib: dllname, +proc glVertexAttrib4NubvARB*(index: TGLuint, v: PGLubyte){.dynlib: dllname, importc: "glVertexAttrib4NubvARB".} -proc glVertexAttrib4NusvARB*(index: TGLuint, v: PGLushort){.dynlib: dllname, +proc glVertexAttrib4NusvARB*(index: TGLuint, v: PGLushort){.dynlib: dllname, importc: "glVertexAttrib4NusvARB".} -proc glVertexAttrib4NuivARB*(index: TGLuint, v: PGLuint){.dynlib: dllname, +proc glVertexAttrib4NuivARB*(index: TGLuint, v: PGLuint){.dynlib: dllname, importc: "glVertexAttrib4NuivARB".} -proc glVertexAttribPointerARB*(index: TGLuint, size: TGLint, thetype: TGLenum, - normalized: TGLboolean, stride: TGLsizei, - pointer: PGLvoid){.dynlib: dllname, +proc glVertexAttribPointerARB*(index: TGLuint, size: TGLint, thetype: TGLenum, + normalized: TGLboolean, stride: TGLsizei, + pointer: PGLvoid){.dynlib: dllname, importc: "glVertexAttribPointerARB".} -proc glEnableVertexAttribArrayARB*(index: TGLuint){.dynlib: dllname, +proc glEnableVertexAttribArrayARB*(index: TGLuint){.dynlib: dllname, importc: "glEnableVertexAttribArrayARB".} -proc glDisableVertexAttribArrayARB*(index: TGLuint){.dynlib: dllname, +proc glDisableVertexAttribArrayARB*(index: TGLuint){.dynlib: dllname, importc: "glDisableVertexAttribArrayARB".} -proc glProgramStringARB*(target: TGLenum, format: TGLenum, length: TGLsizei, - str: PGLvoid){.dynlib: dllname, +proc glProgramStringARB*(target: TGLenum, format: TGLenum, length: TGLsizei, + str: PGLvoid){.dynlib: dllname, importc: "glProgramStringARB".} -proc glBindProgramARB*(target: TGLenum, theProgram: TGLuint){.dynlib: dllname, +proc glBindProgramARB*(target: TGLenum, theProgram: TGLuint){.dynlib: dllname, importc: "glBindProgramARB".} -proc glDeleteProgramsARB*(n: TGLsizei, programs: PGLuint){.dynlib: dllname, +proc glDeleteProgramsARB*(n: TGLsizei, programs: PGLuint){.dynlib: dllname, importc: "glDeleteProgramsARB".} -proc glGenProgramsARB*(n: TGLsizei, programs: PGLuint){.dynlib: dllname, +proc glGenProgramsARB*(n: TGLsizei, programs: PGLuint){.dynlib: dllname, importc: "glGenProgramsARB".} -proc glProgramEnvParameter4dARB*(target: TGLenum, index: TGLuint, x: TGLdouble, +proc glProgramEnvParameter4dARB*(target: TGLenum, index: TGLuint, x: TGLdouble, y: TGLdouble, z: TGLdouble, w: TGLdouble){. dynlib: dllname, importc: "glProgramEnvParameter4dARB".} -proc glProgramEnvParameter4dvARB*(target: TGLenum, index: TGLuint, - params: PGLdouble){.dynlib: dllname, +proc glProgramEnvParameter4dvARB*(target: TGLenum, index: TGLuint, + params: PGLdouble){.dynlib: dllname, importc: "glProgramEnvParameter4dvARB".} -proc glProgramEnvParameter4fARB*(target: TGLenum, index: TGLuint, x: TGLfloat, +proc glProgramEnvParameter4fARB*(target: TGLenum, index: TGLuint, x: TGLfloat, y: TGLfloat, z: TGLfloat, w: TGLfloat){. dynlib: dllname, importc: "glProgramEnvParameter4fARB".} -proc glProgramEnvParameter4fvARB*(target: TGLenum, index: TGLuint, - params: PGLfloat){.dynlib: dllname, +proc glProgramEnvParameter4fvARB*(target: TGLenum, index: TGLuint, + params: PGLfloat){.dynlib: dllname, importc: "glProgramEnvParameter4fvARB".} -proc glProgramLocalParameter4dARB*(target: TGLenum, index: TGLuint, - x: TGLdouble, y: TGLdouble, z: TGLdouble, - w: TGLdouble){.dynlib: dllname, +proc glProgramLocalParameter4dARB*(target: TGLenum, index: TGLuint, + x: TGLdouble, y: TGLdouble, z: TGLdouble, + w: TGLdouble){.dynlib: dllname, importc: "glProgramLocalParameter4dARB".} -proc glProgramLocalParameter4dvARB*(target: TGLenum, index: TGLuint, - params: PGLdouble){.dynlib: dllname, +proc glProgramLocalParameter4dvARB*(target: TGLenum, index: TGLuint, + params: PGLdouble){.dynlib: dllname, importc: "glProgramLocalParameter4dvARB".} -proc glProgramLocalParameter4fARB*(target: TGLenum, index: TGLuint, x: TGLfloat, +proc glProgramLocalParameter4fARB*(target: TGLenum, index: TGLuint, x: TGLfloat, y: TGLfloat, z: TGLfloat, w: TGLfloat){. dynlib: dllname, importc: "glProgramLocalParameter4fARB".} -proc glProgramLocalParameter4fvARB*(target: TGLenum, index: TGLuint, - params: PGLfloat){.dynlib: dllname, +proc glProgramLocalParameter4fvARB*(target: TGLenum, index: TGLuint, + params: PGLfloat){.dynlib: dllname, importc: "glProgramLocalParameter4fvARB".} -proc glGetProgramEnvParameterdvARB*(target: TGLenum, index: TGLuint, - params: PGLdouble){.dynlib: dllname, +proc glGetProgramEnvParameterdvARB*(target: TGLenum, index: TGLuint, + params: PGLdouble){.dynlib: dllname, importc: "glGetProgramEnvParameterdvARB".} -proc glGetProgramEnvParameterfvARB*(target: TGLenum, index: TGLuint, - params: PGLfloat){.dynlib: dllname, +proc glGetProgramEnvParameterfvARB*(target: TGLenum, index: TGLuint, + params: PGLfloat){.dynlib: dllname, importc: "glGetProgramEnvParameterfvARB".} -proc glGetProgramLocalParameterdvARB*(target: TGLenum, index: TGLuint, - params: PGLdouble){.dynlib: dllname, +proc glGetProgramLocalParameterdvARB*(target: TGLenum, index: TGLuint, + params: PGLdouble){.dynlib: dllname, importc: "glGetProgramLocalParameterdvARB".} -proc glGetProgramLocalParameterfvARB*(target: TGLenum, index: TGLuint, - params: PGLfloat){.dynlib: dllname, +proc glGetProgramLocalParameterfvARB*(target: TGLenum, index: TGLuint, + params: PGLfloat){.dynlib: dllname, importc: "glGetProgramLocalParameterfvARB".} proc glGetProgramivARB*(target: TGLenum, pname: TGLenum, params: PGLint){. dynlib: dllname, importc: "glGetProgramivARB".} @@ -426,100 +426,100 @@ proc glGetVertexAttribfvARB*(index: TGLuint, pname: TGLenum, params: PGLfloat){. dynlib: dllname, importc: "glGetVertexAttribfvARB".} proc glGetVertexAttribivARB*(index: TGLuint, pname: TGLenum, params: PGLint){. dynlib: dllname, importc: "glGetVertexAttribivARB".} -proc glGetVertexAttribPointervARB*(index: TGLuint, pname: TGLenum, - pointer: PGLvoid){.dynlib: dllname, +proc glGetVertexAttribPointervARB*(index: TGLuint, pname: TGLenum, + pointer: PGLvoid){.dynlib: dllname, importc: "glGetVertexAttribPointervARB".} -proc glIsProgramARB*(theProgram: TGLuint): TGLboolean{.dynlib: dllname, +proc glIsProgramARB*(theProgram: TGLuint): TGLboolean{.dynlib: dllname, importc: "glIsProgramARB".} #***** GL_ARB_window_pos *****// -proc glWindowPos2dARB*(x: TGLdouble, y: TGLdouble){.dynlib: dllname, +proc glWindowPos2dARB*(x: TGLdouble, y: TGLdouble){.dynlib: dllname, importc: "glWindowPos2dARB".} -proc glWindowPos2fARB*(x: TGLfloat, y: TGLfloat){.dynlib: dllname, +proc glWindowPos2fARB*(x: TGLfloat, y: TGLfloat){.dynlib: dllname, importc: "glWindowPos2fARB".} -proc glWindowPos2iARB*(x: TGLint, y: TGLint){.dynlib: dllname, +proc glWindowPos2iARB*(x: TGLint, y: TGLint){.dynlib: dllname, importc: "glWindowPos2iARB".} -proc glWindowPos2sARB*(x: TGLshort, y: TGLshort){.dynlib: dllname, +proc glWindowPos2sARB*(x: TGLshort, y: TGLshort){.dynlib: dllname, importc: "glWindowPos2sARB".} -proc glWindowPos2dvARB*(p: PGLdouble){.dynlib: dllname, +proc glWindowPos2dvARB*(p: PGLdouble){.dynlib: dllname, importc: "glWindowPos2dvARB".} -proc glWindowPos2fvARB*(p: PGLfloat){.dynlib: dllname, +proc glWindowPos2fvARB*(p: PGLfloat){.dynlib: dllname, importc: "glWindowPos2fvARB".} -proc glWindowPos2ivARB*(p: PGLint){.dynlib: dllname, +proc glWindowPos2ivARB*(p: PGLint){.dynlib: dllname, importc: "glWindowPos2ivARB".} -proc glWindowPos2svARB*(p: PGLshort){.dynlib: dllname, +proc glWindowPos2svARB*(p: PGLshort){.dynlib: dllname, importc: "glWindowPos2svARB".} proc glWindowPos3dARB*(x: TGLdouble, y: TGLdouble, z: TGLdouble){. dynlib: dllname, importc: "glWindowPos3dARB".} -proc glWindowPos3fARB*(x: TGLfloat, y: TGLfloat, z: TGLfloat){.dynlib: dllname, +proc glWindowPos3fARB*(x: TGLfloat, y: TGLfloat, z: TGLfloat){.dynlib: dllname, importc: "glWindowPos3fARB".} -proc glWindowPos3iARB*(x: TGLint, y: TGLint, z: TGLint){.dynlib: dllname, +proc glWindowPos3iARB*(x: TGLint, y: TGLint, z: TGLint){.dynlib: dllname, importc: "glWindowPos3iARB".} -proc glWindowPos3sARB*(x: TGLshort, y: TGLshort, z: TGLshort){.dynlib: dllname, +proc glWindowPos3sARB*(x: TGLshort, y: TGLshort, z: TGLshort){.dynlib: dllname, importc: "glWindowPos3sARB".} -proc glWindowPos3dvARB*(p: PGLdouble){.dynlib: dllname, +proc glWindowPos3dvARB*(p: PGLdouble){.dynlib: dllname, importc: "glWindowPos3dvARB".} -proc glWindowPos3fvARB*(p: PGLfloat){.dynlib: dllname, +proc glWindowPos3fvARB*(p: PGLfloat){.dynlib: dllname, importc: "glWindowPos3fvARB".} -proc glWindowPos3ivARB*(p: PGLint){.dynlib: dllname, +proc glWindowPos3ivARB*(p: PGLint){.dynlib: dllname, importc: "glWindowPos3ivARB".} -proc glWindowPos3svARB*(p: PGLshort){.dynlib: dllname, +proc glWindowPos3svARB*(p: PGLshort){.dynlib: dllname, importc: "glWindowPos3svARB".} proc glBlendEquationSeparate*(modeRGB: TGLenum, modeAlpha: TGLenum){. dynlib: dllname, importc: "glBlendEquationSeparate".} -proc glDrawBuffers*(n: TGLsizei, bufs: PGLenum){.dynlib: dllname, +proc glDrawBuffers*(n: TGLsizei, bufs: PGLenum){.dynlib: dllname, importc: "glDrawBuffers".} -proc glStencilOpSeparate*(face: TGLenum, sfail: TGLenum, dpfail: TGLenum, - dppass: TGLenum){.dynlib: dllname, +proc glStencilOpSeparate*(face: TGLenum, sfail: TGLenum, dpfail: TGLenum, + dppass: TGLenum){.dynlib: dllname, importc: "glStencilOpSeparate".} -proc glStencilFuncSeparate*(frontfunc: TGLenum, backfunc: TGLenum, - theRef: TGLint, mask: TGLuint){.dynlib: dllname, +proc glStencilFuncSeparate*(frontfunc: TGLenum, backfunc: TGLenum, + theRef: TGLint, mask: TGLuint){.dynlib: dllname, importc: "glStencilFuncSeparate".} -proc glStencilMaskSeparate*(face: TGLenum, mask: TGLuint){.dynlib: dllname, +proc glStencilMaskSeparate*(face: TGLenum, mask: TGLuint){.dynlib: dllname, importc: "glStencilMaskSeparate".} -proc glAttachShader*(theProgram: TGLuint, shader: TGLuint){.dynlib: dllname, +proc glAttachShader*(theProgram: TGLuint, shader: TGLuint){.dynlib: dllname, importc: "glAttachShader".} proc glBindAttribLocation*(theProgram: TGLuint, index: TGLuint, name: PGLchar){. dynlib: dllname, importc: "glBindAttribLocation".} -proc glCompileShader*(shader: TGLuint){.dynlib: dllname, +proc glCompileShader*(shader: TGLuint){.dynlib: dllname, importc: "glCompileShader".} proc glCreateProgram*(): TGLuint{.dynlib: dllname, importc: "glCreateProgram".} -proc glCreateShader*(thetype: TGLenum): TGLuint{.dynlib: dllname, +proc glCreateShader*(thetype: TGLenum): TGLuint{.dynlib: dllname, importc: "glCreateShader".} -proc glDeleteProgram*(theProgram: TGLuint){.dynlib: dllname, +proc glDeleteProgram*(theProgram: TGLuint){.dynlib: dllname, importc: "glDeleteProgram".} -proc glDeleteShader*(shader: TGLuint){.dynlib: dllname, +proc glDeleteShader*(shader: TGLuint){.dynlib: dllname, importc: "glDeleteShader".} -proc glDetachShader*(theProgram: TGLuint, shader: TGLuint){.dynlib: dllname, +proc glDetachShader*(theProgram: TGLuint, shader: TGLuint){.dynlib: dllname, importc: "glDetachShader".} -proc glDisableVertexAttribArray*(index: TGLuint){.dynlib: dllname, +proc glDisableVertexAttribArray*(index: TGLuint){.dynlib: dllname, importc: "glDisableVertexAttribArray".} -proc glEnableVertexAttribArray*(index: TGLuint){.dynlib: dllname, +proc glEnableVertexAttribArray*(index: TGLuint){.dynlib: dllname, importc: "glEnableVertexAttribArray".} -proc glGetActiveAttrib*(theProgram: TGLuint, index: TGLuint, bufSize: TGLsizei, - len: PGLsizei, size: PGLint, thetype: PGLenum, - name: PGLchar){.dynlib: dllname, +proc glGetActiveAttrib*(theProgram: TGLuint, index: TGLuint, bufSize: TGLsizei, + len: PGLsizei, size: PGLint, thetype: PGLenum, + name: PGLchar){.dynlib: dllname, importc: "glGetActiveAttrib".} -proc glGetActiveUniform*(theProgram: TGLuint, index: TGLuint, bufSize: TGLsizei, - len: PGLsizei, size: PGLint, thetype: PGLenum, - name: PGLchar){.dynlib: dllname, +proc glGetActiveUniform*(theProgram: TGLuint, index: TGLuint, bufSize: TGLsizei, + len: PGLsizei, size: PGLint, thetype: PGLenum, + name: PGLchar){.dynlib: dllname, importc: "glGetActiveUniform".} -proc glGetAttachedShaders*(theProgram: TGLuint, maxCount: TGLsizei, - count: PGLsizei, obj: PGLuint){.dynlib: dllname, +proc glGetAttachedShaders*(theProgram: TGLuint, maxCount: TGLsizei, + count: PGLsizei, obj: PGLuint){.dynlib: dllname, importc: "glGetAttachedShaders".} proc glGetAttribLocation*(theProgram: TGLuint, name: PGLchar): TGLint{. dynlib: dllname, importc: "glGetAttribLocation".} proc glGetProgramiv*(theProgram: TGLuint, pname: TGLenum, params: PGLint){. dynlib: dllname, importc: "glGetProgramiv".} -proc glGetProgramInfoLog*(theProgram: TGLuint, bufSize: TGLsizei, len: PGLsizei, - infoLog: PGLchar){.dynlib: dllname, +proc glGetProgramInfoLog*(theProgram: TGLuint, bufSize: TGLsizei, len: PGLsizei, + infoLog: PGLchar){.dynlib: dllname, importc: "glGetProgramInfoLog".} proc glGetShaderiv*(shader: TGLuint, pname: TGLenum, params: PGLint){. dynlib: dllname, importc: "glGetShaderiv".} -proc glGetShaderInfoLog*(shader: TGLuint, bufSize: TGLsizei, len: PGLsizei, - infoLog: PGLchar){.dynlib: dllname, +proc glGetShaderInfoLog*(shader: TGLuint, bufSize: TGLsizei, len: PGLsizei, + infoLog: PGLchar){.dynlib: dllname, importc: "glGetShaderInfoLog".} -proc glGetShaderSource*(shader: TGLuint, bufSize: TGLsizei, len: PGLsizei, - source: PGLchar){.dynlib: dllname, +proc glGetShaderSource*(shader: TGLuint, bufSize: TGLsizei, len: PGLsizei, + source: PGLchar){.dynlib: dllname, importc: "glGetShaderSource".} proc glGetUniformLocation*(theProgram: TGLuint, name: PGLchar): TGLint{. dynlib: dllname, importc: "glGetUniformLocation".} @@ -535,31 +535,31 @@ proc glGetVertexAttribiv*(index: TGLuint, pname: TGLenum, params: PGLint){. dynlib: dllname, importc: "glGetVertexAttribiv".} proc glGetVertexAttribPointerv*(index: TGLuint, pname: TGLenum, pointer: PGLvoid){. dynlib: dllname, importc: "glGetVertexAttribPointerv".} -proc glIsProgram*(theProgram: TGLuint): TGLboolean{.dynlib: dllname, +proc glIsProgram*(theProgram: TGLuint): TGLboolean{.dynlib: dllname, importc: "glIsProgram".} -proc glIsShader*(shader: TGLuint): TGLboolean{.dynlib: dllname, +proc glIsShader*(shader: TGLuint): TGLboolean{.dynlib: dllname, importc: "glIsShader".} -proc glLinkProgram*(theProgram: TGLuint){.dynlib: dllname, +proc glLinkProgram*(theProgram: TGLuint){.dynlib: dllname, importc: "glLinkProgram".} proc glShaderSource*(shader: TGLuint, count: TGLsizei, str: PGLchar, len: PGLint){. dynlib: dllname, importc: "glShaderSource".} -proc glUseProgram*(theProgram: TGLuint){.dynlib: dllname, +proc glUseProgram*(theProgram: TGLuint){.dynlib: dllname, importc: "glUseProgram".} -proc glUniform1f*(location: TGLint, v0: TGLfloat){.dynlib: dllname, +proc glUniform1f*(location: TGLint, v0: TGLfloat){.dynlib: dllname, importc: "glUniform1f".} proc glUniform2f*(location: TGLint, v0: TGLfloat, v1: TGLfloat){. dynlib: dllname, importc: "glUniform2f".} proc glUniform3f*(location: TGLint, v0: TGLfloat, v1: TGLfloat, v2: TGLfloat){. dynlib: dllname, importc: "glUniform3f".} -proc glUniform4f*(location: TGLint, v0: TGLfloat, v1: TGLfloat, v2: TGLfloat, +proc glUniform4f*(location: TGLint, v0: TGLfloat, v1: TGLfloat, v2: TGLfloat, v3: TGLfloat){.dynlib: dllname, importc: "glUniform4f".} -proc glUniform1i*(location: TGLint, v0: TGLint){.dynlib: dllname, +proc glUniform1i*(location: TGLint, v0: TGLint){.dynlib: dllname, importc: "glUniform1i".} -proc glUniform2i*(location: TGLint, v0: TGLint, v1: TGLint){.dynlib: dllname, +proc glUniform2i*(location: TGLint, v0: TGLint, v1: TGLint){.dynlib: dllname, importc: "glUniform2i".} proc glUniform3i*(location: TGLint, v0: TGLint, v1: TGLint, v2: TGLint){. dynlib: dllname, importc: "glUniform3i".} -proc glUniform4i*(location: TGLint, v0: TGLint, v1: TGLint, v2: TGLint, +proc glUniform4i*(location: TGLint, v0: TGLint, v1: TGLint, v2: TGLint, v3: TGLint){.dynlib: dllname, importc: "glUniform4i".} proc glUniform1fv*(location: TGLint, count: TGLsizei, value: PGLfloat){. dynlib: dllname, importc: "glUniform1fv".} @@ -577,98 +577,98 @@ proc glUniform3iv*(location: TGLint, count: TGLsizei, value: PGLint){. dynlib: dllname, importc: "glUniform3iv".} proc glUniform4iv*(location: TGLint, count: TGLsizei, value: PGLint){. dynlib: dllname, importc: "glUniform4iv".} -proc glUniformMatrix2fv*(location: TGLint, count: TGLsizei, +proc glUniformMatrix2fv*(location: TGLint, count: TGLsizei, transpose: TGLboolean, value: PGLfloat){. dynlib: dllname, importc: "glUniformMatrix2fv".} -proc glUniformMatrix3fv*(location: TGLint, count: TGLsizei, +proc glUniformMatrix3fv*(location: TGLint, count: TGLsizei, transpose: TGLboolean, value: PGLfloat){. dynlib: dllname, importc: "glUniformMatrix3fv".} -proc glUniformMatrix4fv*(location: TGLint, count: TGLsizei, +proc glUniformMatrix4fv*(location: TGLint, count: TGLsizei, transpose: TGLboolean, value: PGLfloat){. dynlib: dllname, importc: "glUniformMatrix4fv".} -proc glValidateProgram*(theProgram: TGLuint){.dynlib: dllname, +proc glValidateProgram*(theProgram: TGLuint){.dynlib: dllname, importc: "glValidateProgram".} -proc glVertexAttrib1d*(index: TGLuint, x: TGLdouble){.dynlib: dllname, +proc glVertexAttrib1d*(index: TGLuint, x: TGLdouble){.dynlib: dllname, importc: "glVertexAttrib1d".} -proc glVertexAttrib1dv*(index: TGLuint, v: PGLdouble){.dynlib: dllname, +proc glVertexAttrib1dv*(index: TGLuint, v: PGLdouble){.dynlib: dllname, importc: "glVertexAttrib1dv".} -proc glVertexAttrib1f*(index: TGLuint, x: TGLfloat){.dynlib: dllname, +proc glVertexAttrib1f*(index: TGLuint, x: TGLfloat){.dynlib: dllname, importc: "glVertexAttrib1f".} -proc glVertexAttrib1fv*(index: TGLuint, v: PGLfloat){.dynlib: dllname, +proc glVertexAttrib1fv*(index: TGLuint, v: PGLfloat){.dynlib: dllname, importc: "glVertexAttrib1fv".} -proc glVertexAttrib1s*(index: TGLuint, x: TGLshort){.dynlib: dllname, +proc glVertexAttrib1s*(index: TGLuint, x: TGLshort){.dynlib: dllname, importc: "glVertexAttrib1s".} -proc glVertexAttrib1sv*(index: TGLuint, v: PGLshort){.dynlib: dllname, +proc glVertexAttrib1sv*(index: TGLuint, v: PGLshort){.dynlib: dllname, importc: "glVertexAttrib1sv".} proc glVertexAttrib2d*(index: TGLuint, x: TGLdouble, y: TGLdouble){. dynlib: dllname, importc: "glVertexAttrib2d".} -proc glVertexAttrib2dv*(index: TGLuint, v: PGLdouble){.dynlib: dllname, +proc glVertexAttrib2dv*(index: TGLuint, v: PGLdouble){.dynlib: dllname, importc: "glVertexAttrib2dv".} proc glVertexAttrib2f*(index: TGLuint, x: TGLfloat, y: TGLfloat){. dynlib: dllname, importc: "glVertexAttrib2f".} -proc glVertexAttrib2fv*(index: TGLuint, v: PGLfloat){.dynlib: dllname, +proc glVertexAttrib2fv*(index: TGLuint, v: PGLfloat){.dynlib: dllname, importc: "glVertexAttrib2fv".} proc glVertexAttrib2s*(index: TGLuint, x: TGLshort, y: TGLshort){. dynlib: dllname, importc: "glVertexAttrib2s".} -proc glVertexAttrib2sv*(index: TGLuint, v: PGLshort){.dynlib: dllname, +proc glVertexAttrib2sv*(index: TGLuint, v: PGLshort){.dynlib: dllname, importc: "glVertexAttrib2sv".} proc glVertexAttrib3d*(index: TGLuint, x: TGLdouble, y: TGLdouble, z: TGLdouble){. dynlib: dllname, importc: "glVertexAttrib3d".} -proc glVertexAttrib3dv*(index: TGLuint, v: PGLdouble){.dynlib: dllname, +proc glVertexAttrib3dv*(index: TGLuint, v: PGLdouble){.dynlib: dllname, importc: "glVertexAttrib3dv".} proc glVertexAttrib3f*(index: TGLuint, x: TGLfloat, y: TGLfloat, z: TGLfloat){. dynlib: dllname, importc: "glVertexAttrib3f".} -proc glVertexAttrib3fv*(index: TGLuint, v: PGLfloat){.dynlib: dllname, +proc glVertexAttrib3fv*(index: TGLuint, v: PGLfloat){.dynlib: dllname, importc: "glVertexAttrib3fv".} proc glVertexAttrib3s*(index: TGLuint, x: TGLshort, y: TGLshort, z: TGLshort){. dynlib: dllname, importc: "glVertexAttrib3s".} -proc glVertexAttrib3sv*(index: TGLuint, v: PGLshort){.dynlib: dllname, +proc glVertexAttrib3sv*(index: TGLuint, v: PGLshort){.dynlib: dllname, importc: "glVertexAttrib3sv".} -proc glVertexAttrib4Nbv*(index: TGLuint, v: PGLbyte){.dynlib: dllname, +proc glVertexAttrib4Nbv*(index: TGLuint, v: PGLbyte){.dynlib: dllname, importc: "glVertexAttrib4Nbv".} -proc glVertexAttrib4Niv*(index: TGLuint, v: PGLint){.dynlib: dllname, +proc glVertexAttrib4Niv*(index: TGLuint, v: PGLint){.dynlib: dllname, importc: "glVertexAttrib4Niv".} -proc glVertexAttrib4Nsv*(index: TGLuint, v: PGLshort){.dynlib: dllname, +proc glVertexAttrib4Nsv*(index: TGLuint, v: PGLshort){.dynlib: dllname, importc: "glVertexAttrib4Nsv".} -proc glVertexAttrib4Nub*(index: TGLuint, x: TGLubyte, y: TGLubyte, z: TGLubyte, - w: TGLubyte){.dynlib: dllname, +proc glVertexAttrib4Nub*(index: TGLuint, x: TGLubyte, y: TGLubyte, z: TGLubyte, + w: TGLubyte){.dynlib: dllname, importc: "glVertexAttrib4Nub".} -proc glVertexAttrib4Nubv*(index: TGLuint, v: PGLubyte){.dynlib: dllname, +proc glVertexAttrib4Nubv*(index: TGLuint, v: PGLubyte){.dynlib: dllname, importc: "glVertexAttrib4Nubv".} -proc glVertexAttrib4Nuiv*(index: TGLuint, v: PGLuint){.dynlib: dllname, +proc glVertexAttrib4Nuiv*(index: TGLuint, v: PGLuint){.dynlib: dllname, importc: "glVertexAttrib4Nuiv".} -proc glVertexAttrib4Nusv*(index: TGLuint, v: PGLushort){.dynlib: dllname, +proc glVertexAttrib4Nusv*(index: TGLuint, v: PGLushort){.dynlib: dllname, importc: "glVertexAttrib4Nusv".} -proc glVertexAttrib4bv*(index: TGLuint, v: PGLbyte){.dynlib: dllname, +proc glVertexAttrib4bv*(index: TGLuint, v: PGLbyte){.dynlib: dllname, importc: "glVertexAttrib4bv".} -proc glVertexAttrib4d*(index: TGLuint, x: TGLdouble, y: TGLdouble, z: TGLdouble, - w: TGLdouble){.dynlib: dllname, +proc glVertexAttrib4d*(index: TGLuint, x: TGLdouble, y: TGLdouble, z: TGLdouble, + w: TGLdouble){.dynlib: dllname, importc: "glVertexAttrib4d".} -proc glVertexAttrib4dv*(index: TGLuint, v: PGLdouble){.dynlib: dllname, +proc glVertexAttrib4dv*(index: TGLuint, v: PGLdouble){.dynlib: dllname, importc: "glVertexAttrib4dv".} -proc glVertexAttrib4f*(index: TGLuint, x: TGLfloat, y: TGLfloat, z: TGLfloat, - w: TGLfloat){.dynlib: dllname, +proc glVertexAttrib4f*(index: TGLuint, x: TGLfloat, y: TGLfloat, z: TGLfloat, + w: TGLfloat){.dynlib: dllname, importc: "glVertexAttrib4f".} -proc glVertexAttrib4fv*(index: TGLuint, v: PGLfloat){.dynlib: dllname, +proc glVertexAttrib4fv*(index: TGLuint, v: PGLfloat){.dynlib: dllname, importc: "glVertexAttrib4fv".} -proc glVertexAttrib4iv*(index: TGLuint, v: PGLint){.dynlib: dllname, +proc glVertexAttrib4iv*(index: TGLuint, v: PGLint){.dynlib: dllname, importc: "glVertexAttrib4iv".} -proc glVertexAttrib4s*(index: TGLuint, x: TGLshort, y: TGLshort, z: TGLshort, - w: TGLshort){.dynlib: dllname, +proc glVertexAttrib4s*(index: TGLuint, x: TGLshort, y: TGLshort, z: TGLshort, + w: TGLshort){.dynlib: dllname, importc: "glVertexAttrib4s".} -proc glVertexAttrib4sv*(index: TGLuint, v: PGLshort){.dynlib: dllname, +proc glVertexAttrib4sv*(index: TGLuint, v: PGLshort){.dynlib: dllname, importc: "glVertexAttrib4sv".} -proc glVertexAttrib4ubv*(index: TGLuint, v: PGLubyte){.dynlib: dllname, +proc glVertexAttrib4ubv*(index: TGLuint, v: PGLubyte){.dynlib: dllname, importc: "glVertexAttrib4ubv".} -proc glVertexAttrib4uiv*(index: TGLuint, v: PGLuint){.dynlib: dllname, +proc glVertexAttrib4uiv*(index: TGLuint, v: PGLuint){.dynlib: dllname, importc: "glVertexAttrib4uiv".} -proc glVertexAttrib4usv*(index: TGLuint, v: PGLushort){.dynlib: dllname, +proc glVertexAttrib4usv*(index: TGLuint, v: PGLushort){.dynlib: dllname, importc: "glVertexAttrib4usv".} -proc glVertexAttribPointer*(index: TGLuint, size: TGLint, thetype: TGLenum, - normalized: TGLboolean, stride: TGLsizei, - pointer: PGLvoid){.dynlib: dllname, +proc glVertexAttribPointer*(index: TGLuint, size: TGLint, thetype: TGLenum, + normalized: TGLboolean, stride: TGLsizei, + pointer: PGLvoid){.dynlib: dllname, importc: "glVertexAttribPointer".} -const +const GL_CONSTANT_COLOR* = 0x00008001 GL_ONE_MINUS_CONSTANT_COLOR* = 0x00008002 GL_CONSTANT_ALPHA* = 0x00008003 @@ -747,122 +747,122 @@ const GL_REPLICATE_BORDER* = 0x00008153 GL_CONVOLUTION_BORDER_COLOR* = 0x00008154 -proc glActiveTexture*(texture: TGLenum){.dynlib: dllname, +proc glActiveTexture*(texture: TGLenum){.dynlib: dllname, importc: "glActiveTexture".} -proc glClientActiveTexture*(texture: TGLenum){.dynlib: dllname, +proc glClientActiveTexture*(texture: TGLenum){.dynlib: dllname, importc: "glClientActiveTexture".} -proc glMultiTexCoord1d*(target: TGLenum, s: TGLdouble){.dynlib: dllname, +proc glMultiTexCoord1d*(target: TGLenum, s: TGLdouble){.dynlib: dllname, importc: "glMultiTexCoord1d".} -proc glMultiTexCoord1dv*(target: TGLenum, v: PGLdouble){.dynlib: dllname, +proc glMultiTexCoord1dv*(target: TGLenum, v: PGLdouble){.dynlib: dllname, importc: "glMultiTexCoord1dv".} -proc glMultiTexCoord1f*(target: TGLenum, s: TGLfloat){.dynlib: dllname, +proc glMultiTexCoord1f*(target: TGLenum, s: TGLfloat){.dynlib: dllname, importc: "glMultiTexCoord1f".} -proc glMultiTexCoord1fv*(target: TGLenum, v: PGLfloat){.dynlib: dllname, +proc glMultiTexCoord1fv*(target: TGLenum, v: PGLfloat){.dynlib: dllname, importc: "glMultiTexCoord1fv".} -proc glMultiTexCoord1i*(target: TGLenum, s: TGLint){.dynlib: dllname, +proc glMultiTexCoord1i*(target: TGLenum, s: TGLint){.dynlib: dllname, importc: "glMultiTexCoord1i".} -proc glMultiTexCoord1iv*(target: TGLenum, v: PGLint){.dynlib: dllname, +proc glMultiTexCoord1iv*(target: TGLenum, v: PGLint){.dynlib: dllname, importc: "glMultiTexCoord1iv".} -proc glMultiTexCoord1s*(target: TGLenum, s: TGLshort){.dynlib: dllname, +proc glMultiTexCoord1s*(target: TGLenum, s: TGLshort){.dynlib: dllname, importc: "glMultiTexCoord1s".} -proc glMultiTexCoord1sv*(target: TGLenum, v: PGLshort){.dynlib: dllname, +proc glMultiTexCoord1sv*(target: TGLenum, v: PGLshort){.dynlib: dllname, importc: "glMultiTexCoord1sv".} proc glMultiTexCoord2d*(target: TGLenum, s: TGLdouble, t: TGLdouble){. dynlib: dllname, importc: "glMultiTexCoord2d".} -proc glMultiTexCoord2dv*(target: TGLenum, v: PGLdouble){.dynlib: dllname, +proc glMultiTexCoord2dv*(target: TGLenum, v: PGLdouble){.dynlib: dllname, importc: "glMultiTexCoord2dv".} proc glMultiTexCoord2f*(target: TGLenum, s: TGLfloat, t: TGLfloat){. dynlib: dllname, importc: "glMultiTexCoord2f".} -proc glMultiTexCoord2fv*(target: TGLenum, v: PGLfloat){.dynlib: dllname, +proc glMultiTexCoord2fv*(target: TGLenum, v: PGLfloat){.dynlib: dllname, importc: "glMultiTexCoord2fv".} -proc glMultiTexCoord2i*(target: TGLenum, s: TGLint, t: TGLint){.dynlib: dllname, +proc glMultiTexCoord2i*(target: TGLenum, s: TGLint, t: TGLint){.dynlib: dllname, importc: "glMultiTexCoord2i".} -proc glMultiTexCoord2iv*(target: TGLenum, v: PGLint){.dynlib: dllname, +proc glMultiTexCoord2iv*(target: TGLenum, v: PGLint){.dynlib: dllname, importc: "glMultiTexCoord2iv".} proc glMultiTexCoord2s*(target: TGLenum, s: TGLshort, t: TGLshort){. dynlib: dllname, importc: "glMultiTexCoord2s".} -proc glMultiTexCoord2sv*(target: TGLenum, v: PGLshort){.dynlib: dllname, +proc glMultiTexCoord2sv*(target: TGLenum, v: PGLshort){.dynlib: dllname, importc: "glMultiTexCoord2sv".} -proc glMultiTexCoord3d*(target: TGLenum, s: TGLdouble, t: TGLdouble, - r: TGLdouble){.dynlib: dllname, +proc glMultiTexCoord3d*(target: TGLenum, s: TGLdouble, t: TGLdouble, + r: TGLdouble){.dynlib: dllname, importc: "glMultiTexCoord3d".} -proc glMultiTexCoord3dv*(target: TGLenum, v: PGLdouble){.dynlib: dllname, +proc glMultiTexCoord3dv*(target: TGLenum, v: PGLdouble){.dynlib: dllname, importc: "glMultiTexCoord3dv".} proc glMultiTexCoord3f*(target: TGLenum, s: TGLfloat, t: TGLfloat, r: TGLfloat){. dynlib: dllname, importc: "glMultiTexCoord3f".} -proc glMultiTexCoord3fv*(target: TGLenum, v: PGLfloat){.dynlib: dllname, +proc glMultiTexCoord3fv*(target: TGLenum, v: PGLfloat){.dynlib: dllname, importc: "glMultiTexCoord3fv".} proc glMultiTexCoord3i*(target: TGLenum, s: TGLint, t: TGLint, r: TGLint){. dynlib: dllname, importc: "glMultiTexCoord3i".} -proc glMultiTexCoord3iv*(target: TGLenum, v: PGLint){.dynlib: dllname, +proc glMultiTexCoord3iv*(target: TGLenum, v: PGLint){.dynlib: dllname, importc: "glMultiTexCoord3iv".} proc glMultiTexCoord3s*(target: TGLenum, s: TGLshort, t: TGLshort, r: TGLshort){. dynlib: dllname, importc: "glMultiTexCoord3s".} -proc glMultiTexCoord3sv*(target: TGLenum, v: PGLshort){.dynlib: dllname, +proc glMultiTexCoord3sv*(target: TGLenum, v: PGLshort){.dynlib: dllname, importc: "glMultiTexCoord3sv".} -proc glMultiTexCoord4d*(target: TGLenum, s: TGLdouble, t: TGLdouble, - r: TGLdouble, q: TGLdouble){.dynlib: dllname, +proc glMultiTexCoord4d*(target: TGLenum, s: TGLdouble, t: TGLdouble, + r: TGLdouble, q: TGLdouble){.dynlib: dllname, importc: "glMultiTexCoord4d".} -proc glMultiTexCoord4dv*(target: TGLenum, v: PGLdouble){.dynlib: dllname, +proc glMultiTexCoord4dv*(target: TGLenum, v: PGLdouble){.dynlib: dllname, importc: "glMultiTexCoord4dv".} -proc glMultiTexCoord4f*(target: TGLenum, s: TGLfloat, t: TGLfloat, r: TGLfloat, - q: TGLfloat){.dynlib: dllname, +proc glMultiTexCoord4f*(target: TGLenum, s: TGLfloat, t: TGLfloat, r: TGLfloat, + q: TGLfloat){.dynlib: dllname, importc: "glMultiTexCoord4f".} -proc glMultiTexCoord4fv*(target: TGLenum, v: PGLfloat){.dynlib: dllname, +proc glMultiTexCoord4fv*(target: TGLenum, v: PGLfloat){.dynlib: dllname, importc: "glMultiTexCoord4fv".} -proc glMultiTexCoord4i*(target: TGLenum, s: TGLint, t: TGLint, r: TGLint, - q: TGLint){.dynlib: dllname, +proc glMultiTexCoord4i*(target: TGLenum, s: TGLint, t: TGLint, r: TGLint, + q: TGLint){.dynlib: dllname, importc: "glMultiTexCoord4i".} -proc glMultiTexCoord4iv*(target: TGLenum, v: PGLint){.dynlib: dllname, +proc glMultiTexCoord4iv*(target: TGLenum, v: PGLint){.dynlib: dllname, importc: "glMultiTexCoord4iv".} -proc glMultiTexCoord4s*(target: TGLenum, s: TGLshort, t: TGLshort, r: TGLshort, - q: TGLshort){.dynlib: dllname, +proc glMultiTexCoord4s*(target: TGLenum, s: TGLshort, t: TGLshort, r: TGLshort, + q: TGLshort){.dynlib: dllname, importc: "glMultiTexCoord4s".} -proc glMultiTexCoord4sv*(target: TGLenum, v: PGLshort){.dynlib: dllname, +proc glMultiTexCoord4sv*(target: TGLenum, v: PGLshort){.dynlib: dllname, importc: "glMultiTexCoord4sv".} -proc glLoadTransposeMatrixf*(m: PGLfloat){.dynlib: dllname, +proc glLoadTransposeMatrixf*(m: PGLfloat){.dynlib: dllname, importc: "glLoadTransposeMatrixf".} -proc glLoadTransposeMatrixd*(m: PGLdouble){.dynlib: dllname, +proc glLoadTransposeMatrixd*(m: PGLdouble){.dynlib: dllname, importc: "glLoadTransposeMatrixd".} -proc glMultTransposeMatrixf*(m: PGLfloat){.dynlib: dllname, +proc glMultTransposeMatrixf*(m: PGLfloat){.dynlib: dllname, importc: "glMultTransposeMatrixf".} -proc glMultTransposeMatrixd*(m: PGLdouble){.dynlib: dllname, +proc glMultTransposeMatrixd*(m: PGLdouble){.dynlib: dllname, importc: "glMultTransposeMatrixd".} -proc glSampleCoverage*(value: TGLclampf, invert: TGLboolean){.dynlib: dllname, +proc glSampleCoverage*(value: TGLclampf, invert: TGLboolean){.dynlib: dllname, importc: "glSampleCoverage".} -proc glCompressedTexImage3D*(target: TGLenum, level: TGLint, - internalformat: TGLenum, width: TGLsizei, - height: TGLsizei, depth: TGLsizei, border: TGLint, +proc glCompressedTexImage3D*(target: TGLenum, level: TGLint, + internalformat: TGLenum, width: TGLsizei, + height: TGLsizei, depth: TGLsizei, border: TGLint, imageSize: TGLsizei, data: PGLvoid){. dynlib: dllname, importc: "glCompressedTexImage3D".} -proc glCompressedTexImage2D*(target: TGLenum, level: TGLint, - internalformat: TGLenum, width: TGLsizei, - height: TGLsizei, border: TGLint, +proc glCompressedTexImage2D*(target: TGLenum, level: TGLint, + internalformat: TGLenum, width: TGLsizei, + height: TGLsizei, border: TGLint, imageSize: TGLsizei, data: PGLvoid){. dynlib: dllname, importc: "glCompressedTexImage2D".} -proc glCompressedTexImage1D*(target: TGLenum, level: TGLint, - internalformat: TGLenum, width: TGLsizei, +proc glCompressedTexImage1D*(target: TGLenum, level: TGLint, + internalformat: TGLenum, width: TGLsizei, border: TGLint, imageSize: TGLsizei, data: PGLvoid){. dynlib: dllname, importc: "glCompressedTexImage1D".} -proc glCompressedTexSubImage3D*(target: TGLenum, level: TGLint, xoffset: TGLint, - yoffset: TGLint, zoffset: TGLint, - width: TGLsizei, height: TGLsizei, - depth: TGLsizei, format: TGLenum, +proc glCompressedTexSubImage3D*(target: TGLenum, level: TGLint, xoffset: TGLint, + yoffset: TGLint, zoffset: TGLint, + width: TGLsizei, height: TGLsizei, + depth: TGLsizei, format: TGLenum, imageSize: TGLsizei, data: PGLvoid){. dynlib: dllname, importc: "glCompressedTexSubImage3D".} -proc glCompressedTexSubImage2D*(target: TGLenum, level: TGLint, xoffset: TGLint, - yoffset: TGLint, width: TGLsizei, - height: TGLsizei, format: TGLenum, +proc glCompressedTexSubImage2D*(target: TGLenum, level: TGLint, xoffset: TGLint, + yoffset: TGLint, width: TGLsizei, + height: TGLsizei, format: TGLenum, imageSize: TGLsizei, data: PGLvoid){. dynlib: dllname, importc: "glCompressedTexSubImage2D".} -proc glCompressedTexSubImage1D*(target: TGLenum, level: TGLint, xoffset: TGLint, - width: TGLsizei, format: TGLenum, +proc glCompressedTexSubImage1D*(target: TGLenum, level: TGLint, xoffset: TGLint, + width: TGLsizei, format: TGLenum, imageSize: TGLsizei, data: PGLvoid){. dynlib: dllname, importc: "glCompressedTexSubImage1D".} proc glGetCompressedTexImage*(target: TGLenum, level: TGLint, img: PGLvoid){. dynlib: dllname, importc: "glGetCompressedTexImage".} #***** GL_version_1_3 *****// -const +const GL_TEXTURE0* = 0x000084C0 GL_TEXTURE1* = 0x000084C1 GL_TEXTURE2* = 0x000084C2 @@ -961,7 +961,7 @@ const GL_DOT3_RGB* = 0x000086AE GL_DOT3_RGBA* = 0x000086AF -const +const GL_TEXTURE0_ARB* = 0x000084C0 GL_TEXTURE1_ARB* = 0x000084C1 GL_TEXTURE2_ARB* = 0x000084C2 @@ -999,21 +999,21 @@ const GL_MAX_TEXTURE_UNITS_ARB* = 0x000084E2 #***** GL_ARB_transpose_matrix *****// -const +const GL_TRANSPOSE_MODELVIEW_MATRIX_ARB* = 0x000084E3 GL_TRANSPOSE_PROJECTION_MATRIX_ARB* = 0x000084E4 GL_TRANSPOSE_TEXTURE_MATRIX_ARB* = 0x000084E5 GL_TRANSPOSE_COLOR_MATRIX_ARB* = 0x000084E6 -proc glLoadTransposeMatrixfARB*(m: PGLfloat){.dynlib: dllname, +proc glLoadTransposeMatrixfARB*(m: PGLfloat){.dynlib: dllname, importc: "glLoadTransposeMatrixfARB".} -proc glLoadTransposeMatrixdARB*(m: PGLdouble){.dynlib: dllname, +proc glLoadTransposeMatrixdARB*(m: PGLdouble){.dynlib: dllname, importc: "glLoadTransposeMatrixdARB".} -proc glMultTransposeMatrixfARB*(m: PGLfloat){.dynlib: dllname, +proc glMultTransposeMatrixfARB*(m: PGLfloat){.dynlib: dllname, importc: "glMultTransposeMatrixfARB".} -proc glMultTransposeMatrixdARB*(m: PGLdouble){.dynlib: dllname, +proc glMultTransposeMatrixdARB*(m: PGLdouble){.dynlib: dllname, importc: "glMultTransposeMatrixdARB".} -const +const WGL_SAMPLE_BUFFERS_ARB* = 0x00002041 WGL_SAMPLES_ARB* = 0x00002042 GL_MULTISAMPLE_ARB* = 0x0000809D @@ -1026,7 +1026,7 @@ const GL_SAMPLE_COVERAGE_VALUE_ARB* = 0x000080AA GL_SAMPLE_COVERAGE_INVERT_ARB* = 0x000080AB -const +const GL_NORMAL_MAP_ARB* = 0x00008511 GL_REFLECTION_MAP_ARB* = 0x00008512 GL_TEXTURE_CUBE_MAP_ARB* = 0x00008513 @@ -1040,7 +1040,7 @@ const GL_PROXY_TEXTURE_CUBE_MAP_ARB* = 0x0000851B GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB* = 0x0000851C -const +const GL_DEPTH_COMPONENT16_ARB* = 0x000081A5 GL_DEPTH_COMPONENT24_ARB* = 0x000081A6 GL_DEPTH_COMPONENT32_ARB* = 0x000081A7 @@ -1048,26 +1048,26 @@ const GL_DEPTH_TEXTURE_MODE_ARB* = 0x0000884B #***** GL_ARB_point_parameters *****// -const +const GL_POINT_SIZE_MIN_ARB* = 0x00008126 GL_POINT_SIZE_MAX_ARB* = 0x00008127 GL_POINT_FADE_THRESHOLD_SIZE_ARB* = 0x00008128 GL_POINT_DISTANCE_ATTENUATION_ARB* = 0x00008129 -proc glPointParameterfARB*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, +proc glPointParameterfARB*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, importc: "glPointParameterfARB".} -proc glPointParameterfvARB*(pname: TGLenum, params: PGLfloat){.dynlib: dllname, +proc glPointParameterfvARB*(pname: TGLenum, params: PGLfloat){.dynlib: dllname, importc: "glPointParameterfvARB".} -const +const GL_TEXTURE_COMPARE_MODE_ARB* = 0x0000884C GL_TEXTURE_COMPARE_FUNC_ARB* = 0x0000884D GL_COMPARE_R_TO_TEXTURE_ARB* = 0x0000884E -const +const GL_TEXTURE_COMPARE_FAIL_VALUE_ARB* = 0x000080BF GL_CLAMP_TO_BORDER_ARB* = 0x0000812D -const +const GL_COMPRESSED_ALPHA_ARB* = 0x000084E9 GL_COMPRESSED_LUMINANCE_ARB* = 0x000084EA GL_COMPRESSED_LUMINANCE_ALPHA_ARB* = 0x000084EB @@ -1080,44 +1080,44 @@ const GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB* = 0x000086A2 GL_COMPRESSED_TEXTURE_FORMATS_ARB* = 0x000086A3 -proc glCompressedTexImage3DARB*(target: TGLenum, level: TGLint, - internalformat: TGLenum, width: TGLsizei, - height: TGLsizei, depth: TGLsizei, - border: TGLint, imageSize: TGLsizei, - data: PGLvoid){.dynlib: dllname, +proc glCompressedTexImage3DARB*(target: TGLenum, level: TGLint, + internalformat: TGLenum, width: TGLsizei, + height: TGLsizei, depth: TGLsizei, + border: TGLint, imageSize: TGLsizei, + data: PGLvoid){.dynlib: dllname, importc: "glCompressedTexImage3DARB".} -proc glCompressedTexImage2DARB*(target: TGLenum, level: TGLint, - internalformat: TGLenum, width: TGLsizei, - height: TGLsizei, border: TGLint, +proc glCompressedTexImage2DARB*(target: TGLenum, level: TGLint, + internalformat: TGLenum, width: TGLsizei, + height: TGLsizei, border: TGLint, imageSize: TGLsizei, data: PGLvoid){. dynlib: dllname, importc: "glCompressedTexImage2DARB".} -proc glCompressedTexImage1DARB*(target: TGLenum, level: TGLint, - internalformat: TGLenum, width: TGLsizei, - border: TGLint, imageSize: TGLsizei, - data: PGLvoid){.dynlib: dllname, +proc glCompressedTexImage1DARB*(target: TGLenum, level: TGLint, + internalformat: TGLenum, width: TGLsizei, + border: TGLint, imageSize: TGLsizei, + data: PGLvoid){.dynlib: dllname, importc: "glCompressedTexImage1DARB".} -proc glCompressedTexSubImage3DARB*(target: TGLenum, level: TGLint, - xoffset: TGLint, yoffset: TGLint, - zoffset: TGLint, width: TGLsizei, - height: TGLsizei, depth: TGLsizei, - format: TGLenum, imageSize: TGLsizei, - data: PGLvoid){.dynlib: dllname, +proc glCompressedTexSubImage3DARB*(target: TGLenum, level: TGLint, + xoffset: TGLint, yoffset: TGLint, + zoffset: TGLint, width: TGLsizei, + height: TGLsizei, depth: TGLsizei, + format: TGLenum, imageSize: TGLsizei, + data: PGLvoid){.dynlib: dllname, importc: "glCompressedTexSubImage3DARB".} -proc glCompressedTexSubImage2DARB*(target: TGLenum, level: TGLint, - xoffset: TGLint, yoffset: TGLint, - width: TGLsizei, height: TGLsizei, - format: TGLenum, imageSize: TGLsizei, - data: PGLvoid){.dynlib: dllname, +proc glCompressedTexSubImage2DARB*(target: TGLenum, level: TGLint, + xoffset: TGLint, yoffset: TGLint, + width: TGLsizei, height: TGLsizei, + format: TGLenum, imageSize: TGLsizei, + data: PGLvoid){.dynlib: dllname, importc: "glCompressedTexSubImage2DARB".} -proc glCompressedTexSubImage1DARB*(target: TGLenum, level: TGLint, - xoffset: TGLint, width: TGLsizei, - format: TGLenum, imageSize: TGLsizei, - data: PGLvoid){.dynlib: dllname, +proc glCompressedTexSubImage1DARB*(target: TGLenum, level: TGLint, + xoffset: TGLint, width: TGLsizei, + format: TGLenum, imageSize: TGLsizei, + data: PGLvoid){.dynlib: dllname, importc: "glCompressedTexSubImage1DARB".} proc glGetCompressedTexImageARB*(target: TGLenum, lod: TGLint, img: PGLvoid){. dynlib: dllname, importc: "glGetCompressedTexImageARB".} #***** GL_ARB_texture_env_combine *****// -const +const GL_COMBINE_ARB* = 0x00008570 GL_COMBINE_RGB_ARB* = 0x00008571 GL_COMBINE_ALPHA_ARB* = 0x00008572 @@ -1143,16 +1143,16 @@ const #***** GL_ARB_texture_env_crossbar *****// #***** GL_ARB_texture_env_dot3 *****// -const +const GL_DOT3_RGB_ARB* = 0x000086AE GL_DOT3_RGBA_ARB* = 0x000086AF #***** GL_ARB_texture_mirrored_repeat *****// -const +const GL_MIRRORED_REPEAT_ARB* = 0x00008370 #***** GL_ARB_vertex_blend *****// -const +const GL_MAX_VERTEX_UNITS_ARB* = 0x000086A4 GL_ACTIVE_VERTEX_UNITS_ARB* = 0x000086A5 GL_WEIGHT_SUM_UNITY_ARB* = 0x000086A6 @@ -1196,7 +1196,7 @@ const GL_WEIGHT_ARRAY_POINTER_ARB* = 0x000086AC GL_WEIGHT_ARRAY_ARB* = 0x000086AD -const +const GL_VERTEX_PROGRAM_ARB* = 0x00008620 GL_VERTEX_PROGRAM_POINT_SIZE_ARB* = 0x00008642 GL_VERTEX_PROGRAM_TWO_SIDE_ARB* = 0x00008643 @@ -1277,78 +1277,78 @@ const GL_MATRIX30_ARB* = 0x000088DE GL_MATRIX31_ARB* = 0x000088DF -const +const GL_422_EXT* = 0x000080CC GL_422_REV_EXT* = 0x000080CD GL_422_AVERAGE_EXT* = 0x000080CE GL_422_REV_AVERAGE_EXT* = 0x000080CF #***** GL_EXT_abgr *****// -const +const GL_ABGR_EXT* = 0x00008000 #***** GL_EXT_bgra *****// -const +const GL_BGR_EXT* = 0x000080E0 GL_BGRA_EXT* = 0x000080E1 #***** GL_EXT_blend_color *****// -const +const GL_CONSTANT_COLOR_EXT* = 0x00008001 GL_ONE_MINUS_CONSTANT_COLOR_EXT* = 0x00008002 GL_CONSTANT_ALPHA_EXT* = 0x00008003 GL_ONE_MINUS_CONSTANT_ALPHA_EXT* = 0x00008004 constGL_BLEND_COLOR_EXT* = 0x00008005 -proc glBlendColorEXT*(red: TGLclampf, green: TGLclampf, blue: TGLclampf, - alpha: TGLclampf){.dynlib: dllname, +proc glBlendColorEXT*(red: TGLclampf, green: TGLclampf, blue: TGLclampf, + alpha: TGLclampf){.dynlib: dllname, importc: "glBlendColorEXT".} #***** GL_EXT_blend_func_separate *****// -const +const GL_BLEND_DST_RGB_EXT* = 0x000080C8 GL_BLEND_SRC_RGB_EXT* = 0x000080C9 GL_BLEND_DST_ALPHA_EXT* = 0x000080CA GL_BLEND_SRC_ALPHA_EXT* = 0x000080CB -proc glBlendFuncSeparateEXT*(sfactorRGB: TGLenum, dfactorRGB: TGLenum, +proc glBlendFuncSeparateEXT*(sfactorRGB: TGLenum, dfactorRGB: TGLenum, sfactorAlpha: TGLenum, dfactorAlpha: TGLenum){. dynlib: dllname, importc: "glBlendFuncSeparateEXT".} #***** GL_EXT_blend_logic_op *****// #***** GL_EXT_blend_minmax *****// -const +const GL_FUNC_ADD_EXT* = 0x00008006 GL_MIN_EXT* = 0x00008007 GL_MAX_EXT* = 0x00008008 constGL_BLEND_EQUATION_EXT* = 0x00008009 -proc glBlendEquationEXT*(mode: TGLenum){.dynlib: dllname, +proc glBlendEquationEXT*(mode: TGLenum){.dynlib: dllname, importc: "glBlendEquationEXT".} #***** GL_EXT_blend_subtract *****// -const +const GL_FUNC_SUBTRACT_EXT* = 0x0000800A GL_FUNC_REVERSE_SUBTRACT_EXT* = 0x0000800B #***** GL_EXT_clip_volume_hint *****// -const +const GL_CLIP_VOLUME_CLIPPING_HINT_EXT* = 0x000080F0 #***** GL_EXT_color_subtable *****// -proc glColorSubTableEXT*(target: TGLenum, start: TGLsizei, count: TGLsizei, +proc glColorSubTableEXT*(target: TGLenum, start: TGLsizei, count: TGLsizei, format: TGLenum, thetype: TGLenum, data: PGLvoid){. dynlib: dllname, importc: "glColorSubTableEXT".} -proc glCopyColorSubTableEXT*(target: TGLenum, start: TGLsizei, x: TGLint, - y: TGLint, width: TGLsizei){.dynlib: dllname, +proc glCopyColorSubTableEXT*(target: TGLenum, start: TGLsizei, x: TGLint, + y: TGLint, width: TGLsizei){.dynlib: dllname, importc: "glCopyColorSubTableEXT".} #***** GL_EXT_compiled_vertex_array *****// -const +const GL_ARRAY_ELEMENT_LOCK_FIRST_EXT* = 0x000081A8 GL_ARRAY_ELEMENT_LOCK_COUNT_EXT* = 0x000081A9 -proc glLockArraysEXT*(first: TGLint, count: TGLsizei){.dynlib: dllname, +proc glLockArraysEXT*(first: TGLint, count: TGLsizei){.dynlib: dllname, importc: "glLockArraysEXT".} proc glUnlockArraysEXT*(){.dynlib: dllname, importc: "glUnlockArraysEXT".} #***** GL_EXT_convolution *****// -const +const GL_CONVOLUTION_1D_EXT* = 0x00008010 GL_CONVOLUTION_2D_EXT* = 0x00008011 GL_SEPARABLE_2D_EXT* = 0x00008012 @@ -1370,51 +1370,51 @@ const GL_POST_CONVOLUTION_BLUE_BIAS_EXT* = 0x00008022 GL_POST_CONVOLUTION_ALPHA_BIAS_EXT* = 0x00008023 -proc glConvolutionFilter1DEXT*(target: TGLenum, internalformat: TGLenum, - width: TGLsizei, format: TGLenum, +proc glConvolutionFilter1DEXT*(target: TGLenum, internalformat: TGLenum, + width: TGLsizei, format: TGLenum, thetype: TGLenum, image: PGLvoid){. dynlib: dllname, importc: "glConvolutionFilter1DEXT".} -proc glConvolutionFilter2DEXT*(target: TGLenum, internalformat: TGLenum, - width: TGLsizei, height: TGLsizei, +proc glConvolutionFilter2DEXT*(target: TGLenum, internalformat: TGLenum, + width: TGLsizei, height: TGLsizei, format: TGLenum, thetype: TGLenum, image: PGLvoid){. dynlib: dllname, importc: "glConvolutionFilter2DEXT".} -proc glCopyConvolutionFilter1DEXT*(target: TGLenum, internalformat: TGLenum, +proc glCopyConvolutionFilter1DEXT*(target: TGLenum, internalformat: TGLenum, x: TGLint, y: TGLint, width: TGLsizei){. dynlib: dllname, importc: "glCopyConvolutionFilter1DEXT".} -proc glCopyConvolutionFilter2DEXT*(target: TGLenum, internalformat: TGLenum, - x: TGLint, y: TGLint, width: TGLsizei, - height: TGLsizei){.dynlib: dllname, +proc glCopyConvolutionFilter2DEXT*(target: TGLenum, internalformat: TGLenum, + x: TGLint, y: TGLint, width: TGLsizei, + height: TGLsizei){.dynlib: dllname, importc: "glCopyConvolutionFilter2DEXT".} -proc glGetConvolutionFilterEXT*(target: TGLenum, format: TGLenum, +proc glGetConvolutionFilterEXT*(target: TGLenum, format: TGLenum, thetype: TGLenum, image: PGLvoid){. dynlib: dllname, importc: "glGetConvolutionFilterEXT".} -proc glSeparableFilter2DEXT*(target: TGLenum, internalformat: TGLenum, - width: TGLsizei, height: TGLsizei, format: TGLenum, +proc glSeparableFilter2DEXT*(target: TGLenum, internalformat: TGLenum, + width: TGLsizei, height: TGLsizei, format: TGLenum, thetype: TGLenum, row: PGLvoid, column: PGLvoid){. dynlib: dllname, importc: "glSeparableFilter2DEXT".} -proc glGetSeparableFilterEXT*(target: TGLenum, format: TGLenum, - thetype: TGLenum, row: PGLvoid, column: PGLvoid, - span: PGLvoid){.dynlib: dllname, +proc glGetSeparableFilterEXT*(target: TGLenum, format: TGLenum, + thetype: TGLenum, row: PGLvoid, column: PGLvoid, + span: PGLvoid){.dynlib: dllname, importc: "glGetSeparableFilterEXT".} proc glConvolutionParameteriEXT*(target: TGLenum, pname: TGLenum, param: TGLint){. dynlib: dllname, importc: "glConvolutionParameteriEXT".} -proc glConvolutionParameterivEXT*(target: TGLenum, pname: TGLenum, - params: PGLint){.dynlib: dllname, +proc glConvolutionParameterivEXT*(target: TGLenum, pname: TGLenum, + params: PGLint){.dynlib: dllname, importc: "glConvolutionParameterivEXT".} -proc glConvolutionParameterfEXT*(target: TGLenum, pname: TGLenum, - param: TGLfloat){.dynlib: dllname, +proc glConvolutionParameterfEXT*(target: TGLenum, pname: TGLenum, + param: TGLfloat){.dynlib: dllname, importc: "glConvolutionParameterfEXT".} -proc glConvolutionParameterfvEXT*(target: TGLenum, pname: TGLenum, - params: PGLfloat){.dynlib: dllname, +proc glConvolutionParameterfvEXT*(target: TGLenum, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, importc: "glConvolutionParameterfvEXT".} -proc glGetConvolutionParameterivEXT*(target: TGLenum, pname: TGLenum, - params: PGLint){.dynlib: dllname, +proc glGetConvolutionParameterivEXT*(target: TGLenum, pname: TGLenum, + params: PGLint){.dynlib: dllname, importc: "glGetConvolutionParameterivEXT".} -proc glGetConvolutionParameterfvEXT*(target: TGLenum, pname: TGLenum, - params: PGLfloat){.dynlib: dllname, +proc glGetConvolutionParameterfvEXT*(target: TGLenum, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, importc: "glGetConvolutionParameterfvEXT".} #***** GL_EXT_fog_coord *****// -const +const GL_FOG_COORDINATE_SOURCE_EXT* = 0x00008450 GL_FOG_COORDINATE_EXT* = 0x00008451 GL_FRAGMENT_DEPTH_EXT* = 0x00008452 @@ -1424,18 +1424,18 @@ const GL_FOG_COORDINATE_ARRAY_POINTER_EXT* = 0x00008456 GL_FOG_COORDINATE_ARRAY_EXT* = 0x00008457 -proc glFogCoordfEXfloat*(coord: TGLfloat){.dynlib: dllname, +proc glFogCoordfEXfloat*(coord: TGLfloat){.dynlib: dllname, importc: "glFogCoordfEXfloat".} -proc glFogCoorddEXdouble*(coord: TGLdouble){.dynlib: dllname, +proc glFogCoorddEXdouble*(coord: TGLdouble){.dynlib: dllname, importc: "glFogCoorddEXdouble".} -proc glFogCoordfvEXfloat*(coord: TGLfloat){.dynlib: dllname, +proc glFogCoordfvEXfloat*(coord: TGLfloat){.dynlib: dllname, importc: "glFogCoordfvEXfloat".} -proc glFogCoorddvEXdouble*(coord: TGLdouble){.dynlib: dllname, +proc glFogCoorddvEXdouble*(coord: TGLdouble){.dynlib: dllname, importc: "glFogCoorddvEXdouble".} proc glFogCoordPointerEXT*(thetype: TGLenum, stride: TGLsizei, pointer: PGLvoid){. dynlib: dllname, importc: "glFogCoordPointerEXT".} #***** GL_EXT_histogram *****// -const +const constGL_HISTOGRAM_EXT* = 0x00008024 GL_PROXY_HISTOGRAM_EXT* = 0x00008025 GL_HISTOGRAM_WIDTH_EXT* = 0x00008026 @@ -1450,41 +1450,41 @@ const GL_MINMAX_FORMAT_EXT* = 0x0000802F GL_MINMAX_SINK_EXT* = 0x00008030 -proc glHistogramEXT*(target: TGLenum, width: TGLsizei, internalformat: TGLenum, - sink: TGLboolean){.dynlib: dllname, +proc glHistogramEXT*(target: TGLenum, width: TGLsizei, internalformat: TGLenum, + sink: TGLboolean){.dynlib: dllname, importc: "glHistogramEXT".} -proc glResetHistogramEXT*(target: TGLenum){.dynlib: dllname, +proc glResetHistogramEXT*(target: TGLenum){.dynlib: dllname, importc: "glResetHistogramEXT".} -proc glGetHistogramEXT*(target: TGLenum, reset: TGLboolean, format: TGLenum, - thetype: TGLenum, values: PGLvoid){.dynlib: dllname, +proc glGetHistogramEXT*(target: TGLenum, reset: TGLboolean, format: TGLenum, + thetype: TGLenum, values: PGLvoid){.dynlib: dllname, importc: "glGetHistogramEXT".} -proc glGetHistogramParameterivEXT*(target: TGLenum, pname: TGLenum, - params: PGLint){.dynlib: dllname, +proc glGetHistogramParameterivEXT*(target: TGLenum, pname: TGLenum, + params: PGLint){.dynlib: dllname, importc: "glGetHistogramParameterivEXT".} -proc glGetHistogramParameterfvEXT*(target: TGLenum, pname: TGLenum, - params: PGLfloat){.dynlib: dllname, +proc glGetHistogramParameterfvEXT*(target: TGLenum, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, importc: "glGetHistogramParameterfvEXT".} proc glMinmaxEXT*(target: TGLenum, internalformat: TGLenum, sink: TGLboolean){. dynlib: dllname, importc: "glMinmaxEXT".} -proc glResetMinmaxEXT*(target: TGLenum){.dynlib: dllname, +proc glResetMinmaxEXT*(target: TGLenum){.dynlib: dllname, importc: "glResetMinmaxEXT".} -proc glGetMinmaxEXT*(target: TGLenum, reset: TGLboolean, format: TGLenum, - thetype: TGLenum, values: PGLvoid){.dynlib: dllname, +proc glGetMinmaxEXT*(target: TGLenum, reset: TGLboolean, format: TGLenum, + thetype: TGLenum, values: PGLvoid){.dynlib: dllname, importc: "glGetMinmaxEXT".} proc glGetMinmaxParameterivEXT*(target: TGLenum, pname: TGLenum, params: PGLint){. dynlib: dllname, importc: "glGetMinmaxParameterivEXT".} -proc glGetMinmaxParameterfvEXT*(target: TGLenum, pname: TGLenum, - params: PGLfloat){.dynlib: dllname, +proc glGetMinmaxParameterfvEXT*(target: TGLenum, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, importc: "glGetMinmaxParameterfvEXT".} #***** GL_EXT_multi_draw_arrays *****// -proc glMultiDrawArraysEXT*(mode: TGLenum, first: PGLint, count: PGLsizei, - primcount: TGLsizei){.dynlib: dllname, +proc glMultiDrawArraysEXT*(mode: TGLenum, first: PGLint, count: PGLsizei, + primcount: TGLsizei){.dynlib: dllname, importc: "glMultiDrawArraysEXT".} -proc glMultiDrawElementsEXT*(mode: TGLenum, count: PGLsizei, thetype: TGLenum, +proc glMultiDrawElementsEXT*(mode: TGLenum, count: PGLsizei, thetype: TGLenum, indices: PGLvoid, primcount: TGLsizei){. dynlib: dllname, importc: "glMultiDrawElementsEXT".} #***** GL_EXT_packed_pixels *****// -const +const GL_UNSIGNED_BYTE_3_3_2_EXT* = 0x00008032 GL_UNSIGNED_SHORT_4_4_4_4_EXT* = 0x00008033 GL_UNSIGNED_SHORT_5_5_5_1_EXT* = 0x00008034 @@ -1492,7 +1492,7 @@ const GL_UNSIGNED_INT_10_10_10_2_EXT* = 0x00008036 #***** GL_EXT_paletted_texture *****// -const +const GL_COLOR_INDEX1_EXT* = 0x000080E2 GL_COLOR_INDEX2_EXT* = 0x000080E3 GL_COLOR_INDEX4_EXT* = 0x000080E4 @@ -1519,40 +1519,40 @@ const # GL_TEXTURE_3D_EXT { already defined } # GL_TEXTURE_CUBE_MAP_ARB { already defined } -proc glColorTableEXT*(target: TGLenum, internalFormat: TGLenum, width: TGLsizei, +proc glColorTableEXT*(target: TGLenum, internalFormat: TGLenum, width: TGLsizei, format: TGLenum, thetype: TGLenum, data: PGLvoid){. dynlib: dllname, importc: "glColorTableEXT".} # glColorSubTableEXT { already defined } -proc glGetColorTableEXT*(target: TGLenum, format: TGLenum, thetype: TGLenum, - data: PGLvoid){.dynlib: dllname, +proc glGetColorTableEXT*(target: TGLenum, format: TGLenum, thetype: TGLenum, + data: PGLvoid){.dynlib: dllname, importc: "glGetColorTableEXT".} -proc glGetColorTableParameterivEXT*(target: TGLenum, pname: TGLenum, - params: PGLint){.dynlib: dllname, +proc glGetColorTableParameterivEXT*(target: TGLenum, pname: TGLenum, + params: PGLint){.dynlib: dllname, importc: "glGetColorTableParameterivEXT".} -proc glGetColorTableParameterfvEXT*(target: TGLenum, pname: TGLenum, - params: PGLfloat){.dynlib: dllname, +proc glGetColorTableParameterfvEXT*(target: TGLenum, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, importc: "glGetColorTableParameterfvEXT".} #***** GL_EXT_point_parameters *****// -const +const GL_POINT_SIZE_MIN_EXT* = 0x00008126 GL_POINT_SIZE_MAX_EXT* = 0x00008127 GL_POINT_FADE_THRESHOLD_SIZE_EXT* = 0x00008128 GL_DISTANCE_ATTENUATION_EXT* = 0x00008129 -proc glPointParameterfEXT*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, +proc glPointParameterfEXT*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, importc: "glPointParameterfEXT".} -proc glPointParameterfvEXT*(pname: TGLenum, params: PGLfloat){.dynlib: dllname, +proc glPointParameterfvEXT*(pname: TGLenum, params: PGLfloat){.dynlib: dllname, importc: "glPointParameterfvEXT".} #***** GL_EXT_polygon_offset *****// -const +const constGL_POLYGON_OFFSET_EXT* = 0x00008037 GL_POLYGON_OFFSET_FACTOR_EXT* = 0x00008038 GL_POLYGON_OFFSET_BIAS_EXT* = 0x00008039 -proc glPolygonOffsetEXT*(factor: TGLfloat, bias: TGLfloat){.dynlib: dllname, +proc glPolygonOffsetEXT*(factor: TGLfloat, bias: TGLfloat){.dynlib: dllname, importc: "glPolygonOffsetEXT".} #***** GL_EXT_secondary_color *****// -const +const GL_COLOR_SUM_EXT* = 0x00008458 GL_CURRENT_SECONDARY_COLOR_EXT* = 0x00008459 GL_SECONDARY_COLOR_ARRAY_SIZE_EXT* = 0x0000845A @@ -1561,80 +1561,80 @@ const GL_SECONDARY_COLOR_ARRAY_POINTER_EXT* = 0x0000845D GL_SECONDARY_COLOR_ARRAY_EXT* = 0x0000845E -proc glSecondaryColor3bEXT*(components: TGLbyte){.dynlib: dllname, +proc glSecondaryColor3bEXT*(components: TGLbyte){.dynlib: dllname, importc: "glSecondaryColor3bEXT".} -proc glSecondaryColor3sEXT*(components: TGLshort){.dynlib: dllname, +proc glSecondaryColor3sEXT*(components: TGLshort){.dynlib: dllname, importc: "glSecondaryColor3sEXT".} -proc glSecondaryColor3iEXT*(components: TGLint){.dynlib: dllname, +proc glSecondaryColor3iEXT*(components: TGLint){.dynlib: dllname, importc: "glSecondaryColor3iEXT".} -proc glSecondaryColor3fEXT*(components: TGLfloat){.dynlib: dllname, +proc glSecondaryColor3fEXT*(components: TGLfloat){.dynlib: dllname, importc: "glSecondaryColor3fEXT".} -proc glSecondaryColor3dEXT*(components: TGLdouble){.dynlib: dllname, +proc glSecondaryColor3dEXT*(components: TGLdouble){.dynlib: dllname, importc: "glSecondaryColor3dEXT".} -proc glSecondaryColor3ubEXT*(components: TGLubyte){.dynlib: dllname, +proc glSecondaryColor3ubEXT*(components: TGLubyte){.dynlib: dllname, importc: "glSecondaryColor3ubEXT".} -proc glSecondaryColor3usEXT*(components: TGLushort){.dynlib: dllname, +proc glSecondaryColor3usEXT*(components: TGLushort){.dynlib: dllname, importc: "glSecondaryColor3usEXT".} -proc glSecondaryColor3uiEXT*(components: TGLuint){.dynlib: dllname, +proc glSecondaryColor3uiEXT*(components: TGLuint){.dynlib: dllname, importc: "glSecondaryColor3uiEXT".} -proc glSecondaryColor3bvEXT*(components: TGLbyte){.dynlib: dllname, +proc glSecondaryColor3bvEXT*(components: TGLbyte){.dynlib: dllname, importc: "glSecondaryColor3bvEXT".} -proc glSecondaryColor3svEXT*(components: TGLshort){.dynlib: dllname, +proc glSecondaryColor3svEXT*(components: TGLshort){.dynlib: dllname, importc: "glSecondaryColor3svEXT".} -proc glSecondaryColor3ivEXT*(components: TGLint){.dynlib: dllname, +proc glSecondaryColor3ivEXT*(components: TGLint){.dynlib: dllname, importc: "glSecondaryColor3ivEXT".} -proc glSecondaryColor3fvEXT*(components: TGLfloat){.dynlib: dllname, +proc glSecondaryColor3fvEXT*(components: TGLfloat){.dynlib: dllname, importc: "glSecondaryColor3fvEXT".} -proc glSecondaryColor3dvEXT*(components: TGLdouble){.dynlib: dllname, +proc glSecondaryColor3dvEXT*(components: TGLdouble){.dynlib: dllname, importc: "glSecondaryColor3dvEXT".} -proc glSecondaryColor3ubvEXT*(components: TGLubyte){.dynlib: dllname, +proc glSecondaryColor3ubvEXT*(components: TGLubyte){.dynlib: dllname, importc: "glSecondaryColor3ubvEXT".} -proc glSecondaryColor3usvEXT*(components: TGLushort){.dynlib: dllname, +proc glSecondaryColor3usvEXT*(components: TGLushort){.dynlib: dllname, importc: "glSecondaryColor3usvEXT".} -proc glSecondaryColor3uivEXT*(components: TGLuint){.dynlib: dllname, +proc glSecondaryColor3uivEXT*(components: TGLuint){.dynlib: dllname, importc: "glSecondaryColor3uivEXT".} -proc glSecondaryColorPointerEXT*(size: TGLint, thetype: TGLenum, +proc glSecondaryColorPointerEXT*(size: TGLint, thetype: TGLenum, stride: TGLsizei, pointer: PGLvoid){. dynlib: dllname, importc: "glSecondaryColorPointerEXT".} #***** GL_EXT_separate_specular_color *****// -const +const GL_LIGHT_MODEL_COLOR_CONTROL_EXT* = 0x000081F8 GL_SINGLE_COLOR_EXT* = 0x000081F9 GL_SEPARATE_SPECULAR_COLOR_EXT* = 0x000081FA #***** GL_EXT_shadow_funcs *****// #***** GL_EXT_shared_texture_palette *****// -const +const GL_SHARED_TEXTURE_PALETTE_EXT* = 0x000081FB #***** GL_EXT_stencil_two_side *****// -const +const GL_STENCIL_TEST_TWO_SIDE_EXT* = 0x00008910 constGL_ACTIVE_STENCIL_FACE_EXT* = 0x00008911 -proc glActiveStencilFaceEXT*(face: TGLenum){.dynlib: dllname, +proc glActiveStencilFaceEXT*(face: TGLenum){.dynlib: dllname, importc: "glActiveStencilFaceEXT".} #***** GL_EXT_stencil_wrap *****// -const +const GL_INCR_WRAP_EXT* = 0x00008507 GL_DECR_WRAP_EXT* = 0x00008508 #***** GL_EXT_subtexture *****// -proc glTexSubImage1DEXT*(target: TGLenum, level: TGLint, xoffset: TGLint, - width: TGLsizei, format: TGLenum, thetype: TGLenum, - pixels: PGLvoid){.dynlib: dllname, +proc glTexSubImage1DEXT*(target: TGLenum, level: TGLint, xoffset: TGLint, + width: TGLsizei, format: TGLenum, thetype: TGLenum, + pixels: PGLvoid){.dynlib: dllname, importc: "glTexSubImage1DEXT".} -proc glTexSubImage2DEXT*(target: TGLenum, level: TGLint, xoffset: TGLint, - yoffset: TGLint, width: TGLsizei, height: TGLsizei, +proc glTexSubImage2DEXT*(target: TGLenum, level: TGLint, xoffset: TGLint, + yoffset: TGLint, width: TGLsizei, height: TGLsizei, format: TGLenum, thetype: TGLenum, pixels: PGLvoid){. dynlib: dllname, importc: "glTexSubImage2DEXT".} -proc glTexSubImage3DEXT*(target: TGLenum, level: TGLint, xoffset: TGLint, - yoffset: TGLint, zoffset: TGLint, width: TGLsizei, - height: TGLsizei, depth: TGLsizei, format: TGLenum, - thetype: TGLenum, pixels: PGLvoid){.dynlib: dllname, +proc glTexSubImage3DEXT*(target: TGLenum, level: TGLint, xoffset: TGLint, + yoffset: TGLint, zoffset: TGLint, width: TGLsizei, + height: TGLsizei, depth: TGLsizei, format: TGLenum, + thetype: TGLenum, pixels: PGLvoid){.dynlib: dllname, importc: "glTexSubImage3DEXT".} #***** GL_EXT_texture3D *****// -const +const GL_PACK_SKIP_IMAGES_EXT* = 0x0000806B GL_PACK_IMAGE_HEIGHT_EXT* = 0x0000806C GL_UNPACK_SKIP_IMAGES_EXT* = 0x0000806D @@ -1644,13 +1644,13 @@ const GL_TEXTURE_WRAP_R_EXT* = 0x00008072 GL_MAX_3D_TEXTURE_SIZE_EXT* = 0x00008073 -proc glTexImage3DEXT*(target: TGLenum, level: TGLint, internalformat: TGLenum, - width: TGLsizei, height: TGLsizei, depth: TGLsizei, - border: TGLint, format: TGLenum, thetype: TGLenum, - pixels: PGLvoid){.dynlib: dllname, +proc glTexImage3DEXT*(target: TGLenum, level: TGLint, internalformat: TGLenum, + width: TGLsizei, height: TGLsizei, depth: TGLsizei, + border: TGLint, format: TGLenum, thetype: TGLenum, + pixels: PGLvoid){.dynlib: dllname, importc: "glTexImage3DEXT".} #***** GL_EXT_texture_compression_s3tc *****// -const +const GL_COMPRESSED_RGB_S3TC_DXT1_EXT* = 0x000083F0 GL_COMPRESSED_RGBA_S3TC_DXT1_EXT* = 0x000083F1 GL_COMPRESSED_RGBA_S3TC_DXT3_EXT* = 0x000083F2 @@ -1658,7 +1658,7 @@ const #***** GL_EXT_texture_env_add *****// #***** GL_EXT_texture_env_combine *****// -const +const GL_COMBINE_EXT* = 0x00008570 GL_COMBINE_RGB_EXT* = 0x00008571 GL_COMBINE_ALPHA_EXT* = 0x00008572 @@ -1682,45 +1682,45 @@ const GL_PREVIOUS_EXT* = 0x00008578 #***** GL_EXT_texture_env_dot3 *****// -const +const GL_DOT3_RGB_EXT* = 0x00008740 GL_DOT3_RGBA_EXT* = 0x00008741 #***** GL_EXT_texture_filter_anisotropic *****// -const +const GL_TEXTURE_MAX_ANISOTROPY_EXT* = 0x000084FE GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT* = 0x000084FF #***** GL_EXT_texture_lod_bias *****// -const +const GL_TEXTURE_FILTER_CONTROL_EXT* = 0x00008500 GL_TEXTURE_LOD_BIAS_EXT* = 0x00008501 GL_MAX_TEXTURE_LOD_BIAS_EXT* = 0x000084FD #***** GL_EXT_texture_object *****// -const +const GL_TEXTURE_PRIORITY_EXT* = 0x00008066 GL_TEXTURE_RESIDENT_EXT* = 0x00008067 GL_TEXTURE_1D_BINDING_EXT* = 0x00008068 GL_TEXTURE_2D_BINDING_EXT* = 0x00008069 GL_TEXTURE_3D_BINDING_EXT* = 0x0000806A -proc glGenTexturesEXT*(n: TGLsizei, textures: PGLuint){.dynlib: dllname, +proc glGenTexturesEXT*(n: TGLsizei, textures: PGLuint){.dynlib: dllname, importc: "glGenTexturesEXT".} -proc glDeleteTexturesEXT*(n: TGLsizei, textures: PGLuint){.dynlib: dllname, +proc glDeleteTexturesEXT*(n: TGLsizei, textures: PGLuint){.dynlib: dllname, importc: "glDeleteTexturesEXT".} -proc glBindTextureEXT*(target: TGLenum, texture: TGLuint){.dynlib: dllname, +proc glBindTextureEXT*(target: TGLenum, texture: TGLuint){.dynlib: dllname, importc: "glBindTextureEXT".} -proc glPrioritizeTexturesEXT*(n: TGLsizei, textures: PGLuint, - priorities: PGLclampf){.dynlib: dllname, +proc glPrioritizeTexturesEXT*(n: TGLsizei, textures: PGLuint, + priorities: PGLclampf){.dynlib: dllname, importc: "glPrioritizeTexturesEXT".} -proc glAreTexturesResidentEXT*(n: TGLsizei, textures: PGLuint, +proc glAreTexturesResidentEXT*(n: TGLsizei, textures: PGLuint, residences: PGLboolean): TGLboolean{. dynlib: dllname, importc: "glAreTexturesResidentEXT".} -proc glIsTextureEXT*(texture: TGLuint): TGLboolean{.dynlib: dllname, +proc glIsTextureEXT*(texture: TGLuint): TGLboolean{.dynlib: dllname, importc: "glIsTextureEXT".} #***** GL_EXT_vertex_array *****// -const +const GL_VERTEX_ARRAY_EXT* = 0x00008074 GL_NORMAL_ARRAY_EXT* = 0x00008075 GL_COLOR_ARRAY_EXT* = 0x00008076 @@ -1755,32 +1755,32 @@ const GL_TEXTURE_COORD_ARRAY_POINTER_EXT* = 0x00008092 GL_EDGE_FLAG_ARRAY_POINTER_EXT* = 0x00008093 -proc glArrayElementEXT*(i: TGLint){.dynlib: dllname, +proc glArrayElementEXT*(i: TGLint){.dynlib: dllname, importc: "glArrayElementEXT".} proc glDrawArraysEXT*(mode: TGLenum, first: TGLint, count: TGLsizei){. dynlib: dllname, importc: "glDrawArraysEXT".} -proc glVertexPointerEXT*(size: TGLint, thetype: TGLenum, stride: TGLsizei, - count: TGLsizei, pointer: PGLvoid){.dynlib: dllname, +proc glVertexPointerEXT*(size: TGLint, thetype: TGLenum, stride: TGLsizei, + count: TGLsizei, pointer: PGLvoid){.dynlib: dllname, importc: "glVertexPointerEXT".} -proc glNormalPointerEXT*(thetype: TGLenum, stride: TGLsizei, count: TGLsizei, - pointer: PGLvoid){.dynlib: dllname, +proc glNormalPointerEXT*(thetype: TGLenum, stride: TGLsizei, count: TGLsizei, + pointer: PGLvoid){.dynlib: dllname, importc: "glNormalPointerEXT".} -proc glColorPointerEXT*(size: TGLint, thetype: TGLenum, stride: TGLsizei, - count: TGLsizei, pointer: PGLvoid){.dynlib: dllname, +proc glColorPointerEXT*(size: TGLint, thetype: TGLenum, stride: TGLsizei, + count: TGLsizei, pointer: PGLvoid){.dynlib: dllname, importc: "glColorPointerEXT".} -proc glIndexPointerEXT*(thetype: TGLenum, stride: TGLsizei, count: TGLsizei, - pointer: PGLvoid){.dynlib: dllname, +proc glIndexPointerEXT*(thetype: TGLenum, stride: TGLsizei, count: TGLsizei, + pointer: PGLvoid){.dynlib: dllname, importc: "glIndexPointerEXT".} -proc glTexCoordPointerEXT*(size: TGLint, thetype: TGLenum, stride: TGLsizei, - count: TGLsizei, pointer: PGLvoid){.dynlib: dllname, +proc glTexCoordPointerEXT*(size: TGLint, thetype: TGLenum, stride: TGLsizei, + count: TGLsizei, pointer: PGLvoid){.dynlib: dllname, importc: "glTexCoordPointerEXT".} -proc glEdgeFlagPointerEXT*(stride: TGLsizei, count: TGLsizei, - pointer: PGLboolean){.dynlib: dllname, +proc glEdgeFlagPointerEXT*(stride: TGLsizei, count: TGLsizei, + pointer: PGLboolean){.dynlib: dllname, importc: "glEdgeFlagPointerEXT".} -proc glGetPointervEXT*(pname: TGLenum, params: PGLvoid){.dynlib: dllname, +proc glGetPointervEXT*(pname: TGLenum, params: PGLvoid){.dynlib: dllname, importc: "glGetPointervEXT".} #***** GL_EXT_vertex_shader *****// -const +const GL_VERTEX_SHADER_EXT* = 0x00008780 GL_VARIANT_VALUE_EXT* = 0x000087E4 GL_VARIANT_DATATYPE_EXT* = 0x000087E5 @@ -1892,60 +1892,60 @@ const GL_CURRENT_VERTEX_EXT* = 0x000087E2 GL_MVP_MATRIX_EXT* = 0x000087E3 -proc glBeginVertexShaderEXT*(){.dynlib: dllname, +proc glBeginVertexShaderEXT*(){.dynlib: dllname, importc: "glBeginVertexShaderEXT".} proc glEndVertexShaderEXT*(){.dynlib: dllname, importc: "glEndVertexShaderEXT".} -proc glBindVertexShaderEXT*(id: TGLuint){.dynlib: dllname, +proc glBindVertexShaderEXT*(id: TGLuint){.dynlib: dllname, importc: "glBindVertexShaderEXT".} -proc glGenVertexShadersEXT*(range: TGLuint): TGLuint{.dynlib: dllname, +proc glGenVertexShadersEXT*(range: TGLuint): TGLuint{.dynlib: dllname, importc: "glGenVertexShadersEXT".} -proc glDeleteVertexShaderEXT*(id: TGLuint){.dynlib: dllname, +proc glDeleteVertexShaderEXT*(id: TGLuint){.dynlib: dllname, importc: "glDeleteVertexShaderEXT".} -proc glShaderOp1EXT*(op: TGLenum, res: TGLuint, arg1: TGLuint){.dynlib: dllname, +proc glShaderOp1EXT*(op: TGLenum, res: TGLuint, arg1: TGLuint){.dynlib: dllname, importc: "glShaderOp1EXT".} proc glShaderOp2EXT*(op: TGLenum, res: TGLuint, arg1: TGLuint, arg2: TGLuint){. dynlib: dllname, importc: "glShaderOp2EXT".} -proc glShaderOp3EXT*(op: TGLenum, res: TGLuint, arg1: TGLuint, arg2: TGLuint, +proc glShaderOp3EXT*(op: TGLenum, res: TGLuint, arg1: TGLuint, arg2: TGLuint, arg3: TGLuint){.dynlib: dllname, importc: "glShaderOp3EXT".} -proc glSwizzleEXT*(res: TGLuint, theIn: TGLuint, outX: TGLenum, outY: TGLenum, - outZ: TGLenum, outW: TGLenum){.dynlib: dllname, +proc glSwizzleEXT*(res: TGLuint, theIn: TGLuint, outX: TGLenum, outY: TGLenum, + outZ: TGLenum, outW: TGLenum){.dynlib: dllname, importc: "glSwizzleEXT".} -proc glWriteMaskEXT*(res: TGLuint, theIn: TGLuint, outX: TGLenum, outY: TGLenum, - outZ: TGLenum, outW: TGLenum){.dynlib: dllname, +proc glWriteMaskEXT*(res: TGLuint, theIn: TGLuint, outX: TGLenum, outY: TGLenum, + outZ: TGLenum, outW: TGLenum){.dynlib: dllname, importc: "glWriteMaskEXT".} proc glInsertComponentEXT*(res: TGLuint, src: TGLuint, num: TGLuint){. dynlib: dllname, importc: "glInsertComponentEXT".} proc glExtractComponentEXT*(res: TGLuint, src: TGLuint, num: TGLuint){. dynlib: dllname, importc: "glExtractComponentEXT".} -proc glGenSymbolsEXT*(datatype: TGLenum, storagetype: TGLenum, range: TGLenum, - components: TGLuint): TGLuint{.dynlib: dllname, +proc glGenSymbolsEXT*(datatype: TGLenum, storagetype: TGLenum, range: TGLenum, + components: TGLuint): TGLuint{.dynlib: dllname, importc: "glGenSymbolsEXT".} proc glSetInvariantEXT*(id: TGLuint, thetype: TGLenum, address: PGLvoid){. dynlib: dllname, importc: "glSetInvariantEXT".} proc glSetLocalConstantEXT*(id: TGLuint, thetype: TGLenum, address: PGLvoid){. dynlib: dllname, importc: "glSetLocalConstantEXT".} -proc glVariantbvEXT*(id: TGLuint, address: PGLbyte){.dynlib: dllname, +proc glVariantbvEXT*(id: TGLuint, address: PGLbyte){.dynlib: dllname, importc: "glVariantbvEXT".} -proc glVariantsvEXT*(id: TGLuint, address: PGLshort){.dynlib: dllname, +proc glVariantsvEXT*(id: TGLuint, address: PGLshort){.dynlib: dllname, importc: "glVariantsvEXT".} -proc glVariantivEXT*(id: TGLuint, address: PGLint){.dynlib: dllname, +proc glVariantivEXT*(id: TGLuint, address: PGLint){.dynlib: dllname, importc: "glVariantivEXT".} -proc glVariantfvEXT*(id: TGLuint, address: PGLfloat){.dynlib: dllname, +proc glVariantfvEXT*(id: TGLuint, address: PGLfloat){.dynlib: dllname, importc: "glVariantfvEXT".} -proc glVariantdvEXT*(id: TGLuint, address: PGLdouble){.dynlib: dllname, +proc glVariantdvEXT*(id: TGLuint, address: PGLdouble){.dynlib: dllname, importc: "glVariantdvEXT".} -proc glVariantubvEXT*(id: TGLuint, address: PGLubyte){.dynlib: dllname, +proc glVariantubvEXT*(id: TGLuint, address: PGLubyte){.dynlib: dllname, importc: "glVariantubvEXT".} -proc glVariantusvEXT*(id: TGLuint, address: PGLushort){.dynlib: dllname, +proc glVariantusvEXT*(id: TGLuint, address: PGLushort){.dynlib: dllname, importc: "glVariantusvEXT".} -proc glVariantuivEXT*(id: TGLuint, address: PGLuint){.dynlib: dllname, +proc glVariantuivEXT*(id: TGLuint, address: PGLuint){.dynlib: dllname, importc: "glVariantuivEXT".} -proc glVariantPointerEXT*(id: TGLuint, thetype: TGLenum, stride: TGLuint, - address: PGLvoid){.dynlib: dllname, +proc glVariantPointerEXT*(id: TGLuint, thetype: TGLenum, stride: TGLuint, + address: PGLvoid){.dynlib: dllname, importc: "glVariantPointerEXT".} -proc glEnableVariantClientStateEXT*(id: TGLuint){.dynlib: dllname, +proc glEnableVariantClientStateEXT*(id: TGLuint){.dynlib: dllname, importc: "glEnableVariantClientStateEXT".} -proc glDisableVariantClientStateEXT*(id: TGLuint){.dynlib: dllname, +proc glDisableVariantClientStateEXT*(id: TGLuint){.dynlib: dllname, importc: "glDisableVariantClientStateEXT".} proc glBindLightParameterEXT*(light: TGLenum, value: TGLenum): TGLuint{. dynlib: dllname, importc: "glBindLightParameterEXT".} @@ -1955,7 +1955,7 @@ proc glBindTexGenParameterEXT*(theunit: TGLenum, coord: TGLenum, value: TGLenum) dynlib: dllname, importc: "glBindTexGenParameterEXT".} proc glBindTextureUnitParameterEXT*(theunit: TGLenum, value: TGLenum): TGLuint{. dynlib: dllname, importc: "glBindTextureUnitParameterEXT".} -proc glBindParameterEXT*(value: TGLenum): TGLuint{.dynlib: dllname, +proc glBindParameterEXT*(value: TGLenum): TGLuint{.dynlib: dllname, importc: "glBindParameterEXT".} proc glIsVariantEnabledEXT*(id: TGLuint, cap: TGLenum): TGLboolean{. dynlib: dllname, importc: "glIsVariantEnabledEXT".} @@ -1973,15 +1973,15 @@ proc glGetInvariantIntegervEXT*(id: TGLuint, value: TGLenum, data: PGLint){. dynlib: dllname, importc: "glGetInvariantIntegervEXT".} proc glGetInvariantFloatvEXT*(id: TGLuint, value: TGLenum, data: PGLfloat){. dynlib: dllname, importc: "glGetInvariantFloatvEXT".} -proc glGetLocalConstantBooleanvEXT*(id: TGLuint, value: TGLenum, - data: PGLboolean){.dynlib: dllname, +proc glGetLocalConstantBooleanvEXT*(id: TGLuint, value: TGLenum, + data: PGLboolean){.dynlib: dllname, importc: "glGetLocalConstantBooleanvEXT".} proc glGetLocalConstantIntegervEXT*(id: TGLuint, value: TGLenum, data: PGLint){. dynlib: dllname, importc: "glGetLocalConstantIntegervEXT".} proc glGetLocalConstantFloatvEXT*(id: TGLuint, value: TGLenum, data: PGLfloat){. dynlib: dllname, importc: "glGetLocalConstantFloatvEXT".} #***** GL_EXT_vertex_weighting *****// -const +const GL_VERTEX_WEIGHTING_EXT* = 0x00008509 GL_MODELVIEW0_EXT* = 0x00001700 GL_MODELVIEW1_EXT* = 0x0000850A @@ -1996,30 +1996,30 @@ const GL_MODELVIEW1_STACK_DEPTH_EXT* = 0x00008502 GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT* = 0x00008510 -proc glVertexWeightfEXT*(weight: TGLfloat){.dynlib: dllname, +proc glVertexWeightfEXT*(weight: TGLfloat){.dynlib: dllname, importc: "glVertexWeightfEXT".} -proc glVertexWeightfvEXT*(weight: PGLfloat){.dynlib: dllname, +proc glVertexWeightfvEXT*(weight: PGLfloat){.dynlib: dllname, importc: "glVertexWeightfvEXT".} -proc glVertexWeightPointerEXT*(size: TGLint, thetype: TGLenum, stride: TGLsizei, - pointer: PGLvoid){.dynlib: dllname, +proc glVertexWeightPointerEXT*(size: TGLint, thetype: TGLenum, stride: TGLsizei, + pointer: PGLvoid){.dynlib: dllname, importc: "glVertexWeightPointerEXT".} #***** GL_HP_occlusion_test *****// -const +const GL_OCCLUSION_TEST_HP* = 0x00008165 GL_OCCLUSION_TEST_RESULT_HP* = 0x00008166 #***** GL_NV_blend_square *****// #***** GL_NV_copy_depth_to_color *****// -const +const GL_DEPTH_STENCIL_TO_RGBA_NV* = 0x0000886E GL_DEPTH_STENCIL_TO_BGRA_NV* = 0x0000886F #***** GL_NV_depth_clamp *****// -const +const GL_DEPTH_CLAMP_NV* = 0x0000864F #***** GL_NV_evaluators *****// -const +const GL_EVAL_2D_NV* = 0x000086C0 GL_EVAL_TRIANGULAR_2D_NV* = 0x000086C1 GL_MAP_TESSELLATION_NV* = 0x000086C2 @@ -2045,82 +2045,82 @@ const GL_MAX_MAP_TESSELLATION_NV* = 0x000086D6 GL_MAX_RATIONAL_EVAL_ORDER_NV* = 0x000086D7 -proc glMapControlPointsNV*(target: TGLenum, index: TGLuint, thetype: TGLenum, - ustride: TGLsizei, vstride: TGLsizei, uorder: TGLint, - vorder: TGLint, thepacked: TGLboolean, - points: PGLvoid){.dynlib: dllname, +proc glMapControlPointsNV*(target: TGLenum, index: TGLuint, thetype: TGLenum, + ustride: TGLsizei, vstride: TGLsizei, uorder: TGLint, + vorder: TGLint, thepacked: TGLboolean, + points: PGLvoid){.dynlib: dllname, importc: "glMapControlPointsNV".} proc glMapParameterivNV*(target: TGLenum, pname: TGLenum, params: PGLint){. dynlib: dllname, importc: "glMapParameterivNV".} proc glMapParameterfvNV*(target: TGLenum, pname: TGLenum, params: PGLfloat){. dynlib: dllname, importc: "glMapParameterfvNV".} -proc glGetMapControlPointsNV*(target: TGLenum, index: TGLuint, thetype: TGLenum, - ustride: TGLsizei, vstride: TGLsizei, +proc glGetMapControlPointsNV*(target: TGLenum, index: TGLuint, thetype: TGLenum, + ustride: TGLsizei, vstride: TGLsizei, thepacked: TGLboolean, points: PGLvoid){. dynlib: dllname, importc: "glGetMapControlPointsNV".} proc glGetMapParameterivNV*(target: TGLenum, pname: TGLenum, params: PGLint){. dynlib: dllname, importc: "glGetMapParameterivNV".} proc glGetMapParameterfvNV*(target: TGLenum, pname: TGLenum, params: PGLfloat){. dynlib: dllname, importc: "glGetMapParameterfvNV".} -proc glGetMapAttribParameterivNV*(target: TGLenum, index: TGLuint, +proc glGetMapAttribParameterivNV*(target: TGLenum, index: TGLuint, pname: TGLenum, params: PGLint){. dynlib: dllname, importc: "glGetMapAttribParameterivNV".} -proc glGetMapAttribParameterfvNV*(target: TGLenum, index: TGLuint, +proc glGetMapAttribParameterfvNV*(target: TGLenum, index: TGLuint, pname: TGLenum, params: PGLfloat){. dynlib: dllname, importc: "glGetMapAttribParameterfvNV".} -proc glEvalMapsNV*(target: TGLenum, mode: TGLenum){.dynlib: dllname, +proc glEvalMapsNV*(target: TGLenum, mode: TGLenum){.dynlib: dllname, importc: "glEvalMapsNV".} #***** GL_NV_fence *****// -const +const GL_ALL_COMPLETED_NV* = 0x000084F2 GL_FENCE_STATUS_NV* = 0x000084F3 GL_FENCE_CONDITION_NV* = 0x000084F4 -proc glGenFencesNV*(n: TGLsizei, fences: PGLuint){.dynlib: dllname, +proc glGenFencesNV*(n: TGLsizei, fences: PGLuint){.dynlib: dllname, importc: "glGenFencesNV".} -proc glDeleteFencesNV*(n: TGLsizei, fences: PGLuint){.dynlib: dllname, +proc glDeleteFencesNV*(n: TGLsizei, fences: PGLuint){.dynlib: dllname, importc: "glDeleteFencesNV".} -proc glSetFenceNV*(fence: TGLuint, condition: TGLenum){.dynlib: dllname, +proc glSetFenceNV*(fence: TGLuint, condition: TGLenum){.dynlib: dllname, importc: "glSetFenceNV".} -proc glTestFenceNV*(fence: TGLuint): TGLboolean{.dynlib: dllname, +proc glTestFenceNV*(fence: TGLuint): TGLboolean{.dynlib: dllname, importc: "glTestFenceNV".} -proc glFinishFenceNV*(fence: TGLuint){.dynlib: dllname, +proc glFinishFenceNV*(fence: TGLuint){.dynlib: dllname, importc: "glFinishFenceNV".} -proc glIsFenceNV*(fence: TGLuint): TGLboolean{.dynlib: dllname, +proc glIsFenceNV*(fence: TGLuint): TGLboolean{.dynlib: dllname, importc: "glIsFenceNV".} proc glGetFenceivNV*(fence: TGLuint, pname: TGLenum, params: PGLint){. dynlib: dllname, importc: "glGetFenceivNV".} #***** GL_NV_fog_distance *****// -const +const GL_FOG_DISTANCE_MODE_NV* = 0x0000855A GL_EYE_RADIAL_NV* = 0x0000855B GL_EYE_PLANE_ABSOLUTE_NV* = 0x0000855C #***** GL_NV_light_max_exponent *****// -const +const GL_MAX_SHININESS_NV* = 0x00008504 GL_MAX_SPOT_EXPONENT_NV* = 0x00008505 #***** GL_NV_multisample_filter_hint *****// -const +const GL_MULTISAMPLE_FILTER_HINT_NV* = 0x00008534 #***** GL_NV_occlusion_query *****// # GL_OCCLUSION_TEST_HP { already defined } # GL_OCCLUSION_TEST_RESULT_HP { already defined } -const +const GL_PIXEL_COUNTER_BITS_NV* = 0x00008864 GL_CURRENT_OCCLUSION_QUERY_ID_NV* = 0x00008865 GL_PIXEL_COUNT_NV* = 0x00008866 GL_PIXEL_COUNT_AVAILABLE_NV* = 0x00008867 -proc glGenOcclusionQueriesNV*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, +proc glGenOcclusionQueriesNV*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, importc: "glGenOcclusionQueriesNV".} -proc glDeleteOcclusionQueriesNV*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, +proc glDeleteOcclusionQueriesNV*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, importc: "glDeleteOcclusionQueriesNV".} -proc glIsOcclusionQueryNV*(id: TGLuint): TGLboolean{.dynlib: dllname, +proc glIsOcclusionQueryNV*(id: TGLuint): TGLboolean{.dynlib: dllname, importc: "glIsOcclusionQueryNV".} -proc glBeginOcclusionQueryNV*(id: TGLuint){.dynlib: dllname, +proc glBeginOcclusionQueryNV*(id: TGLuint){.dynlib: dllname, importc: "glBeginOcclusionQueryNV".} proc glEndOcclusionQueryNV*(){.dynlib: dllname, importc: "glEndOcclusionQueryNV".} proc glGetOcclusionQueryivNV*(id: TGLuint, pname: TGLenum, params: PGLint){. @@ -2128,22 +2128,22 @@ proc glGetOcclusionQueryivNV*(id: TGLuint, pname: TGLenum, params: PGLint){. proc glGetOcclusionQueryuivNV*(id: TGLuint, pname: TGLenum, params: PGLuint){. dynlib: dllname, importc: "glGetOcclusionQueryuivNV".} #***** GL_NV_packed_depth_stencil *****// -const +const GL_DEPTH_STENCIL_NV* = 0x000084F9 GL_UNSIGNED_INT_24_8_NV* = 0x000084FA #***** GL_NV_point_sprite *****// -const +const GL_POINT_SPRITE_NV* = 0x00008861 GL_COORD_REPLACE_NV* = 0x00008862 GL_POINT_SPRITE_R_MODE_NV* = 0x00008863 -proc glPointParameteriNV*(pname: TGLenum, param: TGLint){.dynlib: dllname, +proc glPointParameteriNV*(pname: TGLenum, param: TGLint){.dynlib: dllname, importc: "glPointParameteriNV".} -proc glPointParameterivNV*(pname: TGLenum, params: PGLint){.dynlib: dllname, +proc glPointParameterivNV*(pname: TGLenum, params: PGLint){.dynlib: dllname, importc: "glPointParameterivNV".} #***** GL_NV_register_combiners *****// -const +const GL_REGISTER_COMBINERS_NV* = 0x00008522 GL_COMBINER0_NV* = 0x00008550 GL_COMBINER1_NV* = 0x00008551 @@ -2198,62 +2198,62 @@ const proc glCombinerParameterfvNV*(pname: TGLenum, params: PGLfloat){. dynlib: dllname, importc: "glCombinerParameterfvNV".} -proc glCombinerParameterivNV*(pname: TGLenum, params: PGLint){.dynlib: dllname, +proc glCombinerParameterivNV*(pname: TGLenum, params: PGLint){.dynlib: dllname, importc: "glCombinerParameterivNV".} -proc glCombinerParameterfNV*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, +proc glCombinerParameterfNV*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, importc: "glCombinerParameterfNV".} -proc glCombinerParameteriNV*(pname: TGLenum, param: TGLint){.dynlib: dllname, +proc glCombinerParameteriNV*(pname: TGLenum, param: TGLint){.dynlib: dllname, importc: "glCombinerParameteriNV".} -proc glCombinerInputNV*(stage: TGLenum, portion: TGLenum, variable: TGLenum, - input: TGLenum, mapping: TGLenum, - componentUsage: TGLenum){.dynlib: dllname, +proc glCombinerInputNV*(stage: TGLenum, portion: TGLenum, variable: TGLenum, + input: TGLenum, mapping: TGLenum, + componentUsage: TGLenum){.dynlib: dllname, importc: "glCombinerInputNV".} -proc glCombinerOutputNV*(stage: TGLenum, portion: TGLenum, abOutput: TGLenum, - cdOutput: TGLenum, sumOutput: TGLenum, scale: TGLenum, - bias: TGLenum, abDotProduct: TGLboolean, +proc glCombinerOutputNV*(stage: TGLenum, portion: TGLenum, abOutput: TGLenum, + cdOutput: TGLenum, sumOutput: TGLenum, scale: TGLenum, + bias: TGLenum, abDotProduct: TGLboolean, cdDotProduct: TGLboolean, muxSum: TGLboolean){. dynlib: dllname, importc: "glCombinerOutputNV".} -proc glFinalCombinerInputNV*(variable: TGLenum, input: TGLenum, +proc glFinalCombinerInputNV*(variable: TGLenum, input: TGLenum, mapping: TGLenum, componentUsage: TGLenum){. dynlib: dllname, importc: "glFinalCombinerInputNV".} -proc glGetCombinerInputParameterfvNV*(stage: TGLenum, portion: TGLenum, - variable: TGLenum, pname: TGLenum, - params: PGLfloat){.dynlib: dllname, +proc glGetCombinerInputParameterfvNV*(stage: TGLenum, portion: TGLenum, + variable: TGLenum, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, importc: "glGetCombinerInputParameterfvNV".} -proc glGetCombinerInputParameterivNV*(stage: TGLenum, portion: TGLenum, - variable: TGLenum, pname: TGLenum, - params: PGLint){.dynlib: dllname, +proc glGetCombinerInputParameterivNV*(stage: TGLenum, portion: TGLenum, + variable: TGLenum, pname: TGLenum, + params: PGLint){.dynlib: dllname, importc: "glGetCombinerInputParameterivNV".} -proc glGetCombinerOutputParameterfvNV*(stage: TGLenum, portion: TGLenum, +proc glGetCombinerOutputParameterfvNV*(stage: TGLenum, portion: TGLenum, pname: TGLenum, params: PGLfloat){. dynlib: dllname, importc: "glGetCombinerOutputParameterfvNV".} -proc glGetCombinerOutputParameterivNV*(stage: TGLenum, portion: TGLenum, +proc glGetCombinerOutputParameterivNV*(stage: TGLenum, portion: TGLenum, pname: TGLenum, params: PGLint){. dynlib: dllname, importc: "glGetCombinerOutputParameterivNV".} -proc glGetFinalCombinerInputParameterfvNV*(variable: TGLenum, pname: TGLenum, - params: PGLfloat){.dynlib: dllname, +proc glGetFinalCombinerInputParameterfvNV*(variable: TGLenum, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, importc: "glGetFinalCombinerInputParameterfvNV".} -proc glGetFinalCombinerInputParameterivNV*(variable: TGLenum, pname: TGLenum, - params: PGLint){.dynlib: dllname, +proc glGetFinalCombinerInputParameterivNV*(variable: TGLenum, pname: TGLenum, + params: PGLint){.dynlib: dllname, importc: "glGetFinalCombinerInputParameterivNV".} #***** GL_NV_register_combiners2 *****// -const +const GL_PER_STAGE_CONSTANTS_NV* = 0x00008535 -proc glCombinerStageParameterfvNV*(stage: TGLenum, pname: TGLenum, - params: PGLfloat){.dynlib: dllname, +proc glCombinerStageParameterfvNV*(stage: TGLenum, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, importc: "glCombinerStageParameterfvNV".} -proc glGetCombinerStageParameterfvNV*(stage: TGLenum, pname: TGLenum, - params: PGLfloat){.dynlib: dllname, +proc glGetCombinerStageParameterfvNV*(stage: TGLenum, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, importc: "glGetCombinerStageParameterfvNV".} #***** GL_NV_texgen_emboss *****// -const +const GL_EMBOSS_MAP_NV* = 0x0000855F GL_EMBOSS_LIGHT_NV* = 0x0000855D GL_EMBOSS_CONSTANT_NV* = 0x0000855E #***** GL_NV_texgen_reflection *****// -const +const GL_NORMAL_MAP_NV* = 0x00008511 GL_REFLECTION_MAP_NV* = 0x00008512 #***** GL_NV_texture_compression_vtc *****// @@ -2263,7 +2263,7 @@ const # GL_COMPRESSED_RGBA_S3TC_DXT5_EXT { already defined } #***** GL_NV_texture_env_combine4 *****// -const +const GL_COMBINE4_NV* = 0x00008503 GL_SOURCE3_RGB_NV* = 0x00008583 GL_SOURCE3_ALPHA_NV* = 0x0000858B @@ -2271,14 +2271,14 @@ const GL_OPERAND3_ALPHA_NV* = 0x0000859B #***** GL_NV_texture_rectangle *****// -const +const GL_TEXTURE_RECTANGLE_NV* = 0x000084F5 GL_TEXTURE_BINDING_RECTANGLE_NV* = 0x000084F6 GL_PROXY_TEXTURE_RECTANGLE_NV* = 0x000084F7 GL_MAX_RECTANGLE_TEXTURE_SIZE_NV* = 0x000084F8 #***** GL_NV_texture_shader *****// -const +const GL_TEXTURE_SHADER_NV* = 0x000086DE GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV* = 0x000086D9 GL_SHADER_OPERATION_NV* = 0x000086DF @@ -2351,7 +2351,7 @@ const GL_TEXTURE_MAG_SIZE_NV* = 0x0000871F #***** GL_NV_texture_shader2 *****// -const +const GL_DOT_PRODUCT_TEXTURE_3D_NV* = 0x000086EF # GL_HILO_NV { already defined } # GL_DSDT_NV { already defined } # GL_DSDT_MAG_NV { already defined } @@ -2381,7 +2381,7 @@ const # GL_DSDT8_MAG8_INTENSITY8_NV { already defined } #***** GL_NV_texture_shader3 *****// -const +const GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV* = 0x00008850 GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV* = 0x00008851 GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV* = 0x00008852 @@ -2401,23 +2401,23 @@ const GL_FORCE_BLUE_TO_ONE_NV* = 0x00008860 #***** GL_NV_vertex_array_range *****// -const +const constGL_VERTEX_ARRAY_RANGE_NV* = 0x0000851D GL_VERTEX_ARRAY_RANGE_LENGTH_NV* = 0x0000851E GL_VERTEX_ARRAY_RANGE_VALID_NV* = 0x0000851F GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV* = 0x00008520 GL_VERTEX_ARRAY_RANGE_POINTER_NV* = 0x00008521 -proc glVertexArrayRangeNV*(len: TGLsizei, pointer: PGLvoid){.dynlib: dllname, +proc glVertexArrayRangeNV*(len: TGLsizei, pointer: PGLvoid){.dynlib: dllname, importc: "glVertexArrayRangeNV".} -proc glFlushVertexArrayRangeNV*(){.dynlib: dllname, +proc glFlushVertexArrayRangeNV*(){.dynlib: dllname, importc: "glFlushVertexArrayRangeNV".} #***** GL_NV_vertex_array_range2 *****// -const +const GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV* = 0x00008533 #***** GL_NV_vertex_program *****// -const +const GL_VERTEX_PROGRAM_NV* = 0x00008620 GL_VERTEX_PROGRAM_POINT_SIZE_NV* = 0x00008642 GL_VERTEX_PROGRAM_TWO_SIDE_NV* = 0x00008643 @@ -2502,30 +2502,30 @@ const GL_MAP2_VERTEX_ATTRIB14_4_NV* = 0x0000867E GL_MAP2_VERTEX_ATTRIB15_4_NV* = 0x0000867F -proc glBindProgramNV*(target: TGLenum, id: TGLuint){.dynlib: dllname, +proc glBindProgramNV*(target: TGLenum, id: TGLuint){.dynlib: dllname, importc: "glBindProgramNV".} -proc glDeleteProgramsNV*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, +proc glDeleteProgramsNV*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, importc: "glDeleteProgramsNV".} proc glExecuteProgramNV*(target: TGLenum, id: TGLuint, params: PGLfloat){. dynlib: dllname, importc: "glExecuteProgramNV".} -proc glGenProgramsNV*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, +proc glGenProgramsNV*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, importc: "glGenProgramsNV".} proc glAreProgramsResidentNV*(n: TGLsizei, ids: PGLuint, residences: PGLboolean): TGLboolean{. dynlib: dllname, importc: "glAreProgramsResidentNV".} -proc glRequestResidentProgramsNV*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, +proc glRequestResidentProgramsNV*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, importc: "glRequestResidentProgramsNV".} -proc glGetProgramParameterfvNV*(target: TGLenum, index: TGLuint, pname: TGLenum, - params: PGLfloat){.dynlib: dllname, +proc glGetProgramParameterfvNV*(target: TGLenum, index: TGLuint, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, importc: "glGetProgramParameterfvNV".} -proc glGetProgramParameterdvNV*(target: TGLenum, index: TGLuint, pname: TGLenum, - params: PGLdouble){.dynlib: dllname, +proc glGetProgramParameterdvNV*(target: TGLenum, index: TGLuint, pname: TGLenum, + params: PGLdouble){.dynlib: dllname, importc: "glGetProgramParameterdvNV".} proc glGetProgramivNV*(id: TGLuint, pname: TGLenum, params: PGLint){. dynlib: dllname, importc: "glGetProgramivNV".} proc glGetProgramStringNV*(id: TGLuint, pname: TGLenum, theProgram: PGLubyte){. dynlib: dllname, importc: "glGetProgramStringNV".} -proc glGetTrackMatrixivNV*(target: TGLenum, address: TGLuint, pname: TGLenum, - params: PGLint){.dynlib: dllname, +proc glGetTrackMatrixivNV*(target: TGLenum, address: TGLuint, pname: TGLenum, + params: PGLint){.dynlib: dllname, importc: "glGetTrackMatrixivNV".} proc glGetVertexAttribdvNV*(index: TGLuint, pname: TGLenum, params: PGLdouble){. dynlib: dllname, importc: "glGetVertexAttribdvNV".} @@ -2533,36 +2533,36 @@ proc glGetVertexAttribfvNV*(index: TGLuint, pname: TGLenum, params: PGLfloat){. dynlib: dllname, importc: "glGetVertexAttribfvNV".} proc glGetVertexAttribivNV*(index: TGLuint, pname: TGLenum, params: PGLint){. dynlib: dllname, importc: "glGetVertexAttribivNV".} -proc glGetVertexAttribPointervNV*(index: TGLuint, pname: TGLenum, - pointer: PGLvoid){.dynlib: dllname, +proc glGetVertexAttribPointervNV*(index: TGLuint, pname: TGLenum, + pointer: PGLvoid){.dynlib: dllname, importc: "glGetVertexAttribPointervNV".} -proc glIsProgramNV*(id: TGLuint): TGLboolean{.dynlib: dllname, +proc glIsProgramNV*(id: TGLuint): TGLboolean{.dynlib: dllname, importc: "glIsProgramNV".} -proc glLoadProgramNV*(target: TGLenum, id: TGLuint, length: TGLsizei, - theProgram: PGLubyte){.dynlib: dllname, +proc glLoadProgramNV*(target: TGLenum, id: TGLuint, length: TGLsizei, + theProgram: PGLubyte){.dynlib: dllname, importc: "glLoadProgramNV".} -proc glProgramParameter4fNV*(target: TGLenum, index: TGLuint, x: TGLfloat, +proc glProgramParameter4fNV*(target: TGLenum, index: TGLuint, x: TGLfloat, y: TGLfloat, z: TGLfloat, w: TGLfloat){. dynlib: dllname, importc: "glProgramParameter4fNV".} proc glProgramParameter4fvNV*(target: TGLenum, index: TGLuint, params: PGLfloat){. dynlib: dllname, importc: "glProgramParameter4fvNV".} -proc glProgramParameters4dvNV*(target: TGLenum, index: TGLuint, num: TGLuint, - params: PGLdouble){.dynlib: dllname, +proc glProgramParameters4dvNV*(target: TGLenum, index: TGLuint, num: TGLuint, + params: PGLdouble){.dynlib: dllname, importc: "glProgramParameters4dvNV".} -proc glProgramParameters4fvNV*(target: TGLenum, index: TGLuint, num: TGLuint, - params: PGLfloat){.dynlib: dllname, +proc glProgramParameters4fvNV*(target: TGLenum, index: TGLuint, num: TGLuint, + params: PGLfloat){.dynlib: dllname, importc: "glProgramParameters4fvNV".} -proc glTrackMatrixNV*(target: TGLenum, address: TGLuint, matrix: TGLenum, - transform: TGLenum){.dynlib: dllname, +proc glTrackMatrixNV*(target: TGLenum, address: TGLuint, matrix: TGLenum, + transform: TGLenum){.dynlib: dllname, importc: "glTrackMatrixNV".} -proc glVertexAttribPointerNV*(index: TGLuint, size: TGLint, thetype: TGLenum, +proc glVertexAttribPointerNV*(index: TGLuint, size: TGLint, thetype: TGLenum, stride: TGLsizei, pointer: PGLvoid){. dynlib: dllname, importc: "glVertexAttribPointerNV".} -proc glVertexAttrib1sNV*(index: TGLuint, x: TGLshort){.dynlib: dllname, +proc glVertexAttrib1sNV*(index: TGLuint, x: TGLshort){.dynlib: dllname, importc: "glVertexAttrib1sNV".} -proc glVertexAttrib1fNV*(index: TGLuint, x: TGLfloat){.dynlib: dllname, +proc glVertexAttrib1fNV*(index: TGLuint, x: TGLfloat){.dynlib: dllname, importc: "glVertexAttrib1fNV".} -proc glVertexAttrib1dNV*(index: TGLuint, x: TGLdouble){.dynlib: dllname, +proc glVertexAttrib1dNV*(index: TGLuint, x: TGLdouble){.dynlib: dllname, importc: "glVertexAttrib1dNV".} proc glVertexAttrib2sNV*(index: TGLuint, x: TGLshort, y: TGLshort){. dynlib: dllname, importc: "glVertexAttrib2sNV".} @@ -2574,46 +2574,46 @@ proc glVertexAttrib3sNV*(index: TGLuint, x: TGLshort, y: TGLshort, z: TGLshort){ dynlib: dllname, importc: "glVertexAttrib3sNV".} proc glVertexAttrib3fNV*(index: TGLuint, x: TGLfloat, y: TGLfloat, z: TGLfloat){. dynlib: dllname, importc: "glVertexAttrib3fNV".} -proc glVertexAttrib3dNV*(index: TGLuint, x: TGLdouble, y: TGLdouble, - z: TGLdouble){.dynlib: dllname, +proc glVertexAttrib3dNV*(index: TGLuint, x: TGLdouble, y: TGLdouble, + z: TGLdouble){.dynlib: dllname, importc: "glVertexAttrib3dNV".} -proc glVertexAttrib4sNV*(index: TGLuint, x: TGLshort, y: TGLshort, z: TGLshort, - w: TGLshort){.dynlib: dllname, +proc glVertexAttrib4sNV*(index: TGLuint, x: TGLshort, y: TGLshort, z: TGLshort, + w: TGLshort){.dynlib: dllname, importc: "glVertexAttrib4sNV".} -proc glVertexAttrib4fNV*(index: TGLuint, x: TGLfloat, y: TGLfloat, z: TGLfloat, - w: TGLfloat){.dynlib: dllname, +proc glVertexAttrib4fNV*(index: TGLuint, x: TGLfloat, y: TGLfloat, z: TGLfloat, + w: TGLfloat){.dynlib: dllname, importc: "glVertexAttrib4fNV".} -proc glVertexAttrib4dNV*(index: TGLuint, x: TGLdouble, y: TGLdouble, - z: TGLdouble, w: TGLdouble){.dynlib: dllname, +proc glVertexAttrib4dNV*(index: TGLuint, x: TGLdouble, y: TGLdouble, + z: TGLdouble, w: TGLdouble){.dynlib: dllname, importc: "glVertexAttrib4dNV".} -proc glVertexAttrib4ubNV*(index: TGLuint, x: TGLubyte, y: TGLubyte, z: TGLubyte, - w: TGLubyte){.dynlib: dllname, +proc glVertexAttrib4ubNV*(index: TGLuint, x: TGLubyte, y: TGLubyte, z: TGLubyte, + w: TGLubyte){.dynlib: dllname, importc: "glVertexAttrib4ubNV".} -proc glVertexAttrib1svNV*(index: TGLuint, v: PGLshort){.dynlib: dllname, +proc glVertexAttrib1svNV*(index: TGLuint, v: PGLshort){.dynlib: dllname, importc: "glVertexAttrib1svNV".} -proc glVertexAttrib1fvNV*(index: TGLuint, v: PGLfloat){.dynlib: dllname, +proc glVertexAttrib1fvNV*(index: TGLuint, v: PGLfloat){.dynlib: dllname, importc: "glVertexAttrib1fvNV".} -proc glVertexAttrib1dvNV*(index: TGLuint, v: PGLdouble){.dynlib: dllname, +proc glVertexAttrib1dvNV*(index: TGLuint, v: PGLdouble){.dynlib: dllname, importc: "glVertexAttrib1dvNV".} -proc glVertexAttrib2svNV*(index: TGLuint, v: PGLshort){.dynlib: dllname, +proc glVertexAttrib2svNV*(index: TGLuint, v: PGLshort){.dynlib: dllname, importc: "glVertexAttrib2svNV".} -proc glVertexAttrib2fvNV*(index: TGLuint, v: PGLfloat){.dynlib: dllname, +proc glVertexAttrib2fvNV*(index: TGLuint, v: PGLfloat){.dynlib: dllname, importc: "glVertexAttrib2fvNV".} -proc glVertexAttrib2dvNV*(index: TGLuint, v: PGLdouble){.dynlib: dllname, +proc glVertexAttrib2dvNV*(index: TGLuint, v: PGLdouble){.dynlib: dllname, importc: "glVertexAttrib2dvNV".} -proc glVertexAttrib3svNV*(index: TGLuint, v: PGLshort){.dynlib: dllname, +proc glVertexAttrib3svNV*(index: TGLuint, v: PGLshort){.dynlib: dllname, importc: "glVertexAttrib3svNV".} -proc glVertexAttrib3fvNV*(index: TGLuint, v: PGLfloat){.dynlib: dllname, +proc glVertexAttrib3fvNV*(index: TGLuint, v: PGLfloat){.dynlib: dllname, importc: "glVertexAttrib3fvNV".} -proc glVertexAttrib3dvNV*(index: TGLuint, v: PGLdouble){.dynlib: dllname, +proc glVertexAttrib3dvNV*(index: TGLuint, v: PGLdouble){.dynlib: dllname, importc: "glVertexAttrib3dvNV".} -proc glVertexAttrib4svNV*(index: TGLuint, v: PGLshort){.dynlib: dllname, +proc glVertexAttrib4svNV*(index: TGLuint, v: PGLshort){.dynlib: dllname, importc: "glVertexAttrib4svNV".} -proc glVertexAttrib4fvNV*(index: TGLuint, v: PGLfloat){.dynlib: dllname, +proc glVertexAttrib4fvNV*(index: TGLuint, v: PGLfloat){.dynlib: dllname, importc: "glVertexAttrib4fvNV".} -proc glVertexAttrib4dvNV*(index: TGLuint, v: PGLdouble){.dynlib: dllname, +proc glVertexAttrib4dvNV*(index: TGLuint, v: PGLdouble){.dynlib: dllname, importc: "glVertexAttrib4dvNV".} -proc glVertexAttrib4ubvNV*(index: TGLuint, v: PGLubyte){.dynlib: dllname, +proc glVertexAttrib4ubvNV*(index: TGLuint, v: PGLubyte){.dynlib: dllname, importc: "glVertexAttrib4ubvNV".} proc glVertexAttribs1svNV*(index: TGLuint, n: TGLsizei, v: PGLshort){. dynlib: dllname, importc: "glVertexAttribs1svNV".} @@ -2643,20 +2643,20 @@ proc glVertexAttribs4ubvNV*(index: TGLuint, n: TGLsizei, v: PGLubyte){. dynlib: dllname, importc: "glVertexAttribs4ubvNV".} #***** GL_NV_vertex_program1_1 *****// #***** GL_ATI_element_array *****// -const +const GL_ELEMENT_ARRAY_ATI* = 0x00008768 GL_ELEMENT_ARRAY_TYPE_ATI* = 0x00008769 GL_ELEMENT_ARRAY_POINTER_ATI* = 0x0000876A -proc glElementPointerATI*(thetype: TGLenum, pointer: PGLvoid){.dynlib: dllname, +proc glElementPointerATI*(thetype: TGLenum, pointer: PGLvoid){.dynlib: dllname, importc: "glElementPointerATI".} -proc glDrawElementArrayATI*(mode: TGLenum, count: TGLsizei){.dynlib: dllname, +proc glDrawElementArrayATI*(mode: TGLenum, count: TGLsizei){.dynlib: dllname, importc: "glDrawElementArrayATI".} -proc glDrawRangeElementArrayATI*(mode: TGLenum, start: TGLuint, theend: TGLuint, - count: TGLsizei){.dynlib: dllname, +proc glDrawRangeElementArrayATI*(mode: TGLenum, start: TGLuint, theend: TGLuint, + count: TGLsizei){.dynlib: dllname, importc: "glDrawRangeElementArrayATI".} #***** GL_ATI_envmap_bumpmap *****// -const +const GL_BUMP_ROT_MATRIX_ATI* = 0x00008775 GL_BUMP_ROT_MATRIX_SIZE_ATI* = 0x00008776 GL_BUMP_NUM_TEX_UNITS_ATI* = 0x00008777 @@ -2666,16 +2666,16 @@ const GL_BUMP_ENVMAP_ATI* = 0x0000877B GL_BUMP_TARGET_ATI* = 0x0000877C -proc glTexBumpParameterivATI*(pname: TGLenum, param: PGLint){.dynlib: dllname, +proc glTexBumpParameterivATI*(pname: TGLenum, param: PGLint){.dynlib: dllname, importc: "glTexBumpParameterivATI".} -proc glTexBumpParameterfvATI*(pname: TGLenum, param: PGLfloat){.dynlib: dllname, +proc glTexBumpParameterfvATI*(pname: TGLenum, param: PGLfloat){.dynlib: dllname, importc: "glTexBumpParameterfvATI".} proc glGetTexBumpParameterivATI*(pname: TGLenum, param: PGLint){. dynlib: dllname, importc: "glGetTexBumpParameterivATI".} proc glGetTexBumpParameterfvATI*(pname: TGLenum, param: PGLfloat){. dynlib: dllname, importc: "glGetTexBumpParameterfvATI".} #***** GL_ATI_fragment_shader *****// -const +const GL_FRAGMENT_SHADER_ATI* = 0x00008920 GL_REG_0_ATI* = 0x00008921 GL_REG_1_ATI* = 0x00008922 @@ -2721,51 +2721,51 @@ const GL_NEGATE_BIT_ATI* = 0x00000004 GL_BIAS_BIT_ATI* = 0x00000008 -proc glGenFragmentShadersATI*(range: TGLuint): TGLuint{.dynlib: dllname, +proc glGenFragmentShadersATI*(range: TGLuint): TGLuint{.dynlib: dllname, importc: "glGenFragmentShadersATI".} -proc glBindFragmentShaderATI*(id: TGLuint){.dynlib: dllname, +proc glBindFragmentShaderATI*(id: TGLuint){.dynlib: dllname, importc: "glBindFragmentShaderATI".} -proc glDeleteFragmentShaderATI*(id: TGLuint){.dynlib: dllname, +proc glDeleteFragmentShaderATI*(id: TGLuint){.dynlib: dllname, importc: "glDeleteFragmentShaderATI".} -proc glBeginFragmentShaderATI*(){.dynlib: dllname, +proc glBeginFragmentShaderATI*(){.dynlib: dllname, importc: "glBeginFragmentShaderATI".} -proc glEndFragmentShaderATI*(){.dynlib: dllname, +proc glEndFragmentShaderATI*(){.dynlib: dllname, importc: "glEndFragmentShaderATI".} proc glPassTexCoordATI*(dst: TGLuint, coord: TGLuint, swizzle: TGLenum){. dynlib: dllname, importc: "glPassTexCoordATI".} proc glSampleMapATI*(dst: TGLuint, interp: TGLuint, swizzle: TGLenum){. dynlib: dllname, importc: "glSampleMapATI".} -proc glColorFragmentOp1ATI*(op: TGLenum, dst: TGLuint, dstMask: TGLuint, - dstMod: TGLuint, arg1: TGLuint, arg1Rep: TGLuint, - arg1Mod: TGLuint){.dynlib: dllname, +proc glColorFragmentOp1ATI*(op: TGLenum, dst: TGLuint, dstMask: TGLuint, + dstMod: TGLuint, arg1: TGLuint, arg1Rep: TGLuint, + arg1Mod: TGLuint){.dynlib: dllname, importc: "glColorFragmentOp1ATI".} -proc glColorFragmentOp2ATI*(op: TGLenum, dst: TGLuint, dstMask: TGLuint, - dstMod: TGLuint, arg1: TGLuint, arg1Rep: TGLuint, - arg1Mod: TGLuint, arg2: TGLuint, arg2Rep: TGLuint, - arg2Mod: TGLuint){.dynlib: dllname, +proc glColorFragmentOp2ATI*(op: TGLenum, dst: TGLuint, dstMask: TGLuint, + dstMod: TGLuint, arg1: TGLuint, arg1Rep: TGLuint, + arg1Mod: TGLuint, arg2: TGLuint, arg2Rep: TGLuint, + arg2Mod: TGLuint){.dynlib: dllname, importc: "glColorFragmentOp2ATI".} -proc glColorFragmentOp3ATI*(op: TGLenum, dst: TGLuint, dstMask: TGLuint, - dstMod: TGLuint, arg1: TGLuint, arg1Rep: TGLuint, - arg1Mod: TGLuint, arg2: TGLuint, arg2Rep: TGLuint, - arg2Mod: TGLuint, arg3: TGLuint, arg3Rep: TGLuint, - arg3Mod: TGLuint){.dynlib: dllname, +proc glColorFragmentOp3ATI*(op: TGLenum, dst: TGLuint, dstMask: TGLuint, + dstMod: TGLuint, arg1: TGLuint, arg1Rep: TGLuint, + arg1Mod: TGLuint, arg2: TGLuint, arg2Rep: TGLuint, + arg2Mod: TGLuint, arg3: TGLuint, arg3Rep: TGLuint, + arg3Mod: TGLuint){.dynlib: dllname, importc: "glColorFragmentOp3ATI".} -proc glAlphaFragmentOp1ATI*(op: TGLenum, dst: TGLuint, dstMod: TGLuint, +proc glAlphaFragmentOp1ATI*(op: TGLenum, dst: TGLuint, dstMod: TGLuint, arg1: TGLuint, arg1Rep: TGLuint, arg1Mod: TGLuint){. dynlib: dllname, importc: "glAlphaFragmentOp1ATI".} -proc glAlphaFragmentOp2ATI*(op: TGLenum, dst: TGLuint, dstMod: TGLuint, - arg1: TGLuint, arg1Rep: TGLuint, arg1Mod: TGLuint, +proc glAlphaFragmentOp2ATI*(op: TGLenum, dst: TGLuint, dstMod: TGLuint, + arg1: TGLuint, arg1Rep: TGLuint, arg1Mod: TGLuint, arg2: TGLuint, arg2Rep: TGLuint, arg2Mod: TGLuint){. dynlib: dllname, importc: "glAlphaFragmentOp2ATI".} -proc glAlphaFragmentOp3ATI*(op: TGLenum, dst: TGLuint, dstMod: TGLuint, - arg1: TGLuint, arg1Rep: TGLuint, arg1Mod: TGLuint, - arg2: TGLuint, arg2Rep: TGLuint, arg2Mod: TGLuint, +proc glAlphaFragmentOp3ATI*(op: TGLenum, dst: TGLuint, dstMod: TGLuint, + arg1: TGLuint, arg1Rep: TGLuint, arg1Mod: TGLuint, + arg2: TGLuint, arg2Rep: TGLuint, arg2Mod: TGLuint, arg3: TGLuint, arg3Rep: TGLuint, arg3Mod: TGLuint){. dynlib: dllname, importc: "glAlphaFragmentOp3ATI".} proc glSetFragmentShaderConstantATI*(dst: TGLuint, value: PGLfloat){. dynlib: dllname, importc: "glSetFragmentShaderConstantATI".} #***** GL_ATI_pn_triangles *****// -const +const GL_PN_TRIANGLES_ATI* = 0x000087F0 GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI* = 0x000087F1 GL_PN_TRIANGLES_POINT_MODE_ATI* = 0x000087F2 @@ -2776,17 +2776,17 @@ const GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI* = 0x000087F7 GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI* = 0x000087F8 -proc glPNTrianglesiATI*(pname: TGLenum, param: TGLint){.dynlib: dllname, +proc glPNTrianglesiATI*(pname: TGLenum, param: TGLint){.dynlib: dllname, importc: "glPNTrianglesiATI".} -proc glPNTrianglesfATI*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, +proc glPNTrianglesfATI*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, importc: "glPNTrianglesfATI".} #***** GL_ATI_texture_mirror_once *****// -const +const GL_MIRROR_CLAMP_ATI* = 0x00008742 GL_MIRROR_CLAMP_TO_EDGE_ATI* = 0x00008743 #***** GL_ATI_vertex_array_object *****// -const +const GL_STATIC_ATI* = 0x00008760 GL_DYNAMIC_ATI* = 0x00008761 GL_PRESERVE_ATI* = 0x00008762 @@ -2798,25 +2798,25 @@ const proc glNewObjectBufferATI*(size: TGLsizei, pointer: PGLvoid, usage: TGLenum): TGLuint{. dynlib: dllname, importc: "glNewObjectBufferATI".} -proc glIsObjectBufferATI*(buffer: TGLuint): TGLboolean{.dynlib: dllname, +proc glIsObjectBufferATI*(buffer: TGLuint): TGLboolean{.dynlib: dllname, importc: "glIsObjectBufferATI".} -proc glUpdateObjectBufferATI*(buffer: TGLuint, offset: TGLuint, size: TGLsizei, +proc glUpdateObjectBufferATI*(buffer: TGLuint, offset: TGLuint, size: TGLsizei, pointer: PGLvoid, preserve: TGLenum){. dynlib: dllname, importc: "glUpdateObjectBufferATI".} proc glGetObjectBufferfvATI*(buffer: TGLuint, pname: TGLenum, params: PGLfloat){. dynlib: dllname, importc: "glGetObjectBufferfvATI".} proc glGetObjectBufferivATI*(buffer: TGLuint, pname: TGLenum, params: PGLint){. dynlib: dllname, importc: "glGetObjectBufferivATI".} -proc glDeleteObjectBufferATI*(buffer: TGLuint){.dynlib: dllname, +proc glDeleteObjectBufferATI*(buffer: TGLuint){.dynlib: dllname, importc: "glDeleteObjectBufferATI".} -proc glArrayObjectATI*(thearray: TGLenum, size: TGLint, thetype: TGLenum, +proc glArrayObjectATI*(thearray: TGLenum, size: TGLint, thetype: TGLenum, stride: TGLsizei, buffer: TGLuint, offset: TGLuint){. dynlib: dllname, importc: "glArrayObjectATI".} proc glGetArrayObjectfvATI*(thearray: TGLenum, pname: TGLenum, params: PGLfloat){. dynlib: dllname, importc: "glGetArrayObjectfvATI".} proc glGetArrayObjectivATI*(thearray: TGLenum, pname: TGLenum, params: PGLint){. dynlib: dllname, importc: "glGetArrayObjectivATI".} -proc glVariantArrayObjectATI*(id: TGLuint, thetype: TGLenum, stride: TGLsizei, +proc glVariantArrayObjectATI*(id: TGLuint, thetype: TGLenum, stride: TGLsizei, buffer: TGLuint, offset: TGLuint){. dynlib: dllname, importc: "glVariantArrayObjectATI".} proc glGetVariantArrayObjectfvATI*(id: TGLuint, pname: TGLenum, params: PGLfloat){. @@ -2824,7 +2824,7 @@ proc glGetVariantArrayObjectfvATI*(id: TGLuint, pname: TGLenum, params: PGLfloat proc glGetVariantArrayObjectivATI*(id: TGLuint, pname: TGLenum, params: PGLint){. dynlib: dllname, importc: "glGetVariantArrayObjectivATI".} #***** GL_ATI_vertex_streams *****// -const +const GL_MAX_VERTEX_STREAMS_ATI* = 0x0000876B GL_VERTEX_STREAM0_ATI* = 0x0000876C GL_VERTEX_STREAM1_ATI* = 0x0000876D @@ -2836,123 +2836,123 @@ const GL_VERTEX_STREAM7_ATI* = 0x00008773 GL_VERTEX_SOURCE_ATI* = 0x00008774 -proc glVertexStream1s*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, +proc glVertexStream1s*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, importc: "glVertexStream1s".} -proc glVertexStream1i*(stream: TGLenum, coords: TGLint){.dynlib: dllname, +proc glVertexStream1i*(stream: TGLenum, coords: TGLint){.dynlib: dllname, importc: "glVertexStream1i".} -proc glVertexStream1f*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, +proc glVertexStream1f*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, importc: "glVertexStream1f".} -proc glVertexStream1d*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, +proc glVertexStream1d*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, importc: "glVertexStream1d".} -proc glVertexStream1sv*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, +proc glVertexStream1sv*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, importc: "glVertexStream1sv".} -proc glVertexStream1iv*(stream: TGLenum, coords: TGLint){.dynlib: dllname, +proc glVertexStream1iv*(stream: TGLenum, coords: TGLint){.dynlib: dllname, importc: "glVertexStream1iv".} -proc glVertexStream1fv*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, +proc glVertexStream1fv*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, importc: "glVertexStream1fv".} -proc glVertexStream1dv*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, +proc glVertexStream1dv*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, importc: "glVertexStream1dv".} -proc glVertexStream2s*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, +proc glVertexStream2s*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, importc: "glVertexStream2s".} -proc glVertexStream2i*(stream: TGLenum, coords: TGLint){.dynlib: dllname, +proc glVertexStream2i*(stream: TGLenum, coords: TGLint){.dynlib: dllname, importc: "glVertexStream2i".} -proc glVertexStream2f*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, +proc glVertexStream2f*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, importc: "glVertexStream2f".} -proc glVertexStream2d*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, +proc glVertexStream2d*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, importc: "glVertexStream2d".} -proc glVertexStream2sv*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, +proc glVertexStream2sv*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, importc: "glVertexStream2sv".} -proc glVertexStream2iv*(stream: TGLenum, coords: TGLint){.dynlib: dllname, +proc glVertexStream2iv*(stream: TGLenum, coords: TGLint){.dynlib: dllname, importc: "glVertexStream2iv".} -proc glVertexStream2fv*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, +proc glVertexStream2fv*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, importc: "glVertexStream2fv".} -proc glVertexStream2dv*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, +proc glVertexStream2dv*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, importc: "glVertexStream2dv".} -proc glVertexStream3s*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, +proc glVertexStream3s*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, importc: "glVertexStream3s".} -proc glVertexStream3i*(stream: TGLenum, coords: TGLint){.dynlib: dllname, +proc glVertexStream3i*(stream: TGLenum, coords: TGLint){.dynlib: dllname, importc: "glVertexStream3i".} -proc glVertexStream3f*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, +proc glVertexStream3f*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, importc: "glVertexStream3f".} -proc glVertexStream3d*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, +proc glVertexStream3d*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, importc: "glVertexStream3d".} -proc glVertexStream3sv*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, +proc glVertexStream3sv*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, importc: "glVertexStream3sv".} -proc glVertexStream3iv*(stream: TGLenum, coords: TGLint){.dynlib: dllname, +proc glVertexStream3iv*(stream: TGLenum, coords: TGLint){.dynlib: dllname, importc: "glVertexStream3iv".} -proc glVertexStream3fv*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, +proc glVertexStream3fv*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, importc: "glVertexStream3fv".} -proc glVertexStream3dv*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, +proc glVertexStream3dv*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, importc: "glVertexStream3dv".} -proc glVertexStream4s*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, +proc glVertexStream4s*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, importc: "glVertexStream4s".} -proc glVertexStream4i*(stream: TGLenum, coords: TGLint){.dynlib: dllname, +proc glVertexStream4i*(stream: TGLenum, coords: TGLint){.dynlib: dllname, importc: "glVertexStream4i".} -proc glVertexStream4f*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, +proc glVertexStream4f*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, importc: "glVertexStream4f".} -proc glVertexStream4d*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, +proc glVertexStream4d*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, importc: "glVertexStream4d".} -proc glVertexStream4sv*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, +proc glVertexStream4sv*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, importc: "glVertexStream4sv".} -proc glVertexStream4iv*(stream: TGLenum, coords: TGLint){.dynlib: dllname, +proc glVertexStream4iv*(stream: TGLenum, coords: TGLint){.dynlib: dllname, importc: "glVertexStream4iv".} -proc glVertexStream4fv*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, +proc glVertexStream4fv*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, importc: "glVertexStream4fv".} -proc glVertexStream4dv*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, +proc glVertexStream4dv*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, importc: "glVertexStream4dv".} -proc glNormalStream3b*(stream: TGLenum, coords: TGLByte){.dynlib: dllname, +proc glNormalStream3b*(stream: TGLenum, coords: TGLByte){.dynlib: dllname, importc: "glNormalStream3b".} -proc glNormalStream3s*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, +proc glNormalStream3s*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, importc: "glNormalStream3s".} -proc glNormalStream3i*(stream: TGLenum, coords: TGLint){.dynlib: dllname, +proc glNormalStream3i*(stream: TGLenum, coords: TGLint){.dynlib: dllname, importc: "glNormalStream3i".} -proc glNormalStream3f*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, +proc glNormalStream3f*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, importc: "glNormalStream3f".} -proc glNormalStream3d*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, +proc glNormalStream3d*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, importc: "glNormalStream3d".} -proc glNormalStream3bv*(stream: TGLenum, coords: TGLByte){.dynlib: dllname, +proc glNormalStream3bv*(stream: TGLenum, coords: TGLByte){.dynlib: dllname, importc: "glNormalStream3bv".} -proc glNormalStream3sv*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, +proc glNormalStream3sv*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, importc: "glNormalStream3sv".} -proc glNormalStream3iv*(stream: TGLenum, coords: TGLint){.dynlib: dllname, +proc glNormalStream3iv*(stream: TGLenum, coords: TGLint){.dynlib: dllname, importc: "glNormalStream3iv".} -proc glNormalStream3fv*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, +proc glNormalStream3fv*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, importc: "glNormalStream3fv".} -proc glNormalStream3dv*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, +proc glNormalStream3dv*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, importc: "glNormalStream3dv".} -proc glClientActiveVertexStream*(stream: TGLenum){.dynlib: dllname, +proc glClientActiveVertexStream*(stream: TGLenum){.dynlib: dllname, importc: "glClientActiveVertexStream".} -proc glVertexBlendEnvi*(pname: TGLenum, param: TGLint){.dynlib: dllname, +proc glVertexBlendEnvi*(pname: TGLenum, param: TGLint){.dynlib: dllname, importc: "glVertexBlendEnvi".} -proc glVertexBlendEnvf*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, +proc glVertexBlendEnvf*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, importc: "glVertexBlendEnvf".} #***** GL_3DFX_texture_compression_FXT1 *****// -const +const GL_COMPRESSED_RGB_FXT1_3DFX* = 0x000086B0 GL_COMPRESSED_RGBA_FXT1_3DFX* = 0x000086B1 #***** GL_IBM_cull_vertex *****// -const +const GL_CULL_VERTEX_IBM* = 0x0001928A #***** GL_IBM_multimode_draw_arrays *****// -proc glMultiModeDrawArraysIBM*(mode: PGLenum, first: PGLint, count: PGLsizei, +proc glMultiModeDrawArraysIBM*(mode: PGLenum, first: PGLint, count: PGLsizei, primcount: TGLsizei, modestride: TGLint){. dynlib: dllname, importc: "glMultiModeDrawArraysIBM".} -proc glMultiModeDrawElementsIBM*(mode: PGLenum, count: PGLsizei, - thetype: TGLenum, indices: PGLvoid, +proc glMultiModeDrawElementsIBM*(mode: PGLenum, count: PGLsizei, + thetype: TGLenum, indices: PGLvoid, primcount: TGLsizei, modestride: TGLint){. dynlib: dllname, importc: "glMultiModeDrawElementsIBM".} #***** GL_IBM_raster_pos_clip *****// -const +const GL_RASTER_POSITION_UNCLIPPED_IBM* = 0x00019262 #***** GL_IBM_texture_mirrored_repeat *****// -const +const GL_MIRRORED_REPEAT_IBM* = 0x00008370 #***** GL_IBM_vertex_array_lists *****// -const +const GL_VERTEX_ARRAY_LIST_IBM* = 0x0001929E GL_NORMAL_ARRAY_LIST_IBM* = 0x0001929F GL_COLOR_ARRAY_LIST_IBM* = 0x000192A0 @@ -2970,62 +2970,62 @@ const GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM* = 0x000192AE GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM* = 0x000192AF -proc glColorPointerListIBM*(size: TGLint, thetype: TGLenum, stride: TGLint, +proc glColorPointerListIBM*(size: TGLint, thetype: TGLenum, stride: TGLint, pointer: PGLvoid, ptrstride: TGLint){. dynlib: dllname, importc: "glColorPointerListIBM".} -proc glSecondaryColorPointerListIBM*(size: TGLint, thetype: TGLenum, - stride: TGLint, pointer: PGLvoid, - ptrstride: TGLint){.dynlib: dllname, +proc glSecondaryColorPointerListIBM*(size: TGLint, thetype: TGLenum, + stride: TGLint, pointer: PGLvoid, + ptrstride: TGLint){.dynlib: dllname, importc: "glSecondaryColorPointerListIBM".} -proc glEdgeFlagPointerListIBM*(stride: TGLint, pointer: PGLboolean, - ptrstride: TGLint){.dynlib: dllname, +proc glEdgeFlagPointerListIBM*(stride: TGLint, pointer: PGLboolean, + ptrstride: TGLint){.dynlib: dllname, importc: "glEdgeFlagPointerListIBM".} -proc glFogCoordPointerListIBM*(thetype: TGLenum, stride: TGLint, +proc glFogCoordPointerListIBM*(thetype: TGLenum, stride: TGLint, pointer: PGLvoid, ptrstride: TGLint){. dynlib: dllname, importc: "glFogCoordPointerListIBM".} -proc glNormalPointerListIBM*(thetype: TGLenum, stride: TGLint, pointer: PGLvoid, - ptrstride: TGLint){.dynlib: dllname, +proc glNormalPointerListIBM*(thetype: TGLenum, stride: TGLint, pointer: PGLvoid, + ptrstride: TGLint){.dynlib: dllname, importc: "glNormalPointerListIBM".} -proc glTexCoordPointerListIBM*(size: TGLint, thetype: TGLenum, stride: TGLint, +proc glTexCoordPointerListIBM*(size: TGLint, thetype: TGLenum, stride: TGLint, pointer: PGLvoid, ptrstride: TGLint){. dynlib: dllname, importc: "glTexCoordPointerListIBM".} -proc glVertexPointerListIBM*(size: TGLint, thetype: TGLenum, stride: TGLint, +proc glVertexPointerListIBM*(size: TGLint, thetype: TGLenum, stride: TGLint, pointer: PGLvoid, ptrstride: TGLint){. dynlib: dllname, importc: "glVertexPointerListIBM".} #***** GL_MESA_resize_buffers *****// proc glResizeBuffersMESA*(){.dynlib: dllname, importc: "glResizeBuffersMESA".} #***** GL_MESA_window_pos *****// -proc glWindowPos2dMESA*(x: TGLdouble, y: TGLdouble){.dynlib: dllname, +proc glWindowPos2dMESA*(x: TGLdouble, y: TGLdouble){.dynlib: dllname, importc: "glWindowPos2dMESA".} -proc glWindowPos2fMESA*(x: TGLfloat, y: TGLfloat){.dynlib: dllname, +proc glWindowPos2fMESA*(x: TGLfloat, y: TGLfloat){.dynlib: dllname, importc: "glWindowPos2fMESA".} -proc glWindowPos2iMESA*(x: TGLint, y: TGLint){.dynlib: dllname, +proc glWindowPos2iMESA*(x: TGLint, y: TGLint){.dynlib: dllname, importc: "glWindowPos2iMESA".} -proc glWindowPos2sMESA*(x: TGLshort, y: TGLshort){.dynlib: dllname, +proc glWindowPos2sMESA*(x: TGLshort, y: TGLshort){.dynlib: dllname, importc: "glWindowPos2sMESA".} -proc glWindowPos2ivMESA*(p: PGLint){.dynlib: dllname, +proc glWindowPos2ivMESA*(p: PGLint){.dynlib: dllname, importc: "glWindowPos2ivMESA".} -proc glWindowPos2svMESA*(p: PGLshort){.dynlib: dllname, +proc glWindowPos2svMESA*(p: PGLshort){.dynlib: dllname, importc: "glWindowPos2svMESA".} -proc glWindowPos2fvMESA*(p: PGLfloat){.dynlib: dllname, +proc glWindowPos2fvMESA*(p: PGLfloat){.dynlib: dllname, importc: "glWindowPos2fvMESA".} -proc glWindowPos2dvMESA*(p: PGLdouble){.dynlib: dllname, +proc glWindowPos2dvMESA*(p: PGLdouble){.dynlib: dllname, importc: "glWindowPos2dvMESA".} -proc glWindowPos3iMESA*(x: TGLint, y: TGLint, z: TGLint){.dynlib: dllname, +proc glWindowPos3iMESA*(x: TGLint, y: TGLint, z: TGLint){.dynlib: dllname, importc: "glWindowPos3iMESA".} -proc glWindowPos3sMESA*(x: TGLshort, y: TGLshort, z: TGLshort){.dynlib: dllname, +proc glWindowPos3sMESA*(x: TGLshort, y: TGLshort, z: TGLshort){.dynlib: dllname, importc: "glWindowPos3sMESA".} -proc glWindowPos3fMESA*(x: TGLfloat, y: TGLfloat, z: TGLfloat){.dynlib: dllname, +proc glWindowPos3fMESA*(x: TGLfloat, y: TGLfloat, z: TGLfloat){.dynlib: dllname, importc: "glWindowPos3fMESA".} proc glWindowPos3dMESA*(x: TGLdouble, y: TGLdouble, z: TGLdouble){. dynlib: dllname, importc: "glWindowPos3dMESA".} -proc glWindowPos3ivMESA*(p: PGLint){.dynlib: dllname, +proc glWindowPos3ivMESA*(p: PGLint){.dynlib: dllname, importc: "glWindowPos3ivMESA".} -proc glWindowPos3svMESA*(p: PGLshort){.dynlib: dllname, +proc glWindowPos3svMESA*(p: PGLshort){.dynlib: dllname, importc: "glWindowPos3svMESA".} -proc glWindowPos3fvMESA*(p: PGLfloat){.dynlib: dllname, +proc glWindowPos3fvMESA*(p: PGLfloat){.dynlib: dllname, importc: "glWindowPos3fvMESA".} -proc glWindowPos3dvMESA*(p: PGLdouble){.dynlib: dllname, +proc glWindowPos3dvMESA*(p: PGLdouble){.dynlib: dllname, importc: "glWindowPos3dvMESA".} proc glWindowPos4iMESA*(x: TGLint, y: TGLint, z: TGLint, w: TGLint){. dynlib: dllname, importc: "glWindowPos4iMESA".} @@ -3035,21 +3035,21 @@ proc glWindowPos4fMESA*(x: TGLfloat, y: TGLfloat, z: TGLfloat, w: TGLfloat){. dynlib: dllname, importc: "glWindowPos4fMESA".} proc glWindowPos4dMESA*(x: TGLdouble, y: TGLdouble, z: TGLdouble, w: TGLdouble){. dynlib: dllname, importc: "glWindowPos4dMESA".} -proc glWindowPos4ivMESA*(p: PGLint){.dynlib: dllname, +proc glWindowPos4ivMESA*(p: PGLint){.dynlib: dllname, importc: "glWindowPos4ivMESA".} -proc glWindowPos4svMESA*(p: PGLshort){.dynlib: dllname, +proc glWindowPos4svMESA*(p: PGLshort){.dynlib: dllname, importc: "glWindowPos4svMESA".} -proc glWindowPos4fvMESA*(p: PGLfloat){.dynlib: dllname, +proc glWindowPos4fvMESA*(p: PGLfloat){.dynlib: dllname, importc: "glWindowPos4fvMESA".} -proc glWindowPos4dvMESA*(p: PGLdouble){.dynlib: dllname, +proc glWindowPos4dvMESA*(p: PGLdouble){.dynlib: dllname, importc: "glWindowPos4dvMESA".} #***** GL_OML_interlace *****// -const +const GL_INTERLACE_OML* = 0x00008980 GL_INTERLACE_READ_OML* = 0x00008981 #***** GL_OML_resample *****// -const +const GL_PACK_RESAMPLE_OML* = 0x00008984 GL_UNPACK_RESAMPLE_OML* = 0x00008985 GL_RESAMPLE_REPLICATE_OML* = 0x00008986 @@ -3058,17 +3058,17 @@ const GL_RESAMPLE_DECIMATE_OML* = 0x00008989 # GL_RESAMPLE_AVERAGE_OML { already defined } #***** GL_OML_subsample *****// -const +const GL_FORMAT_SUBSAMPLE_24_24_OML* = 0x00008982 GL_FORMAT_SUBSAMPLE_244_244_OML* = 0x00008983 #***** GL_SGIS_generate_mipmap *****// -const +const GL_GENERATE_MIPMAP_SGIS* = 0x00008191 GL_GENERATE_MIPMAP_HINT_SGIS* = 0x00008192 #***** GL_SGIS_multisample *****// -const +const GLX_SAMPLE_BUFFERS_SGIS* = 0x000186A0 GLX_SAMPLES_SGIS* = 0x000186A1 GL_MULTISAMPLE_SGIS* = 0x0000809D @@ -3089,12 +3089,12 @@ const GL_SAMPLE_MASK_INVERT_SGIS* = 0x000080AB constGL_SAMPLE_PATTERN_SGIS* = 0x000080AC -proc glSampleMaskSGIS*(value: TGLclampf, invert: TGLboolean){.dynlib: dllname, +proc glSampleMaskSGIS*(value: TGLclampf, invert: TGLboolean){.dynlib: dllname, importc: "glSampleMaskSGIS".} -proc glSamplePatternSGIS*(pattern: TGLenum){.dynlib: dllname, +proc glSamplePatternSGIS*(pattern: TGLenum){.dynlib: dllname, importc: "glSamplePatternSGIS".} #***** GL_SGIS_pixel_texture *****// -const +const GL_PIXEL_TEXTURE_SGIS* = 0x00008353 GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS* = 0x00008354 GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS* = 0x00008355 @@ -3111,44 +3111,44 @@ proc glGetPixelTexGenParameterfvSGIS*(pname: TGLenum, params: TGLfloat){. #***** GL_SGIS_texture_border_clamp *****// # GL_CLAMP_TO_BORDER_SGIS { already defined } #***** GL_SGIS_texture_color_mask *****// -const +const GL_TEXTURE_COLOR_WRITEMASK_SGIS* = 0x000081EF -proc glTextureColorMaskSGIS*(r: TGLboolean, g: TGLboolean, b: TGLboolean, - a: TGLboolean){.dynlib: dllname, +proc glTextureColorMaskSGIS*(r: TGLboolean, g: TGLboolean, b: TGLboolean, + a: TGLboolean){.dynlib: dllname, importc: "glTextureColorMaskSGIS".} #***** GL_SGIS_texture_edge_clamp *****// -const +const GL_CLAMP_TO_EDGE_SGIS* = 0x0000812F #***** GL_SGIS_texture_lod *****// -const +const GL_TEXTURE_MIN_LOD_SGIS* = 0x0000813A GL_TEXTURE_MAX_LOD_SGIS* = 0x0000813B GL_TEXTURE_BASE_LEVEL_SGIS* = 0x0000813C GL_TEXTURE_MAX_LEVEL_SGIS* = 0x0000813D #***** GL_SGIS_depth_texture *****// -const +const GL_DEPTH_COMPONENT16_SGIX* = 0x000081A5 GL_DEPTH_COMPONENT24_SGIX* = 0x000081A6 GL_DEPTH_COMPONENT32_SGIX* = 0x000081A7 #***** GL_SGIX_fog_offset *****// -const +const GL_FOG_OFFSET_SGIX* = 0x00008198 GL_FOG_OFFSET_VALUE_SGIX* = 0x00008199 #***** GL_SGIX_interlace *****// -const +const GL_INTERLACE_SGIX* = 0x00008094 #***** GL_SGIX_shadow_ambient *****// -const +const GL_SHADOW_AMBIENT_SGIX* = 0x000080BF #***** GL_SGI_color_matrix *****// -const +const GL_COLOR_MATRIX_SGI* = 0x000080B1 GL_COLOR_MATRIX_STACK_DEPTH_SGI* = 0x000080B2 GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI* = 0x000080B3 @@ -3162,7 +3162,7 @@ const GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI* = 0x000080BB #***** GL_SGI_color_table *****// -const +const constGL_COLOR_TABLE_SGI* = 0x000080D0 GL_POST_CONVOLUTION_COLOR_TABLE_SGI* = 0x000080D1 GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI* = 0x000080D2 @@ -3180,151 +3180,151 @@ const GL_COLOR_TABLE_LUMINANCE_SIZE_SGI* = 0x000080DE GL_COLOR_TABLE_INTENSITY_SIZE_SGI* = 0x000080DF -proc glColorTableSGI*(target: TGLenum, internalformat: TGLenum, width: TGLsizei, +proc glColorTableSGI*(target: TGLenum, internalformat: TGLenum, width: TGLsizei, format: TGLenum, thetype: TGLenum, table: PGLvoid){. dynlib: dllname, importc: "glColorTableSGI".} -proc glCopyColorTableSGI*(target: TGLenum, internalformat: TGLenum, x: TGLint, - y: TGLint, width: TGLsizei){.dynlib: dllname, +proc glCopyColorTableSGI*(target: TGLenum, internalformat: TGLenum, x: TGLint, + y: TGLint, width: TGLsizei){.dynlib: dllname, importc: "glCopyColorTableSGI".} proc glColorTableParameterivSGI*(target: TGLenum, pname: TGLenum, params: PGLint){. dynlib: dllname, importc: "glColorTableParameterivSGI".} -proc glColorTableParameterfvSGI*(target: TGLenum, pname: TGLenum, - params: PGLfloat){.dynlib: dllname, +proc glColorTableParameterfvSGI*(target: TGLenum, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, importc: "glColorTableParameterfvSGI".} -proc glGetColorTableSGI*(target: TGLenum, format: TGLenum, thetype: TGLenum, - table: PGLvoid){.dynlib: dllname, +proc glGetColorTableSGI*(target: TGLenum, format: TGLenum, thetype: TGLenum, + table: PGLvoid){.dynlib: dllname, importc: "glGetColorTableSGI".} -proc glGetColorTableParameterivSGI*(target: TGLenum, pname: TGLenum, - params: PGLint){.dynlib: dllname, +proc glGetColorTableParameterivSGI*(target: TGLenum, pname: TGLenum, + params: PGLint){.dynlib: dllname, importc: "glGetColorTableParameterivSGI".} -proc glGetColorTableParameterfvSGI*(target: TGLenum, pname: TGLenum, - params: PGLfloat){.dynlib: dllname, +proc glGetColorTableParameterfvSGI*(target: TGLenum, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, importc: "glGetColorTableParameterfvSGI".} #***** GL_SGI_texture_color_table *****// -const +const GL_TEXTURE_COLOR_TABLE_SGI* = 0x000080BC GL_PROXY_TEXTURE_COLOR_TABLE_SGI* = 0x000080BD #***** GL_SUN_vertex *****// -proc glColor4ubVertex2fSUN*(r: TGLubyte, g: TGLubyte, b: TGLubyte, a: TGLubyte, - x: TGLfloat, y: TGLfloat){.dynlib: dllname, +proc glColor4ubVertex2fSUN*(r: TGLubyte, g: TGLubyte, b: TGLubyte, a: TGLubyte, + x: TGLfloat, y: TGLfloat){.dynlib: dllname, importc: "glColor4ubVertex2fSUN".} -proc glColor4ubVertex2fvSUN*(c: PGLubyte, v: PGLfloat){.dynlib: dllname, +proc glColor4ubVertex2fvSUN*(c: PGLubyte, v: PGLfloat){.dynlib: dllname, importc: "glColor4ubVertex2fvSUN".} -proc glColor4ubVertex3fSUN*(r: TGLubyte, g: TGLubyte, b: TGLubyte, a: TGLubyte, +proc glColor4ubVertex3fSUN*(r: TGLubyte, g: TGLubyte, b: TGLubyte, a: TGLubyte, x: TGLfloat, y: TGLfloat, z: TGLfloat){. dynlib: dllname, importc: "glColor4ubVertex3fSUN".} -proc glColor4ubVertex3fvSUN*(c: PGLubyte, v: PGLfloat){.dynlib: dllname, +proc glColor4ubVertex3fvSUN*(c: PGLubyte, v: PGLfloat){.dynlib: dllname, importc: "glColor4ubVertex3fvSUN".} -proc glColor3fVertex3fSUN*(r: TGLfloat, g: TGLfloat, b: TGLfloat, x: TGLfloat, - y: TGLfloat, z: TGLfloat){.dynlib: dllname, +proc glColor3fVertex3fSUN*(r: TGLfloat, g: TGLfloat, b: TGLfloat, x: TGLfloat, + y: TGLfloat, z: TGLfloat){.dynlib: dllname, importc: "glColor3fVertex3fSUN".} -proc glColor3fVertex3fvSUN*(c: PGLfloat, v: PGLfloat){.dynlib: dllname, +proc glColor3fVertex3fvSUN*(c: PGLfloat, v: PGLfloat){.dynlib: dllname, importc: "glColor3fVertex3fvSUN".} -proc glNormal3fVertex3fSUN*(nx: TGLfloat, ny: TGLfloat, nz: TGLfloat, +proc glNormal3fVertex3fSUN*(nx: TGLfloat, ny: TGLfloat, nz: TGLfloat, x: TGLfloat, y: TGLfloat, z: TGLfloat){. dynlib: dllname, importc: "glNormal3fVertex3fSUN".} -proc glNormal3fVertex3fvSUN*(n: PGLfloat, v: PGLfloat){.dynlib: dllname, +proc glNormal3fVertex3fvSUN*(n: PGLfloat, v: PGLfloat){.dynlib: dllname, importc: "glNormal3fVertex3fvSUN".} -proc glColor4fNormal3fVertex3fSUN*(r: TGLfloat, g: TGLfloat, b: TGLfloat, - a: TGLfloat, nx: TGLfloat, ny: TGLfloat, - nz: TGLfloat, x: TGLfloat, y: TGLfloat, - z: TGLfloat){.dynlib: dllname, +proc glColor4fNormal3fVertex3fSUN*(r: TGLfloat, g: TGLfloat, b: TGLfloat, + a: TGLfloat, nx: TGLfloat, ny: TGLfloat, + nz: TGLfloat, x: TGLfloat, y: TGLfloat, + z: TGLfloat){.dynlib: dllname, importc: "glColor4fNormal3fVertex3fSUN".} proc glColor4fNormal3fVertex3fvSUN*(c: PGLfloat, n: PGLfloat, v: PGLfloat){. dynlib: dllname, importc: "glColor4fNormal3fVertex3fvSUN".} -proc glTexCoord2fVertex3fSUN*(s: TGLfloat, t: TGLfloat, x: TGLfloat, - y: TGLfloat, z: TGLfloat){.dynlib: dllname, +proc glTexCoord2fVertex3fSUN*(s: TGLfloat, t: TGLfloat, x: TGLfloat, + y: TGLfloat, z: TGLfloat){.dynlib: dllname, importc: "glTexCoord2fVertex3fSUN".} -proc glTexCoord2fVertex3fvSUN*(tc: PGLfloat, v: PGLfloat){.dynlib: dllname, +proc glTexCoord2fVertex3fvSUN*(tc: PGLfloat, v: PGLfloat){.dynlib: dllname, importc: "glTexCoord2fVertex3fvSUN".} -proc glTexCoord4fVertex4fSUN*(s: TGLfloat, t: TGLfloat, p: TGLfloat, - q: TGLfloat, x: TGLfloat, y: TGLfloat, - z: TGLfloat, w: TGLfloat){.dynlib: dllname, +proc glTexCoord4fVertex4fSUN*(s: TGLfloat, t: TGLfloat, p: TGLfloat, + q: TGLfloat, x: TGLfloat, y: TGLfloat, + z: TGLfloat, w: TGLfloat){.dynlib: dllname, importc: "glTexCoord4fVertex4fSUN".} -proc glTexCoord4fVertex4fvSUN*(tc: PGLfloat, v: PGLfloat){.dynlib: dllname, +proc glTexCoord4fVertex4fvSUN*(tc: PGLfloat, v: PGLfloat){.dynlib: dllname, importc: "glTexCoord4fVertex4fvSUN".} -proc glTexCoord2fColor4ubVertex3fSUN*(s: TGLfloat, t: TGLfloat, r: TGLubyte, - g: TGLubyte, b: TGLubyte, a: TGLubyte, +proc glTexCoord2fColor4ubVertex3fSUN*(s: TGLfloat, t: TGLfloat, r: TGLubyte, + g: TGLubyte, b: TGLubyte, a: TGLubyte, x: TGLfloat, y: TGLfloat, z: TGLfloat){. dynlib: dllname, importc: "glTexCoord2fColor4ubVertex3fSUN".} proc glTexCoord2fColor4ubVertex3fvSUN*(tc: PGLfloat, c: PGLubyte, v: PGLfloat){. dynlib: dllname, importc: "glTexCoord2fColor4ubVertex3fvSUN".} -proc glTexCoord2fColor3fVertex3fSUN*(s: TGLfloat, t: TGLfloat, r: TGLfloat, - g: TGLfloat, b: TGLfloat, x: TGLfloat, - y: TGLfloat, z: TGLfloat){.dynlib: dllname, +proc glTexCoord2fColor3fVertex3fSUN*(s: TGLfloat, t: TGLfloat, r: TGLfloat, + g: TGLfloat, b: TGLfloat, x: TGLfloat, + y: TGLfloat, z: TGLfloat){.dynlib: dllname, importc: "glTexCoord2fColor3fVertex3fSUN".} proc glTexCoord2fColor3fVertex3fvSUN*(tc: PGLfloat, c: PGLfloat, v: PGLfloat){. dynlib: dllname, importc: "glTexCoord2fColor3fVertex3fvSUN".} -proc glTexCoord2fNormal3fVertex3fSUN*(s: TGLfloat, t: TGLfloat, nx: TGLfloat, - ny: TGLfloat, nz: TGLfloat, x: TGLfloat, +proc glTexCoord2fNormal3fVertex3fSUN*(s: TGLfloat, t: TGLfloat, nx: TGLfloat, + ny: TGLfloat, nz: TGLfloat, x: TGLfloat, y: TGLfloat, z: TGLfloat){. dynlib: dllname, importc: "glTexCoord2fNormal3fVertex3fSUN".} proc glTexCoord2fNormal3fVertex3fvSUN*(tc: PGLfloat, n: PGLfloat, v: PGLfloat){. dynlib: dllname, importc: "glTexCoord2fNormal3fVertex3fvSUN".} -proc glTexCoord2fColor4fNormal3fVertex3fSUN*(s: TGLfloat, t: TGLfloat, - r: TGLfloat, g: TGLfloat, b: TGLfloat, a: TGLfloat, nx: TGLfloat, +proc glTexCoord2fColor4fNormal3fVertex3fSUN*(s: TGLfloat, t: TGLfloat, + r: TGLfloat, g: TGLfloat, b: TGLfloat, a: TGLfloat, nx: TGLfloat, ny: TGLfloat, nz: TGLfloat, x: TGLfloat, y: TGLfloat, z: TGLfloat){. dynlib: dllname, importc: "glTexCoord2fColor4fNormal3fVertex3fSUN".} -proc glTexCoord2fColor4fNormal3fVertex3fvSUN*(tc: PGLfloat, c: PGLfloat, +proc glTexCoord2fColor4fNormal3fVertex3fvSUN*(tc: PGLfloat, c: PGLfloat, n: PGLfloat, v: PGLfloat){.dynlib: dllname, importc: "glTexCoord2fColor4fNormal3fVertex3fvSUN".} -proc glTexCoord4fColor4fNormal3fVertex4fSUN*(s: TGLfloat, t: TGLfloat, - p: TGLfloat, q: TGLfloat, r: TGLfloat, g: TGLfloat, b: TGLfloat, - a: TGLfloat, nx: TGLfloat, ny: TGLfloat, nz: TGLfloat, x: TGLfloat, - y: TGLfloat, z: TGLfloat, w: TGLfloat){.dynlib: dllname, +proc glTexCoord4fColor4fNormal3fVertex4fSUN*(s: TGLfloat, t: TGLfloat, + p: TGLfloat, q: TGLfloat, r: TGLfloat, g: TGLfloat, b: TGLfloat, + a: TGLfloat, nx: TGLfloat, ny: TGLfloat, nz: TGLfloat, x: TGLfloat, + y: TGLfloat, z: TGLfloat, w: TGLfloat){.dynlib: dllname, importc: "glTexCoord4fColor4fNormal3fVertex4fSUN".} -proc glTexCoord4fColor4fNormal3fVertex4fvSUN*(tc: PGLfloat, c: PGLfloat, +proc glTexCoord4fColor4fNormal3fVertex4fvSUN*(tc: PGLfloat, c: PGLfloat, n: PGLfloat, v: PGLfloat){.dynlib: dllname, importc: "glTexCoord4fColor4fNormal3fVertex4fvSUN".} -proc glReplacementCodeuiVertex3fSUN*(rc: TGLuint, x: TGLfloat, y: TGLfloat, - z: TGLfloat){.dynlib: dllname, +proc glReplacementCodeuiVertex3fSUN*(rc: TGLuint, x: TGLfloat, y: TGLfloat, + z: TGLfloat){.dynlib: dllname, importc: "glReplacementCodeuiVertex3fSUN".} proc glReplacementCodeuiVertex3fvSUN*(rc: PGLuint, v: PGLfloat){. dynlib: dllname, importc: "glReplacementCodeuiVertex3fvSUN".} -proc glReplacementCodeuiColor4ubVertex3fSUN*(rc: TGLuint, r: TGLubyte, +proc glReplacementCodeuiColor4ubVertex3fSUN*(rc: TGLuint, r: TGLubyte, g: TGLubyte, b: TGLubyte, a: TGLubyte, x: TGLfloat, y: TGLfloat, z: TGLfloat){. dynlib: dllname, importc: "glReplacementCodeuiColor4ubVertex3fSUN".} -proc glReplacementCodeuiColor4ubVertex3fvSUN*(rc: PGLuint, c: PGLubyte, - v: PGLfloat){.dynlib: dllname, +proc glReplacementCodeuiColor4ubVertex3fvSUN*(rc: PGLuint, c: PGLubyte, + v: PGLfloat){.dynlib: dllname, importc: "glReplacementCodeuiColor4ubVertex3fvSUN".} -proc glReplacementCodeuiColor3fVertex3fSUN*(rc: TGLuint, r: TGLfloat, +proc glReplacementCodeuiColor3fVertex3fSUN*(rc: TGLuint, r: TGLfloat, g: TGLfloat, b: TGLfloat, x: TGLfloat, y: TGLfloat, z: TGLfloat){. dynlib: dllname, importc: "glReplacementCodeuiColor3fVertex3fSUN".} -proc glReplacementCodeuiColor3fVertex3fvSUN*(rc: PGLuint, c: PGLfloat, - v: PGLfloat){.dynlib: dllname, +proc glReplacementCodeuiColor3fVertex3fvSUN*(rc: PGLuint, c: PGLfloat, + v: PGLfloat){.dynlib: dllname, importc: "glReplacementCodeuiColor3fVertex3fvSUN".} -proc glReplacementCodeuiNormal3fVertex3fSUN*(rc: TGLuint, nx: TGLfloat, +proc glReplacementCodeuiNormal3fVertex3fSUN*(rc: TGLuint, nx: TGLfloat, ny: TGLfloat, nz: TGLfloat, x: TGLfloat, y: TGLfloat, z: TGLfloat){. dynlib: dllname, importc: "glReplacementCodeuiNormal3fVertex3fSUN".} -proc glReplacementCodeuiNormal3fVertex3fvSUN*(rc: PGLuint, n: PGLfloat, - v: PGLfloat){.dynlib: dllname, +proc glReplacementCodeuiNormal3fVertex3fvSUN*(rc: PGLuint, n: PGLfloat, + v: PGLfloat){.dynlib: dllname, importc: "glReplacementCodeuiNormal3fVertex3fvSUN".} -proc glReplacementCodeuiColor4fNormal3fVertex3fSUN*(rc: TGLuint, r: TGLfloat, - g: TGLfloat, b: TGLfloat, a: TGLfloat, nx: TGLfloat, ny: TGLfloat, - nz: TGLfloat, x: TGLfloat, y: TGLfloat, z: TGLfloat){.dynlib: dllname, +proc glReplacementCodeuiColor4fNormal3fVertex3fSUN*(rc: TGLuint, r: TGLfloat, + g: TGLfloat, b: TGLfloat, a: TGLfloat, nx: TGLfloat, ny: TGLfloat, + nz: TGLfloat, x: TGLfloat, y: TGLfloat, z: TGLfloat){.dynlib: dllname, importc: "glReplacementCodeuiColor4fNormal3fVertex3fSUN".} -proc glReplacementCodeuiColor4fNormal3fVertex3fvSUN*(rc: PGLuint, c: PGLfloat, +proc glReplacementCodeuiColor4fNormal3fVertex3fvSUN*(rc: PGLuint, c: PGLfloat, n: PGLfloat, v: PGLfloat){.dynlib: dllname, importc: "glReplacementCodeuiColor4fNormal3fVertex3fvSUN".} -proc glReplacementCodeuiTexCoord2fVertex3fSUN*(rc: TGLuint, s: TGLfloat, - t: TGLfloat, x: TGLfloat, y: TGLfloat, z: TGLfloat){.dynlib: dllname, +proc glReplacementCodeuiTexCoord2fVertex3fSUN*(rc: TGLuint, s: TGLfloat, + t: TGLfloat, x: TGLfloat, y: TGLfloat, z: TGLfloat){.dynlib: dllname, importc: "glReplacementCodeuiTexCoord2fVertex3fSUN".} -proc glReplacementCodeuiTexCoord2fVertex3fvSUN*(rc: PGLuint, tc: PGLfloat, - v: PGLfloat){.dynlib: dllname, +proc glReplacementCodeuiTexCoord2fVertex3fvSUN*(rc: PGLuint, tc: PGLfloat, + v: PGLfloat){.dynlib: dllname, importc: "glReplacementCodeuiTexCoord2fVertex3fvSUN".} -proc glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN*(rc: TGLuint, s: TGLfloat, - t: TGLfloat, nx: TGLfloat, ny: TGLfloat, nz: TGLfloat, x: TGLfloat, +proc glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN*(rc: TGLuint, s: TGLfloat, + t: TGLfloat, nx: TGLfloat, ny: TGLfloat, nz: TGLfloat, x: TGLfloat, y: TGLfloat, z: TGLfloat){.dynlib: dllname, importc: "glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN".} -proc glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN*(rc: PGLuint, - tc: PGLfloat, n: PGLfloat, v: PGLfloat){.dynlib: dllname, +proc glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN*(rc: PGLuint, + tc: PGLfloat, n: PGLfloat, v: PGLfloat){.dynlib: dllname, importc: "glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN".} -proc glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN*(rc: TGLuint, - s: TGLfloat, t: TGLfloat, r: TGLfloat, g: TGLfloat, b: TGLfloat, - a: TGLfloat, nx: TGLfloat, ny: TGLfloat, nz: TGLfloat, x: TGLfloat, +proc glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN*(rc: TGLuint, + s: TGLfloat, t: TGLfloat, r: TGLfloat, g: TGLfloat, b: TGLfloat, + a: TGLfloat, nx: TGLfloat, ny: TGLfloat, nz: TGLfloat, x: TGLfloat, y: TGLfloat, z: TGLfloat){.dynlib: dllname, importc: "glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN".} -proc glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN*(rc: PGLuint, - tc: PGLfloat, c: PGLfloat, n: PGLfloat, v: PGLfloat){.dynlib: dllname, +proc glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN*(rc: PGLuint, + tc: PGLfloat, c: PGLfloat, n: PGLfloat, v: PGLfloat){.dynlib: dllname, importc: "glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN".} #***** GL_ARB_fragment_program *****// -const +const GL_FRAGMENT_PROGRAM_ARB* = 0x00008804 # GL_PROGRAM_FORMAT_ASCII_ARB { already defined } # GL_PROGRAM_LENGTH_ARB { already defined } # GL_PROGRAM_FORMAT_ARB { already defined } @@ -3360,21 +3360,21 @@ const GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB* = 0x0000880E GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB* = 0x0000880F GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB* = 0x00008810 # GL_PROGRAM_STRING_ARB { already defined } - # - # + # + # # GL_PROGRAM_ERROR_POSITION_ARB { already defined } # GL_CURRENT_MATRIX_ARB { already defined } - # - # + # + # # GL_TRANSPOSE_CURRENT_MATRIX_ARB { already defined } - # - # + # + # # GL_CURRENT_MATRIX_STACK_DEPTH_ARB { already defined } - # - # + # + # # GL_MAX_PROGRAM_MATRICES_ARB { already defined } - # - # + # + # # GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB { already defined } GL_MAX_TEXTURE_COORDS_ARB* = 0x00008871 GL_MAX_TEXTURE_IMAGE_UNITS_ARB* = 0x00008872 # GL_PROGRAM_ERROR_STRING_ARB { already defined } @@ -3431,10 +3431,10 @@ const # glIsProgramARB { already defined } #***** GL_ATI_text_fragment_shader ***** -const +const GL_TEXT_FRAGMENT_SHADER_ATI* = 0x00008200 #***** GL_ARB_vertex_buffer_object ***** -const +const GL_BUFFER_SIZE_ARB* = 0x00008764 GL_BUFFER_USAGE_ARB* = 0x00008765 GL_ARRAY_BUFFER_ARB* = 0x00008892 @@ -3467,37 +3467,37 @@ const GL_DYNAMIC_READ_ARB* = 0x000088E9 GL_DYNAMIC_COPY_ARB* = 0x000088EA -proc glBindBufferARB*(target: TGLenum, buffer: TGLuint){.dynlib: dllname, +proc glBindBufferARB*(target: TGLenum, buffer: TGLuint){.dynlib: dllname, importc: "glBindBufferARB".} -proc glDeleteBuffersARB*(n: TGLsizei, buffers: PGLuint){.dynlib: dllname, +proc glDeleteBuffersARB*(n: TGLsizei, buffers: PGLuint){.dynlib: dllname, importc: "glDeleteBuffersARB".} -proc glGenBuffersARB*(n: TGLsizei, buffers: PGLuint){.dynlib: dllname, +proc glGenBuffersARB*(n: TGLsizei, buffers: PGLuint){.dynlib: dllname, importc: "glGenBuffersARB".} -proc glIsBufferARB*(buffer: TGLuint): TGLboolean{.dynlib: dllname, +proc glIsBufferARB*(buffer: TGLuint): TGLboolean{.dynlib: dllname, importc: "glIsBufferARB".} -proc glBufferDataARB*(target: TGLenum, size: TGLsizei, data: PGLvoid, - usage: TGLenum){.dynlib: dllname, +proc glBufferDataARB*(target: TGLenum, size: TGLsizei, data: PGLvoid, + usage: TGLenum){.dynlib: dllname, importc: "glBufferDataARB".} -proc glBufferSubDataARB*(target: TGLenum, offset: TGLint, size: TGLsizei, - data: PGLvoid){.dynlib: dllname, +proc glBufferSubDataARB*(target: TGLenum, offset: TGLint, size: TGLsizei, + data: PGLvoid){.dynlib: dllname, importc: "glBufferSubDataARB".} -proc glGetBufferSubDataARB*(target: TGLenum, offset: TGLint, size: TGLsizei, - data: PGLvoid){.dynlib: dllname, +proc glGetBufferSubDataARB*(target: TGLenum, offset: TGLint, size: TGLsizei, + data: PGLvoid){.dynlib: dllname, importc: "glGetBufferSubDataARB".} proc glMapBufferARB*(target: TGLenum, access: TGLenum): PGLvoid{. dynlib: dllname, importc: "glMapBufferARB".} -proc glUnmapBufferARB*(target: TGLenum): TGLboolean{.dynlib: dllname, +proc glUnmapBufferARB*(target: TGLenum): TGLboolean{.dynlib: dllname, importc: "glUnmapBufferARB".} proc glGetBufferParameterivARB*(target: TGLenum, pname: TGLenum, params: PGLint){. dynlib: dllname, importc: "glGetBufferParameterivARB".} proc glGetBufferPointervARB*(target: TGLenum, pname: TGLenum, params: PPGLvoid){. dynlib: dllname, importc: "glGetBufferPointervARB".} #***** GL_APPLE_client_storage *****// -const +const GL_UNPACK_CLIENT_STORAGE_APPLE* = 0x000085B2 #***** GL_APPLE_element_array *****// -const +const GL_ELEMENT_ARRAY_APPLE* = 0x00008768 GL_ELEMENT_ARRAY_TYPE_APPLE* = 0x00008769 GL_ELEMENT_ARRAY_POINTER_APPLE* = 0x0000876A @@ -3506,52 +3506,52 @@ proc glElementPointerAPPLE*(thetype: TGLenum, pointer: PGLvoid){. dynlib: dllname, importc: "glElementPointerAPPLE".} proc glDrawElementArrayAPPLE*(mode: TGLenum, first: TGLint, count: TGLsizei){. dynlib: dllname, importc: "glDrawElementArrayAPPLE".} -proc glDrawRangeElementArrayAPPLE*(mode: TGLenum, start: TGLuint, - theend: TGLuint, first: TGLint, - count: TGLsizei){.dynlib: dllname, +proc glDrawRangeElementArrayAPPLE*(mode: TGLenum, start: TGLuint, + theend: TGLuint, first: TGLint, + count: TGLsizei){.dynlib: dllname, importc: "glDrawRangeElementArrayAPPLE".} -proc glMultiDrawElementArrayAPPLE*(mode: TGLenum, first: PGLint, +proc glMultiDrawElementArrayAPPLE*(mode: TGLenum, first: PGLint, count: PGLsizei, primcount: TGLsizei){. dynlib: dllname, importc: "glMultiDrawElementArrayAPPLE".} -proc glMultiDrawRangeElementArrayAPPLE*(mode: TGLenum, start: TGLuint, - theend: TGLuint, first: PGLint, +proc glMultiDrawRangeElementArrayAPPLE*(mode: TGLenum, start: TGLuint, + theend: TGLuint, first: PGLint, count: PGLsizei, primcount: TGLsizei){. dynlib: dllname, importc: "glMultiDrawRangeElementArrayAPPLE".} #***** GL_APPLE_fence *****// -const +const GL_DRAW_PIXELS_APPLE* = 0x00008A0A GL_FENCE_APPLE* = 0x00008A0B -proc glGenFencesAPPLE*(n: TGLsizei, fences: PGLuint){.dynlib: dllname, +proc glGenFencesAPPLE*(n: TGLsizei, fences: PGLuint){.dynlib: dllname, importc: "glGenFencesAPPLE".} -proc glDeleteFencesAPPLE*(n: TGLsizei, fences: PGLuint){.dynlib: dllname, +proc glDeleteFencesAPPLE*(n: TGLsizei, fences: PGLuint){.dynlib: dllname, importc: "glDeleteFencesAPPLE".} -proc glSetFenceAPPLE*(fence: TGLuint){.dynlib: dllname, +proc glSetFenceAPPLE*(fence: TGLuint){.dynlib: dllname, importc: "glSetFenceAPPLE".} -proc glIsFenceAPPLE*(fence: TGLuint): TGLboolean{.dynlib: dllname, +proc glIsFenceAPPLE*(fence: TGLuint): TGLboolean{.dynlib: dllname, importc: "glIsFenceAPPLE".} -proc glTestFenceAPPLE*(fence: TGLuint): TGLboolean{.dynlib: dllname, +proc glTestFenceAPPLE*(fence: TGLuint): TGLboolean{.dynlib: dllname, importc: "glTestFenceAPPLE".} -proc glFinishFenceAPPLE*(fence: TGLuint){.dynlib: dllname, +proc glFinishFenceAPPLE*(fence: TGLuint){.dynlib: dllname, importc: "glFinishFenceAPPLE".} proc glTestObjectAPPLE*(theobject: TGLenum, name: TGLuint): TGLboolean{. dynlib: dllname, importc: "glTestObjectAPPLE".} -proc glFinishObjectAPPLE*(theobject: TGLenum, name: TGLint){.dynlib: dllname, +proc glFinishObjectAPPLE*(theobject: TGLenum, name: TGLint){.dynlib: dllname, importc: "glFinishObjectAPPLE".} #***** GL_APPLE_vertex_array_object *****// -const +const GL_VERTEX_ARRAY_BINDING_APPLE* = 0x000085B5 -proc glBindVertexArrayAPPLE*(thearray: TGLuint){.dynlib: dllname, +proc glBindVertexArrayAPPLE*(thearray: TGLuint){.dynlib: dllname, importc: "glBindVertexArrayAPPLE".} -proc glDeleteVertexArraysAPPLE*(n: TGLsizei, arrays: PGLuint){.dynlib: dllname, +proc glDeleteVertexArraysAPPLE*(n: TGLsizei, arrays: PGLuint){.dynlib: dllname, importc: "glDeleteVertexArraysAPPLE".} -proc glGenVertexArraysAPPLE*(n: TGLsizei, arrays: PGLuint){.dynlib: dllname, +proc glGenVertexArraysAPPLE*(n: TGLsizei, arrays: PGLuint){.dynlib: dllname, importc: "glGenVertexArraysAPPLE".} -proc glIsVertexArrayAPPLE*(thearray: TGLuint): TGLboolean{.dynlib: dllname, +proc glIsVertexArrayAPPLE*(thearray: TGLuint): TGLboolean{.dynlib: dllname, importc: "glIsVertexArrayAPPLE".} #***** GL_APPLE_vertex_array_range *****// -const +const constGL_VERTEX_ARRAY_RANGE_APPLE* = 0x0000851D GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE* = 0x0000851E GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_APPLE* = 0x00008520 @@ -3560,14 +3560,14 @@ const GL_STORAGE_CACHED_APPLE* = 0x000085BE GL_STORAGE_SHARED_APPLE* = 0x000085BF -proc glVertexArrayRangeAPPLE*(len: TGLsizei, pointer: PGLvoid){.dynlib: dllname, +proc glVertexArrayRangeAPPLE*(len: TGLsizei, pointer: PGLvoid){.dynlib: dllname, importc: "glVertexArrayRangeAPPLE".} proc glFlushVertexArrayRangeAPPLE*(len: TGLsizei, pointer: PGLvoid){. dynlib: dllname, importc: "glFlushVertexArrayRangeAPPLE".} proc glVertexArrayParameteriAPPLE*(pname: TGLenum, param: TGLint){. dynlib: dllname, importc: "glVertexArrayParameteriAPPLE".} #***** GL_ARB_matrix_palette *****// -const +const GL_MATRIX_PALETTE_ARB* = 0x00008840 GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB* = 0x00008841 GL_MAX_PALETTE_MATRICES_ARB* = 0x00008842 @@ -3579,38 +3579,38 @@ const GL_MATRIX_INDEX_ARRAY_STRIDE_ARB* = 0x00008848 GL_MATRIX_INDEX_ARRAY_POINTER_ARB* = 0x00008849 -proc glCurrentPaletteMatrixARB*(index: TGLint){.dynlib: dllname, +proc glCurrentPaletteMatrixARB*(index: TGLint){.dynlib: dllname, importc: "glCurrentPaletteMatrixARB".} -proc glMatrixIndexubvARB*(size: TGLint, indices: PGLubyte){.dynlib: dllname, +proc glMatrixIndexubvARB*(size: TGLint, indices: PGLubyte){.dynlib: dllname, importc: "glMatrixIndexubvARB".} -proc glMatrixIndexusvARB*(size: TGLint, indices: PGLushort){.dynlib: dllname, +proc glMatrixIndexusvARB*(size: TGLint, indices: PGLushort){.dynlib: dllname, importc: "glMatrixIndexusvARB".} -proc glMatrixIndexuivARB*(size: TGLint, indices: PGLuint){.dynlib: dllname, +proc glMatrixIndexuivARB*(size: TGLint, indices: PGLuint){.dynlib: dllname, importc: "glMatrixIndexuivARB".} -proc glMatrixIndexPointerARB*(size: TGLint, thetype: TGLenum, stride: TGLsizei, - pointer: PGLvoid){.dynlib: dllname, +proc glMatrixIndexPointerARB*(size: TGLint, thetype: TGLenum, stride: TGLsizei, + pointer: PGLvoid){.dynlib: dllname, importc: "glMatrixIndexPointerARB".} #***** GL_NV_element_array *****// -const +const GL_ELEMENT_ARRAY_TYPE_NV* = 0x00008769 GL_ELEMENT_ARRAY_POINTER_NV* = 0x0000876A -proc glElementPointerNV*(thetype: TGLenum, pointer: PGLvoid){.dynlib: dllname, +proc glElementPointerNV*(thetype: TGLenum, pointer: PGLvoid){.dynlib: dllname, importc: "glElementPointerNV".} proc glDrawElementArrayNV*(mode: TGLenum, first: TGLint, count: TGLsizei){. dynlib: dllname, importc: "glDrawElementArrayNV".} -proc glDrawRangeElementArrayNV*(mode: TGLenum, start: TGLuint, theend: TGLuint, +proc glDrawRangeElementArrayNV*(mode: TGLenum, start: TGLuint, theend: TGLuint, first: TGLint, count: TGLsizei){. dynlib: dllname, importc: "glDrawRangeElementArrayNV".} -proc glMultiDrawElementArrayNV*(mode: TGLenum, first: PGLint, count: PGLsizei, - primcount: TGLsizei){.dynlib: dllname, +proc glMultiDrawElementArrayNV*(mode: TGLenum, first: PGLint, count: PGLsizei, + primcount: TGLsizei){.dynlib: dllname, importc: "glMultiDrawElementArrayNV".} -proc glMultiDrawRangeElementArrayNV*(mode: TGLenum, start: TGLuint, - theend: TGLuint, first: PGLint, +proc glMultiDrawRangeElementArrayNV*(mode: TGLenum, start: TGLuint, + theend: TGLuint, first: PGLint, count: PGLsizei, primcount: TGLsizei){. dynlib: dllname, importc: "glMultiDrawRangeElementArrayNV".} #***** GL_NV_float_buffer *****// -const +const GL_FLOAT_R_NV* = 0x00008880 GL_FLOAT_RG_NV* = 0x00008881 GL_FLOAT_RGB_NV* = 0x00008882 @@ -3628,7 +3628,7 @@ const GL_FLOAT_RGBA_MODE_NV* = 0x0000888E #***** GL_NV_fragment_program *****// -const +const GL_FRAGMENT_PROGRAM_NV* = 0x00008870 GL_MAX_TEXTURE_COORDS_NV* = 0x00008871 GL_MAX_TEXTURE_IMAGE_UNITS_NV* = 0x00008872 @@ -3636,18 +3636,18 @@ const GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV* = 0x00008868 GL_PROGRAM_ERROR_STRING_NV* = 0x00008874 -proc glProgramNamedParameter4fNV*(id: TGLuint, length: TGLsizei, name: PGLubyte, - x: TGLfloat, y: TGLfloat, z: TGLfloat, - w: TGLfloat){.dynlib: dllname, +proc glProgramNamedParameter4fNV*(id: TGLuint, length: TGLsizei, name: PGLubyte, + x: TGLfloat, y: TGLfloat, z: TGLfloat, + w: TGLfloat){.dynlib: dllname, importc: "glProgramNamedParameter4fNV".} -proc glProgramNamedParameter4dNV*(id: TGLuint, length: TGLsizei, name: PGLubyte, - x: TGLdouble, y: TGLdouble, z: TGLdouble, - w: TGLdouble){.dynlib: dllname, +proc glProgramNamedParameter4dNV*(id: TGLuint, length: TGLsizei, name: PGLubyte, + x: TGLdouble, y: TGLdouble, z: TGLdouble, + w: TGLdouble){.dynlib: dllname, importc: "glProgramNamedParameter4dNV".} -proc glGetProgramNamedParameterfvNV*(id: TGLuint, length: TGLsizei, +proc glGetProgramNamedParameterfvNV*(id: TGLuint, length: TGLsizei, name: PGLubyte, params: PGLfloat){. dynlib: dllname, importc: "glGetProgramNamedParameterfvNV".} -proc glGetProgramNamedParameterdvNV*(id: TGLuint, length: TGLsizei, +proc glGetProgramNamedParameterdvNV*(id: TGLuint, length: TGLsizei, name: PGLubyte, params: PGLdouble){. dynlib: dllname, importc: "glGetProgramNamedParameterdvNV".} # glProgramLocalParameter4dARB { already defined } @@ -3657,16 +3657,16 @@ proc glGetProgramNamedParameterdvNV*(id: TGLuint, length: TGLsizei, # glGetProgramLocalParameterdvARB { already defined } # glGetProgramLocalParameterfvARB { already defined } #***** GL_NV_primitive_restart *****// -const +const constGL_PRIMITIVE_RESTART_NV* = 0x00008558 constGL_PRIMITIVE_RESTART_INDEX_NV* = 0x00008559 proc glPrimitiveRestartNV*(){.dynlib: dllname, importc: "glPrimitiveRestartNV".} -proc glPrimitiveRestartIndexNV*(index: TGLuint){.dynlib: dllname, +proc glPrimitiveRestartIndexNV*(index: TGLuint){.dynlib: dllname, importc: "glPrimitiveRestartIndexNV".} #***** GL_NV_vertex_program2 *****// #***** GL_NV_pixel_data_range *****// -const +const GL_WRITE_PIXEL_DATA_RANGE_NV* = 0x00008878 GL_READ_PIXEL_DATA_RANGE_NV* = 0x00008879 GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV* = 0x0000887A @@ -3676,26 +3676,26 @@ const proc glPixelDataRangeNV*(target: TGLenum, len: TGLsizei, pointer: PGLvoid){. dynlib: dllname, importc: "glPixelDataRangeNV".} -proc glFlushPixelDataRangeNV*(target: TGLenum){.dynlib: dllname, +proc glFlushPixelDataRangeNV*(target: TGLenum){.dynlib: dllname, importc: "glFlushPixelDataRangeNV".} # wglAllocateMemoryNV { already defined } # wglFreeMemoryNV { already defined } #***** GL_EXT_texture_rectangle *****// -const +const GL_TEXTURE_RECTANGLE_EXT* = 0x000084F5 GL_TEXTURE_BINDING_RECTANGLE_EXT* = 0x000084F6 GL_PROXY_TEXTURE_RECTANGLE_EXT* = 0x000084F7 GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT* = 0x000084F8 #***** GL_S3_s3tc *****// -const +const GL_RGB_S3TC* = 0x000083A0 GL_RGB4_S3TC* = 0x000083A1 GL_RGBA_S3TC* = 0x000083A2 GL_RGBA4_S3TC* = 0x000083A3 #***** GL_ATI_draw_buffers *****// -const +const GL_MAX_DRAW_BUFFERS_ATI* = 0x00008824 GL_DRAW_BUFFER0_ATI* = 0x00008825 GL_DRAW_BUFFER1_ATI* = 0x00008826 @@ -3714,16 +3714,16 @@ const GL_DRAW_BUFFER14_ATI* = 0x00008833 GL_DRAW_BUFFER15_ATI* = 0x00008834 -proc glDrawBuffersATI*(n: TGLsizei, bufs: PGLenum){.dynlib: dllname, +proc glDrawBuffersATI*(n: TGLsizei, bufs: PGLenum){.dynlib: dllname, importc: "glDrawBuffersATI".} #***** GL_ATI_texture_env_combine3 *****// -const +const GL_MODULATE_ADD_ATI* = 0x00008744 GL_MODULATE_SIGNED_ADD_ATI* = 0x00008745 GL_MODULATE_SUBTRACT_ATI* = 0x00008746 #***** GL_ATI_texture_float *****// -const +const GL_RGBA_FLOAT32_ATI* = 0x00008814 GL_RGB_FLOAT32_ATI* = 0x00008815 GL_ALPHA_FLOAT32_ATI* = 0x00008816 @@ -3738,17 +3738,17 @@ const GL_LUMINANCE_ALPHA_FLOAT16_ATI* = 0x0000881F #***** GL_NV_texture_expand_normal *****// -const +const GL_TEXTURE_UNSIGNED_REMAP_MODE_NV* = 0x0000888F #***** GL_NV_half_float *****// -const +const GL_HALF_FLOAT_NV* = 0x0000140B -proc glVertex2hNV*(x: TGLushort, y: TGLushort){.dynlib: dllname, +proc glVertex2hNV*(x: TGLushort, y: TGLushort){.dynlib: dllname, importc: "glVertex2hNV".} proc glVertex2hvNV*(v: PGLushort){.dynlib: dllname, importc: "glVertex2hvNV".} -proc glVertex3hNV*(x: TGLushort, y: TGLushort, z: TGLushort){.dynlib: dllname, +proc glVertex3hNV*(x: TGLushort, y: TGLushort, z: TGLushort){.dynlib: dllname, importc: "glVertex3hNV".} proc glVertex3hvNV*(v: PGLushort){.dynlib: dllname, importc: "glVertex3hvNV".} proc glVertex4hNV*(x: TGLushort, y: TGLushort, z: TGLushort, w: TGLushort){. @@ -3760,65 +3760,65 @@ proc glNormal3hvNV*(v: PGLushort){.dynlib: dllname, importc: "glNormal3hvNV".} proc glColor3hNV*(red: TGLushort, green: TGLushort, blue: TGLushort){. dynlib: dllname, importc: "glColor3hNV".} proc glColor3hvNV*(v: PGLushort){.dynlib: dllname, importc: "glColor3hvNV".} -proc glColor4hNV*(red: TGLushort, green: TGLushort, blue: TGLushort, +proc glColor4hNV*(red: TGLushort, green: TGLushort, blue: TGLushort, alpha: TGLushort){.dynlib: dllname, importc: "glColor4hNV".} proc glColor4hvNV*(v: PGLushort){.dynlib: dllname, importc: "glColor4hvNV".} proc glTexCoord1hNV*(s: TGLushort){.dynlib: dllname, importc: "glTexCoord1hNV".} proc glTexCoord1hvNV*(v: PGLushort){.dynlib: dllname, importc: "glTexCoord1hvNV".} -proc glTexCoord2hNV*(s: TGLushort, t: TGLushort){.dynlib: dllname, +proc glTexCoord2hNV*(s: TGLushort, t: TGLushort){.dynlib: dllname, importc: "glTexCoord2hNV".} proc glTexCoord2hvNV*(v: PGLushort){.dynlib: dllname, importc: "glTexCoord2hvNV".} -proc glTexCoord3hNV*(s: TGLushort, t: TGLushort, r: TGLushort){.dynlib: dllname, +proc glTexCoord3hNV*(s: TGLushort, t: TGLushort, r: TGLushort){.dynlib: dllname, importc: "glTexCoord3hNV".} proc glTexCoord3hvNV*(v: PGLushort){.dynlib: dllname, importc: "glTexCoord3hvNV".} proc glTexCoord4hNV*(s: TGLushort, t: TGLushort, r: TGLushort, q: TGLushort){. dynlib: dllname, importc: "glTexCoord4hNV".} proc glTexCoord4hvNV*(v: PGLushort){.dynlib: dllname, importc: "glTexCoord4hvNV".} -proc glMultiTexCoord1hNV*(target: TGLenum, s: TGLushort){.dynlib: dllname, +proc glMultiTexCoord1hNV*(target: TGLenum, s: TGLushort){.dynlib: dllname, importc: "glMultiTexCoord1hNV".} -proc glMultiTexCoord1hvNV*(target: TGLenum, v: PGLushort){.dynlib: dllname, +proc glMultiTexCoord1hvNV*(target: TGLenum, v: PGLushort){.dynlib: dllname, importc: "glMultiTexCoord1hvNV".} proc glMultiTexCoord2hNV*(target: TGLenum, s: TGLushort, t: TGLushort){. dynlib: dllname, importc: "glMultiTexCoord2hNV".} -proc glMultiTexCoord2hvNV*(target: TGLenum, v: PGLushort){.dynlib: dllname, +proc glMultiTexCoord2hvNV*(target: TGLenum, v: PGLushort){.dynlib: dllname, importc: "glMultiTexCoord2hvNV".} -proc glMultiTexCoord3hNV*(target: TGLenum, s: TGLushort, t: TGLushort, - r: TGLushort){.dynlib: dllname, +proc glMultiTexCoord3hNV*(target: TGLenum, s: TGLushort, t: TGLushort, + r: TGLushort){.dynlib: dllname, importc: "glMultiTexCoord3hNV".} -proc glMultiTexCoord3hvNV*(target: TGLenum, v: PGLushort){.dynlib: dllname, +proc glMultiTexCoord3hvNV*(target: TGLenum, v: PGLushort){.dynlib: dllname, importc: "glMultiTexCoord3hvNV".} -proc glMultiTexCoord4hNV*(target: TGLenum, s: TGLushort, t: TGLushort, - r: TGLushort, q: TGLushort){.dynlib: dllname, +proc glMultiTexCoord4hNV*(target: TGLenum, s: TGLushort, t: TGLushort, + r: TGLushort, q: TGLushort){.dynlib: dllname, importc: "glMultiTexCoord4hNV".} -proc glMultiTexCoord4hvNV*(target: TGLenum, v: PGLushort){.dynlib: dllname, +proc glMultiTexCoord4hvNV*(target: TGLenum, v: PGLushort){.dynlib: dllname, importc: "glMultiTexCoord4hvNV".} proc glFogCoordhNV*(fog: TGLushort){.dynlib: dllname, importc: "glFogCoordhNV".} proc glFogCoordhvNV*(fog: PGLushort){.dynlib: dllname, importc: "glFogCoordhvNV".} proc glSecondaryColor3hNV*(red: TGLushort, green: TGLushort, blue: TGLushort){. dynlib: dllname, importc: "glSecondaryColor3hNV".} -proc glSecondaryColor3hvNV*(v: PGLushort){.dynlib: dllname, +proc glSecondaryColor3hvNV*(v: PGLushort){.dynlib: dllname, importc: "glSecondaryColor3hvNV".} -proc glVertexWeighthNV*(weight: TGLushort){.dynlib: dllname, +proc glVertexWeighthNV*(weight: TGLushort){.dynlib: dllname, importc: "glVertexWeighthNV".} -proc glVertexWeighthvNV*(weight: PGLushort){.dynlib: dllname, +proc glVertexWeighthvNV*(weight: PGLushort){.dynlib: dllname, importc: "glVertexWeighthvNV".} -proc glVertexAttrib1hNV*(index: TGLuint, x: TGLushort){.dynlib: dllname, +proc glVertexAttrib1hNV*(index: TGLuint, x: TGLushort){.dynlib: dllname, importc: "glVertexAttrib1hNV".} -proc glVertexAttrib1hvNV*(index: TGLuint, v: PGLushort){.dynlib: dllname, +proc glVertexAttrib1hvNV*(index: TGLuint, v: PGLushort){.dynlib: dllname, importc: "glVertexAttrib1hvNV".} proc glVertexAttrib2hNV*(index: TGLuint, x: TGLushort, y: TGLushort){. dynlib: dllname, importc: "glVertexAttrib2hNV".} -proc glVertexAttrib2hvNV*(index: TGLuint, v: PGLushort){.dynlib: dllname, +proc glVertexAttrib2hvNV*(index: TGLuint, v: PGLushort){.dynlib: dllname, importc: "glVertexAttrib2hvNV".} -proc glVertexAttrib3hNV*(index: TGLuint, x: TGLushort, y: TGLushort, - z: TGLushort){.dynlib: dllname, +proc glVertexAttrib3hNV*(index: TGLuint, x: TGLushort, y: TGLushort, + z: TGLushort){.dynlib: dllname, importc: "glVertexAttrib3hNV".} -proc glVertexAttrib3hvNV*(index: TGLuint, v: PGLushort){.dynlib: dllname, +proc glVertexAttrib3hvNV*(index: TGLuint, v: PGLushort){.dynlib: dllname, importc: "glVertexAttrib3hvNV".} -proc glVertexAttrib4hNV*(index: TGLuint, x: TGLushort, y: TGLushort, - z: TGLushort, w: TGLushort){.dynlib: dllname, +proc glVertexAttrib4hNV*(index: TGLuint, x: TGLushort, y: TGLushort, + z: TGLushort, w: TGLushort){.dynlib: dllname, importc: "glVertexAttrib4hNV".} -proc glVertexAttrib4hvNV*(index: TGLuint, v: PGLushort){.dynlib: dllname, +proc glVertexAttrib4hvNV*(index: TGLuint, v: PGLushort){.dynlib: dllname, importc: "glVertexAttrib4hvNV".} proc glVertexAttribs1hvNV*(index: TGLuint, n: TGLsizei, v: PGLushort){. dynlib: dllname, importc: "glVertexAttribs1hvNV".} @@ -3829,12 +3829,12 @@ proc glVertexAttribs3hvNV*(index: TGLuint, n: TGLsizei, v: PGLushort){. proc glVertexAttribs4hvNV*(index: TGLuint, n: TGLsizei, v: PGLushort){. dynlib: dllname, importc: "glVertexAttribs4hvNV".} #***** GL_ATI_map_object_buffer *****// -proc glMapObjectBufferATI*(buffer: TGLuint): PGLvoid{.dynlib: dllname, +proc glMapObjectBufferATI*(buffer: TGLuint): PGLvoid{.dynlib: dllname, importc: "glMapObjectBufferATI".} -proc glUnmapObjectBufferATI*(buffer: TGLuint){.dynlib: dllname, +proc glUnmapObjectBufferATI*(buffer: TGLuint){.dynlib: dllname, importc: "glUnmapObjectBufferATI".} #***** GL_ATI_separate_stencil *****// -const +const GL_KEEP* = 0x00001E00 GL_ZERO* = 0x00000000 GL_REPLACE* = 0x00001E01 @@ -3857,39 +3857,39 @@ const GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI* = 0x00008802 GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI* = 0x00008803 -proc glStencilOpSeparateATI*(face: TGLenum, sfail: TGLenum, dpfail: TGLenum, - dppass: TGLenum){.dynlib: dllname, +proc glStencilOpSeparateATI*(face: TGLenum, sfail: TGLenum, dpfail: TGLenum, + dppass: TGLenum){.dynlib: dllname, importc: "glStencilOpSeparateATI".} -proc glStencilFuncSeparateATI*(frontfunc: TGLenum, backfunc: TGLenum, - theRef: TGLint, mask: TGLuint){.dynlib: dllname, +proc glStencilFuncSeparateATI*(frontfunc: TGLenum, backfunc: TGLenum, + theRef: TGLint, mask: TGLuint){.dynlib: dllname, importc: "glStencilFuncSeparateATI".} #***** GL_ATI_vertex_attrib_array_object *****// -proc glVertexAttribArrayObjectATI*(index: TGLuint, size: TGLint, - thetype: TGLenum, normalized: TGLboolean, - stride: TGLsizei, buffer: TGLuint, - offset: TGLuint){.dynlib: dllname, +proc glVertexAttribArrayObjectATI*(index: TGLuint, size: TGLint, + thetype: TGLenum, normalized: TGLboolean, + stride: TGLsizei, buffer: TGLuint, + offset: TGLuint){.dynlib: dllname, importc: "glVertexAttribArrayObjectATI".} -proc glGetVertexAttribArrayObjectfvATI*(index: TGLuint, pname: TGLenum, - params: PGLfloat){.dynlib: dllname, +proc glGetVertexAttribArrayObjectfvATI*(index: TGLuint, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, importc: "glGetVertexAttribArrayObjectfvATI".} -proc glGetVertexAttribArrayObjectivATI*(index: TGLuint, pname: TGLenum, - params: PGLint){.dynlib: dllname, +proc glGetVertexAttribArrayObjectivATI*(index: TGLuint, pname: TGLenum, + params: PGLint){.dynlib: dllname, importc: "glGetVertexAttribArrayObjectivATI".} #***** GL_ARB_occlusion_query *****// -const +const GL_SAMPLES_PASSED_ARB* = 0x00008914 GL_QUERY_COUNTER_BITS_ARB* = 0x00008864 GL_CURRENT_QUERY_ARB* = 0x00008865 GL_QUERY_RESULT_ARB* = 0x00008866 GL_QUERY_RESULT_AVAILABLE_ARB* = 0x00008867 -proc glGenQueriesARB*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, +proc glGenQueriesARB*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, importc: "glGenQueriesARB".} -proc glDeleteQueriesARB*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, +proc glDeleteQueriesARB*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, importc: "glDeleteQueriesARB".} -proc glIsQueryARB*(id: TGLuint): TGLboolean{.dynlib: dllname, +proc glIsQueryARB*(id: TGLuint): TGLboolean{.dynlib: dllname, importc: "glIsQueryARB".} -proc glBeginQueryARB*(target: TGLenum, id: TGLuint){.dynlib: dllname, +proc glBeginQueryARB*(target: TGLenum, id: TGLuint){.dynlib: dllname, importc: "glBeginQueryARB".} proc glEndQueryARB*(target: TGLenum){.dynlib: dllname, importc: "glEndQueryARB".} proc glGetQueryivARB*(target: TGLenum, pname: TGLenum, params: PGLint){. @@ -3899,7 +3899,7 @@ proc glGetQueryObjectivARB*(id: TGLuint, pname: TGLenum, params: PGLint){. proc glGetQueryObjectuivARB*(id: TGLuint, pname: TGLenum, params: PGLuint){. dynlib: dllname, importc: "glGetQueryObjectuivARB".} #***** GL_ARB_shader_objects *****// -const +const GL_PROGRAM_OBJECT_ARB* = 0x00008B40 GL_OBJECT_TYPE_ARB* = 0x00008B4E GL_OBJECT_SUBTYPE_ARB* = 0x00008B4F @@ -3929,44 +3929,44 @@ const GL_FLOAT_MAT3_ARB* = 0x00008B5B GL_FLOAT_MAT4_ARB* = 0x00008B5C -proc glDeleteObjectARB*(obj: GLhandleARB){.dynlib: dllname, +proc glDeleteObjectARB*(obj: GLhandleARB){.dynlib: dllname, importc: "glDeleteObjectARB".} -proc glGetHandleARB*(pname: TGLenum): GLhandleARB{.dynlib: dllname, +proc glGetHandleARB*(pname: TGLenum): GLhandleARB{.dynlib: dllname, importc: "glGetHandleARB".} proc glDetachObjectARB*(containerObj: GLhandleARB, attachedObj: GLhandleARB){. dynlib: dllname, importc: "glDetachObjectARB".} proc glCreateShaderObjectARB*(shaderType: TGLenum): GLhandleARB{. dynlib: dllname, importc: "glCreateShaderObjectARB".} -proc glShaderSourceARB*(shaderObj: GLhandleARB, count: TGLsizei, str: PGLvoid, - len: PGLint){.dynlib: dllname, +proc glShaderSourceARB*(shaderObj: GLhandleARB, count: TGLsizei, str: PGLvoid, + len: PGLint){.dynlib: dllname, importc: "glShaderSourceARB".} -proc glCompileShaderARB*(shaderObj: GLhandleARB){.dynlib: dllname, +proc glCompileShaderARB*(shaderObj: GLhandleARB){.dynlib: dllname, importc: "glCompileShaderARB".} -proc glCreateProgramObjectARB*(): GLhandleARB{.dynlib: dllname, +proc glCreateProgramObjectARB*(): GLhandleARB{.dynlib: dllname, importc: "glCreateProgramObjectARB".} proc glAttachObjectARB*(containerObj: GLhandleARB, obj: GLhandleARB){. dynlib: dllname, importc: "glAttachObjectARB".} -proc glLinkProgramARB*(programObj: GLhandleARB){.dynlib: dllname, +proc glLinkProgramARB*(programObj: GLhandleARB){.dynlib: dllname, importc: "glLinkProgramARB".} -proc glUseProgramObjectARB*(programObj: GLhandleARB){.dynlib: dllname, +proc glUseProgramObjectARB*(programObj: GLhandleARB){.dynlib: dllname, importc: "glUseProgramObjectARB".} -proc glValidateProgramARB*(programObj: GLhandleARB){.dynlib: dllname, +proc glValidateProgramARB*(programObj: GLhandleARB){.dynlib: dllname, importc: "glValidateProgramARB".} -proc glUniform1fARB*(location: TGLint, v0: TGLfloat){.dynlib: dllname, +proc glUniform1fARB*(location: TGLint, v0: TGLfloat){.dynlib: dllname, importc: "glUniform1fARB".} proc glUniform2fARB*(location: TGLint, v0: TGLfloat, v1: TGLfloat){. dynlib: dllname, importc: "glUniform2fARB".} proc glUniform3fARB*(location: TGLint, v0: TGLfloat, v1: TGLfloat, v2: TGLfloat){. dynlib: dllname, importc: "glUniform3fARB".} -proc glUniform4fARB*(location: TGLint, v0: TGLfloat, v1: TGLfloat, v2: TGLfloat, +proc glUniform4fARB*(location: TGLint, v0: TGLfloat, v1: TGLfloat, v2: TGLfloat, v3: TGLfloat){.dynlib: dllname, importc: "glUniform4fARB".} -proc glUniform1iARB*(location: TGLint, v0: TGLint){.dynlib: dllname, +proc glUniform1iARB*(location: TGLint, v0: TGLint){.dynlib: dllname, importc: "glUniform1iARB".} -proc glUniform2iARB*(location: TGLint, v0: TGLint, v1: TGLint){.dynlib: dllname, +proc glUniform2iARB*(location: TGLint, v0: TGLint, v1: TGLint){.dynlib: dllname, importc: "glUniform2iARB".} proc glUniform3iARB*(location: TGLint, v0: TGLint, v1: TGLint, v2: TGLint){. dynlib: dllname, importc: "glUniform3iARB".} -proc glUniform4iARB*(location: TGLint, v0: TGLint, v1: TGLint, v2: TGLint, +proc glUniform4iARB*(location: TGLint, v0: TGLint, v1: TGLint, v2: TGLint, v3: TGLint){.dynlib: dllname, importc: "glUniform4iARB".} proc glUniform1fvARB*(location: TGLint, count: TGLsizei, value: PGLfloat){. dynlib: dllname, importc: "glUniform1fvARB".} @@ -3984,80 +3984,80 @@ proc glUniform3ivARB*(location: TGLint, count: TGLsizei, value: PGLint){. dynlib: dllname, importc: "glUniform3ivARB".} proc glUniform4ivARB*(location: TGLint, count: TGLsizei, value: PGLint){. dynlib: dllname, importc: "glUniform4ivARB".} -proc glUniformMatrix2fvARB*(location: TGLint, count: TGLsizei, +proc glUniformMatrix2fvARB*(location: TGLint, count: TGLsizei, transpose: TGLboolean, value: PGLfloat){. dynlib: dllname, importc: "glUniformMatrix2fvARB".} -proc glUniformMatrix3fvARB*(location: TGLint, count: TGLsizei, +proc glUniformMatrix3fvARB*(location: TGLint, count: TGLsizei, transpose: TGLboolean, value: PGLfloat){. dynlib: dllname, importc: "glUniformMatrix3fvARB".} -proc glUniformMatrix4fvARB*(location: TGLint, count: TGLsizei, +proc glUniformMatrix4fvARB*(location: TGLint, count: TGLsizei, transpose: TGLboolean, value: PGLfloat){. dynlib: dllname, importc: "glUniformMatrix4fvARB".} -proc glGetObjectParameterfvARB*(obj: GLhandleARB, pname: TGLenum, - params: PGLfloat){.dynlib: dllname, +proc glGetObjectParameterfvARB*(obj: GLhandleARB, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, importc: "glGetObjectParameterfvARB".} proc glGetObjectParameterivARB*(obj: GLhandleARB, pname: TGLenum, params: PGLint){. dynlib: dllname, importc: "glGetObjectParameterivARB".} -proc glGetInfoLogARB*(obj: GLhandleARB, maxLength: TGLsizei, len: PGLsizei, - infoLog: PGLcharARB){.dynlib: dllname, +proc glGetInfoLogARB*(obj: GLhandleARB, maxLength: TGLsizei, len: PGLsizei, + infoLog: PGLcharARB){.dynlib: dllname, importc: "glGetInfoLogARB".} -proc glGetAttachedObjectsARB*(containerObj: GLhandleARB, maxCount: TGLsizei, +proc glGetAttachedObjectsARB*(containerObj: GLhandleARB, maxCount: TGLsizei, count: PGLsizei, obj: PGLhandleARB){. dynlib: dllname, importc: "glGetAttachedObjectsARB".} proc glGetUniformLocationARB*(programObj: GLhandleARB, name: PGLcharARB): TGLint{. dynlib: dllname, importc: "glGetUniformLocationARB".} -proc glGetActiveUniformARB*(programObj: GLhandleARB, index: TGLuint, - maxLength: TGLsizei, len: PGLsizei, size: PGLint, +proc glGetActiveUniformARB*(programObj: GLhandleARB, index: TGLuint, + maxLength: TGLsizei, len: PGLsizei, size: PGLint, thetype: PGLenum, name: PGLcharARB){. dynlib: dllname, importc: "glGetActiveUniformARB".} -proc glGetUniformfvARB*(programObj: GLhandleARB, location: TGLint, - params: PGLfloat){.dynlib: dllname, +proc glGetUniformfvARB*(programObj: GLhandleARB, location: TGLint, + params: PGLfloat){.dynlib: dllname, importc: "glGetUniformfvARB".} -proc glGetUniformivARB*(programObj: GLhandleARB, location: TGLint, - params: PGLint){.dynlib: dllname, +proc glGetUniformivARB*(programObj: GLhandleARB, location: TGLint, + params: PGLint){.dynlib: dllname, importc: "glGetUniformivARB".} -proc glGetShaderSourceARB*(obj: GLhandleARB, maxLength: TGLsizei, len: PGLsizei, - source: PGLcharARB){.dynlib: dllname, +proc glGetShaderSourceARB*(obj: GLhandleARB, maxLength: TGLsizei, len: PGLsizei, + source: PGLcharARB){.dynlib: dllname, importc: "glGetShaderSourceARB".} -const +const GL_VERTEX_SHADER_ARB* = 0x00008B31 GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB* = 0x00008B4A GL_MAX_VARYING_FLOATS_ARB* = 0x00008B4B # GL_MAX_VERTEX_ATTRIBS_ARB { already defined } # GL_MAX_TEXTURE_IMAGE_UNITS_ARB { already defined } GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB* = 0x00008B4C - GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB* = 0x00008B4D # - # + GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB* = 0x00008B4D # + # # GL_MAX_TEXTURE_COORDS_ARB { already defined } - # - # + # + # # GL_VERTEX_PROGRAM_POINT_SIZE_ARB { already defined } - # - # + # + # # GL_VERTEX_PROGRAM_TWO_SIDE_ARB { already defined } # GL_OBJECT_TYPE_ARB { already defined } # GL_OBJECT_SUBTYPE_ARB { already defined } GL_OBJECT_ACTIVE_ATTRIBUTES_ARB* = 0x00008B89 GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB* = 0x00008B8A # GL_SHADER_OBJECT_ARB { already defined } - # - # + # + # # GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB { already defined } - # - # + # + # # GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB { already defined } - # - # + # + # # GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB { already defined } - # - # + # + # # GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB { already defined } - # - # + # + # # GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB { already defined } - # - # + # + # # GL_CURRENT_VERTEX_ATTRIB_ARB { already defined } - # - # + # + # # GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB { already defined } # GL_FLOAT { already defined } # GL_FLOAT_VEC2_ARB { already defined } @@ -4102,22 +4102,22 @@ const # glVertexAttrib4NubvARB { already defined } # glVertexAttrib4NusvARB { already defined } # glVertexAttrib4NuivARB { already defined } - # - # + # + # # glVertexAttribPointerARB { already defined } - # - # + # + # # glEnableVertexAttribArrayARB { already defined } - # - # + # + # # glDisableVertexAttribArrayARB { already defined } -proc glBindAttribLocationARB*(programObj: GLhandleARB, index: TGLuint, - name: PGLcharARB){.dynlib: dllname, +proc glBindAttribLocationARB*(programObj: GLhandleARB, index: TGLuint, + name: PGLcharARB){.dynlib: dllname, importc: "glBindAttribLocationARB".} -proc glGetActiveAttribARB*(programObj: GLhandleARB, index: TGLuint, - maxLength: TGLsizei, len: PGLsizei, size: PGLint, - thetype: PGLenum, name: PGLcharARB){.dynlib: dllname, +proc glGetActiveAttribARB*(programObj: GLhandleARB, index: TGLuint, + maxLength: TGLsizei, len: PGLsizei, size: PGLint, + thetype: PGLenum, name: PGLcharARB){.dynlib: dllname, importc: "glGetActiveAttribARB".} proc glGetAttribLocationARB*(programObj: GLhandleARB, name: PGLcharARB): TGLint{. dynlib: dllname, importc: "glGetAttribLocationARB".} @@ -4126,11 +4126,11 @@ proc glGetAttribLocationARB*(programObj: GLhandleARB, name: PGLcharARB): TGLint{ # glGetVertexAttribivARB { already defined } # glGetVertexAttribPointervARB { already defined } #***** GL_ARB_fragment_shader *****// -const +const GL_FRAGMENT_SHADER_ARB* = 0x00008B30 GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB* = 0x00008B49 # GL_MAX_TEXTURE_COORDS_ARB { already defined } - # - # + # + # # GL_MAX_TEXTURE_IMAGE_UNITS_ARB { already defined } # GL_OBJECT_TYPE_ARB { already defined } # GL_OBJECT_SUBTYPE_ARB { already defined } @@ -4139,36 +4139,36 @@ const #***** GL_ARB_texture_non_power_of_two *****// #***** GL_ARB_point_sprite *****// -const +const GL_POINT_SPRITE_ARB* = 0x00008861 GL_COORD_REPLACE_ARB* = 0x00008862 #***** GL_EXT_depth_bounds_test *****// -const +const constGL_DEPTH_BOUNDS_TEST_EXT* = 0x00008890 constGL_DEPTH_BOUNDS_EXT* = 0x00008891 -proc glDepthBoundsEXT*(zmin: TGLclampd, zmax: TGLclampd){.dynlib: dllname, +proc glDepthBoundsEXT*(zmin: TGLclampd, zmax: TGLclampd){.dynlib: dllname, importc: "glDepthBoundsEXT".} #***** GL_EXT_texture_mirror_clamp *****// -const +const GL_MIRROR_CLAMP_EXT* = 0x00008742 GL_MIRROR_CLAMP_TO_EDGE_EXT* = 0x00008743 GL_MIRROR_CLAMP_TO_BORDER_EXT* = 0x00008912 #***** GL_EXT_blend_equation_separate *****// -const +const GL_BLEND_EQUATION_RGB_EXT* = 0x00008009 GL_BLEND_EQUATION_ALPHA_EXT* = 0x0000883D proc glBlendEquationSeparateEXT*(modeRGB: TGLenum, modeAlpha: TGLenum){. dynlib: dllname, importc: "glBlendEquationSeparateEXT".} #***** GL_MESA_pack_invert *****// -const +const GL_PACK_INVERT_MESA* = 0x00008758 #***** GL_MESA_ycbcr_texture *****// -const +const GL_YCBCR_MESA* = 0x00008757 GL_UNSIGNED_SHORT_8_8_MESA* = 0x000085BA GL_UNSIGNED_SHORT_8_8_REV_MESA* = 0x000085BB @@ -4176,14 +4176,14 @@ const #***** GL_NV_fragment_program_option *****// #***** GL_EXT_pixel_buffer_object *****// -const +const GL_PIXEL_PACK_BUFFER_EXT* = 0x000088EB GL_PIXEL_UNPACK_BUFFER_EXT* = 0x000088EC GL_PIXEL_PACK_BUFFER_BINDING_EXT* = 0x000088ED GL_PIXEL_UNPACK_BUFFER_BINDING_EXT* = 0x000088EF #***** GL_NV_fragment_program2 *****// -const +const GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV* = 0x000088F4 GL_MAX_PROGRAM_CALL_DEPTH_NV* = 0x000088F5 GL_MAX_PROGRAM_IF_DEPTH_NV* = 0x000088F6 @@ -4196,7 +4196,7 @@ const # GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB { already defined } #***** GL_ARB_draw_buffers *****// -const +const GL_MAX_DRAW_BUFFERS_ARB* = 0x00008824 GL_DRAW_BUFFER0_ARB* = 0x00008825 GL_DRAW_BUFFER1_ARB* = 0x00008826 @@ -4215,17 +4215,17 @@ const GL_DRAW_BUFFER14_ARB* = 0x00008833 GL_DRAW_BUFFER15_ARB* = 0x00008834 -proc glDrawBuffersARB*(n: TGLsizei, bufs: PGLenum){.dynlib: dllname, +proc glDrawBuffersARB*(n: TGLsizei, bufs: PGLenum){.dynlib: dllname, importc: "glDrawBuffersARB".} #***** GL_ARB_texture_rectangle *****// -const +const GL_TEXTURE_RECTANGLE_ARB* = 0x000084F5 GL_TEXTURE_BINDING_RECTANGLE_ARB* = 0x000084F6 GL_PROXY_TEXTURE_RECTANGLE_ARB* = 0x000084F7 GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB* = 0x000084F8 #***** GL_ARB_color_buffer_float *****// -const +const GL_RGBA_FLOAT_MODE_ARB* = 0x00008820 GL_CLAMP_VERTEX_COLOR_ARB* = 0x0000891A GL_CLAMP_FRAGMENT_COLOR_ARB* = 0x0000891B @@ -4233,14 +4233,14 @@ const GL_FIXED_ONLY_ARB* = 0x0000891D WGL_TYPE_RGBA_FLOAT_ARB* = 0x000021A0 -proc glClampColorARB*(target: TGLenum, clamp: TGLenum){.dynlib: dllname, +proc glClampColorARB*(target: TGLenum, clamp: TGLenum){.dynlib: dllname, importc: "glClampColorARB".} #***** GL_ARB_half_float_pixel *****// -const +const GL_HALF_FLOAT_ARB* = 0x0000140B #***** GL_ARB_texture_float *****// -const +const GL_TEXTURE_RED_TYPE_ARB* = 0x00008C10 GL_TEXTURE_GREEN_TYPE_ARB* = 0x00008C11 GL_TEXTURE_BLUE_TYPE_ARB* = 0x00008C12 @@ -4266,14 +4266,14 @@ const # GL_COMPRESSED_RGBA_S3TC_DXT1_EXT { already defined } #***** GL_ARB_pixel_buffer_object *****// -const +const GL_PIXEL_PACK_BUFFER_ARB* = 0x000088EB GL_PIXEL_UNPACK_BUFFER_ARB* = 0x000088EC GL_PIXEL_PACK_BUFFER_BINDING_ARB* = 0x000088ED GL_PIXEL_UNPACK_BUFFER_BINDING_ARB* = 0x000088EF #***** GL_EXT_framebuffer_object *****// -const +const GL_FRAMEBUFFER_EXT* = 0x00008D40 GL_RENDERBUFFER_EXT* = 0x00008D41 GL_STENCIL_INDEX_EXT* = 0x00008D45 @@ -4323,7 +4323,7 @@ const GL_MAX_RENDERBUFFER_SIZE_EXT* = 0x000084E8 GL_INVALID_FRAMEBUFFER_OPERATION_EXT* = 0x00000506 -proc glIsRenderbufferEXT*(renderbuffer: TGLuint): TGLboolean{.dynlib: dllname, +proc glIsRenderbufferEXT*(renderbuffer: TGLuint): TGLboolean{.dynlib: dllname, importc: "glIsRenderbufferEXT".} proc glBindRenderbufferEXT*(target: TGLenum, renderbuffer: TGLuint){. dynlib: dllname, importc: "glBindRenderbufferEXT".} @@ -4331,45 +4331,45 @@ proc glDeleteRenderbuffersEXT*(n: TGLsizei, renderbuffers: PGLuint){. dynlib: dllname, importc: "glDeleteRenderbuffersEXT".} proc glGenRenderbuffersEXT*(n: TGLsizei, renderbuffers: PGLuint){. dynlib: dllname, importc: "glGenRenderbuffersEXT".} -proc glRenderbufferStorageEXT*(target: TGLenum, internalformat: TGLenum, +proc glRenderbufferStorageEXT*(target: TGLenum, internalformat: TGLenum, width: TGLsizei, height: TGLsizei){. dynlib: dllname, importc: "glRenderbufferStorageEXT".} -proc glGetRenderbufferParameterivEXT*(target: TGLenum, pname: TGLenum, - params: PGLint){.dynlib: dllname, +proc glGetRenderbufferParameterivEXT*(target: TGLenum, pname: TGLenum, + params: PGLint){.dynlib: dllname, importc: "glGetRenderbufferParameterivEXT".} -proc glIsFramebufferEXT*(framebuffer: TGLuint): TGLboolean{.dynlib: dllname, +proc glIsFramebufferEXT*(framebuffer: TGLuint): TGLboolean{.dynlib: dllname, importc: "glIsFramebufferEXT".} proc glBindFramebufferEXT*(target: TGLenum, framebuffer: TGLuint){. dynlib: dllname, importc: "glBindFramebufferEXT".} proc glDeleteFramebuffersEXT*(n: TGLsizei, framebuffers: PGLuint){. dynlib: dllname, importc: "glDeleteFramebuffersEXT".} -proc glGenFramebuffersEXT*(n: TGLsizei, framebuffers: PGLuint){.dynlib: dllname, +proc glGenFramebuffersEXT*(n: TGLsizei, framebuffers: PGLuint){.dynlib: dllname, importc: "glGenFramebuffersEXT".} -proc glCheckFramebufferStatusEXT*(target: TGLenum): TGLenum{.dynlib: dllname, +proc glCheckFramebufferStatusEXT*(target: TGLenum): TGLenum{.dynlib: dllname, importc: "glCheckFramebufferStatusEXT".} -proc glFramebufferTexture1DEXT*(target: TGLenum, attachment: TGLenum, - textarget: TGLenum, texture: TGLuint, - level: TGLint){.dynlib: dllname, +proc glFramebufferTexture1DEXT*(target: TGLenum, attachment: TGLenum, + textarget: TGLenum, texture: TGLuint, + level: TGLint){.dynlib: dllname, importc: "glFramebufferTexture1DEXT".} -proc glFramebufferTexture2DEXT*(target: TGLenum, attachment: TGLenum, - textarget: TGLenum, texture: TGLuint, - level: TGLint){.dynlib: dllname, +proc glFramebufferTexture2DEXT*(target: TGLenum, attachment: TGLenum, + textarget: TGLenum, texture: TGLuint, + level: TGLint){.dynlib: dllname, importc: "glFramebufferTexture2DEXT".} -proc glFramebufferTexture3DEXT*(target: TGLenum, attachment: TGLenum, - textarget: TGLenum, texture: TGLuint, +proc glFramebufferTexture3DEXT*(target: TGLenum, attachment: TGLenum, + textarget: TGLenum, texture: TGLuint, level: TGLint, zoffset: TGLint){. dynlib: dllname, importc: "glFramebufferTexture3DEXT".} -proc glFramebufferRenderbufferEXT*(target: TGLenum, attachment: TGLenum, - renderbuffertarget: TGLenum, - renderbuffer: TGLuint){.dynlib: dllname, +proc glFramebufferRenderbufferEXT*(target: TGLenum, attachment: TGLenum, + renderbuffertarget: TGLenum, + renderbuffer: TGLuint){.dynlib: dllname, importc: "glFramebufferRenderbufferEXT".} -proc glGetFramebufferAttachmentParameterivEXT*(target: TGLenum, - attachment: TGLenum, pname: TGLenum, params: PGLint){.dynlib: dllname, +proc glGetFramebufferAttachmentParameterivEXT*(target: TGLenum, + attachment: TGLenum, pname: TGLenum, params: PGLint){.dynlib: dllname, importc: "glGetFramebufferAttachmentParameterivEXT".} -proc glGenerateMipmapEXT*(target: TGLenum){.dynlib: dllname, +proc glGenerateMipmapEXT*(target: TGLenum){.dynlib: dllname, importc: "glGenerateMipmapEXT".} #***** GL_version_1_4 *****// -const +const GL_BLEND_DST_RGB* = 0x000080C8 GL_BLEND_SRC_RGB* = 0x000080C9 GL_BLEND_DST_ALPHA* = 0x000080CA @@ -4410,7 +4410,7 @@ const GL_TEXTURE_COMPARE_FUNC* = 0x0000884D GL_COMPARE_R_TO_TEXTURE* = 0x0000884E -proc glBlendFuncSeparate*(sfactorRGB: TGLenum, dfactorRGB: TGLenum, +proc glBlendFuncSeparate*(sfactorRGB: TGLenum, dfactorRGB: TGLenum, sfactorAlpha: TGLenum, dfactorAlpha: TGLenum){. dynlib: dllname, importc: "glBlendFuncSeparate".} proc glFogCoordf*(coord: TGLfloat){.dynlib: dllname, importc: "glFogCoordf".} @@ -4419,81 +4419,81 @@ proc glFogCoordd*(coord: TGLdouble){.dynlib: dllname, importc: "glFogCoordd".} proc glFogCoorddv*(coord: PGLdouble){.dynlib: dllname, importc: "glFogCoorddv".} proc glFogCoordPointer*(thetype: TGLenum, stride: TGLsizei, pointer: PGLvoid){. dynlib: dllname, importc: "glFogCoordPointer".} -proc glMultiDrawArrays*(mode: TGLenum, first: PGLint, count: PGLsizei, - primcount: TGLsizei){.dynlib: dllname, +proc glMultiDrawArrays*(mode: TGLenum, first: PGLint, count: PGLsizei, + primcount: TGLsizei){.dynlib: dllname, importc: "glMultiDrawArrays".} -proc glMultiDrawElements*(mode: TGLenum, count: PGLsizei, thetype: TGLenum, +proc glMultiDrawElements*(mode: TGLenum, count: PGLsizei, thetype: TGLenum, indices: PGLvoid, primcount: TGLsizei){. dynlib: dllname, importc: "glMultiDrawElements".} -proc glPointParameterf*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, +proc glPointParameterf*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, importc: "glPointParameterf".} -proc glPointParameterfv*(pname: TGLenum, params: PGLfloat){.dynlib: dllname, +proc glPointParameterfv*(pname: TGLenum, params: PGLfloat){.dynlib: dllname, importc: "glPointParameterfv".} -proc glPointParameteri*(pname: TGLenum, param: TGLint){.dynlib: dllname, +proc glPointParameteri*(pname: TGLenum, param: TGLint){.dynlib: dllname, importc: "glPointParameteri".} -proc glPointParameteriv*(pname: TGLenum, params: PGLint){.dynlib: dllname, +proc glPointParameteriv*(pname: TGLenum, params: PGLint){.dynlib: dllname, importc: "glPointParameteriv".} proc glSecondaryColor3b*(red: TGLByte, green: TGLByte, blue: TGLByte){. dynlib: dllname, importc: "glSecondaryColor3b".} -proc glSecondaryColor3bv*(v: PGLbyte){.dynlib: dllname, +proc glSecondaryColor3bv*(v: PGLbyte){.dynlib: dllname, importc: "glSecondaryColor3bv".} proc glSecondaryColor3d*(red: TGLdouble, green: TGLdouble, blue: TGLdouble){. dynlib: dllname, importc: "glSecondaryColor3d".} -proc glSecondaryColor3dv*(v: PGLdouble){.dynlib: dllname, +proc glSecondaryColor3dv*(v: PGLdouble){.dynlib: dllname, importc: "glSecondaryColor3dv".} proc glSecondaryColor3f*(red: TGLfloat, green: TGLfloat, blue: TGLfloat){. dynlib: dllname, importc: "glSecondaryColor3f".} -proc glSecondaryColor3fv*(v: PGLfloat){.dynlib: dllname, +proc glSecondaryColor3fv*(v: PGLfloat){.dynlib: dllname, importc: "glSecondaryColor3fv".} proc glSecondaryColor3i*(red: TGLint, green: TGLint, blue: TGLint){. dynlib: dllname, importc: "glSecondaryColor3i".} -proc glSecondaryColor3iv*(v: PGLint){.dynlib: dllname, +proc glSecondaryColor3iv*(v: PGLint){.dynlib: dllname, importc: "glSecondaryColor3iv".} proc glSecondaryColor3s*(red: TGLshort, green: TGLshort, blue: TGLshort){. dynlib: dllname, importc: "glSecondaryColor3s".} -proc glSecondaryColor3sv*(v: PGLshort){.dynlib: dllname, +proc glSecondaryColor3sv*(v: PGLshort){.dynlib: dllname, importc: "glSecondaryColor3sv".} proc glSecondaryColor3ub*(red: TGLubyte, green: TGLubyte, blue: TGLubyte){. dynlib: dllname, importc: "glSecondaryColor3ub".} -proc glSecondaryColor3ubv*(v: PGLubyte){.dynlib: dllname, +proc glSecondaryColor3ubv*(v: PGLubyte){.dynlib: dllname, importc: "glSecondaryColor3ubv".} proc glSecondaryColor3ui*(red: TGLuint, green: TGLuint, blue: TGLuint){. dynlib: dllname, importc: "glSecondaryColor3ui".} -proc glSecondaryColor3uiv*(v: PGLuint){.dynlib: dllname, +proc glSecondaryColor3uiv*(v: PGLuint){.dynlib: dllname, importc: "glSecondaryColor3uiv".} proc glSecondaryColor3us*(red: TGLushort, green: TGLushort, blue: TGLushort){. dynlib: dllname, importc: "glSecondaryColor3us".} -proc glSecondaryColor3usv*(v: PGLushort){.dynlib: dllname, +proc glSecondaryColor3usv*(v: PGLushort){.dynlib: dllname, importc: "glSecondaryColor3usv".} -proc glSecondaryColorPointer*(size: TGLint, thetype: TGLenum, stride: TGLsizei, - pointer: PGLvoid){.dynlib: dllname, +proc glSecondaryColorPointer*(size: TGLint, thetype: TGLenum, stride: TGLsizei, + pointer: PGLvoid){.dynlib: dllname, importc: "glSecondaryColorPointer".} -proc glWindowPos2d*(x: TGLdouble, y: TGLdouble){.dynlib: dllname, +proc glWindowPos2d*(x: TGLdouble, y: TGLdouble){.dynlib: dllname, importc: "glWindowPos2d".} proc glWindowPos2dv*(v: PGLdouble){.dynlib: dllname, importc: "glWindowPos2dv".} -proc glWindowPos2f*(x: TGLfloat, y: TGLfloat){.dynlib: dllname, +proc glWindowPos2f*(x: TGLfloat, y: TGLfloat){.dynlib: dllname, importc: "glWindowPos2f".} proc glWindowPos2fv*(v: PGLfloat){.dynlib: dllname, importc: "glWindowPos2fv".} -proc glWindowPos2i*(x: TGLint, y: TGLint){.dynlib: dllname, +proc glWindowPos2i*(x: TGLint, y: TGLint){.dynlib: dllname, importc: "glWindowPos2i".} proc glWindowPos2iv*(v: PGLint){.dynlib: dllname, importc: "glWindowPos2iv".} -proc glWindowPos2s*(x: TGLshort, y: TGLshort){.dynlib: dllname, +proc glWindowPos2s*(x: TGLshort, y: TGLshort){.dynlib: dllname, importc: "glWindowPos2s".} proc glWindowPos2sv*(v: PGLshort){.dynlib: dllname, importc: "glWindowPos2sv".} -proc glWindowPos3d*(x: TGLdouble, y: TGLdouble, z: TGLdouble){.dynlib: dllname, +proc glWindowPos3d*(x: TGLdouble, y: TGLdouble, z: TGLdouble){.dynlib: dllname, importc: "glWindowPos3d".} proc glWindowPos3dv*(v: PGLdouble){.dynlib: dllname, importc: "glWindowPos3dv".} -proc glWindowPos3f*(x: TGLfloat, y: TGLfloat, z: TGLfloat){.dynlib: dllname, +proc glWindowPos3f*(x: TGLfloat, y: TGLfloat, z: TGLfloat){.dynlib: dllname, importc: "glWindowPos3f".} proc glWindowPos3fv*(v: PGLfloat){.dynlib: dllname, importc: "glWindowPos3fv".} -proc glWindowPos3i*(x: TGLint, y: TGLint, z: TGLint){.dynlib: dllname, +proc glWindowPos3i*(x: TGLint, y: TGLint, z: TGLint){.dynlib: dllname, importc: "glWindowPos3i".} proc glWindowPos3iv*(v: PGLint){.dynlib: dllname, importc: "glWindowPos3iv".} -proc glWindowPos3s*(x: TGLshort, y: TGLshort, z: TGLshort){.dynlib: dllname, +proc glWindowPos3s*(x: TGLshort, y: TGLshort, z: TGLshort){.dynlib: dllname, importc: "glWindowPos3s".} proc glWindowPos3sv*(v: PGLshort){.dynlib: dllname, importc: "glWindowPos3sv".} #***** GL_version_1_5 *****// -const +const GL_BUFFER_SIZE* = 0x00008764 GL_BUFFER_USAGE* = 0x00008765 GL_QUERY_COUNTER_BITS* = 0x00008864 @@ -4545,12 +4545,12 @@ const GL_SRC1_ALPHA* = 0x00008589 GL_SRC2_ALPHA* = 0x0000858A -proc glGenQueries*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, +proc glGenQueries*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, importc: "glGenQueries".} -proc glDeleteQueries*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, +proc glDeleteQueries*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, importc: "glDeleteQueries".} proc glIsQuery*(id: TGLuint): TGLboolean{.dynlib: dllname, importc: "glIsQuery".} -proc glBeginQuery*(target: TGLenum, id: TGLuint){.dynlib: dllname, +proc glBeginQuery*(target: TGLenum, id: TGLuint){.dynlib: dllname, importc: "glBeginQuery".} proc glEndQuery*(target: TGLenum){.dynlib: dllname, importc: "glEndQuery".} proc glGetQueryiv*(target: TGLenum, pname: TGLenum, params: PGLint){. @@ -4559,32 +4559,32 @@ proc glGetQueryObjectiv*(id: TGLuint, pname: TGLenum, params: PGLint){. dynlib: dllname, importc: "glGetQueryObjectiv".} proc glGetQueryObjectuiv*(id: TGLuint, pname: TGLenum, params: PGLuint){. dynlib: dllname, importc: "glGetQueryObjectuiv".} -proc glBindBuffer*(target: TGLenum, buffer: TGLuint){.dynlib: dllname, +proc glBindBuffer*(target: TGLenum, buffer: TGLuint){.dynlib: dllname, importc: "glBindBuffer".} -proc glDeleteBuffers*(n: TGLsizei, buffers: PGLuint){.dynlib: dllname, +proc glDeleteBuffers*(n: TGLsizei, buffers: PGLuint){.dynlib: dllname, importc: "glDeleteBuffers".} -proc glGenBuffers*(n: TGLsizei, buffers: PGLuint){.dynlib: dllname, +proc glGenBuffers*(n: TGLsizei, buffers: PGLuint){.dynlib: dllname, importc: "glGenBuffers".} -proc glIsBuffer*(buffer: TGLuint): TGLboolean{.dynlib: dllname, +proc glIsBuffer*(buffer: TGLuint): TGLboolean{.dynlib: dllname, importc: "glIsBuffer".} -proc glBufferData*(target: TGLenum, size: GLsizeiptr, data: PGLvoid, +proc glBufferData*(target: TGLenum, size: GLsizeiptr, data: PGLvoid, usage: TGLenum){.dynlib: dllname, importc: "glBufferData".} -proc glBufferSubData*(target: TGLenum, offset: GLintptr, size: GLsizeiptr, - data: PGLvoid){.dynlib: dllname, +proc glBufferSubData*(target: TGLenum, offset: GLintptr, size: GLsizeiptr, + data: PGLvoid){.dynlib: dllname, importc: "glBufferSubData".} -proc glGetBufferSubData*(target: TGLenum, offset: GLintptr, size: GLsizeiptr, - data: PGLvoid){.dynlib: dllname, +proc glGetBufferSubData*(target: TGLenum, offset: GLintptr, size: GLsizeiptr, + data: PGLvoid){.dynlib: dllname, importc: "glGetBufferSubData".} -proc glMapBuffer*(target: TGLenum, access: TGLenum): PGLvoid{.dynlib: dllname, +proc glMapBuffer*(target: TGLenum, access: TGLenum): PGLvoid{.dynlib: dllname, importc: "glMapBuffer".} -proc glUnmapBuffer*(target: TGLenum): TGLboolean{.dynlib: dllname, +proc glUnmapBuffer*(target: TGLenum): TGLboolean{.dynlib: dllname, importc: "glUnmapBuffer".} proc glGetBufferParameteriv*(target: TGLenum, pname: TGLenum, params: PGLint){. dynlib: dllname, importc: "glGetBufferParameteriv".} proc glGetBufferPointerv*(target: TGLenum, pname: TGLenum, params: PGLvoid){. dynlib: dllname, importc: "glGetBufferPointerv".} #***** GL_version_2_0 *****// -const +const GL_BLEND_EQUATION_RGB* = 0x00008009 GL_VERTEX_ATTRIB_ARRAY_ENABLED* = 0x00008622 GL_VERTEX_ATTRIB_ARRAY_SIZE* = 0x00008623 @@ -4670,4 +4670,4 @@ const GL_STENCIL_BACK_VALUE_MASK* = 0x00008CA4 GL_STENCIL_BACK_WRITEMASK* = 0x00008CA5 -{.pop.} \ No newline at end of file +{.pop.} diff --git a/tests/manyloc/keineschweine/lib/glu.nim b/tests/manyloc/keineschweine/lib/glu.nim index e00120d83b..867d0e47f0 100644 --- a/tests/manyloc/keineschweine/lib/glu.nim +++ b/tests/manyloc/keineschweine/lib/glu.nim @@ -4,28 +4,28 @@ # Sebastian Guenther (sg@freepascal.org) in 2002 # These units are free to use #****************************************************************************** -# Converted to Delphi by Tom Nuydens (tom@delphi3d.net) -# For the latest updates, visit Delphi3D: http://www.delphi3d.net +# Converted to Delphi by Tom Nuydens (tom@delphi3d.net) +# For the latest updates, visit Delphi3D: http://www.delphi3d.net #****************************************************************************** -import +import GL -when defined(windows): +when defined(windows): {.push, callconv: stdcall.} -else: +else: {.push, callconv: cdecl.} -when defined(windows): - const +when defined(windows): + const dllname = "glu32.dll" -elif defined(macosx): - const +elif defined(macosx): + const dllname = "/System/Library/Frameworks/OpenGL.framework/Libraries/libGLU.dylib" -else: - const +else: + const dllname = "libGLU.so.1" -type +type TViewPortArray* = array[0..3, TGLint] T16dArray* = array[0..15, TGLdouble] TCallBack* = proc () @@ -34,12 +34,12 @@ type T4fArray* = array[0..3, TGLfloat] PPointer* = ptr Pointer -type - GLUnurbs*{.final.} = object +type + GLUnurbs*{.final.} = object PGLUnurbs* = ptr GLUnurbs - GLUquadric*{.final.} = object + GLUquadric*{.final.} = object PGLUquadric* = ptr GLUquadric - GLUtesselator*{.final.} = object + GLUtesselator*{.final.} = object PGLUtesselator* = ptr GLUtesselator # backwards compatibility: GLUnurbsObj* = GLUnurbs PGLUnurbsObj* = PGLUnurbs @@ -57,40 +57,40 @@ type TGLUtesselatorObj* = GLUtesselatorObj TGLUtriangulatorObj* = GLUtriangulatorObj -proc gluErrorString*(errCode: TGLenum): cstring{.dynlib: dllname, +proc gluErrorString*(errCode: TGLenum): cstring{.dynlib: dllname, importc: "gluErrorString".} -proc gluErrorUnicodeStringEXT*(errCode: TGLenum): ptr int16{.dynlib: dllname, +proc gluErrorUnicodeStringEXT*(errCode: TGLenum): ptr int16{.dynlib: dllname, importc: "gluErrorUnicodeStringEXT".} -proc gluGetString*(name: TGLenum): cstring{.dynlib: dllname, +proc gluGetString*(name: TGLenum): cstring{.dynlib: dllname, importc: "gluGetString".} -proc gluOrtho2D*(left, right, bottom, top: TGLdouble){.dynlib: dllname, +proc gluOrtho2D*(left, right, bottom, top: TGLdouble){.dynlib: dllname, importc: "gluOrtho2D".} -proc gluPerspective*(fovy, aspect, zNear, zFar: TGLdouble){.dynlib: dllname, +proc gluPerspective*(fovy, aspect, zNear, zFar: TGLdouble){.dynlib: dllname, importc: "gluPerspective".} proc gluPickMatrix*(x, y, width, height: TGLdouble, viewport: var TViewPortArray){. dynlib: dllname, importc: "gluPickMatrix".} proc gluLookAt*(eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz: TGLdouble){. dynlib: dllname, importc: "gluLookAt".} -proc gluProject*(objx, objy, objz: TGLdouble, - modelMatrix, projMatrix: var T16dArray, +proc gluProject*(objx, objy, objz: TGLdouble, + modelMatrix, projMatrix: var T16dArray, viewport: var TViewPortArray, winx, winy, winz: PGLdouble): int{. dynlib: dllname, importc: "gluProject".} -proc gluUnProject*(winx, winy, winz: TGLdouble, - modelMatrix, projMatrix: var T16dArray, +proc gluUnProject*(winx, winy, winz: TGLdouble, + modelMatrix, projMatrix: var T16dArray, viewport: var TViewPortArray, objx, objy, objz: PGLdouble): int{. dynlib: dllname, importc: "gluUnProject".} -proc gluScaleImage*(format: TGLenum, widthin, heightin: TGLint, typein: TGLenum, - datain: Pointer, widthout, heightout: TGLint, - typeout: TGLenum, dataout: Pointer): int{.dynlib: dllname, +proc gluScaleImage*(format: TGLenum, widthin, heightin: TGLint, typein: TGLenum, + datain: Pointer, widthout, heightout: TGLint, + typeout: TGLenum, dataout: Pointer): int{.dynlib: dllname, importc: "gluScaleImage".} -proc gluBuild1DMipmaps*(target: TGLenum, components, width: TGLint, +proc gluBuild1DMipmaps*(target: TGLenum, components, width: TGLint, format, atype: TGLenum, data: Pointer): int{. dynlib: dllname, importc: "gluBuild1DMipmaps".} -proc gluBuild2DMipmaps*(target: TGLenum, components, width, height: TGLint, +proc gluBuild2DMipmaps*(target: TGLenum, components, width, height: TGLint, format, atype: TGLenum, data: Pointer): int{. dynlib: dllname, importc: "gluBuild2DMipmaps".} proc gluNewQuadric*(): PGLUquadric{.dynlib: dllname, importc: "gluNewQuadric".} -proc gluDeleteQuadric*(state: PGLUquadric){.dynlib: dllname, +proc gluDeleteQuadric*(state: PGLUquadric){.dynlib: dllname, importc: "gluDeleteQuadric".} proc gluQuadricNormals*(quadObject: PGLUquadric, normals: TGLenum){. dynlib: dllname, importc: "gluQuadricNormals".} @@ -100,12 +100,12 @@ proc gluQuadricOrientation*(quadObject: PGLUquadric, orientation: TGLenum){. dynlib: dllname, importc: "gluQuadricOrientation".} proc gluQuadricDrawStyle*(quadObject: PGLUquadric, drawStyle: TGLenum){. dynlib: dllname, importc: "gluQuadricDrawStyle".} -proc gluCylinder*(qobj: PGLUquadric, baseRadius, topRadius, height: TGLdouble, - slices, stacks: TGLint){.dynlib: dllname, +proc gluCylinder*(qobj: PGLUquadric, baseRadius, topRadius, height: TGLdouble, + slices, stacks: TGLint){.dynlib: dllname, importc: "gluCylinder".} -proc gluDisk*(qobj: PGLUquadric, innerRadius, outerRadius: TGLdouble, +proc gluDisk*(qobj: PGLUquadric, innerRadius, outerRadius: TGLdouble, slices, loops: TGLint){.dynlib: dllname, importc: "gluDisk".} -proc gluPartialDisk*(qobj: PGLUquadric, innerRadius, outerRadius: TGLdouble, +proc gluPartialDisk*(qobj: PGLUquadric, innerRadius, outerRadius: TGLdouble, slices, loops: TGLint, startAngle, sweepAngle: TGLdouble){. dynlib: dllname, importc: "gluPartialDisk".} proc gluSphere*(qobj: PGLuquadric, radius: TGLdouble, slices, stacks: TGLint){. @@ -113,51 +113,51 @@ proc gluSphere*(qobj: PGLuquadric, radius: TGLdouble, slices, stacks: TGLint){. proc gluQuadricCallback*(qobj: PGLUquadric, which: TGLenum, fn: TCallBack){. dynlib: dllname, importc: "gluQuadricCallback".} proc gluNewTess*(): PGLUtesselator{.dynlib: dllname, importc: "gluNewTess".} -proc gluDeleteTess*(tess: PGLUtesselator){.dynlib: dllname, +proc gluDeleteTess*(tess: PGLUtesselator){.dynlib: dllname, importc: "gluDeleteTess".} proc gluTessBeginPolygon*(tess: PGLUtesselator, polygon_data: Pointer){. dynlib: dllname, importc: "gluTessBeginPolygon".} -proc gluTessBeginContour*(tess: PGLUtesselator){.dynlib: dllname, +proc gluTessBeginContour*(tess: PGLUtesselator){.dynlib: dllname, importc: "gluTessBeginContour".} proc gluTessVertex*(tess: PGLUtesselator, coords: var T3dArray, data: Pointer){. dynlib: dllname, importc: "gluTessVertex".} -proc gluTessEndContour*(tess: PGLUtesselator){.dynlib: dllname, +proc gluTessEndContour*(tess: PGLUtesselator){.dynlib: dllname, importc: "gluTessEndContour".} -proc gluTessEndPolygon*(tess: PGLUtesselator){.dynlib: dllname, +proc gluTessEndPolygon*(tess: PGLUtesselator){.dynlib: dllname, importc: "gluTessEndPolygon".} proc gluTessProperty*(tess: PGLUtesselator, which: TGLenum, value: TGLdouble){. dynlib: dllname, importc: "gluTessProperty".} -proc gluTessNormal*(tess: PGLUtesselator, x, y, z: TGLdouble){.dynlib: dllname, +proc gluTessNormal*(tess: PGLUtesselator, x, y, z: TGLdouble){.dynlib: dllname, importc: "gluTessNormal".} proc gluTessCallback*(tess: PGLUtesselator, which: TGLenum, fn: TCallBack){. dynlib: dllname, importc: "gluTessCallback".} proc gluGetTessProperty*(tess: PGLUtesselator, which: TGLenum, value: PGLdouble){. dynlib: dllname, importc: "gluGetTessProperty".} -proc gluNewNurbsRenderer*(): PGLUnurbs{.dynlib: dllname, +proc gluNewNurbsRenderer*(): PGLUnurbs{.dynlib: dllname, importc: "gluNewNurbsRenderer".} -proc gluDeleteNurbsRenderer*(nobj: PGLUnurbs){.dynlib: dllname, +proc gluDeleteNurbsRenderer*(nobj: PGLUnurbs){.dynlib: dllname, importc: "gluDeleteNurbsRenderer".} -proc gluBeginSurface*(nobj: PGLUnurbs){.dynlib: dllname, +proc gluBeginSurface*(nobj: PGLUnurbs){.dynlib: dllname, importc: "gluBeginSurface".} proc gluBeginCurve*(nobj: PGLUnurbs){.dynlib: dllname, importc: "gluBeginCurve".} proc gluEndCurve*(nobj: PGLUnurbs){.dynlib: dllname, importc: "gluEndCurve".} proc gluEndSurface*(nobj: PGLUnurbs){.dynlib: dllname, importc: "gluEndSurface".} proc gluBeginTrim*(nobj: PGLUnurbs){.dynlib: dllname, importc: "gluBeginTrim".} proc gluEndTrim*(nobj: PGLUnurbs){.dynlib: dllname, importc: "gluEndTrim".} -proc gluPwlCurve*(nobj: PGLUnurbs, count: TGLint, aarray: PGLfloat, - stride: TGLint, atype: TGLenum){.dynlib: dllname, +proc gluPwlCurve*(nobj: PGLUnurbs, count: TGLint, aarray: PGLfloat, + stride: TGLint, atype: TGLenum){.dynlib: dllname, importc: "gluPwlCurve".} -proc gluNurbsCurve*(nobj: PGLUnurbs, nknots: TGLint, knot: PGLfloat, - stride: TGLint, ctlarray: PGLfloat, order: TGLint, +proc gluNurbsCurve*(nobj: PGLUnurbs, nknots: TGLint, knot: PGLfloat, + stride: TGLint, ctlarray: PGLfloat, order: TGLint, atype: TGLenum){.dynlib: dllname, importc: "gluNurbsCurve".} -proc gluNurbsSurface*(nobj: PGLUnurbs, sknot_count: TGLint, sknot: PGLfloat, - tknot_count: TGLint, tknot: PGLfloat, - s_stride, t_stride: TGLint, ctlarray: PGLfloat, - sorder, torder: TGLint, atype: TGLenum){.dynlib: dllname, +proc gluNurbsSurface*(nobj: PGLUnurbs, sknot_count: TGLint, sknot: PGLfloat, + tknot_count: TGLint, tknot: PGLfloat, + s_stride, t_stride: TGLint, ctlarray: PGLfloat, + sorder, torder: TGLint, atype: TGLenum){.dynlib: dllname, importc: "gluNurbsSurface".} -proc gluLoadSamplingMatrices*(nobj: PGLUnurbs, - modelMatrix, projMatrix: var T16dArray, - viewport: var TViewPortArray){.dynlib: dllname, +proc gluLoadSamplingMatrices*(nobj: PGLUnurbs, + modelMatrix, projMatrix: var T16dArray, + viewport: var TViewPortArray){.dynlib: dllname, importc: "gluLoadSamplingMatrices".} proc gluNurbsProperty*(nobj: PGLUnurbs, aproperty: TGLenum, value: TGLfloat){. dynlib: dllname, importc: "gluNurbsProperty".} @@ -173,16 +173,16 @@ type # gluQuadricCallback GLUtessVertexProc* = proc (p: Pointer) GLUtessEndProc* = proc () GLUtessErrorProc* = proc (p: TGLenum) - GLUtessCombineProc* = proc (p1: var T3dArray, p2: T4pArray, p3: T4fArray, + GLUtessCombineProc* = proc (p1: var T3dArray, p2: T4pArray, p3: T4fArray, p4: PPointer) GLUtessBeginDataProc* = proc (p1: TGLenum, p2: Pointer) GLUtessEdgeFlagDataProc* = proc (p1: TGLboolean, p2: Pointer) GLUtessVertexDataProc* = proc (p1, p2: Pointer) GLUtessEndDataProc* = proc (p: Pointer) GLUtessErrorDataProc* = proc (p1: TGLenum, p2: Pointer) - GLUtessCombineDataProc* = proc (p1: var T3dArray, p2: var T4pArray, - p3: var T4fArray, p4: PPointer, p5: Pointer) # - # + GLUtessCombineDataProc* = proc (p1: var T3dArray, p2: var T4pArray, + p3: var T4fArray, p4: PPointer, p5: Pointer) # + # # gluNurbsCallback GLUnurbsErrorProc* = proc (p: TGLenum) #*** Generic constants ****/ @@ -226,21 +226,21 @@ const # Version GLU_TESS_COMBINE* = 100105 # void (CALLBACK*)(TGLdouble coords[3], # void *data[4], # TGLfloat weight[4], - # void **dataOut) + # void **dataOut) GLU_TESS_BEGIN_DATA* = 100106 # void (CALLBACK*)(TGLenum type, - # void *polygon_data) + # void *polygon_data) GLU_TESS_VERTEX_DATA* = 100107 # void (CALLBACK*)(void *data, - # void *polygon_data) + # void *polygon_data) GLU_TESS_END_DATA* = 100108 # void (CALLBACK*)(void *polygon_data) GLU_TESS_ERROR_DATA* = 100109 # void (CALLBACK*)(TGLenum errno, - # void *polygon_data) + # void *polygon_data) GLU_TESS_EDGE_FLAG_DATA* = 100110 # void (CALLBACK*)(TGLboolean boundaryEdge, - # void *polygon_data) + # void *polygon_data) GLU_TESS_COMBINE_DATA* = 100111 # void (CALLBACK*)(TGLdouble coords[3], # void *data[4], # TGLfloat weight[4], # void **dataOut, - # void *polygon_data) + # void *polygon_data) # TessError GLU_TESS_ERROR1* = 100151 GLU_TESS_ERROR2* = 100152 @@ -313,11 +313,11 @@ const # Version GLU_NURBS_ERROR36* = 100286 GLU_NURBS_ERROR37* = 100287 #*** Backwards compatibility for old tesselator ****/ -proc gluBeginPolygon*(tess: PGLUtesselator){.dynlib: dllname, +proc gluBeginPolygon*(tess: PGLUtesselator){.dynlib: dllname, importc: "gluBeginPolygon".} -proc gluNextContour*(tess: PGLUtesselator, atype: TGLenum){.dynlib: dllname, +proc gluNextContour*(tess: PGLUtesselator, atype: TGLenum){.dynlib: dllname, importc: "gluNextContour".} -proc gluEndPolygon*(tess: PGLUtesselator){.dynlib: dllname, +proc gluEndPolygon*(tess: PGLUtesselator){.dynlib: dllname, importc: "gluEndPolygon".} const # Contours types -- obsolete! GLU_CW* = 100120 diff --git a/tests/manyloc/keineschweine/lib/glut.nim b/tests/manyloc/keineschweine/lib/glut.nim index ff157c3273..44a2907286 100644 --- a/tests/manyloc/keineschweine/lib/glut.nim +++ b/tests/manyloc/keineschweine/lib/glut.nim @@ -15,17 +15,17 @@ # For the latest updates, visit Delphi3D: http://www.delphi3d.net #****************************************************************************** -import +import GL -when defined(windows): - const +when defined(windows): + const dllname = "glut32.dll" -elif defined(macosx): - const +elif defined(macosx): + const dllname = "/System/Library/Frameworks/GLUT.framework/GLUT" -else: - const +else: + const dllname = "libglut.so.3" type TGlutVoidCallback* = proc (){.cdecl.} @@ -36,7 +36,7 @@ type TGlut1Char2IntCallback* = proc (c: int8, v1, v2: cint){.cdecl.} TGlut1UInt3IntCallback* = proc (u, v1, v2, v3: cint){.cdecl.} -const +const GLUT_API_VERSION* = 3 GLUT_XLIB_IMPLEMENTATION* = 12 # Display mode bit masks. GLUT_RGB* = 0 @@ -93,7 +93,7 @@ const GLUT_NORMAL* = 0 GLUT_OVERLAY* = 1 -when defined(Windows): +when defined(Windows): const # Stroke font constants (use these in GLUT program). GLUT_STROKE_ROMAN* = cast[Pointer](0) GLUT_STROKE_MONO_ROMAN* = cast[Pointer](1) # Bitmap font constants (use these in GLUT program). @@ -104,7 +104,7 @@ when defined(Windows): GLUT_BITMAP_HELVETICA_10* = cast[Pointer](6) GLUT_BITMAP_HELVETICA_12* = cast[Pointer](7) GLUT_BITMAP_HELVETICA_18* = cast[Pointer](8) -else: +else: var # Stroke font constants (use these in GLUT program). GLUT_STROKE_ROMAN*: Pointer GLUT_STROKE_MONO_ROMAN*: Pointer # Bitmap font constants (use these in GLUT program). @@ -229,7 +229,7 @@ const # glutGet parameters. GLUT_GAME_MODE_REFRESH_RATE* = 5 GLUT_GAME_MODE_DISPLAY_CHANGED* = 6 # GLUT initialization sub-API. -proc glutInit*(argcp: ptr cint, argv: pointer){.dynlib: dllname, +proc glutInit*(argcp: ptr cint, argv: pointer){.dynlib: dllname, importc: "glutInit".} proc glutInit*() = @@ -239,34 +239,34 @@ proc glutInit*() = cmdCount {.importc: "cmdCount".}: cint glutInit(addr(cmdCount), addr(cmdLine)) -proc glutInitDisplayMode*(mode: int16){.dynlib: dllname, +proc glutInitDisplayMode*(mode: int16){.dynlib: dllname, importc: "glutInitDisplayMode".} -proc glutInitDisplayString*(str: cstring){.dynlib: dllname, +proc glutInitDisplayString*(str: cstring){.dynlib: dllname, importc: "glutInitDisplayString".} -proc glutInitWindowPosition*(x, y: int){.dynlib: dllname, +proc glutInitWindowPosition*(x, y: int){.dynlib: dllname, importc: "glutInitWindowPosition".} -proc glutInitWindowSize*(width, height: int){.dynlib: dllname, +proc glutInitWindowSize*(width, height: int){.dynlib: dllname, importc: "glutInitWindowSize".} proc glutMainLoop*(){.dynlib: dllname, importc: "glutMainLoop".} # GLUT window sub-API. -proc glutCreateWindow*(title: cstring): int{.dynlib: dllname, +proc glutCreateWindow*(title: cstring): int{.dynlib: dllname, importc: "glutCreateWindow".} -proc glutCreateSubWindow*(win, x, y, width, height: int): int{.dynlib: dllname, +proc glutCreateSubWindow*(win, x, y, width, height: int): int{.dynlib: dllname, importc: "glutCreateSubWindow".} proc glutDestroyWindow*(win: int){.dynlib: dllname, importc: "glutDestroyWindow".} proc glutPostRedisplay*(){.dynlib: dllname, importc: "glutPostRedisplay".} -proc glutPostWindowRedisplay*(win: int){.dynlib: dllname, +proc glutPostWindowRedisplay*(win: int){.dynlib: dllname, importc: "glutPostWindowRedisplay".} proc glutSwapBuffers*(){.dynlib: dllname, importc: "glutSwapBuffers".} proc glutGetWindow*(): int{.dynlib: dllname, importc: "glutGetWindow".} proc glutSetWindow*(win: int){.dynlib: dllname, importc: "glutSetWindow".} -proc glutSetWindowTitle*(title: cstring){.dynlib: dllname, +proc glutSetWindowTitle*(title: cstring){.dynlib: dllname, importc: "glutSetWindowTitle".} -proc glutSetIconTitle*(title: cstring){.dynlib: dllname, +proc glutSetIconTitle*(title: cstring){.dynlib: dllname, importc: "glutSetIconTitle".} -proc glutPositionWindow*(x, y: int){.dynlib: dllname, +proc glutPositionWindow*(x, y: int){.dynlib: dllname, importc: "glutPositionWindow".} -proc glutReshapeWindow*(width, height: int){.dynlib: dllname, +proc glutReshapeWindow*(width, height: int){.dynlib: dllname, importc: "glutReshapeWindow".} proc glutPopWindow*(){.dynlib: dllname, importc: "glutPopWindow".} proc glutPushWindow*(){.dynlib: dllname, importc: "glutPushWindow".} @@ -280,107 +280,107 @@ proc glutWarpPointer*(x, y: int){.dynlib: dllname, importc: "glutWarpPointer".} proc glutEstablishOverlay*(){.dynlib: dllname, importc: "glutEstablishOverlay".} proc glutRemoveOverlay*(){.dynlib: dllname, importc: "glutRemoveOverlay".} proc glutUseLayer*(layer: TGLenum){.dynlib: dllname, importc: "glutUseLayer".} -proc glutPostOverlayRedisplay*(){.dynlib: dllname, +proc glutPostOverlayRedisplay*(){.dynlib: dllname, importc: "glutPostOverlayRedisplay".} -proc glutPostWindowOverlayRedisplay*(win: int){.dynlib: dllname, +proc glutPostWindowOverlayRedisplay*(win: int){.dynlib: dllname, importc: "glutPostWindowOverlayRedisplay".} proc glutShowOverlay*(){.dynlib: dllname, importc: "glutShowOverlay".} proc glutHideOverlay*(){.dynlib: dllname, importc: "glutHideOverlay".} # GLUT menu sub-API. -proc glutCreateMenu*(callback: TGlut1IntCallback): int{.dynlib: dllname, +proc glutCreateMenu*(callback: TGlut1IntCallback): int{.dynlib: dllname, importc: "glutCreateMenu".} proc glutDestroyMenu*(menu: int){.dynlib: dllname, importc: "glutDestroyMenu".} proc glutGetMenu*(): int{.dynlib: dllname, importc: "glutGetMenu".} proc glutSetMenu*(menu: int){.dynlib: dllname, importc: "glutSetMenu".} -proc glutAddMenuEntry*(caption: cstring, value: int){.dynlib: dllname, +proc glutAddMenuEntry*(caption: cstring, value: int){.dynlib: dllname, importc: "glutAddMenuEntry".} -proc glutAddSubMenu*(caption: cstring, submenu: int){.dynlib: dllname, +proc glutAddSubMenu*(caption: cstring, submenu: int){.dynlib: dllname, importc: "glutAddSubMenu".} proc glutChangeToMenuEntry*(item: int, caption: cstring, value: int){. dynlib: dllname, importc: "glutChangeToMenuEntry".} proc glutChangeToSubMenu*(item: int, caption: cstring, submenu: int){. dynlib: dllname, importc: "glutChangeToSubMenu".} -proc glutRemoveMenuItem*(item: int){.dynlib: dllname, +proc glutRemoveMenuItem*(item: int){.dynlib: dllname, importc: "glutRemoveMenuItem".} proc glutAttachMenu*(button: int){.dynlib: dllname, importc: "glutAttachMenu".} proc glutDetachMenu*(button: int){.dynlib: dllname, importc: "glutDetachMenu".} # GLUT window callback sub-API. -proc glutDisplayFunc*(f: TGlutVoidCallback){.dynlib: dllname, +proc glutDisplayFunc*(f: TGlutVoidCallback){.dynlib: dllname, importc: "glutDisplayFunc".} -proc glutReshapeFunc*(f: TGlut2IntCallback){.dynlib: dllname, +proc glutReshapeFunc*(f: TGlut2IntCallback){.dynlib: dllname, importc: "glutReshapeFunc".} -proc glutKeyboardFunc*(f: TGlut1Char2IntCallback){.dynlib: dllname, +proc glutKeyboardFunc*(f: TGlut1Char2IntCallback){.dynlib: dllname, importc: "glutKeyboardFunc".} -proc glutMouseFunc*(f: TGlut4IntCallback){.dynlib: dllname, +proc glutMouseFunc*(f: TGlut4IntCallback){.dynlib: dllname, importc: "glutMouseFunc".} -proc glutMotionFunc*(f: TGlut2IntCallback){.dynlib: dllname, +proc glutMotionFunc*(f: TGlut2IntCallback){.dynlib: dllname, importc: "glutMotionFunc".} -proc glutPassiveMotionFunc*(f: TGlut2IntCallback){.dynlib: dllname, +proc glutPassiveMotionFunc*(f: TGlut2IntCallback){.dynlib: dllname, importc: "glutPassiveMotionFunc".} -proc glutEntryFunc*(f: TGlut1IntCallback){.dynlib: dllname, +proc glutEntryFunc*(f: TGlut1IntCallback){.dynlib: dllname, importc: "glutEntryFunc".} -proc glutVisibilityFunc*(f: TGlut1IntCallback){.dynlib: dllname, +proc glutVisibilityFunc*(f: TGlut1IntCallback){.dynlib: dllname, importc: "glutVisibilityFunc".} -proc glutIdleFunc*(f: TGlutVoidCallback){.dynlib: dllname, +proc glutIdleFunc*(f: TGlutVoidCallback){.dynlib: dllname, importc: "glutIdleFunc".} proc glutTimerFunc*(millis: int16, f: TGlut1IntCallback, value: int){. dynlib: dllname, importc: "glutTimerFunc".} -proc glutMenuStateFunc*(f: TGlut1IntCallback){.dynlib: dllname, +proc glutMenuStateFunc*(f: TGlut1IntCallback){.dynlib: dllname, importc: "glutMenuStateFunc".} -proc glutSpecialFunc*(f: TGlut3IntCallback){.dynlib: dllname, +proc glutSpecialFunc*(f: TGlut3IntCallback){.dynlib: dllname, importc: "glutSpecialFunc".} -proc glutSpaceballMotionFunc*(f: TGlut3IntCallback){.dynlib: dllname, +proc glutSpaceballMotionFunc*(f: TGlut3IntCallback){.dynlib: dllname, importc: "glutSpaceballMotionFunc".} -proc glutSpaceballRotateFunc*(f: TGlut3IntCallback){.dynlib: dllname, +proc glutSpaceballRotateFunc*(f: TGlut3IntCallback){.dynlib: dllname, importc: "glutSpaceballRotateFunc".} -proc glutSpaceballButtonFunc*(f: TGlut2IntCallback){.dynlib: dllname, +proc glutSpaceballButtonFunc*(f: TGlut2IntCallback){.dynlib: dllname, importc: "glutSpaceballButtonFunc".} -proc glutButtonBoxFunc*(f: TGlut2IntCallback){.dynlib: dllname, +proc glutButtonBoxFunc*(f: TGlut2IntCallback){.dynlib: dllname, importc: "glutButtonBoxFunc".} -proc glutDialsFunc*(f: TGlut2IntCallback){.dynlib: dllname, +proc glutDialsFunc*(f: TGlut2IntCallback){.dynlib: dllname, importc: "glutDialsFunc".} -proc glutTabletMotionFunc*(f: TGlut2IntCallback){.dynlib: dllname, +proc glutTabletMotionFunc*(f: TGlut2IntCallback){.dynlib: dllname, importc: "glutTabletMotionFunc".} -proc glutTabletButtonFunc*(f: TGlut4IntCallback){.dynlib: dllname, +proc glutTabletButtonFunc*(f: TGlut4IntCallback){.dynlib: dllname, importc: "glutTabletButtonFunc".} -proc glutMenuStatusFunc*(f: TGlut3IntCallback){.dynlib: dllname, +proc glutMenuStatusFunc*(f: TGlut3IntCallback){.dynlib: dllname, importc: "glutMenuStatusFunc".} -proc glutOverlayDisplayFunc*(f: TGlutVoidCallback){.dynlib: dllname, +proc glutOverlayDisplayFunc*(f: TGlutVoidCallback){.dynlib: dllname, importc: "glutOverlayDisplayFunc".} -proc glutWindowStatusFunc*(f: TGlut1IntCallback){.dynlib: dllname, +proc glutWindowStatusFunc*(f: TGlut1IntCallback){.dynlib: dllname, importc: "glutWindowStatusFunc".} -proc glutKeyboardUpFunc*(f: TGlut1Char2IntCallback){.dynlib: dllname, +proc glutKeyboardUpFunc*(f: TGlut1Char2IntCallback){.dynlib: dllname, importc: "glutKeyboardUpFunc".} -proc glutSpecialUpFunc*(f: TGlut3IntCallback){.dynlib: dllname, +proc glutSpecialUpFunc*(f: TGlut3IntCallback){.dynlib: dllname, importc: "glutSpecialUpFunc".} proc glutJoystickFunc*(f: TGlut1UInt3IntCallback, pollInterval: int){. dynlib: dllname, importc: "glutJoystickFunc".} # GLUT color index sub-API. -proc glutSetColor*(cell: int, red, green, blue: TGLfloat){.dynlib: dllname, +proc glutSetColor*(cell: int, red, green, blue: TGLfloat){.dynlib: dllname, importc: "glutSetColor".} -proc glutGetColor*(ndx, component: int): TGLfloat{.dynlib: dllname, +proc glutGetColor*(ndx, component: int): TGLfloat{.dynlib: dllname, importc: "glutGetColor".} proc glutCopyColormap*(win: int){.dynlib: dllname, importc: "glutCopyColormap".} # GLUT state retrieval sub-API. proc glutGet*(t: TGLenum): int{.dynlib: dllname, importc: "glutGet".} proc glutDeviceGet*(t: TGLenum): int{.dynlib: dllname, importc: "glutDeviceGet".} # GLUT extension support sub-API -proc glutExtensionSupported*(name: cstring): int{.dynlib: dllname, +proc glutExtensionSupported*(name: cstring): int{.dynlib: dllname, importc: "glutExtensionSupported".} proc glutGetModifiers*(): int{.dynlib: dllname, importc: "glutGetModifiers".} proc glutLayerGet*(t: TGLenum): int{.dynlib: dllname, importc: "glutLayerGet".} # GLUT font sub-API -proc glutBitmapCharacter*(font: pointer, character: int){.dynlib: dllname, +proc glutBitmapCharacter*(font: pointer, character: int){.dynlib: dllname, importc: "glutBitmapCharacter".} -proc glutBitmapWidth*(font: pointer, character: int): int{.dynlib: dllname, +proc glutBitmapWidth*(font: pointer, character: int): int{.dynlib: dllname, importc: "glutBitmapWidth".} -proc glutStrokeCharacter*(font: pointer, character: int){.dynlib: dllname, +proc glutStrokeCharacter*(font: pointer, character: int){.dynlib: dllname, importc: "glutStrokeCharacter".} -proc glutStrokeWidth*(font: pointer, character: int): int{.dynlib: dllname, +proc glutStrokeWidth*(font: pointer, character: int): int{.dynlib: dllname, importc: "glutStrokeWidth".} -proc glutBitmapLength*(font: pointer, str: cstring): int{.dynlib: dllname, +proc glutBitmapLength*(font: pointer, str: cstring): int{.dynlib: dllname, importc: "glutBitmapLength".} -proc glutStrokeLength*(font: pointer, str: cstring): int{.dynlib: dllname, +proc glutStrokeLength*(font: pointer, str: cstring): int{.dynlib: dllname, importc: "glutStrokeLength".} # GLUT pre-built models sub-API proc glutWireSphere*(radius: TGLdouble, slices, stacks: TGLint){. @@ -399,9 +399,9 @@ proc glutSolidTorus*(innerRadius, outerRadius: TGLdouble, sides, rings: TGLint){ dynlib: dllname, importc: "glutSolidTorus".} proc glutWireDodecahedron*(){.dynlib: dllname, importc: "glutWireDodecahedron".} proc glutSolidDodecahedron*(){.dynlib: dllname, importc: "glutSolidDodecahedron".} -proc glutWireTeapot*(size: TGLdouble){.dynlib: dllname, +proc glutWireTeapot*(size: TGLdouble){.dynlib: dllname, importc: "glutWireTeapot".} -proc glutSolidTeapot*(size: TGLdouble){.dynlib: dllname, +proc glutSolidTeapot*(size: TGLdouble){.dynlib: dllname, importc: "glutSolidTeapot".} proc glutWireOctahedron*(){.dynlib: dllname, importc: "glutWireOctahedron".} proc glutSolidOctahedron*(){.dynlib: dllname, importc: "glutSolidOctahedron".} @@ -410,29 +410,29 @@ proc glutSolidTetrahedron*(){.dynlib: dllname, importc: "glutSolidTetrahedron".} proc glutWireIcosahedron*(){.dynlib: dllname, importc: "glutWireIcosahedron".} proc glutSolidIcosahedron*(){.dynlib: dllname, importc: "glutSolidIcosahedron".} # GLUT video resize sub-API. -proc glutVideoResizeGet*(param: TGLenum): int{.dynlib: dllname, +proc glutVideoResizeGet*(param: TGLenum): int{.dynlib: dllname, importc: "glutVideoResizeGet".} -proc glutSetupVideoResizing*(){.dynlib: dllname, +proc glutSetupVideoResizing*(){.dynlib: dllname, importc: "glutSetupVideoResizing".} proc glutStopVideoResizing*(){.dynlib: dllname, importc: "glutStopVideoResizing".} -proc glutVideoResize*(x, y, width, height: int){.dynlib: dllname, +proc glutVideoResize*(x, y, width, height: int){.dynlib: dllname, importc: "glutVideoResize".} -proc glutVideoPan*(x, y, width, height: int){.dynlib: dllname, +proc glutVideoPan*(x, y, width, height: int){.dynlib: dllname, importc: "glutVideoPan".} # GLUT debugging sub-API. proc glutReportErrors*(){.dynlib: dllname, importc: "glutReportErrors".} # GLUT device control sub-API. -proc glutIgnoreKeyRepeat*(ignore: int){.dynlib: dllname, +proc glutIgnoreKeyRepeat*(ignore: int){.dynlib: dllname, importc: "glutIgnoreKeyRepeat".} -proc glutSetKeyRepeat*(repeatMode: int){.dynlib: dllname, +proc glutSetKeyRepeat*(repeatMode: int){.dynlib: dllname, importc: "glutSetKeyRepeat".} proc glutForceJoystickFunc*(){.dynlib: dllname, importc: "glutForceJoystickFunc".} # GLUT game mode sub-API. #example glutGameModeString('1280x1024:32@75'); -proc glutGameModeString*(AString: cstring){.dynlib: dllname, +proc glutGameModeString*(AString: cstring){.dynlib: dllname, importc: "glutGameModeString".} proc glutEnterGameMode*(): int{.dynlib: dllname, importc: "glutEnterGameMode".} proc glutLeaveGameMode*(){.dynlib: dllname, importc: "glutLeaveGameMode".} -proc glutGameModeGet*(mode: TGLenum): int{.dynlib: dllname, +proc glutGameModeGet*(mode: TGLenum): int{.dynlib: dllname, importc: "glutGameModeGet".} # implementation diff --git a/tests/manyloc/keineschweine/lib/glx.nim b/tests/manyloc/keineschweine/lib/glx.nim index 76c052d70a..ce02835bd8 100644 --- a/tests/manyloc/keineschweine/lib/glx.nim +++ b/tests/manyloc/keineschweine/lib/glx.nim @@ -23,19 +23,19 @@ # Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -import +import X, XLib, XUtil, gl -when defined(windows): - const +when defined(windows): + const dllname = "GL.dll" -elif defined(macosx): - const +elif defined(macosx): + const dllname = "/usr/X11R6/lib/libGL.dylib" -else: - const +else: + const dllname = "libGL.so" -const +const GLX_USE_GL* = 1 GLX_BUFFER_SIZE* = 2 GLX_LEVEL* = 3 @@ -98,55 +98,55 @@ type # From XLib: proc glXChooseVisual*(dpy: PDisplay, screen: int, attribList: ptr int32): PXVisualInfo{. cdecl, dynlib: dllname, importc: "glXChooseVisual".} -proc glXCreateContext*(dpy: PDisplay, vis: PXVisualInfo, shareList: GLXContext, - direct: bool): GLXContext{.cdecl, dynlib: dllname, +proc glXCreateContext*(dpy: PDisplay, vis: PXVisualInfo, shareList: GLXContext, + direct: bool): GLXContext{.cdecl, dynlib: dllname, importc: "glXCreateContext".} -proc glXDestroyContext*(dpy: PDisplay, ctx: GLXContext){.cdecl, dynlib: dllname, +proc glXDestroyContext*(dpy: PDisplay, ctx: GLXContext){.cdecl, dynlib: dllname, importc: "glXDestroyContext".} proc glXMakeCurrent*(dpy: PDisplay, drawable: GLXDrawable, ctx: GLXContext): bool{. cdecl, dynlib: dllname, importc: "glXMakeCurrent".} -proc glXCopyContext*(dpy: PDisplay, src, dst: GLXContext, mask: int32){.cdecl, +proc glXCopyContext*(dpy: PDisplay, src, dst: GLXContext, mask: int32){.cdecl, dynlib: dllname, importc: "glXCopyContext".} -proc glXSwapBuffers*(dpy: PDisplay, drawable: GLXDrawable){.cdecl, +proc glXSwapBuffers*(dpy: PDisplay, drawable: GLXDrawable){.cdecl, dynlib: dllname, importc: "glXSwapBuffers".} proc glXCreateGLXPixmap*(dpy: PDisplay, visual: PXVisualInfo, pixmap: XPixmap): GLXPixmap{. cdecl, dynlib: dllname, importc: "glXCreateGLXPixmap".} -proc glXDestroyGLXPixmap*(dpy: PDisplay, pixmap: GLXPixmap){.cdecl, +proc glXDestroyGLXPixmap*(dpy: PDisplay, pixmap: GLXPixmap){.cdecl, dynlib: dllname, importc: "glXDestroyGLXPixmap".} -proc glXQueryExtension*(dpy: PDisplay, errorb, event: var int): bool{.cdecl, +proc glXQueryExtension*(dpy: PDisplay, errorb, event: var int): bool{.cdecl, dynlib: dllname, importc: "glXQueryExtension".} -proc glXQueryVersion*(dpy: PDisplay, maj, min: var int): bool{.cdecl, +proc glXQueryVersion*(dpy: PDisplay, maj, min: var int): bool{.cdecl, dynlib: dllname, importc: "glXQueryVersion".} -proc glXIsDirect*(dpy: PDisplay, ctx: GLXContext): bool{.cdecl, dynlib: dllname, +proc glXIsDirect*(dpy: PDisplay, ctx: GLXContext): bool{.cdecl, dynlib: dllname, importc: "glXIsDirect".} -proc glXGetConfig*(dpy: PDisplay, visual: PXVisualInfo, attrib: int, - value: var int): int{.cdecl, dynlib: dllname, +proc glXGetConfig*(dpy: PDisplay, visual: PXVisualInfo, attrib: int, + value: var int): int{.cdecl, dynlib: dllname, importc: "glXGetConfig".} -proc glXGetCurrentContext*(): GLXContext{.cdecl, dynlib: dllname, +proc glXGetCurrentContext*(): GLXContext{.cdecl, dynlib: dllname, importc: "glXGetCurrentContext".} -proc glXGetCurrentDrawable*(): GLXDrawable{.cdecl, dynlib: dllname, +proc glXGetCurrentDrawable*(): GLXDrawable{.cdecl, dynlib: dllname, importc: "glXGetCurrentDrawable".} proc glXWaitGL*(){.cdecl, dynlib: dllname, importc: "glXWaitGL".} proc glXWaitX*(){.cdecl, dynlib: dllname, importc: "glXWaitX".} -proc glXUseXFont*(font: XFont, first, count, list: int){.cdecl, dynlib: dllname, +proc glXUseXFont*(font: XFont, first, count, list: int){.cdecl, dynlib: dllname, importc: "glXUseXFont".} # GLX 1.1 and later -proc glXQueryExtensionsString*(dpy: PDisplay, screen: int): cstring{.cdecl, +proc glXQueryExtensionsString*(dpy: PDisplay, screen: int): cstring{.cdecl, dynlib: dllname, importc: "glXQueryExtensionsString".} -proc glXQueryServerString*(dpy: PDisplay, screen, name: int): cstring{.cdecl, +proc glXQueryServerString*(dpy: PDisplay, screen, name: int): cstring{.cdecl, dynlib: dllname, importc: "glXQueryServerString".} -proc glXGetClientString*(dpy: PDisplay, name: int): cstring{.cdecl, +proc glXGetClientString*(dpy: PDisplay, name: int): cstring{.cdecl, dynlib: dllname, importc: "glXGetClientString".} # Mesa GLX Extensions -proc glXCreateGLXPixmapMESA*(dpy: PDisplay, visual: PXVisualInfo, +proc glXCreateGLXPixmapMESA*(dpy: PDisplay, visual: PXVisualInfo, pixmap: XPixmap, cmap: XColormap): GLXPixmap{. cdecl, dynlib: dllname, importc: "glXCreateGLXPixmapMESA".} -proc glXReleaseBufferMESA*(dpy: PDisplay, d: GLXDrawable): bool{.cdecl, +proc glXReleaseBufferMESA*(dpy: PDisplay, d: GLXDrawable): bool{.cdecl, dynlib: dllname, importc: "glXReleaseBufferMESA".} -proc glXCopySubBufferMESA*(dpy: PDisplay, drawbale: GLXDrawable, - x, y, width, height: int){.cdecl, dynlib: dllname, +proc glXCopySubBufferMESA*(dpy: PDisplay, drawbale: GLXDrawable, + x, y, width, height: int){.cdecl, dynlib: dllname, importc: "glXCopySubBufferMESA".} -proc glXGetVideoSyncSGI*(counter: var int32): int{.cdecl, dynlib: dllname, +proc glXGetVideoSyncSGI*(counter: var int32): int{.cdecl, dynlib: dllname, importc: "glXGetVideoSyncSGI".} proc glXWaitVideoSyncSGI*(divisor, remainder: int, count: var int32): int{. cdecl, dynlib: dllname, importc: "glXWaitVideoSyncSGI".} diff --git a/tests/manyloc/keineschweine/lib/idgen.nim b/tests/manyloc/keineschweine/lib/idgen.nim index 8124ba9bd6..1ed196d882 100644 --- a/tests/manyloc/keineschweine/lib/idgen.nim +++ b/tests/manyloc/keineschweine/lib/idgen.nim @@ -5,7 +5,7 @@ type freeIDs: seq[T] EOutOfIDs* = object of EInvalidKey -#proc free[T](idg: PIDgen[T]) = +#proc free[T](idg: PIDgen[T]) = # result.freeIDs = nil proc newIDGen*[T: Ordinal](): PIDGen[T] = new(result)#, free) diff --git a/tests/manyloc/keineschweine/lib/input_helpers.nim b/tests/manyloc/keineschweine/lib/input_helpers.nim index 120576dfb6..1953cb58cb 100644 --- a/tests/manyloc/keineschweine/lib/input_helpers.nim +++ b/tests/manyloc/keineschweine/lib/input_helpers.nim @@ -2,7 +2,7 @@ import sfml, tables, hashes type TKeyEventKind* = enum down, up - TInputFinishedProc* = proc() + TInputFinishedProc* = proc() TKeyCallback = proc() PKeyClient* = ref object onKeyDown: TTable[int32, TKeyCallback] @@ -18,7 +18,7 @@ var activeClient: PKeyClient = nil activeInput: PTextInput = nil -proc setActive*(client: PKeyClient) = +proc setActive*(client: PKeyClient) = activeClient = client echo("** set active client ", client.name) proc newKeyClient*(name: string = "unnamed", setactive = false): PKeyClient = @@ -43,28 +43,28 @@ proc addKeyEvent*(key: TKeyCode, ev: TKeyEventKind) {.inline.} = if activeClient.isNil: return let k = key.int32 case ev - of down: + of down: keyState[k] = true if activeClient.onKeyDown.hasKey(k): activeClient.onKeyDown[k]() - else: + else: keyState[k] = false if activeClient.onKeyUp.hasKey(k): activeClient.onKeyUp[k]() proc addButtonEvent*(btn: TMouseButton, ev: TKeyEventKind) {.inline.} = - if activeClient.isNil: return + if activeClient.isNil: return let b = -btn.int32 case ev - of down: - keyState[b] = true + of down: + keyState[b] = true if activeClient.onKeyDown.hasKey(b): activeClient.onKeyDown[b]() - else: + else: keyState[b] = false if activeClient.onKeyUp.hasKey(b): activeClient.onKeyUp[b]() proc registerHandler*(client: PKeyClient; key: TKeyCode; - ev: TKeyEventKind; fn: TKeyCallback) = + ev: TKeyEventKind; fn: TKeyCallback) = case ev of down: client.onKeyDown[key.int32] = fn of up: client.onKeyUp[key.int32] = fn @@ -90,7 +90,7 @@ proc recordText*(i: PTextInput; c: cint) = if c > 127 or i.isNil: return if c in 32..126: ##printable if i.cursor == i.text.len: i.text.add(c.int.chr) - else: + else: let rem = i.text.substr(i.cursor) i.text.setLen(i.cursor) i.text.add(chr(c.int)) @@ -104,7 +104,7 @@ proc recordText*(i: PTextInput; c: cint) = i.text.add(rem) elif c == 10 or c == 13:## \n, \r enter if not i.onEnter.isNil: i.onEnter() -proc recordText*(i: PTextInput; e: TTextEvent) {.inline.} = +proc recordText*(i: PTextInput; e: TTextEvent) {.inline.} = recordText(i, e.unicode) proc setMousePos*(x, y: cint) {.inline.} = @@ -135,4 +135,4 @@ iterator pollEvents*(window: PRenderWindow): PEvent = of EvtTextEntered: recordText(activeInput, event.text) of EvtMouseMoved: setMousePos(event.mouseMove.x, event.mouseMove.y) else: nil - yield(addr event) \ No newline at end of file + yield(addr event) diff --git a/tests/manyloc/keineschweine/lib/map_filter.nim b/tests/manyloc/keineschweine/lib/map_filter.nim index 5776c9225b..42ef74cebb 100644 --- a/tests/manyloc/keineschweine/lib/map_filter.nim +++ b/tests/manyloc/keineschweine/lib/map_filter.nim @@ -19,7 +19,7 @@ template unless*(condition: expr; body: stmt): stmt {.dirty.} = when isMainModule: proc dumpSeq[T](x: seq[T]) = - for index, item in x.pairs: + for index, item in x.pairs: echo index, " ", item echo "-------" @@ -28,13 +28,13 @@ when isMainModule: dumpSeq res from strutils import toHex - var foocakes = t.map(proc(z: int): string = + var foocakes = t.map(proc(z: int): string = result = toHex((z * 23).BiggestInt, 4)) dumpSeq foocakes t.mapInPlace(proc(z: int): int = result = z * 30) dumpSeq t - + var someSeq = @[9,8,7,6,5,4,3,2,1] ## numbers < 6 or even filterIt2 someSeq, it < 6 or (it and 1) == 0: echo(it) diff --git a/tests/manyloc/keineschweine/lib/math_helpers.nim b/tests/manyloc/keineschweine/lib/math_helpers.nim index 8af56d1ed1..5427dd80ed 100644 --- a/tests/manyloc/keineschweine/lib/math_helpers.nim +++ b/tests/manyloc/keineschweine/lib/math_helpers.nim @@ -6,5 +6,5 @@ proc radians*(deg: float): float = return deg * PI / 180.0 ## V not math, sue me -proc ff*(f: float, precision = 2): string {.inline.} = +proc ff*(f: float, precision = 2): string {.inline.} = return formatFloat(f, ffDecimal, precision) diff --git a/tests/manyloc/keineschweine/lib/sfml_stuff.nim b/tests/manyloc/keineschweine/lib/sfml_stuff.nim index a5ac91195c..5ff80b295e 100644 --- a/tests/manyloc/keineschweine/lib/sfml_stuff.nim +++ b/tests/manyloc/keineschweine/lib/sfml_stuff.nim @@ -1,4 +1,4 @@ -import +import math, strutils, sfml, input_helpers when not defined(NoChipmunk): diff --git a/tests/manyloc/keineschweine/lib/sg_assets.nim b/tests/manyloc/keineschweine/lib/sg_assets.nim index c5a39550a7..3b97816490 100644 --- a/tests/manyloc/keineschweine/lib/sg_assets.nim +++ b/tests/manyloc/keineschweine/lib/sg_assets.nim @@ -1,5 +1,5 @@ import - re, json, strutils, tables, math, os, math_helpers, + re, json, strutils, tables, math, os, math_helpers, sg_packets, md5, zlib_helpers when defined(NoSFML): @@ -56,9 +56,9 @@ type energyCost*: float useSound*: PSoundRecord case kind*: TItemKind - of Projectile: + of Projectile: bullet*: PBulletRecord - else: + else: nil PBulletRecord* = ref TBulletRecord TBulletRecord* = object @@ -84,7 +84,7 @@ type health*: int TExplosionRecord* = object anim*: PAnimationRecord - sound*: PSoundRecord + sound*: PSoundRecord PAnimationRecord* = ref TAnimationRecord TAnimationRecord* = object spriteSheet*: PSpriteSheet @@ -96,9 +96,9 @@ type when defined(NoSFML): contents*: TChecksumFile else: - soundBuf*: PSoundBuffer + soundBuf*: PSoundBuffer PSpriteSheet* = ref TSpriteSheet - TSpriteSheet* = object + TSpriteSheet* = object file*: string framew*,frameh*: int rows*, cols*: int @@ -112,7 +112,7 @@ type const TAU* = PI * 2.0 MomentMult* = 0.62 ## global moment of inertia multiplier -var +var cfg: PZoneSettings SpriteSheets* = initTable[string, PSpriteSheet](64) SoundCache * = initTable[string, PSoundRecord](64) @@ -151,7 +151,7 @@ proc importSound*(data: PJsonNode; errors: var seq[string]; fieldName: string = ## this is the only pipe between lobby and main.nim proc getActiveState*(): TGameState = result = activeState -proc transition*() = +proc transition*() = assert activeState == Lobby, "Transition() called from a state other than lobby!" activeState = Transitioning proc doneWithSaidTransition*() = @@ -179,7 +179,7 @@ proc free*(obj: PSoundRecord) = echo "Free'd ", obj.file proc loadAllAssets*() = - var + var loaded = 0 failed = 0 for name, ss in SpriteSheets.pairs(): @@ -205,7 +205,7 @@ iterator playableVehicles*(): PVehicleRecord = yield v template allAssets*(body: stmt) {.dirty.}= - block: + block: var assetType = FGraphics for file, asset in pairs(SpriteSheets): body @@ -230,7 +230,7 @@ cacheImpl newSprite, SpriteSheets, PSpriteSheet: if filename =~ re"\S+_(\d+)x(\d+)\.\S\S\S": result.framew = strutils.parseInt(matches[0]) result.frameh = strutils.parseInt(matches[1]) - checkFile("data/gfx"/result.file) + checkFile("data/gfx"/result.file) else: errors.add "Bad file: "&filename&" must be in format name_WxH.png" return @@ -260,7 +260,7 @@ when defined(NoSFML): result = true else: proc load*(ss: PSpriteSheet): bool = - if not ss.sprite.isNil: + if not ss.sprite.isNil: return var image = sfml.newImage("data/gfx/"/ss.file) if image == nil: @@ -335,7 +335,7 @@ proc loadSettings*(rawJson: string, errors: var seq[string]): bool = except EJsonParsingError: errors.add("JSON parsing error: "& getCurrentExceptionMsg()) return - except: + except: errors.add("Unknown exception: "& getCurrentExceptionMsg()) return if not validateSettings(settings, errors): @@ -354,7 +354,7 @@ proc loadSettings*(rawJson: string, errors: var seq[string]): bool = nameToItemID = initTable[string, int](32) nameToObjID = initTable[string, int](32) nameToBulletID = initTable[string, int](32) - var + var vID = 0'i16 bID = 0'i16 for vehicle in settings["vehicles"].items: @@ -382,7 +382,7 @@ proc loadSettings*(rawJson: string, errors: var seq[string]): bool = errors.add("Projectile #$1 has no bullet!"% $vID) elif itm.bullet.id == -1: ## this item has an anonymous bullet, fix the ID and name - itm.bullet.id = bID + itm.bullet.id = bID itm.bullet.name = itm.name cfg.bullets.add itm.bullet nameToBulletID[itm.bullet.name] = itm.bullet.id @@ -448,7 +448,7 @@ proc importLevel(data: PJsonNode; errors: var seq[string]): PLevelSettings = new(result) result.size = vec2i(5000, 5000) result.starfield = @[] - + checkKey(data, "level") var level = data["level"] if level.hasKey("size") and level["size"].kind == JArray and level["size"].len == 2: @@ -460,7 +460,7 @@ proc importLevel(data: PJsonNode; errors: var seq[string]): PLevelSettings = proc importPhys(data: PJsonNode): TPhysicsRecord = result.radius = 20.0 result.mass = 10.0 - + if data.hasKey("physics") and data["physics"].kind == JObject: let phys = data["physics"] phys.getField("radius", result.radius) @@ -473,11 +473,11 @@ proc importHandling(data: PJsonNode): THandlingRecord = result.reverse = 30.0 result.strafe = 30.0 result.rotation = 2200.0 - + checkKey(data, "handling") if data["handling"].kind != JObject: return - + let hand = data["handling"] hand.getField("thrust", result.thrust) hand.getField("top_speed", result.topSpeed) @@ -489,19 +489,19 @@ proc importAnim(data: PJsonNode, errors: var seq[string]): PAnimationRecord = result.angle = 0.0 result.delay = 1000.0 result.spriteSheet = nil - + if data.hasKey("anim"): let anim = data["anim"] if anim.kind == JObject: if anim.hasKey("file"): result.spriteSheet = newSprite(anim["file"].str, errors) - + anim.getField "angle", result.angle anim.getField "delay", result.delay elif data["anim"].kind == JString: result.spriteSheet = newSprite(anim.str, errors) - - result.angle = radians(result.angle) ## comes in as degrees + + result.angle = radians(result.angle) ## comes in as degrees result.delay /= 1000 ## delay comes in as milliseconds proc importSoul(data: PJsonNode): TSoulRecord = result.energy = 10000 @@ -525,8 +525,8 @@ proc importSound*(data: PJsonNode; errors: var seq[string]; fieldName: string = proc importVeh(data: PJsonNode; errors: var seq[string]): PVehicleRecord = new(result) result.playable = false - if data.kind != JArray or data.len != 2 or - (data.kind == JArray and + if data.kind != JArray or data.len != 2 or + (data.kind == JArray and (data[0].kind != JString or data[1].kind != JObject)): result.name = "(broken)" errors.add "Vehicle record is malformed" @@ -556,13 +556,13 @@ proc importItem(data: PJsonNode; errors: var seq[string]): PItemRecord = result.name = data[0].str result.anim = importAnim(data[2], errors) result.physics = importPhys(data[2]) - - result.cooldown = 100.0 + + result.cooldown = 100.0 data[2].getField("cooldown", result.cooldown) - result.cooldown /= 1000.0 ##cooldown is stored in ms - + result.cooldown /= 1000.0 ##cooldown is stored in ms + result.useSound = importSound(data[2], errors, "useSound") - + case data[1].str.toLower of "projectile": result.kind = Projectile @@ -570,7 +570,7 @@ proc importItem(data: PJsonNode; errors: var seq[string]): PItemRecord = result.bullet = fetchBullet(data[2]["bullet"].str) elif data[2]["bullet"].kind == JInt: result.bullet = cfg.bullets[data[2]["bullet"].num.int] - elif data[2]["bullet"].kind == JObject: + elif data[2]["bullet"].kind == JObject: result.bullet = importBullet(data[2]["bullet"], errors) else: errors.add "UNKNOWN BULLET TYPE for item "& result.name @@ -584,20 +584,20 @@ proc importItem(data: PJsonNode; errors: var seq[string]): PItemRecord = proc importBullet(data: PJsonNode; errors: var seq[string]): PBulletRecord = new(result) result.id = -1 - + var bdata: PJsonNode if data.kind == JArray: result.name = data[0].str bdata = data[1] elif data.kind == JObject: bdata = data - else: + else: errors.add "Malformed bullet record" return - + result.anim = importAnim(bdata, errors) result.physics = importPhys(bdata) - + result.lifetime = 2000.0 result.inheritVelocity = 1000.0 result.baseVelocity = 30.0 diff --git a/tests/manyloc/keineschweine/lib/sg_gui.nim b/tests/manyloc/keineschweine/lib/sg_gui.nim index 6741fe55eb..aae51baec3 100644 --- a/tests/manyloc/keineschweine/lib/sg_gui.nim +++ b/tests/manyloc/keineschweine/lib/sg_gui.nim @@ -1,5 +1,5 @@ import - sfml, sfml_colors, + sfml, sfml_colors, input_helpers, sg_packets from strutils import countlines {.deadCodeElim: on.} @@ -63,7 +63,7 @@ proc click*(b: PButton; p: TVector2f) proc setPosition*(b: PButton; p: TVector2f) proc setString*(b: PButton; s: string) {.inline.} -proc newButton*(container: PGuiContainer; text: string; position: TVector2f; +proc newButton*(container: PGuiContainer; text: string; position: TVector2f; onClick: TButtonClicked; startEnabled: bool = true): PButton {.discardable.} proc init(b: PButton; text: string; position: TVector2f; onClick: TButtonClicked) proc setEnabled*(b: PButton; enabled: bool) @@ -91,7 +91,7 @@ proc newGuiContainer*(): PGuiContainer = proc newGuiContainer*(pos: TVector2f): PGuiContainer = result = newGuiContainer() result.setPosition pos -proc free*(container: PGuiContainer) = +proc free*(container: PGuiContainer) = container.widgets = nil container.buttons = nil proc add*(container: PGuiContainer; widget: PGuiObject) = @@ -128,9 +128,9 @@ proc newButton*(container: PGuiContainer; text: string; position: TVector2f; onClick: TButtonClicked; startEnabled: bool = true): PButton = new(result, free) - init(result, - text, - if not container.isNil: position + container.position else: position, + init(result, + text, + if not container.isNil: position + container.position else: position, onClick) container.add result if not startEnabled: disable(result) @@ -168,13 +168,13 @@ proc setPosition*(b: PButton, p: TVector2f) = b.bounds = b.text.getGlobalBounds() proc setString*(b: PButton; s: string) = b.text.setString(s) -proc click*(b: PButton, p: TVector2f) = - if b.enabled and (addr b.bounds).contains(p.x, p.y): +proc click*(b: PButton, p: TVector2f) = + if b.enabled and (addr b.bounds).contains(p.x, p.y): b.onClick(b) proc free(obj: PTextEntry) = free(PButton(obj)) -proc newTextEntry*(container: PGuiContainer; text: string; +proc newTextEntry*(container: PGuiContainer; text: string; position: TVector2F; onEnter: TInputFinishedProc = nil): PTextEntry = new(result, free) init(PButton(result), text, position + container.position, proc(b: PButton) = @@ -210,7 +210,7 @@ proc add*(m: PMessageArea, text: string): PText = pos.y -= 16.0 proc draw*(window: PRenderWindow; m: PMessageArea) = - let nmsgs = len(m.messages) + let nmsgs = len(m.messages) if nmsgs == 0: return for i in countdown(nmsgs - 1, max(nmsgs - 30, 0)): window.draw(m.messages[i]) @@ -224,11 +224,11 @@ proc newMessageArea*(container: PGuiContainer; position: TVector2f): PMessageAre result.scrollBack = 0 result.direction = -1 ## to push old messages up container.add(result) - + proc add*(m: PMessageArea, msg: ScChat) = const prependName = {CPub, CPriv} var mmm: TMessage - if msg.kind in prependName: + if msg.kind in prependName: mmm.text = "<" mmm.text.add msg.fromPlayer mmm.text.add "> " @@ -239,9 +239,9 @@ proc add*(m: PMessageArea, msg: ScChat) = of CPub: mmm.color = RoyalBlue of CPriv, CSystem: mmm.color = Green of CError: mmm.color = Red - + mmm.lines = countLines(mmm.text)+1 - + m.messages.add mmm update m proc add*(m: PMessageArea, msg: string) {.inline.} = @@ -249,7 +249,7 @@ proc add*(m: PMessageArea, msg: string) {.inline.} = add(m, chat) proc proctor*(m: PText; msg: ptr TMessage; pos: ptr TVector2f) = - m.setString msg.text + m.setString msg.text m.setColor msg.color m.setPosition pos[] proc update*(m: PMessageArea) = @@ -263,7 +263,7 @@ proc update*(m: PMessageArea) = for i in m.sizeVisible.. < m.texts.len: m.texts.pop().destroy() let nmsgs = m.messages.len() - if m.sizeVisible == 0 or nmsgs == 0: + if m.sizeVisible == 0 or nmsgs == 0: echo "no messages? ", m.sizeVisible, ", ", nmsgs return var pos = vec2f(m.pos.x, m.pos.y) @@ -271,7 +271,7 @@ proc update*(m: PMessageArea) = ##echo nmsgs - i - 1 - m.scrollBack let msg = addr m.messages[nmsgs - i - 1 - m.scrollBack] proctor(m.texts[i], msg, addr pos) - pos.y += (16 * m.direction * msg.lines).cfloat + pos.y += (16 * m.direction * msg.lines).cfloat proc draw*(window: PRenderWindow; m: PMessageArea) = let nmsgs = len(m.texts) diff --git a/tests/manyloc/keineschweine/lib/sg_packets.nim b/tests/manyloc/keineschweine/lib/sg_packets.nim index 601054b473..d84bf72fc4 100644 --- a/tests/manyloc/keineschweine/lib/sg_packets.nim +++ b/tests/manyloc/keineschweine/lib/sg_packets.nim @@ -33,7 +33,7 @@ defPacket(Poing, tuple[id: int32, time: float32]) type ChatType* = enum CPub = 0'i8, CPriv, CSystem, CError forwardPacketT(ChatType, int8) -idPacket(Chat, 'C', +idPacket(Chat, 'C', tuple[kind: ChatType = CPub; fromPlayer: string = ""; text: string = ""], tuple[target: string = ""; text: string = ""]) @@ -65,8 +65,8 @@ defPacket(ScSpawn, tuple[ type TAssetType* = enum - FDummy, - FZoneCfg, FGraphics, FSound + FDummy, + FZoneCfg, FGraphics, FSound forwardPacketT(TAssetType, int8) forwardPacket(MD5Digest, array[0..15, int8]) @@ -93,7 +93,7 @@ let HVerifyClient* = 'v' defPacket(SdVerifyClient, tuple[session: ScLogin]) when isMainModule: - + var buf = newBuffer(100) var m = toMd5("hello there") echo(repr(m)) @@ -101,7 +101,7 @@ when isMainModule: echo(repr(buf.data)) echo(len(buf.data)) - + buf.reset() var x = buf.readMD5Digest() diff --git a/tests/manyloc/keineschweine/lib/vehicles.nim b/tests/manyloc/keineschweine/lib/vehicles.nim index 4b11856c6c..94ebf9f572 100644 --- a/tests/manyloc/keineschweine/lib/vehicles.nim +++ b/tests/manyloc/keineschweine/lib/vehicles.nim @@ -1,5 +1,5 @@ import - sfml, chipmunk, + sfml, chipmunk, sg_assets, sfml_stuff, keineschweine diff --git a/tests/manyloc/keineschweine/lib/wingl.nim b/tests/manyloc/keineschweine/lib/wingl.nim index 7ed78f9707..5bd199911b 100644 --- a/tests/manyloc/keineschweine/lib/wingl.nim +++ b/tests/manyloc/keineschweine/lib/wingl.nim @@ -1,9 +1,9 @@ -import +import gl, windows -proc wglGetExtensionsStringARB*(hdc: HDC): cstring{.dynlib: dllname, +proc wglGetExtensionsStringARB*(hdc: HDC): cstring{.dynlib: dllname, importc: "wglGetExtensionsStringARB".} -const +const WGL_FRONT_COLOR_BUFFER_BIT_ARB* = 0x00000001 WGL_BACK_COLOR_BUFFER_BIT_ARB* = 0x00000002 WGL_DEPTH_BUFFER_BIT_ARB* = 0x00000004 @@ -13,21 +13,21 @@ proc WinChoosePixelFormat*(DC: HDC, p2: PPixelFormatDescriptor): int{. dynlib: "gdi32", importc: "ChoosePixelFormat".} proc wglCreateBufferRegionARB*(hDC: HDC, iLayerPlane: TGLint, uType: TGLuint): THandle{. dynlib: dllname, importc: "wglCreateBufferRegionARB".} -proc wglDeleteBufferRegionARB*(hRegion: THandle){.dynlib: dllname, +proc wglDeleteBufferRegionARB*(hRegion: THandle){.dynlib: dllname, importc: "wglDeleteBufferRegionARB".} -proc wglSaveBufferRegionARB*(hRegion: THandle, x: TGLint, y: TGLint, +proc wglSaveBufferRegionARB*(hRegion: THandle, x: TGLint, y: TGLint, width: TGLint, height: TGLint): BOOL{. dynlib: dllname, importc: "wglSaveBufferRegionARB".} -proc wglRestoreBufferRegionARB*(hRegion: THandle, x: TGLint, y: TGLint, - width: TGLint, height: TGLint, xSrc: TGLint, - ySrc: TGLint): BOOL{.dynlib: dllname, +proc wglRestoreBufferRegionARB*(hRegion: THandle, x: TGLint, y: TGLint, + width: TGLint, height: TGLint, xSrc: TGLint, + ySrc: TGLint): BOOL{.dynlib: dllname, importc: "wglRestoreBufferRegionARB".} -proc wglAllocateMemoryNV*(size: TGLsizei, readFrequency: TGLfloat, +proc wglAllocateMemoryNV*(size: TGLsizei, readFrequency: TGLfloat, writeFrequency: TGLfloat, priority: TGLfloat): PGLvoid{. dynlib: dllname, importc: "wglAllocateMemoryNV".} -proc wglFreeMemoryNV*(pointer: PGLvoid){.dynlib: dllname, +proc wglFreeMemoryNV*(pointer: PGLvoid){.dynlib: dllname, importc: "wglFreeMemoryNV".} -const +const WGL_IMAGE_BUFFER_MIN_ACCESS_I3D* = 0x00000001 WGL_IMAGE_BUFFER_LOCK_I3D* = 0x00000002 @@ -35,30 +35,30 @@ proc wglCreateImageBufferI3D*(hDC: HDC, dwSize: DWORD, uFlags: UINT): PGLvoid{. dynlib: dllname, importc: "wglCreateImageBufferI3D".} proc wglDestroyImageBufferI3D*(hDC: HDC, pAddress: PGLvoid): BOOL{. dynlib: dllname, importc: "wglDestroyImageBufferI3D".} -proc wglAssociateImageBufferEventsI3D*(hdc: HDC, pEvent: PHandle, - pAddress: PGLvoid, pSize: PDWORD, - count: UINT): BOOL{.dynlib: dllname, +proc wglAssociateImageBufferEventsI3D*(hdc: HDC, pEvent: PHandle, + pAddress: PGLvoid, pSize: PDWORD, + count: UINT): BOOL{.dynlib: dllname, importc: "wglAssociateImageBufferEventsI3D".} proc wglReleaseImageBufferEventsI3D*(hdc: HDC, pAddress: PGLvoid, count: UINT): BOOL{. dynlib: dllname, importc: "wglReleaseImageBufferEventsI3D".} -proc wglEnableFrameLockI3D*(): BOOL{.dynlib: dllname, +proc wglEnableFrameLockI3D*(): BOOL{.dynlib: dllname, importc: "wglEnableFrameLockI3D".} -proc wglDisableFrameLockI3D*(): BOOL{.dynlib: dllname, +proc wglDisableFrameLockI3D*(): BOOL{.dynlib: dllname, importc: "wglDisableFrameLockI3D".} -proc wglIsEnabledFrameLockI3D*(pFlag: PBOOL): BOOL{.dynlib: dllname, +proc wglIsEnabledFrameLockI3D*(pFlag: PBOOL): BOOL{.dynlib: dllname, importc: "wglIsEnabledFrameLockI3D".} -proc wglQueryFrameLockMasterI3D*(pFlag: PBOOL): BOOL{.dynlib: dllname, +proc wglQueryFrameLockMasterI3D*(pFlag: PBOOL): BOOL{.dynlib: dllname, importc: "wglQueryFrameLockMasterI3D".} -proc wglGetFrameUsageI3D*(pUsage: PGLfloat): BOOL{.dynlib: dllname, +proc wglGetFrameUsageI3D*(pUsage: PGLfloat): BOOL{.dynlib: dllname, importc: "wglGetFrameUsageI3D".} -proc wglBeginFrameTrackingI3D*(): BOOL{.dynlib: dllname, +proc wglBeginFrameTrackingI3D*(): BOOL{.dynlib: dllname, importc: "wglBeginFrameTrackingI3D".} -proc wglEndFrameTrackingI3D*(): BOOL{.dynlib: dllname, +proc wglEndFrameTrackingI3D*(): BOOL{.dynlib: dllname, importc: "wglEndFrameTrackingI3D".} -proc wglQueryFrameTrackingI3D*(pFrameCount: PDWORD, pMissedFrames: PDWORD, +proc wglQueryFrameTrackingI3D*(pFrameCount: PDWORD, pMissedFrames: PDWORD, pLastMissedUsage: PGLfloat): BOOL{. dynlib: dllname, importc: "wglQueryFrameTrackingI3D".} -const +const WGL_NUMBER_PIXEL_FORMATS_ARB* = 0x00002000 WGL_DRAW_TO_WINDOW_ARB* = 0x00002001 WGL_DRAW_TO_BITMAP_ARB* = 0x00002002 @@ -109,27 +109,27 @@ const WGL_TYPE_RGBA_ARB* = 0x0000202B WGL_TYPE_COLORINDEX_ARB* = 0x0000202C -proc wglGetPixelFormatAttribivARB*(hdc: HDC, iPixelFormat: TGLint, - iLayerPlane: TGLint, nAttributes: TGLuint, +proc wglGetPixelFormatAttribivARB*(hdc: HDC, iPixelFormat: TGLint, + iLayerPlane: TGLint, nAttributes: TGLuint, piAttributes: PGLint, piValues: PGLint): BOOL{. dynlib: dllname, importc: "wglGetPixelFormatAttribivARB".} -proc wglGetPixelFormatAttribfvARB*(hdc: HDC, iPixelFormat: TGLint, - iLayerPlane: TGLint, nAttributes: TGLuint, +proc wglGetPixelFormatAttribfvARB*(hdc: HDC, iPixelFormat: TGLint, + iLayerPlane: TGLint, nAttributes: TGLuint, piAttributes: PGLint, pfValues: PGLfloat): BOOL{. dynlib: dllname, importc: "wglGetPixelFormatAttribfvARB".} -proc wglChoosePixelFormatARB*(hdc: HDC, piAttribIList: PGLint, - pfAttribFList: PGLfloat, nMaxFormats: TGLuint, +proc wglChoosePixelFormatARB*(hdc: HDC, piAttribIList: PGLint, + pfAttribFList: PGLfloat, nMaxFormats: TGLuint, piFormats: PGLint, nNumFormats: PGLuint): BOOL{. dynlib: dllname, importc: "wglChoosePixelFormatARB".} -const +const WGL_ERROR_INVALID_PIXEL_TYPE_ARB* = 0x00002043 WGL_ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB* = 0x00002054 proc wglMakeContextCurrentARB*(hDrawDC: HDC, hReadDC: HDC, hglrc: HGLRC): BOOL{. dynlib: dllname, importc: "wglMakeContextCurrentARB".} -proc wglGetCurrentReadDCARB*(): HDC{.dynlib: dllname, +proc wglGetCurrentReadDCARB*(): HDC{.dynlib: dllname, importc: "wglGetCurrentReadDCARB".} -const +const WGL_DRAW_TO_PBUFFER_ARB* = 0x0000202D # WGL_DRAW_TO_PBUFFER_ARB { already defined } WGL_MAX_PBUFFER_PIXELS_ARB* = 0x0000202E WGL_MAX_PBUFFER_WIDTH_ARB* = 0x0000202F @@ -139,22 +139,22 @@ const WGL_PBUFFER_HEIGHT_ARB* = 0x00002035 WGL_PBUFFER_LOST_ARB* = 0x00002036 -proc wglCreatePbufferARB*(hDC: HDC, iPixelFormat: TGLint, iWidth: TGLint, +proc wglCreatePbufferARB*(hDC: HDC, iPixelFormat: TGLint, iWidth: TGLint, iHeight: TGLint, piAttribList: PGLint): THandle{. dynlib: dllname, importc: "wglCreatePbufferARB".} -proc wglGetPbufferDCARB*(hPbuffer: THandle): HDC{.dynlib: dllname, +proc wglGetPbufferDCARB*(hPbuffer: THandle): HDC{.dynlib: dllname, importc: "wglGetPbufferDCARB".} proc wglReleasePbufferDCARB*(hPbuffer: THandle, hDC: HDC): TGLint{. dynlib: dllname, importc: "wglReleasePbufferDCARB".} -proc wglDestroyPbufferARB*(hPbuffer: THandle): BOOL{.dynlib: dllname, +proc wglDestroyPbufferARB*(hPbuffer: THandle): BOOL{.dynlib: dllname, importc: "wglDestroyPbufferARB".} proc wglQueryPbufferARB*(hPbuffer: THandle, iAttribute: TGLint, piValue: PGLint): BOOL{. dynlib: dllname, importc: "wglQueryPbufferARB".} -proc wglSwapIntervalEXT*(interval: TGLint): BOOL{.dynlib: dllname, +proc wglSwapIntervalEXT*(interval: TGLint): BOOL{.dynlib: dllname, importc: "wglSwapIntervalEXT".} -proc wglGetSwapIntervalEXT*(): TGLint{.dynlib: dllname, +proc wglGetSwapIntervalEXT*(): TGLint{.dynlib: dllname, importc: "wglGetSwapIntervalEXT".} -const +const WGL_BIND_TO_TEXTURE_RGB_ARB* = 0x00002070 WGL_BIND_TO_TEXTURE_RGBA_ARB* = 0x00002071 WGL_TEXTURE_FORMAT_ARB* = 0x00002072 @@ -195,13 +195,13 @@ proc wglReleaseTexImageARB*(hPbuffer: THandle, iBuffer: TGLint): BOOL{. dynlib: dllname, importc: "wglReleaseTexImageARB".} proc wglSetPbufferAttribARB*(hPbuffer: THandle, piAttribList: PGLint): BOOL{. dynlib: dllname, importc: "wglSetPbufferAttribARB".} -proc wglGetExtensionsStringEXT*(): cstring{.dynlib: dllname, +proc wglGetExtensionsStringEXT*(): cstring{.dynlib: dllname, importc: "wglGetExtensionsStringEXT".} proc wglMakeContextCurrentEXT*(hDrawDC: HDC, hReadDC: HDC, hglrc: HGLRC): BOOL{. dynlib: dllname, importc: "wglMakeContextCurrentEXT".} -proc wglGetCurrentReadDCEXT*(): HDC{.dynlib: dllname, +proc wglGetCurrentReadDCEXT*(): HDC{.dynlib: dllname, importc: "wglGetCurrentReadDCEXT".} -const +const WGL_DRAW_TO_PBUFFER_EXT* = 0x0000202D WGL_MAX_PBUFFER_PIXELS_EXT* = 0x0000202E WGL_MAX_PBUFFER_WIDTH_EXT* = 0x0000202F @@ -212,18 +212,18 @@ const WGL_PBUFFER_WIDTH_EXT* = 0x00002034 WGL_PBUFFER_HEIGHT_EXT* = 0x00002035 -proc wglCreatePbufferEXT*(hDC: HDC, iPixelFormat: TGLint, iWidth: TGLint, +proc wglCreatePbufferEXT*(hDC: HDC, iPixelFormat: TGLint, iWidth: TGLint, iHeight: TGLint, piAttribList: PGLint): THandle{. dynlib: dllname, importc: "wglCreatePbufferEXT".} -proc wglGetPbufferDCEXT*(hPbuffer: THandle): HDC{.dynlib: dllname, +proc wglGetPbufferDCEXT*(hPbuffer: THandle): HDC{.dynlib: dllname, importc: "wglGetPbufferDCEXT".} proc wglReleasePbufferDCEXT*(hPbuffer: THandle, hDC: HDC): TGLint{. dynlib: dllname, importc: "wglReleasePbufferDCEXT".} -proc wglDestroyPbufferEXT*(hPbuffer: THandle): BOOL{.dynlib: dllname, +proc wglDestroyPbufferEXT*(hPbuffer: THandle): BOOL{.dynlib: dllname, importc: "wglDestroyPbufferEXT".} proc wglQueryPbufferEXT*(hPbuffer: THandle, iAttribute: TGLint, piValue: PGLint): BOOL{. dynlib: dllname, importc: "wglQueryPbufferEXT".} -const +const WGL_NUMBER_PIXEL_FORMATS_EXT* = 0x00002000 WGL_DRAW_TO_WINDOW_EXT* = 0x00002001 WGL_DRAW_TO_BITMAP_EXT* = 0x00002002 @@ -270,47 +270,47 @@ const WGL_TYPE_RGBA_EXT* = 0x0000202B WGL_TYPE_COLORINDEX_EXT* = 0x0000202C -proc wglGetPixelFormatAttribivEXT*(hdc: HDC, iPixelFormat: TGLint, - iLayerPlane: TGLint, nAttributes: TGLuint, +proc wglGetPixelFormatAttribivEXT*(hdc: HDC, iPixelFormat: TGLint, + iLayerPlane: TGLint, nAttributes: TGLuint, piAttributes: PGLint, piValues: PGLint): BOOL{. dynlib: dllname, importc: "wglGetPixelFormatAttribivEXT".} -proc wglGetPixelFormatAttribfvEXT*(hdc: HDC, iPixelFormat: TGLint, - iLayerPlane: TGLint, nAttributes: TGLuint, +proc wglGetPixelFormatAttribfvEXT*(hdc: HDC, iPixelFormat: TGLint, + iLayerPlane: TGLint, nAttributes: TGLuint, piAttributes: PGLint, pfValues: PGLfloat): BOOL{. dynlib: dllname, importc: "wglGetPixelFormatAttribfvEXT".} -proc wglChoosePixelFormatEXT*(hdc: HDC, piAttribIList: PGLint, - pfAttribFList: PGLfloat, nMaxFormats: TGLuint, +proc wglChoosePixelFormatEXT*(hdc: HDC, piAttribIList: PGLint, + pfAttribFList: PGLfloat, nMaxFormats: TGLuint, piFormats: PGLint, nNumFormats: PGLuint): BOOL{. dynlib: dllname, importc: "wglChoosePixelFormatEXT".} -const +const WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D* = 0x00002050 WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D* = 0x00002051 WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D* = 0x00002052 WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D* = 0x00002053 -proc wglGetDigitalVideoParametersI3D*(hDC: HDC, iAttribute: TGLint, - piValue: PGLint): BOOL{.dynlib: dllname, +proc wglGetDigitalVideoParametersI3D*(hDC: HDC, iAttribute: TGLint, + piValue: PGLint): BOOL{.dynlib: dllname, importc: "wglGetDigitalVideoParametersI3D".} -proc wglSetDigitalVideoParametersI3D*(hDC: HDC, iAttribute: TGLint, - piValue: PGLint): BOOL{.dynlib: dllname, +proc wglSetDigitalVideoParametersI3D*(hDC: HDC, iAttribute: TGLint, + piValue: PGLint): BOOL{.dynlib: dllname, importc: "wglSetDigitalVideoParametersI3D".} -const +const WGL_GAMMA_TABLE_SIZE_I3D* = 0x0000204E WGL_GAMMA_EXCLUDE_DESKTOP_I3D* = 0x0000204F -proc wglGetGammaTableParametersI3D*(hDC: HDC, iAttribute: TGLint, - piValue: PGLint): BOOL{.dynlib: dllname, +proc wglGetGammaTableParametersI3D*(hDC: HDC, iAttribute: TGLint, + piValue: PGLint): BOOL{.dynlib: dllname, importc: "wglGetGammaTableParametersI3D".} -proc wglSetGammaTableParametersI3D*(hDC: HDC, iAttribute: TGLint, - piValue: PGLint): BOOL{.dynlib: dllname, +proc wglSetGammaTableParametersI3D*(hDC: HDC, iAttribute: TGLint, + piValue: PGLint): BOOL{.dynlib: dllname, importc: "wglSetGammaTableParametersI3D".} -proc wglGetGammaTableI3D*(hDC: HDC, iEntries: TGLint, puRed: PGLUSHORT, +proc wglGetGammaTableI3D*(hDC: HDC, iEntries: TGLint, puRed: PGLUSHORT, puGreen: PGLUSHORT, puBlue: PGLUSHORT): BOOL{. dynlib: dllname, importc: "wglGetGammaTableI3D".} -proc wglSetGammaTableI3D*(hDC: HDC, iEntries: TGLint, puRed: PGLUSHORT, +proc wglSetGammaTableI3D*(hDC: HDC, iEntries: TGLint, puRed: PGLUSHORT, puGreen: PGLUSHORT, puBlue: PGLUSHORT): BOOL{. dynlib: dllname, importc: "wglSetGammaTableI3D".} -const +const WGL_GENLOCK_SOURCE_MULTIVIEW_I3D* = 0x00002044 WGL_GENLOCK_SOURCE_EXTERNAL_SYNC_I3D* = 0x00002045 WGL_GENLOCK_SOURCE_EXTERNAL_FIELD_I3D* = 0x00002046 @@ -330,21 +330,21 @@ const WGL_TEXTURE_FLOAT_RGB_NV* = 0x000020B7 WGL_TEXTURE_FLOAT_RGBA_NV* = 0x000020B8 -proc wglEnableGenlockI3D*(hDC: HDC): BOOL{.dynlib: dllname, +proc wglEnableGenlockI3D*(hDC: HDC): BOOL{.dynlib: dllname, importc: "wglEnableGenlockI3D".} -proc wglDisableGenlockI3D*(hDC: HDC): BOOL{.dynlib: dllname, +proc wglDisableGenlockI3D*(hDC: HDC): BOOL{.dynlib: dllname, importc: "wglDisableGenlockI3D".} -proc wglIsEnabledGenlockI3D*(hDC: HDC, pFlag: PBOOL): BOOL{.dynlib: dllname, +proc wglIsEnabledGenlockI3D*(hDC: HDC, pFlag: PBOOL): BOOL{.dynlib: dllname, importc: "wglIsEnabledGenlockI3D".} -proc wglGenlockSourceI3D*(hDC: HDC, uSource: TGLuint): BOOL{.dynlib: dllname, +proc wglGenlockSourceI3D*(hDC: HDC, uSource: TGLuint): BOOL{.dynlib: dllname, importc: "wglGenlockSourceI3D".} -proc wglGetGenlockSourceI3D*(hDC: HDC, uSource: PGLUINT): BOOL{.dynlib: dllname, +proc wglGetGenlockSourceI3D*(hDC: HDC, uSource: PGLUINT): BOOL{.dynlib: dllname, importc: "wglGetGenlockSourceI3D".} -proc wglGenlockSourceEdgeI3D*(hDC: HDC, uEdge: TGLuint): BOOL{.dynlib: dllname, +proc wglGenlockSourceEdgeI3D*(hDC: HDC, uEdge: TGLuint): BOOL{.dynlib: dllname, importc: "wglGenlockSourceEdgeI3D".} proc wglGetGenlockSourceEdgeI3D*(hDC: HDC, uEdge: PGLUINT): BOOL{. dynlib: dllname, importc: "wglGetGenlockSourceEdgeI3D".} -proc wglGenlockSampleRateI3D*(hDC: HDC, uRate: TGLuint): BOOL{.dynlib: dllname, +proc wglGenlockSampleRateI3D*(hDC: HDC, uRate: TGLuint): BOOL{.dynlib: dllname, importc: "wglGenlockSampleRateI3D".} proc wglGetGenlockSampleRateI3D*(hDC: HDC, uRate: PGLUINT): BOOL{. dynlib: dllname, importc: "wglGetGenlockSampleRateI3D".} @@ -352,15 +352,15 @@ proc wglGenlockSourceDelayI3D*(hDC: HDC, uDelay: TGLuint): BOOL{. dynlib: dllname, importc: "wglGenlockSourceDelayI3D".} proc wglGetGenlockSourceDelayI3D*(hDC: HDC, uDelay: PGLUINT): BOOL{. dynlib: dllname, importc: "wglGetGenlockSourceDelayI3D".} -proc wglQueryGenlockMaxSourceDelayI3D*(hDC: HDC, uMaxLineDelay: PGLUINT, +proc wglQueryGenlockMaxSourceDelayI3D*(hDC: HDC, uMaxLineDelay: PGLUINT, uMaxPixelDelay: PGLUINT): BOOL{. dynlib: dllname, importc: "wglQueryGenlockMaxSourceDelayI3D".} -const +const WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV* = 0x000020A0 WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV* = 0x000020A1 WGL_TEXTURE_RECTANGLE_NV* = 0x000020A2 -const +const WGL_RGBA_FLOAT_MODE_ATI* = 0x00008820 WGL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI* = 0x00008835 WGL_TYPE_RGBA_FLOAT_ATI* = 0x000021A0 diff --git a/tests/manyloc/keineschweine/lib/zlib_helpers.nim b/tests/manyloc/keineschweine/lib/zlib_helpers.nim index fcd0e8d245..5241a77c0a 100644 --- a/tests/manyloc/keineschweine/lib/zlib_helpers.nim +++ b/tests/manyloc/keineschweine/lib/zlib_helpers.nim @@ -18,7 +18,7 @@ proc uncompress*(source: string, destLen: var int): string = var res = zlib.uncompress(cstring(result), addr destLen, cstring(source), source.len) if res != Z_OK: echo "Error occurred: ", res - + when isMainModule: import strutils @@ -37,4 +37,4 @@ when isMainModule: ln = s.len rr = uncompress(r, ln) echo r.len, " -> ", rr.len - assert rr == s \ No newline at end of file + assert rr == s diff --git a/tests/manyloc/keineschweine/server/old_dirserver.nim b/tests/manyloc/keineschweine/server/old_dirserver.nim index 897fc7d32f..202dc6fe71 100644 --- a/tests/manyloc/keineschweine/server/old_dirserver.nim +++ b/tests/manyloc/keineschweine/server/old_dirserver.nim @@ -17,7 +17,7 @@ var ## I was high. clients = initTable[TupAddress, PClient](16) alias2client = initTable[string, PClient](32) - allClients: seq[PClient] = @[] + allClients: seq[PClient] = @[] proc findClient*(host: string; port: int16): PClient = let addy: TupAddress = (host, port) @@ -37,7 +37,7 @@ proc loginZone(client: PClient; login: SdZoneLogin): bool = result = true break -proc sendZoneList(client: PClient) = +proc sendZoneList(client: PClient) = echo(">> zonelist ", client, ' ', HZoneList) client.send(HZonelist, zonelist) proc forwardPrivate(rcv: PClient; sender: PClient; txt: string) = @@ -93,7 +93,7 @@ proc sendServMsg(client: PClient; msg: string) = var m = newDsMsg(msg) client.send HDsMsg, m handlers[HZoneLogin] = proc(client: PClient; stream: PStream) = - var + var login = readSdZoneLogin(stream) if not client.loginZone(login): client.sendServMsg "Invalid login" @@ -110,7 +110,7 @@ handlers[HFileChallenge] = proc(client: PClient; stream: PStream) = var chg = readScFileChallenge(stream) proc handlePkt(s: PClient; stream: PStream) = - while not stream.atEnd: + while not stream.atEnd: var typ = readChar(stream) if not handlers.hasKey(typ): break @@ -128,7 +128,7 @@ var clientIndex = 0 var incoming = newIncomingBuffer() proc poll*(timeout: int = 250) = if server.isNil: return - var + var reads = @[server] writes = @[server] if select(reads, timeout) > 0: @@ -163,7 +163,7 @@ when isMainModule: case kind of cmdShortOption, cmdLongOption: case key - of "f", "file": + of "f", "file": if existsFile(val): cfgFile = val else: @@ -177,14 +177,14 @@ when isMainModule: zonelist.network = jsonSettings["network"].str for slot in jsonSettings["zones"].items: zoneSlots.add((slot["name"].str, slot["key"].str)) - + createServer(port) echo("Listening on port ", port, "...") var pubChatTimer = cpuTime() #newClock() const PubChatDelay = 1000/1000 while true: poll(15) - ## TODO sort this type of thing VV into a queue api + ## TODO sort this type of thing VV into a queue api if cpuTime() - pubChatTimer > PubChatDelay: #.getElapsedTime.asMilliseconds > 100: pubChatTimer -= pubChatDelay if pubChatQueue.getPosition > 0: diff --git a/tests/manyloc/keineschweine/server/old_server_utils.nim b/tests/manyloc/keineschweine/server/old_server_utils.nim index af9a1b01e5..d0fd39ae0a 100644 --- a/tests/manyloc/keineschweine/server/old_server_utils.nim +++ b/tests/manyloc/keineschweine/server/old_server_utils.nim @@ -1,4 +1,4 @@ -import +import streams, md5, sockets, unsigned, sg_packets, zlib_helpers, idgen type @@ -54,7 +54,7 @@ proc newClient*(addy: TupAddress): PClient = new(result, free) result.addy = addy result.outputBuf = newStringStream("") - result.outputBuf.flushImpl = proc(stream: PStream) = + result.outputBuf.flushImpl = proc(stream: PStream) = stream.setPosition 0 PStringStream(stream).data.setLen 0 diff --git a/tests/manyloc/keineschweine/server/old_sg_server.nim b/tests/manyloc/keineschweine/server/old_sg_server.nim index 1e57c12a1a..c326720fe2 100644 --- a/tests/manyloc/keineschweine/server/old_sg_server.nim +++ b/tests/manyloc/keineschweine/server/old_sg_server.nim @@ -9,13 +9,13 @@ var ## I was high. clients = initTable[TupAddress, PClient](16) alias2client = initTable[string, PClient](32) - allClients: seq[PClient] = @[] - zonePlayers: seq[PClient] = @[] + allClients: seq[PClient] = @[] + zonePlayers: seq[PClient] = @[] const PubChatDelay = 100/1000 #100 ms import hashes -proc hash*(x: uint16): THash {.inline.} = +proc hash*(x: uint16): THash {.inline.} = result = int32(x) proc findClient*(host: string; port: int16): PClient = @@ -27,7 +27,7 @@ proc findClient*(host: string; port: int16): PClient = allClients.add(result) -proc sendZoneList(client: PClient) = +proc sendZoneList(client: PClient) = echo(">> zonelist ", client) #client.send(HZonelist, zonelist) @@ -83,7 +83,7 @@ handlers[HZoneQuery] = proc(client: PClient; stream: PStream) = handlers[HZoneJoinReq] = proc(client: PClient; stream: PStream) = var req = readCsZoneJoinReq(stream) - echo "Join zone request from (",req.session.id,") ", req.session.alias + echo "Join zone request from (",req.session.id,") ", req.session.alias if client.auth and client.kind == CPlayer: echo "Client is authenticated, verifying filez" client.startVerifyingFiles() @@ -97,7 +97,7 @@ handlers[HZoneJoinReq] = proc(client: PClient; stream: PStream) = proc handlePkt(s: PClient; stream: PStream) = - while not stream.atEnd: + while not stream.atEnd: var typ = readChar(stream) if not handlers.hasKey(typ): break @@ -114,7 +114,7 @@ var clientIndex = 0 var incoming = newIncomingBuffer() proc poll*(timeout: int = 250) = if server.isNil: return - var + var reads = @[server] writes = @[server] if select(reads, timeout) > 0: @@ -148,7 +148,7 @@ when isMainModule: case kind of cmdShortOption, cmdLongOption: case key - of "f", "file": + of "f", "file": if existsFile(val): zoneCfgFile = val else: @@ -158,45 +158,45 @@ when isMainModule: else: echo("Unknown option: ", key, " ", val) var jsonSettings = parseFile(zoneCfgFile) - let + let host = jsonSettings["host"].str port = TPort(jsonSettings["port"].num) zoneFile = jsonSettings["settings"].str dirServerInfo = jsonSettings["dirserver"] - + var path = getAppDir()/../"data"/zoneFile if not existsFile(path): echo("Zone settings file does not exist: ../data/", zoneFile) echo(path) quit(1) - + ## Test file block: - var + var TestFile: FileChallengePair contents = repeat("abcdefghijklmnopqrstuvwxyz", 2) - testFile.challenge = newScFileChallenge("foobar.test", FZoneCfg, contents.len.int32) + testFile.challenge = newScFileChallenge("foobar.test", FZoneCfg, contents.len.int32) testFile.file = checksumStr(contents) myAssets.add testFile - + setCurrentDir getAppDir().parentDir() block: let zonesettings = readFile(path) - var + var errors: seq[string] = @[] if not loadSettings(zoneSettings, errors): echo("You have errors in your zone settings:") for e in errors: echo("**", e) quit(1) errors.setLen 0 - + var pair: FileChallengePair pair.challenge.file = zoneFile pair.challenge.assetType = FZoneCfg pair.challenge.fullLen = zoneSettings.len.int32 pair.file = checksumStr(zoneSettings) myAssets.add pair - + allAssets: if not load(asset): echo "Invalid or missing file ", file @@ -208,10 +208,10 @@ when isMainModule: expandPath(assetType, file)).int32 pair.file = asset.contents myAssets.add pair - + echo "Zone has ", myAssets.len, " associated assets" - - + + dirServer = newServerConnection(dirServerInfo[0].str, dirServerInfo[1].num.TPort) dirServer.handlers[HDsMsg] = proc(serv: PServer; stream: PStream) = var m = readDsMsg(stream) @@ -221,18 +221,18 @@ when isMainModule: if loggedIn: dirServerConnected = true dirServer.writePkt HZoneLogin, login - + thisZone.name = jsonSettings["name"].str thisZone.desc = jsonSettings["desc"].str thisZone.ip = "localhost" thisZone.port = port var login = newSdZoneLogin( dirServerInfo[2].str, dirServerInfo[3].str, - thisZone) + thisZone) #echo "MY LOGIN: ", $login - - - + + + createServer(port) echo("Listening on port ", port, "...") var pubChatTimer = cpuTime()#newClock() @@ -240,7 +240,7 @@ when isMainModule: discard dirServer.pollServer(15) poll(15) ## TODO sort this type of thing VV into a queue api - #let now = cpuTime() + #let now = cpuTime() if cpuTime() - pubChatTimer > PubChatDelay: #.getElapsedTime.asMilliseconds > 100: pubChatTimer -= pubChatDelay #.restart() if pubChatQueue.getPosition > 0: @@ -250,5 +250,5 @@ when isMainModule: c.outputBuf.writeData(addr pubChatQueue.data[0], sizePubChat) pubChatQueue.flush() - - \ No newline at end of file + + diff --git a/tests/manyloc/keineschweine/server/sg_lobby.nim b/tests/manyloc/keineschweine/server/sg_lobby.nim index 042d723376..f130e1b54b 100644 --- a/tests/manyloc/keineschweine/server/sg_lobby.nim +++ b/tests/manyloc/keineschweine/server/sg_lobby.nim @@ -1,7 +1,7 @@ import - sockets, streams, tables, times, math, strutils, json, os, md5, - sfml, sfml_vector, sfml_colors, + sockets, streams, tables, times, math, strutils, json, os, md5, + sfml, sfml_vector, sfml_colors, streams_enh, input_helpers, zlib_helpers, client_helpers, sg_packets, sg_assets, sg_gui type TClientSettings = object @@ -33,7 +33,7 @@ var downloadProgress: PButton connectionButtons: seq[PButton] #buttons that depend on connection to function -template dispmessage(m: expr): stmt = +template dispmessage(m: expr): stmt = messageArea.add(m) proc connectZone(host: string; port: TPort) proc connectToDirserv() @@ -63,7 +63,7 @@ proc handleChat(serv: PServer; s: PStream) = proc connectToDirserv() = if dirServer.isNil: dirServer = newServerConnection(clientSettings.dirserver.host, clientSettings.dirserver.port) - dirServer.handlers[HHello] = proc(serv: PServer; s: PStream) = + dirServer.handlers[HHello] = proc(serv: PServer; s: PStream) = let msg = readScHello(s) dispMessage(msg.resp) setConnected(true) @@ -71,7 +71,7 @@ proc connectToDirserv() = mySession = readScLogin(s) ##do something here dirServer.handlers[HZonelist] = proc(serv: PServer; s: PStream) = - var + var info = readScZonelist(s) zones = info.zones if zones.len > 0: @@ -87,11 +87,11 @@ proc connectToDirserv() = var z = zones[i] zonelist.newButton( text = z.name, position = pos, - onClick = proc(b: PButton) = + onClick = proc(b: PButton) = setActiveZone(i, z)) pos.y += 20 showZonelist = true - dirServer.handlers[HPoing] = proc(serv: PServer; s: PStream) = + dirServer.handlers[HPoing] = proc(serv: PServer; s: PStream) = var ping = readPoing(s) dispmessage("Ping: "& $ping.time) ping.time = epochTime().float32 @@ -108,19 +108,19 @@ proc zoneListReq() = writePkt HZonelist, pkt ##key handlers -keyClient.registerHandler(MouseMiddle, down, proc() = +keyClient.registerHandler(MouseMiddle, down, proc() = gui.setPosition(getMousePos())) -keyClient.registerHandler(KeyO, down, proc() = +keyClient.registerHandler(KeyO, down, proc() = if keyPressed(KeyRShift): echo(repr(outgoing))) keyClient.registerHandler(KeyTab, down, proc() = activeInput = (activeInput + 1) mod 2) #does this work? -keyClient.registerHandler(MouseLeft, down, proc() = +keyClient.registerHandler(MouseLeft, down, proc() = let p = getMousePos() gui.click(p) if showZonelist: zonelist.click(p)) var mptext = newText("", guiFont, 16) -keyClient.registerHandler(MouseRight, down, proc() = +keyClient.registerHandler(MouseRight, down, proc() = let p = getMousePos() mptext.setPosition(p) mptext.setString("($1,$2)"%[$p.x.int,$p.y.int])) @@ -133,15 +133,15 @@ proc connectZone(host: string, port: TPort) = zone.handlers[HFileChallenge] = handleFileChallenge zone.handlers[HChallengeResult] = handleFileChallengeResult zone.handlers[HFileTransfer] = handleFileTransfer - zone.handlers[HChat] = handleChat + zone.handlers[HChat] = handleChat else: zone.sock.connect(host, port) var hello = newCsHello() zone.writePkt HHello, hello - -proc lobbyReady*() = + +proc lobbyReady*() = keyClient.setActive() gui.setActive(u_alias) @@ -186,27 +186,27 @@ proc lobbyInit*() = clientSettings.website = s["website"].str zonelist.setPosition(vec2f(200.0, 100.0)) connectionButtons = @[] - + downloadProgress = gui.newButton( - text = "", position = vec2f(10, 130), onClick = nil) + text = "", position = vec2f(10, 130), onClick = nil) downloadProgress.bg.setFillColor(color(34, 139, 34)) downloadProgress.bg.setSize(vec2f(0, 0)) - + var pos = vec2f(10, 10) u_alias = gui.newTextEntry( - if s.existsKey("alias"): s["alias"].str else: "alias", + if s.existsKey("alias"): s["alias"].str else: "alias", pos) pos.y += 20 u_passwd = gui.newTextEntry("buzz", pos) pos.y += 20 connectionButtons.add(gui.newButton( - text = "Login", + text = "Login", position = pos, onClick = tryLogin, startEnabled = false)) pos.y += 20 fpsText.setPosition(pos) - + playBtn = gui.newButton( text = "Play", position = vec2f(680.0, 8.0), @@ -227,7 +227,7 @@ proc lobbyInit*() = connectionButtons.add(gui.newButton( text = "Test Chat", position = vec2f(10.0, 110.0), - onClick = (proc(b: PButton) = + onClick = (proc(b: PButton) = var pkt = newCsChat(text = "ohai") writePkt HChat, pkt), startEnabled = false)) @@ -239,15 +239,15 @@ proc lobbyInit*() = gui.newButton(text = "Scrollback + 1", position = vec2f(185, 10), onClick = proc(b: PButton) = messageArea.scrollBack += 1 update(messageArea)) - gui.newButton(text = "Scrollback - 1", position = vec2f(185+160, 10), onClick = proc(b: PButton) = + gui.newButton(text = "Scrollback - 1", position = vec2f(185+160, 10), onClick = proc(b: PButton) = messageArea.scrollBack -= 1 update(messageArea)) gui.newButton(text = "Flood msg area", position = vec2f(185, 30), onClick = proc(b: PButton) = - for i in 0.. <30: + for i in 0.. <30: dispMessage($i)) var i = 0 -proc lobbyUpdate*(dt: float) = +proc lobbyUpdate*(dt: float) = #let res = disp.poll() gui.update(dt) i = (i + 1) mod 60 diff --git a/tests/manyloc/nake/nake.nim b/tests/manyloc/nake/nake.nim index 04b7450034..1e88fa73b9 100644 --- a/tests/manyloc/nake/nake.nim +++ b/tests/manyloc/nake/nake.nim @@ -3,7 +3,7 @@ DO AS THOU WILST PUBLIC LICENSE Whoever should stumble upon this document is henceforth and forever entitled to DO AS THOU WILST with aforementioned document and the -contents thereof. +contents thereof. As said in the Olde Country, `Keepe it Gangster'.""" @@ -14,7 +14,7 @@ type desc*: string action*: TTaskFunction TTaskFunction* = proc() {.closure.} -var +var tasks* = initTable[string, PTask](16) proc newTask*(desc: string; action: TTaskFunction): PTask @@ -61,7 +61,7 @@ when isMainModule: quit(shell("nim", "c", "-r", "nakefile.nim", args)) else: addQuitProc(proc() {.noconv.} = - var + var task: string printTaskList: bool for kind, key, val in getOpt(): @@ -70,7 +70,7 @@ else: case key.tolower of "tasks", "t": printTaskList = true - else: + else: echo "Unknown option: ", key, ": ", val of cmdArgument: task = key diff --git a/tests/manyloc/nake/nakefile.nim b/tests/manyloc/nake/nakefile.nim index d1d712964b..6dc453e8d6 100644 --- a/tests/manyloc/nake/nakefile.nim +++ b/tests/manyloc/nake/nakefile.nim @@ -4,7 +4,7 @@ nakeImports randomize() -const +const GameAssets = "http://dl.dropbox.com/u/37533467/data-08-01-2012.7z" BinLibs = "http://dl.dropbox.com/u/37533467/libs-2012-09-12.zip" ExeName = "keineschweine" @@ -60,7 +60,7 @@ task "release", "release build": quit 1 else: runTask "clean" - ## zip up all the files and such or something useful here + ## zip up all the files and such or something useful here task "testskel", "create skeleton test dir for testing": let dirname = "test-"& $random(5000) @@ -103,7 +103,7 @@ task "download", "download game assets": echo "Downloading to ", path downloadFile GameAssets, path echo "Download finished" - + let targetDir = parentDir(parentDir(path)) when defined(linux): let z7 = findExe("7z") @@ -117,7 +117,7 @@ task "download", "download game assets": else: echo "I do not know how to unpack the data on this system. Perhaps you could ", "fill this part in?" - + echo "Download binary libs? Only libs for linux are available currently, enjoy the irony.\n", "[Y]es [N]o Source: ", BinLibs case stdin.readline.toLower @@ -126,11 +126,11 @@ task "download", "download game assets": else: return path = extractFilename(BinLibs) - downloadFile BinLibs, path + downloadFile BinLibs, path echo "Downloaded dem libs ", path when true: echo "Unpack it yourself, sorry." else: ## this crashes, dunno why - var + var z: TZipArchive destDir = getCurrentDir()/("unzip"& $random(5000)) if not z.open(path, fmRead): @@ -152,4 +152,4 @@ task "zip-lib", "zip up the libs dir": echo "adding file ", file z.addFile(file) z.close() - echo "Great success!" \ No newline at end of file + echo "Great success!" diff --git a/tests/metatype/tbindtypedesc.nim b/tests/metatype/tbindtypedesc.nim index 84527362f0..4f027407bf 100644 --- a/tests/metatype/tbindtypedesc.nim +++ b/tests/metatype/tbindtypedesc.nim @@ -9,7 +9,7 @@ TFoo TFoo''' import typetraits -type +type TFoo = object x, y: int @@ -25,7 +25,7 @@ template reject(e: expr) = proc genericParamRepeated[T: typedesc](a: T, b: T) = static: echo a.name, " ", b.name - + accept genericParamRepeated(int, int) accept genericParamRepeated(float, float) diff --git a/tests/metatype/tconstraints.nim b/tests/metatype/tconstraints.nim index 7aef0d6453..76e738a859 100644 --- a/tests/metatype/tconstraints.nim +++ b/tests/metatype/tconstraints.nim @@ -1,6 +1,6 @@ -proc myGenericProc[T: object|tuple|int|ptr|ref|distinct](x: T): string = +proc myGenericProc[T: object|tuple|int|ptr|ref|distinct](x: T): string = result = $x type diff --git a/tests/metatype/tmatrix.nim b/tests/metatype/tmatrix.nim index 90dfde959a..5acd4389e3 100644 --- a/tests/metatype/tmatrix.nim +++ b/tests/metatype/tmatrix.nim @@ -11,7 +11,7 @@ type template `|`(x, y: int): expr = y * m.fWidth + x -proc createMatrix*(width, height: int): TMatrix = +proc createMatrix*(width, height: int): TMatrix = result.fWidth = width result.fHeight = height newSeq(result.data, width*height) @@ -24,7 +24,7 @@ proc `[]`*(m: TMatrix, x, y: int): float {.inline.} = proc `[]=`*(m: var TMatrix, x, y: int, val: float) {.inline.} = m.data[x|y] = val - + proc `-|`*(m: TMatrix): TMatrix = ## transposes a matrix result = createMatrix(m.height, m.width) diff --git a/tests/metatype/tmatrix1.nim b/tests/metatype/tmatrix1.nim index 0adf30b57b..0f325a17b6 100644 --- a/tests/metatype/tmatrix1.nim +++ b/tests/metatype/tmatrix1.nim @@ -3,7 +3,7 @@ discard """ """ type - TMatrixNM*[M, N, T] = object + TMatrixNM*[M, N, T] = object aij*: array[M, array[N, T]] TMatrix2x2*[T] = TMatrixNM[range[0..1], range[0..1], T] TMatrix3x3*[T] = TMatrixNM[range[0..2], range[0..2], T] @@ -12,7 +12,7 @@ proc test*[T] (matrix: TMatrix2x2[T]) = echo "wrong proc called" proc test*[T] (matrix: TMatrix3x3[T]) = - echo "right proc called" + echo "right proc called" var matrix: TMatrix3x3[float] diff --git a/tests/metatype/tmatrix2.nim b/tests/metatype/tmatrix2.nim index 82990f1a59..bad0213905 100644 --- a/tests/metatype/tmatrix2.nim +++ b/tests/metatype/tmatrix2.nim @@ -3,7 +3,7 @@ discard """ """ type - TMatrixNM*[M, N, T] = object + TMatrixNM*[M, N, T] = object aij*: T TVectorN*[N, T] = TMatrixNM[range[0..0], N, T] TVector3*[T] = TVectorN[range[0..2], T] @@ -13,7 +13,7 @@ proc coeffRef*[M, N, T] (matrix: var TMatrixNM[M, N, T], a: M, b: N): var T = proc coeffRef*[N, T] (vector: var TVectorN[N, T], i: N): var T = vector.aij -var +var testVar: TVector3[float] testVar.aij = 2.0 diff --git a/tests/metatype/tstaticparammacro.nim b/tests/metatype/tstaticparammacro.nim index e577efc566..5c7c5e6af6 100644 --- a/tests/metatype/tstaticparammacro.nim +++ b/tests/metatype/tstaticparammacro.nim @@ -5,9 +5,9 @@ bb numbers 11 22 -AST a +AST a [(11, 22), (33, 44)] -AST b +AST b (e: [55, 66], f: [77, 88]) 55 10 diff --git a/tests/metatype/tstaticparams.nim b/tests/metatype/tstaticparams.nim index 7fc5f479bc..11653e5632 100644 --- a/tests/metatype/tstaticparams.nim +++ b/tests/metatype/tstaticparams.nim @@ -3,7 +3,7 @@ discard """ output: "abracadabra\ntest\n3\n15\n4\n2\nfloat\n3\nfloat\nyin\nyang" """ -type +type TFoo[T; Val: static[string]] = object data: array[4, T] @@ -121,7 +121,7 @@ foo_3.yinOrYang # bug 1859 -type +type TypeWith2Params[N, M: static[int]] = object proc bindBothParams[N](x: TypeWith2Params[N, N]) = discard diff --git a/tests/metatype/ttypedesc1.nim b/tests/metatype/ttypedesc1.nim index 0c6f5dce47..19072d9669 100644 --- a/tests/metatype/ttypedesc1.nim +++ b/tests/metatype/ttypedesc1.nim @@ -1,6 +1,6 @@ import unittest, typetraits -type +type TFoo[T, U] = object x: T y: U @@ -21,17 +21,17 @@ proc foo(T: typedesc[int or bool]): string = template foo(T: typedesc[seq]): expr = "seq" test "types can be used as proc params": - # XXX: `check` needs to know that TFoo[int, float] is a type and + # XXX: `check` needs to know that TFoo[int, float] is a type and # cannot be assigned for a local variable for later inspection check ((string.getTypeName == "string")) check ((getTypeName(int) == "int")) - + check ((foo(TFoo[int, float], 1000) == "TFoo 1000")) - + var f = 10.0 check ((foo(float, "long string") == "float true")) check ((foo(type(f), [1, 2, 3]) == "float false")) - + check ((foo(int) == "int or bool 10")) check ((foo(seq[int]) == "seq")) diff --git a/tests/metatype/ttypeselectors.nim b/tests/metatype/ttypeselectors.nim index cca643e1fe..c29fd15ce9 100644 --- a/tests/metatype/ttypeselectors.nim +++ b/tests/metatype/ttypeselectors.nim @@ -10,7 +10,7 @@ template simpleTypeTempl: typeDesc = string macro typeFromMacro: typedesc = string - + proc t1*(x: int): simpleTypeTempl() = result = "test" diff --git a/tests/metatype/ttypetraits.nim b/tests/metatype/ttypetraits.nim index 4c3ad9e0b6..1062578282 100644 --- a/tests/metatype/ttypetraits.nim +++ b/tests/metatype/ttypetraits.nim @@ -42,18 +42,18 @@ const TypeList = [int, string, seq[int]] macro selectType(inType: typedesc): typedesc = var typeSeq = @[float, TBar[int]] - + for t in TypeList: typeSeq.add(t) typeSeq.add(inType) typeSeq.add(type(10)) - + var typeSeq2: seq[typedesc] = @[] typeSeq2 = typeSeq result = typeSeq2[5] - + var xvar: selectType(string) xvar = "proba" echo xvar.type.name diff --git a/tests/method/tmethods1.nim b/tests/method/tmethods1.nim index 43a260bcab..461e2cb5ec 100644 --- a/tests/method/tmethods1.nim +++ b/tests/method/tmethods1.nim @@ -11,7 +11,7 @@ type PNodeFoo* = ref object of TNode - TSomethingElse = object + TSomethingElse = object PSomethingElse = ref TSomethingElse method foo(a: PNode, b: PSomethingElse) = discard diff --git a/tests/method/tmultim1.nim b/tests/method/tmultim1.nim index 7f551aa649..c7027f4c0e 100644 --- a/tests/method/tmultim1.nim +++ b/tests/method/tmultim1.nim @@ -10,7 +10,7 @@ type x: int PlusExpr = ref object of Expression a, b: Expression - + method eval(e: Expression): int = quit "to override!" method eval(e: Literal): int = return e.x method eval(e: PlusExpr): int = return eval(e.a) + eval(e.b) @@ -18,7 +18,7 @@ method eval(e: PlusExpr): int = return eval(e.a) + eval(e.b) proc newLit(x: int): Literal = new(result) result.x = x - + proc newPlus(a, b: Expression): PlusExpr = new(result) result.a = a diff --git a/tests/method/tmultim2.nim b/tests/method/tmultim2.nim index c5fb568a02..e695dd19be 100644 --- a/tests/method/tmultim2.nim +++ b/tests/method/tmultim2.nim @@ -13,10 +13,10 @@ type x: int TParticle = object of TThing a, b: int - + method collide(a, b: TThing) {.inline.} = echo "collide: thing, thing" - + method collide(a: TThing, b: TUnit) {.inline.} = echo "collide: thing, unit" diff --git a/tests/method/tmultim4.nim b/tests/method/tmultim4.nim index d824086b29..54630fb41e 100644 --- a/tests/method/tmultim4.nim +++ b/tests/method/tmultim4.nim @@ -26,7 +26,7 @@ var s:ref Test = newTest() for z in 1..4: s.doMethod() break - + #works #for z in 1..4: # s.doProc() diff --git a/tests/method/tmultim6.nim b/tests/method/tmultim6.nim index 5f45f572a3..6c21f80d27 100644 --- a/tests/method/tmultim6.nim +++ b/tests/method/tmultim6.nim @@ -9,10 +9,10 @@ type x: T TParticle = object of TThing a, b: int - + method collide(a, b: TThing) {.inline.} = quit "to override!" - + method collide[T](a: TThing, b: TUnit[T]) {.inline.} = write stdout, "collide: thing, unit | " diff --git a/tests/misc/minit.nim b/tests/misc/minit.nim index 75fcebb77e..513f46af55 100644 --- a/tests/misc/minit.nim +++ b/tests/misc/minit.nim @@ -1,2 +1,2 @@ -# Test the new initialization for modules -write(stdout, "Hello from module! ") +# Test the new initialization for modules +write(stdout, "Hello from module! ") diff --git a/tests/misc/mvarious.nim b/tests/misc/mvarious.nim index c0a8add732..d1587faecf 100644 --- a/tests/misc/mvarious.nim +++ b/tests/misc/mvarious.nim @@ -1,6 +1,6 @@ -# Test a submodule - -#type -# TStringArr = array [0.. *] of string - -proc exportme* = discard +# Test a submodule + +#type +# TStringArr = array [0.. *] of string + +proc exportme* = discard diff --git a/tests/misc/t99bott.nim b/tests/misc/t99bott.nim index b3b30d2961..62ccfbe162 100644 --- a/tests/misc/t99bott.nim +++ b/tests/misc/t99bott.nim @@ -25,7 +25,7 @@ proc GetBottleNumber(n: int): string = for bn in countdown(99, 1): const cur = GetBottleNumber(bn) echo(cur, " on the wall, ", cur, ".") - echo("Take one down and pass it around, ", GetBottleNumber(bn-1), + echo("Take one down and pass it around, ", GetBottleNumber(bn-1), " on the wall.\n") echo "No more bottles of beer on the wall, no more bottles of beer." diff --git a/tests/misc/tack.nim b/tests/misc/tack.nim index 680ff567e7..a0afab9e84 100644 --- a/tests/misc/tack.nim +++ b/tests/misc/tack.nim @@ -2,20 +2,20 @@ discard """ file: "tack.nim" output: "125" """ -# the Ackermann function - -proc ack(x, y: int): int = - if x != 0: - if y != 0: - return ack(x-1, ack(x, y-1)) - return ack(x-1, 1) - else: - return y + 1 -# if x == 0: return y + 1 -# elif y == 0: return ack(x-1, 1) -# else: return ack(x-1, ack(x, y-1)) - -# echo(ack(0, 0)) -write(stdout, ack(3, 4)) #OUT 125 +# the Ackermann function + +proc ack(x, y: int): int = + if x != 0: + if y != 0: + return ack(x-1, ack(x, y-1)) + return ack(x-1, 1) + else: + return y + 1 +# if x == 0: return y + 1 +# elif y == 0: return ack(x-1, 1) +# else: return ack(x-1, ack(x, y-1)) + +# echo(ack(0, 0)) +write(stdout, ack(3, 4)) #OUT 125 diff --git a/tests/misc/tatomic.nim b/tests/misc/tatomic.nim index 1fa0cff8d0..f3c56ffe31 100644 --- a/tests/misc/tatomic.nim +++ b/tests/misc/tatomic.nim @@ -3,9 +3,9 @@ discard """ line: 7 errormsg: "identifier expected, but found 'keyword atomic'" """ -var +var atomic: int - + echo atomic diff --git a/tests/misc/tcolonisproc.nim b/tests/misc/tcolonisproc.nim index af40772841..665e9e604e 100644 --- a/tests/misc/tcolonisproc.nim +++ b/tests/misc/tcolonisproc.nim @@ -7,7 +7,7 @@ when false: p(1, 3): echo 1 echo 3 - + p(1, 1, proc() = echo 1 echo 2) diff --git a/tests/misc/tdllvar.nim b/tests/misc/tdllvar.nim index 5a31dfbbb7..1c1238e8d7 100644 --- a/tests/misc/tdllvar.nim +++ b/tests/misc/tdllvar.nim @@ -1,6 +1,6 @@ import os -proc getDllName: string = +proc getDllName: string = result = "mylib.dll" if fileExists(result): return result = "mylib2.dll" diff --git a/tests/misc/temit.nim b/tests/misc/temit.nim index e2a9eaff1e..c83235659b 100644 --- a/tests/misc/temit.nim +++ b/tests/misc/temit.nim @@ -2,14 +2,14 @@ discard """ file: "temit.nim" output: "509" """ -# Test the new ``emit`` pragma: +# Test the new ``emit`` pragma: {.emit: """ static int cvariable = 420; """.} -proc embedsC() = +proc embedsC() = var nimVar = 89 {.emit: """printf("%d\n", cvariable + (int)`nimVar`);""".} diff --git a/tests/misc/teventemitter.nim b/tests/misc/teventemitter.nim index c1cc3d3a9c..32cc81be4d 100644 --- a/tests/misc/teventemitter.nim +++ b/tests/misc/teventemitter.nim @@ -13,7 +13,7 @@ proc emit*(emitter: EventEmitter, event: string, args: EventArgs) = for fn in nodes(emitter.events[event]): fn.value(args) #call function with args. -proc on*(emitter: var EventEmitter, event: string, +proc on*(emitter: var EventEmitter, event: string, fn: proc(e: EventArgs) {.nimcall.}) = if not hasKey(emitter.events, event): var list: DoublyLinkedList[proc(e: EventArgs) {.nimcall.}] @@ -21,10 +21,10 @@ proc on*(emitter: var EventEmitter, event: string, append(emitter.events.mget(event), fn) proc initEmitter(emitter: var EventEmitter) = - emitter.events = initTable[string, + emitter.events = initTable[string, DoublyLinkedList[proc(e: EventArgs) {.nimcall.}]]() -var +var ee: EventEmitter args: EventArgs initEmitter(ee) diff --git a/tests/misc/tevents.nim b/tests/misc/tevents.nim index fb94b1f79a..5f2169f29a 100644 --- a/tests/misc/tevents.nim +++ b/tests/misc/tevents.nim @@ -13,11 +13,11 @@ type proc handleprintevent*(e: TEventArgs) = write(stdout, "HandlePrintEvent: Output -> Handled print event\n") - + proc handleprintevent2*(e: TEventArgs) = var args: TPrintEventArgs = TPrintEventArgs(e) write(stdout, "HandlePrintEvent2: Output -> printing for " & args.user) - + var ee = initEventEmitter() var eventargs: TPrintEventArgs diff --git a/tests/misc/tfib.nim b/tests/misc/tfib.nim index 09a4d5038e..34fe0dcf94 100644 --- a/tests/misc/tfib.nim +++ b/tests/misc/tfib.nim @@ -1,8 +1,8 @@ -iterator fibonacci(): int = +iterator fibonacci(): int = var a = 0 var b = 1 - while true: + while true: yield a var c = b b = a diff --git a/tests/misc/tgetstartmilsecs.nim b/tests/misc/tgetstartmilsecs.nim index 5a3368e0f1..bf508dd543 100644 --- a/tests/misc/tgetstartmilsecs.nim +++ b/tests/misc/tgetstartmilsecs.nim @@ -1,4 +1,4 @@ -# +# import times, os var start = epochTime() diff --git a/tests/misc/theaproots.nim b/tests/misc/theaproots.nim index aec140f421..77d0207b05 100644 --- a/tests/misc/theaproots.nim +++ b/tests/misc/theaproots.nim @@ -1,7 +1,7 @@ -type +type Bar = object x: int - + Foo = object rheap: ref Bar rmaybe: ref Bar @@ -31,7 +31,7 @@ proc test(maybeFoo: var Foo, maybeFoo.list[3] = bb maybeFoo.listarr[3] = bb acc(maybeFoo) = bb - + var localFoo: Foo localFoo.rstack = bb localFoo.list[3] = bb diff --git a/tests/misc/thintoff.nim b/tests/misc/thintoff.nim index 807ff44f38..95318ce9b8 100644 --- a/tests/misc/thintoff.nim +++ b/tests/misc/thintoff.nim @@ -6,7 +6,7 @@ discard """ {.hint[XDeclaredButNotUsed]: off.} var x: int - + echo x #OUT 0 diff --git a/tests/misc/tinit.nim b/tests/misc/tinit.nim index 5c75567ece..02607909b8 100644 --- a/tests/misc/tinit.nim +++ b/tests/misc/tinit.nim @@ -2,11 +2,11 @@ discard """ file: "tinit.nim" output: "Hello from module! Hello from main module!" """ -# Test the new init section in modules - -import minit - -write(stdout, "Hello from main module!\n") -#OUT Hello from module! Hello from main module! +# Test the new init section in modules + +import minit + +write(stdout, "Hello from main module!\n") +#OUT Hello from module! Hello from main module! diff --git a/tests/misc/tinout.nim b/tests/misc/tinout.nim index 4e59084285..0b2a54d9f5 100644 --- a/tests/misc/tinout.nim +++ b/tests/misc/tinout.nim @@ -3,14 +3,14 @@ discard """ line: 12 errormsg: "type mismatch: got (int literal(3))" """ -# Test in out checking for parameters - -proc abc(x: var int) = - x = 0 - -proc b() = - abc(3) #ERROR - -b() +# Test in out checking for parameters + +proc abc(x: var int) = + x = 0 + +proc b() = + abc(3) #ERROR + +b() diff --git a/tests/misc/tinvalidnewseq.nim b/tests/misc/tinvalidnewseq.nim index 957a255604..89083d8b24 100644 --- a/tests/misc/tinvalidnewseq.nim +++ b/tests/misc/tinvalidnewseq.nim @@ -14,12 +14,12 @@ proc parseURL(url: string): TURL = var m: array[0..6, string] #Array with the matches newSeq(m, 7) #ERROR discard regexprs.match(url, re(pattern), m) - - result = (protocol: m[1], subdomain: m[2], domain: m[3] & m[4], + + result = (protocol: m[1], subdomain: m[2], domain: m[3] & m[4], port: m[5], path: m[6].split('/')) - + var r: TUrl - + r = parseUrl(r"http://google.com/search?var=bleahdhsad") echo(r.domain) diff --git a/tests/misc/tlastmod.nim b/tests/misc/tlastmod.nim index 857164022d..538b5e6563 100644 --- a/tests/misc/tlastmod.nim +++ b/tests/misc/tlastmod.nim @@ -1,18 +1,18 @@ -# test the new LastModificationTime() proc - -import - os, times, strutils - -proc main() = - var - a, b: TTime - a = getLastModificationTime(paramStr(1)) - b = getLastModificationTime(paramStr(2)) - writeLine(stdout, $a) - writeLine(stdout, $b) - if a < b: - write(stdout, "$2 is newer than $1\n" % [paramStr(1), paramStr(2)]) - else: - write(stdout, "$1 is newer than $2\n" % [paramStr(1), paramStr(2)]) - -main() +# test the new LastModificationTime() proc + +import + os, times, strutils + +proc main() = + var + a, b: TTime + a = getLastModificationTime(paramStr(1)) + b = getLastModificationTime(paramStr(2)) + writeLine(stdout, $a) + writeLine(stdout, $b) + if a < b: + write(stdout, "$2 is newer than $1\n" % [paramStr(1), paramStr(2)]) + else: + write(stdout, "$1 is newer than $2\n" % [paramStr(1), paramStr(2)]) + +main() diff --git a/tests/misc/tlocals.nim b/tests/misc/tlocals.nim index af8a549461..3e240d3c87 100644 --- a/tests/misc/tlocals.nim +++ b/tests/misc/tlocals.nim @@ -2,10 +2,10 @@ discard """ output: "(x: string here, a: 1)" """ -proc simple[T](a: T) = +proc simple[T](a: T) = var x = "string here" echo locals() - + simple(1) diff --git a/tests/misc/tloops.nim b/tests/misc/tloops.nim index 1aada0298d..b160500af2 100644 --- a/tests/misc/tloops.nim +++ b/tests/misc/tloops.nim @@ -76,7 +76,7 @@ proc main[T]() = b = (1, 2, 3) myType = b echo myType - + var myType2: MyType2 var c: MyType2 c = (1.0, 2.0) diff --git a/tests/misc/tmissingnilcheck.nim b/tests/misc/tmissingnilcheck.nim index c2f23ae87a..461fb18f4d 100644 --- a/tests/misc/tmissingnilcheck.nim +++ b/tests/misc/tmissingnilcheck.nim @@ -14,7 +14,7 @@ proc newConnection = proc cb {.closure.} = discard - + first.callback = cb newConnection() diff --git a/tests/misc/tnew.nim b/tests/misc/tnew.nim index 6527541a2a..88e8bd02c8 100644 --- a/tests/misc/tnew.nim +++ b/tests/misc/tnew.nim @@ -1,49 +1,49 @@ -# Test the implementation of the new operator -# and the code generation for gc walkers -# (and the garbage collector): - -type - PNode = ref TNode - TNode = object - data: int - str: string - le, ri: PNode - - TStressTest = ref array [0..45, array [1..45, TNode]] - -proc finalizer(n: PNode) = - write(stdout, n.data) - write(stdout, " is now freed\n") - -proc newNode(data: int, le, ri: PNode): PNode = - new(result, finalizer) - result.le = le - result.ri = ri - result.data = data - -# now loop and build a tree -proc main() = - var - i = 0 - p: TStressTest - while i < 1000: - var n: PNode - - n = newNode(i, nil, newNode(i + 10000, nil, nil)) - inc(i) - new(p) - - write(stdout, "Simple tree node allocation worked!\n") - i = 0 - while i < 1000: - var m = newNode(i + 20000, nil, nil) - var k = newNode(i + 30000, nil, nil) - m.le = m - m.ri = k - k.le = m - k.ri = k - inc(i) - - write(stdout, "Simple cycle allocation worked!\n") - -main() +# Test the implementation of the new operator +# and the code generation for gc walkers +# (and the garbage collector): + +type + PNode = ref TNode + TNode = object + data: int + str: string + le, ri: PNode + + TStressTest = ref array [0..45, array [1..45, TNode]] + +proc finalizer(n: PNode) = + write(stdout, n.data) + write(stdout, " is now freed\n") + +proc newNode(data: int, le, ri: PNode): PNode = + new(result, finalizer) + result.le = le + result.ri = ri + result.data = data + +# now loop and build a tree +proc main() = + var + i = 0 + p: TStressTest + while i < 1000: + var n: PNode + + n = newNode(i, nil, newNode(i + 10000, nil, nil)) + inc(i) + new(p) + + write(stdout, "Simple tree node allocation worked!\n") + i = 0 + while i < 1000: + var m = newNode(i + 20000, nil, nil) + var k = newNode(i + 30000, nil, nil) + m.le = m + m.ri = k + k.le = m + k.ri = k + inc(i) + + write(stdout, "Simple cycle allocation worked!\n") + +main() diff --git a/tests/misc/tnewderef.nim b/tests/misc/tnewderef.nim index 89dc4c8d16..3394dbddf2 100644 --- a/tests/misc/tnewderef.nim +++ b/tests/misc/tnewderef.nim @@ -7,5 +7,5 @@ var x: ref int new(x) x[] = 3 -echo x[] +echo x[] diff --git a/tests/misc/tnewsets.nim b/tests/misc/tnewsets.nim index 415fe8f7e0..f239d4aa2a 100644 --- a/tests/misc/tnewsets.nim +++ b/tests/misc/tnewsets.nim @@ -1,6 +1,6 @@ -# new test for sets: - -const elem = ' ' - -var s: set[char] = {elem} -assert(elem in s and 'a' not_in s and 'c' not_in s ) +# new test for sets: + +const elem = ' ' + +var s: set[char] = {elem} +assert(elem in s and 'a' not_in s and 'c' not_in s ) diff --git a/tests/misc/tnewuns.nim b/tests/misc/tnewuns.nim index 267c73f5b4..d6bae4fb13 100644 --- a/tests/misc/tnewuns.nim +++ b/tests/misc/tnewuns.nim @@ -1,12 +1,12 @@ -# test the new unsigned operations: - -import - strutils - -var - x, y: int - -x = 1 -y = high(int) - -writeLine(stdout, $ ( x +% y ) ) +# test the new unsigned operations: + +import + strutils + +var + x, y: int + +x = 1 +y = high(int) + +writeLine(stdout, $ ( x +% y ) ) diff --git a/tests/misc/tnoinst.nim b/tests/misc/tnoinst.nim index 4c8d9d1aa0..25ebe8dfc3 100644 --- a/tests/misc/tnoinst.nim +++ b/tests/misc/tnoinst.nim @@ -11,7 +11,7 @@ proc wrap[T]() = var x: proc (x, y: T): int x = notConcrete - + wrap[int]() diff --git a/tests/misc/tnot.nim b/tests/misc/tnot.nim index 6193e21e18..60d23c0353 100644 --- a/tests/misc/tnot.nim +++ b/tests/misc/tnot.nim @@ -5,10 +5,10 @@ discard """ """ # BUG: following compiles, but should not: -proc nodeOfDegree(x: int): bool = +proc nodeOfDegree(x: int): bool = result = false -proc main = +proc main = for j in 0..2: for i in 0..10: if not nodeOfDegree(1) >= 0: #ERROR_MSG type mismatch diff --git a/tests/misc/tparedef.nim b/tests/misc/tparedef.nim index dedebf6b7c..83c2651ff4 100644 --- a/tests/misc/tparedef.nim +++ b/tests/misc/tparedef.nim @@ -1,4 +1,4 @@ -# This test is now superfluous: - -proc a(a: int) = - return +# This test is now superfluous: + +proc a(a: int) = + return diff --git a/tests/misc/tpos.nim b/tests/misc/tpos.nim index 5560ef050e..bedb62e624 100644 --- a/tests/misc/tpos.nim +++ b/tests/misc/tpos.nim @@ -2,34 +2,34 @@ discard """ file: "tpos.nim" output: "6" """ -# test this particular function - -proc mypos(sub, s: string, start: int = 0): int = - var - i, j, M, N: int - M = sub.len - N = s.len - i = start - j = 0 - if i >= N: - result = -1 - else: - while true: - if s[i] == sub[j]: - inc(i) - inc(j) - else: - i = i - j + 1 - j = 0 - if (j >= M) or (i >= N): break - if j >= M: - result = i - M - else: - result = -1 - -var sub = "hello" -var s = "world hello" -write(stdout, mypos(sub, s)) -#OUT 6 +# test this particular function + +proc mypos(sub, s: string, start: int = 0): int = + var + i, j, M, N: int + M = sub.len + N = s.len + i = start + j = 0 + if i >= N: + result = -1 + else: + while true: + if s[i] == sub[j]: + inc(i) + inc(j) + else: + i = i - j + 1 + j = 0 + if (j >= M) or (i >= N): break + if j >= M: + result = i - M + else: + result = -1 + +var sub = "hello" +var s = "world hello" +write(stdout, mypos(sub, s)) +#OUT 6 diff --git a/tests/misc/tquicksort.nim b/tests/misc/tquicksort.nim index 6706a185ee..0867a3769f 100644 --- a/tests/misc/tquicksort.nim +++ b/tests/misc/tquicksort.nim @@ -9,17 +9,17 @@ proc QuickSort(list: seq[int]): seq[int] = left.add(list[i]) elif list[i] > pivot: right.add(list[i]) - result = QuickSort(left) & - pivot & + result = QuickSort(left) & + pivot & QuickSort(right) - + proc echoSeq(a: seq[int]) = for i in low(a)..high(a): echo(a[i]) var list: seq[int] - + list = QuickSort(@[89,23,15,23,56,123,356,12,7,1,6,2,9,4,3]) echoSeq(list) diff --git a/tests/misc/tradix.nim b/tests/misc/tradix.nim index 311aa9ccd7..36a4f39f6a 100644 --- a/tests/misc/tradix.nim +++ b/tests/misc/tradix.nim @@ -1,7 +1,7 @@ # implements and tests an efficient radix tree -## another method to store an efficient array of pointers: -## We use a radix tree with node compression. +## another method to store an efficient array of pointers: +## We use a radix tree with node compression. ## There are two node kinds: const BitsPerUnit = 8*sizeof(int) @@ -15,7 +15,7 @@ type len: int8 keys: array [0..31, int8] vals: array [0..31, PRadixNode] - + TRadixNodeFull = object of TRadixNode b: array [0..255, PRadixNode] TRadixNodeLeafBits = object of TRadixNode @@ -27,43 +27,43 @@ type var root: PRadixNode -proc searchInner(r: PRadixNode, a: int): PRadixNode = +proc searchInner(r: PRadixNode, a: int): PRadixNode = case r.kind of rnLinear: var x = cast[ptr TRadixNodeLinear](r) - for i in 0..ze(x.len)-1: + for i in 0..ze(x.len)-1: if ze(x.keys[i]) == a: return x.vals[i] - of rnFull: + of rnFull: var x = cast[ptr TRadixNodeFull](r) return x.b[a] else: assert(false) -proc testBit(w, i: int): bool {.inline.} = +proc testBit(w, i: int): bool {.inline.} = result = (w and (1 shl (i %% BitsPerUnit))) != 0 -proc setBit(w: var int, i: int) {.inline.} = +proc setBit(w: var int, i: int) {.inline.} = w = w or (1 shl (i %% BitsPerUnit)) -proc resetBit(w: var int, i: int) {.inline.} = +proc resetBit(w: var int, i: int) {.inline.} = w = w and not (1 shl (i %% BitsPerUnit)) -proc testOrSetBit(w: var int, i: int): bool {.inline.} = +proc testOrSetBit(w: var int, i: int): bool {.inline.} = var x = (1 shl (i %% BitsPerUnit)) if (w and x) != 0: return true w = w or x -proc searchLeaf(r: PRadixNode, a: int): bool = +proc searchLeaf(r: PRadixNode, a: int): bool = case r.kind of rnLeafBits: var x = cast[ptr TRadixNodeLeafBits](r) return testBit(x.b[a /% BitsPerUnit], a) of rnLeafLinear: var x = cast[ptr TRadixNodeLeafLinear](r) - for i in 0..ze(x.len)-1: + for i in 0..ze(x.len)-1: if ze(x.keys[i]) == a: return true else: assert(false) -proc exclLeaf(r: PRadixNode, a: int) = +proc exclLeaf(r: PRadixNode, a: int) = case r.kind of rnLeafBits: var x = cast[ptr TRadixNodeLeafBits](r) @@ -71,8 +71,8 @@ proc exclLeaf(r: PRadixNode, a: int) = of rnLeafLinear: var x = cast[ptr TRadixNodeLeafLinear](r) var L = ze(x.len) - for i in 0..L-1: - if ze(x.keys[i]) == a: + for i in 0..L-1: + if ze(x.keys[i]) == a: x.keys[i] = x.keys[L-1] dec(x.len) return @@ -98,7 +98,7 @@ proc excl*(r: PRadixNode, a: ByteAddress): bool = if x == nil: return false exclLeaf(x, a and 0xff) -proc addLeaf(r: var PRadixNode, a: int): bool = +proc addLeaf(r: var PRadixNode, a: int): bool = if r == nil: # a linear node: var x = cast[ptr TRadixNodeLinear](alloc(sizeof(TRadixNodeLinear))) @@ -107,23 +107,23 @@ proc addLeaf(r: var PRadixNode, a: int): bool = x.keys[0] = toU8(a) r = x return false # not already in set - case r.kind - of rnLeafBits: + case r.kind + of rnLeafBits: var x = cast[ptr TRadixNodeLeafBits](r) return testOrSetBit(x.b[a /% BitsPerUnit], a) - of rnLeafLinear: + of rnLeafLinear: var x = cast[ptr TRadixNodeLeafLinear](r) var L = ze(x.len) - for i in 0..L-1: + for i in 0..L-1: if ze(x.keys[i]) == a: return true if L <= high(x.keys): x.keys[L] = toU8(a) inc(x.len) - else: + else: # transform into a full node: var y = cast[ptr TRadixNodeLeafBits](alloc0(sizeof(TRadixNodeLeafBits))) y.kind = rnLeafBits - for i in 0..ze(x.len)-1: + for i in 0..ze(x.len)-1: var u = ze(x.keys[i]) setBit(y.b[u /% BitsPerUnit], u) setBit(y.b[a /% BitsPerUnit], a) @@ -131,8 +131,8 @@ proc addLeaf(r: var PRadixNode, a: int): bool = r = y else: assert(false) -proc addInner(r: var PRadixNode, a: int, d: int): bool = - if d == 0: +proc addInner(r: var PRadixNode, a: int, d: int): bool = + if d == 0: return addLeaf(r, a and 0xff) var k = a shr d and 0xff if r == nil: @@ -147,14 +147,14 @@ proc addInner(r: var PRadixNode, a: int, d: int): bool = of rnLinear: var x = cast[ptr TRadixNodeLinear](r) var L = ze(x.len) - for i in 0..L-1: + for i in 0..L-1: if ze(x.keys[i]) == k: # already exists return addInner(x.vals[i], a, d-8) if L <= high(x.keys): x.keys[L] = toU8(k) inc(x.len) return addInner(x.vals[L], a, d-8) - else: + else: # transform into a full node: var y = cast[ptr TRadixNodeFull](alloc0(sizeof(TRadixNodeFull))) y.kind = rnFull @@ -162,55 +162,55 @@ proc addInner(r: var PRadixNode, a: int, d: int): bool = dealloc(r) r = y return addInner(y.b[k], a, d-8) - of rnFull: + of rnFull: var x = cast[ptr TRadixNodeFull](r) return addInner(x.b[k], a, d-8) else: assert(false) -proc incl*(r: var PRadixNode, a: ByteAddress) {.inline.} = +proc incl*(r: var PRadixNode, a: ByteAddress) {.inline.} = discard addInner(r, a, 24) - -proc testOrIncl*(r: var PRadixNode, a: ByteAddress): bool {.inline.} = + +proc testOrIncl*(r: var PRadixNode, a: ByteAddress): bool {.inline.} = return addInner(r, a, 24) - -iterator innerElements(r: PRadixNode): tuple[prefix: int, n: PRadixNode] = + +iterator innerElements(r: PRadixNode): tuple[prefix: int, n: PRadixNode] = if r != nil: - case r.kind - of rnFull: + case r.kind + of rnFull: var r = cast[ptr TRadixNodeFull](r) for i in 0..high(r.b): - if r.b[i] != nil: + if r.b[i] != nil: yield (i, r.b[i]) - of rnLinear: + of rnLinear: var r = cast[ptr TRadixNodeLinear](r) - for i in 0..ze(r.len)-1: + for i in 0..ze(r.len)-1: yield (ze(r.keys[i]), r.vals[i]) else: assert(false) -iterator leafElements(r: PRadixNode): int = +iterator leafElements(r: PRadixNode): int = if r != nil: case r.kind - of rnLeafBits: + of rnLeafBits: var r = cast[ptr TRadixNodeLeafBits](r) # iterate over any bit: - for i in 0..high(r.b): + for i in 0..high(r.b): if r.b[i] != 0: # test all bits for zero - for j in 0..BitsPerUnit-1: - if testBit(r.b[i], j): + for j in 0..BitsPerUnit-1: + if testBit(r.b[i], j): yield i*BitsPerUnit+j - of rnLeafLinear: + of rnLeafLinear: var r = cast[ptr TRadixNodeLeafLinear](r) - for i in 0..ze(r.len)-1: + for i in 0..ze(r.len)-1: yield ze(r.keys[i]) else: assert(false) - -iterator elements*(r: PRadixNode): ByteAddress {.inline.} = - for p1, n1 in innerElements(r): + +iterator elements*(r: PRadixNode): ByteAddress {.inline.} = + for p1, n1 in innerElements(r): for p2, n2 in innerElements(n1): for p3, n3 in innerElements(n2): - for p4 in leafElements(n3): + for p4 in leafElements(n3): yield p1 shl 24 or p2 shl 16 or p3 shl 8 or p4 - + proc main() = const numbers = [128, 1, 2, 3, 4, 255, 17, -8, 45, 19_000] @@ -224,31 +224,31 @@ main() when false: - proc traverse(r: PRadixNode, prefix: int, d: int) = + proc traverse(r: PRadixNode, prefix: int, d: int) = if r == nil: return - case r.kind - of rnLeafBits: + case r.kind + of rnLeafBits: assert(d == 0) var x = cast[ptr TRadixNodeLeafBits](r) # iterate over any bit: - for i in 0..high(x.b): + for i in 0..high(x.b): if x.b[i] != 0: # test all bits for zero - for j in 0..BitsPerUnit-1: - if testBit(x.b[i], j): + for j in 0..BitsPerUnit-1: + if testBit(x.b[i], j): visit(prefix or i*BitsPerUnit+j) - of rnLeafLinear: + of rnLeafLinear: assert(d == 0) var x = cast[ptr TRadixNodeLeafLinear](r) - for i in 0..ze(x.len)-1: + for i in 0..ze(x.len)-1: visit(prefix or ze(x.keys[i])) - of rnFull: + of rnFull: var x = cast[ptr TRadixNodeFull](r) for i in 0..high(r.b): - if r.b[i] != nil: + if r.b[i] != nil: traverse(r.b[i], prefix or (i shl d), d-8) - of rnLinear: + of rnLinear: var x = cast[ptr TRadixNodeLinear](r) - for i in 0..ze(x.len)-1: + for i in 0..ze(x.len)-1: traverse(x.vals[i], prefix or (ze(x.keys[i]) shl d), d-8) type @@ -261,59 +261,59 @@ when false: i.r = r i.x = 0 i.p = 0 - - proc nextr(i: var TRadixIter): PRadixNode = + + proc nextr(i: var TRadixIter): PRadixNode = if i.r == nil: return nil - case i.r.kind - of rnFull: + case i.r.kind + of rnFull: var r = cast[ptr TRadixNodeFull](i.r) while i.x <= high(r.b): - if r.b[i.x] != nil: + if r.b[i.x] != nil: i.p = i.x return r.b[i.x] inc(i.x) - of rnLinear: + of rnLinear: var r = cast[ptr TRadixNodeLinear](i.r) - if i.x < ze(r.len): + if i.x < ze(r.len): i.p = ze(r.keys[i.x]) result = r.vals[i.x] inc(i.x) else: assert(false) - proc nexti(i: var TRadixIter): int = + proc nexti(i: var TRadixIter): int = result = -1 - case i.r.kind - of rnLeafBits: + case i.r.kind + of rnLeafBits: var r = cast[ptr TRadixNodeLeafBits](i.r) - # iterate over any bit: - for i in 0..high(r.b): + # iterate over any bit: + for i in 0..high(r.b): if x.b[i] != 0: # test all bits for zero - for j in 0..BitsPerUnit-1: - if testBit(x.b[i], j): + for j in 0..BitsPerUnit-1: + if testBit(x.b[i], j): visit(prefix or i*BitsPerUnit+j) - of rnLeafLinear: + of rnLeafLinear: var r = cast[ptr TRadixNodeLeafLinear](i.r) - if i.x < ze(r.len): + if i.x < ze(r.len): result = ze(r.keys[i.x]) inc(i.x) - iterator elements(r: PRadixNode): ByteAddress {.inline.} = + iterator elements(r: PRadixNode): ByteAddress {.inline.} = var a, b, c, d: TRadixIter init(a, r) - while true: + while true: var x = nextr(a) - if x != nil: + if x != nil: init(b, x) - while true: + while true: var y = nextr(b) - if y != nil: + if y != nil: init(c, y) while true: var z = nextr(c) - if z != nil: + if z != nil: init(d, z) while true: var q = nexti(d) - if q != -1: + if q != -1: yield a.p shl 24 or b.p shl 16 or c.p shl 8 or q diff --git a/tests/misc/trawstr.nim b/tests/misc/trawstr.nim index ab2aae1593..55e508acc1 100644 --- a/tests/misc/trawstr.nim +++ b/tests/misc/trawstr.nim @@ -3,10 +3,10 @@ discard """ line: 10 errormsg: "closing \" expected" """ -# Test the new raw strings: - -const - xxx = r"This is a raw string!" - yyy = "This not\" #ERROR +# Test the new raw strings: + +const + xxx = r"This is a raw string!" + yyy = "This not\" #ERROR diff --git a/tests/misc/tromans.nim b/tests/misc/tromans.nim index fa6a63595f..132c73ddd6 100644 --- a/tests/misc/tromans.nim +++ b/tests/misc/tromans.nim @@ -32,7 +32,7 @@ proc RomanToDecimal(romanVal: string): int = of 'C', 'c': val = 100 of 'D', 'd': val = 500 of 'M', 'm': val = 1000 - else: raiseInvalidValue("Incorrect character in roman numeral! (" & + else: raiseInvalidValue("Incorrect character in roman numeral! (" & $romanVal[i] & ")") if val >= prevVal: inc(result, val) @@ -49,7 +49,7 @@ proc DecimalToRoman(decValParam: int): string = ("M", 1000), ("CM", 900), ("D", 500), ("CD", 400), ("C", 100), ("XC", 90), ("L", 50), ("XL", 40), ("X", 10), ("IX", 9), - ("V", 5), ("IV", 4), ("I", 1)] + ("V", 5), ("IV", 4), ("I", 1)] if decValParam < 1 or decValParam > 3999: raiseInvalidValue("number not representable") result = "" @@ -64,7 +64,7 @@ for i in 1..100: for i in items([1238, 1777, 3830, 2401, 379, 33, 940, 3973]): if RomanToDecimal(DecimalToRoman(i)) != i: quit "BUG" - + echo "success" #OUT success diff --git a/tests/misc/tsimplesort.nim b/tests/misc/tsimplesort.nim index c282b34452..9c6ad12070 100644 --- a/tests/misc/tsimplesort.nim +++ b/tests/misc/tsimplesort.nim @@ -1,7 +1,7 @@ discard """ output: '''true''' """ - + import hashes, math {.pragma: myShallow.} @@ -112,7 +112,7 @@ proc initTable*[A, B](initialSize=64): TTable[A, B] = result.counter = 0 newSeq(result.data, initialSize) -proc toTable*[A, B](pairs: openarray[tuple[key: A, +proc toTable*[A, B](pairs: openarray[tuple[key: A, val: B]]): TTable[A, B] = ## creates a new hash table that contains the given `pairs`. result = initTable[A, B](nextPowerOfTwo(pairs.len+10)) @@ -214,7 +214,7 @@ proc `$`*[A](t: TCountTable[A]): string = ## The `$` operator for count tables. dollarImpl() -proc inc*[A](t: var TCountTable[A], key: A, val = 1) = +proc inc*[A](t: var TCountTable[A], key: A, val = 1) = ## increments `t[key]` by `val`. var index = RawGet(t, key) if index >= 0: diff --git a/tests/misc/tsimtych.nim b/tests/misc/tsimtych.nim index dd969958c5..27a922f6a0 100644 --- a/tests/misc/tsimtych.nim +++ b/tests/misc/tsimtych.nim @@ -3,10 +3,10 @@ discard """ line: 10 errormsg: "type mismatch: got (bool) but expected \'string\'" """ -# Test 2 -# Simple type checking - -var a: string -a = false #ERROR +# Test 2 +# Simple type checking + +var a: string +a = false #ERROR diff --git a/tests/misc/tsizeof.nim b/tests/misc/tsizeof.nim index f7b70dd4d0..4afd48472a 100644 --- a/tests/misc/tsizeof.nim +++ b/tests/misc/tsizeof.nim @@ -1,10 +1,10 @@ -# Test the sizeof proc - -type - TMyRecord {.final.} = object - x, y: int - b: bool - r: float - s: string - -write(stdout, sizeof(TMyRecord)) +# Test the sizeof proc + +type + TMyRecord {.final.} = object + x, y: int + b: bool + r: float + s: string + +write(stdout, sizeof(TMyRecord)) diff --git a/tests/misc/tsortdev.nim b/tests/misc/tsortdev.nim index d7d42d22c8..f360d96468 100644 --- a/tests/misc/tsortdev.nim +++ b/tests/misc/tsortdev.nim @@ -37,17 +37,17 @@ proc cmpPlatforms(a, b: string): int = else: return system.cmp(a, b) -proc sorted[T](a: openArray[T]): bool = +proc sorted[T](a: openArray[T]): bool = result = true for i in 0 .. < a.high: - if cmpPlatforms(a[i], a[i+1]) > 0: + if cmpPlatforms(a[i], a[i+1]) > 0: echo "Out of order: ", a[i], " ", a[i+1] result = false proc main() = - var testData = @["netbsd-x86_64", "windows-x86", "linux-x86_64", "linux-x86", + var testData = @["netbsd-x86_64", "windows-x86", "linux-x86_64", "linux-x86", "linux-ppc64", "macosx-x86-1058", "macosx-x86-1068"] - + sort(testData, cmpPlatforms) doAssert sorted(testData) diff --git a/tests/misc/tstrace.nim b/tests/misc/tstrace.nim index 3032a34a35..23590d9585 100644 --- a/tests/misc/tstrace.nim +++ b/tests/misc/tstrace.nim @@ -1,16 +1,16 @@ -# Test the new stacktraces (great for debugging!) - -{.push stack_trace: on.} - -proc recTest(i: int) = - # enter - if i < 10: - recTest(i+1) - else: # should printStackTrace() - var p: ptr int = nil - p[] = 12 - # leave - -{.pop.} - -recTest(0) +# Test the new stacktraces (great for debugging!) + +{.push stack_trace: on.} + +proc recTest(i: int) = + # enter + if i < 10: + recTest(i+1) + else: # should printStackTrace() + var p: ptr int = nil + p[] = 12 + # leave + +{.pop.} + +recTest(0) diff --git a/tests/misc/tstrange.nim b/tests/misc/tstrange.nim index 8742011bb6..fee0f44e43 100644 --- a/tests/misc/tstrange.nim +++ b/tests/misc/tstrange.nim @@ -4,23 +4,23 @@ discard """ 1 2''' """ -# test for extremely strange bug - -proc ack(x: int, y: int): int = - if x != 0: - if y != 5: - return y - return x - return x+y - -proc gen[T](a: T) = - write(stdout, a) - - -gen("hallo") -write(stdout, ack(5, 4)) -#OUT hallo4 - +# test for extremely strange bug + +proc ack(x: int, y: int): int = + if x != 0: + if y != 5: + return y + return x + return x+y + +proc gen[T](a: T) = + write(stdout, a) + + +gen("hallo") +write(stdout, ack(5, 4)) +#OUT hallo4 + # bug #1442 let h=3 for x in 0.. ".}: cint - + proc mmap(adr: pointer, len: int, prot, flags, fildes: cint, off: int): pointer {.header: "".} proc munmap(adr: pointer, len: int) {.header: "".} -proc osAllocPages(size: int): pointer {.inline.} = - result = mmap(nil, size, PROT_READ or PROT_WRITE, +proc osAllocPages(size: int): pointer {.inline.} = + result = mmap(nil, size, PROT_READ or PROT_WRITE, MAP_PRIVATE or MAP_ANONYMOUS, -1, 0) if result == nil or result == cast[pointer](-1): quit 1 - cfprintf(c_stdout, "allocated pages %p..%p\n", result, + cfprintf(c_stdout, "allocated pages %p..%p\n", result, cast[int](result) + size) - + proc osDeallocPages(p: pointer, size: int) {.inline} = cfprintf(c_stdout, "freed pages %p..%p\n", p, cast[int](p) + size) munmap(p, size-1) diff --git a/tests/modules/mnamspc1.nim b/tests/modules/mnamspc1.nim index da13c5f24e..91f4d15660 100644 --- a/tests/modules/mnamspc1.nim +++ b/tests/modules/mnamspc1.nim @@ -1,2 +1,2 @@ -import mnamspc2 - +import mnamspc2 + diff --git a/tests/modules/mnamspc2.nim b/tests/modules/mnamspc2.nim index 84ef8533eb..899ef27ea2 100644 --- a/tests/modules/mnamspc2.nim +++ b/tests/modules/mnamspc2.nim @@ -1,3 +1,3 @@ -# export an identifier: -var - global*: int +# export an identifier: +var + global*: int diff --git a/tests/modules/mopaque.nim b/tests/modules/mopaque.nim index 7eee4bd96f..2129bdaf2f 100644 --- a/tests/modules/mopaque.nim +++ b/tests/modules/mopaque.nim @@ -1,7 +1,7 @@ -type - TLexer* {.final.} = object - line*: int - filename*: string - buffer: cstring +type + TLexer* {.final.} = object + line*: int + filename*: string + buffer: cstring proc noProcVar*(): int = 18 diff --git a/tests/modules/mrecmod.nim b/tests/modules/mrecmod.nim index fab9654d52..ce8fa3d640 100644 --- a/tests/modules/mrecmod.nim +++ b/tests/modules/mrecmod.nim @@ -1 +1 @@ -import trecmod +import trecmod diff --git a/tests/modules/mrecmod2.nim b/tests/modules/mrecmod2.nim index 9557ce729b..31fac6e4de 100644 --- a/tests/modules/mrecmod2.nim +++ b/tests/modules/mrecmod2.nim @@ -1,9 +1,9 @@ # Module B -import trecmod2 +import trecmod2 proc p*(x: trecmod2.T1): trecmod2.T1 = # this works because the compiler has already # added T1 to trecmod2's interface symbol table return x + 1 - + diff --git a/tests/modules/texport.nim b/tests/modules/texport.nim index 9515f90600..0890fb369c 100644 --- a/tests/modules/texport.nim +++ b/tests/modules/texport.nim @@ -7,7 +7,7 @@ import mexporta # bug #1029: from rawsockets import accept -# B.TMyObject has been imported implicitly here: +# B.TMyObject has been imported implicitly here: var x: TMyObject echo($x, q(0), q"0") diff --git a/tests/modules/tnamspc.nim b/tests/modules/tnamspc.nim index 1e2049cecd..2f488644c1 100644 --- a/tests/modules/tnamspc.nim +++ b/tests/modules/tnamspc.nim @@ -3,10 +3,10 @@ discard """ line: 10 errormsg: "undeclared identifier: \'global\'" """ -# Test17 - test correct handling of namespaces - -import mnamspc1 - -global = 9 #ERROR +# Test17 - test correct handling of namespaces + +import mnamspc1 + +global = 9 #ERROR diff --git a/tests/modules/trecmod.nim b/tests/modules/trecmod.nim index 9d39d3ff7d..d567e293b3 100644 --- a/tests/modules/trecmod.nim +++ b/tests/modules/trecmod.nim @@ -1,2 +1,2 @@ -# recursive module -import mrecmod +# recursive module +import mrecmod diff --git a/tests/namedparams/tnamedparams.nim b/tests/namedparams/tnamedparams.nim index 9397fea4a9..9a8bd0c2e3 100644 --- a/tests/namedparams/tnamedparams.nim +++ b/tests/namedparams/tnamedparams.nim @@ -6,9 +6,9 @@ discard """ import pegs discard parsePeg( - input = "input", - filename = "filename", - line = 1, + input = "input", + filename = "filename", + line = 1, col = 23) diff --git a/tests/namedparams/tnamedparams2.nim b/tests/namedparams/tnamedparams2.nim index 4b0cd53613..fcbbd32dab 100644 --- a/tests/namedparams/tnamedparams2.nim +++ b/tests/namedparams/tnamedparams2.nim @@ -1,8 +1,8 @@ import pegs discard parsePeg( - pattern = "input", - filename = "filename", - line = 1, + pattern = "input", + filename = "filename", + line = 1, col = 23) diff --git a/tests/notnil/tnotnil.nim b/tests/notnil/tnotnil.nim index fba7fa917d..f65634ed66 100644 --- a/tests/notnil/tnotnil.nim +++ b/tests/notnil/tnotnil.nim @@ -7,7 +7,7 @@ type PObj = ref TObj not nil TObj = object x: int - + MyString = string not nil #var x: PObj = nil diff --git a/tests/notnil/tnotnil1.nim b/tests/notnil/tnotnil1.nim index 863fe45f8b..73472752c7 100644 --- a/tests/notnil/tnotnil1.nim +++ b/tests/notnil/tnotnil1.nim @@ -18,7 +18,7 @@ proc q(s: superstring) = echo s proc p2() = - var a: string = "I am not nil" + var a: string = "I am not nil" q(a) # but this should and does not p2() @@ -30,7 +30,7 @@ proc p() = var x: pointer if not x.isNil: q(x) - + let y = x if not y.isNil: q(y) diff --git a/tests/notnil/tnotnil_in_generic.nim b/tests/notnil/tnotnil_in_generic.nim index 1e2d8b940f..357ab2c7c7 100644 --- a/tests/notnil/tnotnil_in_generic.nim +++ b/tests/notnil/tnotnil_in_generic.nim @@ -9,14 +9,14 @@ type x: int ud: T -proc good[T](p: A[T]) = +proc good[T](p: A[T]) = discard -proc bad[T](p: A[T] not nil) = +proc bad[T](p: A[T] not nil) = discard -proc go() = +proc go() = let s = A[int](x: 1) good(s) diff --git a/tests/objects/tobjcov.nim b/tests/objects/tobjcov.nim index 8391727f2d..cf2e5becf2 100644 --- a/tests/objects/tobjcov.nim +++ b/tests/objects/tobjcov.nim @@ -5,10 +5,10 @@ type a: int TB = object of TA b: array[0..5000_000, int] - + proc ap(x: var TA) = x.a = -1 proc bp(x: var TB) = x.b[high(x.b)] = -1 - + # in Nim proc (x: TB) is compatible to proc (x: TA), # but this is not type safe: var f = cast[proc (x: var TA) {.nimcall.}](bp) diff --git a/tests/objects/tobject.nim b/tests/objects/tobject.nim index 5fec844417..cdb8f80db2 100644 --- a/tests/objects/tobject.nim +++ b/tests/objects/tobject.nim @@ -3,7 +3,7 @@ import unittest type Obj = object foo: int -proc makeObj(x: int): Obj = +proc makeObj(x: int): Obj = result.foo = x suite "object basic methods": diff --git a/tests/objects/tobject3.nim b/tests/objects/tobject3.nim index 85cf1cfe3e..2d9c8d0234 100644 --- a/tests/objects/tobject3.nim +++ b/tests/objects/tobject3.nim @@ -4,7 +4,7 @@ type TFoo = ref object of RootObj - Data: int + Data: int TBar = ref object of TFoo nil TBar2 = ref object of TBar diff --git a/tests/objects/tobjects.nim b/tests/objects/tobjects.nim index 06fa155838..2f46b46b58 100644 --- a/tests/objects/tobjects.nim +++ b/tests/objects/tobjects.nim @@ -18,7 +18,7 @@ type of 0: arg: char of 1: s: string else: wtf: bool - + var x: TMyObject diff --git a/tests/objects/tobjpragma.nim b/tests/objects/tobjpragma.nim index dda8057b6b..0a6cc893b4 100644 --- a/tests/objects/tobjpragma.nim +++ b/tests/objects/tobjpragma.nim @@ -12,7 +12,7 @@ discard """ # Disabled since some versions of GCC ignore the 'packed' attribute -# Test +# Test type Foo {.packed.} = object @@ -21,12 +21,12 @@ type Bar {.packed.} = object a: int8 - b: int16 - + b: int16 + Daz {.packed.} = object a: int32 - b: int8 - c: int32 + b: int8 + c: int32 var f = Foo(a: 1, b: 1) diff --git a/tests/objects/tofopr.nim b/tests/objects/tofopr.nim index 961d81bd32..ab28545711 100644 --- a/tests/objects/tofopr.nim +++ b/tests/objects/tofopr.nim @@ -8,12 +8,12 @@ type TMyType = object {.inheritable.} len: int data: string - + TOtherType = object of TMyType - -proc p(x: TMyType): bool = + +proc p(x: TMyType): bool = return x of TOtherType - + var m: TMyType n: TOtherType diff --git a/tests/objects/toop.nim b/tests/objects/toop.nim index 0b42c2c22d..ebc59f6370 100644 --- a/tests/objects/toop.nim +++ b/tests/objects/toop.nim @@ -5,13 +5,13 @@ discard """ type TA = object of TObject x, y: int - + TB = object of TA z: int - + TC = object of TB whatever: string - + proc p(a: var TA) = echo "a" proc p(b: var TB) = echo "b" diff --git a/tests/objvariant/tcheckedfield1.nim b/tests/objvariant/tcheckedfield1.nim index 1963ceb8d5..56d784a2bd 100644 --- a/tests/objvariant/tcheckedfield1.nim +++ b/tests/objvariant/tcheckedfield1.nim @@ -15,7 +15,7 @@ type case k: TNodeKind of nkBinary, nkTernary: a, b: PNode of nkStr: s: string - + PList = ref object data: string next: PList @@ -52,7 +52,7 @@ proc toString3(x: PNode): string = proc p() = var x: PNode = PNode(k: nkStr, s: "abc") - + let y = x if not y.isNil: echo toString(y), " ", toString2(y) diff --git a/tests/osproc/ta.nim b/tests/osproc/ta.nim index 6c14955908..5ebcc7f142 100644 --- a/tests/osproc/ta.nim +++ b/tests/osproc/ta.nim @@ -1,3 +1,3 @@ import strutils let x = stdin.readLine() -echo x.parseInt + 5 \ No newline at end of file +echo x.parseInt + 5 diff --git a/tests/overflw/tovfint.nim b/tests/overflw/tovfint.nim index f0b1ccaa6c..f775d2e1c5 100644 --- a/tests/overflw/tovfint.nim +++ b/tests/overflw/tovfint.nim @@ -2,22 +2,22 @@ discard """ file: "tovfint.nim" output: "works!" """ -# this tests the new overflow literals - -var - i: int -i = int(0xffffffff'i32) -when defined(cpu64): - if i == -1: - write(stdout, "works!\n") - else: - write(stdout, "broken!\n") -else: - if i == -1: - write(stdout, "works!\n") - else: - write(stdout, "broken!\n") - -#OUT works! +# this tests the new overflow literals + +var + i: int +i = int(0xffffffff'i32) +when defined(cpu64): + if i == -1: + write(stdout, "works!\n") + else: + write(stdout, "broken!\n") +else: + if i == -1: + write(stdout, "works!\n") + else: + write(stdout, "broken!\n") + +#OUT works! diff --git a/tests/overload/toverl2.nim b/tests/overload/toverl2.nim index ea0249e9fe..54714ac1b2 100644 --- a/tests/overload/toverl2.nim +++ b/tests/overload/toverl2.nim @@ -9,9 +9,9 @@ import strutils proc toverl2(x: int): string = return $x proc toverl2(x: bool): string = return $x -iterator toverl2(x: int): int = +iterator toverl2(x: int): int = var res = 0 - while res < x: + while res < x: yield res inc(res) @@ -20,7 +20,7 @@ var stdout.write(pp(true)) -for x in toverl2(3): +for x in toverl2(3): stdout.write(toverl2(x)) block: diff --git a/tests/overload/toverl3.nim b/tests/overload/toverl3.nim index b3e0f2fa7c..92cfc150d8 100644 --- a/tests/overload/toverl3.nim +++ b/tests/overload/toverl3.nim @@ -4,8 +4,8 @@ discard """ tup1''' """ -# Tests more specific generic match: - +# Tests more specific generic match: + proc m[T](x: T) = echo "m2" proc m[T](x: var ref T) = echo "m1" @@ -15,6 +15,6 @@ proc tup[S, T](x: tuple[a: S, b: T]) = echo "tup2" var obj: ref int tu: tuple[a: int, b: ref bool] - + m(obj) tup(tu) diff --git a/tests/overload/toverl4.nim b/tests/overload/toverl4.nim index 6bb3a53d10..b63265bdf2 100644 --- a/tests/overload/toverl4.nim +++ b/tests/overload/toverl4.nim @@ -74,4 +74,4 @@ proc add*[TKey, TData](root: var PElement[TKey, TData], key: TKey, data: TData) var tree = PElement[int, int](kind: ElementKind.inner, key: 0, left: nil, right: nil) let result = add(tree, 1, 1) -echo(result) \ No newline at end of file +echo(result) diff --git a/tests/overload/toverwr.nim b/tests/overload/toverwr.nim index 32d50faaa2..5945a6149f 100644 --- a/tests/overload/toverwr.nim +++ b/tests/overload/toverwr.nim @@ -1,13 +1,13 @@ -discard """ - file: "toverwr.nim" - output: "hello" -""" -# Test the overloading resolution in connection with a qualifier - -proc write(t: TFile, s: string) = - discard # a nop - -system.write(stdout, "hello") -#OUT hello - - +discard """ + file: "toverwr.nim" + output: "hello" +""" +# Test the overloading resolution in connection with a qualifier + +proc write(t: TFile, s: string) = + discard # a nop + +system.write(stdout, "hello") +#OUT hello + + diff --git a/tests/parallel/treadafterwrite.nim b/tests/parallel/treadafterwrite.nim index f59ad5ae0d..12eb314024 100644 --- a/tests/parallel/treadafterwrite.nim +++ b/tests/parallel/treadafterwrite.nim @@ -12,7 +12,7 @@ type BoxedFloat = object value: float -proc term(k: float): ptr BoxedFloat = +proc term(k: float): ptr BoxedFloat = var temp = 4 * math.pow(-1, k) / (2*k + 1) result = cast[ptr BoxedFloat](allocShared(sizeof(BoxedFloat))) result.value = temp diff --git a/tests/parallel/tuseafterdef.nim b/tests/parallel/tuseafterdef.nim index 95123e8863..833c72a0a3 100644 --- a/tests/parallel/tuseafterdef.nim +++ b/tests/parallel/tuseafterdef.nim @@ -7,11 +7,11 @@ discard """ import strutils, math, threadpool -type +type BoxedFloat = object value: float -proc term(k: float): ptr BoxedFloat = +proc term(k: float): ptr BoxedFloat = var temp = 4 * math.pow(-1, k) / (2*k + 1) result = cast[ptr BoxedFloat](allocShared(sizeof(BoxedFloat))) result.value = temp diff --git a/tests/parser/tdomulttest.nim b/tests/parser/tdomulttest.nim index 4ee6de128e..418192ac8b 100644 --- a/tests/parser/tdomulttest.nim +++ b/tests/parser/tdomulttest.nim @@ -14,4 +14,4 @@ do (x: int) -> int: echo("multi lines") return x -echo("end") \ No newline at end of file +echo("end") diff --git a/tests/parser/tinvwhen.nim b/tests/parser/tinvwhen.nim index 5ff94cc6c2..99701bdf52 100644 --- a/tests/parser/tinvwhen.nim +++ b/tests/parser/tinvwhen.nim @@ -3,13 +3,13 @@ discard """ line: 11 errormsg: "invalid indentation" """ -# This was parsed even though it should not! - -proc chdir(path: cstring): cint {.importc: "chdir", header: "dirHeader".} - -proc getcwd(buf: cstring, buflen: cint): cstring - when defined(unix): {.importc: "getcwd", header: "".} #ERROR_MSG invalid indentation - elif defined(windows): {.importc: "getcwd", header: ""} - else: {.error: "os library not ported to your OS. Please help!".} +# This was parsed even though it should not! + +proc chdir(path: cstring): cint {.importc: "chdir", header: "dirHeader".} + +proc getcwd(buf: cstring, buflen: cint): cstring + when defined(unix): {.importc: "getcwd", header: "".} #ERROR_MSG invalid indentation + elif defined(windows): {.importc: "getcwd", header: ""} + else: {.error: "os library not ported to your OS. Please help!".} diff --git a/tests/parser/toprprec.nim b/tests/parser/toprprec.nim index ce33934b57..2c22f5b807 100644 --- a/tests/parser/toprprec.nim +++ b/tests/parser/toprprec.nim @@ -2,7 +2,7 @@ discard """ file: "toprprec.nim" output: "done" """ -# Test operator precedence: +# Test operator precedence: template `@` (x: expr): expr {.immediate.} = self.x template `@!` (x: expr): expr {.immediate.} = x @@ -12,7 +12,7 @@ type TO = object x: int TA = tuple[a, b: int, obj: TO] - + proc init(self: var TA): string = @a = 3 === @b = 4 @@ -22,10 +22,10 @@ proc init(self: var TA): string = assert 3+5*5-2 == 28- -26-28 -proc `^-` (x, y: int): int = +proc `^-` (x, y: int): int = # now right-associative! result = x - y - + assert 34 ^- 6 ^- 2 == 30 assert 34 - 6 - 2 == 26 diff --git a/tests/pragmas/tpush.nim b/tests/pragmas/tpush.nim index 5fb411a791..5ecfe97042 100644 --- a/tests/pragmas/tpush.nim +++ b/tests/pragmas/tpush.nim @@ -1,15 +1,15 @@ -# test the new pragmas - -{.push warnings: off, hints: off.} -proc noWarning() = - var - x: int - echo(x) - -{.pop.} - -proc WarnMe() = - var - x: int - echo(x) - +# test the new pragmas + +{.push warnings: off, hints: off.} +proc noWarning() = + var + x: int + echo(x) + +{.pop.} + +proc WarnMe() = + var + x: int + echo(x) + diff --git a/tests/proc/tnestprc.nim b/tests/proc/tnestprc.nim index c10ad6abf5..9b3c33d5e3 100644 --- a/tests/proc/tnestprc.nim +++ b/tests/proc/tnestprc.nim @@ -4,12 +4,12 @@ discard """ """ # Test nested procs without closures -proc Add3(x: int): int = - proc add(x, y: int): int {.noconv.} = +proc Add3(x: int): int = + proc add(x, y: int): int {.noconv.} = result = x + y - + result = add(x, 3) - + echo Add3(7) #OUT 10 diff --git a/tests/procvar/tprocvar.nim b/tests/procvar/tprocvar.nim index 56f76c613a..f523aa391e 100644 --- a/tests/procvar/tprocvar.nim +++ b/tests/procvar/tprocvar.nim @@ -13,6 +13,6 @@ proc huh(x, y: var int) = proc so(c: TCallback) = c(2, 4) - + so(huh) diff --git a/tests/procvar/tprocvar2.nim b/tests/procvar/tprocvar2.nim index 237e2ef7a8..a590bc4bd7 100644 --- a/tests/procvar/tprocvar2.nim +++ b/tests/procvar/tprocvar2.nim @@ -2,7 +2,7 @@ discard """ file: "tprocvar.nim" output: "papbpcpdpe7" """ -# test variables of type proc +# test variables of type proc proc pa() {.cdecl.} = write(stdout, "pa") proc pb() {.cdecl.} = write(stdout, "pb") @@ -12,21 +12,21 @@ proc pe() {.cdecl.} = write(stdout, "pe") const algos = [pa, pb, pc, pd, pe] - -var - x: proc (a, b: int): int {.cdecl.} - -proc ha(c, d: int): int {.cdecl.} = - echo(c + d) - result = c + d + +var + x: proc (a, b: int): int {.cdecl.} + +proc ha(c, d: int): int {.cdecl.} = + echo(c + d) + result = c + d for a in items(algos): a() - -x = ha -discard x(3, 4) - -#OUT papbpcpdpe7 - + +x = ha +discard x(3, 4) + +#OUT papbpcpdpe7 + diff --git a/tests/range/tbug499771.nim b/tests/range/tbug499771.nim index 6821484225..1504a2ad70 100644 --- a/tests/range/tbug499771.nim +++ b/tests/range/tbug499771.nim @@ -3,11 +3,11 @@ discard """ output: '''TSubRange: 5 from 1 to 10 true true true''' """ -type +type TSubRange = range[1 .. 10] TEnum = enum A, B, C var sr: TSubRange = 5 -echo("TSubRange: " & $sr & " from " & $low(TSubRange) & " to " & +echo("TSubRange: " & $sr & " from " & $low(TSubRange) & " to " & $high(TSubRange)) const cset = {A} + {B} diff --git a/tests/range/tcolors.nim b/tests/range/tcolors.nim index 9d1034405f..ab5b3e1993 100644 --- a/tests/range/tcolors.nim +++ b/tests/range/tcolors.nim @@ -3,7 +3,7 @@ import strutils type TColor = distinct int32 -proc rgb(r, g, b: range[0..255]): TColor = +proc rgb(r, g, b: range[0..255]): TColor = result = TColor(r or g shl 8 or b shl 16) proc `$`(c: TColor): string = @@ -15,25 +15,25 @@ when false: type TColor = distinct int32 TColorComponent = distinct int8 - - proc red(a: TColor): TColorComponent = + + proc red(a: TColor): TColorComponent = result = TColorComponent(int32(a) and 0xff'i32) - - proc green(a: TColor): TColorComponent = + + proc green(a: TColor): TColorComponent = result = TColorComponent(int32(a) shr 8'i32 and 0xff'i32) - - proc blue(a: TColor): TColorComponent = + + proc blue(a: TColor): TColorComponent = result = TColorComponent(int32(a) shr 16'i32 and 0xff'i32) - - proc rgb(r, g, b: range[0..255]): TColor = + + proc rgb(r, g, b: range[0..255]): TColor = result = TColor(r or g shl 8 or b shl 8) - - proc `+!` (a, b: TColorComponent): TColorComponent = + + proc `+!` (a, b: TColorComponent): TColorComponent = ## saturated arithmetic: result = TColorComponent(min(ze(int8(a)) + ze(int8(b)), 255)) - - proc `+` (a, b: TColor): TColor = + + proc `+` (a, b: TColor): TColor = ## saturated arithmetic for colors makes sense, I think: return rgb(red(a) +! red(b), green(a) +! green(b), blue(a) +! blue(b)) - + rgb(34, 55, 255) diff --git a/tests/range/tmatrix3.nim b/tests/range/tmatrix3.nim index 80d38d63d9..fe666b0d8c 100644 --- a/tests/range/tmatrix3.nim +++ b/tests/range/tmatrix3.nim @@ -10,11 +10,11 @@ discard """ include compilehelpers type - Matrix*[M, N, T] = object + Matrix*[M, N, T] = object aij*: array[M, array[N, T]] - + Matrix2*[T] = Matrix[range[0..1], range[0..1], T] - + Matrix3*[T] = Matrix[range[0..2], range[0..2], T] proc mn(x: Matrix): Matrix.T = x.aij[0][0] @@ -23,7 +23,7 @@ proc m2(x: Matrix2): Matrix2.T = x.aij[0][0] proc m3(x: Matrix3): auto = x.aij[0][0] -var +var matn: Matrix[range[0..3], range[0..2], int] mat2: Matrix2[int] mat3: Matrix3[float] diff --git a/tests/range/tsubrange.nim b/tests/range/tsubrange.nim index b4a333bf31..6f88c5a224 100644 --- a/tests/range/tsubrange.nim +++ b/tests/range/tsubrange.nim @@ -5,10 +5,10 @@ discard """ type TRange = range[0..40] - + proc p(r: TRange) = nil - + var r: TRange y = 50 @@ -18,4 +18,4 @@ p y const myConst: TRange = 60 - + diff --git a/tests/range/tsubrange2.nim b/tests/range/tsubrange2.nim index 759d16b9ce..7097faed2a 100644 --- a/tests/range/tsubrange2.nim +++ b/tests/range/tsubrange2.nim @@ -6,12 +6,12 @@ discard """ type TRange = range[0..40] - + proc p(r: TRange) = discard - + var r: TRange y = 50 p y - + diff --git a/tests/range/tsubrange3.nim b/tests/range/tsubrange3.nim index 600161cfd4..f5bb2f1611 100644 --- a/tests/range/tsubrange3.nim +++ b/tests/range/tsubrange3.nim @@ -6,10 +6,10 @@ discard """ type TRange = range[0..40] - + proc p(r: TRange) = discard - + var r: TRange y = 50 diff --git a/tests/rectest.nim b/tests/rectest.nim index f08306cfd3..54815e1f69 100644 --- a/tests/rectest.nim +++ b/tests/rectest.nim @@ -1,6 +1,6 @@ -# Test the error message - -proc main() = - main() - -main() +# Test the error message + +proc main() = + main() + +main() diff --git a/tests/rodfiles/amethods.nim b/tests/rodfiles/amethods.nim index c51d27d249..ecd36d4912 100644 --- a/tests/rodfiles/amethods.nim +++ b/tests/rodfiles/amethods.nim @@ -4,7 +4,7 @@ type proc newBaseClass*: ref TBaseClass = new result - + method echoType*(x: ref TBaseClass) = echo "base class" diff --git a/tests/rodfiles/bmethods.nim b/tests/rodfiles/bmethods.nim index 995942ad63..c77941e4a7 100644 --- a/tests/rodfiles/bmethods.nim +++ b/tests/rodfiles/bmethods.nim @@ -12,7 +12,7 @@ type proc newDerivedClass: ref TDerivedClass = new result - + method echoType*(x: ref TDerivedClass) = echo "derived class" diff --git a/tests/rodfiles/bmethods2.nim b/tests/rodfiles/bmethods2.nim index ac24a22014..c9d25eee4e 100644 --- a/tests/rodfiles/bmethods2.nim +++ b/tests/rodfiles/bmethods2.nim @@ -12,7 +12,7 @@ type proc newDerivedClass: ref TDerivedClass = new result - + method echoType*(x: ref TDerivedClass) = echo "derived class 2" diff --git a/tests/rodfiles/deadg.nim b/tests/rodfiles/deadg.nim index 97bfbed4f7..587608e14e 100644 --- a/tests/rodfiles/deadg.nim +++ b/tests/rodfiles/deadg.nim @@ -3,8 +3,8 @@ proc p1*(x, y: int): int = result = x + y - + proc p2*(x, y: string): string = result = x & y - + diff --git a/tests/rodfiles/gtkex1.nim b/tests/rodfiles/gtkex1.nim index 8f4db4a408..156ba53223 100644 --- a/tests/rodfiles/gtkex1.nim +++ b/tests/rodfiles/gtkex1.nim @@ -1,14 +1,14 @@ -import - cairo, glib2, gtk2 - -proc destroy(widget: pWidget, data: pgpointer) {.cdecl.} = - main_quit() - -var - window: pWidget -nimrod_init() -window = window_new(WINDOW_TOPLEVEL) -discard signal_connect(window, "destroy", - SIGNAL_FUNC(gtkex1.destroy), nil) -show(window) -main() +import + cairo, glib2, gtk2 + +proc destroy(widget: pWidget, data: pgpointer) {.cdecl.} = + main_quit() + +var + window: pWidget +nimrod_init() +window = window_new(WINDOW_TOPLEVEL) +discard signal_connect(window, "destroy", + SIGNAL_FUNC(gtkex1.destroy), nil) +show(window) +main() diff --git a/tests/rodfiles/gtkex2.nim b/tests/rodfiles/gtkex2.nim index 3d181ba124..70926bd50e 100644 --- a/tests/rodfiles/gtkex2.nim +++ b/tests/rodfiles/gtkex2.nim @@ -1,11 +1,11 @@ -import +import glib2, gtk2 -proc destroy(widget: pWidget, data: pgpointer){.cdecl.} = +proc destroy(widget: pWidget, data: pgpointer){.cdecl.} = main_quit() -var +var window: PWidget button: PWidget @@ -14,7 +14,7 @@ window = window_new(WINDOW_TOPLEVEL) button = button_new("Click me") set_border_width(PContainer(Window), 5) add(PContainer(window), button) -discard signal_connect(window, "destroy", +discard signal_connect(window, "destroy", SIGNAL_FUNC(gtkex2.destroy), nil) show(button) show(window) diff --git a/tests/rodfiles/hallo2.nim b/tests/rodfiles/hallo2.nim index a4b3957ecd..40fe64cfd5 100644 --- a/tests/rodfiles/hallo2.nim +++ b/tests/rodfiles/hallo2.nim @@ -12,6 +12,6 @@ type proc newNode(data: string): ref TNode = new(result) result.data = data - + echo newNode("Hello World").data diff --git a/tests/seq/tseq2.nim b/tests/seq/tseq2.nim index e1271964cc..5de9402ecb 100644 --- a/tests/seq/tseq2.nim +++ b/tests/seq/tseq2.nim @@ -1,10 +1,10 @@ -proc `*` *(a, b: seq[int]): seq[int] = +proc `*` *(a, b: seq[int]): seq[int] = # allocate a new sequence: newSeq(result, len(a)) # multiply two int sequences: for i in 0..len(a)-1: result[i] = a[i] * b[i] -when isMainModule: +when isMainModule: # test the new ``*`` operator for sequences: assert(@[1, 2, 3] * @[1, 2, 3] == @[1, 4, 9]) diff --git a/tests/seq/tseqcon.nim b/tests/seq/tseqcon.nim index 6e0a5b56d1..902ac34853 100644 --- a/tests/seq/tseqcon.nim +++ b/tests/seq/tseqcon.nim @@ -2,50 +2,50 @@ discard """ file: "tseqcon.nim" output: "Hithere, what\'s your name?Hathere, what\'s your name?" """ -# Test the add proc for sequences and strings - -const - nestedFixed = true - -type - TRec {.final.} = object - x, y: int - s: string - seq: seq[string] - TRecSeq = seq[TRec] - -proc test() = - var s, b: seq[string] - s = @[] - add(s, "Hi") - add(s, "there, ") - add(s, "what's your name?") - - b = s # deep copying here! - b[0][1] = 'a' - - for i in 0 .. len(s)-1: - write(stdout, s[i]) - for i in 0 .. len(b)-1: - write(stdout, b[i]) - - -when nestedFixed: - proc nested() = - var - s: seq[seq[string]] - for i in 0..10_000: # test if the garbage collector - # now works with sequences - s = @[ - @["A", "B", "C", "D"], - @["E", "F", "G", "H"], - @["I", "J", "K", "L"], - @["M", "N", "O", "P"]] - -test() -when nestedFixed: - nested() - -#OUT Hithere, what's your name?Hathere, what's your name? +# Test the add proc for sequences and strings + +const + nestedFixed = true + +type + TRec {.final.} = object + x, y: int + s: string + seq: seq[string] + TRecSeq = seq[TRec] + +proc test() = + var s, b: seq[string] + s = @[] + add(s, "Hi") + add(s, "there, ") + add(s, "what's your name?") + + b = s # deep copying here! + b[0][1] = 'a' + + for i in 0 .. len(s)-1: + write(stdout, s[i]) + for i in 0 .. len(b)-1: + write(stdout, b[i]) + + +when nestedFixed: + proc nested() = + var + s: seq[seq[string]] + for i in 0..10_000: # test if the garbage collector + # now works with sequences + s = @[ + @["A", "B", "C", "D"], + @["E", "F", "G", "H"], + @["I", "J", "K", "L"], + @["M", "N", "O", "P"]] + +test() +when nestedFixed: + nested() + +#OUT Hithere, what's your name?Hathere, what's your name? diff --git a/tests/seq/tseqtuple.nim b/tests/seq/tseqtuple.nim index 7ef92f7f13..a0102c9efb 100644 --- a/tests/seq/tseqtuple.nim +++ b/tests/seq/tseqtuple.nim @@ -6,7 +6,7 @@ discard """ type TMsg = tuple[ file: string, - line: int, + line: int, msg: string, err: bool] diff --git a/tests/seq/ttoseq.nim b/tests/seq/ttoseq.nim index 34cc4824be..33de59538d 100644 --- a/tests/seq/ttoseq.nim +++ b/tests/seq/ttoseq.nim @@ -4,9 +4,9 @@ discard """ import sequtils -for x in toSeq(countup(2, 6)): +for x in toSeq(countup(2, 6)): stdout.write(x) -for x in items(toSeq(countup(2, 6))): +for x in items(toSeq(countup(2, 6))): stdout.write(x) import strutils diff --git a/tests/sets/tsets.nim b/tests/sets/tsets.nim index 2d37e893dd..53a955af8c 100644 --- a/tests/sets/tsets.nim +++ b/tests/sets/tsets.nim @@ -1,204 +1,204 @@ -discard """ - file: "tsets.nim" - output: '''Ha ein F ist in s! -false''' -""" -# Test the handling of sets - -import - strutils - -proc testSets(s: var set[char]) = - s = {'A', 'B', 'C', 'E'..'G'} + {'Z'} + s - -# test sets if the first element is different from 0: -type - TAZ = range['a'..'z'] - TAZset = set[TAZ] - - TTokType* = enum - tkInvalid, tkEof, - tkSymbol, - tkAddr, tkAnd, tkAs, tkAsm, tkBlock, tkBreak, tkCase, tkCast, tkConst, - tkContinue, tkConverter, tkDiscard, tkDiv, tkElif, tkElse, tkEnd, tkEnum, - tkExcept, tkException, tkFinally, tkFor, tkFrom, tkGeneric, tkIf, tkImplies, - tkImport, tkIn, tkInclude, tkIs, tkIsnot, tkIterator, tkLambda, tkMacro, - tkMethod, tkMod, tkNil, tkNot, tkNotin, tkObject, tkOf, tkOr, tkOut, tkProc, - tkPtr, tkRaise, tkRecord, tkRef, tkReturn, tkShl, tkShr, tkTemplate, tkTry, - tkType, tkVar, tkWhen, tkWhere, tkWhile, tkWith, tkWithout, tkXor, tkYield, - tkIntLit, tkInt8Lit, tkInt16Lit, tkInt32Lit, tkInt64Lit, tkFloatLit, - tkFloat32Lit, tkFloat64Lit, tkStrLit, tkRStrLit, tkTripleStrLit, tkCharLit, - tkRCharLit, tkParLe, tkParRi, tkBracketLe, tkBracketRi, tkCurlyLe, - tkCurlyRi, tkBracketDotLe, tkBracketDotRi, - tkCurlyDotLe, tkCurlyDotRi, - tkParDotLe, tkParDotRi, - tkComma, tkSemiColon, tkColon, tkEquals, tkDot, tkDotDot, tkHat, tkOpr, - tkComment, tkAccent, tkInd, tkSad, tkDed, - tkSpaces, tkInfixOpr, tkPrefixOpr, tkPostfixOpr - TTokTypeRange = range[tkSymbol..tkDed] - TTokTypes* = set[TTokTypeRange] - -const - toktypes: TTokTypes = {TTokTypeRange(tkSymbol)..pred(tkIntLit), - tkStrLit..tkTripleStrLit} - -var - s: set[char] - a: TAZset -s = {'0'..'9'} -testSets(s) -if 'F' in s: write(stdout, "Ha ein F ist in s!\n") -else: write(stdout, "BUG: F ist nicht in s!\n") -a = {} #{'a'..'z'} -for x in low(TAZ) .. high(TAZ): - incl(a, x) - if x in a: discard - else: write(stdout, "BUG: something not in a!\n") - -for x in low(TTokTypeRange) .. high(TTokTypeRange): - if x in tokTypes: - discard - #writeLine(stdout, "the token '$1' is in the set" % repr(x)) - -#OUT Ha ein F ist in s! - - -type - TMsgKind* = enum - errUnknown, errIllFormedAstX, errInternal, errCannotOpenFile, errGenerated, - errXCompilerDoesNotSupportCpp, errStringLiteralExpected, - errIntLiteralExpected, errInvalidCharacterConstant, - errClosingTripleQuoteExpected, errClosingQuoteExpected, - errTabulatorsAreNotAllowed, errInvalidToken, errLineTooLong, - errInvalidNumber, errNumberOutOfRange, errNnotAllowedInCharacter, - errClosingBracketExpected, errMissingFinalQuote, errIdentifierExpected, - errNewlineExpected, - errInvalidModuleName, - errOperatorExpected, errTokenExpected, errStringAfterIncludeExpected, - errRecursiveDependencyX, errOnOrOffExpected, errNoneSpeedOrSizeExpected, - errInvalidPragma, errUnknownPragma, errInvalidDirectiveX, - errAtPopWithoutPush, errEmptyAsm, errInvalidIndentation, - errExceptionExpected, errExceptionAlreadyHandled, - errYieldNotAllowedHere, errYieldNotAllowedInTryStmt, - errInvalidNumberOfYieldExpr, errCannotReturnExpr, errAttemptToRedefine, - errStmtInvalidAfterReturn, errStmtExpected, errInvalidLabel, - errInvalidCmdLineOption, errCmdLineArgExpected, errCmdLineNoArgExpected, - errInvalidVarSubstitution, errUnknownVar, errUnknownCcompiler, - errOnOrOffExpectedButXFound, errNoneBoehmRefcExpectedButXFound, - errNoneSpeedOrSizeExpectedButXFound, errGuiConsoleOrLibExpectedButXFound, - errUnknownOS, errUnknownCPU, errGenOutExpectedButXFound, - errArgsNeedRunOption, errInvalidMultipleAsgn, errColonOrEqualsExpected, - errExprExpected, errUndeclaredIdentifier, errUseQualifier, errTypeExpected, - errSystemNeeds, errExecutionOfProgramFailed, errNotOverloadable, - errInvalidArgForX, errStmtHasNoEffect, errXExpectsTypeOrValue, - errXExpectsArrayType, errIteratorCannotBeInstantiated, errExprXAmbiguous, - errConstantDivisionByZero, errOrdinalTypeExpected, - errOrdinalOrFloatTypeExpected, errOverOrUnderflow, - errCannotEvalXBecauseIncompletelyDefined, errChrExpectsRange0_255, - errDynlibRequiresExportc, errUndeclaredFieldX, errNilAccess, - errIndexOutOfBounds, errIndexTypesDoNotMatch, errBracketsInvalidForType, - errValueOutOfSetBounds, errFieldInitTwice, errFieldNotInit, - errExprXCannotBeCalled, errExprHasNoType, errExprXHasNoType, - errCastNotInSafeMode, errExprCannotBeCastedToX, errCommaOrParRiExpected, - errCurlyLeOrParLeExpected, errSectionExpected, errRangeExpected, - errMagicOnlyInSystem, errPowerOfTwoExpected, - errStringMayNotBeEmpty, errCallConvExpected, errProcOnlyOneCallConv, - errSymbolMustBeImported, errExprMustBeBool, errConstExprExpected, - errDuplicateCaseLabel, errRangeIsEmpty, errSelectorMustBeOfCertainTypes, - errSelectorMustBeOrdinal, errOrdXMustNotBeNegative, errLenXinvalid, - errWrongNumberOfVariables, errExprCannotBeRaised, errBreakOnlyInLoop, - errTypeXhasUnknownSize, errConstNeedsConstExpr, errConstNeedsValue, - errResultCannotBeOpenArray, errSizeTooBig, errSetTooBig, - errBaseTypeMustBeOrdinal, errInheritanceOnlyWithNonFinalObjects, - errInheritanceOnlyWithEnums, errIllegalRecursionInTypeX, - errCannotInstantiateX, errExprHasNoAddress, errXStackEscape, - errVarForOutParamNeeded, - errPureTypeMismatch, errTypeMismatch, errButExpected, errButExpectedX, - errAmbiguousCallXYZ, errWrongNumberOfArguments, - errXCannotBePassedToProcVar, - errXCannotBeInParamDecl, errPragmaOnlyInHeaderOfProc, errImplOfXNotAllowed, - errImplOfXexpected, errNoSymbolToBorrowFromFound, errDiscardValueX, - errInvalidDiscard, errIllegalConvFromXtoY, errCannotBindXTwice, - errInvalidOrderInArrayConstructor, - errInvalidOrderInEnumX, errEnumXHasHoles, errExceptExpected, errInvalidTry, - errOptionExpected, errXisNoLabel, errNotAllCasesCovered, - errUnknownSubstitionVar, errComplexStmtRequiresInd, errXisNotCallable, - errNoPragmasAllowedForX, errNoGenericParamsAllowedForX, - errInvalidParamKindX, errDefaultArgumentInvalid, errNamedParamHasToBeIdent, - errNoReturnTypeForX, errConvNeedsOneArg, errInvalidPragmaX, - errXNotAllowedHere, errInvalidControlFlowX, - errXisNoType, errCircumNeedsPointer, errInvalidExpression, - errInvalidExpressionX, errEnumHasNoValueX, errNamedExprExpected, - errNamedExprNotAllowed, errXExpectsOneTypeParam, - errArrayExpectsTwoTypeParams, errInvalidVisibilityX, errInitHereNotAllowed, - errXCannotBeAssignedTo, errIteratorNotAllowed, errXNeedsReturnType, - errNoReturnTypeDeclared, - errInvalidCommandX, errXOnlyAtModuleScope, - errXNeedsParamObjectType, - errTemplateInstantiationTooNested, errInstantiationFrom, - errInvalidIndexValueForTuple, errCommandExpectsFilename, - errMainModuleMustBeSpecified, - errXExpected, - errTIsNotAConcreteType, - errInvalidSectionStart, errGridTableNotImplemented, errGeneralParseError, - errNewSectionExpected, errWhitespaceExpected, errXisNoValidIndexFile, - errCannotRenderX, errVarVarTypeNotAllowed, errInstantiateXExplicitly, - errOnlyACallOpCanBeDelegator, errUsingNoSymbol, - errMacroBodyDependsOnGenericTypes, - errDestructorNotGenericEnough, - errInlineIteratorsAsProcParams, - errXExpectsTwoArguments, - errXExpectsObjectTypes, errXcanNeverBeOfThisSubtype, errTooManyIterations, - errCannotInterpretNodeX, errFieldXNotFound, errInvalidConversionFromTypeX, - errAssertionFailed, errCannotGenerateCodeForX, errXRequiresOneArgument, - errUnhandledExceptionX, errCyclicTree, errXisNoMacroOrTemplate, - errXhasSideEffects, errIteratorExpected, errLetNeedsInit, - errThreadvarCannotInit, errWrongSymbolX, errIllegalCaptureX, - errXCannotBeClosure, errXMustBeCompileTime, - errCannotInferTypeOfTheLiteral, - errCannotInferReturnType, - errGenericLambdaNotAllowed, - errCompilerDoesntSupportTarget, - errUser, - warnCannotOpenFile, - warnOctalEscape, warnXIsNeverRead, warnXmightNotBeenInit, - warnDeprecated, warnConfigDeprecated, - warnSmallLshouldNotBeUsed, warnUnknownMagic, warnRedefinitionOfLabel, - warnUnknownSubstitutionX, warnLanguageXNotSupported, - warnFieldXNotSupported, warnCommentXIgnored, - warnNilStatement, warnTypelessParam, - warnDifferentHeaps, warnWriteToForeignHeap, warnUnsafeCode, - warnEachIdentIsTuple, warnShadowIdent, - warnProveInit, warnProveField, warnProveIndex, warnGcUnsafe, warnGcUnsafe2, - warnUninit, warnGcMem, warnDestructor, warnLockLevel, warnResultShadowed, - warnUser, - hintSuccess, hintSuccessX, - hintLineTooLong, hintXDeclaredButNotUsed, hintConvToBaseNotNeeded, - hintConvFromXtoItselfNotNeeded, hintExprAlwaysX, hintQuitCalled, - hintProcessing, hintCodeBegin, hintCodeEnd, hintConf, hintPath, - hintConditionAlwaysTrue, hintName, hintPattern, - hintUser - -const - fatalMin* = errUnknown - fatalMax* = errInternal - errMin* = errUnknown - errMax* = errUser - warnMin* = warnCannotOpenFile - warnMax* = pred(hintSuccess) - hintMin* = hintSuccess - hintMax* = high(TMsgKind) - -type - TNoteKind* = range[warnMin..hintMax] # "notes" are warnings or hints - TNoteKinds* = set[TNoteKind] - -var - gNotes*: TNoteKinds = {low(TNoteKind)..high(TNoteKind)} - - {warnShadowIdent, warnUninit, - warnProveField, warnProveIndex, warnGcUnsafe} - - -#import compiler.msgs - -echo warnUninit in gNotes +discard """ + file: "tsets.nim" + output: '''Ha ein F ist in s! +false''' +""" +# Test the handling of sets + +import + strutils + +proc testSets(s: var set[char]) = + s = {'A', 'B', 'C', 'E'..'G'} + {'Z'} + s + +# test sets if the first element is different from 0: +type + TAZ = range['a'..'z'] + TAZset = set[TAZ] + + TTokType* = enum + tkInvalid, tkEof, + tkSymbol, + tkAddr, tkAnd, tkAs, tkAsm, tkBlock, tkBreak, tkCase, tkCast, tkConst, + tkContinue, tkConverter, tkDiscard, tkDiv, tkElif, tkElse, tkEnd, tkEnum, + tkExcept, tkException, tkFinally, tkFor, tkFrom, tkGeneric, tkIf, tkImplies, + tkImport, tkIn, tkInclude, tkIs, tkIsnot, tkIterator, tkLambda, tkMacro, + tkMethod, tkMod, tkNil, tkNot, tkNotin, tkObject, tkOf, tkOr, tkOut, tkProc, + tkPtr, tkRaise, tkRecord, tkRef, tkReturn, tkShl, tkShr, tkTemplate, tkTry, + tkType, tkVar, tkWhen, tkWhere, tkWhile, tkWith, tkWithout, tkXor, tkYield, + tkIntLit, tkInt8Lit, tkInt16Lit, tkInt32Lit, tkInt64Lit, tkFloatLit, + tkFloat32Lit, tkFloat64Lit, tkStrLit, tkRStrLit, tkTripleStrLit, tkCharLit, + tkRCharLit, tkParLe, tkParRi, tkBracketLe, tkBracketRi, tkCurlyLe, + tkCurlyRi, tkBracketDotLe, tkBracketDotRi, + tkCurlyDotLe, tkCurlyDotRi, + tkParDotLe, tkParDotRi, + tkComma, tkSemiColon, tkColon, tkEquals, tkDot, tkDotDot, tkHat, tkOpr, + tkComment, tkAccent, tkInd, tkSad, tkDed, + tkSpaces, tkInfixOpr, tkPrefixOpr, tkPostfixOpr + TTokTypeRange = range[tkSymbol..tkDed] + TTokTypes* = set[TTokTypeRange] + +const + toktypes: TTokTypes = {TTokTypeRange(tkSymbol)..pred(tkIntLit), + tkStrLit..tkTripleStrLit} + +var + s: set[char] + a: TAZset +s = {'0'..'9'} +testSets(s) +if 'F' in s: write(stdout, "Ha ein F ist in s!\n") +else: write(stdout, "BUG: F ist nicht in s!\n") +a = {} #{'a'..'z'} +for x in low(TAZ) .. high(TAZ): + incl(a, x) + if x in a: discard + else: write(stdout, "BUG: something not in a!\n") + +for x in low(TTokTypeRange) .. high(TTokTypeRange): + if x in tokTypes: + discard + #writeLine(stdout, "the token '$1' is in the set" % repr(x)) + +#OUT Ha ein F ist in s! + + +type + TMsgKind* = enum + errUnknown, errIllFormedAstX, errInternal, errCannotOpenFile, errGenerated, + errXCompilerDoesNotSupportCpp, errStringLiteralExpected, + errIntLiteralExpected, errInvalidCharacterConstant, + errClosingTripleQuoteExpected, errClosingQuoteExpected, + errTabulatorsAreNotAllowed, errInvalidToken, errLineTooLong, + errInvalidNumber, errNumberOutOfRange, errNnotAllowedInCharacter, + errClosingBracketExpected, errMissingFinalQuote, errIdentifierExpected, + errNewlineExpected, + errInvalidModuleName, + errOperatorExpected, errTokenExpected, errStringAfterIncludeExpected, + errRecursiveDependencyX, errOnOrOffExpected, errNoneSpeedOrSizeExpected, + errInvalidPragma, errUnknownPragma, errInvalidDirectiveX, + errAtPopWithoutPush, errEmptyAsm, errInvalidIndentation, + errExceptionExpected, errExceptionAlreadyHandled, + errYieldNotAllowedHere, errYieldNotAllowedInTryStmt, + errInvalidNumberOfYieldExpr, errCannotReturnExpr, errAttemptToRedefine, + errStmtInvalidAfterReturn, errStmtExpected, errInvalidLabel, + errInvalidCmdLineOption, errCmdLineArgExpected, errCmdLineNoArgExpected, + errInvalidVarSubstitution, errUnknownVar, errUnknownCcompiler, + errOnOrOffExpectedButXFound, errNoneBoehmRefcExpectedButXFound, + errNoneSpeedOrSizeExpectedButXFound, errGuiConsoleOrLibExpectedButXFound, + errUnknownOS, errUnknownCPU, errGenOutExpectedButXFound, + errArgsNeedRunOption, errInvalidMultipleAsgn, errColonOrEqualsExpected, + errExprExpected, errUndeclaredIdentifier, errUseQualifier, errTypeExpected, + errSystemNeeds, errExecutionOfProgramFailed, errNotOverloadable, + errInvalidArgForX, errStmtHasNoEffect, errXExpectsTypeOrValue, + errXExpectsArrayType, errIteratorCannotBeInstantiated, errExprXAmbiguous, + errConstantDivisionByZero, errOrdinalTypeExpected, + errOrdinalOrFloatTypeExpected, errOverOrUnderflow, + errCannotEvalXBecauseIncompletelyDefined, errChrExpectsRange0_255, + errDynlibRequiresExportc, errUndeclaredFieldX, errNilAccess, + errIndexOutOfBounds, errIndexTypesDoNotMatch, errBracketsInvalidForType, + errValueOutOfSetBounds, errFieldInitTwice, errFieldNotInit, + errExprXCannotBeCalled, errExprHasNoType, errExprXHasNoType, + errCastNotInSafeMode, errExprCannotBeCastedToX, errCommaOrParRiExpected, + errCurlyLeOrParLeExpected, errSectionExpected, errRangeExpected, + errMagicOnlyInSystem, errPowerOfTwoExpected, + errStringMayNotBeEmpty, errCallConvExpected, errProcOnlyOneCallConv, + errSymbolMustBeImported, errExprMustBeBool, errConstExprExpected, + errDuplicateCaseLabel, errRangeIsEmpty, errSelectorMustBeOfCertainTypes, + errSelectorMustBeOrdinal, errOrdXMustNotBeNegative, errLenXinvalid, + errWrongNumberOfVariables, errExprCannotBeRaised, errBreakOnlyInLoop, + errTypeXhasUnknownSize, errConstNeedsConstExpr, errConstNeedsValue, + errResultCannotBeOpenArray, errSizeTooBig, errSetTooBig, + errBaseTypeMustBeOrdinal, errInheritanceOnlyWithNonFinalObjects, + errInheritanceOnlyWithEnums, errIllegalRecursionInTypeX, + errCannotInstantiateX, errExprHasNoAddress, errXStackEscape, + errVarForOutParamNeeded, + errPureTypeMismatch, errTypeMismatch, errButExpected, errButExpectedX, + errAmbiguousCallXYZ, errWrongNumberOfArguments, + errXCannotBePassedToProcVar, + errXCannotBeInParamDecl, errPragmaOnlyInHeaderOfProc, errImplOfXNotAllowed, + errImplOfXexpected, errNoSymbolToBorrowFromFound, errDiscardValueX, + errInvalidDiscard, errIllegalConvFromXtoY, errCannotBindXTwice, + errInvalidOrderInArrayConstructor, + errInvalidOrderInEnumX, errEnumXHasHoles, errExceptExpected, errInvalidTry, + errOptionExpected, errXisNoLabel, errNotAllCasesCovered, + errUnknownSubstitionVar, errComplexStmtRequiresInd, errXisNotCallable, + errNoPragmasAllowedForX, errNoGenericParamsAllowedForX, + errInvalidParamKindX, errDefaultArgumentInvalid, errNamedParamHasToBeIdent, + errNoReturnTypeForX, errConvNeedsOneArg, errInvalidPragmaX, + errXNotAllowedHere, errInvalidControlFlowX, + errXisNoType, errCircumNeedsPointer, errInvalidExpression, + errInvalidExpressionX, errEnumHasNoValueX, errNamedExprExpected, + errNamedExprNotAllowed, errXExpectsOneTypeParam, + errArrayExpectsTwoTypeParams, errInvalidVisibilityX, errInitHereNotAllowed, + errXCannotBeAssignedTo, errIteratorNotAllowed, errXNeedsReturnType, + errNoReturnTypeDeclared, + errInvalidCommandX, errXOnlyAtModuleScope, + errXNeedsParamObjectType, + errTemplateInstantiationTooNested, errInstantiationFrom, + errInvalidIndexValueForTuple, errCommandExpectsFilename, + errMainModuleMustBeSpecified, + errXExpected, + errTIsNotAConcreteType, + errInvalidSectionStart, errGridTableNotImplemented, errGeneralParseError, + errNewSectionExpected, errWhitespaceExpected, errXisNoValidIndexFile, + errCannotRenderX, errVarVarTypeNotAllowed, errInstantiateXExplicitly, + errOnlyACallOpCanBeDelegator, errUsingNoSymbol, + errMacroBodyDependsOnGenericTypes, + errDestructorNotGenericEnough, + errInlineIteratorsAsProcParams, + errXExpectsTwoArguments, + errXExpectsObjectTypes, errXcanNeverBeOfThisSubtype, errTooManyIterations, + errCannotInterpretNodeX, errFieldXNotFound, errInvalidConversionFromTypeX, + errAssertionFailed, errCannotGenerateCodeForX, errXRequiresOneArgument, + errUnhandledExceptionX, errCyclicTree, errXisNoMacroOrTemplate, + errXhasSideEffects, errIteratorExpected, errLetNeedsInit, + errThreadvarCannotInit, errWrongSymbolX, errIllegalCaptureX, + errXCannotBeClosure, errXMustBeCompileTime, + errCannotInferTypeOfTheLiteral, + errCannotInferReturnType, + errGenericLambdaNotAllowed, + errCompilerDoesntSupportTarget, + errUser, + warnCannotOpenFile, + warnOctalEscape, warnXIsNeverRead, warnXmightNotBeenInit, + warnDeprecated, warnConfigDeprecated, + warnSmallLshouldNotBeUsed, warnUnknownMagic, warnRedefinitionOfLabel, + warnUnknownSubstitutionX, warnLanguageXNotSupported, + warnFieldXNotSupported, warnCommentXIgnored, + warnNilStatement, warnTypelessParam, + warnDifferentHeaps, warnWriteToForeignHeap, warnUnsafeCode, + warnEachIdentIsTuple, warnShadowIdent, + warnProveInit, warnProveField, warnProveIndex, warnGcUnsafe, warnGcUnsafe2, + warnUninit, warnGcMem, warnDestructor, warnLockLevel, warnResultShadowed, + warnUser, + hintSuccess, hintSuccessX, + hintLineTooLong, hintXDeclaredButNotUsed, hintConvToBaseNotNeeded, + hintConvFromXtoItselfNotNeeded, hintExprAlwaysX, hintQuitCalled, + hintProcessing, hintCodeBegin, hintCodeEnd, hintConf, hintPath, + hintConditionAlwaysTrue, hintName, hintPattern, + hintUser + +const + fatalMin* = errUnknown + fatalMax* = errInternal + errMin* = errUnknown + errMax* = errUser + warnMin* = warnCannotOpenFile + warnMax* = pred(hintSuccess) + hintMin* = hintSuccess + hintMax* = high(TMsgKind) + +type + TNoteKind* = range[warnMin..hintMax] # "notes" are warnings or hints + TNoteKinds* = set[TNoteKind] + +var + gNotes*: TNoteKinds = {low(TNoteKind)..high(TNoteKind)} - + {warnShadowIdent, warnUninit, + warnProveField, warnProveIndex, warnGcUnsafe} + + +#import compiler.msgs + +echo warnUninit in gNotes diff --git a/tests/sets/tsets2.nim b/tests/sets/tsets2.nim index 7f313e14f7..9c73dbe031 100644 --- a/tests/sets/tsets2.nim +++ b/tests/sets/tsets2.nim @@ -28,7 +28,7 @@ block tableTest1: for x in 0..1: for y in 0..1: assert((x,y) in t) - #assert($t == + #assert($t == # "{(x: 0, y: 0), (x: 0, y: 1), (x: 1, y: 0), (x: 1, y: 1)}") block setTest2: @@ -37,16 +37,16 @@ block setTest2: t.incl("111") t.incl("123") t.excl("111") - + t.incl("012") t.incl("123") # test duplicates - + assert "123" in t assert "111" notin t # deleted - + for key in items(data): t.incl(key) for key in items(data): assert key in t - + block orderedSetTest1: var t = data.toOrderedSet diff --git a/tests/showoff/thtml1.nim b/tests/showoff/thtml1.nim index cd95c7971a..c7a083c21c 100644 --- a/tests/showoff/thtml1.nim +++ b/tests/showoff/thtml1.nim @@ -4,7 +4,7 @@ discard """ template htmlTag(tag: expr) {.immediate.} = proc tag(): string = "<" & astToStr(tag) & ">" - + htmlTag(br) htmlTag(html) diff --git a/tests/stckovfl.nim b/tests/stckovfl.nim index eeb499bed5..cbc893d2ee 100644 --- a/tests/stckovfl.nim +++ b/tests/stckovfl.nim @@ -1,10 +1,10 @@ # To test stack overflow message -proc over(a: int): int = +proc over(a: int): int = if a >= 10: assert false return result = over(a+1)+5 - + Echo($over(0)) diff --git a/tests/stdlib/nre/captures.nim b/tests/stdlib/nre/captures.nim index 4f3f154444..19c344a8db 100644 --- a/tests/stdlib/nre/captures.nim +++ b/tests/stdlib/nre/captures.nim @@ -3,7 +3,7 @@ include nre suite "captures": test "map capture names to numbers": - check(getNameToNumberTable(re("(?1(?2(?3))(?'v4'4))()")) == + check(getNameToNumberTable(re("(?1(?2(?3))(?'v4'4))()")) == { "v1" : 0, "v2" : 1, "v3" : 2, "v4" : 3 }.toTable()) test "capture bounds are correct": diff --git a/tests/stdlib/talgorithm.nim b/tests/stdlib/talgorithm.nim index 3ca425fbce..f200e54c57 100644 --- a/tests/stdlib/talgorithm.nim +++ b/tests/stdlib/talgorithm.nim @@ -8,4 +8,4 @@ doAssert product(@[@[1,2], @[3,4], @[5,6]]) == @[@[2,4,6],@[1,4,6],@[2,3,6],@[1, doAssert product(@[@[1,2], @[]]) == newSeq[seq[int]](), "two elements, but one empty" doAssert lowerBound([1,2,4], 3, system.cmp[int]) == 2 doAssert lowerBound([1,2,2,3], 4, system.cmp[int]) == 4 -doAssert lowerBound([1,2,3,10], 11) == 4 \ No newline at end of file +doAssert lowerBound([1,2,3,10], 11) == 4 diff --git a/tests/stdlib/tcritbits.nim b/tests/stdlib/tcritbits.nim index fb447b80b6..8280ec8812 100644 --- a/tests/stdlib/tcritbits.nim +++ b/tests/stdlib/tcritbits.nim @@ -22,7 +22,7 @@ when isMainModule: for w in r.items: echo w - + for w in r.itemsWithPrefix("de"): echo w diff --git a/tests/stdlib/tformat.nim b/tests/stdlib/tformat.nim index 92c0c16f50..160ab0fd56 100644 --- a/tests/stdlib/tformat.nim +++ b/tests/stdlib/tformat.nim @@ -2,11 +2,11 @@ discard """ file: "tformat.nim" output: "Hi Andreas! How do you feel, Rumpf?" """ -# Tests the new format proc (including the & and &= operators) - -import strutils - -echo("Hi $1! How do you feel, $2?\n" % ["Andreas", "Rumpf"]) -#OUT Hi Andreas! How do you feel, Rumpf? +# Tests the new format proc (including the & and &= operators) + +import strutils + +echo("Hi $1! How do you feel, $2?\n" % ["Andreas", "Rumpf"]) +#OUT Hi Andreas! How do you feel, Rumpf? diff --git a/tests/stdlib/tio.nim b/tests/stdlib/tio.nim index dcb6bd54f3..ebf2d70f33 100644 --- a/tests/stdlib/tio.nim +++ b/tests/stdlib/tio.nim @@ -1,7 +1,7 @@ -# test the file-IO - -proc main() = - for line in lines("thello.nim"): - writeLine(stdout, line) - -main() +# test the file-IO + +proc main() = + for line in lines("thello.nim"): + writeLine(stdout, line) + +main() diff --git a/tests/stdlib/tlists.nim b/tests/stdlib/tlists.nim index 7d53799457..4caa05c90d 100644 --- a/tests/stdlib/tlists.nim +++ b/tests/stdlib/tlists.nim @@ -11,14 +11,14 @@ block SinglyLinkedListTest1: var L: TSinglyLinkedList[int] for d in items(data): L.prepend(d) assert($L == "[6, 5, 4, 3, 2, 1]") - + assert(4 in L) block SinglyLinkedListTest2: var L: TSinglyLinkedList[string] for d in items(data): L.prepend($d) assert($L == "[6, 5, 4, 3, 2, 1]") - + assert("4" in L) @@ -28,7 +28,7 @@ block DoublyLinkedListTest1: for d in items(data): L.append(d) L.remove(L.find(1)) assert($L == "[6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6]") - + assert(4 in L) block SinglyLinkedRingTest1: @@ -39,7 +39,7 @@ block SinglyLinkedRingTest1: assert($L == "[4, 4]") assert(4 in L) - + block DoublyLinkedRingTest1: var L: TDoublyLinkedRing[int] @@ -49,7 +49,7 @@ block DoublyLinkedRingTest1: assert($L == "[4, 4]") assert(4 in L) - + L.append(3) L.append(5) assert($L == "[4, 4, 3, 5]") @@ -60,7 +60,7 @@ block DoublyLinkedRingTest1: L.remove(L.find(4)) assert($L == "[]") assert(4 notin L) - + echo "true" diff --git a/tests/stdlib/tmarshal.nim b/tests/stdlib/tmarshal.nim index a778d2f77c..4c0c103606 100644 --- a/tests/stdlib/tmarshal.nim +++ b/tests/stdlib/tmarshal.nim @@ -25,7 +25,7 @@ type help: string else: discard - + PNode = ref TNode TNode = object next, prev: PNode diff --git a/tests/stdlib/tmath.nim b/tests/stdlib/tmath.nim index fc9486093d..1ac9c80923 100644 --- a/tests/stdlib/tmath.nim +++ b/tests/stdlib/tmath.nim @@ -23,13 +23,13 @@ suite "random int": rand = random(100..1000) check rand < 1000 check rand >= 100 - test "randomize() again gives new numbers": + test "randomize() again gives new numbers": randomize() var rand1 = random(1000000) randomize() var rand2 = random(1000000) check rand1 != rand2 - + suite "random float": test "there might be some randomness": @@ -52,7 +52,7 @@ suite "random float": rand = random(100.0..1000.0) check rand < 1000.0 check rand >= 100.0 - test "randomize() again gives new numbers": + test "randomize() again gives new numbers": randomize() var rand1:float = random(1000000.0) randomize() diff --git a/tests/stdlib/tmath2.nim b/tests/stdlib/tmath2.nim index 88d96c80a9..84a49efa92 100644 --- a/tests/stdlib/tmath2.nim +++ b/tests/stdlib/tmath2.nim @@ -1,85 +1,85 @@ -# tests for the interpreter - -proc loops(a: var int) = - discard - #var - # b: int - #b = glob - #while b != 0: - # b = b + 1 - #a = b - -proc mymax(a, b: int): int = - #loops(result) - result = a - if b > a: result = b - -proc test(a, b: int) = - var - x, y: int - x = 0 - y = 7 - if x == a + b * 3 - 7 or - x == 8 or - x == y and y > -56 and y < 699: - y = 0 - elif y == 78 and x == 0: - y = 1 - elif y == 0 and x == 0: - y = 2 - else: - y = 3 - -type - TTokType = enum - tkNil, tkType, tkConst, tkVar, tkSymbol, tkIf, - tkWhile, tkFor, tkLoop, tkCase, tkLabel, tkGoto - -proc testCase(t: TTokType): int = - case t - of tkNil, tkType, tkConst: result = 0 - of tkVar: result = 1 - of tkSymbol: result = 2 - of tkIf..tkFor: result = 3 - of tkLoop: result = 56 - else: result = -1 - test(0, 9) # test the call - -proc TestLoops() = - var - i, j: int - - while i >= 0: - if i mod 3 == 0: - break - i = i + 1 - while j == 13: - j = 13 - break - break - - while true: - break - - -var - glob: int - a: array [0..5, int] - -proc main() = - #glob = 0 - #loops( glob ) - var - res: int - s: string - #write(stdout, mymax(23, 45)) - write(stdout, "Hallo! Wie heisst du? ") - s = readLine(stdin) - # test the case statement - case s - of "Andreas": write(stdout, "Du bist mein Meister!\n") - of "Rumpf": write(stdout, "Du bist in der Familie meines Meisters!\n") - else: write(stdout, "ich kenne dich nicht!\n") - write(stdout, "Du heisst " & s & "\n") - -main() +# tests for the interpreter + +proc loops(a: var int) = + discard + #var + # b: int + #b = glob + #while b != 0: + # b = b + 1 + #a = b + +proc mymax(a, b: int): int = + #loops(result) + result = a + if b > a: result = b + +proc test(a, b: int) = + var + x, y: int + x = 0 + y = 7 + if x == a + b * 3 - 7 or + x == 8 or + x == y and y > -56 and y < 699: + y = 0 + elif y == 78 and x == 0: + y = 1 + elif y == 0 and x == 0: + y = 2 + else: + y = 3 + +type + TTokType = enum + tkNil, tkType, tkConst, tkVar, tkSymbol, tkIf, + tkWhile, tkFor, tkLoop, tkCase, tkLabel, tkGoto + +proc testCase(t: TTokType): int = + case t + of tkNil, tkType, tkConst: result = 0 + of tkVar: result = 1 + of tkSymbol: result = 2 + of tkIf..tkFor: result = 3 + of tkLoop: result = 56 + else: result = -1 + test(0, 9) # test the call + +proc TestLoops() = + var + i, j: int + + while i >= 0: + if i mod 3 == 0: + break + i = i + 1 + while j == 13: + j = 13 + break + break + + while true: + break + + +var + glob: int + a: array [0..5, int] + +proc main() = + #glob = 0 + #loops( glob ) + var + res: int + s: string + #write(stdout, mymax(23, 45)) + write(stdout, "Hallo! Wie heisst du? ") + s = readLine(stdin) + # test the case statement + case s + of "Andreas": write(stdout, "Du bist mein Meister!\n") + of "Rumpf": write(stdout, "Du bist in der Familie meines Meisters!\n") + else: write(stdout, "ich kenne dich nicht!\n") + write(stdout, "Du heisst " & s & "\n") + +main() diff --git a/tests/stdlib/tos.nim b/tests/stdlib/tos.nim index ebe577b009..cae388792c 100644 --- a/tests/stdlib/tos.nim +++ b/tests/stdlib/tos.nim @@ -2,9 +2,9 @@ import os -proc walkDirTree(root: string) = +proc walkDirTree(root: string) = for k, f in walkDir(root): - case k + case k of pcFile, pcLinkToFile: echo(f) of pcDir: walkDirTree(f) of pcLinkToDir: discard diff --git a/tests/stdlib/tosprocterminate.nim b/tests/stdlib/tosprocterminate.nim index fd044414c5..7fc6c5d855 100644 --- a/tests/stdlib/tosprocterminate.nim +++ b/tests/stdlib/tosprocterminate.nim @@ -14,7 +14,7 @@ var TimeToWait = 5000 while process.running() and TimeToWait > 0: sleep(100) TimeToWait = TimeToWait - 100 - + if process.running(): echo("FAILED") else: diff --git a/tests/stdlib/tparscfg.nim b/tests/stdlib/tparscfg.nim index 618ecadd61..4c11ccf615 100644 --- a/tests/stdlib/tparscfg.nim +++ b/tests/stdlib/tparscfg.nim @@ -1,7 +1,7 @@ import os, parsecfg, strutils, streams - + var f = newFileStream(paramStr(1), fmRead) if f != nil: var p: TCfgParser @@ -9,7 +9,7 @@ if f != nil: while true: var e = next(p) case e.kind - of cfgEof: + of cfgEof: echo("EOF!") break of cfgSectionStart: ## a ``[section]`` has been parsed diff --git a/tests/stdlib/tquit.nim b/tests/stdlib/tquit.nim index d4dc1522d9..d18b468c88 100644 --- a/tests/stdlib/tquit.nim +++ b/tests/stdlib/tquit.nim @@ -1,6 +1,6 @@ -# Test the new beforeQuit variable: - -proc myExit() {.noconv.} = - write(stdout, "just exiting...\n") - -addQuitProc(myExit) +# Test the new beforeQuit variable: + +proc myExit() {.noconv.} = + write(stdout, "just exiting...\n") + +addQuitProc(myExit) diff --git a/tests/stdlib/tregex.nim b/tests/stdlib/tregex.nim index bb4695f02e..ae6714de17 100644 --- a/tests/stdlib/tregex.nim +++ b/tests/stdlib/tregex.nim @@ -2,30 +2,30 @@ discard """ file: "tregex.nim" output: "key: keyAYes!" """ -# Test the new regular expression module -# which is based on the PCRE library +# Test the new regular expression module +# which is based on the PCRE library when defined(powerpc64): # cheat as our powerpc test machine has no PCRE installed: echo "key: keyAYes!" -else: - import - re - - if "keyA = valueA" =~ re"\s*(\w+)\s*\=\s*(\w+)": - write(stdout, "key: ", matches[0]) - elif "# comment!" =~ re.re"\s*(\#.*)": - # test re.re"" syntax - echo("comment: ", matches[0]) - else: - echo("Bug!") - - if "Username".match(re"[A-Za-z]+"): - echo("Yes!") - else: - echo("Bug!") - - #OUT key: keyAYes! +else: + import + re + + if "keyA = valueA" =~ re"\s*(\w+)\s*\=\s*(\w+)": + write(stdout, "key: ", matches[0]) + elif "# comment!" =~ re.re"\s*(\#.*)": + # test re.re"" syntax + echo("comment: ", matches[0]) + else: + echo("Bug!") + + if "Username".match(re"[A-Za-z]+"): + echo("Yes!") + else: + echo("Bug!") + + #OUT key: keyAYes! diff --git a/tests/stdlib/treguse.nim b/tests/stdlib/treguse.nim index a610ad7258..3d09eb7310 100644 --- a/tests/stdlib/treguse.nim +++ b/tests/stdlib/treguse.nim @@ -2,26 +2,26 @@ discard """ file: "treguse.nim" output: "055this should be the casehugh" """ -# Test the register usage of the virtual machine and -# the blocks in var statements - -proc main(a, b: int) = - var x = 0 - write(stdout, x) - if x == 0: - var y = 55 - write(stdout, y) - write(stdout, "this should be the case") - var input = "" - if input == "Andreas": - write(stdout, "wow") - else: - write(stdout, "hugh") - else: - var z = 66 - write(stdout, z) # "bug!") - -main(45, 1000) -#OUT 055this should be the casehugh +# Test the register usage of the virtual machine and +# the blocks in var statements + +proc main(a, b: int) = + var x = 0 + write(stdout, x) + if x == 0: + var y = 55 + write(stdout, y) + write(stdout, "this should be the case") + var input = "" + if input == "Andreas": + write(stdout, "wow") + else: + write(stdout, "hugh") + else: + var z = 66 + write(stdout, z) # "bug!") + +main(45, 1000) +#OUT 055this should be the casehugh diff --git a/tests/stdlib/trepr.nim b/tests/stdlib/trepr.nim index 8d13531738..18fe7e0541 100644 --- a/tests/stdlib/trepr.nim +++ b/tests/stdlib/trepr.nim @@ -6,7 +6,7 @@ discard """ type TEnum = enum a, b - + var val = {a, b} stdout.write(repr(val)) stdout.writeLine(repr({'a'..'z', 'A'..'Z'})) diff --git a/tests/stdlib/trepr2.nim b/tests/stdlib/trepr2.nim index b7c2bd152c..a920248515 100644 --- a/tests/stdlib/trepr2.nim +++ b/tests/stdlib/trepr2.nim @@ -1,32 +1,32 @@ -# test the new "repr" built-in proc - -type - TEnum = enum - en1, en2, en3, en4, en5, en6 - - TPoint {.final.} = object - x, y, z: int - s: array [0..1, string] - e: TEnum - -var - p: TPoint - q: ref TPoint - s: seq[ref TPoint] - -p.x = 0 -p.y = 13 -p.z = 45 -p.s[0] = "abc" -p.s[1] = "xyz" -p.e = en6 - -new(q) -q[] = p - -s = @[q, q, q, q] - -writeLine(stdout, repr(p)) -writeLine(stdout, repr(q)) -writeLine(stdout, repr(s)) -writeLine(stdout, repr(en4)) +# test the new "repr" built-in proc + +type + TEnum = enum + en1, en2, en3, en4, en5, en6 + + TPoint {.final.} = object + x, y, z: int + s: array [0..1, string] + e: TEnum + +var + p: TPoint + q: ref TPoint + s: seq[ref TPoint] + +p.x = 0 +p.y = 13 +p.z = 45 +p.s[0] = "abc" +p.s[1] = "xyz" +p.e = en6 + +new(q) +q[] = p + +s = @[q, q, q, q] + +writeLine(stdout, repr(p)) +writeLine(stdout, repr(q)) +writeLine(stdout, repr(s)) +writeLine(stdout, repr(en4)) diff --git a/tests/stdlib/tsplit.nim b/tests/stdlib/tsplit.nim index 25bad33e20..5a1cd2f5fa 100644 --- a/tests/stdlib/tsplit.nim +++ b/tests/stdlib/tsplit.nim @@ -13,7 +13,7 @@ if s == "#abc#xy#z": echo "true" else: echo "false" - + #OUT true diff --git a/tests/stdlib/tstrset.nim b/tests/stdlib/tstrset.nim index 9cdb5ed352..15024c3f1c 100644 --- a/tests/stdlib/tstrset.nim +++ b/tests/stdlib/tstrset.nim @@ -8,7 +8,7 @@ type TRadixNodeLinear = object of TRadixNode len: int8 keys: array [0..31, char] - vals: array [0..31, PRadixNode] + vals: array [0..31, PRadixNode] TRadixNodeFull = object of TRadixNode b: array [char, PRadixNode] TRadixNodeLeaf = object of TRadixNode @@ -16,7 +16,7 @@ type PRadixNodeLinear = ref TRadixNodeLinear PRadixNodeFull = ref TRadixNodeFull PRadixNodeLeaf = ref TRadixNodeLeaf - + proc search(r: PRadixNode, s: string): PRadixNode = var r = r var i = 0 @@ -52,7 +52,7 @@ proc contains*(r: PRadixNode, s: string): bool = proc testOrincl*(r: var PRadixNode, s: string): bool = nil - + proc incl*(r: var PRadixNode, s: string) = discard testOrIncl(r, s) proc excl*(r: var PRadixNode, s: string) = diff --git a/tests/stdlib/tstrtabs.nim b/tests/stdlib/tstrtabs.nim index 8404a6c887..a248cc3b2d 100644 --- a/tests/stdlib/tstrtabs.nim +++ b/tests/stdlib/tstrtabs.nim @@ -4,7 +4,7 @@ var tab = newStringTable({"key1": "val1", "key2": "val2"}, modeStyleInsensitive) for i in 0..80: tab["key_" & $i] = "value" & $i - + for key, val in pairs(tab): writeLine(stdout, key, ": ", val) writeLine(stdout, "length of table ", $tab.len) diff --git a/tests/stdlib/ttime.nim b/tests/stdlib/ttime.nim index bad818816a..859f0abdd0 100644 --- a/tests/stdlib/ttime.nim +++ b/tests/stdlib/ttime.nim @@ -1,6 +1,6 @@ -# test the new time module - -import - times - -write(stdout, $getTime()) +# test the new time module + +import + times + +write(stdout, $getTime()) diff --git a/tests/stdlib/twalker.nim b/tests/stdlib/twalker.nim index aad0fa7865..91c97df01f 100644 --- a/tests/stdlib/twalker.nim +++ b/tests/stdlib/twalker.nim @@ -1,13 +1,13 @@ -# iterate over all files with a given filter: - -import - "../../lib/pure/os.nim", ../../ lib / pure / times - -proc main(filter: string) = - for filename in walkFiles(filter): - writeLine(stdout, filename) - - for key, val in envPairs(): - writeLine(stdout, key & '=' & val) - -main("*.nim") +# iterate over all files with a given filter: + +import + "../../lib/pure/os.nim", ../../ lib / pure / times + +proc main(filter: string) = + for filename in walkFiles(filter): + writeLine(stdout, filename) + + for key, val in envPairs(): + writeLine(stdout, key & '=' & val) + +main("*.nim") diff --git a/tests/system/io.nim b/tests/system/io.nim index ec9a1ed704..b0ccfda9f6 100644 --- a/tests/system/io.nim +++ b/tests/system/io.nim @@ -13,7 +13,7 @@ proc echoLoop(str: string): string = discard process.waitForExit while not output.atEnd: result.add(output.readLine) - + suite "io": suite "readAll": test "stdin": diff --git a/tests/template/annotate.nim b/tests/template/annotate.nim index fa58030dc1..5f395557ba 100644 --- a/tests/template/annotate.nim +++ b/tests/template/annotate.nim @@ -110,4 +110,4 @@ when isMainModule: echo styles echo body echo info - echo shader \ No newline at end of file + echo shader diff --git a/tests/template/mtempl5.nim b/tests/template/mtempl5.nim index 51e8461b80..3c2881764f 100644 --- a/tests/template/mtempl5.nim +++ b/tests/template/mtempl5.nim @@ -1,10 +1,10 @@ -var +var gx = 88 gy = 44 - + template templ*(): int = bind gx, gy gx + gy - + diff --git a/tests/template/otests.nim b/tests/template/otests.nim index c885e23df5..120146343b 100644 --- a/tests/template/otests.nim +++ b/tests/template/otests.nim @@ -1,219 +1,219 @@ -# Fields -const x = 5 - - -# Test substring -static: - assert "test".substring(3) == "t" - assert "test".substring(2,1) == "s" - assert "test".substring(3,2) == "t" - assert "test".substring(1,2) == "es" - - -# Various parsing tests -when true: - - block: #no_substitution - proc actual: string = tmpli html""" -

Test!

- """ - const expected = html""" -

Test!

- """ - doAssert actual() == expected - - block: #basic - proc actual: string = tmpli html""" -

Test $$x

- $x - """ - const expected = html""" -

Test $x

- 5 - """ - doAssert actual() == expected - - block: #expression - proc actual: string = tmpli html""" -

Test $$(x * 5)

- $(x * 5) - """ - const expected = html""" -

Test $(x * 5)

- 25 - """ - doAssert actual() == expected - - block: #escape - proc actual: string = tmpli js""" - [{ - "hello world" - }] - """ - const expected = js""" - [{ - "hello world" - }] - """ - doAssert actual() == expected - - block: #forIn - proc actual: string = tmpli html""" -

Test for

-
    - $for y in 0..2 { -
  • $y
  • - } -
- """ - const expected = html""" -

Test for

-
    -
  • 0
  • -
  • 1
  • -
  • 2
  • -
- """ - doAssert actual() == expected - - block: #while - proc actual: string = tmpli html""" -

Test while/stmt

-
    - ${ var y = 0 } - $while y < 4 { -
  • $y
  • - ${ inc(y) } - } -
- """ - const expected = html""" -

Test while/stmt

-
    -
  • 0
  • -
  • 1
  • -
  • 2
  • -
  • 3
  • -
- """ - doAssert actual() == expected - - block: #ifElifElse - proc actual: string = tmpli html""" -

Test if/elif/else

- $if x == 8 { -
x is 8!
- } - $elif x == 7 { -
x is 7!
- } - $else { -
x is neither!
- } - """ - const expected = html""" -

Test if/elif/else

-
x is neither!
- """ - doAssert actual() == expected - - block: #multiLineStatements - proc actual: string = tmpli html""" -

Test multiline statements

- ${ - var x = 5 - var y = 7 - } - $x$y - """ - const expected = html""" -

Test multiline statements

- 57 - """ - doAssert actual() == expected - - block: #caseOfElse - proc actual: string = tmpli html""" -

Test case

- $case x - $of 5 { -
x == 5
- } - $of 6 { -
x == 6
- } - $else {} - """ - const expected = html""" -

Test case

-
x == 5
- """ - doAssert actual() == expected - - - -when true: #embeddingTest - proc no_substitution: string = tmpli html""" -

Template test!

- """ - - # # Single variable substitution - proc substitution(who = "nobody"): string = tmpli html""" -
hello $who!
- """ - - # Expression template - proc test_expression(nums: openarray[int] = []): string = - var i = 2 - tmpli html""" - $(no_substitution()) - $(substitution("Billy")) -
Age: $($nums[i] & "!!")
- """ - - proc test_statements(nums: openarray[int] = []): string = - tmpli html""" - $(test_expression(nums)) - $if true { -
    - $for i in nums { -
  • $(i * 2)
  • - } -
- } - """ - - var actual = test_statements([0,1,2]) - const expected = html""" -

Template test!

-
hello Billy!
-
Age: 2!!
-
    -
  • 0
  • -
  • 2
  • -
  • 4
  • -
- """ - doAssert actual == expected - - -when defined(future): - block: #tryCatch - proc actual: string = tmpli html""" -

Test try/catch

-
- $try { -
Lets try this!
- } - $except { -
Uh oh!
- } -
- """ - const expected = html""" -

Test try/catch

-
-
Lets try this!
-
- """ - doAssert actual() == expected \ No newline at end of file +# Fields +const x = 5 + + +# Test substring +static: + assert "test".substring(3) == "t" + assert "test".substring(2,1) == "s" + assert "test".substring(3,2) == "t" + assert "test".substring(1,2) == "es" + + +# Various parsing tests +when true: + + block: #no_substitution + proc actual: string = tmpli html""" +

Test!

+ """ + const expected = html""" +

Test!

+ """ + doAssert actual() == expected + + block: #basic + proc actual: string = tmpli html""" +

Test $$x

+ $x + """ + const expected = html""" +

Test $x

+ 5 + """ + doAssert actual() == expected + + block: #expression + proc actual: string = tmpli html""" +

Test $$(x * 5)

+ $(x * 5) + """ + const expected = html""" +

Test $(x * 5)

+ 25 + """ + doAssert actual() == expected + + block: #escape + proc actual: string = tmpli js""" + [{ + "hello world" + }] + """ + const expected = js""" + [{ + "hello world" + }] + """ + doAssert actual() == expected + + block: #forIn + proc actual: string = tmpli html""" +

Test for

+
    + $for y in 0..2 { +
  • $y
  • + } +
+ """ + const expected = html""" +

Test for

+
    +
  • 0
  • +
  • 1
  • +
  • 2
  • +
+ """ + doAssert actual() == expected + + block: #while + proc actual: string = tmpli html""" +

Test while/stmt

+
    + ${ var y = 0 } + $while y < 4 { +
  • $y
  • + ${ inc(y) } + } +
+ """ + const expected = html""" +

Test while/stmt

+
    +
  • 0
  • +
  • 1
  • +
  • 2
  • +
  • 3
  • +
+ """ + doAssert actual() == expected + + block: #ifElifElse + proc actual: string = tmpli html""" +

Test if/elif/else

+ $if x == 8 { +
x is 8!
+ } + $elif x == 7 { +
x is 7!
+ } + $else { +
x is neither!
+ } + """ + const expected = html""" +

Test if/elif/else

+
x is neither!
+ """ + doAssert actual() == expected + + block: #multiLineStatements + proc actual: string = tmpli html""" +

Test multiline statements

+ ${ + var x = 5 + var y = 7 + } + $x$y + """ + const expected = html""" +

Test multiline statements

+ 57 + """ + doAssert actual() == expected + + block: #caseOfElse + proc actual: string = tmpli html""" +

Test case

+ $case x + $of 5 { +
x == 5
+ } + $of 6 { +
x == 6
+ } + $else {} + """ + const expected = html""" +

Test case

+
x == 5
+ """ + doAssert actual() == expected + + + +when true: #embeddingTest + proc no_substitution: string = tmpli html""" +

Template test!

+ """ + + # # Single variable substitution + proc substitution(who = "nobody"): string = tmpli html""" +
hello $who!
+ """ + + # Expression template + proc test_expression(nums: openarray[int] = []): string = + var i = 2 + tmpli html""" + $(no_substitution()) + $(substitution("Billy")) +
Age: $($nums[i] & "!!")
+ """ + + proc test_statements(nums: openarray[int] = []): string = + tmpli html""" + $(test_expression(nums)) + $if true { +
    + $for i in nums { +
  • $(i * 2)
  • + } +
+ } + """ + + var actual = test_statements([0,1,2]) + const expected = html""" +

Template test!

+
hello Billy!
+
Age: 2!!
+
    +
  • 0
  • +
  • 2
  • +
  • 4
  • +
+ """ + doAssert actual == expected + + +when defined(future): + block: #tryCatch + proc actual: string = tmpli html""" +

Test try/catch

+
+ $try { +
Lets try this!
+ } + $except { +
Uh oh!
+ } +
+ """ + const expected = html""" +

Test try/catch

+
+
Lets try this!
+
+ """ + doAssert actual() == expected diff --git a/tests/template/thygienictempl.nim b/tests/template/thygienictempl.nim index 3cdbac40e5..5e4f534f84 100644 --- a/tests/template/thygienictempl.nim +++ b/tests/template/thygienictempl.nim @@ -1,7 +1,7 @@ - + var e = "abc" - + raise newException(EIO, e & "ha!") template t() = echo(foo) diff --git a/tests/template/tmodulealias.nim b/tests/template/tmodulealias.nim index a7d155e51d..6681379fbb 100644 --- a/tests/template/tmodulealias.nim +++ b/tests/template/tmodulealias.nim @@ -8,10 +8,10 @@ else: import posix when defined(Windows): - template orig: expr = + template orig: expr = winlean else: - template orig: expr = + template orig: expr = posix proc socket(domain, typ, protocol: int): int = diff --git a/tests/template/tstempl.nim b/tests/template/tstempl.nim index f8e57abbb8..6490820416 100644 --- a/tests/template/tstempl.nim +++ b/tests/template/tstempl.nim @@ -6,7 +6,7 @@ levB''' # tstempl.nim import strutils -type +type TLev = enum levA, levB diff --git a/tests/template/ttempl.nim b/tests/template/ttempl.nim index 2c4785325a..5f1341990c 100644 --- a/tests/template/ttempl.nim +++ b/tests/template/ttempl.nim @@ -15,10 +15,10 @@ const var i = 0 -for item in items(tabs): +for item in items(tabs): var content = $i var file: TFile - if open(file, changeFileExt(item[1], "html"), fmWrite): + if open(file, changeFileExt(item[1], "html"), fmWrite): write(file, sunsetTemplate(current=item[1], ticker="", content=content, tabs=tabs)) close(file) diff --git a/tests/template/ttempl3.nim b/tests/template/ttempl3.nim index c5d78d414e..56daf9fe6d 100644 --- a/tests/template/ttempl3.nim +++ b/tests/template/ttempl3.nim @@ -11,18 +11,18 @@ template withOpenFile(f: expr, filename: string, mode: TFileMode, close(f) else: quit("cannot open for writing: " & filename) - + withOpenFile(txt, "ttempl3.txt", fmWrite): writeLine(txt, "line 1") txt.writeLine("line 2") - + var myVar: array[0..1, int] -# Test zero argument template: +# Test zero argument template: template ha: expr = myVar[0] - -ha = 1 + +ha = 1 echo(ha) @@ -37,7 +37,7 @@ template typedef(name: expr, typ: typeDesc) {.immediate, dirty.} = type `T name`* = typ `P name`* = ref `T name` - + typedef(myint, int) var x: PMyInt diff --git a/tests/template/twrongopensymchoice.nim b/tests/template/twrongopensymchoice.nim index 5a02a813cd..360c920373 100644 --- a/tests/template/twrongopensymchoice.nim +++ b/tests/template/twrongopensymchoice.nim @@ -4,11 +4,11 @@ discard """ # bug #940 -type - Foo* = ref object +type + Foo* = ref object b*: int -proc new*(this: var Foo) = +proc new*(this: var Foo) = assert this != nil this.b = 10 diff --git a/tests/testament/backend.nim b/tests/testament/backend.nim index 11743c337c..e2e2e2dd5c 100644 --- a/tests/testament/backend.nim +++ b/tests/testament/backend.nim @@ -81,34 +81,34 @@ proc getCommit(db: TDbConn): CommitId = let hash = "git log -n 1"()[commLen..commLen+10] let branch = "git symbolic-ref --short HEAD"() if hash.len == 0 or branch.len == 0: quit "cannot determine git HEAD" - + let id = db.getValue(sql"select id from [Commit] where hash = ? and branch = ?", hash, branch) if id.len > 0: result = id.parseInt.CommitId else: - result = db.insertId(sql"insert into [Commit](hash, branch) values (?, ?)", + result = db.insertId(sql"insert into [Commit](hash, branch) values (?, ?)", hash, branch).CommitId -proc writeTestResult*(name, category, target, +proc writeTestResult*(name, category, target, action, result, expected, given: string) = - let id = db.getValue(sql"""select id from TestResult + let id = db.getValue(sql"""select id from TestResult where name = ? and category = ? and target = ? and - machine = ? and [commit] = ?""", + machine = ? and [commit] = ?""", name, category, target, thisMachine, thisCommit) if id.len > 0: db.exec(sql"""update TestResult - set action = ?, result = ?, expected = ?, given = ? + set action = ?, result = ?, expected = ?, given = ? where id = ?""", action, result, expected, given, id) else: - db.exec(sql"""insert into TestResult(name, category, target, - action, + db.exec(sql"""insert into TestResult(name, category, target, + action, result, expected, given, [commit], machine) - values (?,?,?,?,?,?,?,?,?) """, name, category, target, + values (?,?,?,?,?,?,?,?,?) """, name, category, target, action, - result, expected, given, + result, expected, given, thisCommit, thisMachine) proc open*() = diff --git a/tests/testament/tester.nim b/tests/testament/tester.nim index 704d7e76e5..b138c9909d 100644 --- a/tests/testament/tester.nim +++ b/tests/testament/tester.nim @@ -286,8 +286,8 @@ proc testSpec(r: var TResults, test: TTest) = if exitCode != expected.exitCode: r.addResult(test, "exitcode: " & $expected.exitCode, - "exitcode: " & $exitCode & "\n\nOutput:\n" & - analyzeAndConsolidateOutput(bufB), + "exitcode: " & $exitCode & "\n\nOutput:\n" & + analyzeAndConsolidateOutput(bufB), reExitCodesDiffer) return diff --git a/tests/threads/tactors2.nim b/tests/threads/tactors2.nim index 5683f98ba4..b011ef1402 100644 --- a/tests/threads/tactors2.nim +++ b/tests/threads/tactors2.nim @@ -16,7 +16,7 @@ proc main() = createActorPool(actorPool, 1) var some_data: some_type - + var inchannel = spawn(actorPool, some_data, thread_proc) var recv_data = ^inchannel close(inchannel[]) diff --git a/tests/threads/threadex.nim b/tests/threads/threadex.nim index 0360c8c049..545d1f0cc5 100644 --- a/tests/threads/threadex.nim +++ b/tests/threads/threadex.nim @@ -32,7 +32,7 @@ proc produce() {.thread.} = close(input) m.k = mEof chan.send(m) - + open(chan) createThread[void](consumer, consume) createThread[void](producer, produce) diff --git a/tests/threads/tthreadanalysis.nim b/tests/threads/tthreadanalysis.nim index b222f15a92..6ef4de0bf8 100644 --- a/tests/threads/tthreadanalysis.nim +++ b/tests/threads/tthreadanalysis.nim @@ -36,9 +36,9 @@ proc echoLeTree(n: PNode) = echo it.data it = it.le -proc threadFunc(interval: tuple[a, b: int]) {.thread.} = +proc threadFunc(interval: tuple[a, b: int]) {.thread.} = doNothing() - for i in interval.a..interval.b: + for i in interval.a..interval.b: var r = buildTree(i) echoLeTree(r) # for local data echoLeTree(root) # and the same for foreign data :-) diff --git a/tests/threads/tthreadanalysis2.nim b/tests/threads/tthreadanalysis2.nim index d5b2cd4303..07d77028b5 100644 --- a/tests/threads/tthreadanalysis2.nim +++ b/tests/threads/tthreadanalysis2.nim @@ -34,9 +34,9 @@ proc echoLeTree(n: PNode) = echo it.data it = it.le -proc threadFunc(interval: tuple[a, b: int]) {.thread.} = +proc threadFunc(interval: tuple[a, b: int]) {.thread.} = doNothing() - for i in interval.a..interval.b: + for i in interval.a..interval.b: var r = buildTree(i) echoLeTree(r) # for local data root = buildTree(2) # BAD! diff --git a/tests/threads/tthreadheapviolation1.nim b/tests/threads/tthreadheapviolation1.nim index 94e1b64db6..02ce7878a0 100644 --- a/tests/threads/tthreadheapviolation1.nim +++ b/tests/threads/tthreadheapviolation1.nim @@ -4,7 +4,7 @@ discard """ cmd: "nim $target --hints:on --threads:on $options $file" """ -var +var global: string = "test string" t: TThread[void] diff --git a/tests/threads/ttryrecv.nim b/tests/threads/ttryrecv.nim index acccf182c5..28529b5acc 100644 --- a/tests/threads/ttryrecv.nim +++ b/tests/threads/ttryrecv.nim @@ -31,5 +31,5 @@ while true: echo "Finished listening" -joinThread(thr) +joinThread(thr) close(chan) diff --git a/tests/trmacros/tcse.nim b/tests/trmacros/tcse.nim index ff04f7d83d..023a8f298f 100644 --- a/tests/trmacros/tcse.nim +++ b/tests/trmacros/tcse.nim @@ -6,7 +6,7 @@ template cse{f(a, a, x)}(a: expr{(nkDotExpr|call|nkBracketExpr)&noSideEffect}, f: expr, x: varargs[expr]): expr = let aa = a f(aa, aa, x)+4 - + var a: array[0..10, int] i = 3 diff --git a/tests/trmacros/tmatrix.nim b/tests/trmacros/tmatrix.nim index c825a77920..f409434c50 100644 --- a/tests/trmacros/tmatrix.nim +++ b/tests/trmacros/tmatrix.nim @@ -24,6 +24,6 @@ macro optOps{ (`+`|`-`|`*`) ** a }(a: TMat): expr = var x, y, z: TMat -echo x + y * z - x +echo x + y * z - x #echo x + y + z diff --git a/tests/trmacros/tstar.nim b/tests/trmacros/tstar.nim index 8443268f4a..536289ff06 100644 --- a/tests/trmacros/tstar.nim +++ b/tests/trmacros/tstar.nim @@ -4,7 +4,7 @@ discard """ var calls = 0 - + proc `&&`(s: varargs[string]): string = result = s[0] for i in 1..len(s)-1: result.add s[i] diff --git a/tests/typerel/tno_int_in_bool_context.nim b/tests/typerel/tno_int_in_bool_context.nim index 755a02c0cb..5577591696 100644 --- a/tests/typerel/tno_int_in_bool_context.nim +++ b/tests/typerel/tno_int_in_bool_context.nim @@ -3,6 +3,6 @@ discard """ errormsg: "type mismatch: got (int literal(1)) but expected 'bool'" """ -if 1: +if 1: echo "wtf?" - + diff --git a/tests/typerel/trectuples.nim b/tests/typerel/trectuples.nim index a74e4859c4..af9ba2dbba 100644 --- a/tests/typerel/trectuples.nim +++ b/tests/typerel/trectuples.nim @@ -7,7 +7,7 @@ type Node = tuple[left: ref Node] proc traverse(root: ref Node) = if root.left != nil: traverse(root.left) - + type A = tuple[B: ptr A] proc C(D: ptr A) = C(D.B) diff --git a/tests/typerel/trefs.nim b/tests/typerel/trefs.nim index b157ca2b56..d4383c5625 100644 --- a/tests/typerel/trefs.nim +++ b/tests/typerel/trefs.nim @@ -3,21 +3,21 @@ discard """ line: 20 errormsg: "type mismatch" """ -# test for ref types (including refs to procs) - -type - TProc = proc (a, b: int): int {.stdcall.} - -proc foo(c, d: int): int {.stdcall.} = - return 0 - -proc wrongfoo(c, e: int): int {.inline.} = - return 0 - -var p: TProc -p = foo -write(stdout, "success!") -p = wrongfoo #ERROR_MSG type mismatch - +# test for ref types (including refs to procs) + +type + TProc = proc (a, b: int): int {.stdcall.} + +proc foo(c, d: int): int {.stdcall.} = + return 0 + +proc wrongfoo(c, e: int): int {.inline.} = + return 0 + +var p: TProc +p = foo +write(stdout, "success!") +p = wrongfoo #ERROR_MSG type mismatch + diff --git a/tests/typerel/tregionptrs.nim b/tests/typerel/tregionptrs.nim index 07387fed89..69a93a1074 100644 --- a/tests/typerel/tregionptrs.nim +++ b/tests/typerel/tregionptrs.nim @@ -8,7 +8,7 @@ type APtr = RegionA ptr int RegionB = object BPtr = RegionB ptr int - + var x,xx: APtr var y: BPtr x = nil diff --git a/tests/typerel/tregionptrs2.nim b/tests/typerel/tregionptrs2.nim index 3b32ff93d6..7fe758c8e0 100644 --- a/tests/typerel/tregionptrs2.nim +++ b/tests/typerel/tregionptrs2.nim @@ -8,14 +8,14 @@ type next: ThingyPtr name: string -proc iname(t: ThingyPtr) = +proc iname(t: ThingyPtr) = var x = t while not x.isNil: echo x.name x = x.next -proc go() = +proc go() = var athing : ThingyPtr iname(athing) diff --git a/tests/typerel/tsecondarrayproperty.nim b/tests/typerel/tsecondarrayproperty.nim index 07fdac1c47..3a6879b163 100644 --- a/tests/typerel/tsecondarrayproperty.nim +++ b/tests/typerel/tsecondarrayproperty.nim @@ -14,7 +14,7 @@ proc `[]=` (self: var TFoo, x, y: int) = proc second(self: var TFoo): var TSecond = return TSecond(self) -proc `[]`(self: var TSecond, x: int): var int = +proc `[]`(self: var TSecond, x: int): var int = return TFoo(self).data[2*x] var f: TFoo diff --git a/tests/typerel/ttuple1.nim b/tests/typerel/ttuple1.nim index 5787cc3090..d5c80800c7 100644 --- a/tests/typerel/ttuple1.nim +++ b/tests/typerel/ttuple1.nim @@ -12,5 +12,5 @@ for key, val in items(romanNumbers): proc PrintBiTuple(t: tuple[k: string, v: int]): int = stdout.write(t.k & "=" & $t.v & ", ") return 0 - + diff --git a/tests/typerel/ttypenoval.nim b/tests/typerel/ttypenoval.nim index 214b35e297..d5b91fbca9 100644 --- a/tests/typerel/ttypenoval.nim +++ b/tests/typerel/ttypenoval.nim @@ -11,7 +11,7 @@ type TBinHeap[T] = object heap: seq[TNode[T]] last: int - + PBinHeap[T] = ref TBinHeap[T] proc newBinHeap*[T](heap: var PBinHeap[T], size: int) = @@ -19,7 +19,7 @@ proc newBinHeap*[T](heap: var PBinHeap[T], size: int) = heap.last = 0 newSeq(heap.heap, size) #newSeq(heap.seq, size) - + proc parent(elem: int): int {.inline.} = return (elem-1) div 2 diff --git a/tests/typerel/tvoid.nim b/tests/typerel/tvoid.nim index d319362176..1e46d016e8 100644 --- a/tests/typerel/tvoid.nim +++ b/tests/typerel/tvoid.nim @@ -16,14 +16,14 @@ proc nothing(x, y: void): void = echo "ha" proc callProc[T](p: proc (x: T) {.nimcall.}, x: T) = - when T is void: + when T is void: p() else: p(x) proc intProc(x: int) = echo x - + proc emptyProc() = echo "empty" diff --git a/tests/typerel/typalias.nim b/tests/typerel/typalias.nim index 55dcb9fa6e..e85f1f6649 100644 --- a/tests/typerel/typalias.nim +++ b/tests/typerel/typalias.nim @@ -3,13 +3,13 @@ type TMyObj = TYourObj TYourObj = object of RootObj x, y: int - + proc init: TYourObj = result.x = 0 result.y = -1 - + proc f(x: var TYourObj) = discard - + var m: TMyObj = init() f(m) diff --git a/tests/types/tfinalobj.nim b/tests/types/tfinalobj.nim index 1cd7fae284..2fda73363f 100644 --- a/tests/types/tfinalobj.nim +++ b/tests/types/tfinalobj.nim @@ -3,9 +3,9 @@ discard """ """ type - TA = object {.pure, final.} + TA = object {.pure, final.} x: string - + var a: TA a.x = "abc" diff --git a/tests/types/tforwty.nim b/tests/types/tforwty.nim index 0f1d3697f5..626abd5efa 100644 --- a/tests/types/tforwty.nim +++ b/tests/types/tforwty.nim @@ -1,9 +1,9 @@ -# Test 13: forward types - -type - PSym = ref TSym - - TSym = object - next: PSym - -var s: PSym +# Test 13: forward types + +type + PSym = ref TSym + + TSym = object + next: PSym + +var s: PSym diff --git a/tests/types/tforwty2.nim b/tests/types/tforwty2.nim index 52af1c7dd3..6449e25bc2 100644 --- a/tests/types/tforwty2.nim +++ b/tests/types/tforwty2.nim @@ -1,22 +1,22 @@ -# Test for a hard to fix internal error -# occurred in the SDL library - -{.push dynlib: "SDL.dll", callconv: cdecl.} - -type - PSDL_semaphore = ptr TSDL_semaphore - TSDL_semaphore {.final.} = object - sem: pointer #PSem_t; - when not defined(USE_NAMED_SEMAPHORES): - sem_data: int - when defined(BROKEN_SEMGETVALUE): - # This is a little hack for MacOS X - - # It's not thread-safe, but it's better than nothing - sem_value: cint - -type - PSDL_Sem = ptr TSDL_Sem - TSDL_Sem = TSDL_Semaphore - -proc SDL_CreateSemaphore(initial_value: int32): PSDL_Sem {. - importc: "SDL_CreateSemaphore".} +# Test for a hard to fix internal error +# occurred in the SDL library + +{.push dynlib: "SDL.dll", callconv: cdecl.} + +type + PSDL_semaphore = ptr TSDL_semaphore + TSDL_semaphore {.final.} = object + sem: pointer #PSem_t; + when not defined(USE_NAMED_SEMAPHORES): + sem_data: int + when defined(BROKEN_SEMGETVALUE): + # This is a little hack for MacOS X - + # It's not thread-safe, but it's better than nothing + sem_value: cint + +type + PSDL_Sem = ptr TSDL_Sem + TSDL_Sem = TSDL_Semaphore + +proc SDL_CreateSemaphore(initial_value: int32): PSDL_Sem {. + importc: "SDL_CreateSemaphore".} diff --git a/tests/types/tillegaltyperecursion.nim b/tests/types/tillegaltyperecursion.nim index ebdbc1d133..bace2dfc8b 100644 --- a/tests/types/tillegaltyperecursion.nim +++ b/tests/types/tillegaltyperecursion.nim @@ -18,7 +18,7 @@ type MessageReceivedHandler*: TEventHandler Socket: TSocket Thread: TThread[TIRC] - + proc initIRC*(): TIRC = result.Socket = socket() result.EventEmitter = initEventEmitter() @@ -26,8 +26,8 @@ proc initIRC*(): TIRC = proc IsConnected*(irc: var TIRC): bool = return running(irc.Thread) - - + + proc sendRaw*(irc: var TIRC, message: string) = irc.Socket.send(message & "\r\L") proc handleData(irc: TIRC) {.thread.} = @@ -40,14 +40,14 @@ proc handleData(irc: TIRC) {.thread.} = if len(tup) == 1: #Connected connected = True - + #Parse data here - + else: #Disconnected connected = False return - + proc Connect*(irc: var TIRC, nick: string, host: string, port: int = 6667) = connect(irc.Socket ,host ,TPort(port),TDomain.AF_INET) send(irc.Socket,"USER " & nick & " " & nick & " " & nick & " " & nick &"\r\L") @@ -57,8 +57,8 @@ proc Connect*(irc: var TIRC, nick: string, host: string, port: int = 6667) = irc.Thread = thread - - + + when isMainModule: var irc = initIRC() irc.Connect("AmryBot[Nim]","irc.freenode.net",6667) diff --git a/tests/types/tinheritref.nim b/tests/types/tinheritref.nim index e5de6a4be8..ecd62a06f0 100644 --- a/tests/types/tinheritref.nim +++ b/tests/types/tinheritref.nim @@ -21,7 +21,7 @@ type TTreeIterator* [T,D] = ref object {.inheritable.} TKeysIterator* [T,D] = ref object of TTreeIterator[T,D] #this not - + var it: TKeysIterator[int, string] = nil diff --git a/tests/types/tisop.nim b/tests/types/tisop.nim index 05c6a1a061..d0b7c32b2f 100644 --- a/tests/types/tisop.nim +++ b/tests/types/tisop.nim @@ -6,7 +6,7 @@ import typetraits type TRecord = (tuple) or (object) - + TFoo[T, U] = object x: int diff --git a/tests/varres/tvarres1.nim b/tests/varres/tvarres1.nim index de4a505d39..8498057684 100644 --- a/tests/varres/tvarres1.nim +++ b/tests/varres/tvarres1.nim @@ -7,10 +7,10 @@ discard """ var g = 5 -proc p(): var int = +proc p(): var int = var bla: int result = bla - + p() = 45 echo g diff --git a/tests/varres/tvarres2.nim b/tests/varres/tvarres2.nim index 165e4a36e2..53a57d882d 100644 --- a/tests/varres/tvarres2.nim +++ b/tests/varres/tvarres2.nim @@ -7,9 +7,9 @@ discard """ var g = 5 -proc p(): var int = +proc p(): var int = result = 89 - + p() = 45 echo g diff --git a/tests/varres/tvarres3.nim b/tests/varres/tvarres3.nim index a48c961df2..9fcd79bfcd 100644 --- a/tests/varres/tvarres3.nim +++ b/tests/varres/tvarres3.nim @@ -5,10 +5,10 @@ discard """ var g = 5 -proc p(): var int = +proc p(): var int = var bla = addr(g) #: array [0..7, int] result = bla[] - + p() = 45 echo g diff --git a/tests/varres/tvartup.nim b/tests/varres/tvartup.nim index f885cdf373..20a4156e6a 100644 --- a/tests/varres/tvartup.nim +++ b/tests/varres/tvartup.nim @@ -6,7 +6,7 @@ discard """ proc divmod(a, b: int): tuple[di, mo: int] = return (a div b, a mod b) - + var (x, y) = divmod(15, 6) stdout.write(x) stdout.write(" ") diff --git a/tests/varstmt/tlet.nim b/tests/varstmt/tlet.nim index 138f344336..9c2d9706dd 100644 --- a/tests/varstmt/tlet.nim +++ b/tests/varstmt/tlet.nim @@ -11,7 +11,7 @@ proc main = echo("Very funny, your name is name.") else: echo("Hi, ", name, "!") - + let (x, y) = ("abc", name) echo y, x diff --git a/tests/varstmt/tvardecl.nim b/tests/varstmt/tvardecl.nim index 5cc6f4960d..a6b5082953 100644 --- a/tests/varstmt/tvardecl.nim +++ b/tests/varstmt/tvardecl.nim @@ -2,14 +2,14 @@ discard """ file: "tvardecl.nim" output: "44" """ -# Test the new variable declaration syntax - -var - x = 0 - s = "Hallo" - a, b: int = 4 - -write(stdout, a) -write(stdout, b) #OUT 44 +# Test the new variable declaration syntax + +var + x = 0 + s = "Hallo" + a, b: int = 4 + +write(stdout, a) +write(stdout, b) #OUT 44 diff --git a/tests/vm/tarrayboundeval.nim b/tests/vm/tarrayboundeval.nim index 07aac4c4ea..af9e33339c 100644 --- a/tests/vm/tarrayboundeval.nim +++ b/tests/vm/tarrayboundeval.nim @@ -15,12 +15,12 @@ type echo FU.high -type +type PKeyboard* = ptr object TKeyboardState* = object display*: pointer internal: array[int((KeyMax + 31)/32), cuint] - + echo myconst, " ", int((KeyMax + 31) / 32) #bug 1304 or something: diff --git a/tests/vm/tasmparser.nim b/tests/vm/tasmparser.nim index 67313c8580..fbacdbc870 100644 --- a/tests/vm/tasmparser.nim +++ b/tests/vm/tasmparser.nim @@ -79,23 +79,23 @@ proc asmx64 () {.compileTime} = case state: of leading: - + echo "b100 ", start start += code.skipWhile (leadingWhiteSpace, start) echo "b200 ", start let ch = code [start] if ch in endOfLine: inc (line) - #echo "c100 ", start, ' ', code + #echo "c100 ", start, ' ', code start += code.skipWhile (endOfline, start) - #echo "c200 ", start, ' ', code + #echo "c200 ", start, ' ', code continue elif ch in symbolStart: state = mnemonic elif ch in eolComment: state = skipToEndOfLine elif ch in passthrough_start: - get_passthrough () + get_passthrough () echo "d100 ", start start += code.parseUntil (token, end_or_symbol_or_comment_or_passthrough, start) echo "d200 ", start @@ -124,7 +124,7 @@ proc asmx64 () {.compileTime} = if codeLen <= start: state = endCmd continue - + let ch = code [start] if ch in passthrough_start: get_passthrough () @@ -148,7 +148,7 @@ proc asmx64 () {.compileTime} = of endCmd: cpp.add ");\n" state = skipToEndOfLine - + of skipToEndOfLine: echo "a100 ", start start += code.skipUntil (endOfLine, start) diff --git a/tests/vm/tconsteval.nim b/tests/vm/tconsteval.nim index 4459931c5e..f4260495ac 100644 --- a/tests/vm/tconsteval.nim +++ b/tests/vm/tconsteval.nim @@ -24,7 +24,7 @@ Possible Commands: csource [options] builds the C sources for installation zip builds the installation ZIP package inno builds the Inno Setup installer -""" % [NimVersion & spaces(44-len(NimVersion)), +""" % [NimVersion & spaces(44-len(NimVersion)), CompileDate, CompileTime] echo HelpText diff --git a/tests/vm/teval1.nim b/tests/vm/teval1.nim index cdb4ad8e2b..1d3a68a0d7 100644 --- a/tests/vm/teval1.nim +++ b/tests/vm/teval1.nim @@ -13,7 +13,7 @@ when true: const x = testProc() - + echo "##", x, "##" # bug #1310 diff --git a/tests/vm/tldconst.nim b/tests/vm/tldconst.nim index 9eabb75259..7df3143c93 100644 --- a/tests/vm/tldconst.nim +++ b/tests/vm/tldconst.nim @@ -11,4 +11,4 @@ proc foobar(): int = discard 0 -const x = foobar() \ No newline at end of file +const x = foobar() diff --git a/tests/vm/trgba.nim b/tests/vm/trgba.nim index 22eec4d6e1..da1a2d0c52 100644 --- a/tests/vm/trgba.nim +++ b/tests/vm/trgba.nim @@ -8,19 +8,19 @@ discard """ type TAggRgba8* = array[4, byte] -template R*(self: TAggRgba8): byte = self[0] -template G*(self: TAggRgba8): byte = self[1] -template B*(self: TAggRgba8): byte = self[2] -template A*(self: TAggRgba8): byte = self[3] +template R*(self: TAggRgba8): byte = self[0] +template G*(self: TAggRgba8): byte = self[1] +template B*(self: TAggRgba8): byte = self[2] +template A*(self: TAggRgba8): byte = self[3] -template `R=`*(self: TAggRgba8, val: byte) = - self[0] = val -template `G=`*(self: TAggRgba8, val: byte) = - self[1] = val -template `B=`*(self: TAggRgba8, val: byte) = - self[2] = val -template `A=`*(self: TAggRgba8, val: byte) = - self[3] = val +template `R=`*(self: TAggRgba8, val: byte) = + self[0] = val +template `G=`*(self: TAggRgba8, val: byte) = + self[1] = val +template `B=`*(self: TAggRgba8, val: byte) = + self[2] = val +template `A=`*(self: TAggRgba8, val: byte) = + self[3] = val proc ABGR* (val: int| int64): TAggRgba8 = var V = val @@ -32,5 +32,5 @@ proc ABGR* (val: int| int64): TAggRgba8 = result.A = (V shr 8) and 0xFF const - c1 = ABGR(0xFF007F7F) + c1 = ABGR(0xFF007F7F) echo ABGR(0xFF007F7F).repr, c1.repr diff --git a/tests/vm/tslurp.nim b/tests/vm/tslurp.nim index fc3dc6f0aa..027db45d62 100644 --- a/tests/vm/tslurp.nim +++ b/tests/vm/tslurp.nim @@ -6,7 +6,7 @@ template getScriptDir(): string = const relRes = slurp"../../readme.txt" absRes = slurp(parentDir(parentDir(getScriptDir())) / "readme.txt") - + echo relRes echo absRes From 5d80548cce84ea62dc8b85c10375f70d037ea4f8 Mon Sep 17 00:00:00 2001 From: Adam Strzelecki Date: Fri, 4 Sep 2015 23:05:22 +0200 Subject: [PATCH 05/11] examples: Trim .nim files trailing whitespace via OSX: find . -name '*.nim' -exec sed -i '' -E 's/[[:space:]]+$//' {} + --- examples/allany.nim | 4 +- examples/c++iface/irrlichtex.nim | 6 +- .../cross_calculator/nim_backend/backend.nim | 10 +- examples/curlex.nim | 4 +- examples/filterex.nim | 4 +- examples/htmlrefs.nim | 18 +-- examples/htmltitle.nim | 8 +- examples/httpserver2.nim | 6 +- examples/maximum.nim | 12 +- examples/parsecfgex.nim | 4 +- examples/sdlex.nim | 104 +++++++++--------- examples/statcsv.nim | 2 +- examples/talk/tags.nim | 2 +- examples/tunit.nim | 94 ++++++++-------- web/snippets/snippet1.nim | 4 +- 15 files changed, 141 insertions(+), 141 deletions(-) diff --git a/examples/allany.nim b/examples/allany.nim index de36a1d9bd..52a794204a 100644 --- a/examples/allany.nim +++ b/examples/allany.nim @@ -18,9 +18,9 @@ template any(container, cond: expr): expr {.immediate.} = break result -if all("mystring", {'a'..'z'}.contains) and any("myohmy", 'y'.`==`): +if all("mystring", {'a'..'z'}.contains) and any("myohmy", 'y'.`==`): echo "works" -else: +else: echo "does not work" diff --git a/examples/c++iface/irrlichtex.nim b/examples/c++iface/irrlichtex.nim index 4dd1d79ee8..373a78ce7a 100644 --- a/examples/c++iface/irrlichtex.nim +++ b/examples/c++iface/irrlichtex.nim @@ -18,13 +18,13 @@ type TDimension2d {.final, header: irr, importc: "dimension2d".} = object Tvector3df {.final, header: irr, importc: "vector3df".} = object TColor {.final, header: irr, importc: "SColor".} = object - + TIrrlichtDevice {.final, header: irr, importc: "IrrlichtDevice".} = object TIVideoDriver {.final, header: irr, importc: "IVideoDriver".} = object TISceneManager {.final, header: irr, importc: "ISceneManager".} = object TIGUIEnvironment {.final, header: irr, importc: "IGUIEnvironment".} = object TIAnimatedMesh {.final, header: irr, importc: "IAnimatedMesh".} = object - TIAnimatedMeshSceneNode {.final, header: irr, + TIAnimatedMeshSceneNode {.final, header: irr, importc: "IAnimatedMeshSceneNode".} = object TITexture {.final, header: irr, importc: "ITexture".} = object @@ -100,7 +100,7 @@ var node = smgr.addAnimatedMeshSceneNode(mesh) if node != nil: #node->setMaterialFlag(EMF_LIGHTING, false) #node->setMD2Animation(scene::EMAT_STAND) - node.setMaterialTexture(0, + node.setMaterialTexture(0, driver.getTexture( "/home/andreas/download/irrlicht-1.7.2/media/media/sydney.bmp")) diff --git a/examples/cross_calculator/nim_backend/backend.nim b/examples/cross_calculator/nim_backend/backend.nim index ffa4311f9d..c8684581ca 100644 --- a/examples/cross_calculator/nim_backend/backend.nim +++ b/examples/cross_calculator/nim_backend/backend.nim @@ -1,5 +1,5 @@ -# Backend for the different user interfaces. - -proc myAdd*(x, y: int): int {.cdecl, exportc.} = - result = x + y - +# Backend for the different user interfaces. + +proc myAdd*(x, y: int): int {.cdecl, exportc.} = + result = x + y + diff --git a/examples/curlex.nim b/examples/curlex.nim index 017956818d..21786a6eeb 100644 --- a/examples/curlex.nim +++ b/examples/curlex.nim @@ -1,8 +1,8 @@ -import +import libcurl var hCurl = easy_init() -if hCurl != nil: +if hCurl != nil: discard easy_setopt(hCurl, OPT_VERBOSE, true) discard easy_setopt(hCurl, OPT_URL, "http://nim-lang.org/") discard easy_perform(hCurl) diff --git a/examples/filterex.nim b/examples/filterex.nim index 3713f4b64d..d9bfb67822 100644 --- a/examples/filterex.nim +++ b/examples/filterex.nim @@ -1,6 +1,6 @@ #! stdtmpl | standard #proc generateHTMLPage(title, currentTab, content: string, -# tabs: openArray[string]): string = +# tabs: openArray[string]): string = # result = "" $title @@ -8,7 +8,7 @@