summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--bin/empty.txt2
-rw-r--r--compiler/ast.nim14
-rw-r--r--compiler/c2nim/c2nim.nim92
-rw-r--r--compiler/c2nim/clex.nim787
-rw-r--r--compiler/c2nim/cparse.nim2142
-rw-r--r--compiler/c2nim/cpp.nim347
-rw-r--r--compiler/c2nim/nimrod.cfg4
-rw-r--r--compiler/c2nim/tests/matrix.h240
-rw-r--r--compiler/c2nim/tests/systest.c622
-rw-r--r--compiler/c2nim/tests/systest2.c17
-rw-r--r--compiler/c2nim/tests/vincent.c33
-rw-r--r--compiler/c2nim/tests/vincent.h3
-rw-r--r--compiler/ccgcalls.nim2
-rw-r--r--compiler/ccgexprs.nim42
-rw-r--r--compiler/ccgtypes.nim9
-rw-r--r--compiler/ccgutils.nim3
-rw-r--r--compiler/cgen.nim8
-rw-r--r--compiler/cgendata.nim1
-rw-r--r--compiler/commands.nim48
-rw-r--r--compiler/docgen.nim10
-rw-r--r--compiler/evals.nim1502
-rw-r--r--compiler/guards.nim316
-rw-r--r--compiler/importer.nim4
-rw-r--r--compiler/lambdalifting.nim745
-rw-r--r--compiler/lexer.nim35
-rw-r--r--compiler/llstream.nim3
-rw-r--r--compiler/lookups.nim21
-rw-r--r--compiler/lowerings.nim395
-rw-r--r--compiler/magicsys.nim2
-rw-r--r--compiler/main.nim2
-rw-r--r--compiler/modules.nim2
-rw-r--r--compiler/nimrod.ini3
-rw-r--r--compiler/parser.nim124
-rw-r--r--compiler/pas2nim/nimrod.cfg4
-rw-r--r--compiler/pas2nim/pas2nim.nim64
-rw-r--r--compiler/pas2nim/paslex.nim570
-rw-r--r--compiler/pas2nim/pasparse.nim1513
-rw-r--r--compiler/patterns.nim2
-rw-r--r--compiler/pragmas.nim13
-rw-r--r--compiler/pretty.nim62
-rw-r--r--compiler/renderer.nim25
-rw-r--r--compiler/rodutils.nim2
-rw-r--r--compiler/sem.nim22
-rw-r--r--compiler/semcall.nim6
-rw-r--r--compiler/semdata.nim5
-rw-r--r--compiler/semexprs.nim107
-rw-r--r--compiler/semfold.nim13
-rw-r--r--compiler/semgnrc.nim41
-rw-r--r--compiler/seminst.nim8
-rw-r--r--compiler/semmagic.nim3
-rw-r--r--compiler/semparallel.nim465
-rw-r--r--compiler/sempass2.nim4
-rw-r--r--compiler/semstmts.nim24
-rw-r--r--compiler/semtempl.nim6
-rw-r--r--compiler/semtypes.nim35
-rw-r--r--compiler/sigmatch.nim12
-rw-r--r--compiler/suggest.nim43
-rw-r--r--compiler/transf.nim5
-rw-r--r--compiler/types.nim14
-rw-r--r--compiler/typesrenderer.nim4
-rw-r--r--compiler/vm.nim38
-rw-r--r--compiler/vmdeps.nim2
-rw-r--r--compiler/vmgen.nim160
-rw-r--r--config/nimrod.cfg1
-rw-r--r--doc/advopt.txt1
-rw-r--r--doc/apis.txt13
-rw-r--r--doc/backends.txt409
-rw-r--r--doc/c2nim.txt295
-rw-r--r--doc/docgen.txt72
-rw-r--r--doc/endb.txt12
-rw-r--r--doc/estp.txt8
-rw-r--r--doc/filters.txt8
-rw-r--r--doc/grammar.txt9
-rw-r--r--doc/idetools.txt4
-rw-r--r--doc/intern.txt10
-rw-r--r--doc/koch.txt144
-rw-r--r--doc/manual.txt259
-rw-r--r--doc/nimgrep.txt6
-rw-r--r--doc/niminst.txt6
-rw-r--r--doc/nimrodc.txt121
-rw-r--r--doc/spawn.txt98
-rw-r--r--doc/subexes.txt1
-rw-r--r--doc/tools.txt6
-rw-r--r--doc/trmacros.txt275
-rw-r--r--doc/tut1.txt48
-rw-r--r--doc/tut2.txt18
-rw-r--r--[-rwxr-xr-x]examples/cross_calculator/android/scripts/jnibuild.sh0
-rw-r--r--[-rwxr-xr-x]examples/cross_calculator/android/scripts/nimbuild.sh0
-rw-r--r--[-rwxr-xr-x]examples/cross_calculator/android/scripts/tags.sh0
-rw-r--r--[-rwxr-xr-x]examples/cross_calculator/ios/scripts/tags.sh0
-rw-r--r--[-rwxr-xr-x]examples/cross_calculator/ios/scripts/xcode_prebuild.sh0
-rw-r--r--koch.nim7
-rw-r--r--lib/impure/db_mysql.nim9
-rw-r--r--lib/js/dom.nim3
-rw-r--r--lib/packages/docutils/rstgen.nim439
-rw-r--r--lib/posix/posix.nim17
-rw-r--r--lib/pure/algorithm.nim23
-rw-r--r--lib/pure/asyncdispatch.nim173
-rw-r--r--lib/pure/asynchttpserver.nim177
-rw-r--r--lib/pure/asyncnet.nim99
-rw-r--r--lib/pure/collections/sequtils.nim63
-rw-r--r--lib/pure/collections/sets.nim60
-rw-r--r--lib/pure/collections/tables.nim17
-rw-r--r--lib/pure/complex.nim39
-rw-r--r--lib/pure/concurrency/cpuinfo.nim58
-rw-r--r--lib/pure/concurrency/cpuload.nim96
-rw-r--r--lib/pure/concurrency/threadpool.nim378
-rw-r--r--lib/pure/encodings.nim1
-rw-r--r--lib/pure/fsmonitor.nim6
-rw-r--r--lib/pure/future.nim1
-rw-r--r--lib/pure/hashes.nim29
-rw-r--r--lib/pure/httpclient.nim2
-rw-r--r--lib/pure/json.nim85
-rw-r--r--lib/pure/math.nim3
-rw-r--r--lib/pure/net.nim73
-rw-r--r--lib/pure/oids.nim4
-rw-r--r--lib/pure/os.nim96
-rw-r--r--lib/pure/osproc.nim44
-rw-r--r--lib/pure/rawsockets.nim6
-rw-r--r--lib/pure/selectors.nim46
-rw-r--r--lib/pure/sockets.nim2
-rw-r--r--lib/pure/strutils.nim10
-rw-r--r--lib/pure/times.nim3
-rw-r--r--[-rwxr-xr-x]lib/pure/unidecode/gen.py0
-rw-r--r--lib/system.nim98
-rw-r--r--lib/system/alloc.nim16
-rw-r--r--lib/system/assign.nim3
-rw-r--r--lib/system/atomics.nim70
-rw-r--r--lib/system/chcks.nim22
-rw-r--r--lib/system/sets.nim4
-rw-r--r--lib/system/sysio.nim12
-rw-r--r--lib/system/sysspawn.nim47
-rw-r--r--lib/windows/windows.nim1708
-rw-r--r--lib/wrappers/openssl.nim69
-rw-r--r--lib/wrappers/pdcurses.nim8
-rw-r--r--lib/wrappers/readline/readline.nim4
-rw-r--r--readme.md5
-rw-r--r--readme.txt5
-rw-r--r--tests/async/tasyncawait.nim12
-rw-r--r--tests/async/tasyncdiscard.nim2
-rw-r--r--tests/async/tnestedpfuturetypeparam.nim2
-rw-r--r--tests/casestmt/tcase_arrayconstr.nim19
-rw-r--r--tests/closure/tclosure.nim8
-rw-r--r--tests/closure/tjester.nim32
-rw-r--r--tests/closure/tnestedclosure.nim51
-rw-r--r--tests/exprs/tstmtexprs.nim32
-rw-r--r--tests/generics/mdotlookup.nim8
-rw-r--r--tests/generics/tdotlookup.nim7
-rw-r--r--tests/macros/tbindsym.nim25
-rw-r--r--tests/macros/tbugs.nim90
-rw-r--r--tests/macros/tdumptree.nim3
-rw-r--r--tests/manyloc/keineschweine/lib/gl.nim1536
-rw-r--r--tests/manyloc/keineschweine/lib/glext.nim4673
-rw-r--r--tests/manyloc/keineschweine/lib/glu.nim335
-rw-r--r--tests/manyloc/keineschweine/lib/glut.nim438
-rw-r--r--tests/manyloc/keineschweine/lib/glx.nim153
-rw-r--r--tests/manyloc/keineschweine/lib/wingl.nim368
-rw-r--r--tests/manyloc/packages/package1/p1.babel0
-rw-r--r--tests/manyloc/packages/package2/p2.babel0
-rw-r--r--tests/metatype/tautoproc.nim16
-rw-r--r--tests/misc/tbug1217bracketquotes.nim14
-rw-r--r--tests/notnil/tnotnil4.nim14
-rw-r--r--tests/objects/tobjconstr2.nim12
-rw-r--r--tests/osproc/ta.nim3
-rw-r--r--tests/osproc/tstdin.nim16
-rw-r--r--tests/parallel/nimrod.cfg1
-rw-r--r--tests/parallel/tdisjoint_slice1.nim21
-rw-r--r--tests/parallel/tdisjoint_slice2.nim33
-rw-r--r--tests/parallel/tflowvar.nim17
-rw-r--r--tests/parallel/tforstmt.nim25
-rw-r--r--tests/parallel/tinvalid_array_bounds.nim25
-rw-r--r--tests/parallel/tinvalid_counter_usage.nim26
-rw-r--r--tests/parallel/tnon_disjoint_slice1.nim25
-rw-r--r--tests/parallel/tpi.nim26
-rw-r--r--tests/parallel/tsysspawn.nim (renamed from tests/system/tsysspawn.nim)10
-rw-r--r--tests/parallel/tsysspawnbadarg.nim9
-rw-r--r--tests/seq/tsequtils.nim4
-rw-r--r--tests/sets/tsets3.nim100
-rw-r--r--tests/system/tsysspawnbadarg.nim7
-rw-r--r--tests/template/annotate.nim113
-rw-r--r--tests/template/otests.nim219
-rw-r--r--tests/template/t_otemplates.nim345
-rw-r--r--tests/testament/caasdriver.nim22
-rw-r--r--tests/testament/categories.nim45
-rw-r--r--tests/testament/specs.nim4
-rw-r--r--tests/testament/tester.nim14
-rw-r--r--tests/vm/tarrayboundeval.nim10
-rw-r--r--tests/vm/teval1.nim5
-rw-r--r--[-rwxr-xr-x]tinyc/tests/gcctestsuite.sh0
-rw-r--r--[-rwxr-xr-x]tinyc/texi2pod.pl0
-rw-r--r--todo.txt24
-rw-r--r--web/assets/style.css2
-rw-r--r--web/babelpkglist.nim8
-rw-r--r--web/news.txt23
-rw-r--r--web/nimrod.ini15
195 files changed, 14991 insertions, 10872 deletions
diff --git a/bin/empty.txt b/bin/empty.txt
index 666142073..20f9a91e3 100644
--- a/bin/empty.txt
+++ b/bin/empty.txt
@@ -1 +1 @@
-This file keeps several tools from deleting this subdirectory.
+This file keeps several tools from deleting this subdirectory.

diff --git a/compiler/ast.nim b/compiler/ast.nim
index 80b9e9bb2..9b8218071 100644
--- a/compiler/ast.nim
+++ b/compiler/ast.nim
@@ -417,6 +417,7 @@ type
                 # efficiency
     nfTransf,   # node has been transformed
     nfSem       # node has been checked for semantics
+    nfLL        # node has gone through lambda lifting
     nfDotField  # the call can use a dot operator
     nfDotSetter # the call can use a setter dot operarator
     nfExplicitCall # x.y() was used instead of x.y
@@ -510,6 +511,7 @@ const
   tfUncheckedArray* = tfVarargs
   tfUnion* = tfNoSideEffect
   tfGcSafe* = tfThread
+  tfObjHasKids* = tfEnumHasHoles
   skError* = skUnknown
   
   # type flags that are essential for type equality:
@@ -560,7 +562,7 @@ type
     mFloat, mFloat32, mFloat64, mFloat128,
     mBool, mChar, mString, mCstring,
     mPointer, mEmptySet, mIntSetBaseType, mNil, mExpr, mStmt, mTypeDesc,
-    mVoidType, mPNimrodNode, mShared, mGuarded, mLock, mSpawn,
+    mVoidType, mPNimrodNode, mShared, mGuarded, mLock, mSpawn, mDeepCopy,
     mIsMainModule, mCompileDate, mCompileTime, mNimrodVersion, mNimrodMajor,
     mNimrodMinor, mNimrodPatch, mCpuEndian, mHostOS, mHostCPU, mAppType,
     mNaN, mInf, mNegInf,
@@ -605,9 +607,9 @@ const
   # thus cannot be overloaded (also documented in the spec!):
   SpecialSemMagics* = {
     mDefined, mDefinedInScope, mCompiles, mLow, mHigh, mSizeOf, mIs, mOf, 
-    mEcho, mShallowCopy, mExpandToAst}
+    mEcho, mShallowCopy, mExpandToAst, mParallel, mSpawn}
 
-type 
+type
   PNode* = ref TNode
   TNodeSeq* = seq[PNode]
   PType* = ref TType
@@ -885,6 +887,8 @@ const
 
   nkCallKinds* = {nkCall, nkInfix, nkPrefix, nkPostfix,
                   nkCommand, nkCallStrLit, nkHiddenCallConv}
+  nkIdentKinds* = {nkIdent, nkSym, nkAccQuoted, nkOpenSymChoice,
+                   nkClosedSymChoice}
 
   nkLiterals* = {nkCharLit..nkTripleStrLit}
   nkLambdaKinds* = {nkLambda, nkDo}
@@ -1045,7 +1049,7 @@ proc discardSons(father: PNode) =
   father.sons = nil
 
 when defined(useNodeIds):
-  const nodeIdToDebug* = 482228 # 612794
+  const nodeIdToDebug* = 310841 # 612794
   #612840 # 612905 # 614635 # 614637 # 614641
   # 423408
   #429107 # 430443 # 441048 # 441090 # 441153
@@ -1502,7 +1506,7 @@ proc isGenericRoutine*(s: PSym): bool =
 proc skipGenericOwner*(s: PSym): PSym =
   internalAssert s.kind in skProcKinds
   ## Generic instantiations are owned by their originating generic
-  ## symbol. This proc skips such owners and goes straigh to the owner
+  ## symbol. This proc skips such owners and goes straight to the owner
   ## of the generic itself (the module or the enclosing proc).
   result = if sfFromGeneric in s.flags: s.owner.owner
            else: s.owner
diff --git a/compiler/c2nim/c2nim.nim b/compiler/c2nim/c2nim.nim
deleted file mode 100644
index 9b12b9e47..000000000
--- a/compiler/c2nim/c2nim.nim
+++ /dev/null
@@ -1,92 +0,0 @@
-#
-#
-#      c2nim - C to Nimrod source converter
-#        (c) Copyright 2013 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-import
-  strutils, os, times, parseopt, llstream, ast, renderer, options, msgs,
-  clex, cparse
-
-const
-  Version = NimrodVersion
-  Usage = """
-c2nim - C to Nimrod source converter
-  (c) 2013 Andreas Rumpf
-Usage: c2nim [options] inputfile [options]
-Options:
-  -o, --out:FILE         set output filename
-  --cpp                  process C++ input file
-  --dynlib:SYMBOL        import from dynlib: SYMBOL will be used for the import
-  --header:HEADER_FILE   import from a HEADER_FILE (discouraged!)
-  --cdecl                annotate procs with ``{.cdecl.}``
-  --stdcall              annotate procs with ``{.stdcall.}``
-  --ref                  convert typ* to ref typ (default: ptr typ)
-  --prefix:PREFIX        strip prefix for the generated Nimrod identifiers
-                         (multiple --prefix options are supported)
-  --suffix:SUFFIX        strip suffix for the generated Nimrod identifiers
-                         (multiple --suffix options are supported)
-  --skipinclude          do not convert ``#include`` to ``import``
-  --typeprefixes         generate ``T`` and ``P`` type prefixes
-  --skipcomments         do not copy comments
-  --ignoreRValueRefs     translate C++'s ``T&&`` to ``T`` instead ``of var T``
-  --keepBodies           keep C++'s method bodies
-  --spliceHeader         parse and emit header before source file
-  -v, --version          write c2nim's version
-  -h, --help             show this help
-"""
-
-proc parse(infile: string, options: PParserOptions): PNode =
-  var stream = llStreamOpen(infile, fmRead)
-  if stream == nil: rawMessage(errCannotOpenFile, infile)
-  var p: TParser
-  openParser(p, infile, stream, options)
-  result = parseUnit(p)
-  closeParser(p)
-
-proc main(infile, outfile: string, options: PParserOptions, spliceHeader: bool) =
-  var start = getTime()
-  if spliceHeader and infile.splitFile.ext == ".c" and existsFile(infile.changeFileExt(".h")):
-    var header_module = parse(infile.changeFileExt(".h"), options)
-    var source_module = parse(infile, options)
-    for n in source_module:
-      addson(header_module, n)
-    renderModule(header_module, outfile)
-  else:
-    renderModule(parse(infile, options), outfile)
-  rawMessage(hintSuccessX, [$gLinesCompiled, $(getTime() - start), 
-                            formatSize(getTotalMem())])
-
-var
-  infile = ""
-  outfile = ""
-  spliceHeader = false
-  parserOptions = newParserOptions()
-for kind, key, val in getopt():
-  case kind
-  of cmdArgument: infile = key
-  of cmdLongOption, cmdShortOption:
-    case key.toLower
-    of "help", "h":
-      stdout.write(Usage)
-      quit(0)
-    of "version", "v":
-      stdout.write(Version & "\n")
-      quit(0)
-    of "o", "out": outfile = val
-    of "spliceheader": spliceHeader = true
-    else:
-      if not parserOptions.setOption(key, val):
-        stdout.writeln("[Error] unknown option: " & key)
-  of cmdEnd: assert(false)
-if infile.len == 0:
-  # no filename has been given, so we show the help:
-  stdout.write(Usage)
-else:
-  if outfile.len == 0:
-    outfile = changeFileExt(infile, "nim")
-  infile = addFileExt(infile, "h")
-  main(infile, outfile, parserOptions, spliceHeader)
diff --git a/compiler/c2nim/clex.nim b/compiler/c2nim/clex.nim
deleted file mode 100644
index 3934eea63..000000000
--- a/compiler/c2nim/clex.nim
+++ /dev/null
@@ -1,787 +0,0 @@
-#
-#
-#      c2nim - C to Nimrod source converter
-#        (c) Copyright 2012 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-# This module implements an Ansi C scanner. This is an adaption from
-# the scanner module. Keywords are not handled here, but in the parser to make
-# it more flexible.
-
-
-import 
-  options, msgs, strutils, platform, nimlexbase, llstream
-
-const 
-  MaxLineLength* = 80         # lines longer than this lead to a warning
-  numChars*: TCharSet = {'0'..'9', 'a'..'z', 'A'..'Z'} 
-  SymChars*: TCharSet = {'a'..'z', 'A'..'Z', '0'..'9', '_', '\x80'..'\xFF'}
-  SymStartChars*: TCharSet = {'a'..'z', 'A'..'Z', '_', '\x80'..'\xFF'}
-
-type
-  TTokKind* = enum 
-    pxInvalid, pxEof,         
-    pxMacroParam,             # fake token: macro parameter (with its index)
-    pxStarComment,            # /* */ comment
-    pxLineComment,            # // comment
-    pxDirective,              # #define, etc.
-    pxDirectiveParLe,         # #define m( with parle (yes, C is that ugly!)
-    pxDirConc,                # ##
-    pxNewLine,                # newline: end of directive
-    pxAmp,                    # &
-    pxAmpAmp,                 # && 
-    pxAmpAsgn,                # &=
-    pxAmpAmpAsgn,             # &&=
-    pxBar,                    # |
-    pxBarBar,                 # ||
-    pxBarAsgn,                # |=
-    pxBarBarAsgn,             # ||=
-    pxNot,                    # !
-    pxPlusPlus,               # ++
-    pxMinusMinus,             # --
-    pxPlus,                   # +
-    pxPlusAsgn,               # +=
-    pxMinus,                  # -
-    pxMinusAsgn,              # -=
-    pxMod,                    # %
-    pxModAsgn,                # %=
-    pxSlash,                  # /
-    pxSlashAsgn,              # /=
-    pxStar,                   # *
-    pxStarAsgn,               # *=
-    pxHat,                    # ^
-    pxHatAsgn,                # ^=
-    pxAsgn,                   # =
-    pxEquals,                 # ==
-    pxDot,                    # .
-    pxDotDotDot,              # ...
-    pxLe,                     # <=
-    pxLt,                     # <
-    pxGe,                     # >=
-    pxGt,                     # >
-    pxNeq,                    # != 
-    pxConditional,            # ?
-    pxShl,                    # <<
-    pxShlAsgn,                # <<=
-    pxShr,                    # >>
-    pxShrAsgn,                # >>=
-    pxTilde,                  # ~
-    pxTildeAsgn,              # ~=
-    pxArrow,                  # ->
-    pxScope,                  # ::
-
-    pxStrLit, 
-    pxCharLit,
-    pxSymbol,                 # a symbol
-    pxIntLit, 
-    pxInt64Lit, # long constant like 0x70fffffff or out of int range
-    pxFloatLit, 
-    pxParLe, pxBracketLe, pxCurlyLe, # this order is important 
-    pxParRi, pxBracketRi, pxCurlyRi, # for macro argument parsing!
-    pxComma, pxSemiColon, pxColon,
-    pxAngleRi                 # '>' but determined to be the end of a
-                              # template's angle bracket
-  TTokKinds* = set[TTokKind]
-
-type
-  TNumericalBase* = enum base10, base2, base8, base16
-  TToken* = object
-    xkind*: TTokKind          # the type of the token
-    s*: string                # parsed symbol, char or string literal
-    iNumber*: BiggestInt      # the parsed integer literal;
-                              # if xkind == pxMacroParam: parameter's position
-    fNumber*: BiggestFloat    # the parsed floating point literal
-    base*: TNumericalBase     # the numerical base; only valid for int
-                              # or float literals
-    next*: ref TToken         # for C we need arbitrary look-ahead :-(
-  
-  TLexer* = object of TBaseLexer
-    fileIdx*: int32
-    inDirective: bool
-  
-proc getTok*(L: var TLexer, tok: var TToken)
-proc printTok*(tok: TToken)
-proc `$`*(tok: TToken): string
-# implementation
-
-var
-  gLinesCompiled*: int
-
-proc fillToken(L: var TToken) = 
-  L.xkind = pxInvalid
-  L.iNumber = 0
-  L.s = ""
-  L.fNumber = 0.0
-  L.base = base10
-  
-proc openLexer*(lex: var TLexer, filename: string, inputstream: PLLStream) = 
-  openBaseLexer(lex, inputstream)
-  lex.fileIdx = filename.fileInfoIdx
-
-proc closeLexer*(lex: var TLexer) = 
-  inc(gLinesCompiled, lex.LineNumber)
-  closeBaseLexer(lex)
-
-proc getColumn*(L: TLexer): int = 
-  result = getColNumber(L, L.bufPos)
-
-proc getLineInfo*(L: TLexer): TLineInfo = 
-  result = newLineInfo(L.fileIdx, L.linenumber, getColNumber(L, L.bufpos))
-
-proc lexMessage*(L: TLexer, msg: TMsgKind, arg = "") = 
-  msgs.GlobalError(getLineInfo(L), msg, arg)
-
-proc lexMessagePos(L: var TLexer, msg: TMsgKind, pos: int, arg = "") = 
-  var info = newLineInfo(L.fileIdx, L.linenumber, pos - L.lineStart)
-  msgs.GlobalError(info, msg, arg)
-
-proc tokKindToStr*(k: TTokKind): string =
-  case k
-  of pxEof: result = "[EOF]"
-  of pxInvalid: result = "[invalid]"
-  of pxMacroParam: result = "[macro param]"
-  of pxStarComment, pxLineComment: result = "[comment]" 
-  of pxStrLit: result = "[string literal]"
-  of pxCharLit: result = "[char literal]"
-
-  of pxDirective, pxDirectiveParLe: result = "#"             # #define, etc.
-  of pxDirConc: result = "##"
-  of pxNewLine: result = "[NewLine]"
-  of pxAmp: result = "&"                   # &
-  of pxAmpAmp: result = "&&"                # && 
-  of pxAmpAsgn: result = "&="                # &=
-  of pxAmpAmpAsgn: result = "&&="            # &&=
-  of pxBar: result = "|"                   # |
-  of pxBarBar: result = "||"                # ||
-  of pxBarAsgn: result = "|="               # |=
-  of pxBarBarAsgn: result = "||="            # ||=
-  of pxNot: result = "!"                   # !
-  of pxPlusPlus: result = "++"             # ++
-  of pxMinusMinus: result = "--"            # --
-  of pxPlus: result = "+"                  # +
-  of pxPlusAsgn: result = "+="              # +=
-  of pxMinus: result = "-"                 # -
-  of pxMinusAsgn: result = "-="             # -=
-  of pxMod: result = "%"                   # %
-  of pxModAsgn: result = "%="               # %=
-  of pxSlash: result = "/"                 # /
-  of pxSlashAsgn: result = "/="             # /=
-  of pxStar: result = "*"                  # *
-  of pxStarAsgn: result = "*="              # *=
-  of pxHat: result = "^"                   # ^
-  of pxHatAsgn: result = "^="               # ^=
-  of pxAsgn: result = "="                  # =
-  of pxEquals: result = "=="                # ==
-  of pxDot: result = "."                   # .
-  of pxDotDotDot: result = "..."             # ...
-  of pxLe: result = "<="                    # <=
-  of pxLt: result = "<"                    # <
-  of pxGe: result = ">="                    # >=
-  of pxGt: result = ">"                    # >
-  of pxNeq: result = "!="                   # != 
-  of pxConditional: result = "?"
-  of pxShl: result = "<<"
-  of pxShlAsgn: result = "<<="
-  of pxShr: result = ">>"
-  of pxShrAsgn: result = ">>="
-  of pxTilde: result = "~"
-  of pxTildeAsgn: result = "~="
-  of pxArrow: result = "->"
-  of pxScope: result = "::"
-
-  of pxSymbol: result = "[identifier]"
-  of pxIntLit, pxInt64Lit: result = "[integer literal]"
-  of pxFloatLit: result = "[floating point literal]"
-  of pxParLe: result = "("
-  of pxParRi: result = ")"
-  of pxBracketLe: result = "["
-  of pxBracketRi: result = "]"
-  of pxComma: result = ","
-  of pxSemiColon: result = ";"
-  of pxColon: result = ":"
-  of pxCurlyLe: result = "{"
-  of pxCurlyRi: result = "}"
-  of pxAngleRi: result = "> [end of template]"
-
-proc `$`(tok: TToken): string = 
-  case tok.xkind
-  of pxSymbol, pxInvalid, pxStarComment, pxLineComment, pxStrLit: result = tok.s
-  of pxIntLit, pxInt64Lit: result = $tok.iNumber
-  of pxFloatLit: result = $tok.fNumber
-  else: result = tokKindToStr(tok.xkind)
-  
-proc printTok(tok: TToken) = 
-  writeln(stdout, $tok)
-  
-proc matchUnderscoreChars(L: var TLexer, tok: var TToken, chars: TCharSet) = 
-  # matches ([chars]_)*
-  var pos = L.bufpos              # use registers for pos, buf
-  var buf = L.buf
-  while true: 
-    if buf[pos] in chars: 
-      add(tok.s, buf[pos])
-      inc(pos)
-    else: 
-      break 
-    if buf[pos] == '_': 
-      add(tok.s, '_')
-      inc(pos)
-  L.bufPos = pos
-
-proc isFloatLiteral(s: string): bool = 
-  for i in countup(0, len(s)-1): 
-    if s[i] in {'.', 'e', 'E'}: 
-      return true
-
-proc getNumber2(L: var TLexer, tok: var TToken) = 
-  var pos = L.bufpos + 2 # skip 0b
-  tok.base = base2
-  var xi: BiggestInt = 0
-  var bits = 0
-  while true: 
-    case L.buf[pos]
-    of 'A'..'Z', 'a'..'z':
-      # ignore type suffix:
-      inc(pos)
-    of '2'..'9', '.': 
-      lexMessage(L, errInvalidNumber)
-      inc(pos)
-    of '_': 
-      inc(pos)
-    of '0', '1': 
-      xi = `shl`(xi, 1) or (ord(L.buf[pos]) - ord('0'))
-      inc(pos)
-      inc(bits)
-    else: break 
-  tok.iNumber = xi
-  if (bits > 32): tok.xkind = pxInt64Lit
-  else: tok.xkind = pxIntLit
-  L.bufpos = pos
-
-proc getNumber8(L: var TLexer, tok: var TToken) = 
-  var pos = L.bufpos + 1 # skip 0
-  tok.base = base8
-  var xi: BiggestInt = 0
-  var bits = 0
-  while true: 
-    case L.buf[pos]
-    of 'A'..'Z', 'a'..'z':
-      # ignore type suffix:
-      inc(pos)
-    of '8'..'9', '.': 
-      lexMessage(L, errInvalidNumber)
-      inc(pos)
-    of '_': 
-      inc(pos)
-    of '0'..'7': 
-      xi = `shl`(xi, 3) or (ord(L.buf[pos]) - ord('0'))
-      inc(pos)
-      inc(bits)
-    else: break 
-  tok.iNumber = xi
-  if (bits > 12): tok.xkind = pxInt64Lit
-  else: tok.xkind = pxIntLit
-  L.bufpos = pos
-
-proc getNumber16(L: var TLexer, tok: var TToken) = 
-  var pos = L.bufpos + 2          # skip 0x
-  tok.base = base16
-  var xi: BiggestInt = 0
-  var bits = 0
-  while true: 
-    case L.buf[pos]
-    of 'G'..'Z', 'g'..'z': 
-      # ignore type suffix:
-      inc(pos)
-    of '_': inc(pos)
-    of '0'..'9': 
-      xi = `shl`(xi, 4) or (ord(L.buf[pos]) - ord('0'))
-      inc(pos)
-      inc(bits, 4)
-    of 'a'..'f': 
-      xi = `shl`(xi, 4) or (ord(L.buf[pos]) - ord('a') + 10)
-      inc(pos)
-      inc(bits, 4)
-    of 'A'..'F': 
-      xi = `shl`(xi, 4) or (ord(L.buf[pos]) - ord('A') + 10)
-      inc(pos)
-      inc(bits, 4)
-    else: break 
-  tok.iNumber = xi
-  if bits > 32: tok.xkind = pxInt64Lit
-  else: tok.xkind = pxIntLit
-  L.bufpos = pos
-
-proc getFloating(L: var TLexer, tok: var TToken) =
-  matchUnderscoreChars(L, tok, {'0'..'9'})
-  if L.buf[L.bufpos] in {'e', 'E'}:
-    add(tok.s, L.buf[L.bufpos])
-    inc(L.bufpos)
-    if L.buf[L.bufpos] in {'+', '-'}:
-      add(tok.s, L.buf[L.bufpos])
-      inc(L.bufpos)
-    matchUnderscoreChars(L, tok, {'0'..'9'})
-
-proc getNumber(L: var TLexer, tok: var TToken) = 
-  tok.base = base10
-  if L.buf[L.bufpos] == '.':
-    add(tok.s, "0.")
-    inc(L.bufpos)
-    getFloating(L, tok)
-  else:
-    matchUnderscoreChars(L, tok, {'0'..'9'})
-    if L.buf[L.bufpos] == '.':
-      add(tok.s, '.')
-      inc(L.bufpos)
-      getFloating(L, tok)
-  try: 
-    if isFloatLiteral(tok.s): 
-      tok.fnumber = parseFloat(tok.s)
-      tok.xkind = pxFloatLit
-    else: 
-      tok.iNumber = parseInt(tok.s)
-      if (tok.iNumber < low(int32)) or (tok.iNumber > high(int32)): 
-        tok.xkind = pxInt64Lit
-      else: 
-        tok.xkind = pxIntLit
-  except EInvalidValue: 
-    lexMessage(L, errInvalidNumber, tok.s)
-  except EOverflow: 
-    lexMessage(L, errNumberOutOfRange, tok.s)
-  # ignore type suffix:
-  while L.buf[L.bufpos] in {'A'..'Z', 'a'..'z'}: inc(L.bufpos)
-  
-proc handleCRLF(L: var TLexer, pos: int): int = 
-  case L.buf[pos]
-  of CR: result = nimlexbase.handleCR(L, pos)
-  of LF: result = nimlexbase.handleLF(L, pos)
-  else: result = pos
-  
-proc escape(L: var TLexer, tok: var TToken, allowEmpty=false) = 
-  inc(L.bufpos) # skip \ 
-  case L.buf[L.bufpos]
-  of 'b', 'B':
-    add(tok.s, '\b')
-    inc(L.bufpos)
-  of 't', 'T':
-    add(tok.s, '\t')
-    inc(L.bufpos)
-  of 'n', 'N':
-    add(tok.s, '\L')
-    inc(L.bufpos)
-  of 'f', 'F':
-    add(tok.s, '\f')
-    inc(L.bufpos)
-  of 'r', 'R':
-    add(tok.s, '\r')
-    inc(L.bufpos)
-  of '\'':
-    add(tok.s, '\'')
-    inc(L.bufpos)
-  of '"':
-    add(tok.s, '"')
-    inc(L.bufpos)
-  of '\\':
-    add(tok.s, '\b')
-    inc(L.bufpos)  
-  of '0'..'7':
-    var xi = ord(L.buf[L.bufpos]) - ord('0')
-    inc(L.bufpos)
-    if L.buf[L.bufpos] in {'0'..'7'}:
-      xi = (xi shl 3) or (ord(L.buf[L.bufpos]) - ord('0'))
-      inc(L.bufpos)
-      if L.buf[L.bufpos] in {'0'..'7'}:
-        xi = (xi shl 3) or (ord(L.buf[L.bufpos]) - ord('0'))
-        inc(L.bufpos)
-    add(tok.s, chr(xi))
-  of 'x':
-    var xi = 0
-    inc(L.bufpos)
-    while true: 
-      case L.buf[L.bufpos]
-      of '0'..'9': 
-        xi = `shl`(xi, 4) or (ord(L.buf[L.bufpos]) - ord('0'))
-        inc(L.bufpos)
-      of 'a'..'f': 
-        xi = `shl`(xi, 4) or (ord(L.buf[L.bufpos]) - ord('a') + 10)
-        inc(L.bufpos)
-      of 'A'..'F': 
-        xi = `shl`(xi, 4) or (ord(L.buf[L.bufpos]) - ord('A') + 10)
-        inc(L.bufpos)
-      else:
-        break 
-    add(tok.s, chr(xi))
-  elif not allowEmpty:
-    lexMessage(L, errInvalidCharacterConstant)
-  
-proc getCharLit(L: var TLexer, tok: var TToken) = 
-  inc(L.bufpos) # skip '
-  if L.buf[L.bufpos] == '\\':
-    escape(L, tok)
-  else:
-    add(tok.s, L.buf[L.bufpos])
-    inc(L.bufpos)
-  if L.buf[L.bufpos] == '\'':
-    inc(L.bufpos)
-  else:
-    lexMessage(L, errMissingFinalQuote)
-  tok.xkind = pxCharLit
-
-proc getString(L: var TLexer, tok: var TToken) = 
-  var pos = L.bufPos + 1          # skip "
-  var buf = L.buf                 # put `buf` in a register
-  var line = L.linenumber         # save linenumber for better error message
-  while true: 
-    case buf[pos]
-    of '\"': 
-      inc(pos)
-      break
-    of CR: 
-      pos = nimlexbase.HandleCR(L, pos)
-      buf = L.buf
-    of LF: 
-      pos = nimlexbase.HandleLF(L, pos)
-      buf = L.buf
-    of nimlexbase.EndOfFile: 
-      var line2 = L.linenumber
-      L.LineNumber = line
-      lexMessagePos(L, errClosingQuoteExpected, L.lineStart)
-      L.LineNumber = line2
-      break 
-    of '\\': 
-      # we allow an empty \ for line concatenation, but we don't require it
-      # for line concatenation
-      L.bufpos = pos
-      escape(L, tok, allowEmpty=true)
-      pos = L.bufpos
-    else: 
-      add(tok.s, buf[pos])
-      inc(pos)
-  L.bufpos = pos
-  tok.xkind = pxStrLit
-
-proc getSymbol(L: var TLexer, tok: var TToken) = 
-  var pos = L.bufpos
-  var buf = L.buf
-  while true: 
-    var c = buf[pos]
-    if c notin SymChars: break
-    add(tok.s, c)
-    inc(pos)
-  L.bufpos = pos
-  tok.xkind = pxSymbol
-
-proc scanLineComment(L: var TLexer, tok: var TToken) = 
-  var pos = L.bufpos
-  var buf = L.buf 
-  # a comment ends if the next line does not start with the // on the same
-  # column after only whitespace
-  tok.xkind = pxLineComment
-  var col = getColNumber(L, pos)
-  while true: 
-    inc(pos, 2)               # skip //
-    add(tok.s, '#')
-    while not (buf[pos] in {CR, LF, nimlexbase.EndOfFile}): 
-      add(tok.s, buf[pos])
-      inc(pos)
-    pos = handleCRLF(L, pos)
-    buf = L.buf
-    var indent = 0
-    while buf[pos] == ' ': 
-      inc(pos)
-      inc(indent)
-    if (col == indent) and (buf[pos] == '/') and (buf[pos + 1] == '/'): 
-      add(tok.s, "\n")
-    else: 
-      break 
-  L.bufpos = pos
-
-proc scanStarComment(L: var TLexer, tok: var TToken) = 
-  var pos = L.bufpos
-  var buf = L.buf
-  tok.s = "#"
-  tok.xkind = pxStarComment
-  while true: 
-    case buf[pos]
-    of CR, LF: 
-      pos = handleCRLF(L, pos)
-      buf = L.buf
-      add(tok.s, "\n#")
-      # skip annoying stars as line prefix: (eg.
-      # /*
-      #  * ugly comment <-- this star
-      #  */
-      while buf[pos] in {' ', '\t'}:
-        add(tok.s, ' ')
-        inc(pos)
-      if buf[pos] == '*' and buf[pos+1] != '/': inc(pos)
-    of '*': 
-      inc(pos)
-      if buf[pos] == '/': 
-        inc(pos)
-        break 
-      else: 
-        add(tok.s, '*')
-    of nimlexbase.EndOfFile: 
-      lexMessage(L, errTokenExpected, "*/")
-    else: 
-      add(tok.s, buf[pos])
-      inc(pos)
-  L.bufpos = pos
-
-proc skip(L: var TLexer, tok: var TToken) = 
-  var pos = L.bufpos
-  var buf = L.buf
-  while true: 
-    case buf[pos]
-    of '\\': 
-      # Ignore \ line continuation characters when not inDirective
-      inc(pos)
-      if L.inDirective:
-        while buf[pos] in {' ', '\t'}: inc(pos)
-        if buf[pos] in {CR, LF}:
-          pos = handleCRLF(L, pos)
-          buf = L.buf
-    of ' ', Tabulator: 
-      inc(pos)                # newline is special:
-    of CR, LF: 
-      pos = handleCRLF(L, pos)
-      buf = L.buf
-      if L.inDirective:
-        tok.xkind = pxNewLine
-        L.inDirective = false
-    else: 
-      break                   # EndOfFile also leaves the loop
-  L.bufpos = pos
-
-proc getDirective(L: var TLexer, tok: var TToken) = 
-  var pos = L.bufpos + 1
-  var buf = L.buf
-  while buf[pos] in {' ', '\t'}: inc(pos)
-  while buf[pos] in SymChars: 
-    add(tok.s, buf[pos])
-    inc(pos)
-  # a HACK: we need to distinguish 
-  # #define x (...)
-  # from:
-  # #define x(...)
-  # 
-  L.bufpos = pos
-  # look ahead:
-  while buf[pos] in {' ', '\t'}: inc(pos)
-  while buf[pos] in SymChars: inc(pos)
-  if buf[pos] == '(': tok.xkind = pxDirectiveParLe
-  else: tok.xkind = pxDirective
-  L.inDirective = true
-
-proc getTok(L: var TLexer, tok: var TToken) = 
-  tok.xkind = pxInvalid
-  fillToken(tok)
-  skip(L, tok)
-  if tok.xkind == pxNewLine: return
-  var c = L.buf[L.bufpos]
-  if c in SymStartChars: 
-    getSymbol(L, tok)
-  elif c == '0':
-    case L.buf[L.bufpos+1]
-    of 'x', 'X': getNumber16(L, tok)
-    of 'b', 'B': getNumber2(L, tok)
-    of '1'..'7': getNumber8(L, tok)
-    else: getNumber(L, tok)
-  elif c in {'1'..'9'} or (c == '.' and L.buf[L.bufpos+1] in {'0'..'9'}): 
-    getNumber(L, tok)
-  else: 
-    case c
-    of ';': 
-      tok.xkind = pxSemicolon
-      inc(L.bufpos)
-    of '/': 
-      if L.buf[L.bufpos + 1] == '/': 
-        scanLineComment(L, tok)
-      elif L.buf[L.bufpos+1] == '*':
-        inc(L.bufpos, 2)
-        scanStarComment(L, tok)
-      elif L.buf[L.bufpos+1] == '=':
-        inc(L.bufpos, 2)
-        tok.xkind = pxSlashAsgn
-      else: 
-        tok.xkind = pxSlash
-        inc(L.bufpos)
-    of ',': 
-      tok.xkind = pxComma
-      inc(L.bufpos)
-    of '(': 
-      inc(L.bufpos)
-      tok.xkind = pxParLe
-    of '*': 
-      inc(L.bufpos)
-      if L.buf[L.bufpos] == '=':
-        inc(L.bufpos)
-        tok.xkind = pxStarAsgn
-      else:
-        tok.xkind = pxStar
-    of ')': 
-      inc(L.bufpos)
-      tok.xkind = pxParRi
-    of '[': 
-      inc(L.bufpos)
-      tok.xkind = pxBracketLe
-    of ']': 
-      inc(L.bufpos)
-      tok.xkind = pxBracketRi
-    of '.': 
-      inc(L.bufpos)
-      if L.buf[L.bufpos] == '.' and L.buf[L.bufpos+1] == '.': 
-        tok.xkind = pxDotDotDot
-        inc(L.bufpos, 2)
-      else: 
-        tok.xkind = pxDot
-    of '{': 
-      inc(L.bufpos)
-      tok.xkind = pxCurlyLe
-    of '}': 
-      inc(L.bufpos)
-      tok.xkind = pxCurlyRi
-    of '+': 
-      inc(L.bufpos)
-      if L.buf[L.bufpos] == '=':
-        tok.xkind = pxPlusAsgn
-        inc(L.bufpos)
-      elif L.buf[L.bufpos] == '+': 
-        tok.xkind = pxPlusPlus
-        inc(L.bufpos)
-      else: 
-        tok.xkind = pxPlus
-    of '-': 
-      inc(L.bufpos)
-      case L.buf[L.bufpos] 
-      of '>':
-        tok.xkind = pxArrow
-        inc(L.bufpos)
-      of '=':
-        tok.xkind = pxMinusAsgn
-        inc(L.bufpos)
-      of '-': 
-        tok.xkind = pxMinusMinus
-        inc(L.bufpos)
-      else: 
-        tok.xkind = pxMinus
-    of '?':
-      inc(L.bufpos)
-      tok.xkind = pxConditional
-    of ':': 
-      inc(L.bufpos)
-      if L.buf[L.bufpos] == ':':
-        tok.xkind = pxScope
-        inc(L.bufpos)
-      else:
-        tok.xkind = pxColon
-    of '!':
-      inc(L.bufpos)
-      if L.buf[L.bufpos] == '=':
-        tok.xkind = pxNeq
-        inc(L.bufpos)
-      else: 
-        tok.xkind = pxNot
-    of '<': 
-      inc(L.bufpos)
-      if L.buf[L.bufpos] == '=': 
-        inc(L.bufpos)
-        tok.xkind = pxLe
-      elif L.buf[L.bufpos] == '<':
-        inc(L.bufpos)
-        if L.buf[L.bufpos] == '=': 
-          inc(L.bufpos)
-          tok.xkind = pxShlAsgn
-        else:
-          tok.xkind = pxShl
-      else: 
-        tok.xkind = pxLt
-    of '>': 
-      inc(L.bufpos)
-      if L.buf[L.bufpos] == '=': 
-        inc(L.bufpos)
-        tok.xkind = pxGe
-      elif L.buf[L.bufpos] == '>':
-        inc(L.bufpos)
-        if L.buf[L.bufpos] == '=': 
-          inc(L.bufpos)
-          tok.xkind = pxShrAsgn
-        else:
-          tok.xkind = pxShr
-      else: 
-        tok.xkind = pxGt
-    of '=': 
-      inc(L.bufpos)
-      if L.buf[L.bufpos] == '=':
-        tok.xkind = pxEquals
-        inc(L.bufpos)
-      else: 
-        tok.xkind = pxAsgn
-    of '&': 
-      inc(L.bufpos)
-      if L.buf[L.bufpos] == '=':
-        tok.xkind = pxAmpAsgn
-        inc(L.bufpos)
-      elif L.buf[L.bufpos] == '&':
-        inc(L.bufpos)
-        if L.buf[L.bufpos] == '=':
-          inc(L.bufpos)
-          tok.xkind = pxAmpAmpAsgn
-        else:
-          tok.xkind = pxAmpAmp
-      else: 
-        tok.xkind = pxAmp
-    of '|': 
-      inc(L.bufpos)
-      if L.buf[L.bufpos] == '=':
-        tok.xkind = pxBarAsgn
-        inc(L.bufpos)
-      elif L.buf[L.bufpos] == '|':
-        inc(L.bufpos)
-        if L.buf[L.bufpos] == '=':
-          inc(L.bufpos)
-          tok.xkind = pxBarBarAsgn
-        else:
-          tok.xkind = pxBarBar
-      else: 
-        tok.xkind = pxBar
-    of '^': 
-      inc(L.bufpos)
-      if L.buf[L.bufpos] == '=':
-        tok.xkind = pxHatAsgn
-        inc(L.bufpos)
-      else: 
-        tok.xkind = pxHat
-    of '%': 
-      inc(L.bufpos)
-      if L.buf[L.bufpos] == '=':
-        tok.xkind = pxModAsgn
-        inc(L.bufpos)
-      else: 
-        tok.xkind = pxMod
-    of '~':
-      inc(L.bufpos)
-      if L.buf[L.bufpos] == '=':
-        tok.xkind = pxTildeAsgn
-        inc(L.bufpos)
-      else: 
-        tok.xkind = pxTilde
-    of '#': 
-      if L.buf[L.bufpos+1] == '#':
-        inc(L.bufpos, 2)
-        tok.xkind = pxDirConc
-      else:
-        getDirective(L, tok)
-    of '"': getString(L, tok)
-    of '\'': getCharLit(L, tok)
-    of nimlexbase.EndOfFile: 
-      tok.xkind = pxEof
-    else: 
-      tok.s = $c
-      tok.xkind = pxInvalid
-      lexMessage(L, errInvalidToken, c & " (\\" & $(ord(c)) & ')')
-      inc(L.bufpos)
diff --git a/compiler/c2nim/cparse.nim b/compiler/c2nim/cparse.nim
deleted file mode 100644
index 52d50ca39..000000000
--- a/compiler/c2nim/cparse.nim
+++ /dev/null
@@ -1,2142 +0,0 @@
-#
-#
-#      c2nim - C to Nimrod source converter
-#        (c) Copyright 2013 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-## This module implements an Ansi C parser.
-## It translates a C source file into a Nimrod AST. Then the renderer can be
-## used to convert the AST to its text representation.
-
-# TODO
-# - document 'cpp' mode
-# - implement handling of '::': function declarations
-# - C++'s "operator" still needs some love
-# - support '#if' in classes
-
-import 
-  os, llstream, renderer, clex, idents, strutils, pegs, ast, astalgo, msgs,
-  options, strtabs
-
-type 
-  TParserFlag = enum
-    pfRefs,             ## use "ref" instead of "ptr" for C's typ*
-    pfCDecl,            ## annotate procs with cdecl
-    pfStdCall,          ## annotate procs with stdcall
-    pfSkipInclude,      ## skip all ``#include``
-    pfTypePrefixes,     ## all generated types start with 'T' or 'P'
-    pfSkipComments,     ## do not generate comments
-    pfCpp,              ## process C++
-    pfIgnoreRValueRefs, ## transform C++'s 'T&&' to 'T'
-    pfKeepBodies        ## do not skip C++ method bodies
-  
-  TMacro = object
-    name: string
-    params: int           # number of parameters
-    body: seq[ref TToken] # can contain pxMacroParam tokens
-  
-  TParserOptions = object
-    flags: set[TParserFlag]
-    prefixes, suffixes: seq[string]
-    mangleRules: seq[tuple[pattern: TPeg, frmt: string]]
-    privateRules: seq[TPeg]
-    dynlibSym, header: string
-    macros: seq[TMacro]
-    toMangle: PStringTable
-    classes: PStringTable
-  PParserOptions* = ref TParserOptions
-  
-  TParser* = object
-    lex: TLexer
-    tok: ref TToken       # current token
-    options: PParserOptions
-    backtrack: seq[ref TToken]
-    inTypeDef: int
-    scopeCounter: int
-    hasDeadCodeElimPragma: bool
-    currentClass: PNode   # type that needs to be added as 'this' parameter
-  
-  TReplaceTuple* = array[0..1, string]
-
-  ERetryParsing = object of ESynch
-
-proc newParserOptions*(): PParserOptions = 
-  new(result)
-  result.prefixes = @[]
-  result.suffixes = @[]
-  result.macros = @[]
-  result.mangleRules = @[]
-  result.privateRules = @[]
-  result.flags = {}
-  result.dynlibSym = ""
-  result.header = ""
-  result.toMangle = newStringTable(modeCaseSensitive)
-  result.classes = newStringTable(modeCaseSensitive)
-
-proc setOption*(parserOptions: PParserOptions, key: string, val=""): bool = 
-  result = true
-  case key.normalize
-  of "ref": incl(parserOptions.flags, pfRefs)
-  of "dynlib": parserOptions.dynlibSym = val
-  of "header": parserOptions.header = val
-  of "cdecl": incl(parserOptions.flags, pfCdecl)
-  of "stdcall": incl(parserOptions.flags, pfStdCall)
-  of "prefix": parserOptions.prefixes.add(val)
-  of "suffix": parserOptions.suffixes.add(val)
-  of "skipinclude": incl(parserOptions.flags, pfSkipInclude)
-  of "typeprefixes": incl(parserOptions.flags, pfTypePrefixes)
-  of "skipcomments": incl(parserOptions.flags, pfSkipComments)
-  of "cpp": incl(parserOptions.flags, pfCpp)
-  of "keepbodies": incl(parserOptions.flags, pfKeepBodies)
-  of "ignorervaluerefs": incl(parserOptions.flags, pfIgnoreRValueRefs)
-  of "class": parserOptions.classes[val] = "true"
-  else: result = false
-
-proc parseUnit*(p: var TParser): PNode
-proc openParser*(p: var TParser, filename: string, inputStream: PLLStream,
-                 options = newParserOptions())
-proc closeParser*(p: var TParser)
-
-# implementation
-
-proc openParser(p: var TParser, filename: string, 
-                inputStream: PLLStream, options = newParserOptions()) = 
-  openLexer(p.lex, filename, inputStream)
-  p.options = options
-  p.backtrack = @[]
-  new(p.tok)
-
-proc parMessage(p: TParser, msg: TMsgKind, arg = "") = 
-  #assert false
-  lexMessage(p.lex, msg, arg)
-
-proc closeParser(p: var TParser) = closeLexer(p.lex)
-proc saveContext(p: var TParser) = p.backtrack.add(p.tok)
-proc closeContext(p: var TParser) = discard p.backtrack.pop()
-proc backtrackContext(p: var TParser) = p.tok = p.backtrack.pop()
-
-proc rawGetTok(p: var TParser) = 
-  if p.tok.next != nil:
-    p.tok = p.tok.next
-  elif p.backtrack.len == 0: 
-    p.tok.next = nil
-    getTok(p.lex, p.tok[])
-  else: 
-    # We need the next token and must be able to backtrack. So we need to 
-    # allocate a new token.
-    var t: ref TToken
-    new(t)
-    getTok(p.lex, t[])
-    p.tok.next = t
-    p.tok = t
-
-proc insertAngleRi(currentToken: ref TToken) = 
-  var t: ref TToken
-  new(t)
-  t.xkind = pxAngleRi
-  t.next = currentToken.next
-  currentToken.next = t
-
-proc findMacro(p: TParser): int =
-  for i in 0..high(p.options.macros):
-    if p.tok.s == p.options.macros[i].name: return i
-  return -1
-
-proc rawEat(p: var TParser, xkind: TTokKind) = 
-  if p.tok.xkind == xkind: rawGetTok(p)
-  else: parMessage(p, errTokenExpected, tokKindToStr(xkind))
-
-proc parseMacroArguments(p: var TParser): seq[seq[ref TToken]] = 
-  result = @[]
-  result.add(@[])
-  var i: array[pxParLe..pxCurlyLe, int]
-  var L = 0
-  saveContext(p)
-  while true:
-    var kind = p.tok.xkind
-    case kind
-    of pxEof: rawEat(p, pxParRi)
-    of pxParLe, pxBracketLe, pxCurlyLe: 
-      inc(i[kind])
-      result[L].add(p.tok)
-    of pxParRi:
-      # end of arguments?
-      if i[pxParLe] == 0 and i[pxBracketLe] == 0 and i[pxCurlyLe] == 0: break
-      if i[pxParLe] > 0: dec(i[pxParLe])
-      result[L].add(p.tok)
-    of pxBracketRi, pxCurlyRi:
-      kind = pred(kind, 3)
-      if i[kind] > 0: dec(i[kind])
-      result[L].add(p.tok)
-    of pxComma: 
-      if i[pxParLe] == 0 and i[pxBracketLe] == 0 and i[pxCurlyLe] == 0:
-        # next argument: comma is not part of the argument
-        result.add(@[])
-        inc(L)
-      else: 
-        # comma does not separate different arguments:
-        result[L].add(p.tok)
-    else:
-      result[L].add(p.tok)
-    rawGetTok(p)
-  closeContext(p)
-
-proc expandMacro(p: var TParser, m: TMacro) = 
-  rawGetTok(p) # skip macro name
-  var arguments: seq[seq[ref TToken]]
-  if m.params > 0:
-    rawEat(p, pxParLe)
-    arguments = parseMacroArguments(p)
-    if arguments.len != m.params: parMessage(p, errWrongNumberOfArguments)
-    rawEat(p, pxParRi)
-  # insert into the token list:
-  if m.body.len > 0:
-    var newList: ref TToken
-    new(newList)
-    var lastTok = newList
-    for tok in items(m.body): 
-      if tok.xkind == pxMacroParam: 
-        for t in items(arguments[int(tok.iNumber)]):
-          #echo "t: ", t^
-          lastTok.next = t
-          lastTok = t
-      else:
-        #echo "tok: ", tok^
-        lastTok.next = tok
-        lastTok = tok
-    lastTok.next = p.tok
-    p.tok = newList.next
-
-proc getTok(p: var TParser) = 
-  rawGetTok(p)
-  if p.tok.xkind == pxSymbol:
-    var idx = findMacro(p)
-    if idx >= 0: 
-      expandMacro(p, p.options.macros[idx])
-
-proc parLineInfo(p: TParser): TLineInfo = 
-  result = getLineInfo(p.lex)
-
-proc skipComAux(p: var TParser, n: PNode) =
-  if n != nil and n.kind != nkEmpty: 
-    if pfSkipComments notin p.options.flags:
-      if n.comment == nil: n.comment = p.tok.s
-      else: add(n.comment, "\n" & p.tok.s)
-  else: 
-    parMessage(p, warnCommentXIgnored, p.tok.s)
-  getTok(p)
-
-proc skipCom(p: var TParser, n: PNode) = 
-  while p.tok.xkind in {pxLineComment, pxStarComment}: skipComAux(p, n)
-
-proc skipStarCom(p: var TParser, n: PNode) = 
-  while p.tok.xkind == pxStarComment: skipComAux(p, n)
-
-proc getTok(p: var TParser, n: PNode) =
-  getTok(p)
-  skipCom(p, n)
-
-proc expectIdent(p: TParser) = 
-  if p.tok.xkind != pxSymbol: parMessage(p, errIdentifierExpected, $(p.tok[]))
-  
-proc eat(p: var TParser, xkind: TTokKind, n: PNode) = 
-  if p.tok.xkind == xkind: getTok(p, n)
-  else: parMessage(p, errTokenExpected, tokKindToStr(xkind))
-  
-proc eat(p: var TParser, xkind: TTokKind) = 
-  if p.tok.xkind == xkind: getTok(p)
-  else: parMessage(p, errTokenExpected, tokKindToStr(xkind))
-  
-proc eat(p: var TParser, tok: string, n: PNode) = 
-  if p.tok.s == tok: getTok(p, n)
-  else: parMessage(p, errTokenExpected, tok)
-  
-proc opt(p: var TParser, xkind: TTokKind, n: PNode) = 
-  if p.tok.xkind == xkind: getTok(p, n)
-  
-proc addSon(father, a, b: PNode) = 
-  addSon(father, a)
-  addSon(father, b)
-
-proc addSon(father, a, b, c: PNode) = 
-  addSon(father, a)
-  addSon(father, b)
-  addSon(father, c)
-  
-proc newNodeP(kind: TNodeKind, p: TParser): PNode = 
-  result = newNodeI(kind, getLineInfo(p.lex))
-
-proc newIntNodeP(kind: TNodeKind, intVal: BiggestInt, p: TParser): PNode = 
-  result = newNodeP(kind, p)
-  result.intVal = intVal
-
-proc newFloatNodeP(kind: TNodeKind, floatVal: BiggestFloat, 
-                   p: TParser): PNode = 
-  result = newNodeP(kind, p)
-  result.floatVal = floatVal
-
-proc newStrNodeP(kind: TNodeKind, strVal: string, p: TParser): PNode = 
-  result = newNodeP(kind, p)
-  result.strVal = strVal
-
-proc newIdentNodeP(ident: PIdent, p: TParser): PNode = 
-  result = newNodeP(nkIdent, p)
-  result.ident = ident
-
-proc newIdentNodeP(ident: string, p: TParser): PNode =
-  result = newIdentNodeP(getIdent(ident), p)
-
-proc mangleRules(s: string, p: TParser): string = 
-  block mangle:
-    for pattern, frmt in items(p.options.mangleRules):
-      if s.match(pattern):
-        result = s.replacef(pattern, frmt)
-        break mangle
-    block prefixes:
-      for prefix in items(p.options.prefixes): 
-        if s.startsWith(prefix): 
-          result = s.substr(prefix.len)
-          break prefixes
-      result = s
-    block suffixes:
-      for suffix in items(p.options.suffixes):
-        if result.endsWith(suffix):
-          setLen(result, result.len - suffix.len)
-          break suffixes
-
-proc mangleName(s: string, p: TParser): string = 
-  if p.options.toMangle.hasKey(s): result = p.options.toMangle[s]
-  else: result = mangleRules(s, p)
-
-proc isPrivate(s: string, p: TParser): bool = 
-  for pattern in items(p.options.privateRules): 
-    if s.match(pattern): return true
-
-proc mangledIdent(ident: string, p: TParser): PNode = 
-  result = newNodeP(nkIdent, p)
-  result.ident = getIdent(mangleName(ident, p))
-
-proc newIdentPair(a, b: string, p: TParser): PNode = 
-  result = newNodeP(nkExprColonExpr, p)
-  addSon(result, newIdentNodeP(a, p))
-  addSon(result, newIdentNodeP(b, p))
-
-proc newIdentStrLitPair(a, b: string, p: TParser): PNode =
-  result = newNodeP(nkExprColonExpr, p)
-  addSon(result, newIdentNodeP(a, p))
-  addSon(result, newStrNodeP(nkStrLit, b, p))
-
-proc addImportToPragma(pragmas: PNode, ident: string, p: TParser) =
-  addSon(pragmas, newIdentStrLitPair("importc", ident, p))
-  if p.options.dynlibSym.len > 0:
-    addSon(pragmas, newIdentPair("dynlib", p.options.dynlibSym, p))
-  else:
-    addSon(pragmas, newIdentStrLitPair("header", p.options.header, p))
-
-proc exportSym(p: TParser, i: PNode, origName: string): PNode = 
-  assert i.kind == nkIdent
-  if p.scopeCounter == 0 and not isPrivate(origName, p):
-    result = newNodeI(nkPostfix, i.info)
-    addSon(result, newIdentNode(getIdent("*"), i.info), i)
-  else:
-    result = i
-
-proc varIdent(ident: string, p: TParser): PNode = 
-  result = exportSym(p, mangledIdent(ident, p), ident)
-  if p.scopeCounter > 0: return
-  if p.options.dynlibSym.len > 0 or p.options.header.len > 0: 
-    var a = result
-    result = newNodeP(nkPragmaExpr, p)
-    var pragmas = newNodeP(nkPragma, p)
-    addSon(result, a)
-    addSon(result, pragmas)
-    addImportToPragma(pragmas, ident, p)
-
-proc fieldIdent(ident: string, p: TParser): PNode = 
-  result = exportSym(p, mangledIdent(ident, p), ident)
-  if p.scopeCounter > 0: return
-  if p.options.header.len > 0: 
-    var a = result
-    result = newNodeP(nkPragmaExpr, p)
-    var pragmas = newNodeP(nkPragma, p)
-    addSon(result, a)
-    addSon(result, pragmas)
-    addSon(pragmas, newIdentStrLitPair("importc", ident, p))
-
-proc doImport(ident: string, pragmas: PNode, p: TParser) = 
-  if p.options.dynlibSym.len > 0 or p.options.header.len > 0: 
-    addImportToPragma(pragmas, ident, p)
-
-proc doImportCpp(ident: string, pragmas: PNode, p: TParser) = 
-  if p.options.dynlibSym.len > 0 or p.options.header.len > 0:
-    addSon(pragmas, newIdentStrLitPair("importcpp", ident, p))
-    if p.options.dynlibSym.len > 0:
-      addSon(pragmas, newIdentPair("dynlib", p.options.dynlibSym, p))
-    else:
-      addSon(pragmas, newIdentStrLitPair("header", p.options.header, p))
-
-proc newBinary(opr: string, a, b: PNode, p: TParser): PNode =
-  result = newNodeP(nkInfix, p)
-  addSon(result, newIdentNodeP(getIdent(opr), p))
-  addSon(result, a)
-  addSon(result, b)
-
-proc skipIdent(p: var TParser): PNode = 
-  expectIdent(p)
-  result = mangledIdent(p.tok.s, p)
-  getTok(p, result)
-
-proc skipIdentExport(p: var TParser): PNode = 
-  expectIdent(p)
-  result = exportSym(p, mangledIdent(p.tok.s, p), p.tok.s)
-  getTok(p, result)
-
-proc skipTypeIdentExport(p: var TParser, prefix='T'): PNode = 
-  expectIdent(p)
-  var n = prefix & mangleName(p.tok.s, p)
-  p.options.toMangle[p.tok.s] = n
-  var i = newNodeP(nkIdent, p)
-  i.ident = getIdent(n)
-  result = exportSym(p, i, p.tok.s)
-  getTok(p, result)
-
-proc markTypeIdent(p: var TParser, typ: PNode) = 
-  if pfTypePrefixes in p.options.flags:
-    var prefix = ""
-    if typ == nil or typ.kind == nkEmpty: 
-      prefix = "T"
-    else: 
-      var t = typ
-      while t != nil and t.kind in {nkVarTy, nkPtrTy, nkRefTy}: 
-        prefix.add('P')
-        t = t.sons[0]
-      if prefix.len == 0: prefix.add('T')
-    expectIdent(p)
-    p.options.toMangle[p.tok.s] = prefix & mangleRules(p.tok.s, p)
-  
-# --------------- parser -----------------------------------------------------
-# We use this parsing rule: If it looks like a declaration, it is one. This
-# avoids to build a symbol table, which can't be done reliably anyway for our
-# purposes.
-
-proc expression(p: var TParser, rbp: int = 0): PNode
-proc constantExpression(p: var TParser): PNode = expression(p, 40)
-proc assignmentExpression(p: var TParser): PNode = expression(p, 30)
-proc compoundStatement(p: var TParser): PNode
-proc statement(p: var TParser): PNode
-
-proc declKeyword(p: TParser, s: string): bool = 
-  # returns true if it is a keyword that introduces a declaration
-  case s
-  of  "extern", "static", "auto", "register", "const", "volatile", "restrict",
-      "inline", "__inline", "__cdecl", "__stdcall", "__syscall", "__fastcall",
-      "__safecall", "void", "struct", "union", "enum", "typedef",
-      "short", "int", "long", "float", "double", "signed", "unsigned", "char": 
-    result = true
-  of "class":
-    result = p.options.flags.contains(pfCpp)
-
-proc stmtKeyword(s: string): bool =
-  case s
-  of  "if", "for", "while", "do", "switch", "break", "continue", "return",
-      "goto":
-    result = true
-
-# ------------------- type desc -----------------------------------------------
-
-proc isIntType(s: string): bool =
-  case s
-  of "short", "int", "long", "float", "double", "signed", "unsigned":
-    result = true
-
-proc skipConst(p: var TParser) = 
-  while p.tok.xkind == pxSymbol and
-      (p.tok.s == "const" or p.tok.s == "volatile" or p.tok.s == "restrict"): 
-    getTok(p, nil)
-
-proc isTemplateAngleBracket(p: var TParser): bool =
-  if pfCpp notin p.options.flags: return false
-  saveContext(p)
-  getTok(p, nil) # skip "<"
-  var i: array[pxParLe..pxCurlyLe, int]
-  var angles = 0
-  while true:
-    let kind = p.tok.xkind
-    case kind
-    of pxEof: break
-    of pxParLe, pxBracketLe, pxCurlyLe: inc(i[kind])
-    of pxGt, pxAngleRi:
-      # end of arguments?
-      if i[pxParLe] == 0 and i[pxBracketLe] == 0 and i[pxCurlyLe] == 0 and
-          angles == 0:
-        # mark as end token:
-        p.tok.xkind = pxAngleRi
-        result = true; 
-        break
-      if angles > 0: dec(angles)
-    of pxShr:
-      # >> can end a template too:
-      if i[pxParLe] == 0 and i[pxBracketLe] == 0 and i[pxCurlyLe] == 0 and
-          angles == 1:
-        p.tok.xkind = pxAngleRi
-        insertAngleRi(p.tok)
-        result = true
-        break
-      if angles > 1: dec(angles, 2)
-    of pxLt: inc(angles)
-    of pxParRi, pxBracketRi, pxCurlyRi:
-      let kind = pred(kind, 3)
-      if i[kind] > 0: dec(i[kind])
-      else: break
-    of pxSemicolon: break
-    else: discard
-    getTok(p, nil)
-  backtrackContext(p)
-
-proc optAngle(p: var TParser, n: PNode): PNode =
-  if p.tok.xkind == pxLt and isTemplateAngleBracket(p):
-    getTok(p)
-    result = newNodeP(nkBracketExpr, p)
-    result.add(n)
-    while true:
-      let a = assignmentExpression(p)
-      if not a.isNil: result.add(a)
-      if p.tok.xkind != pxComma: break
-      getTok(p)
-    eat(p, pxAngleRi)
-  else:
-    result = n
-
-proc optScope(p: var TParser, n: PNode): PNode =
-  result = n
-  if pfCpp in p.options.flags:
-    while p.tok.xkind == pxScope:
-      let a = result
-      result = newNodeP(nkDotExpr, p)
-      result.add(a)
-      getTok(p, result)
-      expectIdent(p)
-      result.add(mangledIdent(p.tok.s, p))
-      getTok(p, result)
-
-proc typeAtom(p: var TParser): PNode = 
-  skipConst(p)
-  expectIdent(p)
-  case p.tok.s
-  of "void": 
-    result = newNodeP(nkNilLit, p) # little hack
-    getTok(p, nil)
-  of "struct", "union", "enum": 
-    getTok(p, nil)
-    result = skipIdent(p)
-  elif isIntType(p.tok.s):
-    var x = ""
-    #getTok(p, nil)
-    var isUnsigned = false
-    while p.tok.xkind == pxSymbol and (isIntType(p.tok.s) or p.tok.s == "char"):
-      if p.tok.s == "unsigned":
-        isUnsigned = true
-      elif p.tok.s == "signed" or p.tok.s == "int":
-        discard
-      else:
-        add(x, p.tok.s)
-      getTok(p, nil)
-    if x.len == 0: x = "int"
-    let xx = if isUnsigned: "cu" & x else: "c" & x
-    result = mangledIdent(xx, p)
-  else:
-    result = mangledIdent(p.tok.s, p)
-    getTok(p, result)
-    result = optScope(p, result)
-    result = optAngle(p, result)
-    
-proc newPointerTy(p: TParser, typ: PNode): PNode =
-  if pfRefs in p.options.flags: 
-    result = newNodeP(nkRefTy, p)
-  else:
-    result = newNodeP(nkPtrTy, p)
-  result.addSon(typ)
-
-proc pointer(p: var TParser, a: PNode): PNode = 
-  result = a
-  var i = 0
-  skipConst(p)
-  while true:
-    if p.tok.xkind == pxStar:
-      inc(i)
-      getTok(p, result)
-      skipConst(p)
-      result = newPointerTy(p, result)
-    elif p.tok.xkind == pxAmp and pfCpp in p.options.flags:
-      getTok(p, result)
-      skipConst(p)
-      let b = result
-      result = newNodeP(nkVarTy, p)
-      result.add(b)
-    elif p.tok.xkind == pxAmpAmp and pfCpp in p.options.flags:
-      getTok(p, result)
-      skipConst(p)
-      if pfIgnoreRvalueRefs notin p.options.flags:
-        let b = result
-        result = newNodeP(nkVarTy, p)
-        result.add(b)
-    else: break
-  if a.kind == nkIdent and a.ident.s == "char": 
-    if i >= 2: 
-      result = newIdentNodeP("cstringArray", p)
-      for j in 1..i-2: result = newPointerTy(p, result)
-    elif i == 1: result = newIdentNodeP("cstring", p)
-  elif a.kind == nkNilLit and i > 0:
-    result = newIdentNodeP("pointer", p)
-    for j in 1..i-1: result = newPointerTy(p, result)
-
-proc newProcPragmas(p: TParser): PNode =
-  result = newNodeP(nkPragma, p)
-  if pfCDecl in p.options.flags: 
-    addSon(result, newIdentNodeP("cdecl", p))
-  elif pfStdCall in p.options.flags:
-    addSon(result, newIdentNodeP("stdcall", p))
-
-proc addPragmas(father, pragmas: PNode) =
-  if sonsLen(pragmas) > 0: addSon(father, pragmas)
-  else: addSon(father, ast.emptyNode)
-
-proc addReturnType(params, rettyp: PNode) =
-  if rettyp == nil: addSon(params, ast.emptyNode)
-  elif rettyp.kind != nkNilLit: addSon(params, rettyp)
-  else: addSon(params, ast.emptyNode)
-
-proc parseFormalParams(p: var TParser, params, pragmas: PNode)
-
-proc parseTypeSuffix(p: var TParser, typ: PNode): PNode = 
-  result = typ
-  while true:
-    case p.tok.xkind 
-    of pxBracketLe:
-      getTok(p, result)
-      skipConst(p) # POSIX contains: ``int [restrict]``
-      if p.tok.xkind != pxBracketRi:
-        var tmp = result
-        var index = expression(p)
-        # array type:
-        result = newNodeP(nkBracketExpr, p)
-        addSon(result, newIdentNodeP("array", p))
-        #var r = newNodeP(nkRange, p)
-        #addSon(r, newIntNodeP(nkIntLit, 0, p))
-        #addSon(r, newBinary("-", index, newIntNodeP(nkIntLit, 1, p), p))
-        #addSon(result, r)
-        addSon(result, index)
-        addSon(result, tmp)
-      else:
-        # pointer type:
-        var tmp = result
-        if pfRefs in p.options.flags: 
-          result = newNodeP(nkRefTy, p)
-        else:
-          result = newNodeP(nkPtrTy, p)
-        result.addSon(tmp)
-      eat(p, pxBracketRi, result)
-    of pxParLe:
-      # function pointer:
-      var procType = newNodeP(nkProcTy, p)
-      var pragmas = newProcPragmas(p)
-      var params = newNodeP(nkFormalParams, p)
-      addReturnType(params, result)
-      parseFormalParams(p, params, pragmas)
-      addSon(procType, params)
-      addPragmas(procType, pragmas)
-      result = procType
-    else: break
-
-proc typeDesc(p: var TParser): PNode = 
-  result = pointer(p, typeAtom(p))
-
-proc abstractDeclarator(p: var TParser, a: PNode): PNode
-
-proc directAbstractDeclarator(p: var TParser, a: PNode): PNode =
-  if p.tok.xkind == pxParLe:
-    getTok(p, a)
-    if p.tok.xkind in {pxStar, pxAmp, pxAmpAmp}:
-      result = abstractDeclarator(p, a)
-      eat(p, pxParRi, result)
-  return parseTypeSuffix(p, a)
-
-proc abstractDeclarator(p: var TParser, a: PNode): PNode =
-  return directAbstractDeclarator(p, pointer(p, a))
-
-proc typeName(p: var TParser): PNode =
-  return abstractDeclarator(p, typeAtom(p))
-
-proc parseField(p: var TParser, kind: TNodeKind): PNode =
-  if p.tok.xkind == pxParLe: 
-    getTok(p, nil)
-    while p.tok.xkind == pxStar: getTok(p, nil)
-    result = parseField(p, kind)
-    eat(p, pxParRi, result)
-  else: 
-    expectIdent(p)
-    if kind == nkRecList: result = fieldIdent(p.tok.s, p) 
-    else: result = mangledIdent(p.tok.s, p)
-    getTok(p, result)
-
-proc parseStructBody(p: var TParser, isUnion: bool,
-                     kind: TNodeKind = nkRecList): PNode =
-  result = newNodeP(kind, p)
-  eat(p, pxCurlyLe, result)
-  while p.tok.xkind notin {pxEof, pxCurlyRi}:
-    var baseTyp = typeAtom(p)
-    while true:
-      var def = newNodeP(nkIdentDefs, p)
-      var t = pointer(p, baseTyp)
-      var i = parseField(p, kind)
-      t = parseTypeSuffix(p, t)
-      addSon(def, i, t, ast.emptyNode)
-      addSon(result, def)
-      if p.tok.xkind != pxComma: break
-      getTok(p, def)
-    eat(p, pxSemicolon, lastSon(result))
-  eat(p, pxCurlyRi, result)
-
-proc structPragmas(p: TParser, name: PNode, origName: string): PNode = 
-  assert name.kind == nkIdent
-  result = newNodeP(nkPragmaExpr, p)
-  addSon(result, exportSym(p, name, origName))
-  var pragmas = newNodeP(nkPragma, p)
-  #addSon(pragmas, newIdentNodeP("pure", p), newIdentNodeP("final", p))
-  if p.options.header.len > 0:
-    addSon(pragmas, newIdentStrLitPair("importc", origName, p),
-                    newIdentStrLitPair("header", p.options.header, p))
-  if pragmas.len > 0: addSon(result, pragmas)
-  else: addSon(result, ast.emptyNode)
-
-proc enumPragmas(p: TParser, name: PNode): PNode =
-  result = newNodeP(nkPragmaExpr, p)
-  addSon(result, name)
-  var pragmas = newNodeP(nkPragma, p)
-  var e = newNodeP(nkExprColonExpr, p)
-  # HACK: sizeof(cint) should be constructed as AST
-  addSon(e, newIdentNodeP("size", p), newIdentNodeP("sizeof(cint)", p))
-  addSon(pragmas, e)
-  addSon(result, pragmas)
-
-proc parseStruct(p: var TParser, isUnion: bool): PNode =
-  result = newNodeP(nkObjectTy, p)
-  var pragmas = ast.emptyNode
-  if isUnion:
-    pragmas = newNodeP(nkPragma, p)
-    addSon(pragmas, newIdentNodeP("union", p))
-  addSon(result, pragmas, ast.emptyNode) # no inheritance 
-  if p.tok.xkind == pxCurlyLe:
-    addSon(result, parseStructBody(p, isUnion))
-  else: 
-    addSon(result, newNodeP(nkRecList, p))
-
-proc declarator(p: var TParser, a: PNode, ident: ptr PNode): PNode
-
-proc directDeclarator(p: var TParser, a: PNode, ident: ptr PNode): PNode =
-  case p.tok.xkind
-  of pxSymbol:
-    ident[] = skipIdent(p)
-  of pxParLe:
-    getTok(p, a)
-    if p.tok.xkind in {pxStar, pxAmp, pxAmpAmp, pxSymbol}:
-      result = declarator(p, a, ident)
-      eat(p, pxParRi, result)
-  else:
-    discard
-  return parseTypeSuffix(p, a)
-
-proc declarator(p: var TParser, a: PNode, ident: ptr PNode): PNode =
-  return directDeclarator(p, pointer(p, a), ident)
-
-# parameter-declaration
-#   declaration-specifiers declarator
-#   declaration-specifiers asbtract-declarator(opt)
-proc parseParam(p: var TParser, params: PNode) = 
-  var typ = typeDesc(p)
-  # support for ``(void)`` parameter list: 
-  if typ.kind == nkNilLit and p.tok.xkind == pxParRi: return
-  var name: PNode
-  typ = declarator(p, typ, addr name)
-  if name == nil:
-    var idx = sonsLen(params)+1
-    name = newIdentNodeP("a" & $idx, p)
-  var x = newNodeP(nkIdentDefs, p)
-  addSon(x, name, typ)
-  if p.tok.xkind == pxAsgn: 
-    # we support default parameters for C++:
-    getTok(p, x)
-    addSon(x, assignmentExpression(p))
-  else:
-    addSon(x, ast.emptyNode)
-  addSon(params, x)
-
-proc parseFormalParams(p: var TParser, params, pragmas: PNode) = 
-  eat(p, pxParLe, params)
-  while p.tok.xkind notin {pxEof, pxParRi}:
-    if p.tok.xkind == pxDotDotDot:  
-      addSon(pragmas, newIdentNodeP("varargs", p))
-      getTok(p, pragmas)
-      break
-    parseParam(p, params)
-    if p.tok.xkind != pxComma: break
-    getTok(p, params)
-  eat(p, pxParRi, params)
-
-proc parseCallConv(p: var TParser, pragmas: PNode) = 
-  while p.tok.xkind == pxSymbol:
-    case p.tok.s
-    of "inline", "__inline": addSon(pragmas, newIdentNodeP("inline", p))
-    of "__cdecl": addSon(pragmas, newIdentNodeP("cdecl", p))
-    of "__stdcall": addSon(pragmas, newIdentNodeP("stdcall", p))
-    of "__syscall": addSon(pragmas, newIdentNodeP("syscall", p))
-    of "__fastcall": addSon(pragmas, newIdentNodeP("fastcall", p))
-    of "__safecall": addSon(pragmas, newIdentNodeP("safecall", p))
-    else: break
-    getTok(p, nil)
-
-proc parseFunctionPointerDecl(p: var TParser, rettyp: PNode): PNode = 
-  var procType = newNodeP(nkProcTy, p)
-  var pragmas = newProcPragmas(p)
-  var params = newNodeP(nkFormalParams, p)
-  eat(p, pxParLe, params)
-  addReturnType(params, rettyp)
-  parseCallConv(p, pragmas)
-  if p.tok.xkind == pxStar: getTok(p, params)
-  else: parMessage(p, errTokenExpected, "*")
-  if p.inTypeDef > 0: markTypeIdent(p, nil)
-  var name = skipIdentExport(p)
-  eat(p, pxParRi, name)
-  parseFormalParams(p, params, pragmas)
-  addSon(procType, params)
-  addPragmas(procType, pragmas)
-  
-  if p.inTypeDef == 0:
-    result = newNodeP(nkVarSection, p)
-    var def = newNodeP(nkIdentDefs, p)
-    addSon(def, name, procType, ast.emptyNode)
-    addSon(result, def)    
-  else:
-    result = newNodeP(nkTypeDef, p)
-    addSon(result, name, ast.emptyNode, procType)
-  assert result != nil
-  
-proc addTypeDef(section, name, t: PNode) = 
-  var def = newNodeI(nkTypeDef, name.info)
-  addSon(def, name, ast.emptyNode, t)
-  addSon(section, def)
-  
-proc otherTypeDef(p: var TParser, section, typ: PNode) = 
-  var name: PNode
-  var t = typ
-  if p.tok.xkind in {pxStar, pxAmp, pxAmpAmp}:
-    t = pointer(p, t)
-  if p.tok.xkind == pxParLe: 
-    # function pointer: typedef typ (*name)();
-    var x = parseFunctionPointerDecl(p, t)
-    name = x[0]
-    t = x[2]
-  else: 
-    # typedef typ name;
-    markTypeIdent(p, t)
-    name = skipIdentExport(p)
-  t = parseTypeSuffix(p, t)
-  addTypeDef(section, name, t)
-
-proc parseTrailingDefinedTypes(p: var TParser, section, typ: PNode) = 
-  while p.tok.xkind == pxComma:
-    getTok(p, nil)
-    var newTyp = pointer(p, typ)
-    markTypeIdent(p, newTyp)
-    var newName = skipIdentExport(p)
-    newTyp = parseTypeSuffix(p, newTyp)
-    addTypeDef(section, newName, newTyp)
-
-proc enumFields(p: var TParser): PNode = 
-  result = newNodeP(nkEnumTy, p)
-  addSon(result, ast.emptyNode) # enum does not inherit from anything
-  while true:
-    var e = skipIdent(p)
-    if p.tok.xkind == pxAsgn: 
-      getTok(p, e)
-      var c = constantExpression(p)
-      var a = e
-      e = newNodeP(nkEnumFieldDef, p)
-      addSon(e, a, c)
-      skipCom(p, e)
-    
-    addSon(result, e)
-    if p.tok.xkind != pxComma: break
-    getTok(p, e)
-    # allow trailing comma:
-    if p.tok.xkind == pxCurlyRi: break
-
-proc parseTypedefStruct(p: var TParser, result: PNode, isUnion: bool) = 
-  getTok(p, result)
-  if p.tok.xkind == pxCurlyLe:
-    var t = parseStruct(p, isUnion)
-    var origName = p.tok.s
-    markTypeIdent(p, nil)
-    var name = skipIdent(p)
-    addTypeDef(result, structPragmas(p, name, origName), t)
-    parseTrailingDefinedTypes(p, result, name)
-  elif p.tok.xkind == pxSymbol: 
-    # name to be defined or type "struct a", we don't know yet:
-    markTypeIdent(p, nil)
-    var origName = p.tok.s
-    var nameOrType = skipIdent(p)
-    case p.tok.xkind 
-    of pxCurlyLe:
-      var t = parseStruct(p, isUnion)
-      if p.tok.xkind == pxSymbol: 
-        # typedef struct tagABC {} abc, *pabc;
-        # --> abc is a better type name than tagABC!
-        markTypeIdent(p, nil)
-        var origName = p.tok.s
-        var name = skipIdent(p)
-        addTypeDef(result, structPragmas(p, name, origName), t)
-        parseTrailingDefinedTypes(p, result, name)
-      else:
-        addTypeDef(result, structPragmas(p, nameOrType, origName), t)
-    of pxSymbol: 
-      # typedef struct a a?
-      if mangleName(p.tok.s, p) == nameOrType.ident.s:
-        # ignore the declaration:
-        getTok(p, nil)
-      else:
-        # typedef struct a b; or typedef struct a b[45];
-        otherTypeDef(p, result, nameOrType)
-    else: 
-      otherTypeDef(p, result, nameOrType)
-  else:
-    expectIdent(p)
-
-proc parseTypedefEnum(p: var TParser, result: PNode) = 
-  getTok(p, result)
-  if p.tok.xkind == pxCurlyLe:
-    getTok(p, result)
-    var t = enumFields(p)
-    eat(p, pxCurlyRi, t)
-    var origName = p.tok.s
-    markTypeIdent(p, nil)
-    var name = skipIdent(p)
-    addTypeDef(result, enumPragmas(p, exportSym(p, name, origName)), t)
-    parseTrailingDefinedTypes(p, result, name)
-  elif p.tok.xkind == pxSymbol: 
-    # name to be defined or type "enum a", we don't know yet:
-    markTypeIdent(p, nil)
-    var origName = p.tok.s
-    var nameOrType = skipIdent(p)
-    case p.tok.xkind 
-    of pxCurlyLe:
-      getTok(p, result)
-      var t = enumFields(p)
-      eat(p, pxCurlyRi, t)
-      if p.tok.xkind == pxSymbol: 
-        # typedef enum tagABC {} abc, *pabc;
-        # --> abc is a better type name than tagABC!
-        markTypeIdent(p, nil)
-        var origName = p.tok.s
-        var name = skipIdent(p)
-        addTypeDef(result, enumPragmas(p, exportSym(p, name, origName)), t)
-        parseTrailingDefinedTypes(p, result, name)
-      else:
-        addTypeDef(result, 
-                   enumPragmas(p, exportSym(p, nameOrType, origName)), t)
-    of pxSymbol: 
-      # typedef enum a a?
-      if mangleName(p.tok.s, p) == nameOrType.ident.s:
-        # ignore the declaration:
-        getTok(p, nil)
-      else:
-        # typedef enum a b; or typedef enum a b[45];
-        otherTypeDef(p, result, nameOrType)
-    else: 
-      otherTypeDef(p, result, nameOrType)
-  else:
-    expectIdent(p)
-
-proc parseTypeDef(p: var TParser): PNode =  
-  result = newNodeP(nkTypeSection, p)
-  while p.tok.xkind == pxSymbol and p.tok.s == "typedef":
-    getTok(p, result)
-    inc(p.inTypeDef)
-    expectIdent(p)
-    case p.tok.s
-    of "struct": parseTypedefStruct(p, result, isUnion=false)
-    of "union": parseTypedefStruct(p, result, isUnion=true)
-    of "enum": parseTypedefEnum(p, result)
-    of "class":
-      if pfCpp in p.options.flags:
-        parseTypedefStruct(p, result, isUnion=false)
-      else:
-        var t = typeAtom(p)
-        otherTypeDef(p, result, t)
-    else: 
-      var t = typeAtom(p)
-      otherTypeDef(p, result, t)
-    eat(p, pxSemicolon)
-    dec(p.inTypeDef)
-    
-proc skipDeclarationSpecifiers(p: var TParser) =
-  while p.tok.xkind == pxSymbol:
-    case p.tok.s
-    of "extern", "static", "auto", "register", "const", "volatile": 
-      getTok(p, nil)
-    else: break
-
-proc parseInitializer(p: var TParser): PNode = 
-  if p.tok.xkind == pxCurlyLe: 
-    result = newNodeP(nkBracket, p)
-    getTok(p, result)
-    while p.tok.xkind notin {pxEof, pxCurlyRi}: 
-      addSon(result, parseInitializer(p))
-      opt(p, pxComma, nil)
-    eat(p, pxCurlyRi, result)
-  else:
-    result = assignmentExpression(p)
-
-proc addInitializer(p: var TParser, def: PNode) = 
-  if p.tok.xkind == pxAsgn:
-    getTok(p, def)
-    addSon(def, parseInitializer(p))
-  else:
-    addSon(def, ast.emptyNode)  
-
-proc parseVarDecl(p: var TParser, baseTyp, typ: PNode, 
-                  origName: string): PNode =  
-  result = newNodeP(nkVarSection, p)
-  var def = newNodeP(nkIdentDefs, p)
-  addSon(def, varIdent(origName, p))
-  addSon(def, parseTypeSuffix(p, typ))
-  addInitializer(p, def)
-  addSon(result, def)
-    
-  while p.tok.xkind == pxComma: 
-    getTok(p, def)
-    var t = pointer(p, baseTyp)
-    expectIdent(p)
-    def = newNodeP(nkIdentDefs, p)
-    addSon(def, varIdent(p.tok.s, p))
-    getTok(p, def)
-    addSon(def, parseTypeSuffix(p, t))
-    addInitializer(p, def)
-    addSon(result, def)
-  eat(p, pxSemicolon)
-
-proc declarationName(p: var TParser): string =
-  expectIdent(p)
-  result = p.tok.s
-  getTok(p) # skip identifier
-  while p.tok.xkind == pxScope and pfCpp in p.options.flags:
-    getTok(p) # skip "::"
-    expectIdent(p)
-    result.add("::")
-    result.add(p.tok.s)
-    getTok(p)
-
-proc declaration(p: var TParser): PNode = 
-  result = newNodeP(nkProcDef, p)
-  var pragmas = newNodeP(nkPragma, p)
-  
-  skipDeclarationSpecifiers(p)
-  parseCallConv(p, pragmas)
-  skipDeclarationSpecifiers(p)
-  expectIdent(p)
-  var baseTyp = typeAtom(p)
-  var rettyp = pointer(p, baseTyp)
-  skipDeclarationSpecifiers(p)
-  parseCallConv(p, pragmas)
-  skipDeclarationSpecifiers(p)
-  
-  if p.tok.xkind == pxParLe: 
-    # Function pointer declaration: This is of course only a heuristic, but the
-    # best we can do here.
-    result = parseFunctionPointerDecl(p, rettyp)
-    eat(p, pxSemicolon)
-    return
-  var origName = declarationName(p)
-  case p.tok.xkind
-  of pxParLe:
-    # really a function!
-    var name = mangledIdent(origName, p)
-    var params = newNodeP(nkFormalParams, p)
-    addReturnType(params, rettyp)
-    parseFormalParams(p, params, pragmas)
-    if pfCpp in p.options.flags and p.tok.xkind == pxSymbol and
-        p.tok.s == "const":
-      addSon(pragmas, newIdentNodeP("noSideEffect", p))
-      getTok(p)
-    if pfCDecl in p.options.flags:
-      addSon(pragmas, newIdentNodeP("cdecl", p))
-    elif pfStdcall in p.options.flags:
-      addSon(pragmas, newIdentNodeP("stdcall", p))
-    # no pattern, no exceptions:
-    addSon(result, exportSym(p, name, origName), ast.emptyNode, ast.emptyNode)
-    addSon(result, params, pragmas, ast.emptyNode) # no exceptions
-    case p.tok.xkind 
-    of pxSemicolon: 
-      getTok(p)
-      addSon(result, ast.emptyNode) # nobody
-      if p.scopeCounter == 0: doImport(origName, pragmas, p)
-    of pxCurlyLe:
-      addSon(result, compoundStatement(p))
-    else:
-      parMessage(p, errTokenExpected, ";")
-    if sonsLen(result.sons[pragmasPos]) == 0: 
-      result.sons[pragmasPos] = ast.emptyNode
-  else:
-    result = parseVarDecl(p, baseTyp, rettyp, origName)
-  assert result != nil
-
-proc createConst(name, typ, val: PNode, p: TParser): PNode =
-  result = newNodeP(nkConstDef, p)
-  addSon(result, name, typ, val)
-
-proc enumSpecifier(p: var TParser): PNode =  
-  saveContext(p)
-  getTok(p, nil) # skip "enum"
-  case p.tok.xkind
-  of pxCurlyLe: 
-    closeContext(p)
-    # make a const section out of it:
-    result = newNodeP(nkConstSection, p)
-    getTok(p, result)
-    var i = 0
-    var hasUnknown = false
-    while true:
-      var name = skipIdentExport(p)
-      var val: PNode
-      if p.tok.xkind == pxAsgn: 
-        getTok(p, name)
-        val = constantExpression(p)
-        if val.kind == nkIntLit:  
-          i = int(val.intVal)+1
-          hasUnknown = false
-        else:
-          hasUnknown = true
-      else:
-        if hasUnknown:
-          parMessage(p, warnUser, "computed const value may be wrong: " &
-            name.renderTree)
-        val = newIntNodeP(nkIntLit, i, p)
-        inc(i)
-      var c = createConst(name, ast.emptyNode, val, p)
-      addSon(result, c)
-      if p.tok.xkind != pxComma: break
-      getTok(p, c)
-      # allow trailing comma:
-      if p.tok.xkind == pxCurlyRi: break
-    eat(p, pxCurlyRi, result)
-    eat(p, pxSemicolon)
-  of pxSymbol: 
-    var origName = p.tok.s
-    markTypeIdent(p, nil)
-    result = skipIdent(p)
-    case p.tok.xkind 
-    of pxCurlyLe: 
-      closeContext(p)
-      var name = result
-      # create a type section containing the enum
-      result = newNodeP(nkTypeSection, p)
-      var t = newNodeP(nkTypeDef, p)
-      getTok(p, t)
-      var e = enumFields(p)
-      addSon(t, exportSym(p, name, origName), ast.emptyNode, e)
-      addSon(result, t)
-      eat(p, pxCurlyRi, result)
-      eat(p, pxSemicolon)
-    of pxSemicolon:
-      # just ignore ``enum X;`` for now.
-      closeContext(p)
-      getTok(p, nil)
-    else: 
-      backtrackContext(p)
-      result = declaration(p)
-  else:
-    closeContext(p)
-    parMessage(p, errTokenExpected, "{")
-    result = ast.emptyNode
-    
-# Expressions
-
-proc setBaseFlags(n: PNode, base: TNumericalBase) = 
-  case base
-  of base10: discard
-  of base2: incl(n.flags, nfBase2)
-  of base8: incl(n.flags, nfBase8)
-  of base16: incl(n.flags, nfBase16)
-
-proc startExpression(p : var TParser, tok : TToken) : PNode =
-  #echo "nud ", $tok
-  case tok.xkind:
-  of pxSymbol:
-    if tok.s == "NULL":
-      result = newNodeP(nkNilLit, p)
-    elif tok.s == "sizeof":
-      result = newNodeP(nkCall, p)
-      addSon(result, newIdentNodeP("sizeof", p))
-      saveContext(p)
-      try:
-        addSon(result, expression(p, 139))
-        closeContext(p)
-      except ERetryParsing:
-        backtrackContext(p)
-        eat(p, pxParLe)
-        addSon(result, typeName(p))
-        eat(p, pxParRi)
-    elif (tok.s == "new" or tok.s == "delete") and pfCpp in p.options.flags:
-      var opr = tok.s
-      result = newNodeP(nkCall, p)
-      if p.tok.xkind == pxBracketLe:
-        getTok(p)
-        eat(p, pxBracketRi)
-        opr.add("Array")
-      addSon(result, newIdentNodeP(opr, p))
-      if p.tok.xkind == pxParLe:
-        getTok(p, result)
-        addSon(result, typeDesc(p))
-        eat(p, pxParRi, result)
-      else:
-        addSon(result, expression(p, 139))
-    else:
-      result = mangledIdent(tok.s, p)
-      result = optScope(p, result)
-      result = optAngle(p, result)
-  of pxIntLit: 
-    result = newIntNodeP(nkIntLit, tok.iNumber, p)
-    setBaseFlags(result, tok.base)
-  of pxInt64Lit: 
-    result = newIntNodeP(nkInt64Lit, tok.iNumber, p)
-    setBaseFlags(result, tok.base)
-  of pxFloatLit: 
-    result = newFloatNodeP(nkFloatLit, tok.fNumber, p)
-    setBaseFlags(result, tok.base)
-  of pxStrLit: 
-    result = newStrNodeP(nkStrLit, tok.s, p)
-    while p.tok.xkind == pxStrLit:
-      add(result.strVal, p.tok.s)
-      getTok(p, result)
-  of pxCharLit:
-    result = newIntNodeP(nkCharLit, ord(tok.s[0]), p)
-  of pxParLe:
-    try:
-      saveContext(p)
-      result = newNodeP(nkPar, p)
-      addSon(result, expression(p, 0))
-      if p.tok.xkind != pxParRi:
-        raise newException(ERetryParsing, "expected a ')'")
-      getTok(p, result)
-      if p.tok.xkind in {pxSymbol, pxIntLit, pxFloatLit, pxStrLit, pxCharLit}:
-        raise newException(ERetryParsing, "expected a non literal token")
-      closeContext(p)
-    except ERetryParsing:
-      backtrackContext(p)
-      result = newNodeP(nkCast, p)
-      addSon(result, typeName(p))
-      eat(p, pxParRi, result)
-      addSon(result, expression(p, 139))
-  of pxPlusPlus:
-    result = newNodeP(nkCall, p)
-    addSon(result, newIdentNodeP("inc", p))
-    addSon(result, expression(p, 139))
-  of pxMinusMinus:
-    result = newNodeP(nkCall, p)
-    addSon(result, newIdentNodeP("dec", p))
-    addSon(result, expression(p, 139))
-  of pxAmp:
-    result = newNodeP(nkAddr, p)
-    addSon(result, expression(p, 139))
-  of pxStar:
-    result = newNodeP(nkBracketExpr, p)
-    addSon(result, expression(p, 139))
-  of pxPlus:
-    result = newNodeP(nkPrefix, p)
-    addSon(result, newIdentNodeP("+", p))
-    addSon(result, expression(p, 139))
-  of pxMinus:
-    result = newNodeP(nkPrefix, p)
-    addSon(result, newIdentNodeP("-", p))
-    addSon(result, expression(p, 139))
-  of pxTilde:
-    result = newNodeP(nkPrefix, p)
-    addSon(result, newIdentNodeP("not", p))
-    addSon(result, expression(p, 139))
-  of pxNot:
-    result = newNodeP(nkPrefix, p)
-    addSon(result, newIdentNodeP("not", p))
-    addSon(result, expression(p, 139))
-  else:
-    # probably from a failed sub expression attempt, try a type cast
-    raise newException(ERetryParsing, "did not expect " & $tok)
-
-proc leftBindingPower(p : var TParser, tok : ref TToken) : int =
-  #echo "lbp ", $tok[]
-  case tok.xkind:
-  of pxComma:
-    return 10
-    # throw == 20
-  of pxAsgn, pxPlusAsgn, pxMinusAsgn, pxStarAsgn, pxSlashAsgn, pxModAsgn, 
-     pxShlAsgn, pxShrAsgn, pxAmpAsgn, pxHatAsgn, pxBarAsgn:
-    return 30
-  of pxConditional:
-    return 40
-  of pxBarBar:
-    return 50
-  of pxAmpAmp:
-    return 60
-  of pxBar:
-    return 70
-  of pxHat:
-    return 80
-  of pxAmp:
-    return 90
-  of pxEquals, pxNeq:
-    return 100
-  of pxLt, pxLe, pxGt, pxGe:
-    return 110
-  of pxShl, pxShr:
-    return 120
-  of pxPlus, pxMinus:
-    return 130
-  of pxStar, pxSlash, pxMod:
-    return 140
-    # .* ->* == 150
-  of pxPlusPlus, pxMinusMinus, pxParLe, pxDot, pxArrow, pxBracketLe:
-    return 160
-    # :: == 170
-  else:
-    return 0
-
-proc buildStmtList(a: PNode): PNode
-
-proc leftExpression(p : var TParser, tok : TToken, left : PNode) : PNode =
-  #echo "led ", $tok
-  case tok.xkind:
-  of pxComma: # 10
-    # not supported as an expression, turns into a statement list
-    result = buildStmtList(left)
-    addSon(result, expression(p, 0))
-    # throw == 20
-  of pxAsgn: # 30
-    result = newNodeP(nkAsgn, p)
-    addSon(result, left, expression(p, 29))
-  of pxPlusAsgn: # 30
-    result = newNodeP(nkCall, p)
-    addSon(result, newIdentNodeP(getIdent("inc"), p), left, expression(p, 29))
-  of pxMinusAsgn: # 30
-    result = newNodeP(nkCall, p)
-    addSon(result, newIdentNodeP(getIdent("dec"), p), left, expression(p, 29))
-  of pxStarAsgn: # 30
-    result = newNodeP(nkAsgn, p)
-    var right = expression(p, 29)
-    addSon(result, left, newBinary("*", copyTree(left), right, p))
-  of pxSlashAsgn: # 30
-    result = newNodeP(nkAsgn, p)
-    var right = expression(p, 29)
-    addSon(result, left, newBinary("/", copyTree(left), right, p))
-  of pxModAsgn: # 30
-    result = newNodeP(nkAsgn, p)
-    var right = expression(p, 29)
-    addSon(result, left, newBinary("mod", copyTree(left), right, p))
-  of pxShlAsgn: # 30
-    result = newNodeP(nkAsgn, p)
-    var right = expression(p, 29)
-    addSon(result, left, newBinary("shl", copyTree(left), right, p))
-  of pxShrAsgn: # 30
-    result = newNodeP(nkAsgn, p)
-    var right = expression(p, 29)
-    addSon(result, left, newBinary("shr", copyTree(left), right, p))
-  of pxAmpAsgn: # 30
-    result = newNodeP(nkAsgn, p)
-    var right = expression(p, 29)
-    addSon(result, left, newBinary("and", copyTree(left), right, p))
-  of pxHatAsgn: # 30
-    result = newNodeP(nkAsgn, p)
-    var right = expression(p, 29)
-    addSon(result, left, newBinary("xor", copyTree(left), right, p))
-  of pxBarAsgn: # 30
-    result = newNodeP(nkAsgn, p)
-    var right = expression(p, 29)
-    addSon(result, left, newBinary("or", copyTree(left), right, p))
-  of pxConditional: # 40
-    var a = expression(p, 0)
-    eat(p, pxColon, a)
-    var b = expression(p, 39)
-    result = newNodeP(nkIfExpr, p)
-    var branch = newNodeP(nkElifExpr, p)
-    addSon(branch, left, a)
-    addSon(result, branch)
-    branch = newNodeP(nkElseExpr, p)
-    addSon(branch, b)
-    addSon(result, branch)
-  of pxBarBar: # 50
-    result = newBinary("or", left, expression(p, 50), p)
-  of pxAmpAmp: # 60
-    result = newBinary("and", left, expression(p, 60), p)
-  of pxBar: # 70
-    result = newBinary("or", left, expression(p, 70), p)
-  of pxHat: # 80
-    result = newBinary("^", left, expression(p, 80), p)
-  of pxAmp: # 90
-    result = newBinary("and", left, expression(p, 90), p)
-  of pxEquals: # 100
-    result = newBinary("==", left, expression(p, 100), p)
-  of pxNeq: # 100
-    result = newBinary("!=", left, expression(p, 100), p)
-  of pxLt: # 110
-    result = newBinary("<", left, expression(p, 110), p)
-  of pxLe: # 110
-    result = newBinary("<=", left, expression(p, 110), p)
-  of pxGt: # 110
-    result = newBinary(">", left, expression(p, 110), p)
-  of pxGe: # 110
-    result = newBinary(">=", left, expression(p, 110), p)
-  of pxShl: # 120
-    result = newBinary("shl", left, expression(p, 120), p)
-  of pxShr: # 120
-    result = newBinary("shr", left, expression(p, 120), p)
-  of pxPlus: # 130
-    result = newNodeP(nkInfix, p)
-    addSon(result, newIdentNodeP("+", p), left)
-    addSon(result, expression(p, 130))
-  of pxMinus: # 130
-    result = newNodeP(nkInfix, p)
-    addSon(result, newIdentNodeP("+", p), left)
-    addSon(result, expression(p, 130))
-  of pxStar: # 140
-    result = newNodeP(nkInfix, p)
-    addSon(result, newIdentNodeP("*", p), left)
-    addSon(result, expression(p, 140))
-  of pxSlash: # 140
-    result = newNodeP(nkInfix, p)
-    addSon(result, newIdentNodeP("div", p), left)
-    addSon(result, expression(p, 140))
-  of pxMod: # 140
-    result = newNodeP(nkInfix, p)
-    addSon(result, newIdentNodeP("mod", p), left)
-    addSon(result, expression(p, 140))
-    # .* ->* == 150
-  of pxPlusPlus: # 160
-    result = newNodeP(nkCall, p)
-    addSon(result, newIdentNodeP("inc", p), left)
-  of pxMinusMinus: # 160
-    result = newNodeP(nkCall, p)
-    addSon(result, newIdentNodeP("dec", p), left)
-  of pxParLe: # 160
-    result = newNodeP(nkCall, p)
-    addSon(result, left)
-    while p.tok.xkind != pxParRi:
-      var a = expression(p, 29)
-      addSon(result, a)
-      while p.tok.xkind == pxComma:
-        getTok(p, a)
-        a = expression(p, 29)
-        addSon(result, a)
-    eat(p, pxParRi, result)
-  of pxDot: # 160
-    result = newNodeP(nkDotExpr, p)
-    addSon(result, left)
-    addSon(result, skipIdent(p))
-  of pxArrow: # 160
-    result = newNodeP(nkDotExpr, p)
-    addSon(result, left)
-    addSon(result, skipIdent(p))
-  of pxBracketLe: # 160
-    result = newNodeP(nkBracketExpr, p)
-    addSon(result, left, expression(p))
-    eat(p, pxBracketRi, result)
-    # :: == 170
-  else:
-    result = left
-
-proc expression*(p : var TParser, rbp : int = 0) : PNode =
-  var tok : TToken
-
-  tok = p.tok[]
-  getTok(p, result)
-
-  result = startExpression(p, tok)
-
-  while rbp < leftBindingPower(p, p.tok):
-    tok = p.tok[]
-    getTok(p, result)
-    result = leftExpression(p, tok, result)
-    
-# Statements
-
-proc buildStmtList(a: PNode): PNode = 
-  if a.kind == nkStmtList: result = a
-  else:
-    result = newNodeI(nkStmtList, a.info)
-    addSon(result, a)
-
-proc nestedStatement(p: var TParser): PNode =
-  # careful: We need to translate:
-  # if (x) if (y) stmt;
-  # into:
-  # if x:
-  #   if x:
-  #     stmt
-  # 
-  # Nimrod requires complex statements to be nested in whitespace!
-  const
-    complexStmt = {nkProcDef, nkMethodDef, nkConverterDef, nkMacroDef,
-      nkTemplateDef, nkIteratorDef, nkIfStmt,
-      nkWhenStmt, nkForStmt, nkWhileStmt, nkCaseStmt, nkVarSection, 
-      nkConstSection, nkTypeSection, nkTryStmt, nkBlockStmt, nkStmtList,
-      nkCommentStmt, nkStmtListExpr, nkBlockExpr, nkStmtListType, nkBlockType}
-  result = statement(p)
-  if result.kind in complexStmt:
-    result = buildStmtList(result)
-
-proc expressionStatement(p: var TParser): PNode = 
-  # do not skip the comment after a semicolon to make a new nkCommentStmt
-  if p.tok.xkind == pxSemicolon: 
-    getTok(p)
-    result = ast.emptyNode
-  else:
-    result = expression(p)
-    if p.tok.xkind == pxSemicolon: getTok(p)
-    else: parMessage(p, errTokenExpected, ";")
-  assert result != nil
-
-proc parseIf(p: var TParser): PNode = 
-  # we parse additional "else if"s too here for better Nimrod code
-  result = newNodeP(nkIfStmt, p)
-  while true: 
-    getTok(p) # skip ``if``
-    var branch = newNodeP(nkElifBranch, p)
-    eat(p, pxParLe, branch)
-    addSon(branch, expression(p))
-    eat(p, pxParRi, branch)
-    addSon(branch, nestedStatement(p))
-    addSon(result, branch)
-    skipCom(p, branch)
-    if p.tok.s == "else": 
-      getTok(p, result)
-      if p.tok.s != "if": 
-        # ordinary else part:
-        branch = newNodeP(nkElse, p)
-        addSon(branch, nestedStatement(p))
-        addSon(result, branch)
-        break 
-    else: 
-      break 
-  
-proc parseWhile(p: var TParser): PNode = 
-  result = newNodeP(nkWhileStmt, p)
-  getTok(p, result)
-  eat(p, pxParLe, result)
-  addSon(result, expression(p))
-  eat(p, pxParRi, result)
-  addSon(result, nestedStatement(p))
-
-proc embedStmts(sl, a: PNode)
-
-proc parseDoWhile(p: var TParser): PNode =  
-  # parsing
-  result = newNodeP(nkWhileStmt, p)
-  getTok(p, result)
-  var stm = nestedStatement(p)
-  eat(p, "while", result)
-  eat(p, pxParLe, result)
-  var exp = expression(p)
-  eat(p, pxParRi, result)
-  if p.tok.xkind == pxSemicolon: getTok(p)
-
-  # while true:
-  #   stmt
-  #   if not expr:
-  #     break
-  addSon(result, newIdentNodeP("true", p))
-
-  stm = buildStmtList(stm)
-
-  # get the last exp if it is a stmtlist
-  var cleanedExp = exp
-  if exp.kind == nkStmtList:
-    cleanedExp = exp.sons[exp.len-1]
-    exp.sons = exp.sons[0..exp.len-2]
-    embedStmts(stm, exp)
-
-  var notExp = newNodeP(nkPrefix, p)
-  addSon(notExp, newIdentNodeP("not", p))
-  addSon(notExp, cleanedExp)
-
-  var brkStm = newNodeP(nkBreakStmt, p)
-  addSon(brkStm, ast.emptyNode)
-
-  var ifStm = newNodeP(nkIfStmt, p)
-  var ifBranch = newNodeP(nkElifBranch, p)
-  addSon(ifBranch, notExp)
-  addSon(ifBranch, brkStm)
-  addSon(ifStm, ifBranch)
-
-  embedStmts(stm, ifStm)
-
-  addSon(result, stm)
-
-proc declarationOrStatement(p: var TParser): PNode = 
-  if p.tok.xkind != pxSymbol:
-    result = expressionStatement(p)
-  elif declKeyword(p, p.tok.s): 
-    result = declaration(p)
-  else:
-    # ordinary identifier:
-    saveContext(p)
-    getTok(p) # skip identifier to look ahead
-    case p.tok.xkind
-    of pxSymbol, pxStar, pxLt, pxAmp, pxAmpAmp:
-      # we parse 
-      # a b
-      # a * b
-      # always as declarations! This is of course not correct, but good
-      # enough for most real world C code out there.
-      backtrackContext(p)
-      result = declaration(p)
-    of pxColon: 
-      # it is only a label:
-      closeContext(p)
-      getTok(p)
-      result = statement(p)
-    else: 
-      backtrackContext(p)
-      result = expressionStatement(p)
-  assert result != nil
-
-proc parseTuple(p: var TParser, isUnion: bool): PNode = 
-  result = parseStructBody(p, isUnion, nkTupleTy)
-
-proc parseTrailingDefinedIdents(p: var TParser, result, baseTyp: PNode) =
-  var varSection = newNodeP(nkVarSection, p)
-  while p.tok.xkind notin {pxEof, pxSemicolon}:
-    var t = pointer(p, baseTyp)
-    expectIdent(p)
-    var def = newNodeP(nkIdentDefs, p)
-    addSon(def, varIdent(p.tok.s, p))
-    getTok(p, def)
-    addSon(def, parseTypeSuffix(p, t))
-    addInitializer(p, def)
-    addSon(varSection, def)
-    if p.tok.xkind != pxComma: break
-    getTok(p, def)
-  eat(p, pxSemicolon)
-  if sonsLen(varSection) > 0:
-    addSon(result, varSection)
-
-proc parseStandaloneStruct(p: var TParser, isUnion: bool): PNode =
-  result = newNodeP(nkStmtList, p)
-  saveContext(p)
-  getTok(p, result) # skip "struct" or "union"
-  var origName = ""
-  if p.tok.xkind == pxSymbol: 
-    markTypeIdent(p, nil)
-    origName = p.tok.s
-    getTok(p, result)
-  if p.tok.xkind in {pxCurlyLe, pxSemiColon}:
-    if origName.len > 0: 
-      var name = mangledIdent(origName, p)
-      var t = parseStruct(p, isUnion)
-      var typeSection = newNodeP(nkTypeSection, p)
-      addTypeDef(typeSection, structPragmas(p, name, origName), t)
-      addSon(result, typeSection)
-      parseTrailingDefinedIdents(p, result, name)
-    else:
-      var t = parseTuple(p, isUnion)
-      parseTrailingDefinedIdents(p, result, t)
-  else:
-    backtrackContext(p)
-    result = declaration(p)
-
-proc parseFor(p: var TParser, result: PNode) = 
-  # 'for' '(' expression_statement expression_statement expression? ')'
-  #   statement
-  getTok(p, result)
-  eat(p, pxParLe, result)
-  var initStmt = declarationOrStatement(p)
-  if initStmt.kind != nkEmpty:
-    embedStmts(result, initStmt)
-  var w = newNodeP(nkWhileStmt, p)
-  var condition = expressionStatement(p)
-  if condition.kind == nkEmpty: condition = newIdentNodeP("true", p)
-  addSon(w, condition)
-  var step = if p.tok.xkind != pxParRi: expression(p) else: ast.emptyNode
-  eat(p, pxParRi, step)
-  var loopBody = nestedStatement(p)
-  if step.kind != nkEmpty:
-    loopBody = buildStmtList(loopBody)
-    embedStmts(loopBody, step)
-  addSon(w, loopBody)
-  addSon(result, w)
-  
-proc switchStatement(p: var TParser): PNode = 
-  result = newNodeP(nkStmtList, p)
-  while true:
-    if p.tok.xkind in {pxEof, pxCurlyRi}: break
-    case p.tok.s 
-    of "break":
-      getTok(p, result)
-      eat(p, pxSemicolon, result)
-      break
-    of "return", "continue", "goto": 
-      addSon(result, statement(p))
-      break
-    of "case", "default":
-      break
-    else: discard
-    addSon(result, statement(p))
-  if sonsLen(result) == 0:
-    # translate empty statement list to Nimrod's ``nil`` statement
-    result = newNodeP(nkNilLit, p)
-
-proc rangeExpression(p: var TParser): PNode =
-  # We support GCC's extension: ``case expr...expr:`` 
-  result = constantExpression(p)
-  if p.tok.xkind == pxDotDotDot:
-    getTok(p, result)
-    var a = result
-    var b = constantExpression(p)
-    result = newNodeP(nkRange, p)
-    addSon(result, a)
-    addSon(result, b)
-
-proc parseSwitch(p: var TParser): PNode = 
-  # We cannot support Duff's device or C's crazy switch syntax. We just support
-  # sane usages of switch. ;-)
-  result = newNodeP(nkCaseStmt, p)
-  getTok(p, result)
-  eat(p, pxParLe, result)
-  addSon(result, expression(p))
-  eat(p, pxParRi, result)
-  eat(p, pxCurlyLe, result)
-  var b: PNode
-  while (p.tok.xkind != pxCurlyRi) and (p.tok.xkind != pxEof): 
-    case p.tok.s 
-    of "default": 
-      b = newNodeP(nkElse, p)
-      getTok(p, b)
-      eat(p, pxColon, b)
-    of "case": 
-      b = newNodeP(nkOfBranch, p)
-      while p.tok.xkind == pxSymbol and p.tok.s == "case":
-        getTok(p, b)
-        addSon(b, rangeExpression(p))
-        eat(p, pxColon, b)
-    else:
-      parMessage(p, errXExpected, "case")
-    addSon(b, switchStatement(p))
-    addSon(result, b)
-    if b.kind == nkElse: break 
-  eat(p, pxCurlyRi)
-
-proc addStmt(sl, a: PNode) = 
-  # merge type sections if possible:
-  if a.kind != nkTypeSection or sonsLen(sl) == 0 or
-      lastSon(sl).kind != nkTypeSection:
-    addSon(sl, a)
-  else:
-    var ts = lastSon(sl)
-    for i in 0..sonsLen(a)-1: addSon(ts, a.sons[i])
-
-proc embedStmts(sl, a: PNode) = 
-  if a.kind != nkStmtList:
-    addStmt(sl, a)
-  else:
-    for i in 0..sonsLen(a)-1: 
-      if a[i].kind != nkEmpty: addStmt(sl, a[i])
-
-proc compoundStatement(p: var TParser): PNode = 
-  result = newNodeP(nkStmtList, p)
-  eat(p, pxCurlyLe)
-  inc(p.scopeCounter)
-  while p.tok.xkind notin {pxEof, pxCurlyRi}: 
-    var a = statement(p)
-    if a.kind == nkEmpty: break
-    embedStmts(result, a)
-  if sonsLen(result) == 0:
-    # translate ``{}`` to Nimrod's ``discard`` statement
-    result = newNodeP(nkDiscardStmt, p)
-    result.add(ast.emptyNode)
-  dec(p.scopeCounter)
-  eat(p, pxCurlyRi)
-
-proc skipInheritKeyw(p: var TParser) =
-  if p.tok.xkind == pxSymbol and (p.tok.s == "private" or 
-                                  p.tok.s == "protected" or
-                                  p.tok.s == "public"):
-    getTok(p)
-
-proc parseConstructor(p: var TParser, pragmas: PNode, 
-                      isDestructor=false): PNode =
-  var origName = p.tok.s
-  getTok(p)
-  
-  result = newNodeP(nkProcDef, p)
-  var rettyp = if isDestructor: newNodeP(nkNilLit, p)
-               else: mangledIdent(origName, p)
-  
-  let oname = if isDestructor: "destroy" & origName
-              else: "construct" & origName
-  var name = mangledIdent(oname, p)
-  var params = newNodeP(nkFormalParams, p)
-  addReturnType(params, rettyp)
-  if p.tok.xkind == pxParLe:
-    parseFormalParams(p, params, pragmas)
-  if p.tok.xkind == pxSymbol and p.tok.s == "const":
-    addSon(pragmas, newIdentNodeP("noSideEffect", p))
-  if pfCDecl in p.options.flags:
-    addSon(pragmas, newIdentNodeP("cdecl", p))
-  elif pfStdcall in p.options.flags:
-    addSon(pragmas, newIdentNodeP("stdcall", p))
-  if p.tok.xkind == pxColon:
-    # skip initializer list:
-    while true:
-      getTok(p)
-      discard expression(p)
-      if p.tok.xkind != pxComma: break
-  # no pattern, no exceptions:
-  addSon(result, exportSym(p, name, origName), ast.emptyNode, ast.emptyNode)
-  addSon(result, params, pragmas, ast.emptyNode) # no exceptions
-  addSon(result, ast.emptyNode) # no body
-  case p.tok.xkind 
-  of pxSemicolon: getTok(p)
-  of pxCurlyLe:
-    let body = compoundStatement(p)
-    if pfKeepBodies in p.options.flags:
-      result.sons[bodyPos] = body
-  else:
-    parMessage(p, errTokenExpected, ";")
-  if result.sons[bodyPos].kind == nkEmpty:
-    doImport((if isDestructor: "~" else: "") & origName, pragmas, p)
-  elif isDestructor:
-    addSon(pragmas, newIdentNodeP("destructor", p))
-  if sonsLen(result.sons[pragmasPos]) == 0:
-    result.sons[pragmasPos] = ast.emptyNode
-
-proc parseMethod(p: var TParser, origName: string, rettyp, pragmas: PNode,
-                 isStatic: bool): PNode =
-  result = newNodeP(nkProcDef, p)
-  var params = newNodeP(nkFormalParams, p)
-  addReturnType(params, rettyp)
-  var thisDef = newNodeP(nkIdentDefs, p)
-  if not isStatic:
-    # declare 'this':
-    var t = newNodeP(nkVarTy, p)
-    t.add(p.currentClass)
-    addSon(thisDef, newIdentNodeP("this", p), t, ast.emptyNode)
-    params.add(thisDef)
-  parseFormalParams(p, params, pragmas)
-  if p.tok.xkind == pxSymbol and p.tok.s == "const":
-    addSon(pragmas, newIdentNodeP("noSideEffect", p))
-    getTok(p, result)
-    if not isStatic:
-      # fix the type of the 'this' parameter:
-      thisDef.sons[1] = thisDef.sons[1].sons[0]
-  if pfCDecl in p.options.flags:
-    addSon(pragmas, newIdentNodeP("cdecl", p))
-  elif pfStdcall in p.options.flags:
-    addSon(pragmas, newIdentNodeP("stdcall", p))
-  # no pattern, no exceptions:
-  let methodName = newIdentNodeP(origName, p)
-  addSon(result, exportSym(p, methodName, origName),
-         ast.emptyNode, ast.emptyNode)
-  addSon(result, params, pragmas, ast.emptyNode) # no exceptions
-  addSon(result, ast.emptyNode) # no body
-  case p.tok.xkind
-  of pxSemicolon: getTok(p)
-  of pxCurlyLe:
-    let body = compoundStatement(p)
-    if pfKeepBodies in p.options.flags:
-      result.sons[bodyPos] = body
-  else:
-    parMessage(p, errTokenExpected, ";")
-  if result.sons[bodyPos].kind == nkEmpty:
-    if isStatic: doImport(origName, pragmas, p)
-    else: doImportCpp(origName, pragmas, p)
-  if sonsLen(result.sons[pragmasPos]) == 0:
-    result.sons[pragmasPos] = ast.emptyNode
-
-proc parseStandaloneClass(p: var TParser, isStruct: bool): PNode
-
-proc followedByParLe(p: var TParser): bool =
-  saveContext(p)
-  getTok(p) # skip Identifier
-  result = p.tok.xkind == pxParLe
-  backtrackContext(p)
-
-proc parseOperator(p: var TParser, origName: var string): bool =
-  getTok(p) # skip 'operator' keyword
-  case p.tok.xkind
-  of pxAmp..pxArrow:
-    # ordinary operator symbol:
-    origName.add(tokKindToStr(p.tok.xkind))
-    getTok(p)
-  of pxSymbol:
-    if p.tok.s == "new" or p.tok.s == "delete":
-      origName.add(p.tok.s)
-      getTok(p)
-      if p.tok.xkind == pxBracketLe:
-        getTok(p)
-        eat(p, pxBracketRi)
-        origName.add("[]")
-    else:
-      # type converter
-      let x = typeAtom(p)
-      if x.kind == nkIdent:
-        origName.add(x.ident.s)
-      else:
-        parMessage(p, errGenerated, "operator symbol expected")
-      result = true
-  of pxParLe:
-    getTok(p)
-    eat(p, pxParRi)
-    origName.add("()")
-  of pxBracketLe:
-    getTok(p)
-    eat(p, pxBracketRi)
-    origName.add("[]")
-  else:
-    parMessage(p, errGenerated, "operator symbol expected")
-
-proc parseClass(p: var TParser; isStruct: bool; stmtList: PNode): PNode =
-  result = newNodeP(nkObjectTy, p)
-  addSon(result, ast.emptyNode, ast.emptyNode) # no pragmas, no inheritance 
-  
-  var recList = newNodeP(nkRecList, p)
-  addSon(result, recList)
-  if p.tok.xkind == pxColon:
-    getTok(p, result)
-    skipInheritKeyw(p)
-    var baseTyp = typeAtom(p)
-    var inh = newNodeP(nkOfInherit, p)
-    inh.add(baseTyp)
-    if p.tok.xkind == pxComma:
-      parMessage(p, errGenerated, "multiple inheritance is not supported")
-      while p.tok.xkind == pxComma:
-        getTok(p)
-        skipInheritKeyw(p)
-        discard typeAtom(p)
-    result.sons[0] = inh
-    
-  eat(p, pxCurlyLe, result)
-  var private = not isStruct
-  var pragmas = newNodeP(nkPragma, p)
-  while p.tok.xkind notin {pxEof, pxCurlyRi}:
-    skipCom(p, stmtList)
-    if p.tok.xkind == pxSymbol and (p.tok.s == "private" or 
-                                    p.tok.s == "protected"):
-      getTok(p, result)
-      eat(p, pxColon, result)
-      private = true
-    elif p.tok.xkind == pxSymbol and p.tok.s == "public":
-      getTok(p, result)
-      eat(p, pxColon, result)
-      private = false
-    if p.tok.xkind == pxSymbol and (p.tok.s == "friend" or p.tok.s == "using"):
-      # we skip friend declarations:
-      while p.tok.xkind notin {pxEof, pxSemicolon}: getTok(p)
-      eat(p, pxSemicolon)
-    elif p.tok.xkind == pxSymbol and p.tok.s == "enum":
-      let x = enumSpecifier(p)
-      if not private or pfKeepBodies in p.options.flags: stmtList.add(x)
-    elif p.tok.xkind == pxSymbol and p.tok.s == "typedef":
-      let x = parseTypeDef(p)
-      if not private or pfKeepBodies in p.options.flags: stmtList.add(x)
-    elif p.tok.xkind == pxSymbol and(p.tok.s == "struct" or p.tok.s == "class"):
-      let x = parseStandaloneClass(p, isStruct=p.tok.s == "struct")
-      if not private or pfKeepBodies in p.options.flags: stmtList.add(x)
-    elif p.tok.xkind == pxSymbol and p.tok.s == "union":
-      let x = parseStandaloneStruct(p, isUnion=true)
-      if not private or pfKeepBodies in p.options.flags: stmtList.add(x)
-    else:
-      if pragmas.len != 0: pragmas = newNodeP(nkPragma, p)
-      parseCallConv(p, pragmas)
-      var isStatic = false
-      if p.tok.xkind == pxSymbol and p.tok.s == "virtual":
-        getTok(p, stmtList)
-      if p.tok.xkind == pxSymbol and p.tok.s == "explicit":
-        getTok(p, stmtList)
-      if p.tok.xkind == pxSymbol and p.tok.s == "static":
-        getTok(p, stmtList)
-        isStatic = true
-      parseCallConv(p, pragmas)
-      if p.tok.xkind == pxSymbol and p.tok.s == p.currentClass.ident.s and 
-          followedByParLe(p):
-        # constructor
-        let cons = parseConstructor(p, pragmas)
-        if not private or pfKeepBodies in p.options.flags: stmtList.add(cons)
-      elif p.tok.xkind == pxTilde:
-        # destructor
-        getTok(p, stmtList)
-        if p.tok.xkind == pxSymbol and p.tok.s == p.currentClass.ident.s:
-          let des = parseConstructor(p, pragmas, isDestructor=true)
-          if not private or pfKeepBodies in p.options.flags: stmtList.add(des)
-        else:
-          parMessage(p, errGenerated, "invalid destructor")
-      else:
-        # field declaration or method:
-        var baseTyp = typeAtom(p)
-        while true:
-          var def = newNodeP(nkIdentDefs, p)
-          var t = pointer(p, baseTyp)
-          let canBeMethod = p.tok.xkind != pxParLe
-          var origName: string
-          if p.tok.xkind == pxSymbol:
-            origName = p.tok.s
-            if p.tok.s == "operator":
-              var isConverter = parseOperator(p, origName)
-              let meth = parseMethod(p, origName, t, pragmas, isStatic)
-              if not private or pfKeepBodies in p.options.flags:
-                if isConverter: meth.kind = nkConverterDef
-                stmtList.add(meth)
-              break
-          var i = parseField(p, nkRecList)
-          if canBeMethod and p.tok.xkind == pxParLe:
-            let meth = parseMethod(p, origName, t, pragmas, isStatic)
-            if not private or pfKeepBodies in p.options.flags:
-              stmtList.add(meth)
-          else:
-            t = parseTypeSuffix(p, t)
-            addSon(def, i, t, ast.emptyNode)
-            if not isStatic: addSon(recList, def)
-          if p.tok.xkind != pxComma: break
-          getTok(p, def)
-        if p.tok.xkind == pxSemicolon:
-          getTok(p, lastSon(recList))
-  eat(p, pxCurlyRi, result)
-
-proc parseStandaloneClass(p: var TParser, isStruct: bool): PNode =
-  result = newNodeP(nkStmtList, p)
-  saveContext(p)
-  getTok(p, result) # skip "class" or "struct"
-  var origName = ""
-  let oldClass = p.currentClass
-  if p.tok.xkind == pxSymbol: 
-    markTypeIdent(p, nil)
-    origName = p.tok.s
-    getTok(p, result)
-    p.currentClass = mangledIdent(origName, p)
-  else:
-    p.currentClass = nil
-  if p.tok.xkind in {pxCurlyLe, pxSemiColon, pxColon}:
-    if origName.len > 0:
-      p.options.classes[origName] = "true"
-
-      var typeSection = newNodeP(nkTypeSection, p)
-      addSon(result, typeSection)
-      
-      var name = mangledIdent(origName, p)
-      var t = parseClass(p, isStruct, result)
-      addTypeDef(typeSection, structPragmas(p, name, origName), t)
-      parseTrailingDefinedIdents(p, result, name)
-    else:
-      var t = parseTuple(p, isUnion=false)
-      parseTrailingDefinedIdents(p, result, t)
-  else:
-    backtrackContext(p)
-    result = declaration(p)
-  p.currentClass = oldClass
-
-proc unwrap(a: PNode): PNode =
-  if a.kind == nkPar:
-    return a.sons[0]
-  return a
-
-include cpp
-
-proc statement(p: var TParser): PNode = 
-  case p.tok.xkind 
-  of pxSymbol: 
-    case p.tok.s
-    of "if": result = parseIf(p)
-    of "switch": result = parseSwitch(p)
-    of "while": result = parseWhile(p)
-    of "do": result = parseDoWhile(p)
-    of "for": 
-      result = newNodeP(nkStmtList, p)
-      parseFor(p, result)
-    of "goto": 
-      # we cannot support "goto"; in hand-written C, "goto" is most often used
-      # to break a block, so we convert it to a break statement with label.
-      result = newNodeP(nkBreakStmt, p)
-      getTok(p)
-      addSon(result, skipIdent(p))
-      eat(p, pxSemicolon)
-    of "continue":
-      result = newNodeP(nkContinueStmt, p)
-      getTok(p)
-      eat(p, pxSemicolon)
-      addSon(result, ast.emptyNode)
-    of "break":
-      result = newNodeP(nkBreakStmt, p)
-      getTok(p)
-      eat(p, pxSemicolon)
-      addSon(result, ast.emptyNode)
-    of "return":
-      result = newNodeP(nkReturnStmt, p)
-      getTok(p)
-      if p.tok.xkind == pxSemicolon:
-        addSon(result, ast.emptyNode)
-      else:
-        addSon(result, unwrap(expression(p)))
-      eat(p, pxSemicolon)
-    of "enum": result = enumSpecifier(p)
-    of "typedef": result = parseTypeDef(p)
-    of "union": result = parseStandaloneStruct(p, isUnion=true)
-    of "struct":
-      if pfCpp in p.options.flags:
-        result = parseStandaloneClass(p, isStruct=true)
-      else:
-        result = parseStandaloneStruct(p, isUnion=false)
-    of "class":
-      if pfCpp in p.options.flags:
-        result = parseStandaloneClass(p, isStruct=false)
-      else:
-        result = declarationOrStatement(p)
-    of "namespace":
-      if pfCpp in p.options.flags:
-        while p.tok.xkind notin {pxEof, pxCurlyLe}: getTok(p)
-        result = compoundStatement(p)
-      else:
-        result = declarationOrStatement(p)
-    of "using":
-      if pfCpp in p.options.flags:
-        while p.tok.xkind notin {pxEof, pxSemicolon}: getTok(p)
-        eat(p, pxSemicolon)
-        result = newNodeP(nkNilLit, p)
-      else:
-        result = declarationOrStatement(p)
-    else: result = declarationOrStatement(p)
-  of pxCurlyLe:
-    result = compoundStatement(p)
-  of pxDirective, pxDirectiveParLe:
-    result = parseDir(p)
-  of pxLineComment, pxStarComment:
-    result = newNodeP(nkCommentStmt, p)
-    skipCom(p, result)
-  of pxSemicolon:
-    # empty statement:
-    getTok(p)
-    if p.tok.xkind in {pxLineComment, pxStarComment}:
-      result = newNodeP(nkCommentStmt, p)
-      skipCom(p, result)
-    else:
-      result = newNodeP(nkNilLit, p)
-  else:
-    result = expressionStatement(p)
-  assert result != nil
-
-proc parseUnit(p: var TParser): PNode =
-  try:
-    result = newNodeP(nkStmtList, p)
-    getTok(p) # read first token
-    while p.tok.xkind != pxEof:
-      var s = statement(p)
-      if s.kind != nkEmpty: embedStmts(result, s)
-  except ERetryParsing:
-    parMessage(p, errGenerated, "Uncaught parsing exception raised")
-
diff --git a/compiler/c2nim/cpp.nim b/compiler/c2nim/cpp.nim
deleted file mode 100644
index 84b4c4dfb..000000000
--- a/compiler/c2nim/cpp.nim
+++ /dev/null
@@ -1,347 +0,0 @@
-#
-#
-#      c2nim - C to Nimrod source converter
-#        (c) Copyright 2012 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-# Preprocessor support
-
-const
-  c2nimSymbol = "C2NIM"
-
-proc eatNewLine(p: var TParser, n: PNode) = 
-  if p.tok.xkind == pxLineComment:
-    skipCom(p, n)
-    if p.tok.xkind == pxNewLine: getTok(p)
-  elif p.tok.xkind == pxNewLine: 
-    eat(p, pxNewLine)
-  
-proc skipLine(p: var TParser) = 
-  while p.tok.xkind notin {pxEof, pxNewLine, pxLineComment}: getTok(p)
-  eatNewLine(p, nil)
-
-proc parseDefineBody(p: var TParser, tmplDef: PNode): string = 
-  if p.tok.xkind == pxCurlyLe or 
-    (p.tok.xkind == pxSymbol and (
-        declKeyword(p, p.tok.s) or stmtKeyword(p.tok.s))):
-    addSon(tmplDef, statement(p))
-    result = "stmt"
-  elif p.tok.xkind in {pxLineComment, pxNewLine}:
-    addSon(tmplDef, buildStmtList(newNodeP(nkNilLit, p)))
-    result = "stmt"
-  else:
-    addSon(tmplDef, buildStmtList(expression(p)))
-    result = "expr"
-
-proc parseDefine(p: var TParser): PNode = 
-  if p.tok.xkind == pxDirectiveParLe: 
-    # a macro with parameters:
-    result = newNodeP(nkTemplateDef, p)
-    getTok(p)
-    addSon(result, skipIdentExport(p))
-    addSon(result, ast.emptyNode)
-    eat(p, pxParLe)
-    var params = newNodeP(nkFormalParams, p)
-    # return type; not known yet:
-    addSon(params, ast.emptyNode)
-    if p.tok.xkind != pxParRi:
-      var identDefs = newNodeP(nkIdentDefs, p)
-      while p.tok.xkind != pxParRi: 
-        addSon(identDefs, skipIdent(p))
-        skipStarCom(p, nil)
-        if p.tok.xkind != pxComma: break
-        getTok(p)
-      addSon(identDefs, newIdentNodeP("expr", p))
-      addSon(identDefs, ast.emptyNode)
-      addSon(params, identDefs)
-    eat(p, pxParRi)
-    
-    addSon(result, ast.emptyNode) # no generic parameters
-    addSon(result, params)
-    addSon(result, ast.emptyNode) # no pragmas
-    addSon(result, ast.emptyNode)
-    var kind = parseDefineBody(p, result)
-    params.sons[0] = newIdentNodeP(kind, p)
-    eatNewLine(p, result)
-  else:
-    # a macro without parameters:
-    result = newNodeP(nkConstSection, p)
-    while p.tok.xkind == pxDirective and p.tok.s == "define":
-      getTok(p) # skip #define
-      var c = newNodeP(nkConstDef, p)
-      addSon(c, skipIdentExport(p))
-      addSon(c, ast.emptyNode)
-      skipStarCom(p, c)
-      if p.tok.xkind in {pxLineComment, pxNewLine, pxEof}:
-        addSon(c, newIdentNodeP("true", p))
-      else:
-        addSon(c, expression(p))
-      addSon(result, c)
-      eatNewLine(p, c)
-  assert result != nil
-  
-proc parseDefBody(p: var TParser, m: var TMacro, params: seq[string]) =
-  m.body = @[]
-  # A little hack: We safe the context, so that every following token will be 
-  # put into a newly allocated TToken object. Thus we can just save a
-  # reference to the token in the macro's body.
-  saveContext(p)
-  while p.tok.xkind notin {pxEof, pxNewLine, pxLineComment}: 
-    case p.tok.xkind 
-    of pxSymbol:
-      # is it a parameter reference?
-      var tok = p.tok
-      for i in 0..high(params):
-        if params[i] == p.tok.s: 
-          new(tok)
-          tok.xkind = pxMacroParam
-          tok.iNumber = i
-          break
-      m.body.add(tok)
-    of pxDirConc: 
-      # just ignore this token: this implements token merging correctly
-      discard
-    else:
-      m.body.add(p.tok)
-    # we do not want macro expansion here:
-    rawGetTok(p)
-  eatNewLine(p, nil)
-  closeContext(p) 
-  # newline token might be overwritten, but this is not
-  # part of the macro body, so it is safe.
-  
-proc parseDef(p: var TParser, m: var TMacro) = 
-  var hasParams = p.tok.xkind == pxDirectiveParLe
-  getTok(p)
-  expectIdent(p)
-  m.name = p.tok.s
-  getTok(p)
-  var params: seq[string] = @[]
-  # parse parameters:
-  if hasParams:
-    eat(p, pxParLe)
-    while p.tok.xkind != pxParRi: 
-      expectIdent(p)
-      params.add(p.tok.s)
-      getTok(p)
-      skipStarCom(p, nil)
-      if p.tok.xkind != pxComma: break
-      getTok(p)
-    eat(p, pxParRi)
-  m.params = params.len
-  parseDefBody(p, m, params)
-  
-proc isDir(p: TParser, dir: string): bool = 
-  result = p.tok.xkind in {pxDirectiveParLe, pxDirective} and p.tok.s == dir
-
-proc parseInclude(p: var TParser): PNode = 
-  result = newNodeP(nkImportStmt, p)
-  while isDir(p, "include"):
-    getTok(p) # skip "include"
-    if p.tok.xkind == pxStrLit and pfSkipInclude notin p.options.flags:
-      var file = newStrNodeP(nkStrLit, changeFileExt(p.tok.s, ""), p)
-      addSon(result, file)
-      getTok(p)
-      skipStarCom(p, file)
-      eatNewLine(p, nil)
-    else:
-      skipLine(p)
-  if sonsLen(result) == 0: 
-    # we only parsed includes that we chose to ignore:
-    result = ast.emptyNode
-
-proc definedExprAux(p: var TParser): PNode = 
-  result = newNodeP(nkCall, p)
-  addSon(result, newIdentNodeP("defined", p))
-  addSon(result, skipIdent(p))
-
-proc parseStmtList(p: var TParser): PNode = 
-  result = newNodeP(nkStmtList, p)
-  while true: 
-    case p.tok.xkind
-    of pxEof: break 
-    of pxDirectiveParLe, pxDirective: 
-      case p.tok.s
-      of "else", "endif", "elif": break
-    else: discard
-    addSon(result, statement(p))
-  
-proc eatEndif(p: var TParser) =
-  if isDir(p, "endif"): 
-    skipLine(p)
-  else: 
-    parMessage(p, errXExpected, "#endif")
-  
-proc parseIfDirAux(p: var TParser, result: PNode) = 
-  addSon(result.sons[0], parseStmtList(p))
-  while isDir(p, "elif"): 
-    var b = newNodeP(nkElifBranch, p)
-    getTok(p)
-    addSon(b, expression(p))
-    eatNewLine(p, nil)
-    addSon(b, parseStmtList(p))
-    addSon(result, b)
-  if isDir(p, "else"): 
-    var s = newNodeP(nkElse, p)
-    skipLine(p)
-    addSon(s, parseStmtList(p))
-    addSon(result, s)
-  eatEndif(p)
-    
-proc skipUntilEndif(p: var TParser) =
-  var nested = 1
-  while p.tok.xkind != pxEof:
-    if isDir(p, "ifdef") or isDir(p, "ifndef") or isDir(p, "if"): 
-      inc(nested)
-    elif isDir(p, "endif"): 
-      dec(nested)
-      if nested <= 0:
-        skipLine(p)
-        return
-    getTok(p)
-  parMessage(p, errXExpected, "#endif")
-  
-type
-  TEndifMarker = enum
-    emElif, emElse, emEndif
-  
-proc skipUntilElifElseEndif(p: var TParser): TEndifMarker =
-  var nested = 1
-  while p.tok.xkind != pxEof:
-    if isDir(p, "ifdef") or isDir(p, "ifndef") or isDir(p, "if"): 
-      inc(nested)
-    elif isDir(p, "elif") and nested <= 1:
-      return emElif
-    elif isDir(p, "else") and nested <= 1:
-      return emElse
-    elif isDir(p, "endif"): 
-      dec(nested)
-      if nested <= 0:
-        return emEndif
-    getTok(p)
-  parMessage(p, errXExpected, "#endif")
-  
-proc parseIfdef(p: var TParser): PNode = 
-  getTok(p) # skip #ifdef
-  expectIdent(p)
-  case p.tok.s
-  of "__cplusplus":
-    skipUntilEndif(p)
-    result = ast.emptyNode
-  of c2nimSymbol:
-    skipLine(p)
-    result = parseStmtList(p)
-    skipUntilEndif(p)
-  else:
-    result = newNodeP(nkWhenStmt, p)
-    addSon(result, newNodeP(nkElifBranch, p))
-    addSon(result.sons[0], definedExprAux(p))
-    eatNewLine(p, nil)
-    parseIfDirAux(p, result)
-  
-proc parseIfndef(p: var TParser): PNode = 
-  result = ast.emptyNode
-  getTok(p) # skip #ifndef
-  expectIdent(p)
-  if p.tok.s == c2nimSymbol: 
-    skipLine(p)
-    case skipUntilElifElseEndif(p)
-    of emElif:
-      result = newNodeP(nkWhenStmt, p)
-      addSon(result, newNodeP(nkElifBranch, p))
-      getTok(p)
-      addSon(result.sons[0], expression(p))
-      eatNewLine(p, nil)
-      parseIfDirAux(p, result)
-    of emElse:
-      skipLine(p)
-      result = parseStmtList(p)
-      eatEndif(p)
-    of emEndif: skipLine(p)
-  else:
-    result = newNodeP(nkWhenStmt, p)
-    addSon(result, newNodeP(nkElifBranch, p))
-    var e = newNodeP(nkCall, p)
-    addSon(e, newIdentNodeP("not", p))
-    addSon(e, definedExprAux(p))
-    eatNewLine(p, nil)
-    addSon(result.sons[0], e)
-    parseIfDirAux(p, result)
-  
-proc parseIfDir(p: var TParser): PNode = 
-  result = newNodeP(nkWhenStmt, p)
-  addSon(result, newNodeP(nkElifBranch, p))
-  getTok(p)
-  addSon(result.sons[0], expression(p))
-  eatNewLine(p, nil)
-  parseIfDirAux(p, result)
-
-proc parsePegLit(p: var TParser): TPeg =
-  var col = getColumn(p.lex) + 2
-  getTok(p)
-  if p.tok.xkind != pxStrLit: expectIdent(p)
-  try:
-    result = parsePeg(
-      pattern = if p.tok.xkind == pxStrLit: p.tok.s else: escapePeg(p.tok.s), 
-      filename = p.lex.fileIdx.toFilename, 
-      line = p.lex.linenumber, 
-      col = col)
-    getTok(p)
-  except EInvalidPeg:
-    parMessage(p, errUser, getCurrentExceptionMsg())
-
-proc parseMangleDir(p: var TParser) = 
-  var pattern = parsePegLit(p)
-  if p.tok.xkind != pxStrLit: expectIdent(p)
-  p.options.mangleRules.add((pattern, p.tok.s))
-  getTok(p)
-  eatNewLine(p, nil)
-
-proc modulePragmas(p: var TParser): PNode = 
-  if p.options.dynlibSym.len > 0 and not p.hasDeadCodeElimPragma:
-    p.hasDeadCodeElimPragma = true
-    result = newNodeP(nkPragma, p)
-    var e = newNodeP(nkExprColonExpr, p)
-    addSon(e, newIdentNodeP("deadCodeElim", p), newIdentNodeP("on", p))
-    addSon(result, e)
-  else:
-    result = ast.emptyNode
-
-proc parseDir(p: var TParser): PNode = 
-  result = ast.emptyNode
-  assert(p.tok.xkind in {pxDirective, pxDirectiveParLe})
-  case p.tok.s
-  of "define": result = parseDefine(p)
-  of "include": result = parseInclude(p)
-  of "ifdef": result = parseIfdef(p)
-  of "ifndef": result = parseIfndef(p)
-  of "if": result = parseIfDir(p)
-  of "cdecl", "stdcall", "ref", "skipinclude", "typeprefixes", "skipcomments": 
-    discard setOption(p.options, p.tok.s)
-    getTok(p)
-    eatNewLine(p, nil)
-  of "dynlib", "header", "prefix", "suffix", "class": 
-    var key = p.tok.s
-    getTok(p)
-    if p.tok.xkind != pxStrLit: expectIdent(p)
-    discard setOption(p.options, key, p.tok.s)
-    getTok(p)
-    eatNewLine(p, nil)
-    result = modulePragmas(p)
-  of "mangle":
-    parseMangleDir(p)
-  of "def":
-    var L = p.options.macros.len
-    setLen(p.options.macros, L+1)
-    parseDef(p, p.options.macros[L])
-  of "private":
-    var pattern = parsePegLit(p)
-    p.options.privateRules.add(pattern)
-    eatNewLine(p, nil)
-  else: 
-    # ignore unimportant/unknown directive ("undef", "pragma", "error")
-    skipLine(p)
-
diff --git a/compiler/c2nim/nimrod.cfg b/compiler/c2nim/nimrod.cfg
deleted file mode 100644
index cfeda63ed..000000000
--- a/compiler/c2nim/nimrod.cfg
+++ /dev/null
@@ -1,4 +0,0 @@
-# Use the modules of the compiler
-
-path: "$nimrod/compiler"
-
diff --git a/compiler/c2nim/tests/matrix.h b/compiler/c2nim/tests/matrix.h
deleted file mode 100644
index 715e9e43b..000000000
--- a/compiler/c2nim/tests/matrix.h
+++ /dev/null
@@ -1,240 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////

-// Name:         wx/matrix.h

-// Purpose:      wxTransformMatrix class. NOT YET USED

-// Author:       Chris Breeze, Julian Smart

-// Modified by:  Klaas Holwerda

-// Created:      01/02/97

-// RCS-ID:       $Id$

-// Copyright:    (c) Julian Smart, Chris Breeze

-// Licence:      wxWindows licence

-/////////////////////////////////////////////////////////////////////////////

-

-#ifndef _WX_MATRIXH__

-#define _WX_MATRIXH__

-

-//! headerfiles="matrix.h wx/object.h"

-#include "wx/object.h"

-#include "wx/math.h"

-

-//! codefiles="matrix.cpp"

-

-// A simple 3x3 matrix. This may be replaced by a more general matrix

-// class some day.

-//

-// Note: this is intended to be used in wxDC at some point to replace

-// the current system of scaling/translation. It is not yet used.

-
-#def WXDLLIMPEXP_CORE
-#header "wxmatrix.h"
-

-//:definition

-//  A 3x3 matrix to do 2D transformations.

-//  It can be used to map data to window coordinates,

-//  and also for manipulating your own data.

-//  For example drawing a picture (composed of several primitives)

-//  at a certain coordinate and angle within another parent picture.

-//  At all times m_isIdentity is set if the matrix itself is an Identity matrix.

-//  It is used where possible to optimize calculations.

-class WXDLLIMPEXP_CORE wxTransformMatrix: public wxObject<string, string<ubyte>>

-{

-public:

-    wxTransformMatrix(void);

-    wxTransformMatrix(const wxTransformMatrix& mat);
-    
-    ~wxTransformMatrix(void);

-

-    //get the value in the matrix at col,row

-    //rows are horizontal (second index of m_matrix member)

-    //columns are vertical (first index of m_matrix member)

-    double GetValue(int col, int row) const;

-

-    //set the value in the matrix at col,row

-    //rows are horizontal (second index of m_matrix member)

-    //columns are vertical (first index of m_matrix member)

-    void SetValue(int col, int row, double value);

-

-    void operator = (const wxTransformMatrix& mat);

-    bool operator == (const wxTransformMatrix& mat) const;

-    bool operator != (const module::gah::wxTransformMatrix& mat) const;

-

-    //multiply every element by t

-    wxTransformMatrix&          operator*=(const double& t);

-    //divide every element by t

-    wxTransformMatrix&          operator/=(const double& t);

-    //add matrix m to this t

-    wxTransformMatrix&          operator+=(const wxTransformMatrix& m);

-    //subtract matrix m from this

-    wxTransformMatrix&          operator-=(const wxTransformMatrix& m);

-    //multiply matrix m with this

-    wxTransformMatrix&          operator*=(const wxTransformMatrix& m);

-

-    // constant operators

-

-    //multiply every element by t  and return result

-    wxTransformMatrix           operator*(const double& t) const;

-    //divide this matrix by t and return result

-    wxTransformMatrix           operator/(const double& t) const;

-    //add matrix m to this and return result

-    wxTransformMatrix           operator+(const wxTransformMatrix& m) const;

-    //subtract matrix m from this and return result

-    wxTransformMatrix           operator-(const wxTransformMatrix& m) const;

-    //multiply this by matrix m and return result

-    wxTransformMatrix           operator*(const wxTransformMatrix& m) const;

-    wxTransformMatrix           operator-() const;

-

-    //rows are horizontal (second index of m_matrix member)

-    //columns are vertical (first index of m_matrix member)

-    double& operator()(int col, int row);

-

-    //rows are horizontal (second index of m_matrix member)

-    //columns are vertical (first index of m_matrix member)

-    double operator()(int col, int row) const;

-

-    // Invert matrix

-    bool Invert(void);

-

-    // Make into identity matrix

-    bool Identity(void);

-

-    // Is the matrix the identity matrix?

-    // Only returns a flag, which is set whenever an operation

-    // is done.

-    inline bool IsIdentity(void) const { return m_isIdentity; }

-

-    // This does an actual check.

-    inline bool IsIdentity1(void) const ;

-

-    //Scale by scale (isotropic scaling i.e. the same in x and y):

-    //!ex:

-    //!code:           | scale  0      0      |

-    //!code: matrix' = |  0     scale  0      | x matrix

-    //!code:           |  0     0      scale  |

-    bool Scale(double scale);

-

-    //Scale with center point and x/y scale

-    //

-    //!ex:

-    //!code:           |  xs    0      xc(1-xs) |

-    //!code: matrix' = |  0    ys      yc(1-ys) | x matrix

-    //!code:           |  0     0      1        |

-    wxTransformMatrix&  Scale(const double &xs, const double &ys,const double &xc, const double &yc);

-

-    // mirror a matrix in x, y

-    //!ex:

-    //!code:           | -1     0      0 |

-    //!code: matrix' = |  0    -1      0 | x matrix

-    //!code:           |  0     0      1 |

-    wxTransformMatrix<float>&  Mirror(bool x=true, bool y=false);

-    // Translate by dx, dy:

-    //!ex:

-    //!code:           | 1  0 dx |

-    //!code: matrix' = | 0  1 dy | x matrix

-    //!code:           | 0  0  1 |

-    bool Translate(double x, double y);

-

-    // Rotate clockwise by the given number of degrees:

-    //!ex:

-    //!code:           |  cos sin 0 |

-    //!code: matrix' = | -sin cos 0 | x matrix

-    //!code:           |   0   0  1 |

-    bool Rotate(double angle);

-

-    //Rotate counter clockwise with point of rotation

-    //

-    //!ex:

-    //!code:           |  cos(r) -sin(r)    x(1-cos(r))+y(sin(r)|

-    //!code: matrix' = |  sin(r)  cos(r)    y(1-cos(r))-x(sin(r)| x matrix

-    //!code:           |   0          0                       1 |

-    wxTransformMatrix&  Rotate(const double &r, const double &x, const double &y);

-

-    // Transform X value from logical to device

-    inline double TransformX(double x) const;

-

-    // Transform Y value from logical to device

-    inline double TransformY(double y) const;

-

-    // Transform a point from logical to device coordinates

-    bool TransformPoint(double x, double y, double& tx, double& ty) const;

-

-    // Transform a point from device to logical coordinates.

-    // Example of use:

-    //   wxTransformMatrix mat = dc.GetTransformation();

-    //   mat.Invert();

-    //   mat.InverseTransformPoint(x, y, x1, y1);

-    // OR (shorthand:)

-    //   dc.LogicalToDevice(x, y, x1, y1);

-    // The latter is slightly less efficient if we're doing several

-    // conversions, since the matrix is inverted several times.

-    // N.B. 'this' matrix is the inverse at this point

-    bool InverseTransformPoint(double x, double y, double& tx, double& ty) const;

-

-    double Get_scaleX();

-    double Get_scaleY();

-    double GetRotation();

-    void   SetRotation(double rotation);

-

-

-public:

-    double  m_matrix[3][3];

-    bool    m_isIdentity;

-};

-

-

-/*

-Chris Breeze reported, that

-some functions of wxTransformMatrix cannot work because it is not

-known if he matrix has been inverted. Be careful when using it.

-*/

-

-// Transform X value from logical to device

-// warning: this function can only be used for this purpose

-// because no rotation is involved when mapping logical to device coordinates

-// mirror and scaling for x and y will be part of the matrix

-// if you have a matrix that is rotated, eg a shape containing a matrix to place

-// it in the logical coordinate system, use TransformPoint

-inline double wxTransformMatrix::TransformX(double x) const

-{

-    //normally like this, but since no rotation is involved (only mirror and scale)

-    //we can do without Y -> m_matrix[1]{0] is -sin(rotation angle) and therefore zero

-    //(x * m_matrix[0][0] + y * m_matrix[1][0] + m_matrix[2][0]))

-    return (m_isIdentity ? x : (x * m_matrix[0][0] +  m_matrix[2][0]));

-}

-

-// Transform Y value from logical to device

-// warning: this function can only be used for this purpose

-// because no rotation is involved when mapping logical to device coordinates

-// mirror and scaling for x and y will be part of the matrix

-// if you have a matrix that is rotated, eg a shape containing a matrix to place

-// it in the logical coordinate system, use TransformPoint

-inline double wxTransformMatrix::TransformY(double y) const

-{

-    //normally like this, but since no rotation is involved (only mirror and scale)

-    //we can do without X -> m_matrix[0]{1] is sin(rotation angle) and therefore zero

-    //(x * m_matrix[0][1] + y * m_matrix[1][1] + m_matrix[2][1]))

-    return (m_isIdentity ? y : (y * m_matrix[1][1] + m_matrix[2][1]));

-}

-

-

-// Is the matrix the identity matrix?

-// Each operation checks whether the result is still the identity matrix and sets a flag.

-inline bool wxTransformMatrix::IsIdentity1(void) const

-{

-    return

-    ( wxIsSameDouble(m_matrix[0][0], 1.0) &&

-      wxIsSameDouble(m_matrix[1][1], 1.0) &&

-      wxIsSameDouble(m_matrix[2][2], 1.0) &&

-      wxIsSameDouble(m_matrix[1][0], 0.0) &&

-      wxIsSameDouble(m_matrix[2][0], 0.0) &&

-      wxIsSameDouble(m_matrix[0][1], 0.0) &&

-      wxIsSameDouble(m_matrix[2][1], 0.0) &&

-      wxIsSameDouble(m_matrix[0][2], 0.0) &&

-      wxIsSameDouble(m_matrix[1][2], 0.0) );

-}

-

-// Calculates the determinant of a 2 x 2 matrix

-inline double wxCalculateDet(double a11, double a21, double a12, double a22)

-{

-    return a11 * a22 - a12 * a21;

-}
-

-#endif // _WX_MATRIXH__

diff --git a/compiler/c2nim/tests/systest.c b/compiler/c2nim/tests/systest.c
deleted file mode 100644
index 51509e253..000000000
--- a/compiler/c2nim/tests/systest.c
+++ /dev/null
@@ -1,622 +0,0 @@
-/* This file has been written by Blablub.
- *
- * Another comment line.
- */
-
-#ifdef __cplusplus
-#  ifdef __SOME_OTHER_CRAP
-extern "C" {
-#  endif
-#endif
-
-#define interrupts() sei()
-
-enum
-{
-/* 8bit, color or not */
-    CV_LOAD_IMAGE_UNCHANGED  =-1,
-/* 8bit, gray */
-    CV_LOAD_IMAGE_GRAYSCALE  =0,
-/* ?, color */
-    CV_LOAD_IMAGE_COLOR      =1,
-/* any depth, ? */
-    CV_LOAD_IMAGE_ANYDEPTH   =2,
-/* ?, any color */
-    CV_LOAD_IMAGE_ANYCOLOR   =4
-};
-
-typedef void (*callback_t) (int rc);
-typedef const char* (*callback2)(int rc, long L, const char* buffer);
-
-int   aw_callback_set (AW_CALLBACK c, callback_t callback );
-int   aw_instance_callback_set (AW_CALLBACK c, callback_t callback);
-
-unsigned long int wawa;
-
-#define MAX(x, y) ((x) < (y)? (y) : (x))
-
-#define AW_BUILD 85 // AW 5.0
-// Limits
-#define AW_MAX_AVCHANGE_PER_SECOND 10
-
-#private expatDll
-
-#if !defined(expatDll)
-#  if defined(windows)
-#    define expatDll "expat.dll"
-#  elif defined(macosx)
-#    define expatDll "libexpat.dynlib"
-#  else
-#    define expatDll "libexpat.so(.1|)"
-#  endif
-#endif
-
-#mangle "'XML_'{.*}" "$1"
-#private "'XML_ParserStruct'"
-
-#mangle cuint cint
-
-unsigned int uiVar;
-
-#private "@('_'!.)"
-unsigned int myPrivateVar__;
-
-
-struct XML_ParserStruct;
-
-#def XMLCALL __cdecl
-
-typedef void (XMLCALL *XML_ElementDeclHandler) (void *userData,
-                                                const XML_Char *name,
-                                                XML_Content *model);
-
-
-void* x;
-void* fn(void);
-void (*fn)(void);
-void* (*fn)(void);
-void* (*fn)(void*);
-
-/*
- * Very ugly real world code ahead:
- */
-
-#def JMETHOD(rettype, name, params) rettype (*name) params
-
-typedef struct cjpeg_source_struct * cjpeg_source_ptr;
-
-struct cjpeg_source_struct {
-  JMETHOD(void, start_input, (j_compress_ptr cinfo,
-			      cjpeg_source_ptr sinfo));
-  JMETHOD(JDIMENSION, get_pixel_rows, (j_compress_ptr cinfo,
-				       cjpeg_source_ptr sinfo));
-  JMETHOD(void, finish_input, (j_compress_ptr cinfo,
-			       cjpeg_source_ptr sinfo));
-
-  FILE *input_file;
-
-  JSAMPARRAY buffer;
-  JDIMENSION buffer_height;
-};
-
-// Test standalone structs: 
-
-union myunion {
-  char x, y, *z;
-  myint a, b;  
-} u;
-
-struct mystruct {
-  char x, y, *z;
-  myint a, b;
-}; 
-
-struct mystruct fn(i32 x, i64 y);
-
-struct mystruct {
-  char x, y, *z;
-  myint a, b;
-} *myvar = NULL, **myvar2 = NULL; 
-
-// anonymous struct: 
-
-struct {
-  char x, y, *z;
-  myint a, b;  
-} varX, **varY;
-
-// empty anonymous struct: 
-
-struct {
-
-} varX, **varY;
-
-// Test C2NIM skipping:
-
-#define MASK(x) ((x) & 0xff)
-#define CAST1(x) ((int) &x)
-#define CAST2(x) (typ*) &x
-#define CAST3(x) ((const unsigned char**) &x)
-
-#ifndef C2NIM 
-  #if someNestedCond
-    This is an invalid text that should generate a parser error, if not 
-  #endif
-    skipped correctly.
-#endif
-
-#ifndef C2NIM
-  #if someNestedCond
-    This is an invalid text that should generate a parser error, if not 
-  #endif
-    skipped correctly.
-#else
-typedef char gchar;
-typedef unsigned int gunsignedint;
-typedef unsigned char guchar;
-#endif
-
-#ifdef C2NIM
-# mangle "'those'" "these"
-int those;
-#elif abc
-  #if someNestedCond
-    This is an invalid text that should generate a parser error, if not 
-  #else
-    skipped correctly.
-  #endif
-#else
-  Another crappy input line.
-#endif
-
-point* newPoint(void) {  
-  for (int i = 0; i < 89; ++i) echo("test" " string "  "concatenation");
-  for (; j < 54; j++) {}
-  for (;; j--) ;
-  for (;;) {}
-  mytype * x = y * z;
- 
-  if (**p == ' ') {
-    --p;
-  } else if (**p == '\t') {
-    p += 3;
-  } else { 
-    p = 45 + (mytype*)45;
-    p = 45 + ((mytype*)45);
-    p = 45 + ((mytype)45);
-    // BUG: This does not parse:
-    // p = 45 + (mytype)45;
-  }
-
-  while (x >= 6 && x <= 20) 
-    --x;
-  
-  switch (*p) {
-    case 'A'...'Z':
-    case 'a'...'z':
-      ++p;
-      break;
-    case '0':
-      ++p;
-      break;
-    default:
-      return NULL;
-  }
-}
-
-enum {
-  a1, a2 = 4, a3
-};
-
-typedef enum crazyTAG {
-  x1, x2, x3 = 8, x4, x5
-} myEnum, *pMyEnum;
-
-typedef enum {
-  x1, x2, x3 = 8, x4, x5
-} myEnum, *pMyEnum;
-
-// Test multi-line macro: 
-
-#define MUILTILINE "abc" \ 
-  "xyz" \
-  "def"
-
-#define MULTILINE(x, y) do { \
-  ++y; ++x; \
-} while (0)
-
-#ifdef C2NIM
-#  dynlib iupdll
-#  cdecl
-#  mangle "'GTK_'{.*}" "TGtk$1"
-#  mangle "'PGTK_'{.*}" "PGtk$1"
-#  if defined(windows)
-#    define iupdll "iup.dll"
-#  elif defined(macosx)
-#    define iupdll "libiup.dynlib"
-#  else
-#    define iupdll "libiup.so"
-#  endif
-#endif
-
-typedef struct stupidTAG {
-  mytype a, b;
-} GTK_MyStruct, *PGTK_MyStruct;
-
-typedef struct  {
-  mytype a, b;
-} GTK_MyStruct, *PGTK_MyStruct;
-
-int IupConvertXYToPos(PIhandle ih, int x, int y);
-
-#ifdef DEBUG
-#  define OUT(x) printf("%s\n", x)
-#else
-#  define OUT(x)
-#endif
-
-
-  #ifdef C2NIM
-  #  def EXTERN(x) static x
-  #  def TWO_ARGS(x, y) x* y
-  #endif
-  // parses now!
-  EXTERN(int) f(void);
-  EXTERN(int) g(void);
-
-
-  #def EXPORT
-  // does parse now!
-  EXPORT int f(void);
-  EXPORT int g(void); 
-
-  static TWO_ARGS(int, x) = TWO_ARGS(56, 45);
-
-
-#  define abc 34
-#  define xyz 42
-
-#  define wuseldusel "my string\nconstant"
-
-#undef ignoreThis
-
-char* x;
-
-typedef struct {
-  char x, y, *z;
-} point;
-
-char* __stdcall printf(char* frmt, const char* const** ptrToStrArray,
-             const int* const dummy, ...);
-
-inline char* myinlineProc(char* frmt, const char* const* strArray,
-             const int* const dummy, ...);
-
-// Test void parameter list:
-void myVoidProc(void);
-
-void emptyReturn(void) { return; }
-
-// POSIX stuff:
-
-#ifdef C2NIM
-#prefix posix_
-int c2nimBranch;
-#elif defined(MACOSX)
-int* x, y, z;
-#else
-int dummy;
-#endif
-
-#ifndef C2NIM
-int dontTranslateThis;
-#elif defined(Windows)
-int WindowsTrue = true;
-#endif
-
-int   posix_spawn(pid_t *restrict, const char *restrict,
-          const posix_spawn_file_actions_t *,
-          const posix_spawnattr_t *restrict, char *const [restrict],
-          char *const [restrict]);
-int   posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *,
-          int);
-int   posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *,
-          int, int);
-int   posix_spawn_file_actions_addopen(posix_spawn_file_actions_t *restrict,
-          int, const char *restrict, int, mode_t);
-int   posix_spawn_file_actions_destroy(posix_spawn_file_actions_t *);
-int   posix_spawn_file_actions_init(posix_spawn_file_actions_t *);
-int   posix_spawnattr_destroy(posix_spawnattr_t *);
-int   posix_spawnattr_getsigdefault(const posix_spawnattr_t *restrict,
-          sigset_t *restrict);
-int   posix_spawnattr_getflags(const posix_spawnattr_t *restrict,
-          short *restrict);
-int   posix_spawnattr_getpgroup(const posix_spawnattr_t *restrict,
-          pid_t *restrict);
-int   posix_spawnattr_getschedparam(const posix_spawnattr_t *restrict,
-          struct sched_param *restrict);
-int   posix_spawnattr_getschedpolicy(const posix_spawnattr_t *restrict,
-          int *restrict);
-int   posix_spawnattr_getsigmask(const posix_spawnattr_t *restrict,
-          sigset_t *restrict);
-int   posix_spawnattr_init(posix_spawnattr_t *);
-int   posix_spawnattr_setsigdefault(posix_spawnattr_t *restrict,
-          const sigset_t *restrict);
-int   posix_spawnattr_setflags(posix_spawnattr_t *, short);
-int   posix_spawnattr_setpgroup(posix_spawnattr_t *, pid_t);
-
-
-int   posix_spawnattr_setschedparam(posix_spawnattr_t *restrict,
-          const struct sched_param *restrict);
-int   posix_spawnattr_setschedpolicy(posix_spawnattr_t *, int);
-int   posix_spawnattr_setsigmask(posix_spawnattr_t *restrict,
-          const sigset_t *restrict);
-int   posix_spawnp(pid_t *restrict, const char *restrict,
-          const posix_spawn_file_actions_t *,
-          const posix_spawnattr_t *restrict,
-          char *const [restrict], char *const [restrict]);
-
-typedef struct
-{
-  float R, G, B;
-}
-RGBType;
-typedef struct
-{
-  float H, W, B;
-}
-HWBType;
-
-static HWBType *
-RGB_to_HWB (RGBType RGB, HWBType * HWB)
-{
-  HWBType* myArray[20];
-  /*
-   * RGB are each on [0, 1]. W and B are returned on [0, 1] and H is  
-   * returned on [0, 6]. Exception: H is returned UNDEFINED if W == 1 - B.  
-   */
-
-  float R = RGB.R, G = RGB.G, B = RGB.B, w, v, b, f;
-  int i;
-
-  w = MIN3 (R, G, B);
-  v = MAX3 (R, G, B);
-  b &= 1 - v;
-  if (v == w)
-    RETURN_HWB (HWB_UNDEFINED, w, b);
-  f = (R == w) ? G - B : ((G == w) ? B - R : R - G);
-  i = (R == w) ? 3 : ((G == w) ? 5 : 1);
-  RETURN_HWB (i - f / (v - w), w, b);
-
-}
-
-static int
-clip_1d (int *x0, int *y0, int *x1, int *y1, int mindim, int maxdim)
-{
-  double m;                        // gradient of line
-  if (*x0 < mindim)
-    {                                // start of line is left of window 
-      if (*x1 < mindim) // as is the end, so the line never cuts the window 
-        return 0;
-      m = (*y1 - *y0) / (double) (*x1 - *x0); // calculate the slope of the line
-      // adjust x0 to be on the left boundary (ie to be zero), and y0 to match 
-      *y0 -= m * (*x0 - mindim);
-      *x0 = mindim;
-      // now, perhaps, adjust the far end of the line as well
-      if (*x1 > maxdim)
-        {
-          *y1 += m * (maxdim - *x1);
-          *x1 = maxdim;
-        }
-      return 1;
-    }
-  if (*x0 > maxdim)
-    { // start of line is right of window - complement of above 
-      if (*x1 > maxdim) // as is the end, so the line misses the window 
-        return 0;
-      m = (*y1 - *y0) / (double) (*x1 - *x0); // calculate the slope of the line
-      *y0 += m * (maxdim - *x0);        // adjust so point is on the right
-                                        // boundary
-      *x0 = maxdim;
-      // now, perhaps, adjust the end of the line
-      if (*x1 < mindim)
-        {
-          *y1 -= m * (*x1 - mindim);
-          *x1 = mindim;
-        }
-      return 1;
-    }
-  // the final case - the start of the line is inside the window
-  if (*x1 > maxdim)
-    {                                // other end is outside to the right
-      m = (*y1 - *y0) / (double) (*x1 - *x0); // calculate the slope of the line 
-      *y1 += m * (maxdim - *x1);
-      *x1 = maxdim;
-      return 1;
-    }
-  if (*x1 < mindim)
-    {                                // other end is outside to the left 
-      m = (*y1 - *y0) / (double) (*x1 - *x0); // calculate the slope of line 
-             *y1 -= m * (*x1 - mindim);
-      *x1 = mindim;
-      return 1;
-    }
-  // only get here if both points are inside the window
-  return 1;
-}
-
-// end of line clipping code
-
-static void
-gdImageBrushApply (gdImagePtr im, int x, int y)
-{
-  int lx, ly;
-  int hy;
-  int hx;
-  int x1, y1, x2, y2;
-  int srcx, srcy;
-  if (!im->brush)
-    {
-      return;
-    }
-  hy = gdImageSY (im->brush) / 2;
-  y1 = y - hy;
-  y2 = y1 + gdImageSY (im->brush);
-  hx = gdImageSX (im->brush) / 2;
-  x1 = x - hx;
-  x2 = x1 + gdImageSX (im->brush);
-  srcy = 0;
-  if (im->trueColor)
-    {
-      if (im->brush->trueColor)
-        {
-          for (ly = y1; (ly < y2); ly++)
-            {
-              srcx = 0;
-              for (lx = x1; (lx < x2); lx++)
-                {
-                  int p;
-                  p = gdImageGetTrueColorPixel (im->brush, srcx, srcy);
-                  // 2.0.9, Thomas Winzig: apply simple full transparency
-                  if (p != gdImageGetTransparent (im->brush))
-                    {
-                      gdImageSetPixel (im, lx, ly, p);
-                    }
-                  srcx++;
-                }
-              srcy++;
-            }
-        }
-      else
-        {
-          // 2.0.12: Brush palette, image truecolor (thanks to Thorben Kundinger
-          // for pointing out the issue)
-          for (ly = y1; (ly < y2); ly++)
-            {
-              srcx = 0;
-              for (lx = x1; (lx < x2); lx++)
-                {
-                  int p, tc;
-                  p = gdImageGetPixel (im->brush, srcx, srcy);
-                  tc = gdImageGetTrueColorPixel (im->brush, srcx, srcy);
-                  // 2.0.9, Thomas Winzig: apply simple full transparency 
-                  if (p != gdImageGetTransparent (im->brush))
-                    {
-                      gdImageSetPixel (im, lx, ly, tc);
-                    }
-                  srcx++;
-                }
-              srcy++;
-            }
-        }
-    }
-  else
-    {
-      for (ly = y1; (ly < y2); ly++)
-        {
-          srcx = 0;
-          for (lx = x1; (lx < x2); lx++)
-            {
-              int p;
-              p = gdImageGetPixel (im->brush, srcx, srcy);
-              // Allow for non-square brushes!
-              if (p != gdImageGetTransparent (im->brush))
-                {
-                  // Truecolor brush. Very slow
-                  // on a palette destination.
-                  if (im->brush->trueColor)
-                    {
-                      gdImageSetPixel (im, lx, ly,
-                                       gdImageColorResolveAlpha(im,
-                                       gdTrueColorGetRed(p),
-                                       gdTrueColorGetGreen(p),
-                                       gdTrueColorGetBlue(p),
-                                       gdTrueColorGetAlpha(p)));
-                    }
-                  else
-                    {
-                      gdImageSetPixel (im, lx, ly, im->brushColorMap[p]);
-                    }
-                }
-              srcx++;
-            }
-          srcy++;
-        }
-    } 
-}
-
-
-void gdImageSetPixel (gdImagePtr im, int x, int y, int color)
-{
-  int p;
-  switch (color)
-    {
-    case gdStyled:
-      if (!im->style)
-        {
-          // Refuse to draw if no style is set.
-          return;
-        }
-      else
-        {
-          p = im->style[im->stylePos++];
-        }
-      if (p != (gdTransparent))
-        {
-          gdImageSetPixel (im, x, y, p);
-        }
-      im->stylePos = im->stylePos % im->styleLength;
-      break;
-    case gdStyledBrushed:
-      if (!im->style)
-        {
-          // Refuse to draw if no style is set.
-          return;
-        }
-      p = im->style[im->stylePos++];
-      if ((p != gdTransparent) && (p != 0))
-        {
-          gdImageSetPixel (im, x, y, gdBrushed);
-        }
-      im->stylePos = im->stylePos % im->styleLength;
-      break;
-    case gdBrushed:
-      gdImageBrushApply (im, x, y);
-      break;
-    case gdTiled:
-      gdImageTileApply (im, x, y);
-      break;
-    case gdAntiAliased:
-      // This shouldn't happen (2.0.26) because we just call
-      // gdImageAALine now, but do something sane.
-      gdImageSetPixel(im, x, y, im->AA_color);
-      break;
-    default:
-      if (gdImageBoundsSafeMacro (im, x, y))
-        {
-          if (im->trueColor)
-            {
-              if (im->alphaBlendingFlag)
-                {
-                  im->tpixels[y][x] = gdAlphaBlend (im->tpixels[y][x], color);
-                }
-              else
-                {
-                  im->tpixels[y][x] = color;
-                }
-            }
-          else
-            {
-              im->pixels[y][x] = color;
-            }
-        }
-      break;
-    }
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-
diff --git a/compiler/c2nim/tests/systest2.c b/compiler/c2nim/tests/systest2.c
deleted file mode 100644
index bf3027cfc..000000000
--- a/compiler/c2nim/tests/systest2.c
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifdef C2NIM
-#  header "iup.h"
-#  cdecl
-#  mangle "'GTK_'{.*}" "TGtk$1"
-#  mangle "'PGTK_'{.*}" "PGtk$1"
-#endif
-
-typedef struct stupidTAG {
-  mytype a, b;
-} GTK_MyStruct, *PGTK_MyStruct;
-
-typedef struct  {
-  mytype a, b;
-} GTK_MyStruct, *PGTK_MyStruct;
-
-int IupConvertXYToPos(PIhandle ih, int x, int y);
-
diff --git a/compiler/c2nim/tests/vincent.c b/compiler/c2nim/tests/vincent.c
deleted file mode 100644
index 24c6d6425..000000000
--- a/compiler/c2nim/tests/vincent.c
+++ /dev/null
@@ -1,33 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-
-int rand(void);
-
-int id2(void) {
-    return (int *)1;
-}
-
-int id(void (*f)(void)) {
-    f();
-    ((void (*)(int))f)(10);
-    return 10;
-    return (20+1);
-    return (int *)id;
-}
-
-int main() {
-    float f = .2,
-          g = 2.,
-          h = 1.0+rand(),
-          i = 1.0e+3;
-    int j, a;
-    for(j = 0, a = 10; j < 0; j++, a++) ;
-    do {
-        printf("howdy");
-    } while(--i, 0);
-    if(1)
-        printf("1"); // error from this comment
-    else
-        printf("2");
-    return '\x00';
-}
diff --git a/compiler/c2nim/tests/vincent.h b/compiler/c2nim/tests/vincent.h
deleted file mode 100644
index b4e761ee1..000000000
--- a/compiler/c2nim/tests/vincent.h
+++ /dev/null
@@ -1,3 +0,0 @@
-struct foo {
-    int x,y,z;
-};
diff --git a/compiler/ccgcalls.nim b/compiler/ccgcalls.nim
index a7840305d..71e23aa1d 100644
--- a/compiler/ccgcalls.nim
+++ b/compiler/ccgcalls.nim
@@ -86,7 +86,7 @@ proc openArrayLoc(p: BProc, n: PNode): PRope =
     initLocExpr(p, q[2], b)
     initLocExpr(p, q[3], c)
     let fmt =
-      case skipTypes(a.t, abstractVar).kind
+      case skipTypes(a.t, abstractVar+{tyPtr}).kind
       of tyOpenArray, tyVarargs, tyArray, tyArrayConstr:
         "($1)+($2), ($3)-($2)+1"
       of tyString, tySequence:
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim
index 94a6f4781..4698082f1 100644
--- a/compiler/ccgexprs.nim
+++ b/compiler/ccgexprs.nim
@@ -484,7 +484,7 @@ proc unaryArithOverflow(p: BProc, e: PNode, d: var TLoc, m: TMagic) =
     opr: array[mUnaryMinusI..mAbsI64, string] = [
       mUnaryMinusI: "((NI$2)-($1))",
       mUnaryMinusI64: "-($1)",
-      mAbsI: "(NI$2)abs($1)",
+      mAbsI: "($1 > 0? ($1) : -($1))",
       mAbsI64: "($1 > 0? ($1) : -($1))"]
   var
     a: TLoc
@@ -714,11 +714,12 @@ proc genFieldCheck(p: BProc, e: PNode, obj: PRope, field: PSym) =
     assert(it.sons[0].kind == nkSym)
     let op = it.sons[0].sym
     if op.magic == mNot: it = it.sons[1]
-    assert(it.sons[2].kind == nkSym)
+    let disc = it.sons[2].skipConv
+    assert(disc.kind == nkSym)
     initLoc(test, locNone, it.typ, OnStack)
     initLocExpr(p, it.sons[1], u)
-    initLoc(v, locExpr, it.sons[2].typ, OnUnknown)
-    v.r = ropef("$1.$2", [obj, it.sons[2].sym.loc.r])
+    initLoc(v, locExpr, disc.typ, OnUnknown)
+    v.r = ropef("$1.$2", [obj, disc.sym.loc.r])
     genInExprAux(p, it, u, v, test)
     let id = nodeTableTestOrSet(p.module.dataCache,
                                newStrNode(nkStrLit, field.name.s), gBackendId)
@@ -1144,6 +1145,24 @@ proc genNewFinalize(p: BProc, e: PNode) =
   genObjectInit(p, cpsStmts, bt, a, false)
   gcUsage(e)
 
+proc genOfHelper(p: BProc; dest: PType; a: PRope): PRope =
+  # unfortunately 'genTypeInfo' sets tfObjHasKids as a side effect, so we
+  # have to call it here first:
+  let ti = genTypeInfo(p.module, dest)
+  if tfFinal in dest.flags or (p.module.objHasKidsValid and
+                               tfObjHasKids notin dest.flags):
+    result = ropef("$1.m_type == $2", a, ti)
+  else:
+    discard cgsym(p.module, "TNimType")
+    inc p.module.labels
+    let cache = con("Nim_OfCheck_CACHE", p.module.labels.toRope)
+    appf(p.module.s[cfsVars], "static TNimType* $#[2];$n", cache)
+    result = rfmt(p.module, "#isObjWithCache($#.m_type, $#, $#)", a, ti, cache)
+  when false:
+    # former version:
+    result = rfmt(p.module, "#isObj($1.m_type, $2)",
+                  a, genTypeInfo(p.module, dest))
+
 proc genOf(p: BProc, x: PNode, typ: PType, d: var TLoc) =
   var a: TLoc
   initLocExpr(p, x, a)
@@ -1163,11 +1182,9 @@ proc genOf(p: BProc, x: PNode, typ: PType, d: var TLoc) =
     globalError(x.info, errGenerated, 
       "no 'of' operator available for pure objects")
   if nilCheck != nil:
-    r = rfmt(p.module, "(($1) && #isObj($2.m_type, $3))",
-             nilCheck, r, genTypeInfo(p.module, dest))
+    r = rfmt(p.module, "(($1) && ($2))", nilCheck, genOfHelper(p, dest, r))
   else:
-    r = rfmt(p.module, "#isObj($1.m_type, $2)",
-             r, genTypeInfo(p.module, dest))
+    r = rfmt(p.module, "($1)", genOfHelper(p, dest, r))
   putIntoDest(p, d, getSysType(tyBool), r)
 
 proc genOf(p: BProc, n: PNode, d: var TLoc) =
@@ -1382,10 +1399,10 @@ proc genSetOp(p: BProc, e: PNode, d: var TLoc, op: TMagic) =
     of mIncl:
       var ts = "NI" & $(size * 8)
       binaryStmtInExcl(p, e, d,
-          "$1 |=((" & ts & ")(1)<<(($2)%(sizeof(" & ts & ")*8)));$n")
+          "$1 |= ((" & ts & ")1)<<(($2)%(sizeof(" & ts & ")*8));$n")
     of mExcl:
       var ts = "NI" & $(size * 8)
-      binaryStmtInExcl(p, e, d, "$1 &= ~((" & ts & ")(1) << (($2) % (sizeof(" &
+      binaryStmtInExcl(p, e, d, "$1 &= ~(((" & ts & ")1) << (($2) % (sizeof(" &
           ts & ")*8)));$n")
     of mCard:
       if size <= 4: unaryExprChar(p, e, d, "#countBits32($1)")
@@ -1636,7 +1653,10 @@ proc genMagicExpr(p: BProc, e: PNode, d: var TLoc, op: TMagic) =
   of mSlurp..mQuoteAst:
     localError(e.info, errXMustBeCompileTime, e.sons[0].sym.name.s)
   of mSpawn:
-    let n = lowerings.wrapProcForSpawn(p.module.module, e.sons[1])
+    let n = lowerings.wrapProcForSpawn(p.module.module, e, e.typ, nil, nil)
+    expr(p, n, d)
+  of mParallel:
+    let n = semparallel.liftParallel(p.module.module, e)
     expr(p, n, d)
   else: internalError(e.info, "genMagicExpr: " & $op)
 
diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim
index 7c11d3e9a..8e762ce27 100644
--- a/compiler/ccgtypes.nim
+++ b/compiler/ccgtypes.nim
@@ -13,8 +13,8 @@
 
 proc mangleField(name: string): string =
   result = mangle(name)
-  if name[0] in 'a'..'z':
-    result[0] = name[0].toUpper
+  result[0] = result[0].toUpper # Mangling makes everything lowercase,
+                                # but some identifiers are C keywords
 
 proc isKeyword(w: PIdent): bool =
   # nimrod and C++ share some keywords
@@ -796,6 +796,11 @@ proc genObjectInfo(m: BModule, typ: PType, name: PRope) =
   var tmp = getNimNode(m)
   genObjectFields(m, typ, typ.n, tmp)
   appf(m.s[cfsTypeInit3], "$1.node = &$2;$n", [name, tmp])
+  var t = typ.sons[0]
+  while t != nil:
+    t = t.skipTypes(abstractInst)
+    t.flags.incl tfObjHasKids
+    t = t.sons[0]
 
 proc genTupleInfo(m: BModule, typ: PType, name: PRope) =
   genTypeInfoAuxBase(m, typ, name, toRope("0"))
diff --git a/compiler/ccgutils.nim b/compiler/ccgutils.nim
index 9beb08a21..04983d6a4 100644
--- a/compiler/ccgutils.nim
+++ b/compiler/ccgutils.nim
@@ -162,6 +162,9 @@ proc makeSingleLineCString*(s: string): string =
   result.add('\"')
 
 proc mangle*(name: string): string =
+  ## Lowercases the given name and manges any non-alphanumeric characters
+  ## so they are represented as `HEX____`. If the name starts with a number,
+  ## `N` is prepended
   result = ""
   case name[0]
   of Letters:
diff --git a/compiler/cgen.nim b/compiler/cgen.nim
index 8d66d7a3b..e2f3b5ab0 100644
--- a/compiler/cgen.nim
+++ b/compiler/cgen.nim
@@ -14,7 +14,8 @@ import
   options, intsets,
   nversion, nimsets, msgs, crc, bitsets, idents, lists, types, ccgutils, os,
   times, ropes, math, passes, rodread, wordrecg, treetab, cgmeth,
-  rodutils, renderer, idgen, cgendata, ccgmerge, semfold, aliases, lowerings
+  rodutils, renderer, idgen, cgendata, ccgmerge, semfold, aliases, lowerings,
+  semparallel
 
 when options.hasTinyCBackend:
   import tccgen
@@ -503,7 +504,8 @@ proc assignLocalVar(p: BProc, s: PSym) =
     if sfRegister in s.flags: app(decl, " register")
     #elif skipTypes(s.typ, abstractInst).kind in GcTypeKinds:
     #  app(decl, " GC_GUARD")
-    if sfVolatile in s.flags or p.nestedTryStmts.len > 0: 
+    if sfVolatile in s.flags or (p.nestedTryStmts.len > 0 and
+                                 gCmd != cmdCompileToCpp):
       app(decl, " volatile")
     appf(decl, " $1;$n", [s.loc.r])
   else:
@@ -1048,6 +1050,7 @@ proc getSomeInitName(m: PSym, suffix: string): PRope =
   assert m.owner.kind == skPackage
   if {sfSystemModule, sfMainModule} * m.flags == {}:
     result = m.owner.name.s.mangle.toRope
+    result.app "_"
   result.app m.name.s
   result.app suffix
   
@@ -1382,6 +1385,7 @@ proc myClose(b: PPassContext, n: PNode): PNode =
   registerModuleToMain(m.module)
 
   if sfMainModule in m.module.flags: 
+    m.objHasKidsValid = true
     var disp = generateMethodDispatchers()
     for i in 0..sonsLen(disp)-1: genProcAux(m, disp.sons[i].sym)
     genMainProc(m)
diff --git a/compiler/cgendata.nim b/compiler/cgendata.nim
index e7d818556..12041c55b 100644
--- a/compiler/cgendata.nim
+++ b/compiler/cgendata.nim
@@ -96,6 +96,7 @@ type
                               # a frame var twice in an init proc
     isHeaderFile*: bool       # C source file is the header file
     includesStringh*: bool    # C source file already includes ``<string.h>``
+    objHasKidsValid*: bool    # whether we can rely on tfObjHasKids
     cfilename*: string        # filename of the module (including path,
                               # without extension)
     typeCache*: TIdTable      # cache the generated types
diff --git a/compiler/commands.nim b/compiler/commands.nim
index 366019c19..38c8dd294 100644
--- a/compiler/commands.nim
+++ b/compiler/commands.nim
@@ -9,10 +9,34 @@
 
 # This module handles the parsing of command line arguments.
 
+
+# We do this here before the 'import' statement so 'defined' does not get
+# confused with 'TGCMode.gcGenerational' etc.
+template bootSwitch(name, expr, userString: expr): expr =
+  # Helper to build boot constants, for debugging you can 'echo' the else part.
+  const name = if expr: " " & userString else: ""
+
+bootSwitch(usedRelease, defined(release), "-d:release")
+bootSwitch(usedGnuReadline, defined(useGnuReadline), "-d:useGnuReadline")
+bootSwitch(usedNoCaas, defined(noCaas), "-d:noCaas")
+bootSwitch(usedBoehm, defined(boehmgc), "--gc:boehm")
+bootSwitch(usedMarkAndSweep, defined(gcmarkandsweep), "--gc:markAndSweep")
+bootSwitch(usedGenerational, defined(gcgenerational), "--gc:generational")
+bootSwitch(usedNoGC, defined(nogc), "--gc:none")
+
 import 
   os, msgs, options, nversion, condsyms, strutils, extccomp, platform, lists, 
   wordrecg, parseutils, babelcmd, idents
 
+# but some have deps to imported modules. Yay.
+bootSwitch(usedTinyC, hasTinyCBackend, "-d:tinyc")
+bootSwitch(usedAvoidTimeMachine, noTimeMachine, "-d:avoidTimeMachine")
+bootSwitch(usedNativeStacktrace,
+  defined(nativeStackTrace) and nativeStackTraceSupported,
+  "-d:nativeStackTrace")
+bootSwitch(usedFFI, hasFFI, "-d:useFFI")
+
+
 proc writeCommandLineUsage*()
 
 type 
@@ -50,30 +74,16 @@ proc writeAdvancedUsage(pass: TCmdLinePass) =
                                  CPU[platform.hostCPU].name]) & AdvancedUsage)
     quit(0)
 
-template bootSwitch(name, expr, userString: expr): expr =
-  # Helper to build boot constants, for debugging you can 'echo' the else part.
-  const name = if expr: " " & userString else: ""
-
-bootSwitch(usedAvoidTimeMachine, noTimeMachine, "-d:avoidTimeMachine")
-bootSwitch(usedRelease, defined(release), "-d:release")
-bootSwitch(usedTinyC, hasTinyCBackend, "-d:tinyc")
-bootSwitch(usedGnuReadline, defined(useGnuReadline), "-d:useGnuReadline")
-bootSwitch(usedNativeStacktrace,
-  defined(nativeStackTrace) and nativeStackTraceSupported,
-  "-d:nativeStackTrace")
-bootSwitch(usedNoCaas, defined(noCaas), "-d:noCaas")
-bootSwitch(usedFFI, hasFFI, "-d:useFFI")
-bootSwitch(usedBoehm, defined(boehmgc), "--gc:boehm")
-bootSwitch(usedMarkAndSweep, defined(gcmarkandsweep), "--gc:markAndSweep")
-bootSwitch(usedGenerational, defined(gcgenerational), "--gc:generational")
-bootSwitch(usedNoGC, defined(nogc), "--gc:none")
-
-
 proc writeVersionInfo(pass: TCmdLinePass) = 
   if pass == passCmd1:
     msgWriteln(`%`(HelpMessage, [VersionAsString, 
                                  platform.OS[platform.hostOS].name, 
                                  CPU[platform.hostCPU].name]))
+
+    const gitHash = gorge("git log -n 1 --format=%H")
+    if gitHash.strip.len == 40:
+      msgWriteln("git hash: " & gitHash)
+
     msgWriteln("active boot switches:" & usedRelease & usedAvoidTimeMachine &
       usedTinyC & usedGnuReadline & usedNativeStacktrace & usedNoCaas &
       usedFFI & usedBoehm & usedMarkAndSweep & usedGenerational & usedNoGC)
diff --git a/compiler/docgen.nim b/compiler/docgen.nim
index 6948c4979..4c9803401 100644
--- a/compiler/docgen.nim
+++ b/compiler/docgen.nim
@@ -541,8 +541,14 @@ proc genOutFile(d: PDoc): PRope =
   if toc != nil:
     toc = ropeFormatNamedVars(getConfigVar("doc.toc"), ["content"], [toc])
   for i in countup(low(TSymKind), high(TSymKind)): app(code, d.section[i])
-  if d.meta[metaTitle].len != 0: title = d.meta[metaTitle]
-  else: title = "Module " & extractFilename(changeFileExt(d.filename, ""))
+
+  # Extract the title. Non API modules generate an entry in the index table.
+  if d.meta[metaTitle].len != 0:
+    title = d.meta[metaTitle]
+    setIndexTerm(d[], "", title)
+  else:
+    # Modules get an automatic title for the HTML, but no entry in the index.
+    title = "Module " & extractFilename(changeFileExt(d.filename, ""))
 
   let bodyname = if d.hasToc: "doc.body_toc" else: "doc.body_no_toc"
   content = ropeFormatNamedVars(getConfigVar(bodyname), ["title",
diff --git a/compiler/evals.nim b/compiler/evals.nim
deleted file mode 100644
index 151adf690..000000000
--- a/compiler/evals.nim
+++ /dev/null
@@ -1,1502 +0,0 @@
-#
-#
-#           The Nimrod Compiler
-#        (c) Copyright 2013 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-# This file implements the evaluator for Nimrod code.
-# The evaluator is very slow, but simple. Since this
-# is used mainly for evaluating macros and some other
-# stuff at compile time, performance is not that
-# important.
-
-import 
-  strutils, magicsys, lists, options, ast, astalgo, trees, treetab, nimsets, 
-  msgs, os, condsyms, idents, renderer, types, passes, semfold, transf, 
-  parser, ropes, rodread, idgen, osproc, streams, evaltempl
-
-when hasFFI:
-  import evalffi
-
-type 
-  PStackFrame* = ref TStackFrame
-  TStackFrame* = object
-    prc: PSym                 # current prc; proc that is evaluated
-    slots: TNodeSeq           # parameters passed to the proc + locals;
-                              # parameters come first
-    call: PNode
-    next: PStackFrame         # for stacking
-  
-  TEvalMode* = enum           ## reason for evaluation
-    emRepl,                   ## evaluate because in REPL mode
-    emConst,                  ## evaluate for 'const' according to spec
-    emOptimize,               ## evaluate for optimization purposes (same as
-                              ## emConst?)
-    emStatic                  ## evaluate for enforced compile time eval
-                              ## ('static' context)
-
-  TSandboxFlag* = enum        ## what the evaluation engine should allow
-    allowCast,                ## allow unsafe language feature: 'cast'
-    allowFFI,                 ## allow the FFI
-    allowInfiniteLoops        ## allow endless loops
-  TSandboxFlags* = set[TSandboxFlag]
-
-  TEvalContext* = object of passes.TPassContext
-    module*: PSym
-    tos*: PStackFrame         # top of stack
-    lastException*: PNode
-    callsite: PNode           # for 'callsite' magic
-    mode*: TEvalMode
-    features: TSandboxFlags
-    globals*: TIdNodeTable    # state of global vars
-    getType*: proc(n: PNode): PNode {.closure.}
-    handleIsOperator*: proc(n: PNode): PNode {.closure.}
-
-  PEvalContext* = ref TEvalContext
-
-  TEvalFlag = enum 
-    efNone, efLValue
-  TEvalFlags = set[TEvalFlag]
-
-const
-  evalMaxIterations = 500_000 # max iterations of all loops
-  evalMaxRecDepth = 10_000    # max recursion depth for evaluation
-
-# other idea: use a timeout! -> Wether code compiles depends on the machine
-# the compiler runs on then! Bad idea!
-
-proc newStackFrame*(): PStackFrame =
-  new(result)
-  result.slots = @[]
-
-proc newEvalContext*(module: PSym, mode: TEvalMode): PEvalContext =
-  new(result)
-  result.module = module
-  result.mode = mode
-  result.features = {allowFFI}
-  initIdNodeTable(result.globals)
-
-proc pushStackFrame*(c: PEvalContext, t: PStackFrame) {.inline.} = 
-  t.next = c.tos
-  c.tos = t
-
-proc popStackFrame*(c: PEvalContext) {.inline.} =
-  if c.tos != nil: c.tos = c.tos.next
-  else: InternalError("popStackFrame")
-
-proc evalMacroCall*(c: PEvalContext, n, nOrig: PNode, sym: PSym): PNode
-proc evalAux(c: PEvalContext, n: PNode, flags: TEvalFlags): PNode
-
-proc raiseCannotEval(c: PEvalContext, info: TLineInfo): PNode =
-  if defined(debug) and gVerbosity >= 3: writeStackTrace()
-  result = newNodeI(nkExceptBranch, info)
-  # creating a nkExceptBranch without sons 
-  # means that it could not be evaluated
-
-proc stackTraceAux(x: PStackFrame) =
-  if x != nil:
-    stackTraceAux(x.next)
-    var info = if x.call != nil: x.call.info else: UnknownLineInfo()
-    # we now use the same format as in system/except.nim
-    var s = toFilename(info)
-    var line = toLineNumber(info)
-    if line > 0:
-      add(s, '(')
-      add(s, $line)
-      add(s, ')')
-    if x.prc != nil:
-      for k in 1..max(1, 25-s.len): add(s, ' ')
-      add(s, x.prc.name.s)
-    MsgWriteln(s)
-
-proc stackTrace(c: PEvalContext, info: TLineInfo, msg: TMsgKind, arg = "") = 
-  MsgWriteln("stack trace: (most recent call last)")
-  stackTraceAux(c.tos)
-  LocalError(info, msg, arg)
-
-template isSpecial(n: PNode): bool = n.kind == nkExceptBranch
-template bailout() {.dirty.} =
-  if isSpecial(result): return
-
-template evalX(n, flags) {.dirty.} =
-  result = evalAux(c, n, flags)
-  bailout()
-
-proc myreset(n: PNode) =
-  when defined(system.reset): 
-    var oldInfo = n.info
-    reset(n[])
-    n.info = oldInfo
-
-proc evalIf(c: PEvalContext, n: PNode): PNode = 
-  var i = 0
-  var length = sonsLen(n)
-  while (i < length) and (sonsLen(n.sons[i]) >= 2): 
-    evalX(n.sons[i].sons[0], {})
-    if result.kind == nkIntLit and result.intVal != 0:
-      return evalAux(c, n.sons[i].sons[1], {})
-    inc(i)
-  if (i < length) and (sonsLen(n.sons[i]) < 2):
-    result = evalAux(c, n.sons[i].sons[0], {})
-  else:
-    result = emptyNode
-  
-proc evalCase(c: PEvalContext, n: PNode): PNode = 
-  evalX(n.sons[0], {})
-  var res = result
-  result = emptyNode
-  for i in countup(1, sonsLen(n) - 1): 
-    if n.sons[i].kind == nkOfBranch: 
-      for j in countup(0, sonsLen(n.sons[i]) - 2): 
-        if overlap(res, n.sons[i].sons[j]): 
-          return evalAux(c, lastSon(n.sons[i]), {})
-    else: 
-      result = evalAux(c, lastSon(n.sons[i]), {})
-
-var 
-  gWhileCounter: int # Use a counter to prevent endless loops!
-                     # We make this counter global, because otherwise
-                     # nested loops could make the compiler extremely slow.
-  gNestedEvals: int  # count the recursive calls to ``evalAux`` to prevent
-                     # endless recursion
-
-proc evalWhile(c: PEvalContext, n: PNode): PNode =
-  while true:
-    evalX(n.sons[0], {})
-    if getOrdValue(result) == 0:
-      result = emptyNode; break
-    result = evalAux(c, n.sons[1], {})
-    case result.kind
-    of nkBreakStmt: 
-      if result.sons[0].kind == nkEmpty: 
-        result = emptyNode    # consume ``break`` token
-      # Bugfix (see tmacro2): but break in any case!
-      break 
-    of nkExceptBranch, nkReturnToken: break 
-    else: nil
-    dec(gWhileCounter)
-    if gWhileCounter <= 0:
-      if allowInfiniteLoops in c.features:
-        gWhileCounter = 0
-      else:
-        stackTrace(c, n.info, errTooManyIterations)
-        break
-
-proc evalBlock(c: PEvalContext, n: PNode): PNode =
-  result = evalAux(c, n.sons[1], {})
-  if result.kind == nkBreakStmt:
-    if result.sons[0] != nil: 
-      assert(result.sons[0].kind == nkSym)
-      if n.sons[0].kind != nkEmpty: 
-        assert(n.sons[0].kind == nkSym)
-        if result.sons[0].sym.id == n.sons[0].sym.id: result = emptyNode
-    # blocks can only be left with an explicit label now!
-    #else: 
-    #  result = emptyNode      # consume ``break`` token
-  
-proc evalFinally(c: PEvalContext, n, exc: PNode): PNode = 
-  var finallyNode = lastSon(n)
-  if finallyNode.kind == nkFinally: 
-    result = evalAux(c, finallyNode, {})
-    if result.kind != nkExceptBranch: result = exc
-  else: 
-    result = exc
-  
-proc evalTry(c: PEvalContext, n: PNode): PNode = 
-  result = evalAux(c, n.sons[0], {})
-  case result.kind
-  of nkBreakStmt, nkReturnToken: 
-    nil
-  of nkExceptBranch: 
-    if sonsLen(result) >= 1: 
-      # creating a nkExceptBranch without sons means that it could not be
-      # evaluated
-      var exc = result
-      var i = 1
-      var length = sonsLen(n)
-      while (i < length) and (n.sons[i].kind == nkExceptBranch): 
-        var blen = sonsLen(n.sons[i])
-        if blen == 1: 
-          # general except section:
-          result = evalAux(c, n.sons[i].sons[0], {})
-          exc = result
-          break 
-        else: 
-          for j in countup(0, blen - 2): 
-            assert(n.sons[i].sons[j].kind == nkType)
-            let a = exc.typ.skipTypes(abstractPtrs)
-            let b = n.sons[i].sons[j].typ.skipTypes(abstractPtrs)
-            if a == b: 
-              result = evalAux(c, n.sons[i].sons[blen - 1], {})
-              exc = result
-              break 
-        inc(i)
-      result = evalFinally(c, n, exc)
-  else: result = evalFinally(c, n, emptyNode)
-  
-proc getNullValue(typ: PType, info: TLineInfo): PNode
-proc getNullValueAux(obj: PNode, result: PNode) = 
-  case obj.kind
-  of nkRecList:
-    for i in countup(0, sonsLen(obj) - 1): getNullValueAux(obj.sons[i], result)
-  of nkRecCase:
-    getNullValueAux(obj.sons[0], result)
-    for i in countup(1, sonsLen(obj) - 1): 
-      getNullValueAux(lastSon(obj.sons[i]), result)
-  of nkSym:
-    var s = obj.sym
-    var p = newNodeIT(nkExprColonExpr, result.info, s.typ)
-    addSon(p, newSymNode(s, result.info))
-    addSon(p, getNullValue(s.typ, result.info))
-    addSon(result, p)
-  else: InternalError(result.info, "getNullValueAux")
-  
-proc getNullValue(typ: PType, info: TLineInfo): PNode = 
-  var t = skipTypes(typ, abstractRange-{tyTypeDesc})
-  result = emptyNode
-  case t.kind
-  of tyBool, tyEnum, tyChar, tyInt..tyInt64: 
-    result = newNodeIT(nkIntLit, info, t)
-  of tyUInt..tyUInt64:
-    result = newNodeIT(nkUIntLit, info, t)
-  of tyFloat..tyFloat128: 
-    result = newNodeIt(nkFloatLit, info, t)
-  of tyVar, tyPointer, tyPtr, tyRef, tyCString, tySequence, tyString, tyExpr,
-     tyStmt, tyTypeDesc, tyStatic, tyProc:
-    result = newNodeIT(nkNilLit, info, t)
-  of tyObject: 
-    result = newNodeIT(nkPar, info, t)
-    getNullValueAux(t.n, result)
-    # initialize inherited fields:
-    var base = t.sons[0]
-    while base != nil:
-      getNullValueAux(skipTypes(base, skipPtrs).n, result)
-      base = base.sons[0]
-  of tyArray, tyArrayConstr: 
-    result = newNodeIT(nkBracket, info, t)
-    for i in countup(0, int(lengthOrd(t)) - 1): 
-      addSon(result, getNullValue(elemType(t), info))
-  of tyTuple:
-    # XXX nkExprColonExpr is out of fashion ...
-    result = newNodeIT(nkPar, info, t)
-    for i in countup(0, sonsLen(t) - 1):
-      var p = newNodeIT(nkExprColonExpr, info, t.sons[i])
-      var field = if t.n != nil: t.n.sons[i].sym else: newSym(
-        skField, getIdent(":tmp" & $i), t.owner, info)
-      addSon(p, newSymNode(field, info))
-      addSon(p, getNullValue(t.sons[i], info))
-      addSon(result, p)
-  of tySet:
-    result = newNodeIT(nkCurly, info, t)    
-  else: InternalError("getNullValue: " & $t.kind)
-  
-proc evalVarValue(c: PEvalContext, n: PNode): PNode =
-  result = evalAux(c, n, {})
-  if result.kind in {nkType..nkNilLit}: result = result.copyNode
-
-proc allocSlot(c: PStackFrame; sym: PSym): int =
-  result = sym.position + ord(sym.kind == skParam)
-  if result == 0 and sym.kind != skResult:
-    result = c.slots.len
-    if result == 0: result = 1
-    sym.position = result
-  setLen(c.slots, max(result+1, c.slots.len))
-
-proc setSlot(c: PStackFrame, sym: PSym, val: PNode) =
-  assert sym.owner == c.prc or sfFromGeneric in sym.flags
-  let idx = allocSlot(c, sym)
-  c.slots[idx] = val
-
-proc setVar(c: PEvalContext, v: PSym, n: PNode) =
-  if sfGlobal notin v.flags: setSlot(c.tos, v, n)
-  else: IdNodeTablePut(c.globals, v, n)
-
-proc evalVar(c: PEvalContext, n: PNode): PNode =
-  for i in countup(0, sonsLen(n) - 1):
-    let a = n.sons[i]
-    if a.kind == nkCommentStmt: continue
-    #assert(a.sons[0].kind == nkSym) can happen for transformed vars
-    if a.kind == nkVarTuple:
-      result = evalVarValue(c, a.lastSon)
-      if result.kind in {nkType..nkNilLit}:
-        result = result.copyNode
-      bailout()
-      if result.kind != nkPar:
-        return raiseCannotEval(c, n.info)
-      for i in 0 .. a.len-3:
-        var v = a.sons[i].sym
-        setVar(c, v, result.sons[i])
-    else:
-      if a.sons[2].kind != nkEmpty:
-        result = evalVarValue(c, a.sons[2])
-        bailout()
-      else:
-        result = getNullValue(a.sons[0].typ, a.sons[0].info)
-      if a.sons[0].kind == nkSym:
-        var v = a.sons[0].sym
-        setVar(c, v, result)
-      else:
-        # assign to a.sons[0]:
-        var x = result
-        evalX(a.sons[0], {})
-        myreset(x)
-        x.kind = result.kind
-        x.typ = result.typ
-        case x.kind
-        of nkCharLit..nkInt64Lit: x.intVal = result.intVal
-        of nkFloatLit..nkFloat64Lit: x.floatVal = result.floatVal
-        of nkStrLit..nkTripleStrLit: x.strVal = result.strVal
-        of nkIdent: x.ident = result.ident
-        of nkSym: x.sym = result.sym
-        else:
-          if x.kind notin {nkEmpty..nkNilLit}:
-            discardSons(x)
-            for j in countup(0, sonsLen(result) - 1): addSon(x, result.sons[j])
-  result = emptyNode
-
-proc aliasNeeded(n: PNode, flags: TEvalFlags): bool = 
-  result = efLValue in flags or n.typ == nil or 
-    n.typ.kind in {tyExpr, tyStatic, tyStmt, tyTypeDesc}
-
-proc evalVariable(c: PStackFrame, sym: PSym, flags: TEvalFlags): PNode =
-  # We need to return a node to the actual value,
-  # which can be modified.
-  assert sym.position != 0 or skResult == sym.kind
-  var x = c
-  while x != nil:
-    if sym.owner == x.prc:
-      result = x.slots[sym.position]
-      assert result != nil
-      if not aliasNeeded(result, flags):
-        result = copyTree(result)
-      return
-    x = x.next
-  #internalError(sym.info, "cannot eval " & sym.name.s & " " & $sym.position)
-  result = raiseCannotEval(nil, sym.info)
-  #result = emptyNode
-
-proc evalGlobalVar(c: PEvalContext, s: PSym, flags: TEvalFlags): PNode =
-  if sfCompileTime in s.flags or c.mode == emRepl or s.kind == skForVar:
-    result = IdNodeTableGet(c.globals, s)
-    if result != nil: 
-      if not aliasNeeded(result, flags): 
-        result = copyTree(result)
-    else:
-      when hasFFI:
-        if sfImportc in s.flags and allowFFI in c.features:
-          result = importcSymbol(s)
-          IdNodeTablePut(c.globals, s, result)
-          return result
-      
-      result = s.ast
-      if result == nil or result.kind == nkEmpty:
-        result = getNullValue(s.typ, s.info)
-      else:
-        result = evalAux(c, result, {})
-        if isSpecial(result): return
-      IdNodeTablePut(c.globals, s, result)
-  else:
-    result = raiseCannotEval(nil, s.info)
-
-proc optBody(c: PEvalContext, s: PSym): PNode =
-  result = s.getBody
-
-proc evalCall(c: PEvalContext, n: PNode): PNode = 
-  var d = newStackFrame()
-  d.call = n
-  var prc = n.sons[0]
-  let isClosure = prc.kind == nkClosure
-  setlen(d.slots, sonsLen(n) + ord(isClosure))
-  if isClosure:
-    #debug prc
-    evalX(prc.sons[1], {efLValue})
-    d.slots[sonsLen(n)] = result
-    result = evalAux(c, prc.sons[0], {})
-  else:
-    result = evalAux(c, prc, {})
-
-  if isSpecial(result): return 
-  prc = result
-  # bind the actual params to the local parameter of a new binding
-  if prc.kind != nkSym: 
-    InternalError(n.info, "evalCall " & n.renderTree)
-    return
-  d.prc = prc.sym
-  if prc.sym.kind notin {skProc, skConverter, skMacro}:
-    InternalError(n.info, "evalCall")
-    return
-  for i in countup(1, sonsLen(n) - 1): 
-    evalX(n.sons[i], {})
-    d.slots[i] = result
-  if n.typ != nil: d.slots[0] = getNullValue(n.typ, n.info)
-  
-  when hasFFI:
-    if sfImportc in prc.sym.flags and allowFFI in c.features:
-      var newCall = newNodeI(nkCall, n.info, n.len)
-      newCall.sons[0] = evalGlobalVar(c, prc.sym, {})
-      for i in 1 .. <n.len:
-        newCall.sons[i] = d.slots[i]
-      return callForeignFunction(newCall)
-  
-  pushStackFrame(c, d)
-  evalX(optBody(c, prc.sym), {})
-  if n.typ != nil: result = d.slots[0]
-  popStackFrame(c)
-
-proc evalArrayAccess(c: PEvalContext, n: PNode, flags: TEvalFlags): PNode = 
-  evalX(n.sons[0], flags)
-  var x = result
-  evalX(n.sons[1], {})
-  var idx = getOrdValue(result)
-  result = emptyNode
-  case x.kind
-  of nkPar:
-    if (idx >= 0) and (idx < sonsLen(x)): 
-      result = x.sons[int(idx)]
-      if result.kind == nkExprColonExpr: result = result.sons[1]
-      if not aliasNeeded(result, flags): result = copyTree(result)
-    else: 
-      stackTrace(c, n.info, errIndexOutOfBounds)
-  of nkBracket, nkMetaNode: 
-    if (idx >= 0) and (idx < sonsLen(x)): 
-      result = x.sons[int(idx)]
-      if not aliasNeeded(result, flags): result = copyTree(result)
-    else: 
-      stackTrace(c, n.info, errIndexOutOfBounds)
-  of nkStrLit..nkTripleStrLit:
-    if efLValue in flags: return raiseCannotEval(c, n.info)
-    result = newNodeIT(nkCharLit, x.info, getSysType(tyChar))
-    if (idx >= 0) and (idx < len(x.strVal)): 
-      result.intVal = ord(x.strVal[int(idx) + 0])
-    elif idx == len(x.strVal): 
-      nil
-    else: 
-      stackTrace(c, n.info, errIndexOutOfBounds)
-  else: stackTrace(c, n.info, errNilAccess)
-  
-proc evalFieldAccess(c: PEvalContext, n: PNode, flags: TEvalFlags): PNode =
-  # a real field access; proc calls have already been transformed
-  # XXX: field checks!
-  evalX(n.sons[0], flags)
-  var x = result
-  if x.kind != nkPar: return raiseCannotEval(c, n.info)
-  # this is performance critical:
-  var field = n.sons[1].sym
-  result = x.sons[field.position]
-  if result.kind == nkExprColonExpr: result = result.sons[1]
-  if not aliasNeeded(result, flags): result = copyTree(result)
-
-proc evalAsgn(c: PEvalContext, n: PNode): PNode =
-  var a = n.sons[0]
-  if a.kind == nkBracketExpr and a.sons[0].typ.kind in {tyString, tyCString}: 
-    evalX(a.sons[0], {efLValue})
-    var x = result
-    evalX(a.sons[1], {})
-    var idx = getOrdValue(result)
-
-    evalX(n.sons[1], {})
-    if result.kind notin {nkIntLit, nkCharLit}: return c.raiseCannotEval(n.info)
-
-    if idx >= 0 and idx < len(x.strVal):
-      x.strVal[int(idx)] = chr(int(result.intVal))
-    else:
-      stackTrace(c, n.info, errIndexOutOfBounds)
-  else:
-    evalX(n.sons[0], {efLValue})
-    var x = result
-    evalX(n.sons[1], {})
-    myreset(x)
-    x.kind = result.kind
-    x.typ = result.typ
-    case x.kind
-    of nkCharLit..nkInt64Lit: x.intVal = result.intVal
-    of nkFloatLit..nkFloat64Lit: x.floatVal = result.floatVal
-    of nkStrLit..nkTripleStrLit: x.strVal = result.strVal
-    of nkIdent: x.ident = result.ident
-    of nkSym: x.sym = result.sym
-    else:
-      if x.kind notin {nkEmpty..nkNilLit}:
-        discardSons(x)
-        for i in countup(0, sonsLen(result) - 1): addSon(x, result.sons[i])
-  result = emptyNode
-  assert result.kind == nkEmpty
-
-proc evalSwap(c: PEvalContext, n: PNode): PNode = 
-  evalX(n.sons[0], {efLValue})
-  var x = result
-  evalX(n.sons[1], {efLValue})
-  if x.kind != result.kind: 
-    stackTrace(c, n.info, errCannotInterpretNodeX, $n.kind)
-  else:
-    case x.kind
-    of nkCharLit..nkInt64Lit: swap(x.intVal, result.intVal)
-    of nkFloatLit..nkFloat64Lit: swap(x.floatVal, result.floatVal)
-    of nkStrLit..nkTripleStrLit: swap(x.strVal, result.strVal)
-    of nkIdent: swap(x.ident, result.ident)
-    of nkSym: swap(x.sym, result.sym)    
-    else: 
-      var tmpn = copyTree(x)
-      discardSons(x)
-      for i in countup(0, sonsLen(result) - 1): addSon(x, result.sons[i])
-      discardSons(result)
-      for i in countup(0, sonsLen(tmpn) - 1): addSon(result, tmpn.sons[i])
-  result = emptyNode
-  
-proc evalSym(c: PEvalContext, n: PNode, flags: TEvalFlags): PNode = 
-  var s = n.sym
-  case s.kind
-  of skProc, skConverter, skMacro, skType:
-    result = n
-    #result = s.getBody
-  of skVar, skLet, skForVar, skTemp, skResult:
-    if sfGlobal notin s.flags:
-      result = evalVariable(c.tos, s, flags)
-    else:
-      result = evalGlobalVar(c, s, flags)
-  of skParam:
-    # XXX what about LValue?
-    if s.position + 1 <% c.tos.slots.len:
-      result = c.tos.slots[s.position + 1]
-  of skConst: result = s.ast
-  of skEnumField: result = newIntNodeT(s.position, n)
-  else: result = nil
-  let mask = if hasFFI and allowFFI in c.features: {sfForward}
-             else: {sfImportc, sfForward}
-  if result == nil or mask * s.flags != {}:
-    result = raiseCannotEval(c, n.info)
-
-proc evalIncDec(c: PEvalContext, n: PNode, sign: biggestInt): PNode = 
-  evalX(n.sons[1], {efLValue})
-  var a = result
-  evalX(n.sons[2], {})
-  var b = result
-  case a.kind
-  of nkCharLit..nkInt64Lit: a.intval = a.intVal + sign * getOrdValue(b)
-  else: return raiseCannotEval(c, n.info)
-  result = emptyNode
-
-proc getStrValue(n: PNode): string = 
-  case n.kind
-  of nkStrLit..nkTripleStrLit: result = n.strVal
-  else: 
-    InternalError(n.info, "getStrValue")
-    result = ""
-
-proc evalEcho(c: PEvalContext, n: PNode): PNode = 
-  for i in countup(1, sonsLen(n) - 1): 
-    evalX(n.sons[i], {})
-    Write(stdout, getStrValue(result))
-  writeln(stdout, "")
-  result = emptyNode
-
-proc evalExit(c: PEvalContext, n: PNode): PNode = 
-  if c.mode in {emRepl, emStatic}:
-    evalX(n.sons[1], {})
-    Message(n.info, hintQuitCalled)
-    quit(int(getOrdValue(result)))
-  else:
-    result = raiseCannotEval(c, n.info)
-
-proc evalOr(c: PEvalContext, n: PNode): PNode = 
-  evalX(n.sons[1], {})
-  if result.intVal == 0: result = evalAux(c, n.sons[2], {})
-  
-proc evalAnd(c: PEvalContext, n: PNode): PNode = 
-  evalX(n.sons[1], {})
-  if result.intVal != 0: result = evalAux(c, n.sons[2], {})
-  
-proc evalNew(c: PEvalContext, n: PNode): PNode = 
-  #if c.mode == emOptimize: return raiseCannotEval(c, n.info)
-  
-  # we ignore the finalizer for now and most likely forever :-)
-  evalX(n.sons[1], {efLValue})
-  var a = result
-  var t = skipTypes(n.sons[1].typ, abstractVar)
-  if a.kind == nkEmpty: InternalError(n.info, "first parameter is empty")
-  myreset(a)
-  let u = getNullValue(t.sons[0], n.info)
-  a.kind = u.kind
-  a.typ = t
-  shallowCopy(a.sons, u.sons)
-  result = emptyNode
-  when false:
-    a.kind = nkRefTy
-    a.info = n.info
-    a.typ = t
-    a.sons = nil
-    addSon(a, getNullValue(t.sons[0], n.info))
-    result = emptyNode
-
-proc evalDeref(c: PEvalContext, n: PNode, flags: TEvalFlags): PNode = 
-  evalX(n.sons[0], {efLValue})
-  case result.kind
-  of nkNilLit: stackTrace(c, n.info, errNilAccess)
-  of nkRefTy: 
-    # XXX efLValue?
-    result = result.sons[0]
-  else:
-    if skipTypes(n.sons[0].typ, abstractInst).kind != tyRef:
-      result = raiseCannotEval(c, n.info)
-  
-proc evalAddr(c: PEvalContext, n: PNode, flags: TEvalFlags): PNode = 
-  evalX(n.sons[0], {efLValue})
-  var a = result
-  var t = newType(tyPtr, c.module)
-  addSonSkipIntLit(t, a.typ)
-  result = newNodeIT(nkRefTy, n.info, t)
-  addSon(result, a)
-
-proc evalConv(c: PEvalContext, n: PNode): PNode = 
-  result = evalAux(c, n.sons[1], {efLValue})
-  if isSpecial(result): return
-  if result.typ != nil:
-    var a = result
-    result = foldConv(n, a)
-    if result == nil: 
-      # foldConv() cannot deal with everything that we want to do here:
-      result = a
-
-proc evalCast(c: PEvalContext, n: PNode, flags: TEvalFlags): PNode =
-  if allowCast in c.features:
-    when hasFFI:
-      result = evalAux(c, n.sons[1], {efLValue})
-      if isSpecial(result): return
-      InternalAssert result.typ != nil
-      result = fficast(result, n.typ)
-    else:
-      result = evalConv(c, n)
-  else:
-    result = raiseCannotEval(c, n.info)
-
-proc evalCheckedFieldAccess(c: PEvalContext, n: PNode, 
-                            flags: TEvalFlags): PNode = 
-  result = evalAux(c, n.sons[0], flags)
-
-proc evalUpConv(c: PEvalContext, n: PNode, flags: TEvalFlags): PNode = 
-  result = evalAux(c, n.sons[0], flags)
-  if isSpecial(result): return 
-  var dest = skipTypes(n.typ, abstractPtrs)
-  var src = skipTypes(result.typ, abstractPtrs)
-  if inheritanceDiff(src, dest) > 0: 
-    stackTrace(c, n.info, errInvalidConversionFromTypeX, typeToString(src))
-  
-proc evalRangeChck(c: PEvalContext, n: PNode): PNode = 
-  evalX(n.sons[0], {})
-  var x = result
-  evalX(n.sons[1], {})
-  var a = result
-  evalX(n.sons[2], {})
-  var b = result
-  if leValueConv(a, x) and leValueConv(x, b): 
-    result = x                # a <= x and x <= b
-    result.typ = n.typ
-  else: 
-    stackTrace(c, n.info, errGenerated, 
-      msgKindToString(errIllegalConvFromXtoY) % [
-      typeToString(n.sons[0].typ), typeToString(n.typ)])
-  
-proc evalConvStrToCStr(c: PEvalContext, n: PNode): PNode = 
-  result = evalAux(c, n.sons[0], {})
-  if isSpecial(result): return 
-  result.typ = n.typ
-
-proc evalConvCStrToStr(c: PEvalContext, n: PNode): PNode = 
-  result = evalAux(c, n.sons[0], {})
-  if isSpecial(result): return 
-  result.typ = n.typ
-
-proc evalRaise(c: PEvalContext, n: PNode): PNode = 
-  if c.mode in {emRepl, emStatic}:
-    if n.sons[0].kind != nkEmpty: 
-      result = evalAux(c, n.sons[0], {})
-      if isSpecial(result): return 
-      var a = result
-      result = newNodeIT(nkExceptBranch, n.info, a.typ)
-      addSon(result, a)
-      c.lastException = result
-    elif c.lastException != nil: 
-      result = c.lastException
-    else: 
-      stackTrace(c, n.info, errExceptionAlreadyHandled)
-      result = newNodeIT(nkExceptBranch, n.info, nil)
-      addSon(result, ast.emptyNode)
-  else:
-    result = raiseCannotEval(c, n.info)
-
-proc evalReturn(c: PEvalContext, n: PNode): PNode = 
-  if n.sons[0].kind != nkEmpty: 
-    result = evalAsgn(c, n.sons[0])
-    if isSpecial(result): return 
-  result = newNodeIT(nkReturnToken, n.info, nil)
-
-proc evalProc(c: PEvalContext, n: PNode): PNode = 
-  if n.sons[genericParamsPos].kind == nkEmpty: 
-    var s = n.sons[namePos].sym
-    if (resultPos < sonsLen(n)) and (n.sons[resultPos].kind != nkEmpty): 
-      var v = n.sons[resultPos].sym
-      result = getNullValue(v.typ, n.info)
-      if c.tos.slots.len == 0: setLen(c.tos.slots, 1)
-      c.tos.slots[0] = result
-      #IdNodeTablePut(c.tos.mapping, v, result)
-      result = evalAux(c, s.getBody, {})
-      if result.kind == nkReturnToken:
-        result = c.tos.slots[0]
-    else:
-      result = evalAux(c, s.getBody, {})
-      if result.kind == nkReturnToken: 
-        result = emptyNode
-  else: 
-    result = emptyNode
-  
-proc evalHigh(c: PEvalContext, n: PNode): PNode = 
-  result = evalAux(c, n.sons[1], {})
-  if isSpecial(result): return 
-  case skipTypes(n.sons[1].typ, abstractVar).kind
-  of tyOpenArray, tySequence, tyVarargs: 
-    result = newIntNodeT(sonsLen(result)-1, n)
-  of tyString: result = newIntNodeT(len(result.strVal) - 1, n)
-  else: InternalError(n.info, "evalHigh")
-
-proc evalOf(c: PEvalContext, n: PNode): PNode = 
-  result = evalAux(c, n.sons[1], {})
-  if isSpecial(result): return 
-  result = newIntNodeT(ord(inheritanceDiff(result.typ, n.sons[2].typ) >= 0), n)
-
-proc evalSetLengthStr(c: PEvalContext, n: PNode): PNode = 
-  result = evalAux(c, n.sons[1], {efLValue})
-  if isSpecial(result): return 
-  var a = result
-  result = evalAux(c, n.sons[2], {})
-  if isSpecial(result): return 
-  var b = result
-  case a.kind
-  of nkStrLit..nkTripleStrLit: 
-    var newLen = int(getOrdValue(b))
-    setlen(a.strVal, newLen)
-  else: InternalError(n.info, "evalSetLengthStr")
-  result = emptyNode
-
-proc evalSetLengthSeq(c: PEvalContext, n: PNode): PNode = 
-  result = evalAux(c, n.sons[1], {efLValue})
-  if isSpecial(result): return 
-  var a = result
-  result = evalAux(c, n.sons[2], {})
-  if isSpecial(result): return 
-  var b = result
-  if a.kind != nkBracket: 
-    InternalError(n.info, "evalSetLengthSeq")
-    return
-  var newLen = int(getOrdValue(b))
-  var oldLen = sonsLen(a)
-  setlen(a.sons, newLen)
-  for i in countup(oldLen, newLen - 1): 
-    a.sons[i] = getNullValue(skipTypes(n.sons[1].typ, abstractVar), n.info)
-  result = emptyNode
-
-proc evalNewSeq(c: PEvalContext, n: PNode): PNode = 
-  result = evalAux(c, n.sons[1], {efLValue})
-  if isSpecial(result): return 
-  var a = result
-  result = evalAux(c, n.sons[2], {})
-  if isSpecial(result): return 
-  var b = result
-  var t = skipTypes(n.sons[1].typ, abstractVar)
-  if a.kind == nkEmpty: InternalError(n.info, "first parameter is empty")
-  myreset(a)
-  a.kind = nkBracket
-  a.info = n.info
-  a.typ = t
-  a.sons = nil
-  var L = int(getOrdValue(b))
-  newSeq(a.sons, L)
-  for i in countup(0, L-1): 
-    a.sons[i] = getNullValue(t.sons[0], n.info)
-  result = emptyNode
- 
-proc evalIncl(c: PEvalContext, n: PNode): PNode = 
-  result = evalAux(c, n.sons[1], {efLValue})
-  if isSpecial(result): return 
-  var a = result
-  result = evalAux(c, n.sons[2], {})
-  if isSpecial(result): return 
-  var b = result
-  if not inSet(a, b): addSon(a, copyTree(b))
-  result = emptyNode
-
-proc evalExcl(c: PEvalContext, n: PNode): PNode = 
-  result = evalAux(c, n.sons[1], {efLValue})
-  if isSpecial(result): return 
-  var a = result
-  result = evalAux(c, n.sons[2], {})
-  if isSpecial(result): return 
-  var b = newNodeIT(nkCurly, n.info, n.sons[1].typ)
-  addSon(b, result)
-  var r = diffSets(a, b)
-  discardSons(a)
-  for i in countup(0, sonsLen(r) - 1): addSon(a, r.sons[i])
-  result = emptyNode
-
-proc evalAppendStrCh(c: PEvalContext, n: PNode): PNode = 
-  result = evalAux(c, n.sons[1], {efLValue})
-  if isSpecial(result): return 
-  var a = result
-  result = evalAux(c, n.sons[2], {})
-  if isSpecial(result): return 
-  var b = result
-  case a.kind
-  of nkStrLit..nkTripleStrLit: add(a.strVal, chr(int(getOrdValue(b))))
-  else: return raiseCannotEval(c, n.info)
-  result = emptyNode
-
-proc evalConStrStr(c: PEvalContext, n: PNode): PNode = 
-  # we cannot use ``evalOp`` for this as we can here have more than 2 arguments
-  var a = newNodeIT(nkStrLit, n.info, n.typ)
-  a.strVal = ""
-  for i in countup(1, sonsLen(n) - 1): 
-    result = evalAux(c, n.sons[i], {})
-    if isSpecial(result): return 
-    a.strVal.add(getStrOrChar(result))
-  result = a
-
-proc evalAppendStrStr(c: PEvalContext, n: PNode): PNode = 
-  result = evalAux(c, n.sons[1], {efLValue})
-  if isSpecial(result): return 
-  var a = result
-  result = evalAux(c, n.sons[2], {})
-  if isSpecial(result): return 
-  var b = result
-  case a.kind
-  of nkStrLit..nkTripleStrLit: a.strVal = a.strVal & getStrOrChar(b)
-  else: return raiseCannotEval(c, n.info)
-  result = emptyNode
-
-proc evalAppendSeqElem(c: PEvalContext, n: PNode): PNode = 
-  result = evalAux(c, n.sons[1], {efLValue})
-  if isSpecial(result): return 
-  var a = result
-  result = evalAux(c, n.sons[2], {})
-  if isSpecial(result): return 
-  var b = result
-  if a.kind == nkBracket: addSon(a, copyTree(b))
-  else: return raiseCannotEval(c, n.info)
-  result = emptyNode
-
-proc evalRepr(c: PEvalContext, n: PNode): PNode = 
-  result = evalAux(c, n.sons[1], {})
-  if isSpecial(result): return 
-  result = newStrNodeT(renderTree(result, {renderNoComments}), n)
-
-proc isEmpty(n: PNode): bool =
-  result = n != nil and n.kind == nkEmpty
-
-proc evalParseExpr(c: PEvalContext, n: PNode): PNode =
-  var code = evalAux(c, n.sons[1], {})
-  var ast = parseString(code.getStrValue, code.info.toFilename,
-                        code.info.line.int)
-  if sonsLen(ast) != 1:
-    GlobalError(code.info, errExprExpected, "multiple statements")
-  result = ast.sons[0]
-  #result.typ = newType(tyExpr, c.module)
-
-proc evalParseStmt(c: PEvalContext, n: PNode): PNode =
-  var code = evalAux(c, n.sons[1], {})
-  result = parseString(code.getStrValue, code.info.toFilename,
-                       code.info.line.int)
-  #result.typ = newType(tyStmt, c.module)
-
-proc evalTypeTrait*(trait, operand: PNode, context: PSym): PNode =
-  let typ = operand.typ.skipTypes({tyTypeDesc})
-  case trait.sym.name.s.normalize
-  of "name":
-    result = newStrNode(nkStrLit, typ.typeToString(preferName))
-    result.typ = newType(tyString, context)
-    result.info = trait.info
-  of "arity":
-    result = newIntNode(nkIntLit, typ.n.len-1)
-    result.typ = newType(tyInt, context)
-    result.info = trait.info
-  else:
-    internalAssert false
-
-proc expectString(n: PNode) =
-  if n.kind notin nkStrKinds:
-    GlobalError(n.info, errStringLiteralExpected)
-
-proc evalSlurp*(e: PNode, module: PSym): PNode =
-  expectString(e)
-  result = newNodeIT(nkStrLit, e.info, getSysType(tyString))
-  try:
-    var filename = e.strVal.FindFile
-    result.strVal = readFile(filename)
-    # we produce a fake include statement for every slurped filename, so that
-    # the module dependencies are accurate:    
-    appendToModule(module, newNode(nkIncludeStmt, e.info, @[
-      newStrNode(nkStrLit, filename)]))
-  except EIO:
-    result.strVal = ""
-    LocalError(e.info, errCannotOpenFile, e.strVal)
-
-proc readOutput(p: PProcess): string =
-  result = ""
-  var output = p.outputStream
-  discard p.waitForExit
-  while not output.atEnd:
-    result.add(output.readLine)
-
-proc evalStaticExec*(cmd, input: PNode): PNode =
-  expectString(cmd)
-  var p = startCmd(cmd.strVal)
-  if input != nil:
-    expectString(input)
-    p.inputStream.write(input.strVal)
-    p.inputStream.close()
-  result = newStrNode(nkStrLit, p.readOutput)
-  result.typ = getSysType(tyString)
-  result.info = cmd.info
-
-proc evalExpandToAst(c: PEvalContext, original: PNode): PNode =
-  var
-    n = original.copyTree
-    macroCall = n.sons[1]
-    expandedSym = macroCall.sons[0].sym
-
-  for i in countup(1, macroCall.sonsLen - 1):
-    macroCall.sons[i] = evalAux(c, macroCall.sons[i], {})
-
-  case expandedSym.kind
-  of skTemplate:
-    let genSymOwner = if c.tos != nil and c.tos.prc != nil:
-                        c.tos.prc 
-                      else:
-                        c.module
-    result = evalTemplate(macroCall, expandedSym, genSymOwner)
-  of skMacro:
-    # At this point macroCall.sons[0] is nkSym node.
-    # To be completely compatible with normal macro invocation,
-    # we want to replace it with nkIdent node featuring
-    # the original unmangled macro name.
-    macroCall.sons[0] = newIdentNode(expandedSym.name, expandedSym.info)
-    result = evalMacroCall(c, macroCall, original, expandedSym)
-  else:
-    InternalError(macroCall.info,
-      "ExpandToAst: expanded symbol is no macro or template")
-    result = emptyNode
-
-proc evalMagicOrCall(c: PEvalContext, n: PNode): PNode = 
-  var m = getMagic(n)
-  case m
-  of mNone: result = evalCall(c, n)
-  of mOf: result = evalOf(c, n)
-  of mSizeOf: result = raiseCannotEval(c, n.info)
-  of mHigh: result = evalHigh(c, n)
-  of mExit: result = evalExit(c, n)
-  of mNew, mNewFinalize: result = evalNew(c, n)
-  of mNewSeq: result = evalNewSeq(c, n)
-  of mSwap: result = evalSwap(c, n)
-  of mInc: result = evalIncDec(c, n, 1)
-  of ast.mDec: result = evalIncDec(c, n, - 1)
-  of mEcho: result = evalEcho(c, n)
-  of mSetLengthStr: result = evalSetLengthStr(c, n)
-  of mSetLengthSeq: result = evalSetLengthSeq(c, n)
-  of mIncl: result = evalIncl(c, n)
-  of mExcl: result = evalExcl(c, n)
-  of mAnd: result = evalAnd(c, n)
-  of mOr: result = evalOr(c, n)
-  of mAppendStrCh: result = evalAppendStrCh(c, n)
-  of mAppendStrStr: result = evalAppendStrStr(c, n)
-  of mAppendSeqElem: result = evalAppendSeqElem(c, n)
-  of mParseExprToAst: result = evalParseExpr(c, n)
-  of mParseStmtToAst: result = evalParseStmt(c, n)
-  of mExpandToAst: result = evalExpandToAst(c, n)
-  of mTypeTrait:
-    let operand = evalAux(c, n.sons[1], {})
-    result = evalTypeTrait(n[0], operand, c.module)
-  of mIs:
-    n.sons[1] = evalAux(c, n.sons[1], {})
-    result = c.handleIsOperator(n)
-  of mSlurp: result = evalSlurp(evalAux(c, n.sons[1], {}), c.module)
-  of mStaticExec:
-    let cmd = evalAux(c, n.sons[1], {})
-    let input = if n.sonsLen == 3: evalAux(c, n.sons[2], {}) else: nil
-    result = evalStaticExec(cmd, input)
-  of mNLen:
-    result = evalAux(c, n.sons[1], {efLValue})
-    if isSpecial(result): return 
-    var a = result
-    result = newNodeIT(nkIntLit, n.info, n.typ)
-    case a.kind
-    of nkEmpty..nkNilLit: nil
-    else: result.intVal = sonsLen(a)
-  of mNChild:
-    result = evalAux(c, n.sons[1], {efLValue})
-    if isSpecial(result): return 
-    var a = result
-    result = evalAux(c, n.sons[2], {efLValue})
-    if isSpecial(result): return 
-    var k = getOrdValue(result)
-    if not (a.kind in {nkEmpty..nkNilLit}) and (k >= 0) and (k < sonsLen(a)): 
-      result = a.sons[int(k)]
-      if result == nil: result = newNode(nkEmpty)
-    else: 
-      stackTrace(c, n.info, errIndexOutOfBounds)
-      result = emptyNode
-  of mNSetChild: 
-    result = evalAux(c, n.sons[1], {efLValue})
-    if isSpecial(result): return 
-    var a = result
-    result = evalAux(c, n.sons[2], {efLValue})
-    if isSpecial(result): return 
-    var b = result
-    result = evalAux(c, n.sons[3], {efLValue})
-    if isSpecial(result): return 
-    var k = getOrdValue(b)
-    if (k >= 0) and (k < sonsLen(a)) and not (a.kind in {nkEmpty..nkNilLit}): 
-      a.sons[int(k)] = result
-    else: 
-      stackTrace(c, n.info, errIndexOutOfBounds)
-    result = emptyNode
-  of mNAdd: 
-    result = evalAux(c, n.sons[1], {efLValue})
-    if isSpecial(result): return 
-    var a = result
-    result = evalAux(c, n.sons[2], {efLValue})
-    if isSpecial(result): return 
-    addSon(a, result)
-    result = a
-  of mNAddMultiple: 
-    result = evalAux(c, n.sons[1], {efLValue})
-    if isSpecial(result): return 
-    var a = result
-    result = evalAux(c, n.sons[2], {efLValue})
-    if isSpecial(result): return 
-    for i in countup(0, sonsLen(result) - 1): addSon(a, result.sons[i])
-    result = a
-  of mNDel: 
-    result = evalAux(c, n.sons[1], {efLValue})
-    if isSpecial(result): return 
-    var a = result
-    result = evalAux(c, n.sons[2], {efLValue})
-    if isSpecial(result): return 
-    var b = result
-    result = evalAux(c, n.sons[3], {efLValue})
-    if isSpecial(result): return 
-    for i in countup(0, int(getOrdValue(result)) - 1): 
-      delSon(a, int(getOrdValue(b)))
-    result = emptyNode
-  of mNKind: 
-    result = evalAux(c, n.sons[1], {})
-    if isSpecial(result): return 
-    var a = result
-    result = newNodeIT(nkIntLit, n.info, n.typ)
-    result.intVal = ord(a.kind)
-  of mNIntVal: 
-    result = evalAux(c, n.sons[1], {})
-    if isSpecial(result): return 
-    var a = result
-    result = newNodeIT(nkIntLit, n.info, n.typ)
-    case a.kind
-    of nkCharLit..nkInt64Lit: result.intVal = a.intVal
-    else: stackTrace(c, n.info, errFieldXNotFound, "intVal")
-  of mNFloatVal: 
-    result = evalAux(c, n.sons[1], {})
-    if isSpecial(result): return 
-    var a = result
-    result = newNodeIT(nkFloatLit, n.info, n.typ)
-    case a.kind
-    of nkFloatLit..nkFloat64Lit: result.floatVal = a.floatVal
-    else: stackTrace(c, n.info, errFieldXNotFound, "floatVal")
-  of mNSymbol: 
-    result = evalAux(c, n.sons[1], {efLValue})
-    if isSpecial(result): return 
-    if result.kind != nkSym: stackTrace(c, n.info, errFieldXNotFound, "symbol")
-  of mNIdent: 
-    result = evalAux(c, n.sons[1], {})
-    if isSpecial(result): return 
-    if result.kind != nkIdent: stackTrace(c, n.info, errFieldXNotFound, "ident")
-  of mNGetType:
-    var ast = evalAux(c, n.sons[1], {})
-    InternalAssert c.getType != nil
-    result = c.getType(ast)
-  of mNStrVal: 
-    result = evalAux(c, n.sons[1], {})
-    if isSpecial(result): return 
-    var a = result
-    result = newNodeIT(nkStrLit, n.info, n.typ)
-    case a.kind
-    of nkStrLit..nkTripleStrLit: result.strVal = a.strVal
-    else: stackTrace(c, n.info, errFieldXNotFound, "strVal")
-  of mNSetIntVal: 
-    result = evalAux(c, n.sons[1], {efLValue})
-    if isSpecial(result): return 
-    var a = result
-    result = evalAux(c, n.sons[2], {})
-    if isSpecial(result): return
-    if a.kind in {nkCharLit..nkInt64Lit} and 
-        result.kind in {nkCharLit..nkInt64Lit}:
-      a.intVal = result.intVal
-    else: 
-      stackTrace(c, n.info, errFieldXNotFound, "intVal")
-    result = emptyNode
-  of mNSetFloatVal: 
-    result = evalAux(c, n.sons[1], {efLValue})
-    if isSpecial(result): return 
-    var a = result
-    result = evalAux(c, n.sons[2], {})
-    if isSpecial(result): return 
-    if a.kind in {nkFloatLit..nkFloat64Lit} and
-        result.kind in {nkFloatLit..nkFloat64Lit}:
-      a.floatVal = result.floatVal
-    else:
-      stackTrace(c, n.info, errFieldXNotFound, "floatVal")
-    result = emptyNode
-  of mNSetSymbol: 
-    result = evalAux(c, n.sons[1], {efLValue})
-    if isSpecial(result): return 
-    var a = result
-    result = evalAux(c, n.sons[2], {efLValue})
-    if isSpecial(result): return 
-    if a.kind == nkSym and result.kind == nkSym:
-      a.sym = result.sym
-    else:
-      stackTrace(c, n.info, errFieldXNotFound, "symbol")
-    result = emptyNode
-  of mNSetIdent: 
-    result = evalAux(c, n.sons[1], {efLValue})
-    if isSpecial(result): return 
-    var a = result
-    result = evalAux(c, n.sons[2], {efLValue})
-    if isSpecial(result): return 
-    if a.kind == nkIdent and result.kind == nkIdent:
-      a.ident = result.ident
-    else:
-      stackTrace(c, n.info, errFieldXNotFound, "ident")
-    result = emptyNode
-  of mNSetType: 
-    result = evalAux(c, n.sons[1], {efLValue})
-    if isSpecial(result): return 
-    var a = result
-    result = evalAux(c, n.sons[2], {efLValue})
-    if isSpecial(result): return 
-    InternalAssert result.kind == nkSym and result.sym.kind == skType
-    a.typ = result.sym.typ
-    result = emptyNode
-  of mNSetStrVal:
-    result = evalAux(c, n.sons[1], {efLValue})
-    if isSpecial(result): return 
-    var a = result
-    result = evalAux(c, n.sons[2], {})
-    if isSpecial(result): return
-    
-    if a.kind in {nkStrLit..nkTripleStrLit} and
-        result.kind in {nkStrLit..nkTripleStrLit}:
-      a.strVal = result.strVal
-    else: stackTrace(c, n.info, errFieldXNotFound, "strVal")
-    result = emptyNode
-  of mNNewNimNode: 
-    result = evalAux(c, n.sons[1], {})
-    if isSpecial(result): return 
-    var k = getOrdValue(result)
-    result = evalAux(c, n.sons[2], {efLValue})
-    if result.kind == nkExceptBranch: return 
-    var a = result
-    if k < 0 or k > ord(high(TNodeKind)): 
-      internalError(n.info, "request to create a NimNode with invalid kind")
-    result = newNodeI(TNodeKind(int(k)), 
-      if a.kind == nkNilLit: n.info else: a.info)
-  of mNCopyNimNode:
-    result = evalAux(c, n.sons[1], {efLValue})
-    if isSpecial(result): return 
-    result = copyNode(result)
-  of mNCopyNimTree: 
-    result = evalAux(c, n.sons[1], {efLValue})
-    if isSpecial(result): return 
-    result = copyTree(result)
-  of mNBindSym:
-    # trivial implementation:
-    result = n.sons[1]
-  of mNGenSym:
-    evalX(n.sons[1], {efLValue})
-    let k = getOrdValue(result)
-    evalX(n.sons[2], {efLValue})
-    let b = result
-    let name = if b.strVal.len == 0: ":tmp" else: b.strVal
-    if k < 0 or k > ord(high(TSymKind)):
-      internalError(n.info, "request to create a symbol with invalid kind")
-    result = newSymNode(newSym(k.TSymKind, name.getIdent, c.module, n.info))
-    incl(result.sym.flags, sfGenSym)
-  of mStrToIdent: 
-    result = evalAux(c, n.sons[1], {})
-    if isSpecial(result): return 
-    if not (result.kind in {nkStrLit..nkTripleStrLit}): 
-      stackTrace(c, n.info, errFieldXNotFound, "strVal")
-      return
-    var a = result
-    result = newNodeIT(nkIdent, n.info, n.typ)
-    result.ident = getIdent(a.strVal)
-  of mIdentToStr: 
-    result = evalAux(c, n.sons[1], {})
-    if isSpecial(result): return 
-    var a = result
-    result = newNodeIT(nkStrLit, n.info, n.typ)
-    if a.kind == nkSym:
-      result.strVal = a.sym.name.s
-    else:
-      if a.kind != nkIdent: InternalError(n.info, "no ident node")
-      result.strVal = a.ident.s
-  of mEqIdent: 
-    result = evalAux(c, n.sons[1], {})
-    if isSpecial(result): return 
-    var a = result
-    result = evalAux(c, n.sons[2], {})
-    if isSpecial(result): return 
-    var b = result
-    result = newNodeIT(nkIntLit, n.info, n.typ)
-    if (a.kind == nkIdent) and (b.kind == nkIdent): 
-      if a.ident.id == b.ident.id: result.intVal = 1
-  of mEqNimrodNode: 
-    result = evalAux(c, n.sons[1], {efLValue})
-    if isSpecial(result): return 
-    var a = result
-    result = evalAux(c, n.sons[2], {efLValue})
-    if isSpecial(result): return 
-    var b = result
-    result = newNodeIT(nkIntLit, n.info, n.typ)
-    if (a == b) or
-        (b.kind in {nkNilLit, nkEmpty}) and (a.kind in {nkNilLit, nkEmpty}): 
-      result.intVal = 1
-  of mNLineInfo:
-    result = evalAux(c, n.sons[1], {})
-    if isSpecial(result): return
-    result = newStrNodeT(result.info.toFileLineCol, n)
-  of mNHint: 
-    result = evalAux(c, n.sons[1], {})
-    if isSpecial(result): return 
-    Message(n.info, hintUser, getStrValue(result))
-    result = emptyNode
-  of mNWarning: 
-    result = evalAux(c, n.sons[1], {})
-    if isSpecial(result): return 
-    Message(n.info, warnUser, getStrValue(result))
-    result = emptyNode
-  of mNError: 
-    result = evalAux(c, n.sons[1], {})
-    if isSpecial(result): return 
-    stackTrace(c, n.info, errUser, getStrValue(result))
-    result = emptyNode
-  of mConStrStr: 
-    result = evalConStrStr(c, n)
-  of mRepr: 
-    result = evalRepr(c, n)
-  of mNewString: 
-    result = evalAux(c, n.sons[1], {})
-    if isSpecial(result): return 
-    var a = result
-    result = newNodeIT(nkStrLit, n.info, n.typ)
-    result.strVal = newString(int(getOrdValue(a)))
-  of mNewStringOfCap:
-    result = evalAux(c, n.sons[1], {})
-    if isSpecial(result): return 
-    var a = result
-    result = newNodeIT(nkStrLit, n.info, n.typ)
-    result.strVal = newString(0)
-  of mNCallSite:
-    if c.callsite != nil: result = c.callsite
-    else: stackTrace(c, n.info, errFieldXNotFound, "callsite")
-  else:
-    result = evalAux(c, n.sons[1], {})
-    if isSpecial(result): return 
-    var a = result
-    var b: PNode = nil
-    var cc: PNode = nil
-    if sonsLen(n) > 2: 
-      result = evalAux(c, n.sons[2], {})
-      if isSpecial(result): return 
-      b = result
-      if sonsLen(n) > 3: 
-        result = evalAux(c, n.sons[3], {})
-        if isSpecial(result): return 
-        cc = result
-    if isEmpty(a) or isEmpty(b) or isEmpty(cc): result = emptyNode
-    else: result = evalOp(m, n, a, b, cc)
-
-proc evalAux(c: PEvalContext, n: PNode, flags: TEvalFlags): PNode =   
-  result = emptyNode
-  dec(gNestedEvals)
-  if gNestedEvals <= 0: stackTrace(c, n.info, errTooManyIterations)
-  case n.kind
-  of nkSym: result = evalSym(c, n, flags)
-  of nkType..nkNilLit, nkTypeOfExpr:
-    # nkStrLit is VERY common in the traces, so we should avoid
-    # the 'copyNode' here.
-    result = n #.copyNode
-  of nkAsgn, nkFastAsgn: result = evalAsgn(c, n)
-  of nkCommand..nkHiddenCallConv:
-    result = evalMagicOrCall(c, n)
-  of nkDotExpr: result = evalFieldAccess(c, n, flags)
-  of nkBracketExpr:
-    result = evalArrayAccess(c, n, flags)
-  of nkDerefExpr, nkHiddenDeref: result = evalDeref(c, n, flags)
-  of nkAddr, nkHiddenAddr: result = evalAddr(c, n, flags)
-  of nkHiddenStdConv, nkHiddenSubConv, nkConv: result = evalConv(c, n)
-  of nkCurly, nkBracket, nkRange:
-    # flags need to be passed here for mNAddMultiple :-(
-    # XXX this is not correct in every case!
-    var a = copyNode(n)
-    for i in countup(0, sonsLen(n) - 1): 
-      result = evalAux(c, n.sons[i], flags)
-      if isSpecial(result): return 
-      addSon(a, result)
-    result = a
-  of nkPar, nkClosure: 
-    var a = copyTree(n)
-    for i in countup(0, sonsLen(n) - 1): 
-      var it = n.sons[i]
-      if it.kind == nkExprColonExpr:
-        result = evalAux(c, it.sons[1], flags)
-        if isSpecial(result): return 
-        a.sons[i].sons[1] = result
-      else:
-        result = evalAux(c, it, flags)
-        if isSpecial(result): return 
-        a.sons[i] = result
-    result = a
-  of nkObjConstr:
-    let t = skipTypes(n.typ, abstractInst)
-    var a: PNode
-    if t.kind == tyRef:
-      result = newNodeIT(nkRefTy, n.info, t)
-      a = getNullValue(t.sons[0], n.info)
-      addSon(result, a)
-    else:
-      a = getNullValue(t, n.info)
-      result = a
-    for i in countup(1, sonsLen(n) - 1):
-      let it = n.sons[i]
-      if it.kind == nkExprColonExpr:
-        let value = evalAux(c, it.sons[1], flags)
-        if isSpecial(value): return value
-        a.sons[it.sons[0].sym.position] = value
-      else: return raiseCannotEval(c, n.info)
-  of nkWhenStmt, nkIfStmt, nkIfExpr: result = evalIf(c, n)
-  of nkWhileStmt: result = evalWhile(c, n)
-  of nkCaseStmt: result = evalCase(c, n)
-  of nkVarSection, nkLetSection: result = evalVar(c, n)
-  of nkTryStmt: result = evalTry(c, n)
-  of nkRaiseStmt: result = evalRaise(c, n)
-  of nkReturnStmt: result = evalReturn(c, n)
-  of nkBreakStmt, nkReturnToken: result = n
-  of nkBlockExpr, nkBlockStmt: result = evalBlock(c, n)
-  of nkDiscardStmt: result = evalAux(c, n.sons[0], {})
-  of nkCheckedFieldExpr: result = evalCheckedFieldAccess(c, n, flags)
-  of nkObjDownConv: result = evalAux(c, n.sons[0], flags)
-  of nkObjUpConv: result = evalUpConv(c, n, flags)
-  of nkChckRangeF, nkChckRange64, nkChckRange: result = evalRangeChck(c, n)
-  of nkStringToCString: result = evalConvStrToCStr(c, n)
-  of nkCStringToString: result = evalConvCStrToStr(c, n)
-  of nkStmtListExpr, nkStmtList: 
-    for i in countup(0, sonsLen(n) - 1): 
-      result = evalAux(c, n.sons[i], flags)
-      case result.kind
-      of nkExceptBranch, nkReturnToken, nkBreakStmt: break 
-      else: nil
-  of nkProcDef, nkMethodDef, nkMacroDef, nkCommentStmt, nkPragma,
-     nkTypeSection, nkTemplateDef, nkConstSection, nkIteratorDef,
-     nkConverterDef, nkIncludeStmt, nkImportStmt, nkFromStmt: 
-    nil
-  of nkMetaNode:
-    result = copyTree(n.sons[0])
-    result.typ = n.typ
-  of nkPragmaBlock:
-    result = evalAux(c, n.sons[1], flags)
-  of nkCast:
-    result = evalCast(c, n, flags)
-  of nkIdentDefs, nkYieldStmt, nkAsmStmt, nkForStmt, nkPragmaExpr, 
-     nkLambdaKinds, nkContinueStmt, nkIdent, nkParForStmt, nkBindStmt,
-     nkClosedSymChoice, nkOpenSymChoice:
-    result = raiseCannotEval(c, n.info)
-  of nkRefTy:
-    result = evalAux(c, n.sons[0], flags)
-  of nkEmpty: 
-    # nkEmpty occurs once in each trace that I looked at
-    result = n
-  else: InternalError(n.info, "evalAux: " & $n.kind)
-  if result == nil:
-    InternalError(n.info, "evalAux: returned nil " & $n.kind)
-  inc(gNestedEvals)
-
-proc tryEval(c: PEvalContext, n: PNode): PNode =
-  #internalAssert nfTransf in n.flags
-  var n = transformExpr(c.module, n)
-  gWhileCounter = evalMaxIterations
-  gNestedEvals = evalMaxRecDepth
-  result = evalAux(c, n, {})
-  
-proc eval*(c: PEvalContext, n: PNode): PNode = 
-  ## eval never returns nil! This simplifies the code a lot and
-  ## makes it faster too.
-  result = tryEval(c, n)
-  if result.kind == nkExceptBranch:
-    if sonsLen(result) >= 1: 
-      stackTrace(c, n.info, errUnhandledExceptionX, typeToString(result.typ))
-    else:
-      stackTrace(c, result.info, errCannotInterpretNodeX, renderTree(n))
-
-proc evalConstExprAux*(p: PEvalContext, module, prc: PSym, e: PNode): PNode =
-  var s = newStackFrame()
-  s.call = e
-  s.prc = prc
-  pushStackFrame(p, s)
-  result = tryEval(p, e)
-  if result != nil and result.kind == nkExceptBranch: result = nil
-  popStackFrame(p)
-
-proc setupMacroParam(x: PNode): PNode =
-  result = x
-  if result.kind in {nkHiddenSubConv, nkHiddenStdConv}: result = result.sons[1]
-
-proc evalMacroCall(c: PEvalContext, n, nOrig: PNode, sym: PSym): PNode =
-  # XXX GlobalError() is ugly here, but I don't know a better solution for now
-  inc(evalTemplateCounter)
-  if evalTemplateCounter > 100:
-    GlobalError(n.info, errTemplateInstantiationTooNested)
-
-  c.callsite = nOrig
-  var s = newStackFrame()
-  s.call = n
-  s.prc = sym
-  var L = n.safeLen
-  if L == 0: L = 1
-  setlen(s.slots, L)
-  # return value:
-  s.slots[0] = newNodeIT(nkNilLit, n.info, sym.typ.sons[0])
-  # setup parameters:
-  for i in 1 .. < L: s.slots[i] = setupMacroParam(n.sons[i])
-  pushStackFrame(c, s)
-  discard eval(c, optBody(c, sym))
-  result = s.slots[0]
-  popStackFrame(c)
-  if cyclicTree(result): GlobalError(n.info, errCyclicTree)
-  dec(evalTemplateCounter)
-  c.callsite = nil
-
-proc myOpen(module: PSym): PPassContext =
-  var c = newEvalContext(module, emRepl)
-  c.features = {allowCast, allowFFI, allowInfiniteLoops}
-  pushStackFrame(c, newStackFrame())
-  result = c
-
-var oldErrorCount: int
-
-proc myProcess(c: PPassContext, n: PNode): PNode =
-  # don't eval errornous code:
-  if oldErrorCount == msgs.gErrorCounter:
-    result = eval(PEvalContext(c), n)
-  else:
-    result = n
-  oldErrorCount = msgs.gErrorCounter
-
-const evalPass* = makePass(myOpen, nil, myProcess, myProcess)
-
diff --git a/compiler/guards.nim b/compiler/guards.nim
index f475f5068..4cf06fe02 100644
--- a/compiler/guards.nim
+++ b/compiler/guards.nim
@@ -1,7 +1,7 @@
 #
 #
 #           The Nimrod Compiler
-#        (c) Copyright 2013 Andreas Rumpf
+#        (c) Copyright 2014 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
@@ -9,7 +9,8 @@
 
 ## This module implements the 'implies' relation for guards.
 
-import ast, astalgo, msgs, magicsys, nimsets, trees, types, renderer, idents
+import ast, astalgo, msgs, magicsys, nimsets, trees, types, renderer, idents,
+  saturate
 
 const
   someEq = {mEqI, mEqI64, mEqF64, mEqEnum, mEqCh, mEqB, mEqRef, mEqProc,
@@ -25,6 +26,17 @@ const
 
   someIn = {mInRange, mInSet}
 
+  someHigh = {mHigh}
+  # we don't list unsigned here because wrap around semantics suck for
+  # proving anything:
+  someAdd = {mAddI, mAddI64, mAddF64, mSucc}
+  someSub = {mSubI, mSubI64, mSubF64, mPred}
+  someMul = {mMulI, mMulI64, mMulF64}
+  someDiv = {mDivI, mDivI64, mDivF64}
+  someMod = {mModI, mModI64}
+  someMax = {mMaxI, mMaxI64, mMaxF64}
+  someMin = {mMinI, mMinI64, mMinF64}
+
 proc isValue(n: PNode): bool = n.kind in {nkCharLit..nkNilLit}
 proc isLocation(n: PNode): bool = not n.isValue
 
@@ -69,19 +81,24 @@ proc isLetLocation(m: PNode, isApprox: bool): bool =
 
 proc interestingCaseExpr*(m: PNode): bool = isLetLocation(m, true)
 
-proc getMagicOp(name: string, m: TMagic): PSym =
+proc createMagic*(name: string, m: TMagic): PSym =
   result = newSym(skProc, getIdent(name), nil, unknownLineInfo())
   result.magic = m
 
 let
-  opLe = getMagicOp("<=", mLeI)
-  opLt = getMagicOp("<", mLtI)
-  opAnd = getMagicOp("and", mAnd)
-  opOr = getMagicOp("or", mOr)
-  opNot = getMagicOp("not", mNot)
-  opIsNil = getMagicOp("isnil", mIsNil)
-  opContains = getMagicOp("contains", mInSet)
-  opEq = getMagicOp("==", mEqI)
+  opLe = createMagic("<=", mLeI)
+  opLt = createMagic("<", mLtI)
+  opAnd = createMagic("and", mAnd)
+  opOr = createMagic("or", mOr)
+  opNot = createMagic("not", mNot)
+  opIsNil = createMagic("isnil", mIsNil)
+  opContains = createMagic("contains", mInSet)
+  opEq = createMagic("==", mEqI)
+  opAdd = createMagic("+", mAddI)
+  opSub = createMagic("-", mSubI)
+  opMul = createMagic("*", mMulI)
+  opDiv = createMagic("div", mDivI)
+  opLen = createMagic("len", mLengthSeq)
 
 proc swapArgs(fact: PNode, newOp: PSym): PNode =
   result = newNodeI(nkCall, fact.info, 3)
@@ -137,17 +154,141 @@ proc neg(n: PNode): PNode =
     result.sons[0] = newSymNode(opNot)
     result.sons[1] = n
 
-proc buildIsNil(arg: PNode): PNode =
-  result = newNodeI(nkCall, arg.info, 2)
-  result.sons[0] = newSymNode(opIsNil)
-  result.sons[1] = arg
+proc buildCall(op: PSym; a: PNode): PNode =
+  result = newNodeI(nkCall, a.info, 2)
+  result.sons[0] = newSymNode(op)
+  result.sons[1] = a
+
+proc buildCall(op: PSym; a, b: PNode): PNode =
+  result = newNodeI(nkInfix, a.info, 3)
+  result.sons[0] = newSymNode(op)
+  result.sons[1] = a
+  result.sons[2] = b
+
+proc `|+|`(a, b: PNode): PNode =
+  result = copyNode(a)
+  if a.kind in {nkCharLit..nkUInt64Lit}: result.intVal = a.intVal |+| b.intVal
+  else: result.floatVal = a.floatVal + b.floatVal
+
+proc `|*|`(a, b: PNode): PNode =
+  result = copyNode(a)
+  if a.kind in {nkCharLit..nkUInt64Lit}: result.intVal = a.intVal |*| b.intVal
+  else: result.floatVal = a.floatVal * b.floatVal
+
+proc negate(a, b, res: PNode): PNode =
+  if b.kind in {nkCharLit..nkUInt64Lit} and b.intVal != low(BiggestInt):
+    var b = copyNode(b)
+    b.intVal = -b.intVal
+    if a.kind in {nkCharLit..nkUInt64Lit}:
+      b.intVal = b.intVal |+| a.intVal
+      result = b
+    else:
+      result = buildCall(opAdd, a, b)
+  elif b.kind in {nkFloatLit..nkFloat64Lit}:
+    var b = copyNode(b)
+    b.floatVal = -b.floatVal
+    result = buildCall(opAdd, a, b)
+  else:
+    result = res
+
+proc zero(): PNode = nkIntLit.newIntNode(0)
+proc one(): PNode = nkIntLit.newIntNode(1)
+proc minusOne(): PNode = nkIntLit.newIntNode(-1)
+
+proc lowBound*(x: PNode): PNode = 
+  result = nkIntLit.newIntNode(firstOrd(x.typ))
+  result.info = x.info
+
+proc highBound*(x: PNode): PNode =
+  result = if x.typ.skipTypes(abstractInst).kind == tyArray:
+             nkIntLit.newIntNode(lastOrd(x.typ))
+           else:
+             opAdd.buildCall(opLen.buildCall(x), minusOne())
+  result.info = x.info
+
+proc reassociation(n: PNode): PNode =
+  result = n
+  # (foo+5)+5 --> foo+10;  same for '*'
+  case result.getMagic
+  of someAdd:
+    if result[2].isValue and 
+        result[1].getMagic in someAdd and result[1][2].isValue:
+      result = opAdd.buildCall(result[1][1], result[1][2] |+| result[2])
+  of someMul:
+    if result[2].isValue and 
+        result[1].getMagic in someMul and result[1][2].isValue:
+      result = opAdd.buildCall(result[1][1], result[1][2] |*| result[2])
+  else: discard
+
+proc canon*(n: PNode): PNode =
+  # XXX for now only the new code in 'semparallel' uses this
+  if n.safeLen >= 1:
+    result = shallowCopy(n)
+    for i in 0 .. < n.len:
+      result.sons[i] = canon(n.sons[i])
+  else:
+    result = n
+  case result.getMagic
+  of someEq, someAdd, someMul, someMin, someMax:
+    # these are symmetric; put value as last:
+    if result.sons[1].isValue and not result.sons[2].isValue:
+      result = swapArgs(result, result.sons[0].sym)
+      # (4 + foo) + 2 --> (foo + 4) + 2
+  of someHigh:
+    # high == len+(-1)
+    result = opAdd.buildCall(opLen.buildCall(result[1]), minusOne())
+  of mUnaryMinusI, mUnaryMinusI64:
+    result = buildCall(opAdd, result[1], newIntNode(nkIntLit, -1))
+  of someSub:
+    # x - 4  -->  x + (-4)
+    result = negate(result[1], result[2], result)
+  of someLen:
+    result.sons[0] = opLen.newSymNode
+  else: discard
+
+  result = skipConv(result)
+  result = reassociation(result)
+  # most important rule: (x-4) < a.len -->  x < a.len+4
+  case result.getMagic
+  of someLe, someLt:
+    let x = result[1]
+    let y = result[2]
+    if x.kind in nkCallKinds and x.len == 3 and x[2].isValue and 
+        isLetLocation(x[1], true):
+      case x.getMagic
+      of someSub:
+        result = buildCall(result[0].sym, x[1], 
+                           reassociation(opAdd.buildCall(y, x[2])))
+      of someAdd:
+        # Rule A:
+        let plus = negate(y, x[2], nil).reassociation
+        if plus != nil: result = buildCall(result[0].sym, x[1], plus)
+      else: discard
+    elif y.kind in nkCallKinds and y.len == 3 and y[2].isValue and 
+        isLetLocation(y[1], true):
+      # a.len < x-3
+      case y.getMagic
+      of someSub:
+        result = buildCall(result[0].sym, y[1],
+                           reassociation(opAdd.buildCall(x, y[2])))
+      of someAdd:
+        let plus = negate(x, y[2], nil).reassociation
+        # ensure that Rule A will not trigger afterwards with the
+        # additional 'not isLetLocation' constraint:
+        if plus != nil and not isLetLocation(x, true):
+          result = buildCall(result[0].sym, plus, y[1])
+      else: discard
+  else: discard
+
+proc `+@`*(a: PNode; b: BiggestInt): PNode =
+  canon(if b != 0: opAdd.buildCall(a, nkIntLit.newIntNode(b)) else: a)
 
 proc usefulFact(n: PNode): PNode =
   case n.getMagic
   of someEq:
     if skipConv(n.sons[2]).kind == nkNilLit and (
         isLetLocation(n.sons[1], false) or isVar(n.sons[1])):
-      result = buildIsNil(n.sons[1])
+      result = opIsNil.buildCall(n.sons[1])
     else:
       if isLetLocation(n.sons[1], true) or isLetLocation(n.sons[2], true):
         # XXX algebraic simplifications!  'i-1 < a.len' --> 'i < a.len+1'
@@ -217,7 +358,7 @@ proc addFactNeg*(m: var TModel, n: PNode) =
   let n = n.neg
   if n != nil: addFact(m, n)
 
-proc sameTree(a, b: PNode): bool = 
+proc sameTree*(a, b: PNode): bool = 
   result = false
   if a == b:
     result = true
@@ -484,7 +625,7 @@ proc factImplies(fact, prop: PNode): TImplication =
     #  == not a or not b == not (a and b)
     let arg = fact.sons[1]
     case arg.getMagic
-    of mIsNil:
+    of mIsNil, mEqRef:
       return ~factImplies(arg, prop)
     of mAnd:
       # not (a and b)  means  not a or not b:
@@ -519,7 +660,144 @@ proc doesImply*(facts: TModel, prop: PNode): TImplication =
       if result != impUnknown: return
 
 proc impliesNotNil*(facts: TModel, arg: PNode): TImplication =
-  result = doesImply(facts, buildIsNil(arg).neg)
+  result = doesImply(facts, opIsNil.buildCall(arg).neg)
+
+proc simpleSlice*(a, b: PNode): BiggestInt =
+  # returns 'c' if a..b matches (i+c)..(i+c), -1 otherwise. (i)..(i) is matched
+  # as if it is (i+0)..(i+0).
+  if guards.sameTree(a, b):
+    if a.getMagic in someAdd and a[2].kind in {nkCharLit..nkUInt64Lit}:
+      result = a[2].intVal
+    else:
+      result = 0
+  else:
+    result = -1
+
+proc pleViaModel(model: TModel; aa, bb: PNode): TImplication
+
+proc ple(m: TModel; a, b: PNode): TImplication =
+  template `<=?`(a,b): expr = ple(m,a,b) == impYes
+  #   0 <= 3
+  if a.isValue and b.isValue:
+    return if leValue(a, b): impYes else: impNo
+
+  # use type information too:  x <= 4  iff  high(x) <= 4
+  if b.isValue and a.typ != nil and a.typ.isOrdinalType:
+    if lastOrd(a.typ) <= b.intVal: return impYes
+  # 3 <= x   iff  low(x) <= 3
+  if a.isValue and b.typ != nil and b.typ.isOrdinalType:
+    if firstOrd(b.typ) <= a.intVal: return impYes
+
+  # x <= x
+  if sameTree(a, b): return impYes
+
+  # 0 <= x.len
+  if b.getMagic in someLen and a.isValue:
+    if a.intVal <= 0: return impYes
+
+  #   x <= y+c  if 0 <= c and x <= y
+  if b.getMagic in someAdd and zero() <=? b[2] and a <=? b[1]: return impYes
+
+  #   x+c <= y  if c <= 0 and x <= y
+  if a.getMagic in someAdd and a[2] <=? zero() and a[1] <=? b: return impYes
+
+  #   x <= y*c  if  1 <= c and x <= y  and 0 <= y
+  if b.getMagic in someMul:
+    if a <=? b[1] and one() <=? b[2] and zero() <=? b[1]: return impYes
+
+  #   x div c <= y   if   1 <= c  and  0 <= y  and x <= y:
+  if a.getMagic in someDiv:
+    if one() <=? a[2] and zero() <=? b and a[1] <=? b: return impYes
+
+  # slightly subtle:
+  # x <= max(y, z)  iff x <= y or x <= z
+  # note that 'x <= max(x, z)' is a special case of the above rule
+  if b.getMagic in someMax:
+    if a <=? b[1] or a <=? b[2]: return impYes
+
+  # min(x, y) <= z  iff x <= z or y <= z
+  if a.getMagic in someMin:
+    if a[1] <=? b or a[2] <=? b: return impYes
+
+  # use the knowledge base:
+  return pleViaModel(m, a, b)
+  #return doesImply(m, opLe.buildCall(a, b))
+
+type TReplacements = seq[tuple[a,b: PNode]]
+
+proc replaceSubTree(n, x, by: PNode): PNode =
+  if sameTree(n, x):
+    result = by
+  elif hasSubTree(n, x):
+    result = shallowCopy(n)
+    for i in 0 .. safeLen(n)-1:
+      result.sons[i] = replaceSubTree(n.sons[i], x, by)
+  else:
+    result = n
+
+proc applyReplacements(n: PNode; rep: TReplacements): PNode =
+  result = n
+  for x in rep: result = result.replaceSubTree(x.a, x.b)
+
+proc pleViaModelRec(m: var TModel; a, b: PNode): TImplication =
+  # now check for inferrable facts: a <= b and b <= c  implies a <= c
+  for i in 0..m.high:
+    let fact = m[i]
+    if fact != nil and fact.getMagic in someLe:
+      # x <= y implies a <= b  if  a <= x and y <= b
+      let x = fact[1]
+      let y = fact[2]
+      # mark as used:
+      m[i] = nil
+      if ple(m, a, x) == impYes:
+        if ple(m, y, b) == impYes: return impYes
+        #if pleViaModelRec(m, y, b): return impYes
+      # fact:  16 <= i
+      #         x    y
+      # question: i <= 15? no!
+      result = impliesLe(fact, a, b)
+      if result != impUnknown: return result
+      if sameTree(y, a):
+        result = ple(m, x, b)
+        if result != impUnknown: return result
+
+proc pleViaModel(model: TModel; aa, bb: PNode): TImplication =
+  # compute replacements:
+  var replacements: TReplacements = @[]
+  for fact in model:
+    if fact != nil and fact.getMagic in someEq:
+      let a = fact[1]
+      let b = fact[2]
+      if a.kind == nkSym: replacements.add((a,b))
+      else: replacements.add((b,a))
+  var m: TModel
+  var a = aa
+  var b = bb
+  if replacements.len > 0:
+    m = @[]
+    # make the other facts consistent:
+    for fact in model:
+      if fact != nil and fact.getMagic notin someEq:
+        # XXX 'canon' should not be necessary here, but it is
+        m.add applyReplacements(fact, replacements).canon
+    a = applyReplacements(aa, replacements)
+    b = applyReplacements(bb, replacements)
+  else:
+    # we have to make a copy here, because the model will be modified:
+    m = model
+  result = pleViaModelRec(m, a, b)
+
+proc proveLe*(m: TModel; a, b: PNode): TImplication =
+  let x = canon(opLe.buildCall(a, b))
+  #echo "ROOT ", renderTree(x[1]), " <=? ", renderTree(x[2])
+  result = ple(m, x[1], x[2])
+  if result == impUnknown:
+    # try an alternative:  a <= b  iff  not (b < a)  iff  not (b+1 <= a):
+    let y = canon(opLe.buildCall(opAdd.buildCall(b, one()), a))
+    result = ~ple(m, y[1], y[2])
+
+proc addFactLe*(m: var TModel; a, b: PNode) =
+  m.add canon(opLe.buildCall(a, b))
 
 proc settype(n: PNode): PType =
   result = newType(tySet, n.typ.owner)
diff --git a/compiler/importer.nim b/compiler/importer.nim
index 7a73f2bbf..b4cae017e 100644
--- a/compiler/importer.nim
+++ b/compiler/importer.nim
@@ -93,7 +93,7 @@ proc rawImportSymbol(c: PContext, s: PSym) =
     if hasPattern(s): addPattern(c, s)
 
 proc importSymbol(c: PContext, n: PNode, fromMod: PSym) = 
-  let ident = lookups.considerAcc(n)
+  let ident = lookups.considerQuotedIdent(n)
   let s = strTableGet(fromMod.tab, ident)
   if s == nil:
     localError(n.info, errUndeclaredIdentifier, ident.s)
@@ -193,7 +193,7 @@ proc evalImportExcept*(c: PContext, n: PNode): PNode =
     addDecl(c, m)               # add symbol to symbol table of module
     var exceptSet = initIntSet()
     for i in countup(1, sonsLen(n) - 1): 
-      let ident = lookups.considerAcc(n.sons[i])
+      let ident = lookups.considerQuotedIdent(n.sons[i])
       exceptSet.incl(ident.id)
     importAllSymbolsExcept(c, m, exceptSet)
     importForwarded(c, m.ast, exceptSet)
diff --git a/compiler/lambdalifting.nim b/compiler/lambdalifting.nim
index c5b9d0f00..ee380b305 100644
--- a/compiler/lambdalifting.nim
+++ b/compiler/lambdalifting.nim
@@ -103,43 +103,50 @@ discard """
 
 """
 
+# Important things to keep in mind:
+# * Don't base the analysis on nkProcDef et al. This doesn't work for
+#   instantiated (formerly generic) procs. The analysis has to look at nkSym.
+#   This also means we need to prevent the same proc is processed multiple
+#   times via the 'processed' set.
+# * Keep in mind that the owner of some temporaries used to be unreliable.
+# * For closure iterators we merge the "real" potential closure with the
+#   local storage requirements for efficiency. This means closure iterators
+#   have slightly different semantics from ordinary closures.
+
+
 const
   upName* = ":up" # field name for the 'up' reference
-  paramName* = ":env"
+  paramName* = ":envP"
   envName* = ":env"
 
 type
-  PInnerContext = ref TInnerContext
   POuterContext = ref TOuterContext
 
+  TIter = object
+    fn, closureParam, state, resultSym: PSym # most are only valid if
+                                             # fn.kind == skClosureIterator
+    obj: PType
+    
   PEnv = ref TEnv
-  TDep = tuple[e: PEnv, field: PSym]
   TEnv {.final.} = object of TObject
-    attachedNode: PNode
+    attachedNode, replacementNode: PNode
     createdVar: PSym        # if != nil it is a used environment
     createdVarComesFromIter: bool
     capturedVars: seq[PSym] # captured variables in this environment
-    deps: seq[TDep]         # dependencies
-    up: PEnv
+    up, next: PEnv          # outer scope and next to keep all in a list
+    upField: PSym        # if != nil the dependency to the outer scope is used
     obj: PType
-  
-  TInnerContext = object
-    fn: PSym
-    closureParam: PSym
-    localsToAccess: TIdNodeTable
+    fn: PSym                # function that belongs to this scope;
+                            # if up.fn != fn then we cross function boundaries.
+                            # This is an important case to consider.
+    vars: TIntSet           # variables belonging to this environment
     
   TOuterContext = object
     fn: PSym # may also be a module!
-    currentEnv: PEnv
-    isIter: bool   # first class iterator?
+    head: PEnv
     capturedVars, processed: TIntSet
-    localsToEnv: TIdTable # PSym->PEnv mapping
     localsToAccess: TIdNodeTable
     lambdasToEnv: TIdTable # PSym->PEnv mapping
-    up: POuterContext
-
-    closureParam, state, resultSym: PSym # only if isIter
-    obj: PType # only if isIter
 
 proc getStateType(iter: PSym): PType =
   var n = newNodeI(nkRange, iter.info)
@@ -147,12 +154,20 @@ proc getStateType(iter: PSym): PType =
   addSon(n, newIntNode(nkIntLit, 0))
   result = newType(tyRange, iter)
   result.n = n
-  rawAddSon(result, getSysType(tyInt))
+  var intType = nilOrSysInt()
+  if intType.isNil: intType = newType(tyInt, iter)
+  rawAddSon(result, intType)
 
 proc createStateField(iter: PSym): PSym =
   result = newSym(skField, getIdent(":state"), iter, iter.info)
   result.typ = getStateType(iter)
 
+proc createEnvObj(owner: PSym): PType =
+  # YYY meh, just add the state field for every closure for now, it's too
+  # hard to figure out if it comes from a closure iterator:
+  result = createObj(owner, owner.info)
+  rawAddField(result, createStateField(owner))
+
 proc newIterResult(iter: PSym): PSym =
   if resultPos < iter.ast.len:
     result = iter.ast.sons[resultPos].sym
@@ -164,6 +179,7 @@ proc newIterResult(iter: PSym): PSym =
     iter.ast.add newSymNode(result)
 
 proc addHiddenParam(routine: PSym, param: PSym) =
+  assert param.kind == skParam
   var params = routine.ast.sons[paramsPos]
   # -1 is correct here as param.position is 0 based but we have at position 0
   # some nkEffect node:
@@ -175,7 +191,7 @@ proc addHiddenParam(routine: PSym, param: PSym) =
 proc getHiddenParam(routine: PSym): PSym =
   let params = routine.ast.sons[paramsPos]
   let hidden = lastSon(params)
-  assert hidden.kind == nkSym
+  internalAssert hidden.kind == nkSym and hidden.sym.kind == skParam
   result = hidden.sym
 
 proc getEnvParam(routine: PSym): PSym =
@@ -184,161 +200,191 @@ proc getEnvParam(routine: PSym): PSym =
   if hidden.kind == nkSym and hidden.sym.name.s == paramName:
     result = hidden.sym
 
-proc initIterContext(c: POuterContext, iter: PSym) =
-  c.fn = iter
-  c.capturedVars = initIntSet()
-
-  var cp = getEnvParam(iter)
-  if cp == nil:
-    c.obj = createObj(iter, iter.info)
-
-    cp = newSym(skParam, getIdent(paramName), iter, iter.info)
-    incl(cp.flags, sfFromGeneric)
-    cp.typ = newType(tyRef, iter)
-    rawAddSon(cp.typ, c.obj)
-    addHiddenParam(iter, cp)
-
-    c.state = createStateField(iter)
-    addField(c.obj, c.state)
-  else:
-    c.obj = cp.typ.sons[0]
-    assert c.obj.kind == tyObject
-    if c.obj.n.len > 0:
-      c.state = c.obj.n[0].sym
+proc initIter(iter: PSym): TIter =
+  result.fn = iter
+  if iter.kind == skClosureIterator:
+    var cp = getEnvParam(iter)
+    if cp == nil:
+      result.obj = createEnvObj(iter)
+
+      cp = newSym(skParam, getIdent(paramName), iter, iter.info)
+      incl(cp.flags, sfFromGeneric)
+      cp.typ = newType(tyRef, iter)
+      rawAddSon(cp.typ, result.obj)
+      addHiddenParam(iter, cp)
     else:
-      c.state = createStateField(iter)
-      addField(c.obj, c.state)
-
-  c.closureParam = cp
-  if iter.typ.sons[0] != nil:
-    c.resultSym = newIterResult(iter)
-    #iter.ast.add(newSymNode(c.resultSym))
-
-proc newOuterContext(fn: PSym, up: POuterContext = nil): POuterContext =
+      result.obj = cp.typ.sons[0]
+      assert result.obj.kind == tyObject
+    internalAssert result.obj.n.len > 0
+    result.state = result.obj.n[0].sym
+    result.closureParam = cp
+    if iter.typ.sons[0] != nil:
+      result.resultSym = newIterResult(iter)
+      #iter.ast.add(newSymNode(c.resultSym))
+
+proc newOuterContext(fn: PSym): POuterContext =
   new(result)
   result.fn = fn
   result.capturedVars = initIntSet()
   result.processed = initIntSet()
   initIdNodeTable(result.localsToAccess)
-  initIdTable(result.localsToEnv)
   initIdTable(result.lambdasToEnv)
-  result.isIter = fn.kind == skClosureIterator
-  if result.isIter: initIterContext(result, fn)
 
-proc newInnerContext(fn: PSym): PInnerContext =
+proc newEnv(o: POuterContext; up: PEnv, n: PNode; owner: PSym): PEnv =
   new(result)
-  result.fn = fn
-  initIdNodeTable(result.localsToAccess)
-
-proc newEnv(outerProc: PSym, up: PEnv, n: PNode): PEnv =
-  new(result)
-  result.deps = @[]
   result.capturedVars = @[]
-  result.obj = createObj(outerProc, outerProc.info)
   result.up = up
   result.attachedNode = n
+  result.fn = owner
+  result.vars = initIntSet()
+  result.next = o.head
+  o.head = result
+  if owner.kind != skModule and (up == nil or up.fn != owner):
+    let param = getEnvParam(owner)
+    if param != nil:
+      result.obj = param.typ.sons[0]
+      assert result.obj.kind == tyObject
+  if result.obj.isNil:
+    result.obj = createEnvObj(owner)
 
 proc addCapturedVar(e: PEnv, v: PSym) =
   for x in e.capturedVars:
     if x == v: return
-  # XXX meh, just add the state field for every closure for now, it's too
-  # hard to figure out if it comes from a closure iterator:
-  if e.obj.n.len == 0: addField(e.obj, createStateField(v.owner))
   e.capturedVars.add(v)
   addField(e.obj, v)
-  
-proc addDep(e, d: PEnv, owner: PSym): PSym =
-  for x, field in items(e.deps):
-    if x == d: return field
-  var pos = sonsLen(e.obj.n)
-  result = newSym(skField, getIdent(upName & $pos), owner, owner.info)
-  result.typ = newType(tyRef, owner)
-  result.position = pos
-  assert d.obj != nil
-  rawAddSon(result.typ, d.obj)
-  addField(e.obj, result)
-  e.deps.add((d, result))
 
 proc newCall(a, b: PSym): PNode =
   result = newNodeI(nkCall, a.info)
   result.add newSymNode(a)
   result.add newSymNode(b)
 
-proc isInnerProc(s, outerProc: PSym): bool {.inline.} =
-  result = s.kind in {skProc, skMethod, skConverter, skClosureIterator} and
-           s.skipGenericOwner == outerProc
+proc isInnerProc(s, outerProc: PSym): bool =
+  if s.kind in {skProc, skMethod, skConverter, skClosureIterator}:
+    var owner = s.skipGenericOwner
+    while true:
+      if owner.isNil: return false
+      if owner == outerProc: return true
+      owner = owner.owner
   #s.typ.callConv == ccClosure
 
-proc addClosureParam(i: PInnerContext, e: PEnv) =
-  var cp = getEnvParam(i.fn)
+proc addClosureParam(fn: PSym; e: PEnv) =
+  var cp = getEnvParam(fn)
   if cp == nil:
-    cp = newSym(skParam, getIdent(paramName), i.fn, i.fn.info)
+    cp = newSym(skParam, getIdent(paramName), fn, fn.info)
     incl(cp.flags, sfFromGeneric)
-    cp.typ = newType(tyRef, i.fn)
+    cp.typ = newType(tyRef, fn)
     rawAddSon(cp.typ, e.obj)
-    addHiddenParam(i.fn, cp)
-  else:
-    e.obj = cp.typ.sons[0]
-    assert e.obj.kind == tyObject
-  i.closureParam = cp
-  #echo "closure param added for ", i.fn.name.s, " ", i.fn.id
-
-proc dummyClosureParam(o: POuterContext, i: PInnerContext) =
-  var e = o.currentEnv
-  if idTableGet(o.lambdasToEnv, i.fn) == nil:
-    idTablePut(o.lambdasToEnv, i.fn, e)
-  if i.closureParam == nil: addClosureParam(i, e)
+    addHiddenParam(fn, cp)
+    #else:
+    #cp.typ.sons[0] = e.obj
+    #assert e.obj.kind == tyObject
 
 proc illegalCapture(s: PSym): bool {.inline.} =
   result = skipTypes(s.typ, abstractInst).kind in 
                    {tyVar, tyOpenArray, tyVarargs} or
       s.kind == skResult
 
-proc captureVar(o: POuterContext, i: PInnerContext, local: PSym, 
-                info: TLineInfo) =
-  # for inlined variables the owner is still wrong, so it can happen that it's
-  # not a captured variable at all ... *sigh* 
-  var it = PEnv(idTableGet(o.localsToEnv, local))
-  if it == nil: return
-  
-  if illegalCapture(local) or o.fn.id != local.owner.id or 
-      i.fn.typ.callConv notin {ccClosure, ccDefault}:
-    # Currently captures are restricted to a single level of nesting:
-    localError(info, errIllegalCaptureX, local.name.s)
-  i.fn.typ.callConv = ccClosure
-  #echo "captureVar ", i.fn.name.s, i.fn.id, " ", local.name.s, local.id
-
-  incl(i.fn.typ.flags, tfCapturesEnv)
-
-  # we need to remember which inner most closure belongs to this lambda:
-  var e = o.currentEnv
-  if idTableGet(o.lambdasToEnv, i.fn) == nil:
-    idTablePut(o.lambdasToEnv, i.fn, e)
-
-  # variable already captured:
-  if idNodeTableGet(i.localsToAccess, local) != nil: return
-  if i.closureParam == nil: addClosureParam(i, e)
-  
-  # check which environment `local` belongs to:
-  var access = newSymNode(i.closureParam)
-  addCapturedVar(it, local)
-  if it == e:
-    # common case: local directly in current environment:
-    discard
-  else:
-    # it's in some upper environment:
-    access = indirectAccess(access, addDep(e, it, i.fn), info)
-  access = indirectAccess(access, local, info)
-  if o.isIter:
-    if not containsOrIncl(o.capturedVars, local.id): addField(o.obj, local)
-  else:
-    incl(o.capturedVars, local.id)
-  idNodeTablePut(i.localsToAccess, local, access)
-
 proc interestingVar(s: PSym): bool {.inline.} =
   result = s.kind in {skVar, skLet, skTemp, skForVar, skParam, skResult} and
     sfGlobal notin s.flags
 
+proc nestedAccess(top: PEnv; local: PSym): PNode =
+  # Parts after the transformation are in []:
+  #
+  #  proc main =
+  #    var [:env.]foo = 23
+  #    proc outer(:paramO) =
+  #      [var :envO; createClosure(:envO); :envO.up = paramO]
+  #      proc inner(:paramI) =
+  #        echo [:paramI.up.]foo
+  #      inner([:envO])
+  #    outer([:env])
+  if not interestingVar(local) or top.fn == local.owner:
+    return nil
+  # check it's in fact a captured variable:
+  var it = top
+  while it != nil:
+    if it.vars.contains(local.id): break
+    it = it.up
+  if it == nil: return nil
+  let envParam = top.fn.getEnvParam
+  internalAssert(not envParam.isNil)
+  var access = newSymNode(envParam)
+  it = top.up
+  while it != nil:
+    if it.vars.contains(local.id):
+      access = indirectAccess(access, local, local.info)
+      return access
+    internalAssert it.upField != nil
+    access = indirectAccess(access, it.upField, local.info)
+    it = it.up
+  when false:
+    # Type based expression construction works too, but turned out to hide
+    # other bugs:
+    while true:
+      let obj = access.typ.sons[0]
+      let field = getFieldFromObj(obj, local)
+      if field != nil:
+        return rawIndirectAccess(access, field, local.info)
+      let upField = lookupInRecord(obj.n, getIdent(upName))
+      if upField == nil: break
+      access = rawIndirectAccess(access, upField, local.info)
+  return nil
+
+proc createUpField(obj, fieldType: PType): PSym =
+  let pos = obj.n.len
+  result = newSym(skField, getIdent(upName), obj.owner, obj.owner.info)
+  result.typ = newType(tyRef, obj.owner)
+  result.position = pos
+  rawAddSon(result.typ, fieldType)
+  #rawAddField(obj, result)
+  addField(obj, result)
+
+proc captureVar(o: POuterContext; top: PEnv; local: PSym; 
+                info: TLineInfo): bool =
+  # first check if we should be concerned at all:
+  var it = top
+  while it != nil:
+    if it.vars.contains(local.id): break
+    it = it.up
+  if it == nil: return false
+  # yes, so mark every 'up' pointer as taken:
+  if illegalCapture(local) or top.fn.typ.callConv notin {ccClosure, ccDefault}:
+    localError(info, errIllegalCaptureX, local.name.s)
+  it = top
+  while it != nil:
+    if it.vars.contains(local.id): break
+    # keep in mind that the first element of the chain belong to top.fn itself
+    # and these don't need any upFields
+    if it.upField == nil and it.up != nil and it.fn != top.fn:
+      it.upField = createUpField(it.obj, it.up.obj)
+
+    if it.fn != local.owner:
+      it.fn.typ.callConv = ccClosure
+      incl(it.fn.typ.flags, tfCapturesEnv)
+
+      var u = it.up
+      while u != nil and u.fn == it.fn: u = u.up
+      addClosureParam(it.fn, u)
+
+      if idTableGet(o.lambdasToEnv, it.fn) == nil:
+        if u != nil: idTablePut(o.lambdasToEnv, it.fn, u)
+
+    it = it.up
+  # don't do this: 'top' might not require a closure:
+  #if idTableGet(o.lambdasToEnv, it.fn) == nil:
+  #  idTablePut(o.lambdasToEnv, it.fn, top)
+
+  # mark as captured:
+  #if top.iter != nil:
+  #  if not containsOrIncl(o.capturedVars, local.id):
+  #    #addField(top.iter.obj, local)
+  #    addCapturedVar(it, local)
+  #else:
+  incl(o.capturedVars, local.id)
+  addCapturedVar(it, local)
+  result = true
+
 proc semCaptureSym*(s, owner: PSym) =
   if interestingVar(s) and owner.id != s.owner.id and s.kind != skResult:
     if owner.typ != nil and not isGenericRoutine(owner):
@@ -350,28 +396,20 @@ proc semCaptureSym*(s, owner: PSym) =
     # since the analysis is not entirely correct, we don't set 'tfCapturesEnv'
     # here
 
-proc gatherVars(o: POuterContext, i: PInnerContext, n: PNode) = 
-  # gather used vars for closure generation
-  if n == nil: return
+proc gatherVars(o: POuterContext; e: PEnv; n: PNode): int =
+  # gather used vars for closure generation; returns number of captured vars
+  if n == nil: return 0
   case n.kind
   of nkSym:
     var s = n.sym
-    if interestingVar(s) and i.fn.id != s.owner.id:
-      captureVar(o, i, s, n.info)
-    elif s.kind in {skProc, skMethod, skConverter} and
-            s.skipGenericOwner == o.fn and 
-            tfCapturesEnv in s.typ.flags and s != i.fn:
-      # call to some other inner proc; we need to track the dependencies for
-      # this:
-      let env = PEnv(idTableGet(o.lambdasToEnv, i.fn))
-      if env == nil: internalError(n.info, "no environment computed")
-      if o.currentEnv != env:
-        discard addDep(o.currentEnv, env, i.fn)
-        internalError(n.info, "too complex environment handling required")
-  of nkEmpty..pred(nkSym), succ(nkSym)..nkNilLit, nkClosure: discard
+    if interestingVar(s) and e.fn != s.owner:
+      if captureVar(o, e, s, n.info): result = 1
+  of nkEmpty..pred(nkSym), succ(nkSym)..nkNilLit, nkClosure, nkProcDef, 
+     nkMethodDef, nkConverterDef, nkMacroDef, nkTemplateDef, nkTypeSection:
+    discard
   else:
-    for k in countup(0, sonsLen(n) - 1): 
-      gatherVars(o, i, n.sons[k])
+    for k in countup(0, sonsLen(n) - 1):
+      result += gatherVars(o, e, n.sons[k])
 
 proc generateThunk(prc: PNode, dest: PType): PNode =
   ## Converts 'prc' into '(thunk, nil)' so that it's compatible with
@@ -403,61 +441,112 @@ proc makeClosure(prc, env: PSym, info: TLineInfo): PNode =
   else:
     result.add(newSymNode(env))
 
-proc transformInnerProc(o: POuterContext, i: PInnerContext, n: PNode): PNode =
+proc newClosureCreationVar(e: PEnv): PSym =
+  result = newSym(skVar, getIdent(envName), e.fn, e.attachedNode.info)
+  incl(result.flags, sfShadowed)
+  result.typ = newType(tyRef, e.fn)
+  result.typ.rawAddSon(e.obj)
+
+proc getClosureVar(e: PEnv): PSym =
+  if e.createdVar == nil:
+    result = newClosureCreationVar(e)
+    e.createdVar = result
+  else:
+    result = e.createdVar
+
+proc findEnv(o: POuterContext; s: PSym): PEnv =
+  var env = o.head
+  while env != nil:
+    if env.fn == s: break
+    env = env.next
+  internalAssert env != nil and env.up != nil
+  result = env.up
+  while result.fn == s: result = result.up
+
+proc transformInnerProc(o: POuterContext; e: PEnv, n: PNode): PNode =
   case n.kind
   of nkEmpty..pred(nkSym), succ(nkSym)..nkNilLit: discard
   of nkSym:
     let s = n.sym
-    if s == i.fn: 
+    if s == e.fn:
       # recursive calls go through (lambda, hiddenParam):
-      assert i.closureParam != nil, i.fn.name.s
-      result = makeClosure(s, i.closureParam, n.info)
+      result = makeClosure(s, getEnvParam(s), n.info)
     elif isInnerProc(s, o.fn) and s.typ.callConv == ccClosure:
-      # ugh: call to some other inner proc; 
-      assert i.closureParam != nil
-      # XXX this is not correct in general! may also be some 'closure.upval'
-      result = makeClosure(s, i.closureParam, n.info)
+      # ugh: call to some other inner proc;
+      result = makeClosure(s, findEnv(o, s).getClosureVar, n.info)
     else:
       # captured symbol?
-      result = idNodeTableGet(i.localsToAccess, n.sym)
-  of nkLambdaKinds, nkIteratorDef:
-    if n.typ != nil:
-      result = transformInnerProc(o, i, n.sons[namePos])
+      result = nestedAccess(e, n.sym)
+      #result = idNodeTableGet(i.localsToAccess, n.sym)
+    #of nkLambdaKinds, nkIteratorDef:
+    #  if n.typ != nil:
+    #    result = transformInnerProc(o, e, n.sons[namePos])
+    #of nkClosure:
+    #  let x = transformInnerProc(o, e, n.sons[0])
+    #  if x != nil: n.sons[0] = x
   of nkProcDef, nkMethodDef, nkConverterDef, nkMacroDef, nkTemplateDef,
-      nkClosure:
+     nkLambdaKinds, nkIteratorDef, nkClosure:
     # don't recurse here:
     discard
   else:
     for j in countup(0, sonsLen(n) - 1):
-      let x = transformInnerProc(o, i, n.sons[j])
+      let x = transformInnerProc(o, e, n.sons[j])
       if x != nil: n.sons[j] = x
 
 proc closureCreationPoint(n: PNode): PNode =
-  result = newNodeI(nkStmtList, n.info)
-  result.add(emptyNode)
-  result.add(n)
-
-proc searchForInnerProcs(o: POuterContext, n: PNode) =
+  if n.kind == nkStmtList and n.len >= 1 and n[0].kind == nkEmpty:
+    # we already have a free slot
+    result = n
+  else:
+    result = newNodeI(nkStmtList, n.info)
+    result.add(emptyNode)
+    result.add(n)
+  #result.flags.incl nfLL
+
+proc addParamsToEnv(fn: PSym; env: PEnv) =
+  let params = fn.typ.n
+  for i in 1.. <params.len: 
+    if params.sons[i].kind != nkSym:
+      internalError(params.info, "liftLambdas: strange params")
+    let param = params.sons[i].sym
+    env.vars.incl(param.id)
+  # put the 'result' into the environment so it can be captured:
+  let ast = fn.ast
+  if resultPos < sonsLen(ast) and ast.sons[resultPos].kind == nkSym:
+    env.vars.incl(ast.sons[resultPos].sym.id)
+
+proc searchForInnerProcs(o: POuterContext, n: PNode, env: PEnv) =
   if n == nil: return
   case n.kind
-  of nkEmpty..pred(nkSym), succ(nkSym)..nkNilLit: 
+  of nkEmpty..pred(nkSym), succ(nkSym)..nkNilLit:
     discard
   of nkSym:
-    if isInnerProc(n.sym, o.fn) and not containsOrIncl(o.processed, n.sym.id):
-      var inner = newInnerContext(n.sym)
-      let body = n.sym.getBody
-      gatherVars(o, inner, body)
+    let fn = n.sym
+    if isInnerProc(fn, o.fn) and not containsOrIncl(o.processed, fn.id):
+      let body = fn.getBody
+
+      # handle deeply nested captures:
+      let ex = closureCreationPoint(body)
+      let envB = newEnv(o, env, ex, fn)
+      addParamsToEnv(fn, envB)
+      searchForInnerProcs(o, body, envB)
+      fn.ast.sons[bodyPos] = ex
+      
+      let capturedCounter = gatherVars(o, envB, body)
       # dummy closure param needed?
-      if inner.closureParam == nil and n.sym.typ.callConv == ccClosure:
+      if capturedCounter == 0 and fn.typ.callConv == ccClosure:
         #assert tfCapturesEnv notin n.sym.typ.flags
-        dummyClosureParam(o, inner)
-      # only transform if it really needs a closure:
-      if inner.closureParam != nil:
-        let ti = transformInnerProc(o, inner, body)
-        if ti != nil: n.sym.ast.sons[bodyPos] = ti
+        if idTableGet(o.lambdasToEnv, fn) == nil:
+          idTablePut(o.lambdasToEnv, fn, env)
+        addClosureParam(fn, env)
+
+      elif fn.getEnvParam != nil:
+        # only transform if it really needs a closure:
+        let ti = transformInnerProc(o, envB, body)
+        if ti != nil: fn.ast.sons[bodyPos] = ti
   of nkLambdaKinds, nkIteratorDef:
     if n.typ != nil:
-      searchForInnerProcs(o, n.sons[namePos])
+      searchForInnerProcs(o, n.sons[namePos], env)
   of nkWhileStmt, nkForStmt, nkParForStmt, nkBlockStmt:
     # some nodes open a new scope, so they are candidates for the insertion
     # of closure creation; however for simplicity we merge closures between
@@ -465,14 +554,11 @@ proc searchForInnerProcs(o: POuterContext, n: PNode) =
     # yield observable changes in semantics. For Zahary we also
     # include ``nkBlock``.
     var body = n.len-1
-    for i in countup(0, body - 1): searchForInnerProcs(o, n.sons[i])
+    for i in countup(0, body - 1): searchForInnerProcs(o, n.sons[i], env)
     # special handling for the loop body:
-    let oldEnv = o.currentEnv
     let ex = closureCreationPoint(n.sons[body])
-    o.currentEnv = newEnv(o.fn, oldEnv, ex)
-    searchForInnerProcs(o, n.sons[body])
+    searchForInnerProcs(o, n.sons[body], newEnv(o, env, ex, env.fn))
     n.sons[body] = ex
-    o.currentEnv = oldEnv
   of nkVarSection, nkLetSection:
     # we need to compute a mapping var->declaredBlock. Note: The definition
     # counts, not the block where it is captured!
@@ -481,26 +567,29 @@ proc searchForInnerProcs(o: POuterContext, n: PNode) =
       if it.kind == nkCommentStmt: discard
       elif it.kind == nkIdentDefs:
         var L = sonsLen(it)
-        if it.sons[0].kind != nkSym: internalError(it.info, "transformOuter")
-        #echo "set: ", it.sons[0].sym.name.s, " ", o.currentBlock == nil
-        idTablePut(o.localsToEnv, it.sons[0].sym, o.currentEnv)
-        searchForInnerProcs(o, it.sons[L-1])
+        if it.sons[0].kind == nkSym:
+          # this can be false for recursive invokations that already
+          # transformed it into 'env.varName':
+          env.vars.incl(it.sons[0].sym.id)
+        searchForInnerProcs(o, it.sons[L-1], env)
       elif it.kind == nkVarTuple:
         var L = sonsLen(it)
         for j in countup(0, L-3):
           #echo "set: ", it.sons[j].sym.name.s, " ", o.currentBlock == nil
-          idTablePut(o.localsToEnv, it.sons[j].sym, o.currentEnv)
-        searchForInnerProcs(o, it.sons[L-1])
+          if it.sons[j].kind == nkSym:
+            env.vars.incl(it.sons[j].sym.id)
+        searchForInnerProcs(o, it.sons[L-1], env)
       else:
-        internalError(it.info, "transformOuter")
+        internalError(it.info, "searchForInnerProcs")
+  of nkClosure:
+    searchForInnerProcs(o, n.sons[0], env)
   of nkProcDef, nkMethodDef, nkConverterDef, nkMacroDef, nkTemplateDef, 
-     nkClosure, nkTypeSection:
+     nkTypeSection:
     # don't recurse here:
-    # XXX recurse here and setup 'up' pointers
     discard
   else:
     for i in countup(0, sonsLen(n) - 1):
-      searchForInnerProcs(o, n.sons[i])
+      searchForInnerProcs(o, n.sons[i], env)
 
 proc newAsgnStmt(le, ri: PNode, info: TLineInfo): PNode = 
   # Bugfix: unfortunately we cannot use 'nkFastAsgn' here as that would
@@ -512,19 +601,6 @@ proc newAsgnStmt(le, ri: PNode, info: TLineInfo): PNode =
   result.sons[0] = le
   result.sons[1] = ri
 
-proc newClosureCreationVar(o: POuterContext; e: PEnv): PSym =
-  result = newSym(skVar, getIdent(envName), o.fn, e.attachedNode.info)
-  incl(result.flags, sfShadowed)
-  result.typ = newType(tyRef, o.fn)
-  result.typ.rawAddSon(e.obj)
-
-proc getClosureVar(o: POuterContext; e: PEnv): PSym =
-  if e.createdVar == nil:
-    result = newClosureCreationVar(o, e)
-    e.createdVar = result
-  else:
-    result = e.createdVar
-
 proc rawClosureCreation(o: POuterContext, scope: PEnv; env: PSym): PNode =
   result = newNodeI(nkStmtList, env.info)
   var v = newNodeI(nkVarSection, env.info)
@@ -548,21 +624,25 @@ proc rawClosureCreation(o: POuterContext, scope: PEnv; env: PSym): PNode =
       idNodeTablePut(o.localsToAccess, local, fieldAccess)
     else:
       result.add(newAsgnStmt(fieldAccess, existing, env.info))
-  # add support for 'up' references:
-  for e, field in items(scope.deps):
-    # add ``env.up = env2``
-    result.add(newAsgnStmt(indirectAccess(env, field, env.info),
-               newSymNode(getClosureVar(o, e)), env.info))
-  
+  if scope.upField != nil:
+    # "up" chain has been used:
+    if scope.up.fn != scope.fn:
+      # crosses function boundary:
+      result.add(newAsgnStmt(indirectAccess(env, scope.upField, env.info),
+                 newSymNode(getEnvParam(scope.fn)), env.info))
+    else:
+      result.add(newAsgnStmt(indirectAccess(env, scope.upField, env.info),
+                 newSymNode(getClosureVar(scope.up)), env.info))
+
 proc generateClosureCreation(o: POuterContext, scope: PEnv): PNode =
-  var env = getClosureVar(o, scope)
+  var env = getClosureVar(scope)
   result = rawClosureCreation(o, scope, env)
 
 proc generateIterClosureCreation(o: POuterContext; env: PEnv;
                                  scope: PNode): PSym =
   if env.createdVarComesFromIter or env.createdVar.isNil:
     # we have to create a new closure:
-    result = newClosureCreationVar(o, env)
+    result = newClosureCreationVar(env)
     let cc = rawClosureCreation(o, env, result)
     var insertPoint = scope.sons[0]
     if insertPoint.kind == nkEmpty: scope.sons[0] = cc
@@ -577,21 +657,25 @@ proc generateIterClosureCreation(o: POuterContext; env: PEnv;
 proc interestingIterVar(s: PSym): bool {.inline.} =
   result = s.kind in {skVar, skLet, skTemp, skForVar} and sfGlobal notin s.flags
 
-proc transformOuterProc(o: POuterContext, n: PNode): PNode
+proc transformOuterProc(o: POuterContext, n: PNode, it: TIter): PNode
 
-proc transformYield(c: POuterContext, n: PNode): PNode =
-  inc c.state.typ.n.sons[1].intVal
-  let stateNo = c.state.typ.n.sons[1].intVal
+proc transformYield(c: POuterContext, n: PNode, it: TIter): PNode =
+  assert it.state != nil
+  assert it.state.typ != nil
+  assert it.state.typ.n != nil
+  inc it.state.typ.n.sons[1].intVal
+  let stateNo = it.state.typ.n.sons[1].intVal
 
   var stateAsgnStmt = newNodeI(nkAsgn, n.info)
-  stateAsgnStmt.add(indirectAccess(newSymNode(c.closureParam),c.state,n.info))
+  stateAsgnStmt.add(rawIndirectAccess(newSymNode(it.closureParam),
+                    it.state, n.info))
   stateAsgnStmt.add(newIntTypeNode(nkIntLit, stateNo, getSysType(tyInt)))
 
   var retStmt = newNodeI(nkReturnStmt, n.info)
   if n.sons[0].kind != nkEmpty:
     var a = newNodeI(nkAsgn, n.sons[0].info)
-    var retVal = transformOuterProc(c, n.sons[0])
-    addSon(a, newSymNode(c.resultSym))
+    var retVal = transformOuterProc(c, n.sons[0], it)
+    addSon(a, newSymNode(it.resultSym))
     addSon(a, if retVal.isNil: n.sons[0] else: retVal)
     retStmt.add(a)
   else:
@@ -605,17 +689,18 @@ proc transformYield(c: POuterContext, n: PNode): PNode =
   result.add(retStmt)
   result.add(stateLabelStmt)
 
-proc transformReturn(c: POuterContext, n: PNode): PNode =
+proc transformReturn(c: POuterContext, n: PNode, it: TIter): PNode =
   result = newNodeI(nkStmtList, n.info)
   var stateAsgnStmt = newNodeI(nkAsgn, n.info)
-  stateAsgnStmt.add(indirectAccess(newSymNode(c.closureParam),c.state,n.info))
+  stateAsgnStmt.add(rawIndirectAccess(newSymNode(it.closureParam), it.state,
+                    n.info))
   stateAsgnStmt.add(newIntTypeNode(nkIntLit, -1, getSysType(tyInt)))
   result.add(stateAsgnStmt)
   result.add(n)
 
-proc outerProcSons(o: POuterContext, n: PNode) =
+proc outerProcSons(o: POuterContext, n: PNode, it: TIter) =
   for i in countup(0, sonsLen(n) - 1):
-    let x = transformOuterProc(o, n.sons[i])
+    let x = transformOuterProc(o, n.sons[i], it)
     if x != nil: n.sons[i] = x
 
 proc liftIterSym*(n: PNode): PNode =
@@ -631,27 +716,107 @@ proc liftIterSym*(n: PNode): PNode =
   addVar(v, newSymNode(env))
   result.add(v)
   # add 'new' statement:
-  result.add(newCall(getSysSym"internalNew", env))
+  result.add newCall(getSysSym"internalNew", env)
   result.add makeClosure(iter, env, n.info)
 
-proc transformOuterProc(o: POuterContext, n: PNode): PNode =
-  if n == nil: return nil
+template envActive(env): expr =
+  (env.capturedVars.len > 0 or env.upField != nil)
+
+# We have to split up environment creation in 2 steps:
+# 1. Generate it and store it in env.replacementNode
+# 2. Insert replacementNode into its forseen slot.
+# This split is necessary so that assignments belonging to closure
+# creation like 'env.param = param' are not transformed
+# into 'env.param = env.param'.
+proc createEnvironments(o: POuterContext) =
+  var env = o.head
+  while env != nil:
+    if envActive(env):
+      var scope = env.attachedNode
+      assert scope.kind == nkStmtList
+      if scope.sons[0].kind == nkEmpty:
+        # prepare for closure construction:
+        env.replacementNode = generateClosureCreation(o, env)
+    env = env.next
+
+proc finishEnvironments(o: POuterContext) =
+  var env = o.head
+  while env != nil:
+    if env.replacementNode != nil:
+      var scope = env.attachedNode
+      assert scope.kind == nkStmtList
+      if scope.sons[0].kind == nkEmpty:
+        # change the empty node to contain the closure construction:
+        scope.sons[0] = env.replacementNode
+    env = env.next
+
+proc transformOuterProcBody(o: POuterContext, n: PNode; it: TIter): PNode =
+  if nfLL in n.flags:
+    result = nil
+  elif it.fn.kind == skClosureIterator:
+    # unfortunately control flow is still convoluted and we can end up
+    # multiple times here for the very same iterator. We shield against this
+    # with some rather primitive check for now:
+    if n.kind == nkStmtList and n.len > 0:
+      if n.sons[0].kind == nkGotoState: return nil
+      if n.len > 1 and n[1].kind == nkStmtList and n[1].len > 0 and 
+          n[1][0].kind == nkGotoState:
+        return nil
+    result = newNodeI(nkStmtList, it.fn.info)
+    var gs = newNodeI(nkGotoState, it.fn.info)
+    assert it.closureParam != nil
+    assert it.state != nil
+    gs.add(rawIndirectAccess(newSymNode(it.closureParam), it.state, it.fn.info))
+    result.add(gs)
+    var state0 = newNodeI(nkState, it.fn.info)
+    state0.add(newIntNode(nkIntLit, 0))
+    result.add(state0)
+    
+    let newBody = transformOuterProc(o, n, it)
+    if newBody != nil:
+      result.add(newBody)
+    else:
+      result.add(n)
+
+    var stateAsgnStmt = newNodeI(nkAsgn, it.fn.info)
+    stateAsgnStmt.add(rawIndirectAccess(newSymNode(it.closureParam),
+                      it.state, it.fn.info))
+    stateAsgnStmt.add(newIntTypeNode(nkIntLit, -1, getSysType(tyInt)))
+    result.add(stateAsgnStmt)
+    result.flags.incl nfLL
+  else:
+    result = transformOuterProc(o, n, it)
+    if result != nil: result.flags.incl nfLL
+
+proc transformOuterProc(o: POuterContext, n: PNode; it: TIter): PNode =
+  if n == nil or nfLL in n.flags: return nil
   case n.kind
   of nkEmpty..pred(nkSym), succ(nkSym)..nkNilLit: discard
   of nkSym:
     var local = n.sym
 
-    if o.isIter and interestingIterVar(local) and o.fn.id == local.owner.id:
-      if not containsOrIncl(o.capturedVars, local.id): addField(o.obj, local)
-      return indirectAccess(newSymNode(o.closureParam), local, n.info)
+    if isInnerProc(local, o.fn) and o.processed.contains(local.id):
+      o.processed.excl(local.id)
+      let body = local.getBody
+      let newBody = transformOuterProcBody(o, body, initIter(local))
+      if newBody != nil:
+        local.ast.sons[bodyPos] = newBody
+
+    if it.fn.kind == skClosureIterator and interestingIterVar(local) and
+        it.fn == local.owner:
+      # every local goes through the closure:
+      #if not containsOrIncl(o.capturedVars, local.id):
+      #  addField(it.obj, local)
+      addUniqueField(it.obj, local)
+      return indirectAccess(newSymNode(it.closureParam), local, n.info)
 
     var closure = PEnv(idTableGet(o.lambdasToEnv, local))
-
     if local.kind == skClosureIterator:
       # consider: [i1, i2, i1]  Since we merged the iterator's closure
       # with the captured owning variables, we need to generate the
       # closure generation code again:
-      if local == o.fn: message(n.info, errRecursiveDependencyX, local.name.s)
+      if local == o.fn or local == it.fn:
+        message(n.info, errRecursiveDependencyX, local.name.s)
       # XXX why doesn't this work?
       if closure.isNil:
         return liftIterSym(n)
@@ -662,7 +827,6 @@ proc transformOuterProc(o: POuterContext, n: PNode): PNode =
 
     if closure != nil:
       # we need to replace the lambda with '(lambda, env)':
-      
       let a = closure.createdVar
       if a != nil:
         return makeClosure(local, a, n.info)
@@ -678,14 +842,6 @@ proc transformOuterProc(o: POuterContext, n: PNode): PNode =
         return makeClosure(local, x, n.info)
     
     if not contains(o.capturedVars, local.id): return
-    var env = PEnv(idTableGet(o.localsToEnv, local))
-    if env == nil: return
-    var scope = env.attachedNode
-    assert scope.kind == nkStmtList
-    if scope.sons[0].kind == nkEmpty:
-      # change the empty node to contain the closure construction:
-      scope.sons[0] = generateClosureCreation(o, env)
-    
     # change 'local' to 'closure.local', unless it's a 'byCopy' variable:
     # if sfByCopy notin local.flags:
     result = idNodeTableGet(o.localsToAccess, local)
@@ -694,73 +850,56 @@ proc transformOuterProc(o: POuterContext, n: PNode): PNode =
     # to access the local as a local.
   of nkLambdaKinds, nkIteratorDef:
     if n.typ != nil:
-      result = transformOuterProc(o, n.sons[namePos])
-  of nkProcDef, nkMethodDef, nkConverterDef, nkMacroDef, nkTemplateDef,
-      nkClosure:
+      result = transformOuterProc(o, n.sons[namePos], it)
+  of nkProcDef, nkMethodDef, nkConverterDef, nkMacroDef, nkTemplateDef:
     # don't recurse here:
     discard
+  of nkClosure:
+    if n.sons[0].kind == nkSym:
+      var local = n.sons[0].sym
+      if isInnerProc(local, o.fn) and o.processed.contains(local.id):
+        o.processed.excl(local.id)
+        let body = local.getBody
+        let newBody = transformOuterProcBody(o, body, initIter(local))
+        if newBody != nil:
+          local.ast.sons[bodyPos] = newBody
   of nkHiddenStdConv, nkHiddenSubConv, nkConv:
-    let x = transformOuterProc(o, n.sons[1])
+    let x = transformOuterProc(o, n.sons[1], it)
     if x != nil: n.sons[1] = x
     result = transformOuterConv(n)
   of nkYieldStmt:
-    if o.isIter: result = transformYield(o, n)
-    else: outerProcSons(o, n)
+    if it.fn.kind == skClosureIterator: result = transformYield(o, n, it)
+    else: outerProcSons(o, n, it)
   of nkReturnStmt:
-    if o.isIter: result = transformReturn(o, n)
-    else: outerProcSons(o, n)
-  else:
-    outerProcSons(o, n)
-
-proc liftIterator(c: POuterContext, body: PNode): PNode =
-  let iter = c.fn
-  result = newNodeI(nkStmtList, iter.info)
-  var gs = newNodeI(nkGotoState, iter.info)
-  gs.add(indirectAccess(newSymNode(c.closureParam), c.state, iter.info))
-  result.add(gs)
-  var state0 = newNodeI(nkState, iter.info)
-  state0.add(newIntNode(nkIntLit, 0))
-  result.add(state0)
-  
-  let newBody = transformOuterProc(c, body)
-  if newBody != nil:
-    result.add(newBody)
+    if it.fn.kind == skClosureIterator: result = transformReturn(o, n, it)
+    else: outerProcSons(o, n, it)
   else:
-    result.add(body)
-
-  var stateAsgnStmt = newNodeI(nkAsgn, iter.info)
-  stateAsgnStmt.add(indirectAccess(newSymNode(c.closureParam),
-                    c.state,iter.info))
-  stateAsgnStmt.add(newIntTypeNode(nkIntLit, -1, getSysType(tyInt)))
-  result.add(stateAsgnStmt)
+    outerProcSons(o, n, it)
 
 proc liftLambdas*(fn: PSym, body: PNode): PNode =
   # XXX gCmd == cmdCompileToJS does not suffice! The compiletime stuff needs
   # the transformation even when compiling to JS ...
-  if body.kind == nkEmpty or gCmd == cmdCompileToJS:
+  if body.kind == nkEmpty or gCmd == cmdCompileToJS or 
+      fn.skipGenericOwner.kind != skModule:
     # ignore forward declaration:
     result = body
   else:
+    #if fn.name.s == "cbOuter":
+    #  echo rendertree(fn.ast, {renderIds})
     var o = newOuterContext(fn)
     let ex = closureCreationPoint(body)
-    o.currentEnv = newEnv(fn, nil, ex)
-    # put all params into the environment so they can be captured:
-    let params = fn.typ.n
-    for i in 1.. <params.len: 
-      if params.sons[i].kind != nkSym:
-        internalError(params.info, "liftLambdas: strange params")
-      let param = params.sons[i].sym
-      idTablePut(o.localsToEnv, param, o.currentEnv)
-    # put the 'result' into the environment so it can be captured:
-    let ast = fn.ast
-    if resultPos < sonsLen(ast) and ast.sons[resultPos].kind == nkSym:
-      idTablePut(o.localsToEnv, ast.sons[resultPos].sym, o.currentEnv)
-    searchForInnerProcs(o, body)
-    if o.isIter:
-      result = liftIterator(o, ex)
+    let env = newEnv(o, nil, ex, fn)
+    addParamsToEnv(fn, env)
+    searchForInnerProcs(o, body, env)
+    createEnvironments(o)
+    if fn.kind == skClosureIterator:
+      result = transformOuterProcBody(o, body, initIter(fn))
     else:
-      discard transformOuterProc(o, body)
+      discard transformOuterProcBody(o, body, initIter(fn))
       result = ex
+    finishEnvironments(o)
+    #if fn.name.s == "cbOuter":
+    #  echo rendertree(result, {renderIds})
 
 proc liftLambdasForTopLevel*(module: PSym, body: PNode): PNode =
   if body.kind == nkEmpty or gCmd == cmdCompileToJS:
@@ -768,9 +907,11 @@ proc liftLambdasForTopLevel*(module: PSym, body: PNode): PNode =
   else:
     var o = newOuterContext(module)
     let ex = closureCreationPoint(body)
-    o.currentEnv = newEnv(module, nil, ex)
-    searchForInnerProcs(o, body)
-    discard transformOuterProc(o, body)
+    let env = newEnv(o, nil, ex, module)
+    searchForInnerProcs(o, body, env)
+    createEnvironments(o)
+    discard transformOuterProc(o, body, initIter(module))
+    finishEnvironments(o)
     result = ex
 
 # ------------------- iterator transformation --------------------------------
@@ -846,10 +987,6 @@ proc liftForLoop*(body: PNode): PNode =
 
   loopBody.sons[0] = v2
   var bs = newNodeI(nkBreakState, body.info)
-  #if not env.isNil:
-  #  bs.addSon(indirectAccess(env, 
-  #    newSym(skField, getIdent":state", env, env.info), body.info))
-  #else:
   bs.addSon(call.sons[0])
   loopBody.sons[1] = bs
   loopBody.sons[2] = body[L-1]
diff --git a/compiler/lexer.nim b/compiler/lexer.nim
index 2bfd8d1eb..0e4dfc2ac 100644
--- a/compiler/lexer.nim
+++ b/compiler/lexer.nim
@@ -347,7 +347,7 @@ proc getNumber(L: var TLexer): TToken =
         result.base = base2
         while true: 
           case L.buf[pos]
-          of 'A'..'Z', 'a'..'z', '2'..'9', '.': 
+          of '2'..'9', '.': 
             lexMessage(L, errInvalidNumber, result.literal)
             inc(pos)
           of '_': 
@@ -363,7 +363,7 @@ proc getNumber(L: var TLexer): TToken =
         result.base = base8
         while true: 
           case L.buf[pos]
-          of 'A'..'Z', 'a'..'z', '8'..'9', '.': 
+          of '8'..'9', '.': 
             lexMessage(L, errInvalidNumber, result.literal)
             inc(pos)
           of '_': 
@@ -377,25 +377,22 @@ proc getNumber(L: var TLexer): TToken =
           else: break 
       of 'O': 
         lexMessage(L, errInvalidNumber, result.literal)
-      of 'x', 'X': 
+      of 'x', 'X':
         result.base = base16
-        while true: 
+        while true:
           case L.buf[pos]
-          of 'G'..'Z', 'g'..'z': 
-            lexMessage(L, errInvalidNumber, result.literal)
-            inc(pos)
-          of '_': 
-            if L.buf[pos+1] notin {'0'..'9', 'a'..'f', 'A'..'F'}: 
+          of '_':
+            if L.buf[pos+1] notin {'0'..'9', 'a'..'f', 'A'..'F'}:
               lexMessage(L, errInvalidToken, "_")
               break
             inc(pos)
-          of '0'..'9': 
+          of '0'..'9':
             xi = `shl`(xi, 4) or (ord(L.buf[pos]) - ord('0'))
             inc(pos)
-          of 'a'..'f': 
+          of 'a'..'f':
             xi = `shl`(xi, 4) or (ord(L.buf[pos]) - ord('a') + 10)
             inc(pos)
-          of 'A'..'F': 
+          of 'A'..'F':
             xi = `shl`(xi, 4) or (ord(L.buf[pos]) - ord('A') + 10)
             inc(pos)
           else: break 
@@ -424,8 +421,14 @@ proc getNumber(L: var TLexer): TToken =
       if (result.iNumber < low(int32)) or (result.iNumber > high(int32)):
         if result.tokType == tkIntLit:
           result.tokType = tkInt64Lit
-        elif result.tokType in {tkInt8Lit, tkInt16Lit}:
-          lexMessage(L, errInvalidNumber, result.literal)
+        elif result.tokType in {tkInt8Lit, tkInt16Lit, tkInt32Lit}:
+          lexMessage(L, errNumberOutOfRange, result.literal)
+      elif result.tokType == tkInt8Lit and
+          (result.iNumber < int8.low or result.iNumber > int8.high):
+        lexMessage(L, errNumberOutOfRange, result.literal)
+      elif result.tokType == tkInt16Lit and
+          (result.iNumber < int16.low or result.iNumber > int16.high):
+        lexMessage(L, errNumberOutOfRange, result.literal)
   except EInvalidValue:
     lexMessage(L, errInvalidNumber, result.literal)
   except EOverflow, EOutOfRange:
@@ -537,6 +540,10 @@ proc getString(L: var TLexer, tok: var TToken, rawMode: bool) =
     tok.tokType = tkTripleStrLit # long string literal:
     inc(pos, 2)               # skip ""
     # skip leading newline:
+    if buf[pos] in {' ', '\t'}:
+      var newpos = pos+1
+      while buf[newpos] in {' ', '\t'}: inc newpos
+      if buf[newpos] in {CR, LF}: pos = newpos
     pos = handleCRLF(L, pos)
     buf = L.buf
     while true: 
diff --git a/compiler/llstream.nim b/compiler/llstream.nim
index 510880ffd..86bfeaabd 100644
--- a/compiler/llstream.nim
+++ b/compiler/llstream.nim
@@ -82,6 +82,9 @@ when not defined(readLineFromStdin):
   proc readLineFromStdin(prompt: string, line: var string): bool =
     stdout.write(prompt)
     result = readLine(stdin, line)
+    if not result:
+      stdout.write("\n")
+      quit(0)
 
 proc endsWith*(x: string, s: set[char]): bool =
   var i = x.len-1
diff --git a/compiler/lookups.nim b/compiler/lookups.nim
index 60125177c..aee64f52f 100644
--- a/compiler/lookups.nim
+++ b/compiler/lookups.nim
@@ -15,14 +15,15 @@ import
 
 proc ensureNoMissingOrUnusedSymbols(scope: PScope)
 
-proc considerAcc*(n: PNode): PIdent = 
+proc considerQuotedIdent*(n: PNode): PIdent =
+  ## Retrieve a PIdent from a PNode, taking into account accent nodes.
   case n.kind
   of nkIdent: result = n.ident
   of nkSym: result = n.sym.name
   of nkAccQuoted:
     case n.len
     of 0: globalError(n.info, errIdentifierExpected, renderTree(n))
-    of 1: result = considerAcc(n.sons[0])
+    of 1: result = considerQuotedIdent(n.sons[0])
     else:
       var id = ""
       for i in 0.. <n.len:
@@ -82,10 +83,10 @@ proc searchInScopes*(c: PContext, s: PIdent, filter: TSymKinds): PSym =
 proc errorSym*(c: PContext, n: PNode): PSym =
   ## creates an error symbol to avoid cascading errors (for IDE support)
   var m = n
-  # ensure that 'considerAcc' can't fail:
+  # ensure that 'considerQuotedIdent' can't fail:
   if m.kind == nkDotExpr: m = m.sons[1]
   let ident = if m.kind in {nkIdent, nkSym, nkAccQuoted}: 
-      considerAcc(m)
+      considerQuotedIdent(m)
     else:
       getIdent("err:" & renderTree(m))
   result = newSym(skError, ident, getCurrOwner(), n.info)
@@ -189,7 +190,7 @@ proc lookUp*(c: PContext, n: PNode): PSym =
   of nkSym:
     result = n.sym
   of nkAccQuoted:
-    var ident = considerAcc(n)
+    var ident = considerQuotedIdent(n)
     result = searchInScopes(c, ident)
     if result == nil:
       localError(n.info, errUndeclaredIdentifier, ident.s)
@@ -208,7 +209,7 @@ type
 proc qualifiedLookUp*(c: PContext, n: PNode, flags = {checkUndeclared}): PSym = 
   case n.kind
   of nkIdent, nkAccQuoted:
-    var ident = considerAcc(n)
+    var ident = considerQuotedIdent(n)
     result = searchInScopes(c, ident)
     if result == nil and checkUndeclared in flags: 
       localError(n.info, errUndeclaredIdentifier, ident.s)
@@ -228,7 +229,7 @@ proc qualifiedLookUp*(c: PContext, n: PNode, flags = {checkUndeclared}): PSym =
       if n.sons[1].kind == nkIdent: 
         ident = n.sons[1].ident
       elif n.sons[1].kind == nkAccQuoted: 
-        ident = considerAcc(n.sons[1])
+        ident = considerQuotedIdent(n.sons[1])
       if ident != nil: 
         if m == c.module: 
           result = strTableGet(c.topLevelScope.symbols, ident)
@@ -251,7 +252,7 @@ proc qualifiedLookUp*(c: PContext, n: PNode, flags = {checkUndeclared}): PSym =
 proc initOverloadIter*(o: var TOverloadIter, c: PContext, n: PNode): PSym =
   case n.kind
   of nkIdent, nkAccQuoted:
-    var ident = considerAcc(n)
+    var ident = considerQuotedIdent(n)
     o.scope = c.currentScope
     o.mode = oimNoQualifier
     while true:
@@ -272,7 +273,7 @@ proc initOverloadIter*(o: var TOverloadIter, c: PContext, n: PNode): PSym =
       if n.sons[1].kind == nkIdent: 
         ident = n.sons[1].ident
       elif n.sons[1].kind == nkAccQuoted:
-        ident = considerAcc(n.sons[1])
+        ident = considerQuotedIdent(n.sons[1])
       if ident != nil: 
         if o.m == c.module: 
           # a module may access its private members:
@@ -354,5 +355,5 @@ when false:
       if sfImmediate in a.flags: return a
       a = nextOverloadIter(o, c, n)
     if result == nil and checkUndeclared in flags: 
-      localError(n.info, errUndeclaredIdentifier, n.considerAcc.s)
+      localError(n.info, errUndeclaredIdentifier, n.considerQuotedIdent.s)
       result = errorSym(c, n)
diff --git a/compiler/lowerings.nim b/compiler/lowerings.nim
index 1b9e5fe0f..5b61a9cae 100644
--- a/compiler/lowerings.nim
+++ b/compiler/lowerings.nim
@@ -13,6 +13,8 @@ const
   genPrefix* = ":tmp"         # prefix for generated names
 
 import ast, astalgo, types, idents, magicsys, msgs, options
+from guards import createMagic
+from trees import getMagic
 
 proc newTupleAccess*(tup: PNode, i: int): PNode =
   result = newNodeIT(nkBracketExpr, tup.info, tup.typ.skipTypes(
@@ -62,15 +64,42 @@ proc createObj*(owner: PSym, info: TLineInfo): PType =
   incl result.flags, tfFinal
   result.n = newNodeI(nkRecList, info)
 
+proc rawAddField*(obj: PType; field: PSym) =
+  assert field.kind == skField
+  field.position = sonsLen(obj.n)
+  addSon(obj.n, newSymNode(field))
+
+proc rawIndirectAccess*(a: PNode; field: PSym; info: TLineInfo): PNode = 
+  # returns a[].field as a node
+  assert field.kind == skField
+  var deref = newNodeI(nkHiddenDeref, info)
+  deref.typ = a.typ.skipTypes(abstractInst).sons[0]
+  addSon(deref, a)
+  result = newNodeI(nkDotExpr, info)
+  addSon(result, deref)
+  addSon(result, newSymNode(field))
+  result.typ = field.typ
+
 proc addField*(obj: PType; s: PSym) =
   # because of 'gensym' support, we have to mangle the name with its ID.
   # This is hacky but the clean solution is much more complex than it looks.
   var field = newSym(skField, getIdent(s.name.s & $s.id), s.owner, s.info)
   let t = skipIntLit(s.typ)
   field.typ = t
+  assert t.kind != tyStmt
   field.position = sonsLen(obj.n)
   addSon(obj.n, newSymNode(field))
 
+proc addUniqueField*(obj: PType; s: PSym) =
+  let fieldName = getIdent(s.name.s & $s.id)
+  if lookupInRecord(obj.n, fieldName) == nil:
+    var field = newSym(skField, fieldName, s.owner, s.info)
+    let t = skipIntLit(s.typ)
+    field.typ = t
+    assert t.kind != tyStmt
+    field.position = sonsLen(obj.n)
+    addSon(obj.n, newSymNode(field))
+
 proc newDotExpr(obj, b: PSym): PNode =
   result = newNodeI(nkDotExpr, obj.info)
   let field = getSymFromList(obj.typ.n, getIdent(b.name.s & $b.id))
@@ -79,19 +108,45 @@ proc newDotExpr(obj, b: PSym): PNode =
   addSon(result, newSymNode(field))
   result.typ = field.typ
 
-proc indirectAccess*(a: PNode, b: PSym, info: TLineInfo): PNode = 
+proc indirectAccess*(a: PNode, b: string, info: TLineInfo): PNode = 
   # returns a[].b as a node
   var deref = newNodeI(nkHiddenDeref, info)
-  deref.typ = a.typ.sons[0]
-  assert deref.typ.kind == tyObject
-  let field = getSymFromList(deref.typ.n, getIdent(b.name.s & $b.id))
-  assert field != nil, b.name.s
+  deref.typ = a.typ.skipTypes(abstractInst).sons[0]
+  var t = deref.typ.skipTypes(abstractInst)
+  var field: PSym
+  while true:
+    assert t.kind == tyObject
+    field = getSymFromList(t.n, getIdent(b))
+    if field != nil: break
+    t = t.sons[0]
+    if t == nil: break
+    t = t.skipTypes(abstractInst)
+  #if field == nil:
+  #  debug deref.typ
+  #  echo deref.typ.id
+  internalAssert field != nil
   addSon(deref, a)
   result = newNodeI(nkDotExpr, info)
   addSon(result, deref)
   addSon(result, newSymNode(field))
   result.typ = field.typ
 
+proc getFieldFromObj*(t: PType; v: PSym): PSym =
+  assert v.kind != skField
+  let fieldName = getIdent(v.name.s & $v.id)
+  var t = t
+  while true:
+    assert t.kind == tyObject
+    result = getSymFromList(t.n, fieldName)
+    if result != nil: break
+    t = t.sons[0]
+    if t == nil: break
+    t = t.skipTypes(abstractInst)
+
+proc indirectAccess*(a: PNode, b: PSym, info: TLineInfo): PNode = 
+  # returns a[].b as a node
+  result = indirectAccess(a, b.name.s & $b.id, info)
+
 proc indirectAccess*(a, b: PSym, info: TLineInfo): PNode =
   result = indirectAccess(newSymNode(a), b, info)
 
@@ -101,6 +156,11 @@ proc genAddrOf*(n: PNode): PNode =
   result.typ = newType(tyPtr, n.typ.owner)
   result.typ.rawAddSon(n.typ)
 
+proc genDeref*(n: PNode): PNode =
+  result = newNodeIT(nkHiddenDeref, n.info, 
+                     n.typ.skipTypes(abstractInst).sons[0])
+  result.add n
+
 proc callCodegenProc*(name: string, arg1: PNode; 
                       arg2, arg3: PNode = nil): PNode =
   result = newNodeI(nkCall, arg1.info)
@@ -112,13 +172,120 @@ proc callCodegenProc*(name: string, arg1: PNode;
     result.add arg1
     if arg2 != nil: result.add arg2
     if arg3 != nil: result.add arg3
+    result.typ = sym.typ.sons[0]
+
+proc callProc(a: PNode): PNode =
+  result = newNodeI(nkCall, a.info)
+  result.add a
+  result.typ = a.typ.sons[0]
+
+# we have 4 cases to consider:
+# - a void proc --> nothing to do
+# - a proc returning GC'ed memory --> requires a flowVar
+# - a proc returning non GC'ed memory --> pass as hidden 'var' parameter
+# - not in a parallel environment --> requires a flowVar for memory safety
+type
+  TSpawnResult = enum
+    srVoid, srFlowVar, srByVar
+  TFlowVarKind = enum
+    fvInvalid # invalid type T for 'FlowVar[T]'
+    fvGC      # FlowVar of a GC'ed type
+    fvBlob    # FlowVar of a blob type
+
+proc spawnResult(t: PType; inParallel: bool): TSpawnResult =
+  if t.isEmptyType: srVoid
+  elif inParallel and not containsGarbageCollectedRef(t): srByVar
+  else: srFlowVar
+
+proc flowVarKind(t: PType): TFlowVarKind =
+  if t.skipTypes(abstractInst).kind in {tyRef, tyString, tySequence}: fvGC
+  elif containsGarbageCollectedRef(t): fvInvalid
+  else: fvBlob
+
+proc addLocalVar(varSection: PNode; owner: PSym; typ: PType; v: PNode): PSym =
+  result = newSym(skTemp, getIdent(genPrefix), owner, varSection.info)
+  result.typ = typ
+  incl(result.flags, sfFromGeneric)
+
+  var vpart = newNodeI(nkIdentDefs, varSection.info, 3)
+  vpart.sons[0] = newSymNode(result)
+  vpart.sons[1] = ast.emptyNode
+  vpart.sons[2] = v
+  varSection.add vpart
+
+discard """
+We generate roughly this:
+
+proc f_wrapper(thread, args) =
+  barrierEnter(args.barrier)  # for parallel statement
+  var a = args.a # thread transfer; deepCopy or shallowCopy or no copy
+                 # depending on whether we're in a 'parallel' statement
+  var b = args.b
+  var fv = args.fv
+
+  fv.owner = thread # optional
+  nimArgsPassingDone() # signal parent that the work is done
+  # 
+  args.fv.blob = f(a, b, ...)
+  nimFlowVarSignal(args.fv)
+  
+  # - or -
+  f(a, b, ...)
+  barrierLeave(args.barrier)  # for parallel statement
+
+stmtList:
+  var scratchObj
+  scratchObj.a = a
+  scratchObj.b = b
+
+  nimSpawn(f_wrapper, addr scratchObj)
+  scratchObj.fv # optional
+
+"""
 
 proc createWrapperProc(f: PNode; threadParam, argsParam: PSym;
-                       varSection, call: PNode): PSym =
+                       varSection, call, barrier, fv: PNode;
+                       spawnKind: TSpawnResult): PSym =
   var body = newNodeI(nkStmtList, f.info)
+  var threadLocalBarrier: PSym
+  if barrier != nil:
+    var varSection = newNodeI(nkVarSection, barrier.info)
+    threadLocalBarrier = addLocalVar(varSection, argsParam.owner, 
+                                     barrier.typ, barrier)
+    body.add varSection
+    body.add callCodeGenProc("barrierEnter", threadLocalBarrier.newSymNode)
+  var threadLocalProm: PSym
+  if spawnKind == srByVar:
+    threadLocalProm = addLocalVar(varSection, argsParam.owner, fv.typ, fv)
+  elif fv != nil:
+    internalAssert fv.typ.kind == tyGenericInst
+    threadLocalProm = addLocalVar(varSection, argsParam.owner, fv.typ, fv)
+    
   body.add varSection
-  body.add callCodeGenProc("nimArgsPassingDone", newSymNode(threadParam))
-  body.add call
+  if fv != nil and spawnKind != srByVar:
+    # generate:
+    #   fv.owner = threadParam
+    body.add newAsgnStmt(indirectAccess(threadLocalProm.newSymNode,
+      "owner", fv.info), threadParam.newSymNode)
+
+  body.add callCodeGenProc("nimArgsPassingDone", threadParam.newSymNode)
+  if spawnKind == srByVar:
+    body.add newAsgnStmt(genDeref(threadLocalProm.newSymNode), call)
+  elif fv != nil:
+    let fk = fv.typ.sons[1].flowVarKind
+    if fk == fvInvalid:
+      localError(f.info, "cannot create a flowVar of type: " & 
+        typeToString(fv.typ.sons[1]))
+    body.add newAsgnStmt(indirectAccess(threadLocalProm.newSymNode,
+      if fk == fvGC: "data" else: "blob", fv.info), call)
+    if barrier == nil:
+      # by now 'fv' is shared and thus might have beeen overwritten! we need
+      # to use the thread-local view instead:
+      body.add callCodeGenProc("nimFlowVarSignal", threadLocalProm.newSymNode)
+  else:
+    body.add call
+  if barrier != nil:
+    body.add callCodeGenProc("barrierLeave", threadLocalBarrier.newSymNode)
 
   var params = newNodeI(nkFormalParams, f.info)
   params.add emptyNode
@@ -146,10 +313,152 @@ proc createCastExpr(argsParam: PSym; objType: PType): PNode =
   result.typ = newType(tyPtr, objType.owner)
   result.typ.rawAddSon(objType)
 
-proc wrapProcForSpawn*(owner: PSym; n: PNode): PNode =
-  result = newNodeI(nkStmtList, n.info)
-  if n.kind notin nkCallKinds or not n.typ.isEmptyType:
-    localError(n.info, "'spawn' takes a call expression of type void")
+proc setupArgsForConcurrency(n: PNode; objType: PType; scratchObj: PSym, 
+                             castExpr, call, varSection, result: PNode) =
+  let formals = n[0].typ.n
+  let tmpName = getIdent(genPrefix)
+  for i in 1 .. <n.len:
+    # we pick n's type here, which hopefully is 'tyArray' and not
+    # 'tyOpenArray':
+    var argType = n[i].typ.skipTypes(abstractInst)
+    if i < formals.len and formals[i].typ.kind == tyVar:
+      localError(n[i].info, "'spawn'ed function cannot have a 'var' parameter")
+    elif containsTyRef(argType):
+      localError(n[i].info, "'spawn'ed function cannot refer to 'ref'/closure")
+
+    let fieldname = if i < formals.len: formals[i].sym.name else: tmpName
+    var field = newSym(skField, fieldname, objType.owner, n.info)
+    field.typ = argType
+    objType.addField(field)
+    result.add newFastAsgnStmt(newDotExpr(scratchObj, field), n[i])
+
+    let temp = addLocalVar(varSection, objType.owner, argType,
+                           indirectAccess(castExpr, field, n.info))    
+    call.add(newSymNode(temp))
+
+proc getRoot*(n: PNode): PSym =
+  ## ``getRoot`` takes a *path* ``n``. A path is an lvalue expression
+  ## like ``obj.x[i].y``. The *root* of a path is the symbol that can be
+  ## determined as the owner; ``obj`` in the example.
+  case n.kind
+  of nkSym:
+    if n.sym.kind in {skVar, skResult, skTemp, skLet, skForVar}:
+      result = n.sym
+  of nkDotExpr, nkBracketExpr, nkHiddenDeref, nkDerefExpr,
+      nkObjUpConv, nkObjDownConv, nkCheckedFieldExpr:
+    result = getRoot(n.sons[0])
+  of nkHiddenStdConv, nkHiddenSubConv, nkConv:
+    result = getRoot(n.sons[1])
+  of nkCallKinds:
+    if getMagic(n) == mSlice: result = getRoot(n.sons[1])
+  else: discard
+
+proc newIntLit(value: BiggestInt): PNode =
+  result = nkIntLit.newIntNode(value)
+  result.typ = getSysType(tyInt)
+
+proc genHigh(n: PNode): PNode =
+  if skipTypes(n.typ, abstractVar).kind in {tyArrayConstr, tyArray}:
+    result = newIntLit(lastOrd(skipTypes(n.typ, abstractVar)))
+  else:
+    result = newNodeI(nkCall, n.info, 2)
+    result.typ = getSysType(tyInt)
+    result.sons[0] = newSymNode(createMagic("high", mHigh))
+    result.sons[1] = n
+
+proc setupArgsForParallelism(n: PNode; objType: PType; scratchObj: PSym;
+                             castExpr, call, varSection, result: PNode) =
+  let formals = n[0].typ.n
+  let tmpName = getIdent(genPrefix)
+  # we need to copy the foreign scratch object fields into local variables
+  # for correctness: These are called 'threadLocal' here.
+  for i in 1 .. <n.len:
+    let n = n[i]
+    let argType = skipTypes(if i < formals.len: formals[i].typ else: n.typ,
+                            abstractInst)
+    if containsTyRef(argType):
+      localError(n.info, "'spawn'ed function cannot refer to 'ref'/closure")
+
+    let fieldname = if i < formals.len: formals[i].sym.name else: tmpName
+    var field = newSym(skField, fieldname, objType.owner, n.info)
+
+    if argType.kind in {tyVarargs, tyOpenArray}:
+      # important special case: we always create a zero-copy slice:
+      let slice = newNodeI(nkCall, n.info, 4)
+      slice.typ = n.typ
+      slice.sons[0] = newSymNode(createMagic("slice", mSlice))
+      var fieldB = newSym(skField, tmpName, objType.owner, n.info)
+      fieldB.typ = getSysType(tyInt)
+      objType.addField(fieldB)
+      
+      if getMagic(n) == mSlice:
+        let a = genAddrOf(n[1])
+        field.typ = a.typ
+        objType.addField(field)
+        result.add newFastAsgnStmt(newDotExpr(scratchObj, field), a)
+
+        var fieldA = newSym(skField, tmpName, objType.owner, n.info)
+        fieldA.typ = getSysType(tyInt)
+        objType.addField(fieldA)
+        result.add newFastAsgnStmt(newDotExpr(scratchObj, fieldA), n[2])
+        result.add newFastAsgnStmt(newDotExpr(scratchObj, fieldB), n[3])
+
+        let threadLocal = addLocalVar(varSection, objType.owner, fieldA.typ,
+                                      indirectAccess(castExpr, fieldA, n.info))
+        slice.sons[2] = threadLocal.newSymNode
+      else:
+        let a = genAddrOf(n)
+        field.typ = a.typ
+        objType.addField(field)
+        result.add newFastAsgnStmt(newDotExpr(scratchObj, field), a)
+        result.add newFastAsgnStmt(newDotExpr(scratchObj, fieldB), genHigh(n))
+
+        slice.sons[2] = newIntLit(0)
+      # the array itself does not need to go through a thread local variable:
+      slice.sons[1] = genDeref(indirectAccess(castExpr, field, n.info))
+
+      let threadLocal = addLocalVar(varSection, objType.owner, fieldB.typ,
+                                    indirectAccess(castExpr, fieldB, n.info))
+      slice.sons[3] = threadLocal.newSymNode
+      call.add slice
+    elif (let size = computeSize(argType); size < 0 or size > 16) and
+        n.getRoot != nil:
+      # it is more efficient to pass a pointer instead:
+      let a = genAddrOf(n)
+      field.typ = a.typ
+      objType.addField(field)
+      result.add newFastAsgnStmt(newDotExpr(scratchObj, field), a)
+      let threadLocal = addLocalVar(varSection, objType.owner, field.typ,
+                                    indirectAccess(castExpr, field, n.info))
+      call.add(genDeref(threadLocal.newSymNode))
+    else:
+      # boring case
+      field.typ = argType
+      objType.addField(field)
+      result.add newFastAsgnStmt(newDotExpr(scratchObj, field), n)
+      let threadLocal = addLocalVar(varSection, objType.owner, field.typ,
+                                    indirectAccess(castExpr, field, n.info))
+      call.add(threadLocal.newSymNode)
+
+proc wrapProcForSpawn*(owner: PSym; spawnExpr: PNode; retType: PType; 
+                       barrier, dest: PNode = nil): PNode =
+  # if 'barrier' != nil, then it is in a 'parallel' section and we
+  # generate quite different code
+  let n = spawnExpr[1]
+  let spawnKind = spawnResult(retType, barrier!=nil)
+  case spawnKind
+  of srVoid:
+    internalAssert dest == nil
+    result = newNodeI(nkStmtList, n.info)
+  of srFlowVar:
+    internalAssert dest == nil
+    result = newNodeIT(nkStmtListExpr, n.info, retType)
+  of srByVar:
+    if dest == nil: localError(n.info, "'spawn' must not be discarded")
+    result = newNodeI(nkStmtList, n.info)
+
+  if n.kind notin nkCallKinds:
+    localError(n.info, "'spawn' takes a call expression")
     return
   if optThreadAnalysis in gGlobalOptions:
     if {tfThread, tfNoSideEffect} * n[0].typ.flags == {}:
@@ -162,6 +471,7 @@ proc wrapProcForSpawn*(owner: PSym; n: PNode): PNode =
     threadParam.typ = ptrType
     argsParam.typ = ptrType
     argsParam.position = 1
+
   var objType = createObj(owner, n.info)
   incl(objType.flags, tfFinal)
   let castExpr = createCastExpr(argsParam, objType)
@@ -174,7 +484,7 @@ proc wrapProcForSpawn*(owner: PSym; n: PNode): PNode =
     varSectionB.addVar(scratchObj.newSymNode)
     result.add varSectionB
 
-  var call = newNodeI(nkCall, n.info)
+  var call = newNodeIT(nkCall, n.info, n.typ)
   var fn = n.sons[0]
   # templates and macros are in fact valid here due to the nature of
   # the transformation:
@@ -194,35 +504,44 @@ proc wrapProcForSpawn*(owner: PSym; n: PNode): PNode =
 
   call.add(fn)
   var varSection = newNodeI(nkVarSection, n.info)
-  let formals = n[0].typ.n
-  let tmpName = getIdent(genPrefix)
-  for i in 1 .. <n.len:
-    # we pick n's type here, which hopefully is 'tyArray' and not
-    # 'tyOpenArray':
-    var argType = n[i].typ.skipTypes(abstractInst)
-    if i < formals.len and formals[i].typ.kind == tyVar:
-      localError(n[i].info, "'spawn'ed function cannot have a 'var' parameter")
-    elif containsTyRef(argType):
-      localError(n[i].info, "'spawn'ed function cannot refer to 'ref'/closure")
+  if barrier.isNil:
+    setupArgsForConcurrency(n, objType, scratchObj, castExpr, call, varSection, result)
+  else: 
+    setupArgsForParallelism(n, objType, scratchObj, castExpr, call, varSection, result)
 
-    let fieldname = if i < formals.len: formals[i].sym.name else: tmpName
-    var field = newSym(skField, fieldname, owner, n.info)
-    field.typ = argType
+  var barrierAsExpr: PNode = nil
+  if barrier != nil:
+    let typ = newType(tyPtr, owner)
+    typ.rawAddSon(magicsys.getCompilerProc("Barrier").typ)
+    var field = newSym(skField, getIdent"barrier", owner, n.info)
+    field.typ = typ
     objType.addField(field)
-    result.add newFastAsgnStmt(newDotExpr(scratchObj, field), n[i])
+    result.add newFastAsgnStmt(newDotExpr(scratchObj, field), barrier)
+    barrierAsExpr = indirectAccess(castExpr, field, n.info)
 
-    var temp = newSym(skTemp, tmpName, owner, n.info)
-    temp.typ = argType
-    incl(temp.flags, sfFromGeneric)
-
-    var vpart = newNodeI(nkIdentDefs, n.info, 3)
-    vpart.sons[0] = newSymNode(temp)
-    vpart.sons[1] = ast.emptyNode
-    vpart.sons[2] = indirectAccess(castExpr, field, n.info)
-    varSection.add vpart
+  var fvField, fvAsExpr: PNode = nil
+  if spawnKind == srFlowVar:
+    var field = newSym(skField, getIdent"fv", owner, n.info)
+    field.typ = retType
+    objType.addField(field)
+    fvField = newDotExpr(scratchObj, field)
+    fvAsExpr = indirectAccess(castExpr, field, n.info)
+    # create flowVar:
+    result.add newFastAsgnStmt(fvField, callProc(spawnExpr[2]))
+    if barrier == nil:
+      result.add callCodeGenProc("nimFlowVarCreateCondVar", fvField)
 
-    call.add(newSymNode(temp))
+  elif spawnKind == srByVar:
+    var field = newSym(skField, getIdent"fv", owner, n.info)
+    field.typ = newType(tyPtr, objType.owner)
+    field.typ.rawAddSon(retType)
+    objType.addField(field)
+    fvAsExpr = indirectAccess(castExpr, field, n.info)
+    result.add newFastAsgnStmt(newDotExpr(scratchObj, field), genAddrOf(dest))
 
-  let wrapper = createWrapperProc(fn, threadParam, argsParam, varSection, call)
+  let wrapper = createWrapperProc(fn, threadParam, argsParam, varSection, call,
+                                  barrierAsExpr, fvAsExpr, spawnKind)
   result.add callCodeGenProc("nimSpawn", wrapper.newSymNode,
                              genAddrOf(scratchObj.newSymNode))
+
+  if spawnKind == srFlowVar: result.add fvField
diff --git a/compiler/magicsys.nim b/compiler/magicsys.nim
index b4f6e043d..475326161 100644
--- a/compiler/magicsys.nim
+++ b/compiler/magicsys.nim
@@ -27,6 +27,8 @@ var
   gSysTypes: array[TTypeKind, PType]
   compilerprocs: TStrTable
 
+proc nilOrSysInt*: PType = gSysTypes[tyInt]
+
 proc registerSysType(t: PType) = 
   if gSysTypes[t.kind] == nil: gSysTypes[t.kind] = t
   
diff --git a/compiler/main.nim b/compiler/main.nim
index f833394f7..b4af49248 100644
--- a/compiler/main.nim
+++ b/compiler/main.nim
@@ -310,7 +310,7 @@ proc mainCommand* =
   of "cpp", "compiletocpp":
     extccomp.cExt = ".cpp"
     gCmd = cmdCompileToCpp
-    if cCompiler == ccGcc: setCC("gpp")
+    if cCompiler == ccGcc: setCC("gcc")
     wantMainModule()
     defineSymbol("cpp")
     commandCompileToC()
diff --git a/compiler/modules.nim b/compiler/modules.nim
index fb1940741..b102224cd 100644
--- a/compiler/modules.nim
+++ b/compiler/modules.nim
@@ -115,7 +115,7 @@ proc newModule(fileIdx: int32): PSym =
   new(result)
   result.id = - 1             # for better error checking
   result.kind = skModule
-  let filename = fileIdx.toFilename
+  let filename = fileIdx.toFullPath
   result.name = getIdent(splitFile(filename).name)
   if not isNimrodIdentifier(result.name.s):
     rawMessage(errInvalidModuleName, result.name.s)
diff --git a/compiler/nimrod.ini b/compiler/nimrod.ini
index 0dc44a7c9..44e16cec8 100644
--- a/compiler/nimrod.ini
+++ b/compiler/nimrod.ini
@@ -3,7 +3,7 @@ Name: "Nimrod"
 Version: "$version"
 Platforms: """
   windows: i386;amd64
-  linux: i386;amd64;powerpc64;arm;sparc;mips
+  linux: i386;amd64;powerpc64;arm;sparc;mips;powerpc
   macosx: i386;amd64;powerpc64
   solaris: i386;amd64;sparc
   freebsd: i386;amd64
@@ -79,6 +79,7 @@ Files: "lib/system/*.nim"
 Files: "lib/core/*.nim"
 Files: "lib/pure/*.nim"
 Files: "lib/pure/collections/*.nim"
+Files: "lib/pure/concurrency/*.nim"
 Files: "lib/impure/*.nim"
 Files: "lib/wrappers/*.nim"
 
diff --git a/compiler/parser.nim b/compiler/parser.nim
index 5c7b86240..6ff0c2dfc 100644
--- a/compiler/parser.nim
+++ b/compiler/parser.nim
@@ -28,25 +28,20 @@ import
   llstream, lexer, idents, strutils, ast, astalgo, msgs
 
 type
-  TParser*{.final.} = object  # a TParser object represents a module that
+  TParser*{.final.} = object  # A TParser object represents a module that
                               # is being parsed
-    currInd: int              # current indentation
-    firstTok, strongSpaces: bool
-    lex*: TLexer              # the lexer that is used for parsing
-    tok*: TToken              # the current token
-    inPragma: int
+    currInd: int              # current indentation level
+    firstTok, strongSpaces: bool # Has the first token been read?
+                                 # Is strongSpaces on?
+    lex*: TLexer              # The lexer that is used for parsing
+    tok*: TToken              # The current token
+    inPragma: int             # Pragma level
     inSemiStmtList: int
 
 proc parseAll*(p: var TParser): PNode
 proc closeParser*(p: var TParser)
 proc parseTopLevelStmt*(p: var TParser): PNode
-  # implements an iterator. Returns the next top-level statement or
-  # emtyNode if end of stream.
-
 proc parseString*(s: string, filename: string = "", line: int = 0): PNode
-  # filename and line could be set optionally, when the string originates 
-  # from a certain source file. This way, the compiler could generate
-  # correct error messages referring to the original source.
   
 # helpers for the other parsers
 proc isOperator*(tok: TToken): bool
@@ -68,15 +63,19 @@ proc optInd*(p: var TParser, n: PNode)
 proc indAndComment*(p: var TParser, n: PNode)
 proc setBaseFlags*(n: PNode, base: TNumericalBase)
 proc parseSymbol*(p: var TParser, allowNil = false): PNode
-proc parseTry(p: var TParser): PNode
+proc parseTry(p: var TParser; isExpr: bool): PNode
 proc parseCase(p: var TParser): PNode
 # implementation
 
-proc getTok(p: var TParser) = 
+proc getTok(p: var TParser) =
+  ## Get the next token from the parser's lexer, and store it in the parser's
+  ## `tok` member.
   rawGetTok(p.lex, p.tok)
 
 proc openParser*(p: var TParser, fileIdx: int32, inputStream: PLLStream,
                  strongSpaces=false) =
+  ## Open a parser, using the given arguments to set up its internal state.
+  ## 
   initToken(p.tok)
   openLexer(p.lex, fileIdx, inputStream)
   getTok(p)                   # read the first token
@@ -87,13 +86,16 @@ proc openParser*(p: var TParser, filename: string, inputStream: PLLStream,
                  strongSpaces=false) =
   openParser(p, filename.fileInfoIdx, inputstream, strongSpaces)
 
-proc closeParser(p: var TParser) = 
+proc closeParser(p: var TParser) =
+  ## Close a parser, freeing up its resources.
   closeLexer(p.lex)
 
-proc parMessage(p: TParser, msg: TMsgKind, arg: string = "") = 
+proc parMessage(p: TParser, msg: TMsgKind, arg = "") =
+  ## Produce and emit the parser message `arg` to output.
   lexMessage(p.lex, msg, arg)
 
-proc parMessage(p: TParser, msg: TMsgKind, tok: TToken) = 
+proc parMessage(p: TParser, msg: TMsgKind, tok: TToken) =
+  ## Produce and emit a parser message to output about the token `tok`
   lexMessage(p.lex, msg, prettyTok(tok))
 
 template withInd(p: expr, body: stmt) {.immediate.} =
@@ -143,10 +145,15 @@ proc expectIdent(p: TParser) =
     lexMessage(p.lex, errIdentifierExpected, prettyTok(p.tok))
   
 proc eat(p: var TParser, tokType: TTokType) =
-  if p.tok.tokType == tokType: getTok(p)
-  else: lexMessage(p.lex, errTokenExpected, TokTypeToStr[tokType])
+  ## Move the parser to the next token if the current token is of type
+  ## `tokType`, otherwise error.
+  if p.tok.tokType == tokType:
+    getTok(p)
+  else:
+    lexMessage(p.lex, errTokenExpected, TokTypeToStr[tokType])
   
 proc parLineInfo(p: TParser): TLineInfo =
+  ## Retrieve the line information associated with the parser's current state.
   result = getLineInfo(p.lex, p.tok)
 
 proc indAndComment(p: var TParser, n: PNode) =
@@ -192,9 +199,11 @@ proc isSigilLike(tok: TToken): bool {.inline.} =
   result = tok.tokType == tkOpr and relevantOprChar(tok.ident) == '@'
 
 proc isLeftAssociative(tok: TToken): bool {.inline.} =
+  ## Determines whether the token is left assocative.
   result = tok.tokType != tkOpr or relevantOprChar(tok.ident) != '^'
 
 proc getPrecedence(tok: TToken, strongSpaces: bool): int =
+  ## Calculates the precedence of the given token.
   template considerStrongSpaces(x): expr =
     x + (if strongSpaces: 100 - tok.strongSpaceA.int*10 else: 0)
 
@@ -224,22 +233,26 @@ proc getPrecedence(tok: TToken, strongSpaces: bool): int =
   else: result = -10
 
 proc isOperator(tok: TToken): bool =
+  ## Determines if the given token is an operator type token.
   tok.tokType in {tkOpr, tkDiv, tkMod, tkShl, tkShr, tkIn, tkNotin, tkIs,
                   tkIsnot, tkNot, tkOf, tkAs, tkDotDot, tkAnd, tkOr, tkXor}
 
 proc isUnary(p: TParser): bool =
+  ## Check if the current parser token is a unary operator
   p.strongSpaces and p.tok.tokType in {tkOpr, tkDotDot} and
     p.tok.strongSpaceB == 0 and
     p.tok.strongSpaceA > 0
 
 proc checkBinary(p: TParser) {.inline.} =
+  ## Check if the current parser token is a binary operator.
   # we don't check '..' here as that's too annoying
   if p.strongSpaces and p.tok.tokType == tkOpr:
     if p.tok.strongSpaceB > 0 and p.tok.strongSpaceA != p.tok.strongSpaceB:
-      parMessage(p, errGenerated, "number of spaces around '$#' not consistent"%
-        prettyTok(p.tok))
+      parMessage(p, errGenerated,
+                 "Number of spaces around '$#' not consistent" %
+                 prettyTok(p.tok))
     elif p.tok.strongSpaceA notin {0,1,2,4,8}:
-      parMessage(p, errGenerated, "number of spaces must be 0,1,2,4 or 8")
+      parMessage(p, errGenerated, "Number of spaces must be 0,1,2,4 or 8")
 
 #| module = stmt ^* (';' / IND{=})
 #|
@@ -274,7 +287,7 @@ proc colcom(p: var TParser, n: PNode) =
   skipComment(p, n)
 
 proc parseSymbol(p: var TParser, allowNil = false): PNode =
-  #| symbol = '`' (KEYW|IDENT|operator|'(' ')'|'[' ']'|'{' '}'|'='|literal)+ '`'
+  #| symbol = '`' (KEYW|IDENT|literal|(operator|'('|')'|'['|']'|'{'|'}'|'=')+)+ '`'
   #|        | IDENT
   case p.tok.tokType
   of tkSymbol: 
@@ -285,31 +298,22 @@ proc parseSymbol(p: var TParser, allowNil = false): PNode =
     getTok(p)
     while true:
       case p.tok.tokType
-      of tkBracketLe: 
-        add(result, newIdentNodeP(getIdent"[]", p))
-        getTok(p)
-        eat(p, tkBracketRi)
-      of tkEquals:
-        add(result, newIdentNodeP(getIdent"=", p))
-        getTok(p)
-      of tkParLe:
-        add(result, newIdentNodeP(getIdent"()", p))
-        getTok(p)
-        eat(p, tkParRi)
-      of tkCurlyLe:
-        add(result, newIdentNodeP(getIdent"{}", p))
-        getTok(p)
-        eat(p, tkCurlyRi)
-      of tokKeywordLow..tokKeywordHigh, tkSymbol, tkOpr, tkDot, tkDotDot:
-        add(result, newIdentNodeP(p.tok.ident, p))
-        getTok(p)
-      of tkIntLit..tkCharLit:
-        add(result, newIdentNodeP(getIdent(tokToStr(p.tok)), p))
-        getTok(p)
-      else:
+      of tkAccent:
         if result.len == 0: 
           parMessage(p, errIdentifierExpected, p.tok)
         break
+      of tkOpr, tkDot, tkDotDot, tkEquals, tkParLe..tkParDotRi:
+        var accm = ""
+        while p.tok.tokType in {tkOpr, tkDot, tkDotDot, tkEquals,
+                                tkParLe..tkParDotRi}:
+          accm.add(tokToStr(p.tok))
+          getTok(p)
+        result.add(newIdentNodeP(getIdent(accm), p))
+      of tokKeywordLow..tokKeywordHigh, tkSymbol, tkIntLit..tkCharLit:
+        result.add(newIdentNodeP(getIdent(tokToStr(p.tok)), p))
+        getTok(p)
+      else:
+        parMessage(p, errIdentifierExpected, p.tok)
     eat(p, tkAccent)
   else:
     if allowNil and p.tok.tokType == tkNil:
@@ -841,7 +845,7 @@ proc parseIdentColonEquals(p: var TParser, flags: TDeclaredIdentFlags): PNode =
     addSon(result, parseTypeDesc(p))
   else: 
     addSon(result, ast.emptyNode)
-    if (p.tok.tokType != tkEquals) and not (withBothOptional in flags): 
+    if p.tok.tokType != tkEquals and withBothOptional notin flags: 
       parMessage(p, errColonOrEqualsExpected, p.tok)
   if p.tok.tokType == tkEquals: 
     getTok(p)
@@ -982,6 +986,7 @@ proc parseSymbolList(p: var TParser, result: PNode, allowNil = false) =
 
 proc parseTypeDescKAux(p: var TParser, kind: TNodeKind,
                        mode: TPrimaryMode): PNode =
+  #| distinct = 'distinct' optInd typeDesc
   result = newNodeP(kind, p)
   getTok(p)
   optInd(p, result)
@@ -999,13 +1004,13 @@ proc parseExpr(p: var TParser): PNode =
   #| expr = (ifExpr
   #|       | whenExpr
   #|       | caseExpr
-  #|       | tryStmt)
+  #|       | tryExpr)
   #|       / simpleExpr
   case p.tok.tokType:
   of tkIf: result = parseIfExpr(p, nkIfExpr)
   of tkWhen: result = parseIfExpr(p, nkWhenExpr)
   of tkCase: result = parseCase(p)
-  of tkTry: result = parseTry(p)
+  of tkTry: result = parseTry(p, isExpr=true)
   else: result = simpleExpr(p)
 
 proc parseEnum(p: var TParser): PNode
@@ -1108,6 +1113,7 @@ proc parseTypeDefAux(p: var TParser): PNode =
   result = simpleExpr(p, pmTypeDef)
 
 proc makeCall(n: PNode): PNode =
+  ## Creates a call if the given node isn't already a call.
   if n.kind in nkCallKinds:
     result = n
   else:
@@ -1357,22 +1363,25 @@ proc parseCase(p: var TParser): PNode =
   if wasIndented:
     p.currInd = oldInd
     
-proc parseTry(p: var TParser): PNode =
+proc parseTry(p: var TParser; isExpr: bool): PNode =
   #| tryStmt = 'try' colcom stmt &(IND{=}? 'except'|'finally')
   #|            (IND{=}? 'except' exprList colcom stmt)*
   #|            (IND{=}? 'finally' colcom stmt)?
+  #| tryExpr = 'try' colcom stmt &(optInd 'except'|'finally')
+  #|            (optInd 'except' exprList colcom stmt)*
+  #|            (optInd 'finally' colcom stmt)?
   result = newNodeP(nkTryStmt, p)
   getTok(p)
   eat(p, tkColon)
   skipComment(p, result)
   addSon(result, parseStmt(p))
   var b: PNode = nil
-  while sameOrNoInd(p):
+  while sameOrNoInd(p) or isExpr:
     case p.tok.tokType
-    of tkExcept: 
+    of tkExcept:
       b = newNodeP(nkExceptBranch, p)
       exprList(p, tkColon, b)
-    of tkFinally: 
+    of tkFinally:
       b = newNodeP(nkFinally, p)
       getTokNoInd(p)
       eat(p, tkColon)
@@ -1871,7 +1880,7 @@ proc complexOrSimpleStmt(p: var TParser): PNode =
   of tkIf: result = parseIfOrWhen(p, nkIfStmt)
   of tkWhile: result = parseWhile(p)
   of tkCase: result = parseCase(p)
-  of tkTry: result = parseTry(p)
+  of tkTry: result = parseTry(p, isExpr=false)
   of tkFinally: result = parseExceptBlock(p, nkFinally)
   of tkExcept: result = parseExceptBlock(p, nkExceptBranch)
   of tkFor: result = parseFor(p)
@@ -1952,7 +1961,8 @@ proc parseStmt(p: var TParser): PNode =
           if p.tok.tokType != tkSemiColon: break
           getTok(p)
   
-proc parseAll(p: var TParser): PNode = 
+proc parseAll(p: var TParser): PNode =
+  ## Parses the rest of the input stream held by the parser into a PNode.
   result = newNodeP(nkStmtList, p)
   while p.tok.tokType != tkEof: 
     var a = complexOrSimpleStmt(p)
@@ -1966,6 +1976,8 @@ proc parseAll(p: var TParser): PNode =
       parMessage(p, errInvalidIndentation)
 
 proc parseTopLevelStmt(p: var TParser): PNode =
+  ## Implements an iterator which, when called repeatedly, returns the next
+  ## top-level statement or emptyNode if end of stream.
   result = ast.emptyNode
   while true:
     if p.tok.indent != 0: 
@@ -1984,6 +1996,10 @@ proc parseTopLevelStmt(p: var TParser): PNode =
       break
 
 proc parseString(s: string, filename: string = "", line: int = 0): PNode =
+  ## Parses a string into an AST, returning the top node.
+  ## `filename` and `line`, although optional, provide info so that the
+  ## compiler can generate correct error messages referring to the original
+  ## source.
   var stream = llStreamOpen(s)
   stream.lineOffset = line
 
diff --git a/compiler/pas2nim/nimrod.cfg b/compiler/pas2nim/nimrod.cfg
deleted file mode 100644
index cfeda63ed..000000000
--- a/compiler/pas2nim/nimrod.cfg
+++ /dev/null
@@ -1,4 +0,0 @@
-# Use the modules of the compiler
-
-path: "$nimrod/compiler"
-
diff --git a/compiler/pas2nim/pas2nim.nim b/compiler/pas2nim/pas2nim.nim
deleted file mode 100644
index d10028167..000000000
--- a/compiler/pas2nim/pas2nim.nim
+++ /dev/null
@@ -1,64 +0,0 @@
-#
-#
-#      Pas2nim - Pascal to Nimrod source converter
-#        (c) Copyright 2012 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-import
-  strutils, os, parseopt, llstream, ast, renderer, options, msgs,
-  paslex, pasparse
-
-const
-  Version = "0.8"
-  Usage = """
-pas2nim - Pascal to Nimrod source converter
-  (c) 2012 Andreas Rumpf
-Usage: pas2nim [options] inputfile [options]
-Options:
-  -o, --out:FILE         set output filename
-  --ref                  convert ^typ to ref typ (default: ptr typ)
-  --boot                 use special translation rules for the Nimrod compiler
-  -v, --version          write pas2nim's version
-  -h, --help             show this help
-"""
-
-proc main(infile, outfile: string, flags: set[TParserFlag]) =
-  var stream = llStreamOpen(infile, fmRead)
-  if stream == nil: rawMessage(errCannotOpenFile, infile)
-  var p: TParser
-  openParser(p, infile, stream, flags)
-  var module = parseUnit(p)
-  closeParser(p)
-  renderModule(module, outfile)
-
-var
-  infile = ""
-  outfile = ""
-  flags: set[TParserFlag] = {}
-for kind, key, val in getopt():
-  case kind
-  of cmdArgument: infile = key
-  of cmdLongOption, cmdShortOption:
-    case key
-    of "help", "h":
-      stdout.write(Usage)
-      quit(0)
-    of "version", "v":
-      stdout.write(Version & "\n")
-      quit(0)
-    of "o", "out": outfile = val
-    of "ref": incl(flags, pfRefs)
-    of "boot": flags = flags + {pfRefs, pfMoreReplacements, pfImportBlackList}
-    else: stdout.writeln("[Error] unknown option: " & key)
-  of cmdEnd: assert(false)
-if infile.len == 0:
-  # no filename has been given, so we show the help:
-  stdout.write(Usage)
-else:
-  if outfile.len == 0:
-    outfile = changeFileExt(infile, "nim")
-  infile = addFileExt(infile, "pas")
-  main(infile, outfile, flags)
diff --git a/compiler/pas2nim/paslex.nim b/compiler/pas2nim/paslex.nim
deleted file mode 100644
index f24b0c420..000000000
--- a/compiler/pas2nim/paslex.nim
+++ /dev/null
@@ -1,570 +0,0 @@
-#
-#
-#      Pas2nim - Pascal to Nimrod source converter
-#        (c) Copyright 2012 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-# This module implements a FreePascal scanner. This is an adaption from
-# the scanner module.
-
-import
-  hashes, options, msgs, strutils, platform, idents, nimlexbase, llstream
-
-const
-  MaxLineLength* = 80         # lines longer than this lead to a warning
-  numChars*: TCharSet = {'0'..'9', 'a'..'z', 'A'..'Z'}
-  SymChars*: TCharSet = {'a'..'z', 'A'..'Z', '0'..'9', '\x80'..'\xFF'}
-  SymStartChars*: TCharSet = {'a'..'z', 'A'..'Z', '\x80'..'\xFF'}
-  OpChars*: TCharSet = {'+', '-', '*', '/', '<', '>', '!', '?', '^', '.', '|',
-    '=', ':', '%', '&', '$', '@', '~', '\x80'..'\xFF'}
-
-# keywords are sorted!
-
-type
-  TTokKind* = enum
-    pxInvalid, pxEof,
-    pxAnd, pxArray, pxAs, pxAsm, pxBegin, pxCase, pxClass, pxConst,
-    pxConstructor, pxDestructor, pxDiv, pxDo, pxDownto, pxElse, pxEnd, pxExcept,
-    pxExports, pxFinalization, pxFinally, pxFor, pxFunction, pxGoto, pxIf,
-    pxImplementation, pxIn, pxInherited, pxInitialization, pxInline,
-    pxInterface, pxIs, pxLabel, pxLibrary, pxMod, pxNil, pxNot, pxObject, pxOf,
-    pxOr, pxOut, pxPacked, pxProcedure, pxProgram, pxProperty, pxRaise,
-    pxRecord, pxRepeat, pxResourcestring, pxSet, pxShl, pxShr, pxThen,
-    pxThreadvar, pxTo, pxTry, pxType, pxUnit, pxUntil, pxUses, pxVar, pxWhile,
-    pxWith, pxXor,
-    pxComment,                # ordinary comment
-    pxCommand,                # {@}
-    pxAmp,                    # {&}
-    pxPer,                    # {%}
-    pxStrLit, pxSymbol,       # a symbol
-    pxIntLit, pxInt64Lit, # long constant like 0x70fffffff or out of int range
-    pxFloatLit, pxParLe, pxParRi, pxBracketLe, pxBracketRi, pxComma,
-    pxSemiColon, pxColon,     # operators
-    pxAsgn, pxEquals, pxDot, pxDotDot, pxHat, pxPlus, pxMinus, pxStar, pxSlash,
-    pxLe, pxLt, pxGe, pxGt, pxNeq, pxAt, pxStarDirLe, pxStarDirRi, pxCurlyDirLe,
-    pxCurlyDirRi
-  TTokKinds* = set[TTokKind]
-
-const
-  Keywords = ["and", "array", "as", "asm", "begin", "case", "class", "const",
-    "constructor", "destructor", "div", "do", "downto", "else", "end", "except",
-    "exports", "finalization", "finally", "for", "function", "goto", "if",
-    "implementation", "in", "inherited", "initialization", "inline",
-    "interface", "is", "label", "library", "mod", "nil", "not", "object", "of",
-    "or", "out", "packed", "procedure", "program", "property", "raise",
-    "record", "repeat", "resourcestring", "set", "shl", "shr", "then",
-    "threadvar", "to", "try", "type", "unit", "until", "uses", "var", "while",
-    "with", "xor"]
-
-  firstKeyword = pxAnd
-  lastKeyword = pxXor
-
-type
-  TNumericalBase* = enum base10, base2, base8, base16
-  TToken* = object
-    xkind*: TTokKind          # the type of the token
-    ident*: PIdent            # the parsed identifier
-    iNumber*: BiggestInt      # the parsed integer literal
-    fNumber*: BiggestFloat    # the parsed floating point literal
-    base*: TNumericalBase     # the numerical base; only valid for int
-                              # or float literals
-    literal*: string          # the parsed (string) literal
-
-  TLexer* = object of TBaseLexer
-    filename*: string
-
-
-proc getTok*(L: var TLexer, tok: var TToken)
-proc printTok*(tok: TToken)
-proc `$`*(tok: TToken): string
-# implementation
-
-var
-  dummyIdent: PIdent
-  gLinesCompiled: int
-
-proc fillToken(L: var TToken) =
-  L.xkind = pxInvalid
-  L.iNumber = 0
-  L.literal = ""
-  L.fNumber = 0.0
-  L.base = base10
-  L.ident = dummyIdent        # this prevents many bugs!
-
-proc openLexer*(lex: var TLexer, filename: string, inputstream: PLLStream) =
-  openBaseLexer(lex, inputstream)
-  lex.filename = filename
-
-proc closeLexer*(lex: var TLexer) =
-  inc(gLinesCompiled, lex.LineNumber)
-  closeBaseLexer(lex)
-
-proc getColumn(L: TLexer): int =
-  result = getColNumber(L, L.bufPos)
-
-proc getLineInfo*(L: TLexer): TLineInfo =
-  result = newLineInfo(L.filename, L.linenumber, getColNumber(L, L.bufpos))
-
-proc lexMessage*(L: TLexer, msg: TMsgKind, arg = "") =
-  msgs.globalError(getLineInfo(L), msg, arg)
-
-proc lexMessagePos(L: var TLexer, msg: TMsgKind, pos: int, arg = "") =
-  var info = newLineInfo(L.filename, L.linenumber, pos - L.lineStart)
-  msgs.globalError(info, msg, arg)
-
-proc tokKindToStr*(k: TTokKind): string =
-  case k
-  of pxEof: result = "[EOF]"
-  of firstKeyword..lastKeyword:
-    result = Keywords[ord(k)-ord(firstKeyword)]
-  of pxInvalid, pxComment, pxStrLit: result = "string literal"
-  of pxCommand: result = "{@"
-  of pxAmp: result = "{&"
-  of pxPer: result = "{%"
-  of pxSymbol: result = "identifier"
-  of pxIntLit, pxInt64Lit: result = "integer literal"
-  of pxFloatLit: result = "floating point literal"
-  of pxParLe: result = "("
-  of pxParRi: result = ")"
-  of pxBracketLe: result = "["
-  of pxBracketRi: result = "]"
-  of pxComma: result = ","
-  of pxSemiColon: result = ";"
-  of pxColon: result = ":"
-  of pxAsgn: result = ":="
-  of pxEquals: result = "="
-  of pxDot: result = "."
-  of pxDotDot: result = ".."
-  of pxHat: result = "^"
-  of pxPlus: result = "+"
-  of pxMinus: result = "-"
-  of pxStar: result = "*"
-  of pxSlash: result = "/"
-  of pxLe: result = "<="
-  of pxLt: result = "<"
-  of pxGe: result = ">="
-  of pxGt: result = ">"
-  of pxNeq: result = "<>"
-  of pxAt: result = "@"
-  of pxStarDirLe: result = "(*$"
-  of pxStarDirRi: result = "*)"
-  of pxCurlyDirLe: result = "{$"
-  of pxCurlyDirRi: result = "}"
-
-proc `$`(tok: TToken): string =
-  case tok.xkind
-  of pxInvalid, pxComment, pxStrLit: result = tok.literal
-  of pxSymbol: result = tok.ident.s
-  of pxIntLit, pxInt64Lit: result = $tok.iNumber
-  of pxFloatLit: result = $tok.fNumber
-  else: result = tokKindToStr(tok.xkind)
-
-proc printTok(tok: TToken) =
-  writeln(stdout, $tok)
-
-proc setKeyword(L: var TLexer, tok: var TToken) =
-  var x = binaryStrSearch(keywords, toLower(tok.ident.s))
-  if x < 0: tok.xkind = pxSymbol
-  else: tok.xKind = TTokKind(x + ord(firstKeyword))
-
-proc matchUnderscoreChars(L: var TLexer, tok: var TToken, chars: TCharSet) =
-  # matches ([chars]_)*
-  var pos = L.bufpos              # use registers for pos, buf
-  var buf = L.buf
-  while true:
-    if buf[pos] in chars:
-      add(tok.literal, buf[pos])
-      inc(pos)
-    else:
-      break
-    if buf[pos] == '_':
-      add(tok.literal, '_')
-      inc(pos)
-  L.bufPos = pos
-
-proc isFloatLiteral(s: string): bool =
-  for i in countup(0, len(s)-1):
-    if s[i] in {'.', 'e', 'E'}:
-      return true
-
-proc getNumber2(L: var TLexer, tok: var TToken) =
-  var pos = L.bufpos + 1 # skip %
-  if not (L.buf[pos] in {'0'..'1'}):
-    # BUGFIX for %date%
-    tok.xkind = pxInvalid
-    add(tok.literal, '%')
-    inc(L.bufpos)
-    return
-  tok.base = base2
-  var xi: BiggestInt = 0
-  var bits = 0
-  while true:
-    case L.buf[pos]
-    of 'A'..'Z', 'a'..'z', '2'..'9', '.':
-      lexMessage(L, errInvalidNumber)
-      inc(pos)
-    of '_':
-      inc(pos)
-    of '0', '1':
-      xi = `shl`(xi, 1) or (ord(L.buf[pos]) - ord('0'))
-      inc(pos)
-      inc(bits)
-    else: break
-  tok.iNumber = xi
-  if (bits > 32): tok.xkind = pxInt64Lit
-  else: tok.xkind = pxIntLit
-  L.bufpos = pos
-
-proc getNumber16(L: var TLexer, tok: var TToken) =
-  var pos = L.bufpos + 1          # skip $
-  tok.base = base16
-  var xi: BiggestInt = 0
-  var bits = 0
-  while true:
-    case L.buf[pos]
-    of 'G'..'Z', 'g'..'z', '.':
-      lexMessage(L, errInvalidNumber)
-      inc(pos)
-    of '_': inc(pos)
-    of '0'..'9':
-      xi = `shl`(xi, 4) or (ord(L.buf[pos]) - ord('0'))
-      inc(pos)
-      inc(bits, 4)
-    of 'a'..'f':
-      xi = `shl`(xi, 4) or (ord(L.buf[pos]) - ord('a') + 10)
-      inc(pos)
-      inc(bits, 4)
-    of 'A'..'F':
-      xi = `shl`(xi, 4) or (ord(L.buf[pos]) - ord('A') + 10)
-      inc(pos)
-      inc(bits, 4)
-    else: break
-  tok.iNumber = xi
-  if (bits > 32):
-    tok.xkind = pxInt64Lit
-  else:
-    tok.xkind = pxIntLit
-  L.bufpos = pos
-
-proc getNumber10(L: var TLexer, tok: var TToken) =
-  tok.base = base10
-  matchUnderscoreChars(L, tok, {'0'..'9'})
-  if (L.buf[L.bufpos] == '.') and (L.buf[L.bufpos + 1] in {'0'..'9'}):
-    add(tok.literal, '.')
-    inc(L.bufpos)
-    matchUnderscoreChars(L, tok, {'e', 'E', '+', '-', '0'..'9'})
-  try:
-    if isFloatLiteral(tok.literal):
-      tok.fnumber = parseFloat(tok.literal)
-      tok.xkind = pxFloatLit
-    else:
-      tok.iNumber = parseInt(tok.literal)
-      if (tok.iNumber < low(int32)) or (tok.iNumber > high(int32)):
-        tok.xkind = pxInt64Lit
-      else:
-        tok.xkind = pxIntLit
-  except EInvalidValue:
-    lexMessage(L, errInvalidNumber, tok.literal)
-  except EOverflow:
-    lexMessage(L, errNumberOutOfRange, tok.literal)
-
-proc handleCRLF(L: var TLexer, pos: int): int =
-  case L.buf[pos]
-  of CR: result = nimlexbase.handleCR(L, pos)
-  of LF: result = nimlexbase.handleLF(L, pos)
-  else: result = pos
-
-proc getString(L: var TLexer, tok: var TToken) =
-  var xi: int
-  var pos = L.bufPos
-  var buf = L.buf
-  while true:
-    if buf[pos] == '\'':
-      inc(pos)
-      while true:
-        case buf[pos]
-        of CR, LF, nimlexbase.EndOfFile:
-          lexMessage(L, errClosingQuoteExpected)
-          break
-        of '\'':
-          inc(pos)
-          if buf[pos] == '\'':
-            inc(pos)
-            add(tok.literal, '\'')
-          else:
-            break
-        else:
-          add(tok.literal, buf[pos])
-          inc(pos)
-    elif buf[pos] == '#':
-      inc(pos)
-      xi = 0
-      case buf[pos]
-      of '$':
-        inc(pos)
-        xi = 0
-        while true:
-          case buf[pos]
-          of '0'..'9': xi = (xi shl 4) or (ord(buf[pos]) - ord('0'))
-          of 'a'..'f': xi = (xi shl 4) or (ord(buf[pos]) - ord('a') + 10)
-          of 'A'..'F': xi = (xi shl 4) or (ord(buf[pos]) - ord('A') + 10)
-          else: break
-          inc(pos)
-      of '0'..'9':
-        xi = 0
-        while buf[pos] in {'0'..'9'}:
-          xi = (xi * 10) + (ord(buf[pos]) - ord('0'))
-          inc(pos)
-      else: lexMessage(L, errInvalidCharacterConstant)
-      if (xi <= 255): add(tok.literal, chr(xi))
-      else: lexMessage(L, errInvalidCharacterConstant)
-    else:
-      break
-  tok.xkind = pxStrLit
-  L.bufpos = pos
-
-proc getSymbol(L: var TLexer, tok: var TToken) =
-  var h: THash = 0
-  var pos = L.bufpos
-  var buf = L.buf
-  while true:
-    var c = buf[pos]
-    case c
-    of 'a'..'z', '0'..'9', '\x80'..'\xFF':
-      h = h +% ord(c)
-      h = h +% h shl 10
-      h = h xor (h shr 6)
-    of 'A'..'Z':
-      c = chr(ord(c) + (ord('a') - ord('A'))) # toLower()
-      h = h +% ord(c)
-      h = h +% h shl 10
-      h = h xor (h shr 6)
-    of '_': discard
-    else: break
-    inc(pos)
-  h = h +% h shl 3
-  h = h xor (h shr 11)
-  h = h +% h shl 15
-  tok.ident = getIdent(addr(L.buf[L.bufpos]), pos - L.bufpos, h)
-  L.bufpos = pos
-  setKeyword(L, tok)
-
-proc scanLineComment(L: var TLexer, tok: var TToken) =
-  var pos = L.bufpos
-  var buf = L.buf
-  # a comment ends if the next line does not start with the // on the same
-  # column after only whitespace
-  tok.xkind = pxComment
-  var col = getColNumber(L, pos)
-  while true:
-    inc(pos, 2)               # skip //
-    add(tok.literal, '#')
-    while not (buf[pos] in {CR, LF, nimlexbase.EndOfFile}):
-      add(tok.literal, buf[pos])
-      inc(pos)
-    pos = handleCRLF(L, pos)
-    buf = L.buf
-    var indent = 0
-    while buf[pos] == ' ':
-      inc(pos)
-      inc(indent)
-    if (col == indent) and (buf[pos] == '/') and (buf[pos + 1] == '/'):
-      tok.literal = tok.literal & "\n"
-    else:
-      break
-  L.bufpos = pos
-
-proc scanCurlyComment(L: var TLexer, tok: var TToken) =
-  var pos = L.bufpos
-  var buf = L.buf
-  tok.literal = "#"
-  tok.xkind = pxComment
-  while true:
-    case buf[pos]
-    of CR, LF:
-      pos = handleCRLF(L, pos)
-      buf = L.buf
-      add(tok.literal, "\n#")
-    of '}':
-      inc(pos)
-      break
-    of nimlexbase.EndOfFile: lexMessage(L, errTokenExpected, "}")
-    else:
-      add(tok.literal, buf[pos])
-      inc(pos)
-  L.bufpos = pos
-
-proc scanStarComment(L: var TLexer, tok: var TToken) =
-  var pos = L.bufpos
-  var buf = L.buf
-  tok.literal = "#"
-  tok.xkind = pxComment
-  while true:
-    case buf[pos]
-    of CR, LF:
-      pos = handleCRLF(L, pos)
-      buf = L.buf
-      add(tok.literal, "\n#")
-    of '*':
-      inc(pos)
-      if buf[pos] == ')':
-        inc(pos)
-        break
-      else:
-        add(tok.literal, '*')
-    of nimlexbase.EndOfFile:
-      lexMessage(L, errTokenExpected, "*)")
-    else:
-      add(tok.literal, buf[pos])
-      inc(pos)
-  L.bufpos = pos
-
-proc skip(L: var TLexer, tok: var TToken) =
-  var pos = L.bufpos
-  var buf = L.buf
-  while true:
-    case buf[pos]
-    of ' ', Tabulator:
-      inc(pos)                # newline is special:
-    of CR, LF:
-      pos = handleCRLF(L, pos)
-      buf = L.buf
-    else:
-      break                   # EndOfFile also leaves the loop
-  L.bufpos = pos
-
-proc getTok(L: var TLexer, tok: var TToken) =
-  tok.xkind = pxInvalid
-  fillToken(tok)
-  skip(L, tok)
-  var c = L.buf[L.bufpos]
-  if c in SymStartChars:
-    getSymbol(L, tok)
-  elif c in {'0'..'9'}:
-    getNumber10(L, tok)
-  else:
-    case c
-    of ';':
-      tok.xkind = pxSemicolon
-      inc(L.bufpos)
-    of '/':
-      if L.buf[L.bufpos + 1] == '/':
-        scanLineComment(L, tok)
-      else:
-        tok.xkind = pxSlash
-        inc(L.bufpos)
-    of ',':
-      tok.xkind = pxComma
-      inc(L.bufpos)
-    of '(':
-      inc(L.bufpos)
-      if (L.buf[L.bufPos] == '*'):
-        if (L.buf[L.bufPos + 1] == '$'):
-          inc(L.bufpos, 2)
-          skip(L, tok)
-          getSymbol(L, tok)
-          tok.xkind = pxStarDirLe
-        else:
-          inc(L.bufpos)
-          scanStarComment(L, tok)
-      else:
-        tok.xkind = pxParLe
-    of '*':
-      inc(L.bufpos)
-      if L.buf[L.bufpos] == ')':
-        inc(L.bufpos)
-        tok.xkind = pxStarDirRi
-      else:
-        tok.xkind = pxStar
-    of ')':
-      tok.xkind = pxParRi
-      inc(L.bufpos)
-    of '[':
-      inc(L.bufpos)
-      tok.xkind = pxBracketLe
-    of ']':
-      inc(L.bufpos)
-      tok.xkind = pxBracketRi
-    of '.':
-      inc(L.bufpos)
-      if L.buf[L.bufpos] == '.':
-        tok.xkind = pxDotDot
-        inc(L.bufpos)
-      else:
-        tok.xkind = pxDot
-    of '{':
-      inc(L.bufpos)
-      case L.buf[L.bufpos]
-      of '$':
-        inc(L.bufpos)
-        skip(L, tok)
-        getSymbol(L, tok)
-        tok.xkind = pxCurlyDirLe
-      of '&':
-        inc(L.bufpos)
-        tok.xkind = pxAmp
-      of '%':
-        inc(L.bufpos)
-        tok.xkind = pxPer
-      of '@':
-        inc(L.bufpos)
-        tok.xkind = pxCommand
-      else: scanCurlyComment(L, tok)
-    of '+':
-      tok.xkind = pxPlus
-      inc(L.bufpos)
-    of '-':
-      tok.xkind = pxMinus
-      inc(L.bufpos)
-    of ':':
-      inc(L.bufpos)
-      if L.buf[L.bufpos] == '=':
-        inc(L.bufpos)
-        tok.xkind = pxAsgn
-      else:
-        tok.xkind = pxColon
-    of '<':
-      inc(L.bufpos)
-      if L.buf[L.bufpos] == '>':
-        inc(L.bufpos)
-        tok.xkind = pxNeq
-      elif L.buf[L.bufpos] == '=':
-        inc(L.bufpos)
-        tok.xkind = pxLe
-      else:
-        tok.xkind = pxLt
-    of '>':
-      inc(L.bufpos)
-      if L.buf[L.bufpos] == '=':
-        inc(L.bufpos)
-        tok.xkind = pxGe
-      else:
-        tok.xkind = pxGt
-    of '=':
-      tok.xkind = pxEquals
-      inc(L.bufpos)
-    of '@':
-      tok.xkind = pxAt
-      inc(L.bufpos)
-    of '^':
-      tok.xkind = pxHat
-      inc(L.bufpos)
-    of '}':
-      tok.xkind = pxCurlyDirRi
-      inc(L.bufpos)
-    of '\'', '#':
-      getString(L, tok)
-    of '$':
-      getNumber16(L, tok)
-    of '%':
-      getNumber2(L, tok)
-    of nimlexbase.EndOfFile:
-      tok.xkind = pxEof
-    else:
-      tok.literal = c & ""
-      tok.xkind = pxInvalid
-      lexMessage(L, errInvalidToken, c & " (\\" & $(ord(c)) & ')')
-      inc(L.bufpos)
diff --git a/compiler/pas2nim/pasparse.nim b/compiler/pas2nim/pasparse.nim
deleted file mode 100644
index a6f8363f6..000000000
--- a/compiler/pas2nim/pasparse.nim
+++ /dev/null
@@ -1,1513 +0,0 @@
-#
-#
-#      Pas2nim - Pascal to Nimrod source converter
-#        (c) Copyright 2012 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-# This module implements the parser of the Pascal variant Nimrod is written in.
-# It transfers a Pascal module into a Nimrod AST. Then the renderer can be
-# used to convert the AST to its text representation.
-
-import 
-  os, llstream, paslex, idents, strutils, ast, astalgo, msgs, options
-
-type 
-  TSection = enum 
-    seImplementation, seInterface
-  TContext = enum 
-    conExpr, conStmt, conTypeDesc
-  TParserFlag* = enum
-    pfRefs,             ## use "ref" instead of "ptr" for Pascal's ^typ
-    pfMoreReplacements, ## use more than the default replacements
-    pfImportBlackList   ## use import blacklist
-  TParser*{.final.} = object
-    section: TSection
-    inParamList: bool
-    context: TContext     # needed for the @emit command
-    lastVarSection: PNode
-    lex: TLexer
-    tok: TToken
-    repl: TIdTable           # replacements
-    flags: set[TParserFlag]
-  
-  TReplaceTuple* = array[0..1, string]
-
-const 
-  ImportBlackList*: array[1..3, string] = ["nsystem", "sysutils", "charsets"]
-  stdReplacements*: array[1..19, TReplaceTuple] = [["include", "incl"], 
-    ["exclude", "excl"], ["pchar", "cstring"], ["assignfile", "open"], 
-    ["integer", "int"], ["longword", "int32"], ["cardinal", "int"], 
-    ["boolean", "bool"], ["shortint", "int8"], ["smallint", "int16"], 
-    ["longint", "int32"], ["byte", "int8"], ["word", "int16"], 
-    ["single", "float32"], ["double", "float64"], ["real", "float"], 
-    ["length", "len"], ["len", "length"], ["setlength", "setlen"]]
-  nimReplacements*: array[1..35, TReplaceTuple] = [["nimread", "read"], 
-    ["nimwrite", "write"], ["nimclosefile", "close"], ["closefile", "close"], 
-    ["openfile", "open"], ["nsystem", "system"], ["ntime", "times"], 
-    ["nos", "os"], ["nmath", "math"], ["ncopy", "copy"], ["addChar", "add"], 
-    ["halt", "quit"], ["nobject", "TObject"], ["eof", "EndOfFile"], 
-    ["input", "stdin"], ["output", "stdout"], ["addu", "`+%`"], 
-    ["subu", "`-%`"], ["mulu", "`*%`"], ["divu", "`/%`"], ["modu", "`%%`"], 
-    ["ltu", "`<%`"], ["leu", "`<=%`"], ["shlu", "`shl`"], ["shru", "`shr`"], 
-    ["assigned", "not isNil"], ["eintoverflow", "EOverflow"], ["format", "`%`"], 
-    ["snil", "nil"], ["tostringf", "$"], ["ttextfile", "tfile"], 
-    ["tbinaryfile", "tfile"], ["strstart", "0"], ["nl", "\"\\n\""],
-    ["tostring", "$"]]
-
-proc parseUnit*(p: var TParser): PNode
-proc openParser*(p: var TParser, filename: string, inputStream: PLLStream,
-                 flags: set[TParserFlag] = {})
-proc closeParser*(p: var TParser)
-proc exSymbol*(n: var PNode)
-proc fixRecordDef*(n: var PNode)
-  # XXX: move these two to an auxiliary module
-
-# implementation
-
-proc openParser(p: var TParser, filename: string, 
-                inputStream: PLLStream, flags: set[TParserFlag] = {}) = 
-  openLexer(p.lex, filename, inputStream)
-  initIdTable(p.repl)
-  for i in countup(low(stdReplacements), high(stdReplacements)): 
-    idTablePut(p.repl, getIdent(stdReplacements[i][0]), 
-               getIdent(stdReplacements[i][1]))
-  if pfMoreReplacements in flags: 
-    for i in countup(low(nimReplacements), high(nimReplacements)): 
-      idTablePut(p.repl, getIdent(nimReplacements[i][0]), 
-                 getIdent(nimReplacements[i][1]))
-  p.flags = flags
-  
-proc closeParser(p: var TParser) = closeLexer(p.lex)
-proc getTok(p: var TParser) = getTok(p.lex, p.tok)
-
-proc parMessage(p: TParser, msg: TMsgKind, arg = "") = 
-  lexMessage(p.lex, msg, arg)
-
-proc parLineInfo(p: TParser): TLineInfo = 
-  result = getLineInfo(p.lex)
-
-proc skipCom(p: var TParser, n: PNode) = 
-  while p.tok.xkind == pxComment: 
-    if (n != nil): 
-      if n.comment == nil: n.comment = p.tok.literal
-      else: add(n.comment, "\n" & p.tok.literal)
-    else: 
-      parMessage(p, warnCommentXIgnored, p.tok.literal)
-    getTok(p)
-
-proc expectIdent(p: TParser) = 
-  if p.tok.xkind != pxSymbol: 
-    lexMessage(p.lex, errIdentifierExpected, $(p.tok))
-  
-proc eat(p: var TParser, xkind: TTokKind) = 
-  if p.tok.xkind == xkind: getTok(p)
-  else: lexMessage(p.lex, errTokenExpected, tokKindToStr(xkind))
-  
-proc opt(p: var TParser, xkind: TTokKind) = 
-  if p.tok.xkind == xkind: getTok(p)
-  
-proc newNodeP(kind: TNodeKind, p: TParser): PNode = 
-  result = newNodeI(kind, getLineInfo(p.lex))
-
-proc newIntNodeP(kind: TNodeKind, intVal: BiggestInt, p: TParser): PNode = 
-  result = newNodeP(kind, p)
-  result.intVal = intVal
-
-proc newFloatNodeP(kind: TNodeKind, floatVal: BiggestFloat, 
-                   p: TParser): PNode = 
-  result = newNodeP(kind, p)
-  result.floatVal = floatVal
-
-proc newStrNodeP(kind: TNodeKind, strVal: string, p: TParser): PNode = 
-  result = newNodeP(kind, p)
-  result.strVal = strVal
-
-proc newIdentNodeP(ident: PIdent, p: TParser): PNode = 
-  result = newNodeP(nkIdent, p)
-  result.ident = ident
-
-proc createIdentNodeP(ident: PIdent, p: TParser): PNode = 
-  result = newNodeP(nkIdent, p)
-  var x = PIdent(idTableGet(p.repl, ident))
-  if x != nil: result.ident = x
-  else: result.ident = ident
-  
-proc parseExpr(p: var TParser): PNode
-proc parseStmt(p: var TParser): PNode
-proc parseTypeDesc(p: var TParser, definition: PNode = nil): PNode
-
-proc parseEmit(p: var TParser, definition: PNode): PNode = 
-  getTok(p)                   # skip 'emit'
-  result = ast.emptyNode
-  if p.tok.xkind != pxCurlyDirRi: 
-    case p.context
-    of conExpr: 
-      result = parseExpr(p)
-    of conStmt: 
-      result = parseStmt(p)
-      if p.tok.xkind != pxCurlyDirRi: 
-        var a = result
-        result = newNodeP(nkStmtList, p)
-        addSon(result, a)
-        while p.tok.xkind != pxCurlyDirRi: 
-          addSon(result, parseStmt(p))
-    of conTypeDesc: 
-      result = parseTypeDesc(p, definition)
-  eat(p, pxCurlyDirRi)
-
-proc parseCommand(p: var TParser, definition: PNode = nil): PNode = 
-  result = ast.emptyNode
-  getTok(p)
-  if p.tok.ident.id == getIdent("discard").id: 
-    result = newNodeP(nkDiscardStmt, p)
-    getTok(p)
-    eat(p, pxCurlyDirRi)
-    addSon(result, parseExpr(p))
-  elif p.tok.ident.id == getIdent("set").id: 
-    getTok(p)
-    eat(p, pxCurlyDirRi)
-    result = parseExpr(p)
-    if result.kind == nkEmpty: internalError("emptyNode modified")
-    result.kind = nkCurly
-  elif p.tok.ident.id == getIdent("cast").id: 
-    getTok(p)
-    eat(p, pxCurlyDirRi)
-    var a = parseExpr(p)
-    if (a.kind == nkCall) and (sonsLen(a) == 2): 
-      result = newNodeP(nkCast, p)
-      addSon(result, a.sons[0])
-      addSon(result, a.sons[1])
-    else: 
-      parMessage(p, errInvalidDirectiveX, $p.tok)
-      result = a
-  elif p.tok.ident.id == getIdent("emit").id: 
-    result = parseEmit(p, definition)
-  elif p.tok.ident.id == getIdent("ignore").id: 
-    getTok(p)
-    eat(p, pxCurlyDirRi)
-    while true: 
-      case p.tok.xkind
-      of pxEof: 
-        parMessage(p, errTokenExpected, "{@emit}")
-      of pxCommand: 
-        getTok(p)
-        if p.tok.ident.id == getIdent("emit").id: 
-          result = parseEmit(p, definition)
-          break 
-        else: 
-          while (p.tok.xkind != pxCurlyDirRi) and (p.tok.xkind != pxEof): 
-            getTok(p)
-          eat(p, pxCurlyDirRi)
-      else: 
-        getTok(p)             # skip token
-  elif p.tok.ident.id == getIdent("ptr").id: 
-    result = newNodeP(nkPtrTy, p)
-    getTok(p)
-    eat(p, pxCurlyDirRi)
-  elif p.tok.ident.id == getIdent("tuple").id: 
-    result = newNodeP(nkTupleTy, p)
-    getTok(p)
-    eat(p, pxCurlyDirRi)
-  elif p.tok.ident.id == getIdent("acyclic").id: 
-    result = newIdentNodeP(p.tok.ident, p)
-    getTok(p)
-    eat(p, pxCurlyDirRi)
-  else: 
-    parMessage(p, errInvalidDirectiveX, $p.tok)
-    while true: 
-      getTok(p)
-      if p.tok.xkind == pxCurlyDirRi or p.tok.xkind == pxEof: break 
-    eat(p, pxCurlyDirRi)
-    result = ast.emptyNode
-
-proc getPrecedence(kind: TTokKind): int = 
-  case kind
-  of pxDiv, pxMod, pxStar, pxSlash, pxShl, pxShr, pxAnd: result = 5
-  of pxPlus, pxMinus, pxOr, pxXor: result = 4
-  of pxIn, pxEquals, pxLe, pxLt, pxGe, pxGt, pxNeq, pxIs: result = 3
-  else: result = -1
-  
-proc rangeExpr(p: var TParser): PNode = 
-  var a = parseExpr(p)
-  if p.tok.xkind == pxDotDot: 
-    result = newNodeP(nkRange, p)
-    addSon(result, a)
-    getTok(p)
-    skipCom(p, result)
-    addSon(result, parseExpr(p))
-  else: 
-    result = a
-  
-proc bracketExprList(p: var TParser, first: PNode): PNode = 
-  result = newNodeP(nkBracketExpr, p)
-  addSon(result, first)
-  getTok(p)
-  skipCom(p, result)
-  while true: 
-    if p.tok.xkind == pxBracketRi: 
-      getTok(p)
-      break 
-    if p.tok.xkind == pxEof: 
-      parMessage(p, errTokenExpected, tokKindToStr(pxBracketRi))
-      break 
-    var a = rangeExpr(p)
-    skipCom(p, a)
-    if p.tok.xkind == pxComma: 
-      getTok(p)
-      skipCom(p, a)
-    addSon(result, a)
-
-proc exprColonEqExpr(p: var TParser, kind: TNodeKind, 
-                     tok: TTokKind): PNode = 
-  var a = parseExpr(p)
-  if p.tok.xkind == tok: 
-    result = newNodeP(kind, p)
-    getTok(p)
-    skipCom(p, result)
-    addSon(result, a)
-    addSon(result, parseExpr(p))
-  else: 
-    result = a
-  
-proc exprListAux(p: var TParser, elemKind: TNodeKind, 
-                 endTok, sepTok: TTokKind, result: PNode) = 
-  getTok(p)
-  skipCom(p, result)
-  while true: 
-    if p.tok.xkind == endTok: 
-      getTok(p)
-      break 
-    if p.tok.xkind == pxEof: 
-      parMessage(p, errTokenExpected, tokKindToStr(endTok))
-      break 
-    var a = exprColonEqExpr(p, elemKind, sepTok)
-    skipCom(p, a)
-    if (p.tok.xkind == pxComma) or (p.tok.xkind == pxSemicolon): 
-      getTok(p)
-      skipCom(p, a)
-    addSon(result, a)
-
-proc qualifiedIdent(p: var TParser): PNode = 
-  if p.tok.xkind == pxSymbol: 
-    result = createIdentNodeP(p.tok.ident, p)
-  else: 
-    parMessage(p, errIdentifierExpected, $p.tok)
-    return ast.emptyNode
-  getTok(p)
-  skipCom(p, result)
-  if p.tok.xkind == pxDot: 
-    getTok(p)
-    skipCom(p, result)
-    if p.tok.xkind == pxSymbol: 
-      var a = result
-      result = newNodeI(nkDotExpr, a.info)
-      addSon(result, a)
-      addSon(result, createIdentNodeP(p.tok.ident, p))
-      getTok(p)
-    else: 
-      parMessage(p, errIdentifierExpected, $p.tok)
-  
-proc qualifiedIdentListAux(p: var TParser, endTok: TTokKind, 
-                           result: PNode) = 
-  getTok(p)
-  skipCom(p, result)
-  while true: 
-    if p.tok.xkind == endTok: 
-      getTok(p)
-      break 
-    if p.tok.xkind == pxEof: 
-      parMessage(p, errTokenExpected, tokKindToStr(endTok))
-      break 
-    var a = qualifiedIdent(p)
-    skipCom(p, a)
-    if p.tok.xkind == pxComma: 
-      getTok(p)
-      skipCom(p, a)
-    addSon(result, a)
-
-proc exprColonEqExprList(p: var TParser, kind, elemKind: TNodeKind, 
-                         endTok, sepTok: TTokKind): PNode = 
-  result = newNodeP(kind, p)
-  exprListAux(p, elemKind, endTok, sepTok, result)
-
-proc setBaseFlags(n: PNode, base: TNumericalBase) = 
-  case base
-  of base10: discard
-  of base2: incl(n.flags, nfBase2)
-  of base8: incl(n.flags, nfBase8)
-  of base16: incl(n.flags, nfBase16)
-  
-proc identOrLiteral(p: var TParser): PNode = 
-  case p.tok.xkind
-  of pxSymbol: 
-    result = createIdentNodeP(p.tok.ident, p)
-    getTok(p)
-  of pxIntLit: 
-    result = newIntNodeP(nkIntLit, p.tok.iNumber, p)
-    setBaseFlags(result, p.tok.base)
-    getTok(p)
-  of pxInt64Lit: 
-    result = newIntNodeP(nkInt64Lit, p.tok.iNumber, p)
-    setBaseFlags(result, p.tok.base)
-    getTok(p)
-  of pxFloatLit: 
-    result = newFloatNodeP(nkFloatLit, p.tok.fNumber, p)
-    setBaseFlags(result, p.tok.base)
-    getTok(p)
-  of pxStrLit: 
-    if len(p.tok.literal) != 1: result = newStrNodeP(nkStrLit, p.tok.literal, p)
-    else: result = newIntNodeP(nkCharLit, ord(p.tok.literal[0]), p)
-    getTok(p)
-  of pxNil: 
-    result = newNodeP(nkNilLit, p)
-    getTok(p)
-  of pxParLe: 
-    # () constructor
-    result = exprColonEqExprList(p, nkPar, nkExprColonExpr, pxParRi, pxColon)
-    #if hasSonWith(result, nkExprColonExpr) then
-    #  replaceSons(result, nkExprColonExpr, nkExprEqExpr)
-    if (sonsLen(result) > 1) and not hasSonWith(result, nkExprColonExpr): 
-      result.kind = nkBracket # is an array constructor
-  of pxBracketLe: 
-    # [] constructor
-    result = newNodeP(nkBracket, p)
-    getTok(p)
-    skipCom(p, result)
-    while (p.tok.xkind != pxBracketRi) and (p.tok.xkind != pxEof): 
-      var a = rangeExpr(p)
-      if a.kind == nkRange: 
-        result.kind = nkCurly # it is definitely a set literal
-      opt(p, pxComma)
-      skipCom(p, a)
-      assert(a != nil)
-      addSon(result, a)
-    eat(p, pxBracketRi)
-  of pxCommand: 
-    result = parseCommand(p)
-  else: 
-    parMessage(p, errExprExpected, $(p.tok))
-    getTok(p) # we must consume a token here to prevend endless loops!
-    result = ast.emptyNode
-  if result.kind != nkEmpty: skipCom(p, result)
-  
-proc primary(p: var TParser): PNode = 
-  # prefix operator?
-  if (p.tok.xkind == pxNot) or (p.tok.xkind == pxMinus) or
-      (p.tok.xkind == pxPlus): 
-    result = newNodeP(nkPrefix, p)
-    var a = newIdentNodeP(getIdent($p.tok), p)
-    addSon(result, a)
-    getTok(p)
-    skipCom(p, a)
-    addSon(result, primary(p))
-    return 
-  elif p.tok.xkind == pxAt: 
-    result = newNodeP(nkAddr, p)
-    var a = newIdentNodeP(getIdent($p.tok), p)
-    getTok(p)
-    if p.tok.xkind == pxBracketLe: 
-      result = newNodeP(nkPrefix, p)
-      addSon(result, a)
-      addSon(result, identOrLiteral(p))
-    else: 
-      addSon(result, primary(p))
-    return 
-  result = identOrLiteral(p)
-  while true: 
-    case p.tok.xkind
-    of pxParLe: 
-      var a = result
-      result = newNodeP(nkCall, p)
-      addSon(result, a)
-      exprListAux(p, nkExprEqExpr, pxParRi, pxEquals, result)
-    of pxDot: 
-      var a = result
-      result = newNodeP(nkDotExpr, p)
-      addSon(result, a)
-      getTok(p)               # skip '.'
-      skipCom(p, result)
-      if p.tok.xkind == pxSymbol: 
-        addSon(result, createIdentNodeP(p.tok.ident, p))
-        getTok(p)
-      else: 
-        parMessage(p, errIdentifierExpected, $p.tok)
-    of pxHat: 
-      var a = result
-      result = newNodeP(nkBracketExpr, p)
-      addSon(result, a)
-      getTok(p)
-    of pxBracketLe: 
-      result = bracketExprList(p, result)
-    else: break 
-  
-proc lowestExprAux(p: var TParser, v: var PNode, limit: int): TTokKind = 
-  var 
-    nextop: TTokKind
-    v2, node, opNode: PNode
-  v = primary(p) # expand while operators have priorities higher than 'limit'
-  var op = p.tok.xkind
-  var opPred = getPrecedence(op)
-  while (opPred > limit): 
-    node = newNodeP(nkInfix, p)
-    opNode = newIdentNodeP(getIdent($(p.tok)), p) # skip operator:
-    getTok(p)
-    case op
-    of pxPlus: 
-      case p.tok.xkind
-      of pxPer: 
-        getTok(p)
-        eat(p, pxCurlyDirRi)
-        opNode.ident = getIdent("+%")
-      of pxAmp: 
-        getTok(p)
-        eat(p, pxCurlyDirRi)
-        opNode.ident = getIdent("&")
-      else: 
-        discard
-    of pxMinus: 
-      if p.tok.xkind == pxPer: 
-        getTok(p)
-        eat(p, pxCurlyDirRi)
-        opNode.ident = getIdent("-%")
-    of pxEquals: 
-      opNode.ident = getIdent("==")
-    of pxNeq: 
-      opNode.ident = getIdent("!=")
-    else: 
-      discard
-    skipCom(p, opNode)        # read sub-expression with higher priority
-    nextop = lowestExprAux(p, v2, opPred)
-    addSon(node, opNode)
-    addSon(node, v)
-    addSon(node, v2)
-    v = node
-    op = nextop
-    opPred = getPrecedence(nextop)
-  result = op                 # return first untreated operator
-  
-proc fixExpr(n: PNode): PNode = 
-  result = n
-  case n.kind
-  of nkInfix: 
-    if n.sons[1].kind == nkBracket: n.sons[1].kind = nkCurly
-    if n.sons[2].kind == nkBracket: n.sons[2].kind = nkCurly
-    if (n.sons[0].kind == nkIdent): 
-      if (n.sons[0].ident.id == getIdent("+").id): 
-        if (n.sons[1].kind == nkCharLit) and (n.sons[2].kind == nkStrLit) and
-            (n.sons[2].strVal == ""): 
-          result = newStrNode(nkStrLit, chr(int(n.sons[1].intVal)) & "")
-          result.info = n.info
-          return              # do not process sons as they don't exist anymore
-        elif (n.sons[1].kind in {nkCharLit, nkStrLit}) or
-            (n.sons[2].kind in {nkCharLit, nkStrLit}): 
-          n.sons[0].ident = getIdent("&") # fix operator
-  else: 
-    discard
-  if not (n.kind in {nkEmpty..nkNilLit}): 
-    for i in countup(0, sonsLen(n) - 1): result.sons[i] = fixExpr(n.sons[i])
-  
-proc parseExpr(p: var TParser): PNode = 
-  var oldcontext = p.context
-  p.context = conExpr
-  if p.tok.xkind == pxCommand: 
-    result = parseCommand(p)
-  else: 
-    discard lowestExprAux(p, result, - 1)
-    result = fixExpr(result)
-  p.context = oldcontext
-
-proc parseExprStmt(p: var TParser): PNode = 
-  var info = parLineInfo(p)
-  var a = parseExpr(p)
-  if p.tok.xkind == pxAsgn: 
-    getTok(p)
-    skipCom(p, a)
-    var b = parseExpr(p)
-    result = newNodeI(nkAsgn, info)
-    addSon(result, a)
-    addSon(result, b)
-  else: 
-    result = a
-  
-proc inImportBlackList(ident: PIdent): bool = 
-  for i in countup(low(ImportBlackList), high(ImportBlackList)): 
-    if ident.id == getIdent(ImportBlackList[i]).id: 
-      return true
-
-proc parseUsesStmt(p: var TParser): PNode = 
-  var a: PNode
-  result = newNodeP(nkImportStmt, p)
-  getTok(p)                   # skip `import`
-  skipCom(p, result)
-  while true: 
-    case p.tok.xkind
-    of pxEof: break 
-    of pxSymbol: a = newIdentNodeP(p.tok.ident, p)
-    else: 
-      parMessage(p, errIdentifierExpected, $(p.tok))
-      break 
-    getTok(p)                 # skip identifier, string
-    skipCom(p, a)
-    if pfImportBlackList notin p.flags or not inImportBlackList(a.ident): 
-      addSon(result, createIdentNodeP(a.ident, p))
-    if p.tok.xkind == pxComma: 
-      getTok(p)
-      skipCom(p, a)
-    else: 
-      break 
-  if sonsLen(result) == 0: result = ast.emptyNode
-  
-proc parseIncludeDir(p: var TParser): PNode = 
-  result = newNodeP(nkIncludeStmt, p)
-  getTok(p)                   # skip `include`
-  var filename = ""
-  while true: 
-    case p.tok.xkind
-    of pxSymbol, pxDot, pxDotDot, pxSlash: 
-      add(filename, $p.tok)
-      getTok(p)
-    of pxStrLit: 
-      filename = p.tok.literal
-      getTok(p)
-      break 
-    of pxCurlyDirRi: 
-      break 
-    else: 
-      parMessage(p, errIdentifierExpected, $p.tok)
-      break 
-  addSon(result, newStrNodeP(nkStrLit, changeFileExt(filename, "nim"), p))
-  if filename == "config.inc": result = ast.emptyNode
-  
-proc definedExprAux(p: var TParser): PNode = 
-  result = newNodeP(nkCall, p)
-  addSon(result, newIdentNodeP(getIdent("defined"), p))
-  expectIdent(p)
-  addSon(result, createIdentNodeP(p.tok.ident, p))
-  getTok(p)
-
-proc isHandledDirective(p: TParser): bool = 
-  if p.tok.xkind in {pxCurlyDirLe, pxStarDirLe}: 
-    case toLower(p.tok.ident.s)
-    of "else", "endif": result = false
-    else: result = true
-  
-proc parseStmtList(p: var TParser): PNode = 
-  result = newNodeP(nkStmtList, p)
-  while true: 
-    case p.tok.xkind
-    of pxEof: 
-      break 
-    of pxCurlyDirLe, pxStarDirLe: 
-      if not isHandledDirective(p): break 
-    else: 
-      discard
-    addSon(result, parseStmt(p))
-  if sonsLen(result) == 1: result = result.sons[0]
-  
-proc parseIfDirAux(p: var TParser, result: PNode) = 
-  addSon(result.sons[0], parseStmtList(p))
-  if p.tok.xkind in {pxCurlyDirLe, pxStarDirLe}: 
-    var endMarker = succ(p.tok.xkind)
-    if toLower(p.tok.ident.s) == "else": 
-      var s = newNodeP(nkElse, p)
-      while p.tok.xkind != pxEof and p.tok.xkind != endMarker: getTok(p)
-      eat(p, endMarker)
-      addSon(s, parseStmtList(p))
-      addSon(result, s)
-    if p.tok.xkind in {pxCurlyDirLe, pxStarDirLe}: 
-      endMarker = succ(p.tok.xkind)
-      if toLower(p.tok.ident.s) == "endif": 
-        while p.tok.xkind != pxEof and p.tok.xkind != endMarker: getTok(p)
-        eat(p, endMarker)
-      else: 
-        parMessage(p, errXExpected, "{$endif}")
-  else: 
-    parMessage(p, errXExpected, "{$endif}")
-  
-proc parseIfdefDir(p: var TParser, endMarker: TTokKind): PNode = 
-  result = newNodeP(nkWhenStmt, p)
-  addSon(result, newNodeP(nkElifBranch, p))
-  getTok(p)
-  addSon(result.sons[0], definedExprAux(p))
-  eat(p, endMarker)
-  parseIfDirAux(p, result)
-
-proc parseIfndefDir(p: var TParser, endMarker: TTokKind): PNode = 
-  result = newNodeP(nkWhenStmt, p)
-  addSon(result, newNodeP(nkElifBranch, p))
-  getTok(p)
-  var e = newNodeP(nkCall, p)
-  addSon(e, newIdentNodeP(getIdent("not"), p))
-  addSon(e, definedExprAux(p))
-  eat(p, endMarker)
-  addSon(result.sons[0], e)
-  parseIfDirAux(p, result)
-
-proc parseIfDir(p: var TParser, endMarker: TTokKind): PNode = 
-  result = newNodeP(nkWhenStmt, p)
-  addSon(result, newNodeP(nkElifBranch, p))
-  getTok(p)
-  addSon(result.sons[0], parseExpr(p))
-  eat(p, endMarker)
-  parseIfDirAux(p, result)
-
-proc parseDirective(p: var TParser): PNode = 
-  result = ast.emptyNode
-  if not (p.tok.xkind in {pxCurlyDirLe, pxStarDirLe}): return 
-  var endMarker = succ(p.tok.xkind)
-  if p.tok.ident != nil: 
-    case toLower(p.tok.ident.s)
-    of "include": 
-      result = parseIncludeDir(p)
-      eat(p, endMarker)
-    of "if": result = parseIfDir(p, endMarker)
-    of "ifdef": result = parseIfdefDir(p, endMarker)
-    of "ifndef": result = parseIfndefDir(p, endMarker)
-    else: 
-      # skip unknown compiler directive
-      while p.tok.xkind != pxEof and p.tok.xkind != endMarker: getTok(p)
-      eat(p, endMarker)
-  else: 
-    eat(p, endMarker)
-  
-proc parseRaise(p: var TParser): PNode = 
-  result = newNodeP(nkRaiseStmt, p)
-  getTok(p)
-  skipCom(p, result)
-  if p.tok.xkind != pxSemicolon: addSon(result, parseExpr(p))
-  else: addSon(result, ast.emptyNode)
-  
-proc parseIf(p: var TParser): PNode = 
-  result = newNodeP(nkIfStmt, p)
-  while true: 
-    getTok(p)                 # skip ``if``
-    var branch = newNodeP(nkElifBranch, p)
-    skipCom(p, branch)
-    addSon(branch, parseExpr(p))
-    eat(p, pxThen)
-    skipCom(p, branch)
-    addSon(branch, parseStmt(p))
-    skipCom(p, branch)
-    addSon(result, branch)
-    if p.tok.xkind == pxElse: 
-      getTok(p)
-      if p.tok.xkind != pxIf: 
-        # ordinary else part:
-        branch = newNodeP(nkElse, p)
-        skipCom(p, result)    # BUGFIX
-        addSon(branch, parseStmt(p))
-        addSon(result, branch)
-        break 
-    else: 
-      break 
-  
-proc parseWhile(p: var TParser): PNode = 
-  result = newNodeP(nkWhileStmt, p)
-  getTok(p)
-  skipCom(p, result)
-  addSon(result, parseExpr(p))
-  eat(p, pxDo)
-  skipCom(p, result)
-  addSon(result, parseStmt(p))
-
-proc parseRepeat(p: var TParser): PNode = 
-  result = newNodeP(nkWhileStmt, p)
-  getTok(p)
-  skipCom(p, result)
-  addSon(result, newIdentNodeP(getIdent("true"), p))
-  var s = newNodeP(nkStmtList, p)
-  while p.tok.xkind != pxEof and p.tok.xkind != pxUntil: 
-    addSon(s, parseStmt(p))
-  eat(p, pxUntil)
-  var a = newNodeP(nkIfStmt, p)
-  skipCom(p, a)
-  var b = newNodeP(nkElifBranch, p)
-  var c = newNodeP(nkBreakStmt, p)
-  addSon(c, ast.emptyNode)
-  addSon(b, parseExpr(p))
-  skipCom(p, a)
-  addSon(b, c)
-  addSon(a, b)
-  if b.sons[0].kind == nkIdent and b.sons[0].ident.id == getIdent("false").id: 
-    discard
-  else: 
-    addSon(s, a)
-  addSon(result, s)
-
-proc parseCase(p: var TParser): PNode = 
-  var b: PNode
-  result = newNodeP(nkCaseStmt, p)
-  getTok(p)
-  addSon(result, parseExpr(p))
-  eat(p, pxOf)
-  skipCom(p, result)
-  while (p.tok.xkind != pxEnd) and (p.tok.xkind != pxEof): 
-    if p.tok.xkind == pxElse: 
-      b = newNodeP(nkElse, p)
-      getTok(p)
-    else: 
-      b = newNodeP(nkOfBranch, p)
-      while (p.tok.xkind != pxEof) and (p.tok.xkind != pxColon): 
-        addSon(b, rangeExpr(p))
-        opt(p, pxComma)
-        skipCom(p, b)
-      eat(p, pxColon)
-    skipCom(p, b)
-    addSon(b, parseStmt(p))
-    addSon(result, b)
-    if b.kind == nkElse: break 
-  eat(p, pxEnd)
-
-proc parseTry(p: var TParser): PNode = 
-  result = newNodeP(nkTryStmt, p)
-  getTok(p)
-  skipCom(p, result)
-  var b = newNodeP(nkStmtList, p)
-  while not (p.tok.xkind in {pxFinally, pxExcept, pxEof, pxEnd}): 
-    addSon(b, parseStmt(p))
-  addSon(result, b)
-  if p.tok.xkind == pxExcept: 
-    getTok(p)
-    while p.tok.ident.id == getIdent("on").id: 
-      b = newNodeP(nkExceptBranch, p)
-      getTok(p)
-      var e = qualifiedIdent(p)
-      if p.tok.xkind == pxColon: 
-        getTok(p)
-        e = qualifiedIdent(p)
-      addSon(b, e)
-      eat(p, pxDo)
-      addSon(b, parseStmt(p))
-      addSon(result, b)
-      if p.tok.xkind == pxCommand: discard parseCommand(p)
-    if p.tok.xkind == pxElse: 
-      b = newNodeP(nkExceptBranch, p)
-      getTok(p)
-      addSon(b, parseStmt(p))
-      addSon(result, b)
-  if p.tok.xkind == pxFinally: 
-    b = newNodeP(nkFinally, p)
-    getTok(p)
-    var e = newNodeP(nkStmtList, p)
-    while (p.tok.xkind != pxEof) and (p.tok.xkind != pxEnd): 
-      addSon(e, parseStmt(p))
-    if sonsLen(e) == 0: addSon(e, newNodeP(nkNilLit, p))
-    addSon(result, e)
-  eat(p, pxEnd)
-
-proc parseFor(p: var TParser): PNode = 
-  result = newNodeP(nkForStmt, p)
-  getTok(p)
-  skipCom(p, result)
-  expectIdent(p)
-  addSon(result, createIdentNodeP(p.tok.ident, p))
-  getTok(p)
-  eat(p, pxAsgn)
-  var a = parseExpr(p)
-  var b = ast.emptyNode
-  var c = newNodeP(nkCall, p)
-  if p.tok.xkind == pxTo: 
-    addSon(c, newIdentNodeP(getIdent("countup"), p))
-    getTok(p)
-    b = parseExpr(p)
-  elif p.tok.xkind == pxDownto: 
-    addSon(c, newIdentNodeP(getIdent("countdown"), p))
-    getTok(p)
-    b = parseExpr(p)
-  else: 
-    parMessage(p, errTokenExpected, tokKindToStr(pxTo))
-  addSon(c, a)
-  addSon(c, b)
-  eat(p, pxDo)
-  skipCom(p, result)
-  addSon(result, c)
-  addSon(result, parseStmt(p))
-
-proc parseParam(p: var TParser): PNode = 
-  var a: PNode
-  result = newNodeP(nkIdentDefs, p)
-  var v = ast.emptyNode
-  case p.tok.xkind
-  of pxConst: 
-    getTok(p)
-  of pxVar: 
-    getTok(p)
-    v = newNodeP(nkVarTy, p)
-  of pxOut: 
-    getTok(p)
-    v = newNodeP(nkVarTy, p)
-  else: 
-    discard
-  while true: 
-    case p.tok.xkind
-    of pxSymbol: a = createIdentNodeP(p.tok.ident, p)
-    of pxColon, pxEof, pxParRi, pxEquals: break 
-    else: 
-      parMessage(p, errIdentifierExpected, $p.tok)
-      return 
-    getTok(p)                 # skip identifier
-    skipCom(p, a)
-    if p.tok.xkind == pxComma: 
-      getTok(p)
-      skipCom(p, a)
-    addSon(result, a)
-  if p.tok.xkind == pxColon: 
-    getTok(p)
-    skipCom(p, result)
-    if v.kind != nkEmpty: addSon(v, parseTypeDesc(p))
-    else: v = parseTypeDesc(p)
-    addSon(result, v)
-  else: 
-    addSon(result, ast.emptyNode)
-    if p.tok.xkind != pxEquals: 
-      parMessage(p, errColonOrEqualsExpected, $p.tok)
-  if p.tok.xkind == pxEquals: 
-    getTok(p)
-    skipCom(p, result)
-    addSon(result, parseExpr(p))
-  else: 
-    addSon(result, ast.emptyNode)
-  
-proc parseParamList(p: var TParser): PNode = 
-  var a: PNode
-  result = newNodeP(nkFormalParams, p)
-  addSon(result, ast.emptyNode)         # return type
-  if p.tok.xkind == pxParLe: 
-    p.inParamList = true
-    getTok(p)
-    skipCom(p, result)
-    while true: 
-      case p.tok.xkind
-      of pxSymbol, pxConst, pxVar, pxOut: 
-        a = parseParam(p)
-      of pxParRi: 
-        getTok(p)
-        break 
-      else: 
-        parMessage(p, errTokenExpected, ")")
-        break 
-      skipCom(p, a)
-      if p.tok.xkind == pxSemicolon: 
-        getTok(p)
-        skipCom(p, a)
-      addSon(result, a)
-    p.inParamList = false
-  if p.tok.xkind == pxColon: 
-    getTok(p)
-    skipCom(p, result)
-    result.sons[0] = parseTypeDesc(p)
-
-proc parseCallingConvention(p: var TParser): PNode = 
-  result = ast.emptyNode
-  if p.tok.xkind == pxSymbol: 
-    case toLower(p.tok.ident.s)
-    of "stdcall", "cdecl", "safecall", "syscall", "inline", "fastcall": 
-      result = newNodeP(nkPragma, p)
-      addSon(result, newIdentNodeP(p.tok.ident, p))
-      getTok(p)
-      opt(p, pxSemicolon)
-    of "register": 
-      result = newNodeP(nkPragma, p)
-      addSon(result, newIdentNodeP(getIdent("fastcall"), p))
-      getTok(p)
-      opt(p, pxSemicolon)
-    else: 
-      discard
-
-proc parseRoutineSpecifiers(p: var TParser, noBody: var bool): PNode = 
-  var e: PNode
-  result = parseCallingConvention(p)
-  noBody = false
-  while p.tok.xkind == pxSymbol: 
-    case toLower(p.tok.ident.s)
-    of "assembler", "overload", "far": 
-      getTok(p)
-      opt(p, pxSemicolon)
-    of "forward": 
-      noBody = true
-      getTok(p)
-      opt(p, pxSemicolon)
-    of "importc": 
-      # This is a fake for platform module. There is no ``importc``
-      # directive in Pascal.
-      if result.kind == nkEmpty: result = newNodeP(nkPragma, p)
-      addSon(result, newIdentNodeP(getIdent("importc"), p))
-      noBody = true
-      getTok(p)
-      opt(p, pxSemicolon)
-    of "noconv": 
-      # This is a fake for platform module. There is no ``noconv``
-      # directive in Pascal.
-      if result.kind == nkEmpty: result = newNodeP(nkPragma, p)
-      addSon(result, newIdentNodeP(getIdent("noconv"), p))
-      noBody = true
-      getTok(p)
-      opt(p, pxSemicolon)
-    of "procvar": 
-      # This is a fake for the Nimrod compiler. There is no ``procvar``
-      # directive in Pascal.
-      if result.kind == nkEmpty: result = newNodeP(nkPragma, p)
-      addSon(result, newIdentNodeP(getIdent("procvar"), p))
-      getTok(p)
-      opt(p, pxSemicolon)
-    of "varargs": 
-      if result.kind == nkEmpty: result = newNodeP(nkPragma, p)
-      addSon(result, newIdentNodeP(getIdent("varargs"), p))
-      getTok(p)
-      opt(p, pxSemicolon)
-    of "external": 
-      if result.kind == nkEmpty: result = newNodeP(nkPragma, p)
-      getTok(p)
-      noBody = true
-      e = newNodeP(nkExprColonExpr, p)
-      addSon(e, newIdentNodeP(getIdent("dynlib"), p))
-      addSon(e, parseExpr(p))
-      addSon(result, e)
-      opt(p, pxSemicolon)
-      if (p.tok.xkind == pxSymbol) and
-          (p.tok.ident.id == getIdent("name").id): 
-        e = newNodeP(nkExprColonExpr, p)
-        getTok(p)
-        addSon(e, newIdentNodeP(getIdent("importc"), p))
-        addSon(e, parseExpr(p))
-        addSon(result, e)
-      else: 
-        addSon(result, newIdentNodeP(getIdent("importc"), p))
-      opt(p, pxSemicolon)
-    else: 
-      e = parseCallingConvention(p)
-      if e.kind == nkEmpty: break 
-      if result.kind == nkEmpty: result = newNodeP(nkPragma, p)
-      addSon(result, e.sons[0])
-
-proc parseRoutineType(p: var TParser): PNode = 
-  result = newNodeP(nkProcTy, p)
-  getTok(p)
-  skipCom(p, result)
-  addSon(result, parseParamList(p))
-  opt(p, pxSemicolon)
-  addSon(result, parseCallingConvention(p))
-  skipCom(p, result)
-
-proc parseEnum(p: var TParser): PNode = 
-  var a: PNode
-  result = newNodeP(nkEnumTy, p)
-  getTok(p)
-  skipCom(p, result)
-  addSon(result, ast.emptyNode) # it does not inherit from any enumeration
-  while true: 
-    case p.tok.xkind
-    of pxEof, pxParRi: break 
-    of pxSymbol: a = newIdentNodeP(p.tok.ident, p)
-    else: 
-      parMessage(p, errIdentifierExpected, $(p.tok))
-      break 
-    getTok(p)                 # skip identifier
-    skipCom(p, a)
-    if (p.tok.xkind == pxEquals) or (p.tok.xkind == pxAsgn): 
-      getTok(p)
-      skipCom(p, a)
-      var b = a
-      a = newNodeP(nkEnumFieldDef, p)
-      addSon(a, b)
-      addSon(a, parseExpr(p))
-    if p.tok.xkind == pxComma: 
-      getTok(p)
-      skipCom(p, a)
-    addSon(result, a)
-  eat(p, pxParRi)
-
-proc identVis(p: var TParser): PNode = 
-  # identifier with visability
-  var a = createIdentNodeP(p.tok.ident, p)
-  if p.section == seInterface: 
-    result = newNodeP(nkPostfix, p)
-    addSon(result, newIdentNodeP(getIdent("*"), p))
-    addSon(result, a)
-  else: 
-    result = a
-  getTok(p)
-
-type 
-  TSymbolParser = proc (p: var TParser): PNode {.nimcall.}
-
-proc rawIdent(p: var TParser): PNode = 
-  result = createIdentNodeP(p.tok.ident, p)
-  getTok(p)
-
-proc parseIdentColonEquals(p: var TParser, 
-                           identParser: TSymbolParser): PNode = 
-  var a: PNode
-  result = newNodeP(nkIdentDefs, p)
-  while true: 
-    case p.tok.xkind
-    of pxSymbol: a = identParser(p)
-    of pxColon, pxEof, pxParRi, pxEquals: break 
-    else: 
-      parMessage(p, errIdentifierExpected, $(p.tok))
-      return 
-    skipCom(p, a)
-    if p.tok.xkind == pxComma: 
-      getTok(p)
-      skipCom(p, a)
-    addSon(result, a)
-  if p.tok.xkind == pxColon: 
-    getTok(p)
-    skipCom(p, result)
-    addSon(result, parseTypeDesc(p))
-  else: 
-    addSon(result, ast.emptyNode)
-    if p.tok.xkind != pxEquals: 
-      parMessage(p, errColonOrEqualsExpected, $(p.tok))
-  if p.tok.xkind == pxEquals: 
-    getTok(p)
-    skipCom(p, result)
-    addSon(result, parseExpr(p))
-  else: 
-    addSon(result, ast.emptyNode)
-  if p.tok.xkind == pxSemicolon: 
-    getTok(p)
-    skipCom(p, result)
-
-proc parseRecordCase(p: var TParser): PNode = 
-  var b, c: PNode
-  result = newNodeP(nkRecCase, p)
-  getTok(p)
-  var a = newNodeP(nkIdentDefs, p)
-  addSon(a, rawIdent(p))
-  eat(p, pxColon)
-  addSon(a, parseTypeDesc(p))
-  addSon(a, ast.emptyNode)
-  addSon(result, a)
-  eat(p, pxOf)
-  skipCom(p, result)
-  while true: 
-    case p.tok.xkind
-    of pxEof, pxEnd: 
-      break 
-    of pxElse: 
-      b = newNodeP(nkElse, p)
-      getTok(p)
-    else: 
-      b = newNodeP(nkOfBranch, p)
-      while (p.tok.xkind != pxEof) and (p.tok.xkind != pxColon): 
-        addSon(b, rangeExpr(p))
-        opt(p, pxComma)
-        skipCom(p, b)
-      eat(p, pxColon)
-    skipCom(p, b)
-    c = newNodeP(nkRecList, p)
-    eat(p, pxParLe)
-    while (p.tok.xkind != pxParRi) and (p.tok.xkind != pxEof): 
-      addSon(c, parseIdentColonEquals(p, rawIdent))
-      opt(p, pxSemicolon)
-      skipCom(p, lastSon(c))
-    eat(p, pxParRi)
-    opt(p, pxSemicolon)
-    if sonsLen(c) > 0: skipCom(p, lastSon(c))
-    else: addSon(c, newNodeP(nkNilLit, p))
-    addSon(b, c)
-    addSon(result, b)
-    if b.kind == nkElse: break 
-  
-proc parseRecordPart(p: var TParser): PNode = 
-  result = ast.emptyNode
-  while (p.tok.xkind != pxEof) and (p.tok.xkind != pxEnd): 
-    if result.kind == nkEmpty: result = newNodeP(nkRecList, p)
-    case p.tok.xkind
-    of pxSymbol: 
-      addSon(result, parseIdentColonEquals(p, rawIdent))
-      opt(p, pxSemicolon)
-      skipCom(p, lastSon(result))
-    of pxCase: 
-      addSon(result, parseRecordCase(p))
-    of pxComment: 
-      skipCom(p, lastSon(result))
-    else: 
-      parMessage(p, errIdentifierExpected, $p.tok)
-      break
-
-proc exSymbol(n: var PNode) = 
-  case n.kind
-  of nkPostfix: 
-    discard
-  of nkPragmaExpr: 
-    exSymbol(n.sons[0])
-  of nkIdent, nkAccQuoted: 
-    var a = newNodeI(nkPostFix, n.info)
-    addSon(a, newIdentNode(getIdent("*"), n.info))
-    addSon(a, n)
-    n = a
-  else: internalError(n.info, "exSymbol(): " & $n.kind)
-  
-proc fixRecordDef(n: var PNode) = 
-  case n.kind
-  of nkRecCase: 
-    fixRecordDef(n.sons[0])
-    for i in countup(1, sonsLen(n) - 1): 
-      var length = sonsLen(n.sons[i])
-      fixRecordDef(n.sons[i].sons[length - 1])
-  of nkRecList, nkRecWhen, nkElse, nkOfBranch, nkElifBranch, nkObjectTy: 
-    for i in countup(0, sonsLen(n) - 1): fixRecordDef(n.sons[i])
-  of nkIdentDefs: 
-    for i in countup(0, sonsLen(n) - 3): exSymbol(n.sons[i])
-  of nkNilLit, nkEmpty: discard
-  else: internalError(n.info, "fixRecordDef(): " & $n.kind)
-  
-proc addPragmaToIdent(ident: var PNode, pragma: PNode) = 
-  var pragmasNode: PNode
-  if ident.kind != nkPragmaExpr: 
-    pragmasNode = newNodeI(nkPragma, ident.info)
-    var e = newNodeI(nkPragmaExpr, ident.info)
-    addSon(e, ident)
-    addSon(e, pragmasNode)
-    ident = e
-  else: 
-    pragmasNode = ident.sons[1]
-    if pragmasNode.kind != nkPragma: 
-      internalError(ident.info, "addPragmaToIdent")
-  addSon(pragmasNode, pragma)
-
-proc parseRecordBody(p: var TParser, result, definition: PNode) = 
-  skipCom(p, result)
-  var a = parseRecordPart(p)
-  if result.kind != nkTupleTy: fixRecordDef(a)
-  addSon(result, a)
-  eat(p, pxEnd)
-  case p.tok.xkind
-  of pxSymbol: 
-    if p.tok.ident.id == getIdent("acyclic").id: 
-      if definition != nil: 
-        addPragmaToIdent(definition.sons[0], newIdentNodeP(p.tok.ident, p))
-      else: 
-        internalError(result.info, "anonymous record is not supported")
-      getTok(p)
-    else: 
-      internalError(result.info, "parseRecordBody")
-  of pxCommand: 
-    if definition != nil: addPragmaToIdent(definition.sons[0], parseCommand(p))
-    else: internalError(result.info, "anonymous record is not supported")
-  else: 
-    discard
-  opt(p, pxSemicolon)
-  skipCom(p, result)
-
-proc parseRecordOrObject(p: var TParser, kind: TNodeKind, 
-                         definition: PNode): PNode = 
-  result = newNodeP(kind, p)
-  getTok(p)
-  addSon(result, ast.emptyNode)
-  if p.tok.xkind == pxParLe: 
-    var a = newNodeP(nkOfInherit, p)
-    getTok(p)
-    addSon(a, parseTypeDesc(p))
-    addSon(result, a)
-    eat(p, pxParRi)
-  else: 
-    addSon(result, ast.emptyNode)
-  parseRecordBody(p, result, definition)
-
-proc parseTypeDesc(p: var TParser, definition: PNode = nil): PNode = 
-  var oldcontext = p.context
-  p.context = conTypeDesc
-  if p.tok.xkind == pxPacked: getTok(p)
-  case p.tok.xkind
-  of pxCommand: 
-    result = parseCommand(p, definition)
-  of pxProcedure, pxFunction: 
-    result = parseRoutineType(p)
-  of pxRecord: 
-    getTok(p)
-    if p.tok.xkind == pxCommand: 
-      result = parseCommand(p)
-      if result.kind != nkTupleTy: internalError(result.info, "parseTypeDesc")
-      parseRecordBody(p, result, definition)
-      var a = lastSon(result)     # embed nkRecList directly into nkTupleTy
-      for i in countup(0, sonsLen(a) - 1): 
-        if i == 0: result.sons[sonsLen(result) - 1] = a.sons[0]
-        else: addSon(result, a.sons[i])
-    else: 
-      result = newNodeP(nkObjectTy, p)
-      addSon(result, ast.emptyNode)
-      addSon(result, ast.emptyNode)
-      parseRecordBody(p, result, definition)
-      if definition != nil: 
-        addPragmaToIdent(definition.sons[0], newIdentNodeP(getIdent("final"), p))
-      else: 
-        internalError(result.info, "anonymous record is not supported")
-  of pxObject: result = parseRecordOrObject(p, nkObjectTy, definition)
-  of pxParLe: result = parseEnum(p)
-  of pxArray: 
-    result = newNodeP(nkBracketExpr, p)
-    getTok(p)
-    if p.tok.xkind == pxBracketLe: 
-      addSon(result, newIdentNodeP(getIdent("array"), p))
-      getTok(p)
-      addSon(result, rangeExpr(p))
-      eat(p, pxBracketRi)
-    else: 
-      if p.inParamList: addSon(result, newIdentNodeP(getIdent("openarray"), p))
-      else: addSon(result, newIdentNodeP(getIdent("seq"), p))
-    eat(p, pxOf)
-    addSon(result, parseTypeDesc(p))
-  of pxSet: 
-    result = newNodeP(nkBracketExpr, p)
-    getTok(p)
-    eat(p, pxOf)
-    addSon(result, newIdentNodeP(getIdent("set"), p))
-    addSon(result, parseTypeDesc(p))
-  of pxHat: 
-    getTok(p)
-    if p.tok.xkind == pxCommand: result = parseCommand(p)
-    elif pfRefs in p.flags: result = newNodeP(nkRefTy, p)
-    else: result = newNodeP(nkPtrTy, p)
-    addSon(result, parseTypeDesc(p))
-  of pxType: 
-    getTok(p)
-    result = parseTypeDesc(p)
-  else: 
-    var a = primary(p)
-    if p.tok.xkind == pxDotDot: 
-      result = newNodeP(nkBracketExpr, p)
-      var r = newNodeP(nkRange, p)
-      addSon(result, newIdentNodeP(getIdent("range"), p))
-      getTok(p)
-      addSon(r, a)
-      addSon(r, parseExpr(p))
-      addSon(result, r)
-    else: 
-      result = a
-  p.context = oldcontext
-
-proc parseTypeDef(p: var TParser): PNode = 
-  result = newNodeP(nkTypeDef, p)
-  addSon(result, identVis(p))
-  addSon(result, ast.emptyNode)         # generic params
-  if p.tok.xkind == pxEquals: 
-    getTok(p)
-    skipCom(p, result)
-    addSon(result, parseTypeDesc(p, result))
-  else: 
-    addSon(result, ast.emptyNode)
-  if p.tok.xkind == pxSemicolon: 
-    getTok(p)
-    skipCom(p, result)
-
-proc parseTypeSection(p: var TParser): PNode = 
-  result = newNodeP(nkTypeSection, p)
-  getTok(p)
-  skipCom(p, result)
-  while p.tok.xkind == pxSymbol: 
-    addSon(result, parseTypeDef(p))
-
-proc parseConstant(p: var TParser): PNode = 
-  result = newNodeP(nkConstDef, p)
-  addSon(result, identVis(p))
-  if p.tok.xkind == pxColon: 
-    getTok(p)
-    skipCom(p, result)
-    addSon(result, parseTypeDesc(p))
-  else: 
-    addSon(result, ast.emptyNode)
-    if p.tok.xkind != pxEquals: 
-      parMessage(p, errColonOrEqualsExpected, $(p.tok))
-  if p.tok.xkind == pxEquals: 
-    getTok(p)
-    skipCom(p, result)
-    addSon(result, parseExpr(p))
-  else: 
-    addSon(result, ast.emptyNode)
-  if p.tok.xkind == pxSemicolon: 
-    getTok(p)
-    skipCom(p, result)
-
-proc parseConstSection(p: var TParser): PNode = 
-  result = newNodeP(nkConstSection, p)
-  getTok(p)
-  skipCom(p, result)
-  while p.tok.xkind == pxSymbol: 
-    addSon(result, parseConstant(p))
-
-proc parseVar(p: var TParser): PNode = 
-  result = newNodeP(nkVarSection, p)
-  getTok(p)
-  skipCom(p, result)
-  while p.tok.xkind == pxSymbol:
-    addSon(result, parseIdentColonEquals(p, identVis))
-  p.lastVarSection = result
-
-proc parseRoutine(p: var TParser): PNode = 
-  var noBody: bool
-  result = newNodeP(nkProcDef, p)
-  getTok(p)
-  skipCom(p, result)
-  expectIdent(p)
-  addSon(result, identVis(p))
-  # patterns, generic parameters:
-  addSon(result, ast.emptyNode)
-  addSon(result, ast.emptyNode)   
-  addSon(result, parseParamList(p))
-  opt(p, pxSemicolon)
-  addSon(result, parseRoutineSpecifiers(p, noBody))
-  addSon(result, ast.emptyNode)
-  if (p.section == seInterface) or noBody: 
-    addSon(result, ast.emptyNode)
-  else: 
-    var stmts = newNodeP(nkStmtList, p)
-    while true: 
-      case p.tok.xkind
-      of pxVar: addSon(stmts, parseVar(p))
-      of pxConst: addSon(stmts, parseConstSection(p))
-      of pxType: addSon(stmts, parseTypeSection(p))
-      of pxComment: skipCom(p, result)
-      of pxBegin: break 
-      else: 
-        parMessage(p, errTokenExpected, "begin")
-        break 
-    var a = parseStmt(p)
-    for i in countup(0, sonsLen(a) - 1): addSon(stmts, a.sons[i])
-    addSon(result, stmts)
-
-proc fixExit(p: var TParser, n: PNode): bool = 
-  if (p.tok.ident.id == getIdent("exit").id): 
-    var length = sonsLen(n)
-    if (length <= 0): return 
-    var a = n.sons[length-1]
-    if (a.kind == nkAsgn) and (a.sons[0].kind == nkIdent) and
-        (a.sons[0].ident.id == getIdent("result").id): 
-      delSon(a, 0)
-      a.kind = nkReturnStmt
-      result = true
-      getTok(p)
-      opt(p, pxSemicolon)
-      skipCom(p, a)
-
-proc fixVarSection(p: var TParser, counter: PNode) = 
-  if p.lastVarSection == nil: return 
-  assert(counter.kind == nkIdent)
-  for i in countup(0, sonsLen(p.lastVarSection) - 1): 
-    var v = p.lastVarSection.sons[i]
-    for j in countup(0, sonsLen(v) - 3): 
-      if v.sons[j].ident.id == counter.ident.id: 
-        delSon(v, j)
-        if sonsLen(v) <= 2: 
-          delSon(p.lastVarSection, i)
-        return 
-
-proc exSymbols(n: PNode) = 
-  case n.kind
-  of nkEmpty..nkNilLit: discard
-  of nkProcDef..nkIteratorDef: exSymbol(n.sons[namePos])
-  of nkWhenStmt, nkStmtList: 
-    for i in countup(0, sonsLen(n) - 1): exSymbols(n.sons[i])
-  of nkVarSection, nkConstSection: 
-    for i in countup(0, sonsLen(n) - 1): exSymbol(n.sons[i].sons[0])
-  of nkTypeSection: 
-    for i in countup(0, sonsLen(n) - 1): 
-      exSymbol(n.sons[i].sons[0])
-      if n.sons[i].sons[2].kind == nkObjectTy: 
-        fixRecordDef(n.sons[i].sons[2])
-  else: discard
-
-proc parseBegin(p: var TParser, result: PNode) = 
-  getTok(p)
-  while true: 
-    case p.tok.xkind
-    of pxComment: addSon(result, parseStmt(p))
-    of pxSymbol: 
-      if not fixExit(p, result): addSon(result, parseStmt(p))
-    of pxEnd: 
-      getTok(p)
-      break 
-    of pxSemicolon: getTok(p)
-    of pxEof: parMessage(p, errExprExpected)
-    else: 
-      var a = parseStmt(p)
-      if a.kind != nkEmpty: addSon(result, a)
-  if sonsLen(result) == 0: addSon(result, newNodeP(nkNilLit, p))
-  
-proc parseStmt(p: var TParser): PNode = 
-  var oldcontext = p.context
-  p.context = conStmt
-  result = ast.emptyNode
-  case p.tok.xkind
-  of pxBegin: 
-    result = newNodeP(nkStmtList, p)
-    parseBegin(p, result)
-  of pxCommand: result = parseCommand(p)
-  of pxCurlyDirLe, pxStarDirLe: 
-    if isHandledDirective(p): result = parseDirective(p)
-  of pxIf: result = parseIf(p)
-  of pxWhile: result = parseWhile(p)
-  of pxRepeat: result = parseRepeat(p)
-  of pxCase: result = parseCase(p)
-  of pxTry: result = parseTry(p)
-  of pxProcedure, pxFunction: result = parseRoutine(p)
-  of pxType: result = parseTypeSection(p)
-  of pxConst: result = parseConstSection(p)
-  of pxVar: result = parseVar(p)
-  of pxFor: 
-    result = parseFor(p)
-    fixVarSection(p, result.sons[0])
-  of pxRaise: result = parseRaise(p)
-  of pxUses: result = parseUsesStmt(p)
-  of pxProgram, pxUnit, pxLibrary: 
-    # skip the pointless header
-    while not (p.tok.xkind in {pxSemicolon, pxEof}): getTok(p)
-    getTok(p)
-  of pxInitialization: getTok(p) # just skip the token
-  of pxImplementation: 
-    p.section = seImplementation
-    result = newNodeP(nkCommentStmt, p)
-    result.comment = "# implementation"
-    getTok(p)
-  of pxInterface: 
-    p.section = seInterface
-    getTok(p)
-  of pxComment: 
-    result = newNodeP(nkCommentStmt, p)
-    skipCom(p, result)
-  of pxSemicolon: getTok(p)
-  of pxSymbol: 
-    if p.tok.ident.id == getIdent("break").id: 
-      result = newNodeP(nkBreakStmt, p)
-      getTok(p)
-      skipCom(p, result)
-      addSon(result, ast.emptyNode)
-    elif p.tok.ident.id == getIdent("continue").id: 
-      result = newNodeP(nkContinueStmt, p)
-      getTok(p)
-      skipCom(p, result)
-      addSon(result, ast.emptyNode)
-    elif p.tok.ident.id == getIdent("exit").id: 
-      result = newNodeP(nkReturnStmt, p)
-      getTok(p)
-      skipCom(p, result)
-      addSon(result, ast.emptyNode)
-    else: 
-      result = parseExprStmt(p)
-  of pxDot: getTok(p) # BUGFIX for ``end.`` in main program
-  else: result = parseExprStmt(p)
-  opt(p, pxSemicolon)
-  if result.kind != nkEmpty: skipCom(p, result)
-  p.context = oldcontext
-
-proc parseUnit(p: var TParser): PNode = 
-  result = newNodeP(nkStmtList, p)
-  getTok(p)                   # read first token
-  while true: 
-    case p.tok.xkind
-    of pxEof, pxEnd: break 
-    of pxBegin: parseBegin(p, result)
-    of pxCurlyDirLe, pxStarDirLe: 
-      if isHandledDirective(p): addSon(result, parseDirective(p))
-      else: parMessage(p, errXNotAllowedHere, p.tok.ident.s)
-    else: addSon(result, parseStmt(p))
-  opt(p, pxEnd)
-  opt(p, pxDot)
-  if p.tok.xkind != pxEof: 
-    addSon(result, parseStmt(p)) # comments after final 'end.'
-  
diff --git a/compiler/patterns.nim b/compiler/patterns.nim
index d262790ab..5e21289b5 100644
--- a/compiler/patterns.nim
+++ b/compiler/patterns.nim
@@ -287,7 +287,7 @@ proc applyRule*(c: PContext, s: PSym, n: PNode): PNode =
         # constraint not fullfilled:
         if not ok: return nil
 
-  markUsed(n, s)
+  markUsed(n.info, s)
   if ctx.subMatch:
     assert m.len == 3
     m.sons[1] = result
diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim
index db9fe7cbe..a17773aa4 100644
--- a/compiler/pragmas.nim
+++ b/compiler/pragmas.nim
@@ -517,7 +517,7 @@ proc pragmaUses(c: PContext, n: PNode) =
   proc processExc(c: PContext, x: PNode): PNode =
     if x.kind in {nkAccQuoted, nkIdent, nkSym,
                   nkOpenSymChoice, nkClosedSymChoice}:
-      if considerAcc(x).s == "*":
+      if considerQuotedIdent(x).s == "*":
         return newSymNode(ast.anyGlobal)
     result = c.semExpr(c, x)
     if result.kind != nkSym or sfGlobal notin result.sym.flags:
@@ -644,12 +644,13 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: int,
           incl(sym.flags, sfNoReturn)
         of wDynlib: 
           processDynLib(c, it, sym)
-        of wCompilerproc: 
+        of wCompilerproc:
           noVal(it)           # compilerproc may not get a string!
-          makeExternExport(sym, "$1", it.info)
-          incl(sym.flags, sfCompilerProc)
-          incl(sym.flags, sfUsed) # suppress all those stupid warnings
-          registerCompilerProc(sym)
+          if sfFromGeneric notin sym.flags:
+            makeExternExport(sym, "$1", it.info)
+            incl(sym.flags, sfCompilerProc)
+            incl(sym.flags, sfUsed) # suppress all those stupid warnings
+            registerCompilerProc(sym)
         of wProcVar: 
           noVal(it)
           incl(sym.flags, sfProcvar)
diff --git a/compiler/pretty.nim b/compiler/pretty.nim
index 3a5bfe197..17311f9e6 100644
--- a/compiler/pretty.nim
+++ b/compiler/pretty.nim
@@ -1,7 +1,7 @@
 #
 #
 #           The Nimrod Compiler
-#        (c) Copyright 2013 Andreas Rumpf
+#        (c) Copyright 2014 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
@@ -149,8 +149,8 @@ proc checkDef(c: PGen; n: PNode) =
   if n.kind != nkSym: return
   checkDef(n, n.sym)
 
-proc checkUse*(n: PNode, s: PSym) =
-  if n.info.fileIndex < 0: return
+proc checkUse*(info: TLineInfo; s: PSym) =
+  if info.fileIndex < 0: return
   # we simply convert it to what it looks like in the definition
   # for consistency
   
@@ -159,10 +159,10 @@ proc checkUse*(n: PNode, s: PSym) =
   if s.kind in {skType, skGenericParam} and sfAnon in s.flags: return
   let newName = s.name.s
   
-  loadFile(n.info)
+  loadFile(info)
   
-  let line = gSourceFiles[n.info.fileIndex].lines[n.info.line-1]
-  var first = min(n.info.col.int, line.len)
+  let line = gSourceFiles[info.fileIndex].lines[info.line-1]
+  var first = min(info.col.int, line.len)
   if first < 0: return
   #inc first, skipIgnoreCase(line, "proc ", first)
   while first > 0 and line[first-1] in Letters: dec first
@@ -179,8 +179,8 @@ proc checkUse*(n: PNode, s: PSym) =
       if x.match(peg"\s* {\ident} \s* '=' \s* y$1 ('#' .*)?"):
         x = ""
     
-    system.shallowCopy(gSourceFiles[n.info.fileIndex].lines[n.info.line-1], x)
-    gSourceFiles[n.info.fileIndex].dirty = true
+    system.shallowCopy(gSourceFiles[info.fileIndex].lines[info.line-1], x)
+    gSourceFiles[info.fileIndex].dirty = true
 
 when false:
   var cannotRename = initIntSet()
@@ -220,53 +220,9 @@ when false:
         result.add s[i]
       inc i
 
-  proc checkUse(c: PGen; n: PNode) =
-    if n.info.fileIndex < 0: return
-    let s = n.sym
-    # operators stay as they are:
-    if s.kind in {skResult, skTemp} or s.name.s[0] notin Letters: return
-    if s.kind in {skType, skGenericParam} and sfAnon in s.flags: return
-    
-    if s.id in cannotRename: return
-    
-    let newName = if rules.hasKey(s.name.s): rules[s.name.s]
-                  else: beautifyName(s.name.s, n.sym.kind)
-    
-    loadFile(n.info)
-    
-    let line = gSourceFiles[n.info.fileIndex].lines[n.info.line-1]
-    var first = min(n.info.col.int, line.len)
-    if first < 0: return
-    #inc first, skipIgnoreCase(line, "proc ", first)
-    while first > 0 and line[first-1] in Letters: dec first
-    if first < 0: return
-    if line[first] == '`': inc first
-    
-    if {sfImportc, sfExportc} * s.flags != {}:
-      # careful, we must ensure the resulting name still matches the external
-      # name:
-      if newName != s.name.s and newName != s.loc.r.ropeToStr and
-          lfFullExternalName notin s.loc.flags:
-        #Message(n.info, errGenerated, 
-        #  "cannot rename $# to $# due to external name" % [s.name.s, newName])
-        cannotRename.incl(s.id)
-        return
-    let last = first+identLen(line, first)-1
-    if differ(line, first, last, newName):
-      # last-first+1 != newName.len or 
-      var x = line.subStr(0, first-1) & newName & line.substr(last+1)
-      when removeTP:
-        # the WinAPI module is full of 'TX = X' which after the substitution
-        # becomes 'X = X'. We remove those lines:
-        if x.match(peg"\s* {\ident} \s* '=' \s* y$1 ('#' .*)?"):
-          x = ""
-      
-      system.shallowCopy(gSourceFiles[n.info.fileIndex].lines[n.info.line-1], x)
-      gSourceFiles[n.info.fileIndex].dirty = true
-
 proc check(c: PGen, n: PNode) =
   case n.kind
-  of nkSym: checkUse(n, n.sym)
+  of nkSym: checkUse(n.info, n.sym)
   of nkBlockStmt, nkBlockExpr, nkBlockType:
     checkDef(c, n[0])
     check(c, n.sons[1])
diff --git a/compiler/renderer.nim b/compiler/renderer.nim
index 6b62c48c5..0b1312ccc 100644
--- a/compiler/renderer.nim
+++ b/compiler/renderer.nim
@@ -146,28 +146,29 @@ proc makeNimString(s: string): string =
   for i in countup(0, len(s)-1): add(result, toNimChar(s[i]))
   add(result, '\"')
 
-proc putComment(g: var TSrcGen, s: string) = 
+proc putComment(g: var TSrcGen, s: string) =
+  if s.isNil: return
   var i = 0
   var comIndent = 1
   var isCode = (len(s) >= 2) and (s[1] != ' ')
   var ind = g.lineLen
   var com = ""
-  while true: 
+  while true:
     case s[i]
-    of '\0': 
-      break 
-    of '\x0D': 
+    of '\0':
+      break
+    of '\x0D':
       put(g, tkComment, com)
       com = ""
       inc(i)
       if s[i] == '\x0A': inc(i)
       optNL(g, ind)
-    of '\x0A': 
+    of '\x0A':
       put(g, tkComment, com)
       com = ""
       inc(i)
       optNL(g, ind)
-    of '#': 
+    of '#':
       add(com, s[i])
       inc(i)
       comIndent = 0
@@ -175,10 +176,10 @@ proc putComment(g: var TSrcGen, s: string) =
         add(com, s[i])
         inc(i)
         inc(comIndent)
-    of ' ', '\x09': 
+    of ' ', '\x09':
       add(com, s[i])
       inc(i)
-    else: 
+    else:
       # we may break the comment into a multi-line comment if the line
       # gets too long:
       # compute length of the following word:
@@ -195,10 +196,10 @@ proc putComment(g: var TSrcGen, s: string) =
   optNL(g)
 
 proc maxLineLength(s: string): int = 
-  result = 0
+  if s.isNil: return 0
   var i = 0
   var lineLen = 0
-  while true: 
+  while true:
     case s[i]
     of '\0': 
       break 
@@ -459,7 +460,7 @@ proc lsub(n: PNode): int =
   of nkBreakStmt: result = lsub(n.sons[0]) + len("break_")
   of nkContinueStmt: result = lsub(n.sons[0]) + len("continue_")
   of nkPragma: result = lcomma(n) + 4
-  of nkCommentStmt: result = len(n.comment)
+  of nkCommentStmt: result = if n.comment.isNil: 0 else: len(n.comment)
   of nkOfBranch: result = lcomma(n, 0, - 2) + lsub(lastSon(n)) + len("of_:_")
   of nkImportAs: result = lsub(n.sons[0]) + len("_as_") + lsub(n.sons[1])
   of nkElifBranch: result = lsons(n) + len("elif_:_")
diff --git a/compiler/rodutils.nim b/compiler/rodutils.nim
index 4433ed4ab..09b92cd8a 100644
--- a/compiler/rodutils.nim
+++ b/compiler/rodutils.nim
@@ -10,7 +10,7 @@
 ## Serialization utilities for the compiler.
 import strutils
 
-proc c_sprintf(buf, frmt: cstring) {.importc: "sprintf", nodecl, varargs.}
+proc c_sprintf(buf, frmt: cstring) {.importc: "sprintf", header: "<stdio.h>", nodecl, varargs.}
 
 proc toStrMaxPrecision*(f: BiggestFloat): string = 
   if f != f:
diff --git a/compiler/sem.nim b/compiler/sem.nim
index 7d129caf4..8025ef70d 100644
--- a/compiler/sem.nim
+++ b/compiler/sem.nim
@@ -15,7 +15,8 @@ import
   magicsys, parser, nversion, nimsets, semfold, importer,
   procfind, lookups, rodread, pragmas, passes, semdata, semtypinst, sigmatch,
   intsets, transf, vmdef, vm, idgen, aliases, cgmeth, lambdalifting,
-  evaltempl, patterns, parampatterns, sempass2, pretty, semmacrosanity
+  evaltempl, patterns, parampatterns, sempass2, pretty, semmacrosanity,
+  semparallel
 
 # implementation
 
@@ -134,7 +135,7 @@ proc isTopLevel(c: PContext): bool {.inline.} =
   result = c.currentScope.depthLevel <= 2
 
 proc newSymS(kind: TSymKind, n: PNode, c: PContext): PSym = 
-  result = newSym(kind, considerAcc(n), getCurrOwner(), n.info)
+  result = newSym(kind, considerQuotedIdent(n), getCurrOwner(), n.info)
 
 proc newSymG*(kind: TSymKind, n: PNode, c: PContext): PSym =
   # like newSymS, but considers gensym'ed symbols
@@ -147,7 +148,7 @@ proc newSymG*(kind: TSymKind, n: PNode, c: PContext): PSym =
     # template; we must fix it here: see #909
     result.owner = getCurrOwner()
   else:
-    result = newSym(kind, considerAcc(n), getCurrOwner(), n.info)
+    result = newSym(kind, considerQuotedIdent(n), getCurrOwner(), n.info)
 
 proc semIdentVis(c: PContext, kind: TSymKind, n: PNode,
                  allowed: TSymFlags): PSym
@@ -268,11 +269,15 @@ include hlo, seminst, semcall
 
 proc semAfterMacroCall(c: PContext, n: PNode, s: PSym,
                        flags: TExprFlags): PNode =
+  ## Semantically check the output of a macro.
+  ## This involves processes such as re-checking the macro output for type
+  ## coherence, making sure that variables declared with 'let' aren't
+  ## reassigned, and binding the unbound identifiers that the macro output
+  ## contains.
   inc(evalTemplateCounter)
   if evalTemplateCounter > 100:
     globalError(s.info, errTemplateInstantiationTooNested)
-  let oldFriend = c.friendModule
-  c.friendModule = s.owner.getModule
+  c.friendModules.add(s.owner.getModule)
 
   result = n
   if s.typ.sons[0] == nil:
@@ -296,11 +301,13 @@ proc semAfterMacroCall(c: PContext, n: PNode, s: PSym,
       result = fitNode(c, s.typ.sons[0], result)
       #GlobalError(s.info, errInvalidParamKindX, typeToString(s.typ.sons[0]))
   dec(evalTemplateCounter)
-  c.friendModule = oldFriend
+  discard c.friendModules.pop()
 
 proc semMacroExpr(c: PContext, n, nOrig: PNode, sym: PSym,
                   flags: TExprFlags = {}): PNode =
-  markUsed(n, sym)
+  pushInfoContext(nOrig.info)
+
+  markUsed(n.info, sym)
   if sym == c.p.owner:
     globalError(n.info, errRecursiveDependencyX, sym.name.s)
 
@@ -310,6 +317,7 @@ proc semMacroExpr(c: PContext, n, nOrig: PNode, sym: PSym,
   result = evalMacroCall(c.module, n, nOrig, sym)
   if efNoSemCheck notin flags:
     result = semAfterMacroCall(c, result, sym, flags)
+  popInfoContext()
 
 proc forceBool(c: PContext, n: PNode): PNode = 
   result = fitNode(c, getSysType(tyBool), n)
diff --git a/compiler/semcall.nim b/compiler/semcall.nim
index 04d280ce2..65a2d7ab8 100644
--- a/compiler/semcall.nim
+++ b/compiler/semcall.nim
@@ -168,7 +168,7 @@ proc resolveOverloads(c: PContext, n, orig: PNode,
       pickBest(callOp)
    
     if overloadsState == csEmpty and result.state == csEmpty:
-      localError(n.info, errUndeclaredIdentifier, considerAcc(f).s)
+      localError(n.info, errUndeclaredIdentifier, considerQuotedIdent(f).s)
       return
     elif result.state != csMatch:
       if nfExprCall in n.flags:
@@ -251,7 +251,7 @@ proc inferWithMetatype(c: PContext, formal: PType,
 proc semResolvedCall(c: PContext, n: PNode, x: TCandidate): PNode =
   assert x.state == csMatch
   var finalCallee = x.calleeSym
-  markUsed(n.sons[0], finalCallee)
+  markUsed(n.sons[0].info, finalCallee)
   if finalCallee.ast == nil:
     internalError(n.info, "calleeSym.ast is nil") # XXX: remove this check!
   if finalCallee.ast.sons[genericParamsPos].kind != nkEmpty:
@@ -283,7 +283,7 @@ proc explicitGenericSym(c: PContext, n: PNode, s: PSym): PNode =
   var m: TCandidate
   initCandidate(c, m, s, n)
   var newInst = generateInstance(c, s, m.bindings, n.info)
-  markUsed(n, s)
+  markUsed(n.info, s)
   result = newSymNode(newInst, n.info)
 
 proc explicitGenericInstantiation(c: PContext, n: PNode, s: PSym): PNode = 
diff --git a/compiler/semdata.nim b/compiler/semdata.nim
index 987a70a41..abecc1b6d 100644
--- a/compiler/semdata.nim
+++ b/compiler/semdata.nim
@@ -52,7 +52,7 @@ type
     importTable*: PScope       # scope for all imported symbols
     topLevelScope*: PScope     # scope for all top-level symbols
     p*: PProcCon               # procedure context
-    friendModule*: PSym        # current friend module; may access private data;
+    friendModules*: seq[PSym]  # friend modules; may access private data;
                                # this is used so that generic instantiations
                                # can access private object fields
     instCounter*: int          # to prevent endless instantiations
@@ -91,6 +91,7 @@ type
     generics*: seq[TInstantiationPair] # pending list of instantiated generics to compile
     lastGenericIdx*: int      # used for the generics stack
     hloLoopDetector*: int     # used to prevent endless loops in the HLO
+    inParallelStmt*: int
    
 proc makeInstPair*(s: PSym, inst: PInstantiation): TInstantiationPair =
   result.genericSym = s
@@ -168,7 +169,7 @@ proc newContext(module: PSym): PContext =
   initLinkedList(result.libs)
   append(result.optionStack, newOptionEntry())
   result.module = module
-  result.friendModule = module
+  result.friendModules = @[module]
   result.converters = @[]
   result.patterns = @[]
   result.includedFiles = initIntSet()
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index 9ea93a15e..7deb46af9 100644
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -12,7 +12,7 @@
 
 proc semTemplateExpr(c: PContext, n: PNode, s: PSym,
                      flags: TExprFlags = {}): PNode =
-  markUsed(n, s)
+  markUsed(n.info, s)
   pushInfoContext(n.info)
   result = evalTemplate(n, s, getCurrOwner())
   if efNoSemCheck notin flags: result = semAfterMacroCall(c, result, s, flags)
@@ -78,11 +78,12 @@ proc inlineConst(n: PNode, s: PSym): PNode {.inline.} =
 proc semSym(c: PContext, n: PNode, s: PSym, flags: TExprFlags): PNode = 
   case s.kind
   of skConst:
-    markUsed(n, s)
+    markUsed(n.info, s)
     case skipTypes(s.typ, abstractInst-{tyTypeDesc}).kind
     of  tyNil, tyChar, tyInt..tyInt64, tyFloat..tyFloat128, 
         tyTuple, tySet, tyUInt..tyUInt64:
-      result = inlineConst(n, s)
+      if s.magic == mNone: result = inlineConst(n, s)
+      else: result = newSymNode(s, n.info)
     of tyArrayConstr, tySequence:
       # Consider::
       #     const x = []
@@ -101,7 +102,7 @@ proc semSym(c: PContext, n: PNode, s: PSym, flags: TExprFlags): PNode =
   of skMacro: result = semMacroExpr(c, n, n, s, flags)
   of skTemplate: result = semTemplateExpr(c, n, s, flags)
   of skVar, skLet, skResult, skParam, skForVar:
-    markUsed(n, s)
+    markUsed(n.info, s)
     # if a proc accesses a global variable, it is not side effect free:
     if sfGlobal in s.flags:
       incl(c.p.owner.flags, sfSideEffect)
@@ -123,13 +124,13 @@ proc semSym(c: PContext, n: PNode, s: PSym, flags: TExprFlags): PNode =
       n.typ = s.typ
       return n
   of skType:
-    markUsed(n, s)
+    markUsed(n.info, s)
     if s.typ.kind == tyStatic and s.typ.n != nil:
       return s.typ.n
     result = newSymNode(s, n.info)
     result.typ = makeTypeDesc(c, s.typ)
   else:
-    markUsed(n, s)
+    markUsed(n.info, s)
     result = newSymNode(s, n.info)
 
 type
@@ -176,21 +177,26 @@ proc checkConvertible(c: PContext, castDest, src: PType): TConvStatus =
     else:
       discard
 
-proc isCastable(dst, src: PType): bool = 
+proc isCastable(dst, src: PType): bool =
+  ## Checks whether the source type can be casted to the destination type.
+  ## Casting is very unrestrictive; casts are allowed as long as 
+  ## castDest.size >= src.size, and typeAllowed(dst, skParam)
   #const
   #  castableTypeKinds = {tyInt, tyPtr, tyRef, tyCstring, tyString, 
   #                       tySequence, tyPointer, tyNil, tyOpenArray,
   #                       tyProc, tySet, tyEnum, tyBool, tyChar}
-  var ds, ss: BiggestInt
-  # this is very unrestrictive; cast is allowed if castDest.size >= src.size
-  ds = computeSize(dst)
-  ss = computeSize(src)
-  if ds < 0: 
+  var dstSize, srcSize: BiggestInt
+
+  dstSize = computeSize(dst)
+  srcSize = computeSize(src)
+  if dstSize < 0: 
     result = false
-  elif ss < 0: 
+  elif srcSize < 0: 
+    result = false
+  elif not typeAllowed(dst, skParam):
     result = false
   else: 
-    result = (ds >= ss) or
+    result = (dstSize >= srcSize) or
         (skipTypes(dst, abstractInst).kind in IntegralTypes) or
         (skipTypes(src, abstractInst-{tyTypeDesc}).kind in IntegralTypes)
   
@@ -248,12 +254,13 @@ proc semConv(c: PContext, n: PNode): PNode =
       let it = op.sons[i]
       let status = checkConvertible(c, result.typ, it.typ)
       if status in {convOK, convNotNeedeed}:
-        markUsed(n, it.sym)
+        markUsed(n.info, it.sym)
         markIndirect(c, it.sym)
         return it
     localError(n.info, errUseQualifier, op.sons[0].sym.name.s)
 
 proc semCast(c: PContext, n: PNode): PNode = 
+  ## Semantically analyze a casting ("cast[type](param)")
   if optSafeCode in gGlobalOptions: localError(n.info, errCastNotInSafeMode)
   #incl(c.p.owner.flags, sfSideEffect)
   checkSonsLen(n, 2)
@@ -387,7 +394,7 @@ proc semOpAux(c: PContext, n: PNode) =
     var a = n.sons[i]
     if a.kind == nkExprEqExpr and sonsLen(a) == 2: 
       var info = a.sons[0].info
-      a.sons[0] = newIdentNode(considerAcc(a.sons[0]), info)
+      a.sons[0] = newIdentNode(considerQuotedIdent(a.sons[0]), info)
       a.sons[1] = semExprWithType(c, a.sons[1], flags)
       a.typ = a.sons[1].typ
     else:
@@ -786,6 +793,10 @@ proc semIndirectOp(c: PContext, n: PNode, flags: TExprFlags): PNode =
       n.flags.incl nfExprCall
       result = semOverloadedCallAnalyseEffects(c, n, nOrig, flags)
       if result == nil: return errorNode(c, n)
+    elif result.kind notin nkCallKinds:
+      # the semExpr() in overloadedCallOpr can even break this condition!
+      # See bug #904 of how to trigger it:
+      return result
   #result = afterCallActions(c, result, nOrig, flags)
   fixAbstractType(c, result)
   analyseIfAddressTakenInCall(c, result)
@@ -965,12 +976,12 @@ proc builtinFieldAccess(c: PContext, n: PNode, flags: TExprFlags): PNode =
 
   var s = qualifiedLookUp(c, n, {checkAmbiguity, checkUndeclared})
   if s != nil:
-    markUsed(n.sons[1], s)
+    markUsed(n.sons[1].info, s)
     return semSym(c, n, s, flags)
 
   n.sons[0] = semExprWithType(c, n.sons[0], flags+{efDetermineType})
   #restoreOldStyleType(n.sons[0])
-  var i = considerAcc(n.sons[1])
+  var i = considerQuotedIdent(n.sons[1])
   var ty = n.sons[0].typ
   var f: PSym = nil
   result = nil
@@ -988,7 +999,7 @@ proc builtinFieldAccess(c: PContext, n: PNode, flags: TExprFlags): PNode =
         result = newSymNode(f)
         result.info = n.info
         result.typ = ty
-        markUsed(n, f)
+        markUsed(n.info, f)
         return
     of tyTypeParamsHolders:
       return readTypeParameter(c, ty, i, n.info)
@@ -1020,7 +1031,7 @@ proc builtinFieldAccess(c: PContext, n: PNode, flags: TExprFlags): PNode =
     if f != nil:
       if fieldVisible(c, f):
         # is the access to a public field or in the same module or in a friend?
-        markUsed(n.sons[1], f)
+        markUsed(n.sons[1].info, f)
         n.sons[0] = makeDeref(n.sons[0])
         n.sons[1] = newSymNode(f) # we now have the correct field
         n.typ = f.typ
@@ -1033,7 +1044,7 @@ proc builtinFieldAccess(c: PContext, n: PNode, flags: TExprFlags): PNode =
   elif ty.kind == tyTuple and ty.n != nil: 
     f = getSymFromList(ty.n, i)
     if f != nil:
-      markUsed(n.sons[1], f)
+      markUsed(n.sons[1].info, f)
       n.sons[0] = makeDeref(n.sons[0])
       n.sons[1] = newSymNode(f)
       n.typ = f.typ
@@ -1051,7 +1062,7 @@ proc dotTransformation(c: PContext, n: PNode): PNode =
     addSon(result, n.sons[1])
     addSon(result, copyTree(n[0]))
   else:
-    var i = considerAcc(n.sons[1])
+    var i = considerQuotedIdent(n.sons[1])
     result = newNodeI(nkDotCall, n.info)
     result.flags.incl nfDotField
     addSon(result, newIdentNode(i, n[1].info))
@@ -1135,7 +1146,7 @@ proc semArrayAccess(c: PContext, n: PNode, flags: TExprFlags): PNode =
     result = semExpr(c, buildOverloadedSubscripts(n, getIdent"[]"))
 
 proc propertyWriteAccess(c: PContext, n, nOrig, a: PNode): PNode =
-  var id = considerAcc(a[1])
+  var id = considerQuotedIdent(a[1])
   var setterId = newIdentNode(getIdent(id.s & '='), n.info)
   # a[0] is already checked for semantics, that does ``builtinFieldAccess``
   # this is ugly. XXX Semantic checking should use the ``nfSem`` flag for
@@ -1369,7 +1380,7 @@ proc lookUpForDefined(c: PContext, n: PNode, onlyCurrentScope: bool): PSym =
       else: 
         localError(n.sons[1].info, errIdentifierExpected, "")
   of nkAccQuoted:
-    result = lookUpForDefined(c, considerAcc(n), onlyCurrentScope)
+    result = lookUpForDefined(c, considerQuotedIdent(n), onlyCurrentScope)
   of nkSym:
     result = n.sym
   else: 
@@ -1388,11 +1399,6 @@ proc semDefined(c: PContext, n: PNode, onlyCurrentScope: bool): PNode =
   result.info = n.info
   result.typ = getSysType(tyBool)
 
-proc setMs(n: PNode, s: PSym): PNode = 
-  result = n
-  n.sons[0] = newSymNode(s)
-  n.sons[0].info = n.info
-
 proc expectMacroOrTemplateCall(c: PContext, n: PNode): PSym =
   ## The argument to the proc should be nkCall(...) or similar
   ## Returns the macro/template symbol
@@ -1449,7 +1455,7 @@ proc semExpandToAst(c: PContext, n: PNode): PNode =
   if expandedSym.kind == skError: return n
 
   macroCall.sons[0] = newSymNode(expandedSym, macroCall.info)
-  markUsed(n, expandedSym)
+  markUsed(n.info, expandedSym)
 
   for i in countup(1, macroCall.len-1):
     macroCall.sons[i] = semExprWithType(c, macroCall[i], {})
@@ -1584,6 +1590,27 @@ proc semShallowCopy(c: PContext, n: PNode, flags: TExprFlags): PNode =
   else:
     result = semDirectOp(c, n, flags)
 
+proc createFlowVar(c: PContext; t: PType; info: TLineInfo): PType =
+  result = newType(tyGenericInvokation, c.module)
+  addSonSkipIntLit(result, magicsys.getCompilerProc("FlowVar").typ)
+  addSonSkipIntLit(result, t)
+  result = instGenericContainer(c, info, result, allowMetaTypes = false)
+
+proc instantiateCreateFlowVarCall(c: PContext; t: PType;
+                                  info: TLineInfo): PSym =
+  let sym = magicsys.getCompilerProc("nimCreateFlowVar")
+  if sym == nil:
+    localError(info, errSystemNeeds, "nimCreateFlowVar")
+  var bindings: TIdTable 
+  initIdTable(bindings)
+  bindings.idTablePut(sym.ast[genericParamsPos].sons[0].typ, t)
+  result = c.semGenerateInstance(c, sym, bindings, info)
+
+proc setMs(n: PNode, s: PSym): PNode = 
+  result = n
+  n.sons[0] = newSymNode(s)
+  n.sons[0].info = n.info
+
 proc semMagic(c: PContext, n: PNode, s: PSym, flags: TExprFlags): PNode = 
   # this is a hotspot in the compiler!
   # DON'T forget to update ast.SpecialSemMagics if you add a magic here!
@@ -1605,6 +1632,22 @@ proc semMagic(c: PContext, n: PNode, s: PSym, flags: TExprFlags): PNode =
     checkSonsLen(n, 2)
     result = newStrNodeT(renderTree(n[1], {renderNoComments}), n)
     result.typ = getSysType(tyString)
+  of mParallel:
+    result = setMs(n, s)
+    var x = n.lastSon
+    if x.kind == nkDo: x = x.sons[bodyPos]
+    inc c.inParallelStmt
+    result.sons[1] = semStmt(c, x)
+    dec c.inParallelStmt
+  of mSpawn:
+    result = setMs(n, s)
+    result.sons[1] = semExpr(c, n.sons[1])
+    if not result[1].typ.isEmptyType:
+      if c.inParallelStmt > 0:
+        result.typ = result[1].typ
+      else:
+        result.typ = createFlowVar(c, result[1].typ, n.info)
+      result.add instantiateCreateFlowVarCall(c, result[1].typ, n.info).newSymNode
   else: result = semDirectOp(c, n, flags)
 
 proc semWhen(c: PContext, n: PNode, semCheck = true): PNode =
@@ -1843,7 +1886,7 @@ proc semBlock(c: PContext, n: PNode): PNode =
     if sfGenSym notin labl.flags:
       addDecl(c, labl)
       n.sons[0] = newSymNode(labl, n.sons[0].info)
-    suggestSym(n.sons[0], labl)
+    suggestSym(n.sons[0].info, labl)
   n.sons[1] = semExpr(c, n.sons[1])
   n.typ = n.sons[1].typ
   if isEmptyType(n.typ): n.kind = nkBlockStmt
@@ -1963,7 +2006,7 @@ proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
     var s = qualifiedLookUp(c, n.sons[0], mode)
     if s != nil: 
       if gCmd == cmdPretty and n.sons[0].kind == nkDotExpr:
-        pretty.checkUse(n.sons[0].sons[1], s)
+        pretty.checkUse(n.sons[0].sons[1].info, s)
       case s.kind
       of skMacro:
         if sfImmediate notin s.flags:
diff --git a/compiler/semfold.nim b/compiler/semfold.nim
index 712d2efd2..30e02dcc9 100644
--- a/compiler/semfold.nim
+++ b/compiler/semfold.nim
@@ -1,7 +1,7 @@
 #
 #
 #           The Nimrod Compiler
-#        (c) Copyright 2012 Andreas Rumpf
+#        (c) Copyright 2014 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
@@ -537,17 +537,18 @@ proc foldArrayAccess(m: PSym, n: PNode): PNode =
   var idx = getOrdValue(y)
   case x.kind
   of nkPar: 
-    if (idx >= 0) and (idx < sonsLen(x)): 
+    if idx >= 0 and idx < sonsLen(x):
       result = x.sons[int(idx)]
       if result.kind == nkExprColonExpr: result = result.sons[1]
     else:
       localError(n.info, errIndexOutOfBounds)
-  of nkBracket: 
-    if (idx >= 0) and (idx < sonsLen(x)): result = x.sons[int(idx)]
+  of nkBracket:
+    idx = idx - x.typ.firstOrd
+    if idx >= 0 and idx < x.len: result = x.sons[int(idx)]
     else: localError(n.info, errIndexOutOfBounds)
-  of nkStrLit..nkTripleStrLit: 
+  of nkStrLit..nkTripleStrLit:
     result = newNodeIT(nkCharLit, x.info, n.typ)
-    if (idx >= 0) and (idx < len(x.strVal)): 
+    if idx >= 0 and idx < len(x.strVal): 
       result.intVal = ord(x.strVal[int(idx)])
     elif idx == len(x.strVal): 
       discard
diff --git a/compiler/semgnrc.nim b/compiler/semgnrc.nim
index 63beb15b0..934434951 100644
--- a/compiler/semgnrc.nim
+++ b/compiler/semgnrc.nim
@@ -69,7 +69,7 @@ proc semGenericStmtSymbol(c: PContext, n: PNode, s: PSym): PNode =
 proc lookup(c: PContext, n: PNode, flags: TSemGenericFlags, 
             ctx: var TIntSet): PNode =
   result = n
-  let ident = considerAcc(n)
+  let ident = considerQuotedIdent(n)
   var s = searchInScopes(c, ident)
   if s == nil:
     if ident.id notin ctx and withinMixin notin flags:
@@ -82,7 +82,37 @@ proc lookup(c: PContext, n: PNode, flags: TSemGenericFlags,
     else:
       result = semGenericStmtSymbol(c, n, s)
   # else: leave as nkIdent
+
+proc newDot(n, b: PNode): PNode =
+  result = newNodeI(nkDotExpr, n.info)
+  result.add(n.sons[0])
+  result.add(b)
+
+proc fuzzyLookup(c: PContext, n: PNode, flags: TSemGenericFlags, 
+                 ctx: var TIntSet): PNode =
+  assert n.kind == nkDotExpr
+  let luf = if withinMixin notin flags: {checkUndeclared} else: {}
   
+  var s = qualifiedLookUp(c, n, luf)
+  if s != nil:
+    result = semGenericStmtSymbol(c, n, s)
+  else:
+    result = n
+    let n = n[1]
+    let ident = considerQuotedIdent(n)
+    var s = searchInScopes(c, ident)
+    if s != nil and s.kind in routineKinds:
+      if withinBind in flags:
+        result = newDot(result, symChoice(c, n, s, scClosed))
+      elif s.name.id in ctx:
+        result = newDot(result, symChoice(c, n, s, scForceOpen))
+      else:
+        let sym = semGenericStmtSymbol(c, n, s)
+        if sym.kind == nkSym:
+          result = newDot(result, symChoice(c, n, s, scForceOpen))
+        else:
+          result = newDot(result, sym)
+
 proc semGenericStmt(c: PContext, n: PNode, 
                     flags: TSemGenericFlags, ctx: var TIntSet): PNode =
   result = n
@@ -91,10 +121,11 @@ proc semGenericStmt(c: PContext, n: PNode,
   of nkIdent, nkAccQuoted:
     result = lookup(c, n, flags, ctx)
   of nkDotExpr:
-    let luf = if withinMixin notin flags: {checkUndeclared} else: {}
-    var s = qualifiedLookUp(c, n, luf)
-    if s != nil: result = semGenericStmtSymbol(c, n, s)
+    #let luf = if withinMixin notin flags: {checkUndeclared} else: {}
+    #var s = qualifiedLookUp(c, n, luf)
+    #if s != nil: result = semGenericStmtSymbol(c, n, s)
     # XXX for example: ``result.add`` -- ``add`` needs to be looked up here...
+    result = fuzzyLookup(c, n, flags, ctx)
   of nkEmpty, nkSym..nkNilLit:
     # see tests/compile/tgensymgeneric.nim:
     # We need to open the gensym'ed symbol again so that the instantiation
@@ -114,7 +145,7 @@ proc semGenericStmt(c: PContext, n: PNode,
     let fn = n.sons[0]
     var s = qualifiedLookUp(c, fn, {})
     if s == nil and withinMixin notin flags and
-        fn.kind in {nkIdent, nkAccQuoted} and considerAcc(fn).id notin ctx:
+        fn.kind in {nkIdent, nkAccQuoted} and considerQuotedIdent(fn).id notin ctx:
       localError(n.info, errUndeclaredIdentifier, fn.renderTree)
     
     var first = 0
diff --git a/compiler/seminst.nim b/compiler/seminst.nim
index f7d5fa6f8..b93d7ca15 100644
--- a/compiler/seminst.nim
+++ b/compiler/seminst.nim
@@ -190,6 +190,9 @@ proc instantiateProcType(c: PContext, pt: TIdTable,
 
 proc generateInstance(c: PContext, fn: PSym, pt: TIdTable,
                       info: TLineInfo): PSym =
+  ## Generates a new instance of a generic procedure.
+  ## The `pt` parameter is a type-unsafe mapping table used to link generic
+  ## parameters to their concrete types within the generic instance.
   # no need to instantiate generic templates/macros:
   if fn.kind in {skTemplate, skMacro}: return fn
   # generates an instantiated proc
@@ -199,8 +202,7 @@ proc generateInstance(c: PContext, fn: PSym, pt: TIdTable,
   var n = copyTree(fn.ast)
   # NOTE: for access of private fields within generics from a different module
   # we set the friend module:
-  var oldFriend = c.friendModule
-  c.friendModule = getModule(fn)
+  c.friendModules.add(getModule(fn))
   #let oldScope = c.currentScope
   #c.currentScope = fn.scope
   result = copySym(fn, false)
@@ -236,6 +238,6 @@ proc generateInstance(c: PContext, fn: PSym, pt: TIdTable,
   closeScope(c)           # close scope for parameters
   popOwner()
   #c.currentScope = oldScope
-  c.friendModule = oldFriend
+  discard c.friendModules.pop()
   dec(c.instCounter)
   if result.kind == skMethod: finishMethod(c, result)
diff --git a/compiler/semmagic.nim b/compiler/semmagic.nim
index 4caf1fb8e..f943e7006 100644
--- a/compiler/semmagic.nim
+++ b/compiler/semmagic.nim
@@ -1,7 +1,7 @@
 #
 #
 #           The Nimrod Compiler
-#        (c) Copyright 2013 Andreas Rumpf
+#        (c) Copyright 2014 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
@@ -131,4 +131,3 @@ proc magicsAfterOverloadResolution(c: PContext, n: PNode,
   of mNBindSym: result = semBindSym(c, n)
   of mLocals: result = semLocals(c, n)
   else: result = n
-
diff --git a/compiler/semparallel.nim b/compiler/semparallel.nim
new file mode 100644
index 000000000..c594a4788
--- /dev/null
+++ b/compiler/semparallel.nim
@@ -0,0 +1,465 @@
+#
+#
+#           The Nimrod Compiler
+#        (c) Copyright 2014 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## Semantic checking for 'parallel'.
+
+# - codegen needs to support mSlice (+)
+# - lowerings must not perform unnecessary copies (+)
+# - slices should become "nocopy" to openArray (+)
+#   - need to perform bound checks (+)
+#
+# - parallel needs to insert a barrier (+)
+# - passed arguments need to be ensured to be "const"
+#   - what about 'f(a)'? --> f shouldn't have side effects anyway
+# - passed arrays need to be ensured not to alias
+# - passed slices need to be ensured to be disjoint (+)
+# - output slices need special logic (+)
+
+import
+  ast, astalgo, idents, lowerings, magicsys, guards, sempass2, msgs,
+  renderer
+from trees import getMagic
+from strutils import `%`
+
+discard """
+
+one major problem:
+  spawn f(a[i])
+  inc i
+  spawn f(a[i])
+is valid, but
+  spawn f(a[i])
+  spawn f(a[i])
+  inc i
+is not! However, 
+  spawn f(a[i])
+  if guard: inc i
+  spawn f(a[i])
+is not valid either! --> We need a flow dependent analysis here.
+
+However:
+  while foo:
+    spawn f(a[i])
+    inc i
+    spawn f(a[i])
+
+Is not valid either! --> We should really restrict 'inc' to loop endings?
+
+The heuristic that we implement here (that has no false positives) is: Usage
+of 'i' in a slice *after* we determined the stride is invalid!
+"""
+
+type
+  TDirection = enum
+    ascending, descending
+  MonotonicVar = object
+    v, alias: PSym        # to support the ordinary 'countup' iterator
+                          # we need to detect aliases
+    lower, upper, stride: PNode
+    dir: TDirection
+    blacklisted: bool     # blacklisted variables that are not monotonic
+  AnalysisCtx = object
+    locals: seq[MonotonicVar]
+    slices: seq[tuple[x,a,b: PNode, spawnId: int, inLoop: bool]]
+    guards: TModel      # nested guards
+    args: seq[PSym]     # args must be deeply immutable
+    spawns: int         # we can check that at last 1 spawn is used in
+                        # the 'parallel' section
+    currentSpawnId: int
+    inLoop: int
+
+let opSlice = createMagic("slice", mSlice)
+
+proc initAnalysisCtx(): AnalysisCtx =
+  result.locals = @[]
+  result.slices = @[]
+  result.args = @[]
+  result.guards = @[]
+
+proc lookupSlot(c: AnalysisCtx; s: PSym): int =
+  for i in 0.. <c.locals.len:
+    if c.locals[i].v == s or c.locals[i].alias == s: return i
+  return -1
+
+proc getSlot(c: var AnalysisCtx; v: PSym): ptr MonotonicVar =
+  let s = lookupSlot(c, v)
+  if s >= 0: return addr(c.locals[s])
+  let L = c.locals.len
+  c.locals.setLen(L+1)
+  c.locals[L].v = v
+  return addr(c.locals[L])
+
+proc gatherArgs(c: var AnalysisCtx; n: PNode) =
+  for i in 0.. <n.safeLen:
+    let root = getRoot n[i]
+    if root != nil:
+      block addRoot:
+        for r in items(c.args):
+          if r == root: break addRoot
+        c.args.add root
+    gatherArgs(c, n[i])
+
+proc isSingleAssignable(n: PNode): bool =
+  n.kind == nkSym and (let s = n.sym;
+    s.kind in {skTemp, skForVar, skLet} and
+          {sfAddrTaken, sfGlobal} * s.flags == {})
+
+proc isLocal(n: PNode): bool =
+  n.kind == nkSym and (let s = n.sym;
+    s.kind in {skResult, skTemp, skForVar, skVar, skLet} and
+          {sfAddrTaken, sfGlobal} * s.flags == {})
+
+proc checkLocal(c: AnalysisCtx; n: PNode) =
+  if isLocal(n):
+    let s = c.lookupSlot(n.sym)
+    if s >= 0 and c.locals[s].stride != nil:
+      localError(n.info, "invalid usage of counter after increment")
+  else:
+    for i in 0 .. <n.safeLen: checkLocal(c, n.sons[i])
+
+template `?`(x): expr = x.renderTree
+
+proc checkLe(c: AnalysisCtx; a, b: PNode) =
+  case proveLe(c.guards, a, b)
+  of impUnknown:
+    localError(a.info, "cannot prove: " & ?a & " <= " & ?b)
+  of impYes: discard
+  of impNo:
+    localError(a.info, "can prove: " & ?a & " > " & ?b)
+
+proc checkBounds(c: AnalysisCtx; arr, idx: PNode) =
+  checkLe(c, arr.lowBound, idx)
+  checkLe(c, idx, arr.highBound)
+
+proc addLowerBoundAsFacts(c: var AnalysisCtx) =
+  for v in c.locals:
+    if not v.blacklisted:
+      c.guards.addFactLe(v.lower, newSymNode(v.v))
+
+proc addSlice(c: var AnalysisCtx; n: PNode; x, le, ri: PNode) =
+  checkLocal(c, n)
+  let le = le.canon
+  let ri = ri.canon
+  # perform static bounds checking here; and not later!
+  let oldState = c.guards.len
+  addLowerBoundAsFacts(c)
+  c.checkBounds(x, le)
+  c.checkBounds(x, ri)
+  c.guards.setLen(oldState)
+  c.slices.add((x, le, ri, c.currentSpawnId, c.inLoop > 0))
+
+proc overlap(m: TModel; x,y,c,d: PNode) =
+  #  X..Y and C..D overlap iff (X <= D and C <= Y)
+  case proveLe(m, x, d)
+  of impUnknown:
+    localError(x.info,
+      "cannot prove: $# > $#; required for ($#)..($#) disjoint from ($#)..($#)" %
+        [?x, ?d, ?x, ?y, ?c, ?d])
+  of impYes:
+    case proveLe(m, c, y)
+    of impUnknown:
+      localError(x.info,
+        "cannot prove: $# > $#; required for ($#)..($#) disjoint from ($#)..($#)" %
+          [?c, ?y, ?x, ?y, ?c, ?d])
+    of impYes:
+      localError(x.info, "($#)..($#) not disjoint from ($#)..($#)" % [?x, ?y, ?c, ?d])
+    of impNo: discard
+  of impNo: discard
+
+proc stride(c: AnalysisCtx; n: PNode): BiggestInt =
+  if isLocal(n):
+    let s = c.lookupSlot(n.sym)
+    if s >= 0 and c.locals[s].stride != nil:
+      result = c.locals[s].stride.intVal
+  else:
+    for i in 0 .. <n.safeLen: result += stride(c, n.sons[i])
+
+proc subStride(c: AnalysisCtx; n: PNode): PNode =
+  # substitute with stride:
+  if isLocal(n):
+    let s = c.lookupSlot(n.sym)
+    if s >= 0 and c.locals[s].stride != nil:
+      result = n +@ c.locals[s].stride.intVal
+    else:
+      result = n
+  elif n.safeLen > 0:
+    result = shallowCopy(n)
+    for i in 0 .. <n.len: result.sons[i] = subStride(c, n.sons[i])
+  else:
+    result = n
+
+proc checkSlicesAreDisjoint(c: var AnalysisCtx) =
+  # this is the only thing that we need to perform after we have traversed
+  # the whole tree so that the strides are available.
+  # First we need to add all the computed lower bounds:
+  addLowerBoundAsFacts(c)
+  # Every slice used in a loop needs to be disjoint with itself:
+  for x,a,b,id,inLoop in items(c.slices):
+    if inLoop: overlap(c.guards, a,b, c.subStride(a), c.subStride(b))
+  # Another tricky example is:
+  #   while true:
+  #     spawn f(a[i])
+  #     spawn f(a[i+1])
+  #     inc i  # inc i, 2  would be correct here
+  #
+  # Or even worse:
+  #   while true:
+  #     spawn f(a[i+1 .. i+3])
+  #     spawn f(a[i+4 .. i+5])
+  #     inc i, 4
+  # Prove that i*k*stride + 3 != i*k'*stride + 5
+  # For the correct example this amounts to
+  #   i*k*2 != i*k'*2 + 1
+  # which is true.
+  # For now, we don't try to prove things like that at all, even though it'd
+  # be feasible for many useful examples. Instead we attach the slice to
+  # a spawn and if the attached spawns differ, we bail out:
+  for i in 0 .. high(c.slices):
+    for j in i+1 .. high(c.slices):
+      let x = c.slices[i]
+      let y = c.slices[j]
+      if x.spawnId != y.spawnId and guards.sameTree(x.x, y.x):
+        if not x.inLoop or not y.inLoop:
+          # XXX strictly speaking, 'or' is not correct here and it needs to
+          # be 'and'. However this prevents too many obviously correct programs
+          # like f(a[0..x]); for i in x+1 .. a.high: f(a[i])
+          overlap(c.guards, x.a, x.b, y.a, y.b)
+        elif (let k = simpleSlice(x.a, x.b); let m = simpleSlice(y.a, y.b);
+              k >= 0 and m >= 0):
+          # ah I cannot resist the temptation and add another sweet heuristic:
+          # if both slices have the form (i+k)..(i+k)  and (i+m)..(i+m) we
+          # check they are disjoint and k < stride and m < stride:
+          overlap(c.guards, x.a, x.b, y.a, y.b)
+          let stride = min(c.stride(x.a), c.stride(y.a))
+          if k < stride and m < stride:
+            discard
+          else:
+            localError(x.x.info, "cannot prove ($#)..($#) disjoint from ($#)..($#)" %
+              [?x.a, ?x.b, ?y.a, ?y.b])
+        else:
+          localError(x.x.info, "cannot prove ($#)..($#) disjoint from ($#)..($#)" %
+            [?x.a, ?x.b, ?y.a, ?y.b])
+
+proc analyse(c: var AnalysisCtx; n: PNode)
+
+proc analyseSons(c: var AnalysisCtx; n: PNode) =
+  for i in 0 .. <safeLen(n): analyse(c, n[i])
+
+proc min(a, b: PNode): PNode =
+  if a.isNil: result = b
+  elif a.intVal < b.intVal: result = a
+  else: result = b
+
+proc fromSystem(op: PSym): bool = sfSystemModule in getModule(op).flags
+
+proc analyseCall(c: var AnalysisCtx; n: PNode; op: PSym) =
+  if op.magic == mSpawn:
+    inc c.spawns
+    let oldSpawnId = c.currentSpawnId
+    c.currentSpawnId = c.spawns
+    gatherArgs(c, n[1])
+    analyseSons(c, n)
+    c.currentSpawnId = oldSpawnId
+  elif op.magic == mInc or (op.name.s == "+=" and op.fromSystem):
+    if n[1].isLocal:
+      let incr = n[2].skipConv
+      if incr.kind in {nkCharLit..nkUInt32Lit} and incr.intVal > 0:
+        let slot = c.getSlot(n[1].sym)
+        slot.stride = min(slot.stride, incr)
+    analyseSons(c, n)
+  elif op.name.s == "[]" and op.fromSystem:
+    c.addSlice(n, n[1], n[2][1], n[2][2])
+    analyseSons(c, n)
+  elif op.name.s == "[]=" and op.fromSystem:
+    c.addSlice(n, n[1], n[2][1], n[2][2])
+    analyseSons(c, n)
+  else:
+    analyseSons(c, n)
+
+proc analyseCase(c: var AnalysisCtx; n: PNode) =
+  analyse(c, n.sons[0])
+  let oldFacts = c.guards.len
+  for i in 1.. <n.len:
+    let branch = n.sons[i]
+    setLen(c.guards, oldFacts)
+    addCaseBranchFacts(c.guards, n, i)
+    for i in 0 .. <branch.len:
+      analyse(c, branch.sons[i])
+  setLen(c.guards, oldFacts)
+
+proc analyseIf(c: var AnalysisCtx; n: PNode) =
+  analyse(c, n.sons[0].sons[0])
+  let oldFacts = c.guards.len
+  addFact(c.guards, canon(n.sons[0].sons[0]))
+
+  analyse(c, n.sons[0].sons[1])
+  for i in 1.. <n.len:
+    let branch = n.sons[i]
+    setLen(c.guards, oldFacts)
+    for j in 0..i-1:
+      addFactNeg(c.guards, canon(n.sons[j].sons[0]))
+    if branch.len > 1:
+      addFact(c.guards, canon(branch.sons[0]))
+    for i in 0 .. <branch.len:
+      analyse(c, branch.sons[i])
+  setLen(c.guards, oldFacts)
+
+proc analyse(c: var AnalysisCtx; n: PNode) =
+  case n.kind
+  of nkAsgn, nkFastAsgn:
+    if n[0].isSingleAssignable and n[1].isLocal:
+      let slot = c.getSlot(n[1].sym)
+      slot.alias = n[0].sym
+    elif n[0].isLocal:
+      # since we already ensure sfAddrTaken is not in s.flags, we only need to
+      # prevent direct assignments to the monotonic variable:
+      let slot = c.getSlot(n[0].sym)
+      slot.blackListed = true
+    invalidateFacts(c.guards, n[0])
+    analyseSons(c, n)
+    addAsgnFact(c.guards, n[0], n[1])
+  of nkCallKinds:
+    # direct call:
+    if n[0].kind == nkSym: analyseCall(c, n, n[0].sym)
+    else: analyseSons(c, n)
+  of nkBracketExpr:
+    c.addSlice(n, n[0], n[1], n[1])
+    analyseSons(c, n)
+  of nkReturnStmt, nkRaiseStmt, nkTryStmt:
+    localError(n.info, "invalid control flow for 'parallel'")
+    # 'break' that leaves the 'parallel' section is not valid either
+    # or maybe we should generate a 'try' XXX
+  of nkVarSection:
+    for it in n:
+      let value = it.lastSon
+      if value.kind != nkEmpty:
+        for j in 0 .. it.len-3:
+          if it[j].isLocal:
+            let slot = c.getSlot(it[j].sym)
+            if slot.lower.isNil: slot.lower = value
+            else: internalError(it.info, "slot already has a lower bound")
+        analyse(c, value)
+  of nkCaseStmt: analyseCase(c, n)
+  of nkIfStmt, nkIfExpr: analyseIf(c, n)
+  of nkWhileStmt:
+    analyse(c, n.sons[0])
+    # 'while true' loop?
+    inc c.inLoop
+    if isTrue(n.sons[0]):
+      analyseSons(c, n.sons[1])
+    else:
+      # loop may never execute:
+      let oldState = c.locals.len
+      let oldFacts = c.guards.len
+      addFact(c.guards, canon(n.sons[0]))
+      analyse(c, n.sons[1])
+      setLen(c.locals, oldState)
+      setLen(c.guards, oldFacts)
+      # we know after the loop the negation holds:
+      if not hasSubnodeWith(n.sons[1], nkBreakStmt):
+        addFactNeg(c.guards, canon(n.sons[0]))
+    dec c.inLoop
+  of nkTypeSection, nkProcDef, nkConverterDef, nkMethodDef, nkIteratorDef,
+      nkMacroDef, nkTemplateDef, nkConstSection, nkPragma:
+    discard
+  else:
+    analyseSons(c, n)
+
+proc transformSlices(n: PNode): PNode =
+  if n.kind in nkCallKinds and n[0].kind == nkSym:
+    let op = n[0].sym
+    if op.name.s == "[]" and op.fromSystem:
+      result = copyNode(n)
+      result.add opSlice.newSymNode
+      result.add n[1]
+      result.add n[2][1]
+      result.add n[2][2]
+      return result
+  if n.safeLen > 0:
+    result = shallowCopy(n)
+    for i in 0 .. < n.len:
+      result.sons[i] = transformSlices(n.sons[i])
+  else:
+    result = n
+
+proc transformSpawn(owner: PSym; n, barrier: PNode): PNode
+proc transformSpawnSons(owner: PSym; n, barrier: PNode): PNode =
+  result = shallowCopy(n)
+  for i in 0 .. < n.len:
+    result.sons[i] = transformSpawn(owner, n.sons[i], barrier)
+
+proc transformSpawn(owner: PSym; n, barrier: PNode): PNode =
+  case n.kind
+  of nkVarSection:
+    result = nil
+    for it in n:
+      let b = it.lastSon
+      if getMagic(b) == mSpawn:
+        if it.len != 3: localError(it.info, "invalid context for 'spawn'")
+        let m = transformSlices(b)
+        if result.isNil:
+          result = newNodeI(nkStmtList, n.info)
+          result.add n
+        result.add wrapProcForSpawn(owner, m, b.typ, barrier, it[0])
+        it.sons[it.len-1] = emptyNode
+    if result.isNil: result = n
+  of nkAsgn, nkFastAsgn:
+    let b = n[1]
+    if getMagic(b) == mSpawn:
+      let m = transformSlices(b)
+      return wrapProcForSpawn(owner, m, b.typ, barrier, n[0])
+    result = transformSpawnSons(owner, n, barrier)
+  of nkCallKinds:
+    if getMagic(n) == mSpawn:
+      result = transformSlices(n)
+      return wrapProcForSpawn(owner, result, n.typ, barrier, nil)
+    result = transformSpawnSons(owner, n, barrier)
+  elif n.safeLen > 0:
+    result = transformSpawnSons(owner, n, barrier)
+  else:
+    result = n
+
+proc checkArgs(a: var AnalysisCtx; n: PNode) =
+  discard "too implement"
+
+proc generateAliasChecks(a: AnalysisCtx; result: PNode) =
+  discard "too implement"
+
+proc liftParallel*(owner: PSym; n: PNode): PNode =
+  # this needs to be called after the 'for' loop elimination
+
+  # first pass:
+  # - detect monotonic local integer variables
+  # - detect used slices
+  # - detect used arguments
+  #echo "PAR ", renderTree(n)
+  
+  var a = initAnalysisCtx()
+  let body = n.lastSon
+  analyse(a, body)
+  if a.spawns == 0:
+    localError(n.info, "'parallel' section without 'spawn'")
+  checkSlicesAreDisjoint(a)
+  checkArgs(a, body)
+
+  var varSection = newNodeI(nkVarSection, n.info)
+  var temp = newSym(skTemp, getIdent"barrier", owner, n.info)
+  temp.typ = magicsys.getCompilerProc("Barrier").typ
+  incl(temp.flags, sfFromGeneric)
+  let tempNode = newSymNode(temp)
+  varSection.addVar tempNode
+
+  let barrier = genAddrOf(tempNode)
+  result = newNodeI(nkStmtList, n.info)
+  generateAliasChecks(a, result)
+  result.add varSection
+  result.add callCodeGenProc("openBarrier", barrier)
+  result.add transformSpawn(owner, body, barrier)
+  result.add callCodeGenProc("closeBarrier", barrier)
+
diff --git a/compiler/sempass2.nim b/compiler/sempass2.nim
index 6afde5f05..c8ce5e787 100644
--- a/compiler/sempass2.nim
+++ b/compiler/sempass2.nim
@@ -89,7 +89,7 @@ proc initVarViaNew(a: PEffects, n: PNode) =
   if n.kind != nkSym: return
   let s = n.sym
   if {tfNeedsInit, tfNotNil} * s.typ.flags <= {tfNotNil}:
-    # 'x' is not nil, but that doesn't mean it's not nil children
+    # 'x' is not nil, but that doesn't mean its "not nil" children
     # are initialized:
     initVar(a, n)
 
@@ -478,7 +478,7 @@ proc trackBlock(tracked: PEffects, n: PNode) =
   else:
     track(tracked, n)
 
-proc isTrue(n: PNode): bool =
+proc isTrue*(n: PNode): bool =
   n.kind == nkSym and n.sym.kind == skEnumField and n.sym.position != 0 or
     n.kind == nkIntLit and n.intVal != 0
 
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index c2827905c..4d06b201e 100644
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -33,7 +33,7 @@ proc semBreakOrContinue(c: PContext, n: PNode): PNode =
       x.info = n.info
       incl(s.flags, sfUsed)
       n.sons[0] = x
-      suggestSym(x, s)
+      suggestSym(x.info, s)
     else:
       localError(n.info, errInvalidControlFlowX, s.name.s)
   elif (c.p.nestedLoopCounter <= 0) and (c.p.nestedBlockCounter <= 0): 
@@ -66,10 +66,16 @@ proc toCover(t: PType): BiggestInt =
     result = lengthOrd(skipTypes(t, abstractVar-{tyTypeDesc}))
 
 proc performProcvarCheck(c: PContext, n: PNode, s: PSym) =
+  ## Checks that the given symbol is a proper procedure variable, meaning
+  ## that it 
   var smoduleId = getModule(s).id
   if sfProcvar notin s.flags and s.typ.callConv == ccDefault and
-      smoduleId != c.module.id and smoduleId != c.friendModule.id: 
-    localError(n.info, errXCannotBePassedToProcVar, s.name.s)
+      smoduleId != c.module.id:
+    block outer:
+      for module in c.friendModules:
+        if smoduleId == module.id:
+          break outer
+      localError(n.info, errXCannotBePassedToProcVar, s.name.s)
 
 proc semProcvarCheck(c: PContext, n: PNode) =
   let n = n.skipConv
@@ -313,7 +319,7 @@ proc semIdentDef(c: PContext, n: PNode, kind: TSymKind): PSym =
     incl(result.flags, sfGlobal)
   else:
     result = semIdentWithPragma(c, kind, n, {})
-  suggestSym(n, result)
+  suggestSym(n.info, result)
 
 proc checkNilable(v: PSym) =
   if sfGlobal in v.flags and {tfNotNil, tfNeedsInit} * v.typ.flags != {}:
@@ -655,7 +661,8 @@ proc semFor(c: PContext, n: PNode): PNode =
   n.sons[length-2] = semExprNoDeref(c, n.sons[length-2], {efWantIterator})
   var call = n.sons[length-2]
   let isCallExpr = call.kind in nkCallKinds
-  if isCallExpr and call[0].kind == nkSym and call[0].sym.magic != mNone:
+  if isCallExpr and call[0].kind == nkSym and
+      call[0].sym.magic in {mFields, mFieldPairs, mOmpParFor}:
     if call.sons[0].sym.magic == mOmpParFor:
       result = semForVars(c, n)
       result.kind = nkParForStmt
@@ -822,6 +829,9 @@ proc typeSectionFinalPass(c: PContext, n: PNode) =
                               getCurrOwner(), s.info)
 
 proc semTypeSection(c: PContext, n: PNode): PNode =
+  ## Processes a type section. This must be done in separate passes, in order
+  ## to allow the type definitions in the section to reference each other
+  ## without regard for the order of their definitions.
   typeSectionLeftSidePass(c, n)
   typeSectionRightSidePass(c, n)
   typeSectionFinalPass(c, n)
@@ -868,7 +878,7 @@ proc lookupMacro(c: PContext, n: PNode): PSym =
     result = n.sym
     if result.kind notin {skMacro, skTemplate}: result = nil
   else:
-    result = searchInScopes(c, considerAcc(n), {skMacro, skTemplate})
+    result = searchInScopes(c, considerQuotedIdent(n), {skMacro, skTemplate})
 
 proc semProcAnnotation(c: PContext, prc: PNode): PNode =
   var n = prc.sons[pragmasPos]
@@ -879,7 +889,7 @@ proc semProcAnnotation(c: PContext, prc: PNode): PNode =
     let m = lookupMacro(c, key)
     if m == nil:
       if key.kind == nkIdent and key.ident.id == ord(wDelegator):
-        if considerAcc(prc.sons[namePos]).s == "()":
+        if considerQuotedIdent(prc.sons[namePos]).s == "()":
           prc.sons[namePos] = newIdentNode(idDelegator, prc.info)
           prc.sons[pragmasPos] = copyExcept(n, i)
         else:
diff --git a/compiler/semtempl.nim b/compiler/semtempl.nim
index ad34eea65..ee8b1ccb8 100644
--- a/compiler/semtempl.nim
+++ b/compiler/semtempl.nim
@@ -59,7 +59,7 @@ proc symChoice(c: PContext, n: PNode, s: PSym, r: TSymChoiceRule): PNode =
     # (s.kind notin routineKinds or s.magic != mNone):
     # for instance 'nextTry' is both in tables.nim and astalgo.nim ...
     result = newSymNode(s, n.info)
-    markUsed(n, s)
+    markUsed(n.info, s)
   else:
     # semantic checking requires a type; ``fitNode`` deals with it
     # appropriately
@@ -93,7 +93,7 @@ proc semBindStmt(c: PContext, n: PNode, toBind: var TIntSet): PNode =
 
 proc semMixinStmt(c: PContext, n: PNode, toMixin: var TIntSet): PNode =
   for i in 0 .. < n.len:
-    toMixin.incl(considerAcc(n.sons[i]).id)
+    toMixin.incl(considerQuotedIdent(n.sons[i]).id)
   result = newNodeI(nkEmpty, n.info)
   
 proc replaceIdentBySym(n: var PNode, s: PNode) =
@@ -151,7 +151,7 @@ proc onlyReplaceParams(c: var TemplCtx, n: PNode): PNode =
       result.sons[i] = onlyReplaceParams(c, n.sons[i])
 
 proc newGenSym(kind: TSymKind, n: PNode, c: var TemplCtx): PSym =
-  result = newSym(kind, considerAcc(n), c.owner, n.info)
+  result = newSym(kind, considerQuotedIdent(n), c.owner, n.info)
   incl(result.flags, sfGenSym)
   incl(result.flags, sfShadowed)
 
diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim
index 8fcb6ea99..53fe4e266 100644
--- a/compiler/semtypes.nim
+++ b/compiler/semtypes.nim
@@ -70,9 +70,10 @@ proc semEnum(c: PContext, n: PNode, prev: PType): PType =
       counter = x
     of nkSym: 
       e = n.sons[i].sym
-    of nkIdent: 
+    of nkIdent, nkAccQuoted: 
       e = newSymS(skEnumField, n.sons[i], c)
-    else: illFormedAst(n)
+    else:
+      illFormedAst(n[i])
     e.typ = result
     e.position = int(counter)
     if e.position == 0: hasNull = true
@@ -116,7 +117,7 @@ proc semVarargs(c: PContext, n: PNode, prev: PType): PType =
     var base = semTypeNode(c, n.sons[1], nil)
     addSonSkipIntLit(result, base)
     if sonsLen(n) == 3:
-      result.n = newIdentNode(considerAcc(n.sons[2]), n.sons[2].info)
+      result.n = newIdentNode(considerQuotedIdent(n.sons[2]), n.sons[2].info)
   else:
     localError(n.info, errXExpectsOneTypeParam, "varargs")
     addSonSkipIntLit(result, errorType(c))
@@ -280,7 +281,7 @@ proc semTypeIdent(c: PContext, n: PNode): PSym =
   else:
     result = qualifiedLookUp(c, n, {checkAmbiguity, checkUndeclared})
     if result != nil:
-      markUsed(n, result)
+      markUsed(n.info, result)
       if result.kind == skParam and result.typ.kind == tyTypeDesc:
         # This is a typedesc param. is it already bound?
         # it's not bound when it's used multiple times in the
@@ -442,14 +443,14 @@ proc semCaseBranch(c: PContext, t, branch: PNode, branchIndex: int,
     elif isRange(b):
       branch.sons[i] = semCaseBranchRange(c, t, b, covered)
     else:
+      # constant sets and arrays are allowed:
       var r = semConstExpr(c, b)
       # for ``{}`` we want to trigger the type mismatch in ``fitNode``:
-      if r.kind != nkCurly or len(r) == 0:
+      if r.kind notin {nkCurly, nkBracket} or len(r) == 0:
         checkMinSonsLen(t, 1)
         branch.sons[i] = skipConv(fitNode(c, t.sons[0].typ, r))
         inc(covered)
       else:
-        # constant sets have special rules
         # first element is special and will overwrite: branch.sons[i]:
         branch.sons[i] = semCaseBranchSetElem(c, t, r[0], covered)
         # other elements have to be added to ``branch``
@@ -561,7 +562,7 @@ proc semRecordNodeAux(c: PContext, n: PNode, check: var TIntSet, pos: var int,
     let rec = rectype.sym
     for i in countup(0, sonsLen(n)-3):
       var f = semIdentWithPragma(c, skField, n.sons[i], {sfExported})
-      suggestSym(n.sons[i], f)
+      suggestSym(n.sons[i].info, f)
       f.typ = typ
       f.position = pos
       if (rec != nil) and ({sfImportc, sfExportc} * rec.flags != {}) and
@@ -826,7 +827,7 @@ proc liftParamType(c: PContext, procKind: TSymKind, genericParams: PNode,
       result = addImplicitGeneric(newTypeS(tyAnything, c))
   
   of tyGenericParam:
-    markUsed(genericParams, paramType.sym)
+    markUsed(info, paramType.sym)
     if tfWildcard in paramType.flags:
       paramType.flags.excl tfWildcard
       paramType.sym.kind = skType
@@ -863,7 +864,13 @@ proc semProcTypeNode(c: PContext, n, genericParams: PNode,
   var counter = 0
   for i in countup(1, n.len - 1):
     var a = n.sons[i]
-    if a.kind != nkIdentDefs: illFormedAst(a)
+    if a.kind != nkIdentDefs:
+      # for some generic instantiations the passed ':env' parameter
+      # for closures has already been produced (see bug #898). We simply
+      # skip this parameter here. It'll then be re-generated in another LL
+      # pass over this instantiation:
+      if a.kind == nkSym and sfFromGeneric in a.sym.flags: continue
+      illFormedAst(a)
     checkMinSonsLen(a, 3)
     var
       typ: PType = nil
@@ -1084,8 +1091,10 @@ proc semTypeNode(c: PContext, n: PNode, prev: PType): PType =
   of nkCallKinds:
     if isRange(n):
       result = semRangeAux(c, n, prev)
-    elif n[0].kind == nkIdent:
-      let op = n.sons[0].ident
+    elif n[0].kind notin nkIdentKinds:
+      result = semTypeExpr(c, n)
+    else:
+      let op = considerQuotedIdent(n.sons[0])
       if op.id in {ord(wAnd), ord(wOr)} or op.s == "|":
         checkSonsLen(n, 3)
         var
@@ -1120,8 +1129,6 @@ proc semTypeNode(c: PContext, n: PNode, prev: PType): PType =
         result = semAnyRef(c, n, tyRef, prev)
       else:
         result = semTypeExpr(c, n)
-    else:
-      result = semTypeExpr(c, n)
   of nkWhenStmt:
     var whenResult = semWhen(c, n, false)
     if whenResult.kind == nkStmtList: whenResult.kind = nkStmtListType
@@ -1180,7 +1187,7 @@ proc semTypeNode(c: PContext, n: PNode, prev: PType): PType =
       else: 
         assignType(prev, t)
         result = prev
-      markUsed(n, n.sym)
+      markUsed(n.info, n.sym)
     else:
       if n.sym.kind != skError: localError(n.info, errTypeExpected)
       result = newOrPrevType(tyError, prev, c)
diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim
index 4b91a067e..e5bf08097 100644
--- a/compiler/sigmatch.nim
+++ b/compiler/sigmatch.nim
@@ -62,7 +62,7 @@ type
 const
   isNilConversion = isConvertible # maybe 'isIntConv' fits better?
     
-proc markUsed*(n: PNode, s: PSym)
+proc markUsed*(info: TLineInfo, s: PSym)
 
 proc initCandidateAux(ctx: PContext,
                       c: var TCandidate, callee: PType) {.inline.} =
@@ -497,11 +497,11 @@ proc matchUserTypeClass*(c: PContext, m: var TCandidate,
 proc shouldSkipDistinct(rules: PNode, callIdent: PIdent): bool =
   if rules.kind == nkWith:
     for r in rules:
-      if r.considerAcc == callIdent: return true
+      if r.considerQuotedIdent == callIdent: return true
     return false
   else:
     for r in rules:
-      if r.considerAcc == callIdent: return false
+      if r.considerQuotedIdent == callIdent: return false
     return true
 
 proc maybeSkipDistinct(t: PType, callee: PSym): PType =
@@ -1058,7 +1058,7 @@ proc userConvMatch(c: PContext, m: var TCandidate, f, a: PType,
       dest = generateTypeInstance(c, m.bindings, arg, dest)
     let fdest = typeRel(m, f, dest)
     if fdest in {isEqual, isGeneric}: 
-      markUsed(arg, c.converters[i])
+      markUsed(arg.info, c.converters[i])
       var s = newSymNode(c.converters[i])
       s.typ = c.converters[i].typ
       s.info = arg.info
@@ -1271,7 +1271,7 @@ proc paramTypesMatch*(m: var TCandidate, f, a: PType,
       result = nil
     else: 
       # only one valid interpretation found:
-      markUsed(arg, arg.sons[best].sym)
+      markUsed(arg.info, arg.sons[best].sym)
       result = paramTypesMatchAux(m, f, arg.sons[best].typ, arg.sons[best],
                                   argOrig)
 
@@ -1302,7 +1302,7 @@ proc prepareOperand(c: PContext; a: PNode): PNode =
 proc prepareNamedParam(a: PNode) =
   if a.sons[0].kind != nkIdent:
     var info = a.sons[0].info
-    a.sons[0] = newIdentNode(considerAcc(a.sons[0]), info)
+    a.sons[0] = newIdentNode(considerQuotedIdent(a.sons[0]), info)
 
 proc arrayConstr(c: PContext, n: PNode): PType =
   result = newTypeS(tyArrayConstr, c)
diff --git a/compiler/suggest.nim b/compiler/suggest.nim
index fc6ba2f77..c2bdfc5c3 100644
--- a/compiler/suggest.nim
+++ b/compiler/suggest.nim
@@ -63,8 +63,11 @@ proc filterSym(s: PSym): bool {.inline.} =
 
 proc fieldVisible*(c: PContext, f: PSym): bool {.inline.} =
   let fmoduleId = getModule(f).id
-  result = sfExported in f.flags or fmoduleId == c.module.id or
-      fmoduleId == c.friendModule.id
+  result = sfExported in f.flags or fmoduleId == c.module.id
+  for module in c.friendModules:
+    if fmoduleId == module.id:
+      result = true
+      break
 
 proc suggestField(c: PContext, s: PSym, outputs: var int) = 
   if filterSym(s) and fieldVisible(c, s):
@@ -243,18 +246,18 @@ var
   usageSym*: PSym
   lastLineInfo: TLineInfo
 
-proc findUsages(node: PNode, s: PSym) =
-  if usageSym == nil and isTracked(node.info, s.name.s.len):
+proc findUsages(info: TLineInfo; s: PSym) =
+  if usageSym == nil and isTracked(info, s.name.s.len):
     usageSym = s
     suggestWriteln(symToStr(s, isLocal=false, sectionUsage))
   elif s == usageSym:
-    if lastLineInfo != node.info:
-      suggestWriteln(symToStr(s, isLocal=false, sectionUsage, node.info))
-    lastLineInfo = node.info
+    if lastLineInfo != info:
+      suggestWriteln(symToStr(s, isLocal=false, sectionUsage, info))
+    lastLineInfo = info
 
-proc findDefinition(node: PNode, s: PSym) =
-  if node.isNil or s.isNil: return
-  if isTracked(node.info, s.name.s.len):
+proc findDefinition(info: TLineInfo; s: PSym) =
+  if s.isNil: return
+  if isTracked(info, s.name.s.len):
     suggestWriteln(symToStr(s, isLocal=false, sectionDef))
     suggestQuit()
 
@@ -313,26 +316,26 @@ proc defFromSourceMap*(i: TLineInfo) =
   
   defFromLine(gSourceMaps[i.fileIndex].lines[i.line].entries, i.col)
 
-proc suggestSym*(n: PNode, s: PSym) {.inline.} =
+proc suggestSym*(info: TLineInfo; s: PSym) {.inline.} =
   ## misnamed: should be 'symDeclared'
   if optUsages in gGlobalOptions:
-    findUsages(n, s)
+    findUsages(info, s)
   if optDef in gGlobalOptions:
-    findDefinition(n, s)
+    findDefinition(info, s)
   if isServing:
-    addToSourceMap(s, n.info)
+    addToSourceMap(s, info)
 
-proc markUsed(n: PNode, s: PSym) =
+proc markUsed(info: TLineInfo; s: PSym) =
   incl(s.flags, sfUsed)
   if {sfDeprecated, sfError} * s.flags != {}:
-    if sfDeprecated in s.flags: message(n.info, warnDeprecated, s.name.s)
-    if sfError in s.flags: localError(n.info, errWrongSymbolX, s.name.s)
-  suggestSym(n, s)
-  if gCmd == cmdPretty: checkUse(n, s)
+    if sfDeprecated in s.flags: message(info, warnDeprecated, s.name.s)
+    if sfError in s.flags: localError(info, errWrongSymbolX, s.name.s)
+  suggestSym(info, s)
+  if gCmd == cmdPretty: checkUse(info, s)
 
 proc useSym*(sym: PSym): PNode =
   result = newSymNode(sym)
-  markUsed(result, sym)
+  markUsed(result.info, sym)
 
 proc suggestExpr*(c: PContext, node: PNode) = 
   var cp = msgs.inCheckpoint(node.info)
diff --git a/compiler/transf.nim b/compiler/transf.nim
index fb5e321b6..dece1ac18 100644
--- a/compiler/transf.nim
+++ b/compiler/transf.nim
@@ -546,7 +546,7 @@ proc flattenTree(root: PNode): PNode =
     flattenTreeAux(result, root, op)
   else: 
     result = root
-  
+
 proc transformCall(c: PTransf, n: PNode): PTransNode = 
   var n = flattenTree(n)
   var op = getMergeOp(n)
@@ -565,6 +565,9 @@ proc transformCall(c: PTransf, n: PNode): PTransNode =
           inc(j)
       add(result, a.PTransNode)
     if len(result) == 2: result = result[1]
+  elif getMagic(n) == mNBindSym:
+    # for bindSym(myconst) we MUST NOT perform constant folding:
+    result = n.PTransNode
   else:
     let s = transformSons(c, n).PNode
     # bugfix: check after 'transformSons' if it's still a method call:
diff --git a/compiler/types.nim b/compiler/types.nim
index 1f266d64f..786eea14e 100644
--- a/compiler/types.nim
+++ b/compiler/types.nim
@@ -1118,6 +1118,11 @@ proc typeAllowed(t: PType, kind: TSymKind): bool =
 proc align(address, alignment: BiggestInt): BiggestInt = 
   result = (address + (alignment - 1)) and not (alignment - 1)
 
+const
+  szNonConcreteType* = -3
+  szIllegalRecursion* = -2
+  szUnknownSize* = -1
+
 proc computeSizeAux(typ: PType, a: var BiggestInt): BiggestInt
 proc computeRecSizeAux(n: PNode, a, currOffset: var BiggestInt): BiggestInt = 
   var maxAlign, maxSize, b, res: BiggestInt
@@ -1151,14 +1156,9 @@ proc computeRecSizeAux(n: PNode, a, currOffset: var BiggestInt): BiggestInt =
   of nkSym: 
     result = computeSizeAux(n.sym.typ, a)
     n.sym.offset = int(currOffset)
-  else: 
-    internalError("computeRecSizeAux()")
+  else:
     a = 1
-    result = - 1
-
-const 
-  szIllegalRecursion* = -2
-  szUnknownSize* = -1
+    result = szNonConcreteType
 
 proc computeSizeAux(typ: PType, a: var BiggestInt): BiggestInt =
   var res, maxAlign, length, currOffset: BiggestInt
diff --git a/compiler/typesrenderer.nim b/compiler/typesrenderer.nim
index 790bd1047..f3121a0b4 100644
--- a/compiler/typesrenderer.nim
+++ b/compiler/typesrenderer.nim
@@ -1,4 +1,4 @@
-import renderer, strutils, ast, msgs, types
+import renderer, strutils, ast, msgs, types, astalgo
 
 const defaultParamSeparator* = ","
 
@@ -92,7 +92,7 @@ proc renderParamTypes(found: var seq[string], n: PNode) =
       if not typ.isNil: typeStr = typeToString(typ, preferExported)
       if typeStr.len < 1: return
     for i in 0 .. <typePos:
-      assert n[i].kind == nkIdent
+      assert ((n[i].kind == nkIdent) or (n[i].kind == nkAccQuoted))
       found.add(typeStr)
   else:
     internalError(n.info, "renderParamTypes(found,n) with " & $n.kind)
diff --git a/compiler/vm.nim b/compiler/vm.nim
index 218369fa1..66595856a 100644
--- a/compiler/vm.nim
+++ b/compiler/vm.nim
@@ -131,12 +131,16 @@ proc createStrKeepNode(x: var TFullReg) =
       nfAllConst in x.node.flags:
     # XXX this is hacky; tests/txmlgen triggers it:
     x.node = newNode(nkStrLit)
-    #  debug x.node
-    #assert x.node.kind in {nkStrLit..nkTripleStrLit}
+    # It not only hackey, it is also wrong for tgentemplate. The primary
+    # cause of bugs like these is that the VM does not properly distinguish
+    # between variable defintions (var foo = e) and variable updates (foo = e).
 
 template createStr(x) =
   x.node = newNode(nkStrLit)
 
+template createSet(x) =
+  x.node = newNode(nkCurly)
+
 proc moveConst(x: var TFullReg, y: TFullReg) =
   if x.kind != y.kind:
     myreset(x)
@@ -434,7 +438,6 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
       if regs[rc].intVal > high(int):
         stackTrace(c, tos, pc, errIndexOutOfBounds)
       let idx = regs[rc].intVal.int
-      # XXX what if the array is not 0-based? -> codegen should insert a sub
       let src = regs[rb].node
       if src.kind notin {nkEmpty..nkNilLit} and idx <% src.len:
         regs[ra].node = src.sons[idx]
@@ -500,13 +503,13 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
       else:
         stackTrace(c, tos, pc, errNilAccess)
     of opcWrDeref:
-      # a[] = b
+      # a[] = c; b unused
       let ra = instr.regA
-      let rb = instr.regB
+      let rc = instr.regC
       case regs[ra].kind
-      of rkNodeAddr: putIntoNode(regs[ra].nodeAddr[], regs[rb])
-      of rkRegisterAddr: regs[ra].regAddr[] = regs[rb]
-      of rkNode: putIntoNode(regs[ra].node, regs[rb])
+      of rkNodeAddr: putIntoNode(regs[ra].nodeAddr[], regs[rc])
+      of rkRegisterAddr: regs[ra].regAddr[] = regs[rc]
+      of rkNode: putIntoNode(regs[ra].node, regs[rc])
       else: stackTrace(c, tos, pc, errNilAccess)
     of opcAddInt:
       decodeBC(rkInt)
@@ -668,14 +671,11 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
     of opcLtu:
       decodeBC(rkInt)
       regs[ra].intVal = ord(regs[rb].intVal <% regs[rc].intVal)
-    of opcEqRef:
+    of opcEqRef, opcEqNimrodNode:
       decodeBC(rkInt)
       regs[ra].intVal = ord((regs[rb].node.kind == nkNilLit and
                              regs[rc].node.kind == nkNilLit) or
                              regs[rb].node == regs[rc].node)
-    of opcEqNimrodNode:
-      decodeBC(rkInt)
-      regs[ra].intVal = ord(regs[rb].node == regs[rc].node)
     of opcXor:
       decodeBC(rkInt)
       regs[ra].intVal = ord(regs[rb].intVal != regs[rc].intVal)
@@ -721,18 +721,22 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
       regs[ra].intVal = ord(containsSets(a, b) and not equalSets(a, b))
     of opcMulSet:
       decodeBC(rkNode)
+      createSet(regs[ra])
       move(regs[ra].node.sons, 
             nimsets.intersectSets(regs[rb].node, regs[rc].node).sons)
     of opcPlusSet: 
       decodeBC(rkNode)
+      createSet(regs[ra])
       move(regs[ra].node.sons,
            nimsets.unionSets(regs[rb].node, regs[rc].node).sons)
     of opcMinusSet:
       decodeBC(rkNode)
+      createSet(regs[ra])
       move(regs[ra].node.sons,
            nimsets.diffSets(regs[rb].node, regs[rc].node).sons)
     of opcSymdiffSet:
       decodeBC(rkNode)
+      createSet(regs[ra])
       move(regs[ra].node.sons,
            nimsets.symdiffSets(regs[rb].node, regs[rc].node).sons)    
     of opcConcatStr:
@@ -743,11 +747,11 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
         regs[ra].node.strVal.add getstr(regs[i])
     of opcAddStrCh:
       decodeB(rkNode)
-      createStrKeepNode regs[ra]
+      #createStrKeepNode regs[ra]
       regs[ra].node.strVal.add(regs[rb].intVal.chr)
     of opcAddStrStr:
       decodeB(rkNode)
-      createStrKeepNode regs[ra]
+      #createStrKeepNode regs[ra]
       regs[ra].node.strVal.add(regs[rb].node.strVal)
     of opcAddSeqElem:
       decodeB(rkNode)
@@ -898,10 +902,10 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
       c.exceptionInstr = pc
       let (newPc, newTos) = cleanUpOnException(c, tos)
       # -1 because of the following 'inc'
-      if pc-1 < 0:
+      if newPc-1 < 0:
         bailOut(c, tos)
         return
-      pc = newPc -1
+      pc = newPc-1
       if tos != newTos:
         tos = newTos
         move(regs, tos.slots)
@@ -984,7 +988,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
         return TFullReg(kind: rkNone)
     of opcSetLenStr:
       decodeB(rkNode)
-      createStrKeepNode regs[ra]
+      #createStrKeepNode regs[ra]
       regs[ra].node.strVal.setLen(regs[rb].intVal.int)
     of opcOf:
       decodeBC(rkInt)
diff --git a/compiler/vmdeps.nim b/compiler/vmdeps.nim
index 0e01f5031..9a213d813 100644
--- a/compiler/vmdeps.nim
+++ b/compiler/vmdeps.nim
@@ -15,6 +15,8 @@ proc readOutput(p: PProcess): string =
   discard p.waitForExit
   while not output.atEnd:
     result.add(output.readLine)
+    result.add("\n")
+  result.setLen(result.len - "\n".len)
 
 proc opGorge*(cmd, input: string): string =
   var p = startCmd(cmd)
diff --git a/compiler/vmgen.nim b/compiler/vmgen.nim
index ba1b33e77..c1ec637dd 100644
--- a/compiler/vmgen.nim
+++ b/compiler/vmgen.nim
@@ -9,6 +9,24 @@
 
 ## This module implements the code generator for the VM.
 
+# Important things to remember:
+# - The VM does not distinguish between definitions ('var x = y') and
+#   assignments ('x = y'). For simple data types that fit into a register
+#   this doesn't matter. However it matters for strings and other complex
+#   types that use the 'node' field; the reason is that slots are
+#   re-used in a register based VM. Example:
+# 
+# .. code-block:: nimrod
+#   let s = a & b  # no matter what, create fresh node
+#   s = a & b  # no matter what, keep the node
+#
+# Also *stores* into non-temporary memory need to perform deep copies:
+# a.b = x.y
+# We used to generate opcAsgn for the *load* of 'x.y' but this is clearly
+# wrong! We need to produce opcAsgn (the copy) for the *store*. This also
+# solves the opcLdConst vs opcAsgnConst issue. Of course whether we need
+# this copy depends on the involved types.
+
 import
   unsigned, strutils, ast, astalgo, types, msgs, renderer, vmdef, 
   trees, intsets, rodread, magicsys, options, lowerings
@@ -84,21 +102,27 @@ proc gABI(c: PCtx; n: PNode; opc: TOpcode; a, b: TRegister; imm: BiggestInt) =
   # Takes the `b` register and the immediate `imm`, appies the operation `opc`,
   # and stores the output value into `a`.
   # `imm` is signed and must be within [-127, 128]
-  assert(imm >= -127 and imm <= 128)
-  let ins = (opc.uint32 or (a.uint32 shl 8'u32) or
-                           (b.uint32 shl 16'u32) or
-                           (imm+byteExcess).uint32 shl 24'u32).TInstr
-  c.code.add(ins)
-  c.debug.add(n.info)
+  if imm >= -127 and imm <= 128:
+    let ins = (opc.uint32 or (a.uint32 shl 8'u32) or
+                             (b.uint32 shl 16'u32) or
+                             (imm+byteExcess).uint32 shl 24'u32).TInstr
+    c.code.add(ins)
+    c.debug.add(n.info)
+  else:
+    localError(n.info, errGenerated,
+      "VM: immediate value does not fit into an int8")
 
 proc gABx(c: PCtx; n: PNode; opc: TOpcode; a: TRegister = 0; bx: int) =
   # Applies `opc` to `bx` and stores it into register `a`
   # `bx` must be signed and in the range [-32767, 32768]
-  assert(bx >= -32767 and bx <= 32768)
-  let ins = (opc.uint32 or a.uint32 shl 8'u32 or 
-            (bx+wordExcess).uint32 shl 16'u32).TInstr
-  c.code.add(ins)
-  c.debug.add(n.info)
+  if bx >= -32767 and bx <= 32768:
+    let ins = (opc.uint32 or a.uint32 shl 8'u32 or 
+              (bx+wordExcess).uint32 shl 16'u32).TInstr
+    c.code.add(ins)
+    c.debug.add(n.info)
+  else:
+    localError(n.info, errGenerated,
+      "VM: immediate value does not fit into an int16")
 
 proc xjmp(c: PCtx; n: PNode; opc: TOpcode; a: TRegister = 0): TPosition =
   #assert opc in {opcJmp, opcFJmp, opcTJmp}
@@ -485,11 +509,22 @@ proc genField(n: PNode): TRegister =
         "too large offset! cannot generate code for: " & s.name.s)
   result = s.position
 
+proc genIndex(c: PCtx; n: PNode; arr: PType): TRegister =
+  if arr.skipTypes(abstractInst).kind == tyArray and (let x = firstOrd(arr);
+      x != 0):
+    let tmp = c.genx(n)
+    # freeing the temporary here means we can produce:  regA = regA - Imm
+    c.freeTemp(tmp)
+    result = c.getTemp(n.typ)
+    c.gABI(n, opcSubImmInt, result, tmp, x.int)
+  else:
+    result = c.genx(n)
+
 proc genAsgnPatch(c: PCtx; le: PNode, value: TRegister) =
   case le.kind
   of nkBracketExpr:
     let dest = c.genx(le.sons[0], {gfAddrOf})
-    let idx = c.genx(le.sons[1])
+    let idx = c.genIndex(le.sons[1], le.sons[0].typ)
     c.gABC(le, opcWrArr, dest, idx, value)
     c.freeTemp(dest)
     c.freeTemp(idx)
@@ -502,12 +537,12 @@ proc genAsgnPatch(c: PCtx; le: PNode, value: TRegister) =
     c.freeTemp(dest)
   of nkDerefExpr, nkHiddenDeref:
     let dest = c.genx(le.sons[0], {gfAddrOf})
-    c.gABC(le, opcWrDeref, dest, value)
+    c.gABC(le, opcWrDeref, dest, 0, value)
     c.freeTemp(dest)
   of nkSym:
     if le.sym.isGlobal:
       let dest = c.genx(le, {gfAddrOf})
-      c.gABC(le, opcWrDeref, dest, value)
+      c.gABC(le, opcWrDeref, dest, 0, value)
       c.freeTemp(dest)
   else:
     discard
@@ -787,10 +822,12 @@ proc genMagic(c: PCtx; n: PNode; dest: var TDest) =
     c.freeTemp(tmp)
   of mSwap: 
     unused(n, dest)
-    var d = c.genx(n.sons[1])
-    var tmp = c.genx(n.sons[2])
-    c.gABC(n, opcSwap, d, tmp)
-    c.freeTemp(tmp)
+    var
+      d1 = c.genx(n.sons[1])
+      d2 = c.genx(n.sons[2])
+    c.gABC(n, opcSwap, d1, d2)
+    c.genAsgnPatch(n.sons[1], d1)
+    c.genAsgnPatch(n.sons[2], d2)
   of mIsNil: genUnaryABC(c, n, dest, opcIsNil)
   of mCopyStr:
     if dest < 0: dest = c.getTemp(n.typ)
@@ -969,7 +1006,7 @@ const
 
 proc fitsRegister*(t: PType): bool =
   t.skipTypes(abstractInst-{tyTypeDesc}).kind in {
-    tyRange, tyEnum, tyBool, tyInt..tyUInt64}
+    tyRange, tyEnum, tyBool, tyInt..tyUInt64, tyChar}
 
 proc requiresCopy(n: PNode): bool =
   if n.typ.skipTypes(abstractInst-{tyTypeDesc}).kind in atomicTypes:
@@ -1066,17 +1103,36 @@ proc checkCanEval(c: PCtx; n: PNode) =
         not s.isOwnedBy(c.prc.sym) and s.owner != c.module:
       cannotEval(n)
 
+proc isTemp(c: PCtx; dest: TDest): bool =
+  result = dest >= 0 and c.prc.slots[dest].kind >= slotTempUnknown
+
+template needsAdditionalCopy(n): expr =
+  not c.isTemp(dest) and not fitsRegister(n.typ)
+
+proc preventFalseAlias(c: PCtx; n: PNode; opc: TOpcode;
+                       dest, idx, value: TRegister) =
+  # opcLdObj et al really means "load address". We sometimes have to create a
+  # copy in order to not introduce false aliasing:
+  # mylocal = a.b  # needs a copy of the data!
+  if needsAdditionalCopy(n):
+    var cc = c.getTemp(n.typ)
+    c.gABC(n, whichAsgnOpc(n), cc, value)
+    c.gABC(n, opc, dest, idx, cc)
+    c.freeTemp(cc)
+  else:
+    c.gABC(n, opc, dest, idx, value)
+
 proc genAsgn(c: PCtx; le, ri: PNode; requiresCopy: bool) =
   case le.kind
   of nkBracketExpr:
     let dest = c.genx(le.sons[0], {gfAddrOf})
-    let idx = c.genx(le.sons[1])
+    let idx = c.genIndex(le.sons[1], le.sons[0].typ)
     let tmp = c.genx(ri)
     if le.sons[0].typ.skipTypes(abstractVarRange-{tyTypeDesc}).kind in {
         tyString, tyCString}:
-      c.gABC(le, opcWrStrIdx, dest, idx, tmp)
+      c.preventFalseAlias(le, opcWrStrIdx, dest, idx, tmp)
     else:
-      c.gABC(le, opcWrArr, dest, idx, tmp)
+      c.preventFalseAlias(le, opcWrArr, dest, idx, tmp)
     c.freeTemp(tmp)
   of nkDotExpr, nkCheckedFieldExpr:
     # XXX field checks here
@@ -1084,12 +1140,12 @@ proc genAsgn(c: PCtx; le, ri: PNode; requiresCopy: bool) =
     let dest = c.genx(left.sons[0], {gfAddrOf})
     let idx = genField(left.sons[1])
     let tmp = c.genx(ri)
-    c.gABC(left, opcWrObj, dest, idx, tmp)
+    c.preventFalseAlias(left, opcWrObj, dest, idx, tmp)
     c.freeTemp(tmp)
   of nkDerefExpr, nkHiddenDeref:
     let dest = c.genx(le.sons[0], {gfAddrOf})
     let tmp = c.genx(ri)
-    c.gABC(le, opcWrDeref, dest, tmp)
+    c.preventFalseAlias(le, opcWrDeref, dest, 0, tmp)
     c.freeTemp(tmp)
   of nkSym:
     let s = le.sym
@@ -1098,24 +1154,32 @@ proc genAsgn(c: PCtx; le, ri: PNode; requiresCopy: bool) =
       withTemp(tmp, le.typ):
         c.gen(le, tmp, {gfAddrOf})
         let val = c.genx(ri)
-        c.gABC(le, opcWrDeref, tmp, val)
+        c.preventFalseAlias(le, opcWrDeref, tmp, 0, val)
         c.freeTemp(val)
     else:
       if s.kind == skForVar: c.setSlot s
       internalAssert s.position > 0 or (s.position == 0 and
                                         s.kind in {skParam,skResult})
       var dest: TRegister = s.position + ord(s.kind == skParam)
-      gen(c, ri, dest)
+      if needsAdditionalCopy(le) and s.kind in {skResult, skVar, skParam}:
+        var cc = c.getTemp(le.typ)
+        gen(c, ri, cc)
+        c.gABC(le, whichAsgnOpc(le), dest, cc)
+        c.freeTemp(cc)
+      else:
+        gen(c, ri, dest)
   else:
     let dest = c.genx(le, {gfAddrOf})
     genAsgn(c, dest, ri, requiresCopy)
 
 proc genLit(c: PCtx; n: PNode; dest: var TDest) =
-  var opc = opcLdConst
+  # opcLdConst is now always valid. We produce the necessary copy in the
+  # assignments now:
+  #var opc = opcLdConst
   if dest < 0: dest = c.getTemp(n.typ)
-  elif c.prc.slots[dest].kind == slotFixedVar: opc = opcAsgnConst
+  #elif c.prc.slots[dest].kind == slotFixedVar: opc = opcAsgnConst
   let lit = genLiteral(c, n)
-  c.gABx(n, opc, dest, lit)
+  c.gABx(n, opcLdConst, dest, lit)
 
 proc genTypeLit(c: PCtx; t: PType; dest: var TDest) =
   var n = newNode(nkType)
@@ -1144,7 +1208,7 @@ proc genGlobalInit(c: PCtx; n: PNode; s: PSym) =
   let dest = c.getTemp(s.typ)
   c.gABx(n, opcLdGlobal, dest, s.position)
   let tmp = c.genx(s.ast)
-  c.gABC(n, opcWrDeref, dest, tmp)
+  c.preventFalseAlias(n, opcWrDeref, dest, 0, tmp)
   c.freeTemp(dest)
   c.freeTemp(tmp)
 
@@ -1180,17 +1244,22 @@ proc genRdVar(c: PCtx; n: PNode; dest: var TDest; flags: TGenFlags) =
       # see tests/t99bott for an example that triggers it:
       cannotEval(n)
 
+template needsRegLoad(): expr =
+  gfAddrOf notin flags and fitsRegister(n.typ.skipTypes({tyVar}))
+
 proc genArrAccess2(c: PCtx; n: PNode; dest: var TDest; opc: TOpcode;
                    flags: TGenFlags) =
   let a = c.genx(n.sons[0], flags)
-  let b = c.genx(n.sons[1], {})
+  let b = c.genIndex(n.sons[1], n.sons[0].typ)
   if dest < 0: dest = c.getTemp(n.typ)
-  if gfAddrOf notin flags and fitsRegister(n.typ):
+  if needsRegLoad():
     var cc = c.getTemp(n.typ)
     c.gABC(n, opc, cc, a, b)
     c.gABC(n, opcNodeToReg, dest, cc)
     c.freeTemp(cc)
   else:
+    #message(n.info, warnUser, "argh")
+    #echo "FLAGS ", flags, " ", fitsRegister(n.typ), " ", typeToString(n.typ)
     c.gABC(n, opc, dest, a, b)
   c.freeTemp(a)
   c.freeTemp(b)
@@ -1199,7 +1268,7 @@ proc genObjAccess(c: PCtx; n: PNode; dest: var TDest; flags: TGenFlags) =
   let a = c.genx(n.sons[0], flags)
   let b = genField(n.sons[1])
   if dest < 0: dest = c.getTemp(n.typ)
-  if gfAddrOf notin flags and fitsRegister(n.typ.skipTypes({tyVar})):
+  if needsRegLoad():
     var cc = c.getTemp(n.typ)
     c.gABC(n, opcLdObj, cc, a, b)
     c.gABC(n, opcNodeToReg, dest, cc)
@@ -1299,7 +1368,7 @@ proc genVarSection(c: PCtx; n: PNode) =
         if a.sons[2].kind != nkEmpty:
           let tmp = c.genx(a.sons[0], {gfAddrOf})
           let val = c.genx(a.sons[2])
-          c.gABC(a, opcWrDeref, tmp, val)
+          c.preventFalseAlias(a, opcWrDeref, tmp, 0, val)
           c.freeTemp(val)
           c.freeTemp(tmp)
       else:
@@ -1307,7 +1376,16 @@ proc genVarSection(c: PCtx; n: PNode) =
         if a.sons[2].kind == nkEmpty:
           c.gABx(a, ldNullOpcode(s.typ), s.position, c.genType(s.typ))
         else:
-          gen(c, a.sons[2], s.position.TRegister)
+          if not fitsRegister(s.typ):
+            c.gABx(a, ldNullOpcode(s.typ), s.position, c.genType(s.typ))
+          let le = a.sons[0]
+          if not fitsRegister(le.typ) and s.kind in {skResult, skVar, skParam}:
+            var cc = c.getTemp(le.typ)
+            gen(c, a.sons[2], cc)
+            c.gABC(le, whichAsgnOpc(le), s.position.TRegister, cc)
+            c.freeTemp(cc)
+          else:
+            gen(c, a.sons[2], s.position.TRegister)
     else:
       # assign to a.sons[0]; happens for closures
       if a.sons[2].kind == nkEmpty:
@@ -1335,7 +1413,7 @@ proc genArrayConstr(c: PCtx, n: PNode, dest: var TDest) =
     c.gABx(n, opcLdNullReg, tmp, c.genType(intType))
     for x in n:
       let a = c.genx(x)
-      c.gABC(n, whichAsgnOpc(x, opcWrArr), dest, tmp, a)
+      c.preventFalseAlias(n, whichAsgnOpc(x, opcWrArr), dest, tmp, a)
       c.gABI(n, opcAddImmInt, tmp, tmp, 1)
       c.freeTemp(a)
     c.freeTemp(tmp)
@@ -1367,7 +1445,8 @@ proc genObjConstr(c: PCtx, n: PNode, dest: var TDest) =
     if it.kind == nkExprColonExpr and it.sons[0].kind == nkSym:
       let idx = genField(it.sons[0])
       let tmp = c.genx(it.sons[1])
-      c.gABC(it, whichAsgnOpc(it.sons[1], opcWrObj), dest, idx, tmp)
+      c.preventFalseAlias(it.sons[1], whichAsgnOpc(it.sons[1], opcWrObj),
+                          dest, idx, tmp)
       c.freeTemp(tmp)
     else:
       internalError(n.info, "invalid object constructor")
@@ -1381,11 +1460,12 @@ proc genTupleConstr(c: PCtx, n: PNode, dest: var TDest) =
     if it.kind == nkExprColonExpr:
       let idx = genField(it.sons[0])
       let tmp = c.genx(it.sons[1])
-      c.gABC(it, whichAsgnOpc(it.sons[1], opcWrObj), dest, idx, tmp)
+      c.preventFalseAlias(it.sons[1], whichAsgnOpc(it.sons[1], opcWrObj),
+                          dest, idx, tmp)
       c.freeTemp(tmp)
     else:
       let tmp = c.genx(it)
-      c.gABC(it, whichAsgnOpc(it, opcWrObj), dest, i.TRegister, tmp)
+      c.preventFalseAlias(it, whichAsgnOpc(it, opcWrObj), dest, i.TRegister, tmp)
       c.freeTemp(tmp)
 
 proc genProc*(c: PCtx; s: PSym): int
@@ -1623,7 +1703,7 @@ proc genProc(c: PCtx; s: PSym): int =
     c.gABC(body, opcEof, eofInstr.regA)
     c.optimizeJumps(result)
     s.offset = c.prc.maxSlots
-    #if s.name.s == "parse_until_symbol":
+    #if s.name.s == "calc":
     #  echo renderTree(body)
     #  c.echoCode(result)
     c.prc = oldPrc
diff --git a/config/nimrod.cfg b/config/nimrod.cfg
index 2817eac55..df3835ace 100644
--- a/config/nimrod.cfg
+++ b/config/nimrod.cfg
@@ -16,6 +16,7 @@ arm.linux.gcc.linkerexe = "arm-linux-gcc"
 path="$lib/core"
 path="$lib/pure"
 path="$lib/pure/collections"
+path="$lib/pure/concurrency"
 path="$lib/impure"
 path="$lib/wrappers"
 # path="$lib/wrappers/cairo"
diff --git a/doc/advopt.txt b/doc/advopt.txt
index f5ff90791..08465e457 100644
--- a/doc/advopt.txt
+++ b/doc/advopt.txt
@@ -2,6 +2,7 @@ Advanced commands:
   //compileToC, cc          compile project with C code generator
   //compileToCpp, cpp       compile project to C++ code
   //compileToOC, objc       compile project to Objective C code
+  //js                      compile project to Javascript
   //rst2html                convert a reStructuredText file to HTML
   //rst2tex                 convert a reStructuredText file to TeX
   //jsondoc                 extract the documentation to a json file
diff --git a/doc/apis.txt b/doc/apis.txt
index d76bd721e..9906f6bbc 100644
--- a/doc/apis.txt
+++ b/doc/apis.txt
@@ -1,6 +1,6 @@
-==========
-API design
-==========
+=================
+API naming design
+=================
 
 The API is designed to be **easy to use** and consistent. Ease of use is
 measured by the number of calls to achieve a concrete high level action.
@@ -79,3 +79,10 @@ string                  str
 identifier              ident
 indentation             indent
 -------------------     ------------   --------------------------------------
+
+
+Coding Guidelines
+=================
+
+For coding guidelines see the `Internals of the Nimrod Compiler
+<intern.html#coding-guidelines>`_ documentation.
diff --git a/doc/backends.txt b/doc/backends.txt
new file mode 100644
index 000000000..26576e733
--- /dev/null
+++ b/doc/backends.txt
@@ -0,0 +1,409 @@
+================================
+   Nimrod Backend Integration
+================================
+
+:Author: Puppet Master
+:Version: |nimrodversion|
+
+.. contents::
+  "Heresy grows from idleness." -- Unknown.
+
+
+Introduction
+============
+
+The `Nimrod Compiler User Guide <nimrodc.html>`_ documents the typical
+compiler invocation, using the ``compile`` or ``c`` command to transform a
+``.nim`` file into one or more ``.c`` files which are then compiled with the
+platform's C compiler into a static binary. However there are other commands
+to compile to C++, Objective-C or JavaScript. This document tries to
+concentrate in a single place all the backend and interfacing options.
+
+The Nimrod compiler supports mainly two backend families: the C, C++ and
+Objective-C targets and the JavaScript target. `The C like targets`_ creates
+source files which can be compiled into a library or a final executable. `The
+JavaScript target`_ can generate a ``.js`` file which you reference from an
+HTML file or create a `standalone nodejs program <http://nodejs.org>`_.
+
+On top of generating libraries or standalone applications, Nimrod offers
+bidirectional interfacing with the backend targets through generic and
+specific pragmas.
+
+
+Backends
+========
+
+The C like targets
+------------------
+
+The commands to compile to either C, C++ or Objective-C are:
+
+  //compileToC, cc          compile project with C code generator
+  //compileToCpp, cpp       compile project to C++ code
+  //compileToOC, objc       compile project to Objective C code
+
+The most significant difference between these commands is that if you look
+into the ``nimcache`` directory you will find ``.c``, ``.cpp`` or ``.m``
+files, other than that all of them will produce a native binary for your
+project.  This allows you to take the generated code and place it directly
+into a project using any of these languages. Here are some typical command
+line invocations::
+
+    $ nimrod c hallo.nim
+    $ nimrod cpp hallo.nim
+    $ nimrod objc hallo.nim
+
+The compiler commands select the target backend, but if needed you can
+`specify additional switches for cross compilation
+<nimrodc.html#cross-compilation>`_ to select the target CPU, operative system
+or compiler/linker commands.
+
+
+The JavaScript target
+---------------------
+
+Nimrod can also generate `JavaScript`:idx: code through the ``js`` command.
+However, the JavaScript code generator is experimental!
+
+Nimrod targets JavaScript 1.5 which is supported by any widely used browser.
+Since JavaScript does not have a portable means to include another module,
+Nimrod just generates a long ``.js`` file.
+
+Features or modules that the JavaScript platform does not support are not
+available. This includes:
+
+* manual memory management (``alloc``, etc.)
+* casting and other unsafe operations (``cast`` operator, ``zeroMem``, etc.)
+* file management
+* most modules of the Standard library
+* proper 64 bit integer arithmetic
+* unsigned integer arithmetic
+
+However, the modules `strutils <strutils.html>`_, `math <math.html>`_, and
+`times <times.html>`_ are available! To access the DOM, use the `dom
+<dom.html>`_ module that is only available for the JavaScript platform.
+
+To compile a Nimrod module into a ``.js`` file use the ``js`` command; the
+default is a ``.js`` file that is supposed to be referenced in an ``.html``
+file. However, you can also run the code with `nodejs`:idx:, a `software
+platform for easily building fast, scalable network applications
+<http://nodejs.org>`_::
+
+  nimrod js -d:nodejs -r examples/hallo.nim
+
+
+Interfacing
+===========
+
+Nimrod offers bidirectional interfacing with the target backend. This means
+that you can call backend code from Nimrod and Nimrod code can be called by
+the backend code. Usually the direction of which calls which depends on your
+software architecture (is Nimrod your main program or is Nimrod providing a
+component?).
+
+
+Nimrod code calling the backend
+--------------------------------
+
+Nimrod code can interface with the backend through the `Foreign function
+interface <manual.html#foreign-function-interface>`_ mainly through the
+`importc pragma <manual.html#importc-pragma>`_. The ``importc`` pragma is the
+*generic* way of making backend symbols available in Nimrod and is available
+in all the target backends (JavaScript too).  The C++ or Objective-C backends
+have their respective `ImportCpp <nimrodc.html#importcpp-pragma>`_ and
+`ImportObjC <nimrodc.html#importobjc-pragma>`_ pragmas to call methods from
+classes.
+
+Whenever you use any of these pragmas you need to integrate native code into
+your final binary. In the case of JavaScript this is no problem at all, the
+same html file which hosts the generated JavaScript will likely provide other
+JavaScript functions which you are importing with ``importc``.
+
+However, for the C like targets you need to link external code either
+statically or dynamically. The preferred way of integrating native code is to
+use dynamic linking because it allows you to compile Nimrod programs without
+the need for having the related development libraries installed. This is done
+through the `dynlib pragma for import
+<manual.html#dynlib-pragma-for-import>`_, though more specific control can be
+gained using the `dynlib module <dynlib.html>`_.
+
+The `dynlibOverride <nimrodc.html#dynliboverride>`_ command line switch allows
+to avoid dynamic linking if you need to statically link something instead.
+Nimrod wrappers designed to statically link source files can use the `compile
+pragma <nimrodc.html#compile-pragma>`_ if there are few sources or providing
+them along the Nimrod code is easier than using a system library. Libraries
+installed on the host system can be linked in with the `PassL pragma
+<nimrodc.html#passl-pragma>`_.
+
+To wrap native code, take a look at the `c2nim tool <c2nim.html>`_ which helps
+with the process of scanning and transforming header files into a Nimrod
+interface.
+
+C invocation example
+~~~~~~~~~~~~~~~~~~~~
+
+Create a ``logic.c`` file with the following content:
+
+.. code-block:: c
+  int addTwoIntegers(int a, int b)
+  {
+    return a + b;
+  }
+
+Create a ``calculator.nim`` file with the following content:
+
+.. code-block:: nimrod
+
+  {.compile: "logic.c".}
+  proc addTwoIntegers(a, b: cint): cint {.importc.}
+
+  when isMainModule:
+    echo addTwoIntegers(3, 7)
+
+With these two files in place, you can run ``nimrod c -r calculator.nim`` and
+the Nimrod compiler will compile the ``logic.c`` file in addition to
+``calculator.nim`` and link both into an executable, which outputs ``10`` when
+run. Another way to link the C file statically and get the same effect would
+be remove the line with the ``compile`` pragma and run the following typical
+Unix commands::
+
+    $ gcc -c logic.c
+    $ ar rvs mylib.a logic.o
+    $ nimrod c --passL:mylib.a -r calculator.nim
+
+Just like in this example we pass the path to the ``mylib.a`` library (and we
+could as well pass ``logic.o``) we could be passing switches to link any other
+static C library.
+
+
+JavaScript invocation example
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Create a ``host.html`` file with the following content:
+
+.. code-block::
+
+  <html><body>
+  <script type="text/javascript">
+  function addTwoIntegers(a, b)
+  {
+    return a + b;
+  }
+  </script>
+  <script type="text/javascript" src="calculator.js"></script>
+  </body></html>
+
+Create a ``calculator.nim`` file with the following content (or reuse the one
+from the previous section):
+
+.. code-block:: nimrod
+
+  proc addTwoIntegers(a, b: int): int {.importc.}
+
+  when isMainModule:
+    echo addTwoIntegers(3, 7)
+
+Compile the Nimrod code to JavaScript with ``nimrod js -o:calculator.js
+calculator.nim`` and open ``host.html`` in a browser. If the browser supports
+javascript, you should see the value ``10``. In JavaScript the `echo proc
+<system.html#echo>`_ will modify the HTML DOM and append the string. Use the
+`dom module <dom.html>`_ for specific DOM querying and modification procs.
+
+
+Backend code calling Nimrod
+---------------------------
+
+Backend code can interface with Nimrod code exposed through the `exportc
+pragma <manual.html#exportc-pragma>`_. The ``exportc`` pragma is the *generic*
+way of making Nimrod symbols available to the backends. By default the Nimrod
+compiler will mangle all the Nimrod symbols to avoid any name collision, so
+the most significant thing the ``exportc`` pragma does is maintain the Nimrod
+symbol name, or if specified, use an alternative symbol for the backend in
+case the symbol rules don't match.
+
+The JavaScript target doesn't have any further interfacing considerations
+since it also has garbage collection, but the C targets require you to
+initialize Nimrod's internals, which is done calling a ``NimMain`` function.
+Also, C code requires you to specify a forward declaration for functions or
+the compiler will asume certain types for the return value and parameters
+which will likely make your program crash at runtime.
+
+The Nimrod compiler can generate a C interface header through the ``--header``
+command line switch. The generated header will contain all the exported
+symbols and the ``NimMain`` proc which you need to call before any other
+Nimrod code.
+
+
+Nimrod invocation example from C
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Create a ``fib.nim`` file with the following content:
+
+.. code-block:: nimrod
+
+  proc fib(a: cint): cint {.exportc.} =
+    if a <= 2:
+      result = 1
+    else:
+      result = fib(a - 1) + fib(a - 2)
+
+Create a ``maths.c`` file with the following content:
+
+.. code-block:: c
+
+  #include "fib.h"
+  #include <stdio.h>
+
+  int main(void)
+  {
+    NimMain();
+    for (int f = 0; f < 10; f++)
+      printf("Fib of %d is %d\n", f, fib(f));
+    return 0;
+  }
+
+Now you can run the following Unix like commands to first generate C sources
+form the Nimrod code, then link them into a static binary along your main C
+program::
+
+  $ nimrod c --noMain --noLinking --header:fib.h fib.nim
+  $ gcc -o m -Inimcache -Ipath/to/nimrod/lib nimcache/*.c maths.c
+
+The first command runs the Nimrod compiler with three special options to avoid
+generating a ``main()`` function in the generated files, avoid linking the
+object files into a final binary, and explicitly generate a header file for C
+integration. All the generated files are placed into the ``nimcache``
+directory. That's why the next command compiles the ``maths.c`` source plus
+all the ``.c`` files form ``nimcache``. In addition to this path, you also
+have to tell the C compiler where to find Nimrod's ``nimbase.h`` header file.
+
+Instead of depending on the generation of the individual ``.c`` files you can
+also ask the Nimrod compiler to generate a statically linked library::
+
+  $ nimrod c --app:staticLib --noMain --header fib.nim
+  $ gcc -o m -Inimcache -Ipath/to/nimrod/lib libfib.nim.a maths.c
+
+The Nimrod compiler will handle linking the source files generated in the
+``nimcache`` directory into the ``libfib.nim.a`` static library, which you can
+then link into your C program.  Note that these commands are generic and will
+vary for each system. For instance, on Linux systems you will likely need to
+use ``-ldl`` too to link in required dlopen functionality.
+
+
+Nimrod invocation example from JavaScript
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Create a ``mhost.html`` file with the following content:
+
+.. code-block::
+
+  <html><body>
+  <script type="text/javascript" src="fib.js"></script>
+  <script type="text/javascript">
+  alert("Fib for 9 is " + fib(9));
+  </script>
+  </body></html>
+
+Create a ``fib.nim`` file with the following content (or reuse the one
+from the previous section):
+
+.. code-block:: nimrod
+
+  proc fib(a: cint): cint {.exportc.} =
+    if a <= 2:
+      result = 1
+    else:
+      result = fib(a - 1) + fib(a - 2)
+
+Compile the Nimrod code to JavaScript with ``nimrod js -o:fib.js fib.nim`` and
+open ``mhost.html`` in a browser. If the browser supports javascript, you
+should see an alert box displaying the text ``Fib for 9 is 34``. As mentioned
+earlier, JavaScript doesn't require an initialisation call to ``NimMain`` or
+similar function and you can call the exported Nimrod proc directly.
+
+
+Memory management
+=================
+
+In the previous sections the ``NimMain()`` function reared its head. Since
+JavaScript already provides automatic memory management, you can freely pass
+objects between the two language without problems. In C and derivate languages
+you need to be careful about what you do and how you share memory. The
+previous examples only dealt with simple scalar values, but passing a Nimrod
+string to C, or reading back a C string in Nimrod already requires you to be
+aware of who controls what to avoid crashing.
+
+
+Strings and C strings
+---------------------
+
+The manual mentions that `Nimrod strings are implicitly convertible to
+cstrings <manual.html#cstring-type>`_ which makes interaction usually
+painless. Most C functions accepting a Nimrod string converted to a
+``cstring`` will likely not need to keep this string around and by the time
+they return the string won't be needed any more. However, for the rare cases
+where a Nimrod string has to be preserved and made available to the C backend
+as a ``cstring``, you will need to manually prevent the string data from being
+freed with `GC_ref <system.html#GC_ref>`_ and `GC_unref
+<system.html#GC_unref>`_.
+
+A similar thing happens with C code invoking Nimrod code which returns a
+``cstring``. Consider the following proc:
+
+.. code-block:: nimrod
+
+  proc gimme(): cstring {.exportc.} =
+    result = "Hey there C code! " & $random(100)
+
+Since Nimrod's garbage collector is not aware of the C code, once the
+``gimme`` proc has finished it can reclaim the memory of the ``cstring``.
+However, from a practical standpoint, the C code invoking the ``gimme``
+function directly will be able to use it since Nimrod's garbage collector has
+not had a chance to run *yet*. This gives you enough time to make a copy for
+the C side of the program, as calling any further Nimrod procs *might* trigger
+garbage collection making the previously returned string garbage. Or maybe you
+are `triggering yourself the collection <gc.html>`_.
+
+
+Custom data types
+-----------------
+
+Just like strings, custom data types that are to be shared between Nimrod and
+the backend will need careful consideration of who controlls who. If you want
+to hand a Nimrod reference to C code, you will need to use `GC_ref
+<system.html#GC_ref>`_ to mark the reference as used, so it does not get
+freed. And for the C backend you will need to expose the `GC_unref
+<system.html#GC_unref>`_ proc to clean up this memory when it is not required
+any more.
+
+Again, if you are wrapping a library which *mallocs* and *frees* data
+structures, you need to expose the appropriate *free* function to Nimrod so
+you can clean it up. And of course, once cleaned you should avoid accessing it
+from Nimrod (or C for that matter). Typically C data structures have their own
+``malloc_structure`` and ``free_structure`` specific functions, so wrapping
+these for the Nimrod side should be enough.
+
+
+Thread coordination
+-------------------
+
+When the ``NimMain()`` function is called Nimrod initializes the garbage
+collector to the current thread, which is usually the main thread of your
+application. If your C code later spawns a different thread and calls Nimrod
+code, the garbage collector will fail to work properly and you will crash.
+
+As long as you don't use the threadvar emulation Nimrod uses native thread
+variables, of which you get a fresh version whenever you create a thread. You
+can then attach a GC to this thread via
+
+.. code-block:: nimrod
+
+  setStackBottom(addr(someLocal))
+  initGC()
+
+At the moment this support is still experimental so you need to expose these
+functions yourself or submit patches to request a public API. 
+
+It is **not** safe to disable the garbage collector and enable it after the
+call from your background thread even if the code you are calling is short
+lived.
diff --git a/doc/c2nim.txt b/doc/c2nim.txt
deleted file mode 100644
index 6788ef569..000000000
--- a/doc/c2nim.txt
+++ /dev/null
@@ -1,295 +0,0 @@
-=================================
-  c2nim  User's manual
-=================================
-
-:Author: Andreas Rumpf
-:Version: |nimrodversion|
-
-.. contents::
-
-Introduction
-============
-
-  "We all make choices. But in the end our choices make us."
-
-
-c2nim is a tool to translate Ansi C code to Nimrod. The output is 
-human-readable Nimrod code that is meant to be tweaked by hand after the 
-translation process. c2nim is no real compiler!
-
-c2nim is preliminary meant to translate C header files. Because of this, the 
-preprocessor is part of the parser. For example:
-
-.. code-block:: C
-  #define abc 123
-  #define xyz 789
-  
-Is translated into:
-
-.. code-block:: Nimrod
-  const
-    abc* = 123
-    xyz* = 789
-    
-
-c2nim is meant to translate fragments of C code and thus does not follow 
-include files. c2nim cannot parse all of Ansi C and many constructs cannot
-be represented in Nimrod: for example `duff's device`:idx: cannot be translated
-to Nimrod. 
-
-
-Preprocessor support
-====================
-
-Even though the translation process is not perfect, it is often the case that
-the translated Nimrod code does not need any tweaking by hand. In other cases
-it may be preferable to modify the input file instead of the generated Nimrod
-code so that c2nim can parse it properly. c2nim's preprocessor defines the 
-symbol ``C2NIM`` that can be used to mark code sections: 
-
-.. code-block:: C
-  #ifndef C2NIM
-    // C2NIM should ignore this prototype:
-    int fprintf(FILE* f, const char* frmt, ...);
-  #endif
-  
-The ``C2NIM`` symbol is only recognized in ``#ifdef`` and ``#ifndef`` 
-constructs! ``#if defined(C2NIM)`` does **not** work. 
-
-c2nim *processes* ``#ifdef C2NIM`` and ``#ifndef C2NIM`` directives, but other
-``#if[def]`` directives are *translated* into Nimrod's ``when`` construct: 
-
-.. code-block:: C
-  #ifdef DEBUG
-  #  define OUT(x) printf("%s\n", x)
-  #else
-  #  define OUT(x)
-  #endif
-  
-Is translated into:
-
-.. code-block:: Nimrod
-  when defined(debug):
-    template OUT*(x: expr): expr = 
-      printf("%s\x0A", x)
-  else:
-    template OUT*(x: expr): stmt = 
-      discard
-  
-As can been seen from the example, C's macros with parameters are mapped
-to Nimrod's templates. This mapping is the best one can do, but it is of course
-not accurate: Nimrod's templates operate on syntax trees whereas C's 
-macros work on the token level. c2nim cannot translate any macro that contains
-the ``##`` token concatenation operator.
-
-c2nim's preprocessor supports special directives that affect how the output
-is generated. They should be put into a ``#ifdef C2NIM`` section so that 
-ordinary C compilers ignore them.
-
-
-``#skipinclude`` directive
---------------------------
-**Note**: There is also a ``--skipinclude`` command line option that can be 
-used for the same purpose.
-
-By default, c2nim translates an ``#include`` that is not followed by ``<`` 
-(like in ``#include <stdlib>``) to a Nimrod ``import`` statement. This 
-directive tells c2nim to just skip any ``#include``. 
-
-
-``#stdcall`` and ``#cdecl`` directives
---------------------------------------
-**Note**: There are also ``--stdcall`` and ``--cdecl`` command line options
-that can be used for the same purpose.
-
-These directives tell c2nim that it should annotate every proc (or proc type)
-with the ``stdcall`` / ``cdecl`` calling convention.
-
-
-``#dynlib`` directive
----------------------
-**Note**: There is also a ``--dynlib`` command line option that can be used for
-the same purpose.
-
-This directive tells c2nim that it should annotate every proc that resulted
-from a C function prototype with the ``dynlib`` pragma:
- 
-.. code-block:: C
-  
-  #ifdef C2NIM
-  #  dynlib iupdll
-  #  cdecl
-  #  if defined(windows)
-  #    define iupdll "iup.dll"
-  #  elif defined(macosx)
-  #    define iupdll "libiup.dylib"
-  #  else
-  #    define iupdll "libiup.so"
-  #  endif
-  #endif
-  
-  int IupConvertXYToPos(PIhandle ih, int x, int y);
-
-Is translated to:
-  
-.. code-block:: Nimrod
-  when defined(windows):
-    const iupdll* = "iup.dll"
-  elif defined(macosx):
-    const iupdll* = "libiup.dylib"
-  else:
-    const iupdll* = "libiup.so"
-  
-  proc IupConvertXYToPos*(ih: PIhandle, x: cint, y: cint): cint {.
-    importc: "IupConvertXYToPos", cdecl, dynlib: iupdll.}
-
-Note how the example contains extra C code to declare the ``iupdll`` symbol
-in the generated Nimrod code.
-
-
-``#header`` directive
----------------------
-**Note**: There is also a ``--header`` command line option that can be used for
-the same purpose.
-
-The ``#header`` directive tells c2nim that it should annotate every proc that
-resulted from a C function prototype and every exported variable and type with
-the ``header`` pragma:
-
-.. code-block:: C
-  
-  #ifdef C2NIM
-  #  header "iup.h"
-  #endif
-  
-  int IupConvertXYToPos(PIhandle ih, int x, int y);
-
-Is translated to:
-  
-.. code-block:: Nimrod
-  proc IupConvertXYToPos*(ih: PIhandle, x: cint, y: cint): cint {.
-    importc: "IupConvertXYToPos", header: "iup.h".}
-
-The ``#header`` and the ``#dynlib`` directives are mutually exclusive. 
-A binding that uses ``dynlib`` is much more preferable over one that uses
-``header``! The Nimrod compiler might drop support for the ``header`` pragma
-in the future as it cannot work for backends that do not generate C code.
-
-
-``#prefix`` and ``#suffix`` directives
---------------------------------------
-
-**Note**: There are also ``--prefix`` and ``--suffix`` command line options
-that can be used for the same purpose.
-
-c2nim does not do any name mangling by default. However the 
-``#prefix`` and ``#suffix`` directives can be used to strip prefixes and
-suffixes from the identifiers in the C code: 
- 
-.. code-block:: C
-  
-  #ifdef C2NIM
-  #  prefix Iup
-  #  dynlib dllname
-  #  cdecl
-  #endif
-  
-  int IupConvertXYToPos(PIhandle ih, int x, int y);
-
-Is translated to:
-  
-.. code-block:: Nimrod
-
-  proc ConvertXYToPos*(ih: PIhandle, x: cint, y: cint): cint {.
-    importc: "IupConvertXYToPos", cdecl, dynlib: dllname.}
-
-
-``#mangle`` directive
----------------------
-
-Even more sophisticated name mangling can be achieved by the ``#mangle`` 
-directive: It takes a PEG pattern and format string that specify how the
-identifier should be converted: 
-
-.. code-block:: C
-  #mangle "'GTK_'{.*}" "TGtk$1"
-
-For convenience the PEG pattern and the replacement can be single identifiers
-too, there is no need to quote them: 
-
-.. code-block:: C
-  #mangle ssize_t  int
-  // is short for:
-  #mangle "'ssize_t'" "int"
-
-
-``#private`` directive
-----------------------
-
-By default c2nim marks every top level identifier (proc name, variable, etc.)
-as exported (the export marker is ``*`` in Nimrod). With the ``#private`` 
-directive identifiers can be marked as private so that the resulting Nimrod
-module does not export them. The ``#private`` directive takes a PEG pattern:
-
-.. code-block:: C
-  #private "@('_'!.)" // all identifiers ending in '_' are private
-  
-Note: The pattern refers to the original C identifiers, not to the resulting
-identifiers after mangling!
-
-
-``#skipcomments`` directive
----------------------------
-**Note**: There is also a ``--skipcomments`` command line option that can be
-used for the same purpose.
-
-The ``#skipcomments`` directive can be put into the C code to make c2nim
-ignore comments and not copy them into the generated Nimrod file.
-
-
-``#typeprefixes`` directive
----------------------------
-**Note**: There is also a ``--typeprefixes`` command line option that can be
-used for the same purpose.
-
-The ``#typeprefixes`` directive can be put into the C code to make c2nim
-generate the ``T`` or ``P`` prefix for every defined type.
-
-
-``#def`` directive
-------------------
-
-Often C code contains special macros that affect the declaration of a function
-prototype but confuse c2nim's parser:
-
-.. code-block:: C
-  // does not parse!
-  EXTERN(int) f(void);
-  EXTERN(int) g(void);
-
-Instead of removing ``EXTERN()`` from the input source file (which cannot be 
-done reliably even with a regular expression!), one can tell c2nim
-that ``EXPORT`` is a macro that should be expanded by c2nim too:
-
-.. code-block:: C
-  #ifdef C2NIM
-  #  def EXTERN(x) static x
-  #endif
-  // parses now!
-  EXTERN(int) f(void);
-  EXTERN(int) g(void);
-  
-``#def`` is very similar to C's ``#define``, so in general the macro definition
-can be copied and pasted into a ``#def`` directive.
-
-
-Limitations
-===========
-
-* C's ``,`` operator (comma operator) is not supported.
-* C's ``union`` are translated to Nimrod's objects and only the first field
-  is included in the object type. This way there is a high chance that it is
-  binary compatible to the union.
-* The condition in a ``do while(condition)`` statement must be ``0``.
-* Lots of other small issues...
-
diff --git a/doc/docgen.txt b/doc/docgen.txt
index 520d5e8a0..30d0c6ff2 100644
--- a/doc/docgen.txt
+++ b/doc/docgen.txt
@@ -164,20 +164,10 @@ Index switch
   nimrod doc2 --index:on filename.nim
 
 This will generate an index of all the exported symbols in the input Nimrod
-module, and put it into a neighboring file with the extension of `.idx`. The
-index file is line oriented (newlines have to be escaped). Each line represents
-a tab separated record of several columns, the first two mandatory, the rest
-optional:
-
-1. Mandatory term being indexed. Terms can include quoting according to
-   Nimrod's rules (eg. ```^```)
-2. Base filename plus anchor hyper link (eg.
-   ``algorithm.html#*,int,TSortOrder``).
-3. Optional human readable string to display as hyper link. If the value is not
-   present or is the empty string, the hyper link will be rendered using the
-   term.
-4. Optional title or description of the hyper link. Browsers usually display
-   this as a tooltip after hovering a moment over the hyper link.
+module, and put it into a neighboring file with the extension of ``.idx``. The
+index file is line oriented (newlines have to be escaped). Each line
+represents a tab separated record of several columns, the first two mandatory,
+the rest optional. See the `Index (idx) file format`_ section for details.
 
 Once index files have been generated for one or more modules, the Nimrod
 compiler command ``buildIndex directory`` can be run to go over all the index
@@ -295,6 +285,60 @@ symbols in the `system module <system.html>`_.
   <system.html#newException.t,typedesc,string>`_
 
 
+Index (idx) file format
+=======================
+
+Files with the ``.idx`` extension are generated when you use the `Index
+switch`_ along with commands to generate documentation from source or text
+files. You can programatically generate indices with the `setIndexTerm()
+<rstgen.html#setIndexTerm>`_ and `writeIndexFile()
+<rstgen.html#writeIndexFile>`_ procs. The purpose of ``idx`` files is to hold
+the interesting symbols and their HTML references so they can be later
+concatenated into a big index file with `mergeIndexes()
+<rstgen.html#mergeIndexes>`_.  This section documents the file format in
+detail.
+
+Index files are line oriented and tab separated (newline and tab characters
+have to be escaped). Each line represents a record with at least two fields,
+but can have up to four (additional columns are ignored). The content of these
+columns is:
+
+1. Mandatory term being indexed. Terms can include quoting according to
+   Nimrod's rules (eg. \`^\` like in `the actors module
+   <actors.html#^,ptr.TChannel[T]>`_).
+2. Base filename plus anchor hyper link (eg.
+   ``algorithm.html#*,int,TSortOrder``).
+3. Optional human readable string to display as hyper link. If the value is not
+   present or is the empty string, the hyper link will be rendered
+   using the term. Prefix whitespace indicates that this entry is
+   not for an API symbol but for a TOC entry.
+4. Optional title or description of the hyper link. Browsers usually display
+   this as a tooltip after hovering a moment over the hyper link.
+
+The index generation tools try to differentiate between documentation
+generated from ``.nim`` files and documentation generated from ``.txt`` or
+``.rst`` files. The former are always closely related to source code and
+consist mainly of API entries. The latter are generic documents meant for
+human reading.
+
+To differentiate both types (documents and APIs), the index generator will add
+to the index of documents an entry with the title of the document. Since the
+title is the topmost element, it will be added with a second field containing
+just the filename without any HTML anchor.  By convention this entry without
+anchor is the *title entry*, and since entries in the index file are added as
+they are scanned, the title entry will be the first line. The title for APIs
+is not present because it can be generated concatenating the name of the file
+to the word **Module**.
+
+Normal symbols are added to the index with surrounding whitespaces removed. An
+exception to this are table of content (TOC) entries. TOC entries are added to
+the index file with their third column having as much prefix spaces as their
+level is in the TOC (at least 1 character). The prefix whitespace helps to
+filter TOC entries from API or text symbols. This is important because the
+amount of spaces is used to replicate the hiearchy for document TOCs in the
+final index, and TOC entries found in ``.nim`` files are discarded.
+
+
 Additional resources
 ====================
 
diff --git a/doc/endb.txt b/doc/endb.txt
index d4437e5d9..e9a01b583 100644
--- a/doc/endb.txt
+++ b/doc/endb.txt
@@ -1,6 +1,6 @@
-===========================================

-  Embedded Nimrod Debugger User Guide

-===========================================

+==============================================

+  Embedded Nimrod Debugger (ENDB) User Guide

+==============================================

 

 :Author: Andreas Rumpf

 :Version: |nimrodversion|

@@ -9,7 +9,7 @@
 

 

 Nimrod comes with a platform independent debugger -

-the `Embedded Nimrod Debugger`:idx: (`ENDB`:idx:). The debugger is

+the Embedded Nimrod Debugger (ENDB). The debugger is

 *embedded* into your executable if it has been

 compiled with the ``--debugger:on`` command line option.

 This also defines the conditional symbol ``ENDB`` for you.

@@ -102,7 +102,7 @@ necessary: A special pragma has been defined for this:
 The ``breakpoint`` pragma

 -------------------------

 

-The `breakpoint`:idx: pragma is syntactically a statement. It can be used

+The ``breakpoint`` pragma is syntactically a statement. It can be used

 to mark the *following line* as a breakpoint:

 

 .. code-block:: Nimrod

@@ -122,7 +122,7 @@ debugging.
 The ``watchpoint`` pragma

 -------------------------

 

-The `watchpoint`:idx: pragma is syntactically a statement. It can be used

+The ``watchpoint`` pragma is syntactically a statement. It can be used

 to mark a location as a watchpoint:

 

 .. code-block:: Nimrod

diff --git a/doc/estp.txt b/doc/estp.txt
index 353e4576f..704bc33f2 100644
--- a/doc/estp.txt
+++ b/doc/estp.txt
@@ -1,13 +1,13 @@
-============================================

-  Embedded Stack Trace Profiler User Guide

-============================================

+===================================================

+  Embedded Stack Trace Profiler (ESTP) User Guide

+===================================================

 

 :Author: Andreas Rumpf

 :Version: |nimrodversion|

 

 

 Nimrod comes with a platform independent profiler -

-the `Embedded Stack Trace Profiler`:idx: (`ESTP`:idx:). The profiler 
+the Embedded Stack Trace Profiler (ESTP). The profiler 
 is *embedded* into your executable. To activate the profiler you need to do: 
 
 * compile your program with the ``--profiler:on --stackTrace:on`` command 
diff --git a/doc/filters.txt b/doc/filters.txt
index 683599a03..961a0ea49 100644
--- a/doc/filters.txt
+++ b/doc/filters.txt
@@ -26,7 +26,7 @@ available parameters depend on the invoked filter.
 Pipe operator
 =============
 
-Filters can be combined with the ``|`` `pipe operator`:idx:\ ::
+Filters can be combined with the ``|`` pipe operator::
 
   #! strip(startswith="<") | stdtmpl
   #proc generateXML(name, age: string): string =
@@ -46,7 +46,7 @@ after each filter application.
 Replace filter
 --------------
 
-The `replace`:idx: filter replaces substrings in each line.
+The replace filter replaces substrings in each line.
 
 Parameters and their defaults:
 
@@ -60,7 +60,7 @@ Parameters and their defaults:
 Strip filter
 ------------
 
-The `strip`:idx: filter simply removes leading and trailing whitespace from
+The strip filter simply removes leading and trailing whitespace from
 each line.
 
 Parameters and their defaults:
@@ -79,7 +79,7 @@ Parameters and their defaults:
 StdTmpl filter
 --------------
 
-The `stdtmpl`:idx: filter provides a simple templating engine for Nimrod. The
+The stdtmpl filter provides a simple templating engine for Nimrod. The
 filter uses a line based parser: Lines prefixed with a *meta character*
 (default: ``#``) contain Nimrod code, other lines are verbatim. Because
 indentation-based parsing is not suited for a templating engine, control flow
diff --git a/doc/grammar.txt b/doc/grammar.txt
index 63e898e11..a54428678 100644
--- a/doc/grammar.txt
+++ b/doc/grammar.txt
@@ -24,7 +24,7 @@ ampExpr = plusExpr (OP6 optInd plusExpr)*
 plusExpr = mulExpr (OP7 optInd mulExpr)*
 mulExpr = dollarExpr (OP8 optInd dollarExpr)*
 dollarExpr = primary (OP9 optInd primary)*
-symbol = '`' (KEYW|IDENT|operator|'(' ')'|'[' ']'|'{' '}'|'='|literal)+ '`'
+symbol = '`' (KEYW|IDENT|literal|(operator|'('|')'|'['|']'|'{'|'}'|'=')+)+ '`'
        | IDENT
 indexExpr = expr
 indexExprList = indexExpr ^+ comma
@@ -82,10 +82,11 @@ paramListColon = paramList? (':' optInd typeDesc)?
 doBlock = 'do' paramListArrow pragmas? colcom stmt
 doBlocks = doBlock ^* IND{=}
 procExpr = 'proc' paramListColon pragmas? ('=' COMMENT? stmt)?
+distinct = 'distinct' optInd typeDesc
 expr = (ifExpr
       | whenExpr
       | caseExpr
-      | tryStmt)
+      | tryExpr)
       / simpleExpr
 typeKeyw = 'var' | 'ref' | 'ptr' | 'shared' | 'type' | 'tuple'
          | 'proc' | 'iterator' | 'distinct' | 'object' | 'enum'
@@ -134,6 +135,9 @@ caseStmt = 'case' expr ':'? COMMENT?
 tryStmt = 'try' colcom stmt &(IND{=}? 'except'|'finally')
            (IND{=}? 'except' exprList colcom stmt)*
            (IND{=}? 'finally' colcom stmt)?
+tryExpr = 'try' colcom stmt &(optInd 'except'|'finally')
+           (optInd 'except' exprList colcom stmt)*
+           (optInd 'finally' colcom stmt)?
 exceptBlock = 'except' colcom stmt
 forStmt = 'for' (identWithPragma ^+ comma) 'in' expr colcom stmt
 blockStmt = 'block' symbol? colcom stmt
@@ -166,7 +170,6 @@ object = 'object' pragma? ('of' typeDesc)? COMMENT? objectPart
 typeClassParam = ('var')? symbol
 typeClass = typeClassParam ^* ',' (pragma)? ('of' typeDesc ^* ',')?
               &IND{>} stmt
-distinct = 'distinct' optInd typeDesc
 typeDef = identWithPragma genericParamList? '=' optInd typeDefAux
             indAndComment?
 varTuple = '(' optInd identWithPragma ^+ comma optPar ')' '=' optInd expr
diff --git a/doc/idetools.txt b/doc/idetools.txt
index 0c554a80b..97e110b1d 100644
--- a/doc/idetools.txt
+++ b/doc/idetools.txt
@@ -16,7 +16,7 @@
 Nimrod differs from many other compilers in that it is really fast,
 and being so fast makes it suited to provide external queries for
 text editors about the source code being written. Through the
-`idetools`:idx: command of `the compiler <nimrodc.html>`_, any IDE
+``idetools`` command of `the compiler <nimrodc.html>`_, any IDE
 can query a ``.nim`` source file and obtain useful information like
 definition of symbols or suggestions for completion.
 
@@ -169,7 +169,7 @@ clicks it and after a second or two the IDE displays where that
 symbol is defined. Such latencies would be terrible for features
 like symbol suggestion, plus why wait at all if we can avoid it?
 
-The idetools command can be run as a compiler service (`caas`:idx:),
+The idetools command can be run as a compiler service (CAAS),
 where you first launch the compiler and it will stay online as a
 server, accepting queries in a telnet like fashion. The advantage
 of staying on is that for many queries the compiler can cache the
diff --git a/doc/intern.txt b/doc/intern.txt
index c602e4933..1dcf27774 100644
--- a/doc/intern.txt
+++ b/doc/intern.txt
@@ -59,6 +59,8 @@ And for a debug version compatible with GDB::
 
 The ``koch`` program is Nimrod's maintenance script. It is a replacement for
 make and shell scripting with the advantage that it is much more portable.
+More information about its options can be found in the `koch <koch.html>`_
+documentation.
 
 
 Coding Guidelines
@@ -69,8 +71,10 @@ Coding Guidelines
 * Max line length is 80 characters.
 * Provide spaces around binary operators if that enhances readability.
 * Use a space after a colon, but not before it.
-* Start types with a capital ``T``, unless they are pointers/references which start
-  with ``P``. 
+* Start types with a capital ``T``, unless they are pointers/references which
+  start with ``P``.
+
+See also the `API naming design <apis.html>`_ document.
 
 
 Porting to new platforms
@@ -156,7 +160,7 @@ generator.
 Compilation cache
 =================
 
-The implementation of the `compilation cache`:idx: is tricky: There are lots
+The implementation of the compilation cache is tricky: There are lots
 of issues to be solved for the front- and backend. In the following 
 sections *global* means *shared between modules* or *property of the whole
 program*.
diff --git a/doc/koch.txt b/doc/koch.txt
new file mode 100644
index 000000000..032151808
--- /dev/null
+++ b/doc/koch.txt
@@ -0,0 +1,144 @@
+===============================
+   Nimrod maintenance script
+===============================
+
+:Version: |nimrodversion|
+
+.. contents::
+
+.. raw:: html
+  <blockquote><p>
+  "A great chef is an artist that I truly respect" -- Robert Stack.
+  </p></blockquote>
+
+
+Introduction
+============
+
+The `koch`:idx: program is Nimrod's maintenance script. It is a replacement
+for make and shell scripting with the advantage that it is much more portable.
+The word *koch* means *cook* in German. ``koch`` is used mainly to build the
+Nimrod compiler, but it can also be used for other tasks. This document
+describes the supported commands and their options.
+
+
+Commands
+========
+
+boot command
+------------
+
+The `boot`:idx: command bootstraps the compiler, and it accepts different
+options:
+
+-d:release
+  By default a debug version is created, passing this option will
+  force a release build, which is much faster and should be preferred
+  unless you are debugging the compiler.
+-d:tinyc
+  Include the `Tiny C <http://bellard.org/tcc/>`_ backend. This
+  option is not supported on Windows.
+-d:useGnuReadline
+  Includes the `rdstdin module <rdstdin.html>`_ for `interactive
+  mode <nimrodc.html#nimrod-interactive-mode>`_ (aka ``nimrod i``).
+  This is not needed on Windows. On other platforms this may
+  incorporate the GNU readline library.
+-d:nativeStacktrace
+  Use native stack traces (only for Mac OS X or Linux).
+-d:noCaas
+  Builds Nimrod without compiler as a service (CAAS) support. CAAS
+  support is required for functionality like Nimrod's `idetool
+  <idetools.html>`_ command used to integrate the compiler with
+  `external IDEs <https://github.com/Araq/Nimrod/wiki/Editor-Support>`_.
+-d:avoidTimeMachine
+  Only for Mac OS X, activating this switch will force excluding
+  the generated ``nimcache`` directories from Time Machine backups.
+  By default ``nimcache`` directories will be included in backups,
+  and just for the Nimrod compiler itself it means backing up 20MB
+  of generated files each time you update the compiler. Using this
+  option will make the compiler invoke the `tmutil
+  <https://developer.apple.com/library/mac/documentation/Darwin/Reference/Manpages/man8/tmutil.8.html>`_
+  command on all ``nimcache`` directories, setting their backup
+  exclusion bit.
+
+  You can use the following command to locate all ``nimcache``
+  directories and check their backup exclusion bit::
+
+    $ find . -type d -name nimcache -exec tmutil isexcluded \{\} \;
+-d:useFFI
+  Nimrod code can use the `foreign function interface (FFI)
+  <manual.html#foreign-function-interface>`_ at runtime, but macros
+  are limited to pure Nimrod code at compilation time.  Enabling
+  this switch will allow macros to execute non-nimrod code at
+  compilation time (eg. open a file and write to it).
+--gc:refc|v2|markAndSweep|boehm|none
+  Selects which garbage collection strategy to use for the compiler
+  and generated code. See the `Nimrod's Garbage Collector <gc.html>`_
+  documentation for more information.
+
+After compilation is finished you will hopefully end up with the nimrod
+compiler in the ``bin`` directory. You can add Nimrod's ``bin`` directory to
+your ``$PATH`` or use the `install command`_ to place it where it will be
+found.
+
+clean command
+-------------
+
+The `clean`:idx: command removes all generated files.
+
+csource command
+---------------
+
+The `csource`:idx: command builds the C sources for installation. It accepts
+the same options as you would pass to the `boot command`_.
+
+inno command
+------------
+
+The `inno`:idx: command builds the `Inno Setup installer for Windows
+<http://www.jrsoftware.org/isinfo.php>`_.
+
+install command
+---------------
+
+The `install`:idx: command installs Nimrod to the specified directory, which
+is required as a parameter. For example, on Unix platforms you could run::
+
+  $ ./koch install /usr/local/bin
+
+temp command
+------------
+
+The temp command builds the Nimrod compiler but with a different final name
+(``nimrod_temp``), so it doesn't overwrite your normal compiler. You can use
+this command to test different options, the same you would issue for the `boot
+command`_.
+
+test command
+------------
+
+The `test`:idx: command can also be invoked with the alias ``tests``. This
+command will compile and run ``tests/testament/tester.nim``, which is the main
+driver of Nimrod's test suite. You can pass options to the ``test`` command,
+they will be forwarded to the tester. See its source code for available
+options.
+
+update command
+--------------
+
+The `update`:idx: command updates nimrod to the latest version from github.
+For this command to work you need to have compiled ``koch`` itself with the
+``-d:withUpdate`` switch.
+
+web command
+-----------
+
+The `web`:idx: command converts the documentation in the ``doc`` directory
+from rst to HTML. It also repeats the same operation but places the result in
+the ``web/upload`` which can be used to update the website at
+http://nimrod-lang.org.
+
+zip command
+-----------
+
+The `zip`:idx: command builds the installation ZIP package.
diff --git a/doc/manual.txt b/doc/manual.txt
index a87abab7a..32b0541e9 100644
--- a/doc/manual.txt
+++ b/doc/manual.txt
@@ -152,7 +152,7 @@ statements (simplified example)::
 Comments
 --------
 
-`Comments`:idx: start anywhere outside a string or character literal with the
+Comments start anywhere outside a string or character literal with the
 hash character ``#``.
 Comments consist of a concatenation of `comment pieces`:idx:. A comment piece
 starts with ``#`` and runs until the end of the line. The end of line characters
@@ -188,7 +188,7 @@ which code snippet the comment refers to.
 Identifiers & Keywords
 ----------------------
 
-`Identifiers`:idx: in Nimrod can be any string of letters, digits
+Identifiers in Nimrod can be any string of letters, digits
 and underscores, beginning with a letter. Two immediate following
 underscores ``__`` are not allowed::
 
@@ -201,7 +201,7 @@ classified as a ``letter`` and may thus be part of an identifier but later
 versions of the language may assign some Unicode characters to belong to the
 operator characters instead.
 
-The following `keywords`:idx: are reserved and cannot be used as identifiers:
+The following keywords are reserved and cannot be used as identifiers:
 
 .. code-block:: nimrod
    :file: keywords.txt
@@ -224,7 +224,7 @@ String literals
 
 Terminal symbol in the grammar: ``STR_LIT``.
 
-`String literals`:idx: can be delimited by matching double quotes, and can
+String literals can be delimited by matching double quotes, and can
 contain the following `escape sequences`:idx:\ :
 
 ==================         ===================================================
@@ -263,15 +263,16 @@ String literals can also be delimited by three double quotes
 ``"""`` ... ``"""``.
 Literals in this form may run for several lines, may contain ``"`` and do not
 interpret any escape sequences.
-For convenience, when the opening ``"""`` is immediately followed by a newline,
-the newline is not included in the string. The ending of the string literal is
-defined by the pattern ``"""[^"]``, so this:
-  
+For convenience, when the opening ``"""`` is followed by a newline (there may
+be whitespace between the opening ``"""`` and the newline),
+the newline (and the preceding whitespace) is not included in the string. The
+ending of the string literal is defined by the pattern ``"""[^"]``, so this:
+
 .. code-block:: nimrod 
   """"long string within quotes""""
-  
+
 Produces::
-  
+
   "long string within quotes"
 
 
@@ -280,7 +281,7 @@ Raw string literals
 
 Terminal symbol in the grammar: ``RSTR_LIT``.
 
-There are also `raw string literals`:idx: that are preceded with the 
+There are also raw string literals that are preceded with the 
 letter ``r`` (or ``R``) and are delimited by matching double quotes (just 
 like ordinary string literals) and do not interpret the escape sequences. 
 This is especially convenient for regular expressions or Windows paths:
@@ -313,7 +314,7 @@ Terminal symbols in the grammar: ``GENERALIZED_STR_LIT``,
 
 The construct ``identifier"string literal"`` (without whitespace between the
 identifier and the opening quotation mark) is a
-`generalized raw string literal`:idx:. It is a shortcut for the construct
+generalized raw string literal. It is a shortcut for the construct
 ``identifier(r"string literal")``, so it denotes a procedure call with a
 raw string literal as its only argument. Generalized raw string literals
 are especially convenient for embedding mini languages directly into Nimrod
@@ -365,7 +366,7 @@ type is used for Unicode characters, it can represent any Unicode character.
 Numerical constants
 -------------------
 
-`Numerical constants`:idx: are of a single type and have the form::
+Numerical constants are of a single type and have the form::
 
   hexdigit = digit | 'A'..'F' | 'a'..'f'
   octdigit = '0'..'7'
@@ -440,7 +441,7 @@ is approximately 1.72826e35 according to the IEEE floating point standard.
 Operators
 ---------
 
-In Nimrod one can define his own operators. An `operator`:idx: is any
+In Nimrod one can define his own operators. An operator is any
 combination of the following characters::
 
        =     +     -     *     /     <     >
@@ -587,7 +588,7 @@ The grammar's start symbol is ``module``.
 Types
 =====
 
-All expressions have a `type`:idx: which is known at compile time. Nimrod
+All expressions have a type which is known at compile time. Nimrod
 is statically typed. One can declare new types, which is in essence defining
 an identifier that can be used to denote this custom type.
 
@@ -605,7 +606,7 @@ These are the major type classes:
 
 Ordinal types
 -------------
-`Ordinal types`:idx: have the following characteristics:
+Ordinal types have the following characteristics:
 
 - Ordinal types are countable and ordered. This property allows
   the operation of functions as ``Inc``, ``Ord``, ``Dec`` on ordinal types to
@@ -705,7 +706,7 @@ For further details, see `Convertible relation`_.
 
 Subrange types
 --------------
-A `subrange`:idx: type is a range of values from an ordinal type (the base
+A subrange type is a range of values from an ordinal type (the base
 type). To define a subrange type, one must specify it's limiting values: the
 lowest and highest value of the type:
 
@@ -806,7 +807,7 @@ the ``+``, ``-``, ``*``, ``/`` operators for floating point types.
 
 Boolean type
 ------------
-The `boolean`:idx: type is named `bool`:idx: in Nimrod and can be one of the two
+The boolean type is named `bool`:idx: in Nimrod and can be one of the two
 pre-defined values ``true`` and ``false``. Conditions in while,
 if, elif, when statements need to be of type bool.
 
@@ -830,7 +831,7 @@ The size of the bool type is one byte.
 
 Character type
 --------------
-The `character type`:idx: is named ``char`` in Nimrod. Its size is one byte.
+The character type is named ``char`` in Nimrod. Its size is one byte.
 Thus it cannot represent an UTF-8 character, but a part of it.
 The reason for this is efficiency: for the overwhelming majority of use-cases,
 the resulting programs will still handle UTF-8 properly as UTF-8 was specially
@@ -845,7 +846,7 @@ character. ``TRune`` is declared in the `unicode module <unicode.html>`_.
 
 Enumeration types
 -----------------
-`Enumeration`:idx: types define a new type whose values consist of the ones
+Enumeration types define a new type whose values consist of the ones
 specified. The values are ordered. Example:
 
 .. code-block:: nimrod
@@ -915,7 +916,7 @@ via ``TMyEnum.value``:
 
 String type
 -----------
-All string literals are of the type `string`:idx:. A string in Nimrod is very
+All string literals are of the type ``string``. A string in Nimrod is very
 similar to a sequence of characters. However, strings in Nimrod are both
 zero-terminated and have a length field. One can retrieve the length with the
 builtin ``len`` procedure; the length never counts the terminating zero.
@@ -942,7 +943,7 @@ i-th *unichar*. The iterator ``runes`` from the `unicode module
 
 CString type
 ------------
-The `cstring`:idx: type represents a pointer to a zero-terminated char array
+The ``cstring`` type represents a pointer to a zero-terminated char array
 compatible to the type ``char*`` in Ansi C. Its primary purpose lies in easy
 interfacing with C. The index operation ``s[i]`` means the i-th *char* of 
 ``s``; however no bounds checking for ``cstring`` is performed making the
@@ -976,20 +977,20 @@ string from a cstring:
 
 Structured types
 ----------------
-A variable of a `structured type`:idx: can hold multiple values at the same
+A variable of a structured type can hold multiple values at the same
 time. Structured types can be nested to unlimited levels. Arrays, sequences,
 tuples, objects and sets belong to the structured types.
 
 Array and sequence types
 ------------------------
-`Arrays`:idx: are a homogeneous type, meaning that each element in the array
+Arrays are a homogeneous type, meaning that each element in the array
 has the same type. Arrays always have a fixed length which is specified at
 compile time (except for open arrays). They can be indexed by any ordinal type.
 A parameter ``A`` may be an *open array*, in which case it is indexed by
 integers from 0 to ``len(A)-1``. An array expression may be constructed by the
 array constructor ``[]``.
 
-`Sequences`:idx: are similar to arrays but of dynamic length which may change
+Sequences are similar to arrays but of dynamic length which may change
 during runtime (like strings). Sequences are implemented as growable arrays, 
 allocating pieces of memory as items are added. A sequence ``S`` is always
 indexed by integers from 0 to ``len(S)-1`` and its bounds are checked. 
@@ -1046,7 +1047,7 @@ supported because this is seldom needed and cannot be done efficiently.
 Varargs
 -------
 
-A `varargs`:idx: parameter is an openarray parameter that additionally
+A ``varargs`` parameter is an openarray parameter that additionally
 allows to pass a variable number of arguments to a procedure. The compiler 
 converts the list of arguments to an array implicitly:
 
@@ -1081,7 +1082,7 @@ parameter ``a``. (Note that ``$`` applied to strings is a nop.)
 
 Tuples and object types
 -----------------------
-A variable of a `tuple`:idx: or `object`:idx: type is a heterogeneous storage
+A variable of a tuple or object type is a heterogeneous storage
 container.
 A tuple or object defines various named *fields* of a type. A tuple also
 defines an *order* of the fields. Tuples are meant for heterogeneous storage
@@ -1089,7 +1090,8 @@ types with no overhead and few abstraction possibilities. The constructor ``()``
 can be used to construct tuples. The order of the fields in the constructor
 must match the order of the tuple's definition. Different tuple-types are
 *equivalent* if they specify the same fields of the same type in the same
-order.
+order. The *names* of the fields also have to be identical but this might
+change in a future version of the language.
 
 The assignment operator for tuples copies each component.
 The default assignment operator for objects copies each component. Overloading
@@ -1161,7 +1163,7 @@ For a ``ref object`` type ``system.new`` is invoked implicitly.
 Object variants
 ---------------
 Often an object hierarchy is overkill in certain situations where simple
-`variant`:idx: types are needed.
+variant types are needed.
 
 An example:
 
@@ -1219,7 +1221,7 @@ branch switch ``system.reset`` has to be used.
 
 Set type
 --------
-The `set type`:idx: models the mathematical notion of a set. The set's
+The set type models the mathematical notion of a set. The set's
 basetype can only be an ordinal type. The reason is that sets are implemented
 as high performance bit vectors.
 
@@ -1254,7 +1256,7 @@ operation             meaning
 
 Reference and pointer types
 ---------------------------
-References (similar to `pointers`:idx: in other programming languages) are a
+References (similar to pointers in other programming languages) are a
 way to introduce many-to-one relationships. This means different references can
 point to and modify the same location in memory (also called `aliasing`:idx:).
 
@@ -1352,7 +1354,7 @@ Not nil annotation
 ------------------
 
 All types for that ``nil`` is a valid value can be annotated to 
-exclude ``nil`` as a valid value with the `not nil`:idx: annotation:
+exclude ``nil`` as a valid value with the ``not nil`` annotation:
 
 .. code-block:: nimrod
   type
@@ -1377,7 +1379,7 @@ here.
 Memory regions
 --------------
 
-The types ``ref`` and ``ptr`` can get an optional `region`:idx: annotation.
+The types ``ref`` and ``ptr`` can get an optional ``region`` annotation.
 A region has to be an object type.
 
 Regions are very useful to separate user space and kernel memory in the
@@ -1436,7 +1438,7 @@ Future directions:
 
 Procedural type
 ---------------
-A `procedural type`:idx: is internally a pointer to a procedure. ``nil`` is
+A procedural type is internally a pointer to a procedure. ``nil`` is
 an allowed value for variables of a procedural type. Nimrod uses procedural
 types to achieve `functional`:idx: programming techniques.
 
@@ -1544,7 +1546,7 @@ accesses its environment. If it does so, it has the calling convention
 Distinct type
 -------------
 
-A `distinct type`:idx: is new type derived from a `base type`:idx: that is
+A ``distinct`` type is new type derived from a `base type`:idx: that is
 incompatible with its base type. In particular, it is an essential property
 of a distinct type that it **does not** imply a subtype relation between it
 and its base type. Explicit type conversions from a distinct type to its
@@ -1727,7 +1729,7 @@ modules like `db_sqlite <db_sqlite.html>`_.
 Void type
 ---------
 
-The `void`:idx: type denotes the absense of any type. Parameters of 
+The ``void`` type denotes the absense of any type. Parameters of 
 type ``void`` are treated as non-existent, ``void`` as a return type means that
 the procedure does not return a value:
 
@@ -1960,7 +1962,7 @@ To be written.
 Statements and expressions
 ==========================
 
-Nimrod uses the common statement/expression paradigm: `Statements`:idx: do not
+Nimrod uses the common statement/expression paradigm: Statements do not
 produce a value in contrast to expressions. However, some expressions are 
 statements.
 
@@ -1977,7 +1979,7 @@ Statement list expression
 
 Statements can also occur in an expression context that looks 
 like ``(stmt1; stmt2; ...; ex)``. This is called
-an `statement list expression`:idx: or ``(;)``. The type 
+an statement list expression or ``(;)``. The type 
 of ``(stmt1; stmt2; ...; ex)`` is the type of ``ex``. All the other statements
 must be of type ``void``. (One can use ``discard`` to produce a ``void`` type.)
 ``(;)`` does not introduce a new scope.
@@ -1994,7 +1996,7 @@ Example:
 
   discard p(3, 4) # discard the return value of `p`
 
-The `discard`:idx: statement evaluates its expression for side-effects and
+The ``discard`` statement evaluates its expression for side-effects and
 throws the expression's resulting value away. 
 
 Ignoring the return value of a procedure without using a discard statement is
@@ -2022,7 +2024,7 @@ An empty ``discard`` statement is often used as a null statement:
 Var statement
 -------------
 
-`Var`:idx: statements declare new local and global variables and
+Var statements declare new local and global variables and
 initialize them. A comma separated list of variables can be used to specify
 variables of the same type:
 
@@ -2091,7 +2093,7 @@ initialized and does not rely on syntactic properties:
 let statement
 -------------
 
-A `Let`:idx: statement declares new local and global `single assignment`:idx:
+A ``let`` statement declares new local and global `single assignment`:idx:
 variables and binds a value to them. The syntax is the of the ``var`` 
 statement, except that the keyword ``var`` is replaced by the keyword ``let``.
 Let variables are not l-values and can thus not be passed to ``var`` parameters
@@ -2133,7 +2135,7 @@ they contain such a type.
 Static statement/expression
 ---------------------------
 
-A `static`:idx: statement/expression can be used to enforce compile 
+A static statement/expression can be used to enforce compile 
 time evaluation explicitly. Enforced compile time evaluation can even evaluate
 code that has side effects: 
 
@@ -2167,7 +2169,7 @@ Example:
   else:
     echo("Boring name...")
 
-The `if`:idx: statement is a simple way to make a branch in the control flow:
+The ``if`` statement is a simple way to make a branch in the control flow:
 The expression after the keyword ``if`` is evaluated, if it is true
 the corresponding statements after the ``:`` are executed. Otherwise
 the expression after the ``elif`` is evaluated (if there is an
@@ -2213,7 +2215,7 @@ Example:
     else:                   echo("unknown command")
   
 
-The `case`:idx: statement is similar to the if statement, but it represents
+The ``case`` statement is similar to the if statement, but it represents
 a multi-branch selection. The expression after the keyword ``case`` is
 evaluated and if its value is in a *slicelist* the corresponding statements
 (after the ``of`` keyword) are executed. If the value is not in any
@@ -2226,12 +2228,12 @@ type.
 If the expression is not of an ordinal type, and no ``else`` part is
 given, control passes after the ``case`` statement.
 
-To suppress the static error in the ordinal case an ``else`` part with a ``nil``
-statement can be used.
+To suppress the static error in the ordinal case an ``else`` part with an
+empty ``discard`` statement can be used.
 
 As a special semantic extension, an expression in an ``of`` branch of a case
-statement may evaluate to a set constructor; the set is then expanded into 
-a list of its elements:
+statement may evaluate to a set or array constructor; the set or array is then
+expanded into a list of its elements:
 
 .. code-block:: nimrod
   const
@@ -2267,7 +2269,7 @@ Example:
   else:
     echo("cannot happen!")
 
-The `when`:idx: statement is almost identical to the ``if`` statement with some
+The ``when`` statement is almost identical to the ``if`` statement with some
 exceptions:
 
 * Each condition (``expr``) has to be a constant expression (of type ``bool``).
@@ -2289,7 +2291,7 @@ Example:
 .. code-block:: nimrod
   return 40+2
 
-The `return`:idx: statement ends the execution of the current procedure.
+The ``return`` statement ends the execution of the current procedure.
 It is only allowed in procedures. If there is an ``expr``, this is syntactic
 sugar for:
 
@@ -2316,7 +2318,7 @@ Example:
 .. code-block:: nimrod
   yield (1, 2, 3)
 
-The `yield`:idx: statement is used instead of the ``return`` statement in
+The ``yield`` statement is used instead of the ``return`` statement in
 iterators. It is only valid in iterators. Execution is returned to the body
 of the for loop that called the iterator. Yield does not end the iteration
 process, but execution is passed back to the iterator if the next iteration
@@ -2339,7 +2341,7 @@ Example:
           break myblock # leave the block, in this case both for-loops
   echo(found)
 
-The block statement is a means to group statements to a (named) `block`:idx:.
+The block statement is a means to group statements to a (named) ``block``.
 Inside the block, the ``break`` statement is allowed to leave the block
 immediately. A ``break`` statement can contain a name of a surrounding
 block to specify which block is to leave.
@@ -2353,7 +2355,7 @@ Example:
 .. code-block:: nimrod
   break
 
-The `break`:idx: statement is used to leave a block immediately. If ``symbol``
+The ``break`` statement is used to leave a block immediately. If ``symbol``
 is given, it is the name of the enclosing block that is to leave. If it is
 absent, the innermost block is left.
 
@@ -2371,7 +2373,7 @@ Example:
     pw = readLine(stdin)
 
 
-The `while`:idx: statement is executed until the ``expr`` evaluates to false.
+The ``while`` statement is executed until the ``expr`` evaluates to false.
 Endless loops are no error. ``while`` statements open an `implicit block`,
 so that they can be left with a ``break`` statement.
 
@@ -2379,7 +2381,7 @@ so that they can be left with a ``break`` statement.
 Continue statement
 ------------------
 
-A `continue`:idx: statement leads to the immediate next iteration of the
+A ``continue`` statement leads to the immediate next iteration of the
 surrounding loop construct. It is only allowed within a loop. A continue
 statement is syntactic sugar for a nested block:
 
@@ -2402,13 +2404,14 @@ Is equivalent to:
 Assembler statement
 -------------------
 
-The direct embedding of `assembler`:idx: code into Nimrod code is supported
+The direct embedding of assembler code into Nimrod code is supported
 by the unsafe ``asm`` statement. Identifiers in the assembler code that refer to
 Nimrod identifiers shall be enclosed in a special character which can be
 specified in the statement's pragmas. The default special character is ``'`'``:
 
 .. code-block:: nimrod
-  proc addInt(a, b: int): int {.noStackFrame.} =
+  {.push stackTrace:off.}
+  proc addInt(a, b: int): int =
     # a in eax, and b in edx
     asm """
         mov eax, `a`
@@ -2417,6 +2420,7 @@ specified in the statement's pragmas. The default special character is ``'`'``:
         call `raiseOverflow`
       theEnd:
     """
+  {.pop.}
 
 If the GNU assembler is used, quotes and newlines are inserted automatically:
 
@@ -2449,7 +2453,7 @@ Using statement
 
 **Warning**: The ``using`` statement is highly experimental!
 
-The `using statement`:idx: provides syntactic convenience for procs that
+The using statement provides syntactic convenience for procs that
 heavily use a single contextual parameter. When applied to a variable or a
 constant, it will instruct Nimrod to automatically consider the used symbol as
 a hidden leading parameter for any procedure calls, following the using
@@ -2534,7 +2538,7 @@ the last expression as the result value, much like in an `expr` template.
 Table constructor
 -----------------
 
-A `table constructor`:idx: is syntactic sugar for an array constructor:
+A table constructor is syntactic sugar for an array constructor:
 
 .. code-block:: nimrod
   {"key1": "value1", "key2", "key3": "value2"}
@@ -2581,7 +2585,7 @@ only needed for low-level programming and are inherently unsafe.
 
 The addr operator
 -----------------
-The `addr`:idx: operator returns the address of an l-value. If the type of the
+The ``addr`` operator returns the address of an l-value. If the type of the
 location is ``T``, the `addr` operator result is of the type ``ptr T``. An
 address is always an untraced reference. Taking the address of an object that
 resides on the stack is **unsafe**, as the pointer may live longer than the
@@ -2682,7 +2686,7 @@ For object oriented programming, the syntax ``obj.method(args)`` can be used
 instead of ``method(obj, args)``. The parentheses can be omitted if there are no
 remaining arguments: ``obj.len`` (instead of ``len(obj)``).
 
-This `method call syntax`:idx: is not restricted to objects, it can be used
+This method call syntax is not restricted to objects, it can be used
 to supply any type of first argument for procedures:
 
 .. code-block:: nimrod
@@ -2727,7 +2731,7 @@ Command invocation syntax
 -------------------------
 
 Routines can be invoked without the ``()`` if the call is syntatically
-a statement. This `command invocation syntax`:idx: also works for
+a statement. This command invocation syntax also works for
 expressions, but then only a single argument may follow. This restriction
 means ``echo f 1, f 2`` is parsed as ``echo(f(1), f(2))`` and not as
 ``echo(f(1, f(2)))``. The method call syntax may be used to provide one
@@ -2821,7 +2825,7 @@ The following builtin procs cannot be overloaded for reasons of implementation
 simplicity (they require specialized semantic checking)::
 
   defined, definedInScope, compiles, low, high, sizeOf, 
-  is, of, echo, shallowCopy, getAst
+  is, of, echo, shallowCopy, getAst, spawn
 
 Thus they act more like keywords than like ordinary identifiers; unlike a 
 keyword however, a redefinition may `shadow`:idx: the definition in 
@@ -2924,7 +2928,7 @@ The ``[]`` subscript operator for arrays/openarrays/sequences can be overloaded.
 Multi-methods
 =============
 
-Procedures always use static dispatch. `Multi-methods`:idx: use dynamic
+Procedures always use static dispatch. Multi-methods use dynamic
 dispatch.
 
 .. code-block:: nimrod
@@ -3177,7 +3181,7 @@ Example:
       line: int       # the line the symbol was declared in
       code: PNode     # the symbol's abstract syntax tree
 
-A `type`:idx: section begins with the ``type`` keyword. It contains multiple
+A type section begins with the ``type`` keyword. It contains multiple
 type definitions. A type definition binds a type to a name. Type definitions
 can be recursive or even mutually recursive. Mutually recursive types are only
 possible within a single ``type`` section. Nominal types like ``objects`` 
@@ -3214,7 +3218,7 @@ Example:
       close(f)
 
 
-The statements after the `try`:idx: are executed in sequential order unless
+The statements after the ``try`` are executed in sequential order unless
 an exception ``e`` is raised. If the exception type of ``e`` matches any
 listed in an ``except`` clause the corresponding statements are executed.
 The statements following the ``except`` clauses are called
@@ -3236,7 +3240,7 @@ is not executed (if an exception occurs).
 Except and finally statements
 -----------------------------
 
-`except`:idx: and `finally`:idx: can also be used as a stand-alone statements.
+``except`` and ``finally`` can also be used as a stand-alone statements.
 Any statements following them in the current block will be considered to be 
 in an implicit try block:
 
@@ -3285,9 +3289,9 @@ exception (unless a raise hook has been provided).
 OnRaise builtin
 ---------------
 
-``system.onRaise`` can be used to override the behaviour of ``raise`` for a
-single ``try`` statement. `onRaise`:idx: has to be called within the ``try`` 
-statement that should be affected.
+`system.onRaise() <system.html#onRaise>`_ can be used to override the
+behaviour of ``raise`` for a single ``try`` statement. ``onRaise`` has to be
+called within the ``try`` statement that should be affected.
 
 This allows for a Lisp-like `condition system`:idx:\:
 
@@ -3316,7 +3320,7 @@ Effect system
 Exception tracking
 ------------------
 
-Nimrod supports `exception tracking`:idx:. The `raises`:idx: pragma can be used
+Nimrod supports exception tracking. The `raises`:idx: pragma can be used
 to explicitly define which exceptions a proc/iterator/method/converter is 
 allowed to raise. The compiler verifies this:
 
@@ -3424,7 +3428,7 @@ exception tracking.
 Effects pragma
 --------------
 
-The `effects`:idx: pragma has been designed to assist the programmer with the
+The ``effects`` pragma has been designed to assist the programmer with the
 effects analysis. It is a statement that makes the compiler output all inferred
 effects up to the ``effects``'s position:
 
@@ -3493,7 +3497,7 @@ Example:
   for str in inorder(root):
     writeln(stdout, str)
 
-`Generics`:idx: are Nimrod's means to parametrize procs, iterators or types with
+Generics are Nimrod's means to parametrize procs, iterators or types with
 `type parameters`:idx:. Depending on context, the brackets are used either to
 introduce type parameters or to instantiate a generic proc, iterator or type.
 
@@ -3501,7 +3505,7 @@ introduce type parameters or to instantiate a generic proc, iterator or type.
 Is operator
 -----------
 
-The `is`:idx: operator checks for type equivalence at compile time. It is
+The ``is`` operator checks for type equivalence at compile time. It is
 therefore very useful for type specialization within generic code: 
 
 .. code-block:: nimrod
@@ -3516,7 +3520,7 @@ therefore very useful for type specialization within generic code:
 Type operator
 -------------
 
-The `type`:idx: (in many other languages called `typeof`:idx:) operator can
+The ``type`` (in many other languages called `typeof`:idx:) operator can
 be used to get the type of an expression: 
 
 .. code-block:: nimrod
@@ -3539,7 +3543,7 @@ other interpretations:
 Type Classes
 ------------
 
-A `type class`:idx: is a special pseudo-type that can be used to match against
+A type class is a special pseudo-type that can be used to match against
 types in the context of overload resolution or the ``is`` operator. 
 Nimrod supports the following built-in type classes:
 
@@ -3757,7 +3761,7 @@ A symbol can be forced to be open by a `mixin`:idx: declaration:
 Bind statement
 --------------
 
-The `bind`:idx: statement is the counterpart to the ``mixin`` statement. It 
+The ``bind`` statement is the counterpart to the ``mixin`` statement. It 
 can be used to explicitly declare identifiers that should be bound early (i.e.
 the identifiers should be looked up in the scope of the template/generic
 definition):
@@ -3785,7 +3789,7 @@ scope is the default.
 Templates
 =========
 
-A `template`:idx: is a simple form of a macro: It is a simple substitution
+A template is a simple form of a macro: It is a simple substitution
 mechanism that operates on Nimrod's abstract syntax trees. It is processed in
 the semantic pass of the compiler.
 
@@ -3817,7 +3821,7 @@ expected.
 Ordinary vs immediate templates
 -------------------------------
 
-There are two different kinds of templates: `immediate`:idx: templates and
+There are two different kinds of templates: immediate templates and
 ordinary templates. Ordinary templates take part in overloading resolution. As
 such their arguments need to be type checked before the template is invoked.
 So ordinary templates cannot receive undeclared identifiers:
@@ -4012,7 +4016,7 @@ a template. ``inject`` and ``gensym`` have no effect in ``dirty`` templates.
 Macros
 ======
 
-A `macro`:idx: is a special kind of low level template. Macros can be used
+A macro is a special kind of low level template. Macros can be used
 to implement `domain specific languages`:idx:. Like templates, macros come in
 the 2 flavors *immediate* and *ordinary*.
 
@@ -4390,7 +4394,7 @@ This operator will be matched against assignments to missing fields.
 Term rewriting macros
 =====================
 
-`Term rewriting macros`:idx: are macros or templates that have not only
+Term rewriting macros are macros or templates that have not only
 a *name* but also a *pattern* that is searched for after the semantic checking
 phase of the compiler: This means they provide an easy way to enhance the 
 compilation pipeline with user defined optimizations:
@@ -4726,7 +4730,7 @@ ordinary routines.
 Move optimization
 -----------------
 
-The ``call`` constraint is particularly useful to implement a `move`:idx: 
+The ``call`` constraint is particularly useful to implement a move 
 optimization for types that have copying semantics:
 
 .. code-block:: nimrod
@@ -4752,7 +4756,7 @@ optimization for types that have copying semantics:
 
 Modules
 =======
-Nimrod supports splitting a program into pieces by a `module`:idx: concept.
+Nimrod supports splitting a program into pieces by a module concept.
 Each module needs to be in its own file and has its own `namespace`:idx:.
 Modules enable `information hiding`:idx: and `separate compilation`:idx:.
 A module may gain access to symbols of another module by the `import`:idx:
@@ -4795,7 +4799,7 @@ This is best illustrated by an example:
 Import statement
 ~~~~~~~~~~~~~~~~
 
-After the `import`:idx: statement a list of module names can follow or a single
+After the ``import`` statement a list of module names can follow or a single
 module name followed by an ``except`` to prevent some symbols to be imported:
 
 .. code-block:: nimrod
@@ -4838,7 +4842,7 @@ Likewise the following does not make sense as the name is ``strutils`` already:
 From import statement
 ~~~~~~~~~~~~~~~~~~~~~
 
-After the `from`:idx: statement a module name follows followed by 
+After the ``from`` statement a module name follows followed by 
 an ``import`` to list the symbols one likes to use without explict
 full qualification:
 
@@ -4857,7 +4861,7 @@ in ``module``.
 Export statement
 ~~~~~~~~~~~~~~~~
 
-An `export`:idx: statement can be used for symbol fowarding so that client
+An ``export`` statement can be used for symbol fowarding so that client
 modules don't need to import a module's dependencies:
 
 .. code-block:: nimrod
@@ -4885,7 +4889,7 @@ Scope rules
 -----------
 Identifiers are valid from the point of their declaration until the end of
 the block in which the declaration occurred. The range where the identifier
-is known is the `scope`:idx: of the identifier. The exact scope of an
+is known is the scope of the identifier. The exact scope of an
 identifier depends on the way it was declared.
 
 Block scope
@@ -4958,7 +4962,7 @@ to access the feature becomes available.
 
 noSideEffect pragma
 -------------------
-The `noSideEffect`:idx: pragma is used to mark a proc/iterator to have no side
+The ``noSideEffect`` pragma is used to mark a proc/iterator to have no side
 effects. This means that the proc/iterator only changes locations that are
 reachable from its parameters and the return value only depends on the
 arguments. If none of its parameters have the type ``var T``
@@ -4980,7 +4984,7 @@ proc with no side effects:
 destructor pragma
 -----------------
 
-The `destructor`:idx: pragma is used to mark a proc to act as a type destructor.
+The ``destructor`` pragma is used to mark a proc to act as a type destructor.
 The proc must have a single parameter with a concrete type (the name of a
 generic type is allowed too).
 
@@ -5040,25 +5044,25 @@ the ``finalizer`` parameter to ``new``.
 
 procvar pragma
 --------------
-The `procvar`:idx: pragma is used to mark a proc that it can be passed to a
+The ``procvar`` pragma is used to mark a proc that it can be passed to a
 procedural variable.
 
 
 compileTime pragma
 ------------------
-The `compileTime`:idx: pragma is used to mark a proc to be used at compile
+The ``compileTime`` pragma is used to mark a proc to be used at compile
 time only. No code will be generated for it. Compile time procs are useful
 as helpers for macros.
 
 
 noReturn pragma
 ---------------
-The `noreturn`:idx: pragma is used to mark a proc that never returns. 
+The ``noreturn`` pragma is used to mark a proc that never returns. 
 
 
 Acyclic pragma
 --------------
-The `acyclic`:idx: pragma can be used for object types to mark them as acyclic
+The ``acyclic`` pragma can be used for object types to mark them as acyclic
 even though they seem to be cyclic. This is an **optimization** for the garbage
 collector to not consider objects of this type as part of a cycle:
 
@@ -5089,13 +5093,13 @@ memory, but nothing worse happens.
 
 Final pragma
 ------------
-The `final`:idx: pragma can be used for an object type to specify that it
+The ``final`` pragma can be used for an object type to specify that it
 cannot be inherited from.
 
 
 shallow pragma
 --------------
-The `shallow`:idx: pragma affects the semantics of a type: The compiler is
+The ``shallow`` pragma affects the semantics of a type: The compiler is
 allowed to make a shallow copy. This can cause serious semantic issues and
 break memory safety! However, it can speed up assignments considerably, 
 because the semantics of Nimrod require deep copying of sequences and strings. 
@@ -5115,14 +5119,14 @@ structure:
 
 Pure pragma
 -----------
-An object type can be marked with the `pure`:idx: pragma so that its type 
+An object type can be marked with the ``pure`` pragma so that its type 
 field which is used for runtime type identification is omitted. This is
 necessary for binary compatibility with other compiled languages.
 
 
 AsmNoStackFrame pragma
 ----------------------
-A proc can be marked with the `AsmNoStackFrame`:idx: pragma to tell the compiler
+A proc can be marked with the ``AsmNoStackFrame`` pragma to tell the compiler
 it should not generate a stack frame for the proc. There are also no exit
 statements like ``return result;`` generated and the generated C function is
 declared as ``__declspec(naked)`` or ``__attribute__((naked))`` (depending on
@@ -5133,7 +5137,7 @@ assembler statements.
 
 error pragma
 ------------
-The `error`:idx: pragma is used to make the compiler output an error message
+The ``error`` pragma is used to make the compiler output an error message
 with the given content. Compilation does not necessarily abort after an error
 though. 
 
@@ -5149,7 +5153,7 @@ operation is valid due to overloading and type conversions:
 
 fatal pragma
 ------------
-The `fatal`:idx: pragma is used to make the compiler output an error message
+The ``fatal`` pragma is used to make the compiler output an error message
 with the given content. In contrast to the ``error`` pragma, compilation
 is guaranteed to be aborted by this pragma. Example:
 
@@ -5159,17 +5163,17 @@ is guaranteed to be aborted by this pragma. Example:
 
 warning pragma
 --------------
-The `warning`:idx: pragma is used to make the compiler output a warning message
+The ``warning`` pragma is used to make the compiler output a warning message
 with the given content. Compilation continues after the warning.
 
 hint pragma
 -----------
-The `hint`:idx: pragma is used to make the compiler output a hint message with
+The ``hint`` pragma is used to make the compiler output a hint message with
 the given content. Compilation continues after the hint.
 
 line pragma
 -----------
-The `line`:idx: pragma can be used to affect line information of the annotated
+The ``line`` pragma can be used to affect line information of the annotated
 statement as seen in stack backtraces:
 
 .. code-block:: nimrod
@@ -5187,7 +5191,7 @@ If the ``line`` pragma is used with a parameter, the parameter needs be a
 
 linearScanEnd pragma
 --------------------
-The `linearScanEnd`:idx: pragma can be used to tell the compiler how to 
+The ``linearScanEnd`` pragma can be used to tell the compiler how to 
 compile a Nimrod `case`:idx: statement. Syntactically it has to be used as a
 statement:
 
@@ -5215,7 +5219,7 @@ whole ``case`` statement, the whole ``case`` statement uses linear scanning.
 
 computedGoto pragma
 -------------------
-The `computedGoto`:idx: pragma can be used to tell the compiler how to 
+The ``computedGoto`` pragma can be used to tell the compiler how to 
 compile a Nimrod `case`:idx: in a ``while true`` statement. 
 Syntactically it has to be used as a statement inside the loop:
 
@@ -5260,7 +5264,7 @@ extension the pragma is simply ignored.
 
 unroll pragma
 -------------
-The `unroll`:idx: pragma can be used to tell the compiler that it should unroll
+The ``unroll`` pragma can be used to tell the compiler that it should unroll
 a `for`:idx: or `while`:idx: loop for runtime efficiency: 
 
 .. code-block:: nimrod
@@ -5339,7 +5343,7 @@ but are used to override the settings temporarily. Example:
 
 register pragma
 ---------------
-The `register`:idx: pragma is for variables only. It declares the variable as
+The ``register`` pragma is for variables only. It declares the variable as
 ``register``, giving the compiler a hint that the variable should be placed
 in a hardware register for faster access. C compilers usually ignore this
 though and for good reasons: Often they do a better job without it anyway.
@@ -5350,7 +5354,7 @@ example) it may provide benefits, though.
 
 global pragma
 -------------
-The `global`:idx: pragma can be applied to a variable within a proc to instruct
+The ``global`` pragma can be applied to a variable within a proc to instruct
 the compiler to store it in a global location and initialize it once at program
 startup.
 
@@ -5367,7 +5371,7 @@ and before any variable in a module that imports it.
 
 DeadCodeElim pragma
 -------------------
-The `deadCodeElim`:idx: pragma only applies to whole modules: It tells the
+The ``deadCodeElim`` pragma only applies to whole modules: It tells the
 compiler to activate (or deactivate) dead code elimination for the module the
 pragma appears in.
 
@@ -5385,7 +5389,7 @@ Example:
 ..
   NoForward pragma
   ----------------
-  The `noforward`:idx: pragma can be used to turn on and off a special compilation
+  The ``noforward`` pragma can be used to turn on and off a special compilation
   mode that to large extent eliminates the need for forward declarations. In this
   mode, the proc definitions may appear out of order and the compiler will postpone
   their semantic analysis and compilation until it actually needs to generate code
@@ -5433,7 +5437,7 @@ Example:
 Pragma pragma
 -------------
 
-The `pragma`:idx: pragma can be used to declare user defined pragmas. This is 
+The ``pragma`` pragma can be used to declare user defined pragmas. This is 
 useful because Nimrod's templates and macros do not affect pragmas. User 
 defined pragmas are in a different module-wide scope than all other symbols. 
 They cannot be imported from a module.
@@ -5462,7 +5466,7 @@ and warning message contains a symbol in brackets. This is the message's
 identifier that can be used to enable or disable it:
 
 .. code-block:: Nimrod
-  {.warning[LineTooLong]: off.} # turn off warning about too long lines
+  {.hint[LineTooLong]: off.} # turn off the hint about too long lines
 
 This is often better than disabling all warnings at once.
 
@@ -5477,21 +5481,24 @@ are documented here.
 
 Importc pragma
 --------------
-The `importc`:idx: pragma provides a means to import a proc or a variable
+The ``importc`` pragma provides a means to import a proc or a variable
 from C. The optional argument is a string containing the C identifier. If
 the argument is missing, the C name is the Nimrod identifier *exactly as
 spelled*:
 
 .. code-block::
-  proc printf(formatstr: cstring) {.importc: "printf", varargs.}
+  proc printf(formatstr: cstring) {.header: "<stdio.h>", importc: "printf", varargs.}
 
 Note that this pragma is somewhat of a misnomer: Other backends will provide
-the same feature under the same name.
+the same feature under the same name. Also, if you are interfacing with C++
+you can use the `ImportCpp pragma <nimrodc.html#importcpp-pragma>`_ and
+interfacing with Objective-C the `ImportObjC pragma
+<nimrodc.html#importobjc-pragma>`_.
 
 
 Exportc pragma
 --------------
-The `exportc`:idx: pragma provides a means to export a type, a variable, or a
+The ``exportc`` pragma provides a means to export a type, a variable, or a
 procedure to C. Enums and constants can't be exported. The optional argument
 is a string containing the C identifier.  If the argument is missing, the C
 name is the Nimrod identifier *exactly as spelled*:
@@ -5505,7 +5512,7 @@ the same feature under the same name.
 
 Extern pragma
 -------------
-Like ``exportc`` or ``importc`` the `extern`:idx: pragma affects name
+Like ``exportc`` or ``importc``, the ``extern`` pragma affects name
 mangling. The string literal passed to ``extern`` can be a format string:
 
 .. code-block:: Nimrod
@@ -5518,7 +5525,7 @@ In the example the external name of ``p`` is set to ``prefixp``.
 Bycopy pragma
 -------------
 
-The `bycopy`:idx: pragma can be applied to an object or tuple type and
+The ``bycopy`` pragma can be applied to an object or tuple type and
 instructs the compiler to pass the type by value to procs:
 
 .. code-block:: nimrod
@@ -5530,13 +5537,13 @@ instructs the compiler to pass the type by value to procs:
 Byref pragma
 ------------
 
-The `byref`:idx: pragma can be applied to an object or tuple type and instructs
+The ``byref`` pragma can be applied to an object or tuple type and instructs
 the compiler to pass the type by reference (hidden pointer) to procs.
 
 
 Varargs pragma
 --------------
-The `varargs`:idx: pragma can be applied to procedures only (and procedure 
+The ``varargs`` pragma can be applied to procedures only (and procedure 
 types). It tells Nimrod that the proc can take a variable number of parameters 
 after the last specified parameter. Nimrod string values will be converted to C
 strings automatically:
@@ -5549,7 +5556,7 @@ strings automatically:
 
 Union pragma
 ------------
-The `union`:idx: pragma can be applied to any ``object`` type. It means all
+The ``union`` pragma can be applied to any ``object`` type. It means all
 of the object's fields are overlaid in memory. This produces a ``union``
 instead of a ``struct`` in the generated C/C++ code. The object declaration
 then must not use inheritance or any GC'ed memory but this is currently not
@@ -5560,7 +5567,7 @@ should scan unions conservatively.
 
 Packed pragma
 -------------
-The `packed`:idx: pragma can be applied to any ``object`` type. It ensures 
+The ``packed`` pragma can be applied to any ``object`` type. It ensures 
 that the fields of an object are packed back-to-back in memory. It is useful 
 to store packets or messages from/to network or hardware drivers, and for 
 interoperability with C. Combining packed pragma with inheritance is not 
@@ -5571,7 +5578,7 @@ compile-time error. Usage with inheritance should be defined and documented.
 
 Unchecked pragma
 ----------------
-The `unchecked`:idx: pragma can be used to mark a named array as ``unchecked``
+The ``unchecked`` pragma can be used to mark a named array as ``unchecked``
 meaning its bounds are not checked. This is often useful when one wishes to
 implement his own flexibly sized arrays. Additionally an unchecked array is
 translated into a C array of undetermined size:
@@ -5606,7 +5613,7 @@ runtime size of the array.
 
 Dynlib pragma for import
 ------------------------
-With the `dynlib`:idx: pragma a procedure or a variable can be imported from
+With the ``dynlib`` pragma a procedure or a variable can be imported from
 a dynamic library (``.dll`` files for Windows, ``lib*.so`` files for UNIX). 
 The non-optional argument has to be the name of the dynamic library:
 
@@ -5696,7 +5703,7 @@ Thread pragma
 -------------
 
 A proc that is executed as a new thread of execution should be marked by the
-`thread pragma`:idx:. The compiler checks procedures marked as ``thread`` for
+``thread`` pragma. The compiler checks procedures marked as ``thread`` for
 violations of the `no heap sharing restriction`:idx:\: This restriction implies
 that it is invalid to construct a data structure that consists of memory 
 allocated from different (thread local) heaps. 
@@ -5737,7 +5744,7 @@ Future directions:
 Threadvar pragma
 ----------------
 
-A global variable can be marked with the `threadvar`:idx: pragma; it is 
+A global variable can be marked with the ``threadvar`` pragma; it is 
 a `thread-local`:idx: variable then:
 
 .. code-block:: nimrod
@@ -5789,7 +5796,7 @@ Taint mode
 ==========
 
 The Nimrod compiler and most parts of the standard library support 
-a `taint mode`:idx:. Input strings are declared with the `TaintedString`:idx: 
+a taint mode. Input strings are declared with the `TaintedString`:idx: 
 string type declared in the ``system`` module.
 
 If the taint mode is turned on (via the ``--taintMode:on`` command line 
diff --git a/doc/nimgrep.txt b/doc/nimgrep.txt
index c231bf31b..67aaa427e 100644
--- a/doc/nimgrep.txt
+++ b/doc/nimgrep.txt
@@ -1,6 +1,6 @@
-=================================
-  nimgrep  User's manual
-=================================
+=========================
+  nimgrep User's manual
+=========================
 
 :Author: Andreas Rumpf
 :Version: 0.9
diff --git a/doc/niminst.txt b/doc/niminst.txt
index ebed396e4..8d95d01c9 100644
--- a/doc/niminst.txt
+++ b/doc/niminst.txt
@@ -1,6 +1,6 @@
-=================================
-  niminst  User's manual
-=================================
+=========================
+  niminst User's manual
+=========================
 
 :Author: Andreas Rumpf
 :Version: |nimrodversion|
diff --git a/doc/nimrodc.txt b/doc/nimrodc.txt
index d1925547e..428c42f39 100644
--- a/doc/nimrodc.txt
+++ b/doc/nimrodc.txt
@@ -87,6 +87,18 @@ Level  Description
        for compiler developers.
 =====  ============================================
 
+
+Compile time symbols
+--------------------
+
+Through the ``-d:x`` or ``--define:x`` switch you can define compile time
+symbols for conditional compilation. The defined switches can be checked in
+source code with the `when statement <manual.html#when-statement>`_ and
+`defined proc <system.html#defined>`_. The typical use of this switch is to
+enable builds in release mode (``-d:release``) where certain safety checks are
+omitted for better performance. Another common use is the ``-d:ssl`` switch to
+activate `SSL sockets <sockets.html>`_.
+
 

 Configuration files

 -------------------

@@ -116,7 +128,7 @@ The default build of a project is a `debug build`:idx:. To compile a
 Search path handling
 --------------------
 
-Nimrod has the concept of a global `search path`:idx: (PATH) that is queried to
+Nimrod has the concept of a global search path (PATH) that is queried to
 determine where to find imported modules or include files. If multiple files are
 found an ambiguity error is produced.
 
@@ -174,7 +186,7 @@ is not shared between different projects.
 Cross compilation

 =================

 

-To `cross compile`:idx:, use for example::

+To cross compile, use for example::

 

   nimrod c --cpu:i386 --os:linux --compile_only --gen_script myproject.nim

 

@@ -200,7 +212,7 @@ DLL generation
 

 Nimrod supports the generation of DLLs. However, there must be only one 

 instance of the GC per process/address space. This instance is contained in

-``nimrtl.dll``. This means that every generated Nimrod `DLL`:idx: depends

+``nimrtl.dll``. This means that every generated Nimrod DLL depends

 on ``nimrtl.dll``. To generate the "nimrtl.dll" file, use the command::

   

   nimrod c -d:release lib/nimrtl.nim

@@ -251,7 +263,7 @@ generator and are subject to change.
 

 NoDecl pragma

 -------------

-The `noDecl`:idx: pragma can be applied to almost any symbol (variable, proc,

+The ``noDecl`` pragma can be applied to almost any symbol (variable, proc,

 type, etc.) and is sometimes useful for interoperability with C:

 It tells Nimrod that it should not generate a declaration for the symbol in

 the C code. For example:

@@ -268,7 +280,7 @@ However, the ``header`` pragma is often the better alternative.
 

 Header pragma

 -------------

-The `header`:idx: pragma is very similar to the ``noDecl`` pragma: It can be

+The ``header`` pragma is very similar to the ``noDecl`` pragma: It can be

 applied to almost any symbol and specifies that it should not be declared

 and instead the generated code should contain an ``#include``:

 

@@ -287,7 +299,7 @@ encloses the header file in ``""`` in the generated C code.
 

 IncompleteStruct pragma

 -----------------------

-The `incompleteStruct`:idx: pragma tells the compiler to not use the 

+The ``incompleteStruct`` pragma tells the compiler to not use the 

 underlying C ``struct`` in a ``sizeof`` expression:

 

 .. code-block:: Nimrod

@@ -298,7 +310,7 @@ underlying C ``struct`` in a ``sizeof`` expression:
 

 Compile pragma

 --------------

-The `compile`:idx: pragma can be used to compile and link a C/C++ source file 

+The ``compile`` pragma can be used to compile and link a C/C++ source file 

 with the project: 

 

 .. code-block:: Nimrod

@@ -311,7 +323,7 @@ of the file.
 

 Link pragma

 -----------

-The `link`:idx: pragma can be used to link an additional file with the project: 

+The ``link`` pragma can be used to link an additional file with the project: 

 

 .. code-block:: Nimrod

   {.link: "myfile.o".}

@@ -319,7 +331,7 @@ The `link`:idx: pragma can be used to link an additional file with the project:
 

 PassC pragma
 ------------
-The `passC`:idx: pragma can be used to pass additional parameters to the C
+The ``passC`` pragma can be used to pass additional parameters to the C
 compiler like you would using the commandline switch ``--passC``:
 
 .. code-block:: Nimrod
@@ -333,7 +345,7 @@ embed parameters from an external command at compile time:
 
 PassL pragma
 ------------
-The `passL`:idx: pragma can be used to pass additional parameters to the linker
+The ``passL`` pragma can be used to pass additional parameters to the linker
 like you would using the commandline switch ``--passL``:
 
 .. code-block:: Nimrod
@@ -348,7 +360,7 @@ embed parameters from an external command at compile time:
 
 Emit pragma

 -----------

-The `emit`:idx: pragma can be used to directly affect the output of the 

+The ``emit`` pragma can be used to directly affect the output of the 

 compiler's code generator. So it makes your code unportable to other code

 generators/backends. Its usage is highly discouraged! However, it can be

 extremely useful for interfacing with `C++`:idx: or `Objective C`:idx: code.

@@ -360,20 +372,23 @@ Example:
   static int cvariable = 420;

   """.}

 

-  proc embedsC() {.noStackFrame.} = 

+  {.push stackTrace:off.}
+  proc embedsC() =

     var nimrodVar = 89

     # use backticks to access Nimrod symbols within an emit section:

     {.emit: """fprintf(stdout, "%d\n", cvariable + (int)`nimrodVar`);""".}

+  {.pop.}
 

   embedsC()

 

 

 ImportCpp pragma

 ----------------

-The `importcpp`:idx: pragma can be used to import `C++`:idx: methods. The

-generated code then uses the C++ method calling syntax: ``obj->method(arg)``.

-In addition with the ``header`` and ``emit`` pragmas this allows *sloppy*

-interfacing with libraries written in C++:

+Similar to the `importc pragma for C <manual.html#importc-pragma>`_, the
+``importcpp`` pragma can be used to import `C++`:idx: methods. The generated
+code then uses the C++ method calling syntax: ``obj->method(arg)``.  In
+addition with the ``header`` and ``emit`` pragmas this allows *sloppy*
+interfacing with libraries written in C++:
 

 .. code-block:: Nimrod

   # Horrible example of how to interface with a C++ engine ... ;-)

@@ -408,11 +423,11 @@ emits C++ code.
 

 ImportObjC pragma

 -----------------

-The `importobjc`:idx: pragma can be used to import `Objective C`:idx: methods. 

-The generated code then uses the Objective C method calling 

-syntax: ``[obj method param1: arg]``.

-In addition with the ``header`` and ``emit`` pragmas this allows *sloppy*

-interfacing with libraries written in Objective C:

+Similar to the `importc pragma for C <manual.html#importc-pragma>`_, the
+``importobjc`` pragma can be used to import `Objective C`:idx: methods.  The
+generated code then uses the Objective C method calling syntax: ``[obj method
+param1: arg]``.  In addition with the ``header`` and ``emit`` pragmas this
+allows *sloppy* interfacing with libraries written in Objective C:
 

 .. code-block:: Nimrod

   # horrible example of how to interface with GNUStep ...

@@ -458,7 +473,7 @@ emits Objective C code.
 CodegenDecl pragma
 ------------------
 
-The `codegenDecl`:idx: pragma can be used to directly influence Nimrod's code
+The ``codegenDecl`` pragma can be used to directly influence Nimrod's code
 generator. It receives a format string that determines how the variable or 
 proc is declared in the generated code:
 
@@ -473,7 +488,7 @@ proc is declared in the generated code:
 InjectStmt pragma
 -----------------
 
-The `injectStmt`:idx: pragma can be used to inject a statement before every
+The ``injectStmt`` pragma can be used to inject a statement before every
 other statement in the current module. It is only supposed to be used for
 debugging:
 
@@ -485,28 +500,28 @@ debugging:
 

 LineDir option

 --------------

-The `lineDir`:idx: option can be turned on or off. If turned on the

+The ``lineDir`` option can be turned on or off. If turned on the

 generated C code contains ``#line`` directives. This may be helpful for

 debugging with GDB.

 

 

 StackTrace option

 -----------------

-If the `stackTrace`:idx: option is turned on, the generated C contains code to

+If the ``stackTrace`` option is turned on, the generated C contains code to

 ensure that proper stack traces are given if the program crashes or an

 uncaught exception is raised.

 

 

 LineTrace option

 ----------------

-The `lineTrace`:idx: option implies the ``stackTrace`` option. If turned on,

+The ``lineTrace`` option implies the ``stackTrace`` option. If turned on,

 the generated C contains code to ensure that proper stack traces with line

 number information are given if the program crashes or an uncaught exception

 is raised.

 

 Debugger option

 ---------------

-The `debugger`:idx: option enables or disables the *Embedded Nimrod Debugger*.

+The ``debugger`` option enables or disables the *Embedded Nimrod Debugger*.

 See the documentation of endb_ for further information.

 

 

@@ -518,7 +533,7 @@ ENDB. See the documentation of `endb <endb.html>`_ for further information.
 

 Volatile pragma

 ---------------

-The `volatile`:idx: pragma is for variables only. It declares the variable as

+The ``volatile`` pragma is for variables only. It declares the variable as

 ``volatile``, whatever that means in C/C++ (its semantics are not well defined

 in C/C++).

 

@@ -530,14 +545,24 @@ DynlibOverride
 
 By default Nimrod's ``dynlib`` pragma causes the compiler to generate 
 ``GetProcAddress`` (or their Unix counterparts)
-calls to bind to a DLL. With the `dynlibOverride`:idx: command line switch this
+calls to bind to a DLL. With the ``dynlibOverride`` command line switch this
 can be prevented and then via ``--passL`` the static library can be linked
 against. For instance, to link statically against Lua this command might work
 on Linux::
 
   nimrod c --dynlibOverride:lua --passL:liblua.lib program.nim
-

-

+
+
+Backend language options
+========================
+
+The typical compiler usage involves using the ``compile`` or ``c`` command to
+transform a ``.nim`` file into one or more ``.c`` files which are then
+compiled with the platform's C compiler into a static binary. However there
+are other commands to compile to C++, Objective-C or Javascript. More details
+can be read in the `Nimrod Backend Integration document <backends.html>`_.
+
+
 Nimrod documentation tools
 ==========================
 
@@ -556,7 +581,7 @@ for further information.
 Nimrod interactive mode

 =======================

 

-The Nimrod compiler supports an `interactive mode`:idx:. This is also known as

+The Nimrod compiler supports an interactive mode. This is also known as

 a `REPL`:idx: (*read eval print loop*). If Nimrod has been built with the 

 ``-d:useGnuReadline`` switch, it uses the GNU readline library for terminal

 input management. To start Nimrod in interactive mode use the command 

@@ -681,35 +706,3 @@ efficient:
     else: quit(errorStr(p, "expected: console or gui"))

   of "license": c.license = UnixToNativePath(k.value)

   else: quit(errorStr(p, "unknown variable: " & k.key))

-
-
-The JavaScript target
-=====================
-
-Nimrod can also generate `JavaScript`:idx: code. However, the
-JavaScript code generator is experimental!
-
-Nimrod targets JavaScript 1.5 which is supported by any widely used browser.
-Since JavaScript does not have a portable means to include another module,
-Nimrod just generates a long ``.js`` file.
-
-Features or modules that the JavaScript platform does not support are not
-available. This includes:
-
-* manual memory management (``alloc``, etc.)
-* casting and other unsafe operations (``cast`` operator, ``zeroMem``, etc.)
-* file management
-* most modules of the Standard library
-* proper 64 bit integer arithmetic
-* unsigned integer arithmetic
-
-However, the modules `strutils`:idx:, `math`:idx:, and `times`:idx: are
-available! To access the DOM, use the `dom`:idx: module that is only
-available for the JavaScript platform.
-
-To compile a Nimrod module into a ``.js`` file use the ``js`` command; the
-default is a  ``.js`` file that is supposed to be referenced in an ``.html``
-file. However, you can also run the code with `nodejs`:idx:\:  
-
-  nimrod js -d:nodejs -r examples/hallo.nim
-
diff --git a/doc/spawn.txt b/doc/spawn.txt
new file mode 100644
index 000000000..ed500f3a5
--- /dev/null
+++ b/doc/spawn.txt
@@ -0,0 +1,98 @@
+==========================================================
+                  Parallel & Spawn
+==========================================================
+
+Nimrod has two flavors of parallelism: 
+1) `Structured`:idx parallelism via the ``parallel`` statement.
+2) `Unstructured`:idx: parallelism via the standalone ``spawn`` statement.
+
+Both need the `threadpool <threadpool.html>`_ module to work.
+
+Somewhat confusingly, ``spawn`` is also used in the ``parallel`` statement
+with slightly different semantics. ``spawn`` always takes a call expression of
+the form ``f(a, ...)``. Let ``T`` be ``f``'s return type. If ``T`` is ``void``
+then ``spawn``'s return type is also ``void``. Within a ``parallel`` section
+``spawn``'s return type is ``T``, otherwise it is ``FlowVar[T]``.
+
+The compiler can ensure the location in ``location = spawn f(...)`` is not
+read prematurely within a ``parallel`` section and so there is no need for
+the overhead of an indirection via ``FlowVar[T]`` to ensure correctness.
+
+
+Parallel statement
+==================
+
+Example:
+
+.. code-block:: nimrod
+  # Compute PI in an inefficient way
+  import strutils, math, threadpool
+
+  proc term(k: float): float = 4 * math.pow(-1, k) / (2*k + 1)
+
+  proc pi(n: int): float =
+    var ch = newSeq[float](n+1)
+    parallel:
+      for k in 0..ch.high:
+        ch[k] = spawn term(float(k))
+    for k in 0..ch.high:
+      result += ch[k]
+
+  echo formatFloat(pi(5000))
+
+
+The parallel statement is the preferred mechanism to introduce parallelism
+in a Nimrod program. A subset of the Nimrod language is valid within a
+``parallel`` section. This subset is checked to be free of data races at
+compile time. A sophisticated `disjoint checker`:idx: ensures that no data
+races are possible even though shared memory is extensively supported!
+
+The subset is in fact the full language with the following
+restrictions / changes:
+
+* ``spawn`` within a ``parallel`` section has special semantics.
+* Every location of the form ``a[i]`` and ``a[i..j]`` and ``dest`` where
+  ``dest`` is part of the pattern ``dest = spawn f(...)`` has to be
+  provable disjoint. This is called the *disjoint check*.
+* Every other complex location ``loc`` that is used in a spawned
+  proc (``spawn f(loc)``) has to be immutable for the duration of
+  the ``parallel`` section. This is called the *immutability check*. Currently
+  it is not specified what exactly "complex location" means. We need to make
+  this an optimization!
+* Every array access has to be provable within bounds. This is called 
+  the *bounds check*.
+* Slices are optimized so that no copy is performed. This optimization is not
+  yet performed for ordinary slices outside of a ``parallel`` section. Slices
+  are also special in that they currently do not support negative indexes!
+
+
+
+
+Spawn statement
+===============
+
+A standalone ``spawn`` statement is a simple construct. It executes
+the passed expression on the thread pool and returns a `data flow variable`:idx:
+``FlowVar[T]`` that can be read from. The reading with the ``^`` operator is
+**blocking**. However, one can use ``awaitAny`` to wait on multiple flow
+variables at the same time:
+
+.. code-block:: nimrod
+  import threadpool, ...
+  
+  # wait until 2 out of 3 servers received the update:
+  proc main =
+    var responses = newSeq[RawFlowVar](3)
+    for i in 0..2:
+      responses[i] = spawn tellServer(Update, "key", "value")
+    var index = awaitAny(responses)
+    assert index >= 0
+    responses.del(index)
+    discard awaitAny(responses)
+
+Like the ``parallel`` statement data flow variables ensure that no data races
+are possible. Due to technical limitations not every type ``T`` is possible in
+a data flow variable: ``T`` has to be of the type ``ref``, ``string``, ``seq``
+or of a type that doesn't contain a type that is garbage collected. This
+restriction will be removed in the future.
+
diff --git a/doc/subexes.txt b/doc/subexes.txt
index 10e0f4cc1..3b688fd0a 100644
--- a/doc/subexes.txt
+++ b/doc/subexes.txt
@@ -1,4 +1,3 @@
-================================
 Substitution Expressions (subex)
 ================================
 
diff --git a/doc/tools.txt b/doc/tools.txt
index ae739e778..0127bc4a8 100644
--- a/doc/tools.txt
+++ b/doc/tools.txt
@@ -1,6 +1,6 @@
-=====
-Tools
-=====
+===========================
+Tools available with Nimrod
+===========================
 
 The standard distribution ships with the following tools:
 
diff --git a/doc/trmacros.txt b/doc/trmacros.txt
deleted file mode 100644
index d5ad74e6e..000000000
--- a/doc/trmacros.txt
+++ /dev/null
@@ -1,275 +0,0 @@
-=========================================================
-   Term rewriting macros for Nimrod
-=========================================================
-
-:Author: Andreas Rumpf
-
-Term rewriting macros are macros or templates that have not only a *name* but
-also a *pattern* that is searched for after the semantic checking phase of
-the compiler: This means they provide an easy way to enhance the compilation
-pipeline with user defined optimizations:
-
-.. code-block:: nimrod
-  template optMul{`*`(a, 2)}(a: int): int = a+a
-  
-  let x = 3
-  echo x * 2
-
-The compiler now rewrites ``x * 2`` as ``x + x``. The code inside the
-curlies is the pattern to match against. The operators ``*``,  ``**``,
-``|``, ``~`` have a special meaning in patterns if they are written in infix 
-notation, so to match verbatim against ``*`` the ordinary function call syntax
-needs to be used.
-
-
-Unfortunately optimizations are hard to get right and even the tiny example
-is **wrong**: 
-
-.. code-block:: nimrod
-  template optMul{`*`(a, 2)}(a: int): int = a+a
-  
-  proc f(): int =
-    echo "side effect!"
-    result = 55
-  
-  echo f() * 2
-
-We cannot duplicate 'a' if it denotes an expression that has a side effect!
-Fortunately Nimrod supports side effect analysis:
-
-.. code-block:: nimrod
-  template optMul{`*`(a, 2)}(a: int{noSideEffect}): int = a+a
-  
-  proc f(): int =
-    echo "side effect!"
-    result = 55
-  
-  echo f() * 2 # not optimized ;-)
-
-So what about ``2 * a``? We should tell the compiler ``*`` is commutative. We
-cannot really do that however as the following code only swaps arguments
-blindly:
-
-.. code-block:: nimrod
-  template mulIsCommutative{`*`(a, b)}(a, b: int): int = b*a
-  
-What optimizers really need to do is a *canonicalization*:
-
-.. code-block:: nimrod
-  template canonMul{`*`(a, b)}(a: int{lit}, b: int): int = b*a
-
-The ``int{lit}`` parameter pattern matches against an expression of 
-type ``int``, but only if it's a literal.
-
-
-
-Parameter constraints
-=====================
-
-The parameter constraint expression can use the operators ``|`` (or), 
-``&`` (and) and ``~`` (not) and the following predicates:
-
-===================      =====================================================
-Predicate                Meaning
-===================      =====================================================
-``atom``                 The matching node has no children.
-``lit``                  The matching node is a literal like "abc", 12.
-``sym``                  The matching node must be a symbol (a bound 
-                         identifier).
-``ident``                The matching node must be an identifier (an unbound
-                         identifier).
-``call``                 The matching AST must be a call/apply expression.
-``lvalue``               The matching AST must be an lvalue.
-``sideeffect``           The matching AST must have a side effect.
-``nosideeffect``         The matching AST must have no side effect.
-``param``                A symbol which is a parameter.
-``genericparam``         A symbol which is a generic parameter.
-``module``               A symbol which is a module.
-``type``                 A symbol which is a type.
-``var``                  A symbol which is a variable.
-``let``                  A symbol which is a ``let`` variable.
-``const``                A symbol which is a constant.
-``result``               The special ``result`` variable.
-``proc``                 A symbol which is a proc.
-``method``               A symbol which is a method.
-``iterator``             A symbol which is an iterator.
-``converter``            A symbol which is a converter.
-``macro``                A symbol which is a macro.
-``template``             A symbol which is a template.
-``field``                A symbol which is a field in a tuple or an object.
-``enumfield``            A symbol which is a field in an enumeration.
-``forvar``               A for loop variable.
-``label``                A label (used in ``block`` statements).
-``nk*``                  The matching AST must have the specified kind. 
-                         (Example: ``nkIfStmt`` denotes an ``if`` statement.)
-``alias``                States that the marked parameter needs to alias 
-                         with *some* other parameter.
-``noalias``              States that *every* other parameter must not alias
-                         with the marked parameter.
-===================      =====================================================
-
-The ``alias`` and ``noalias`` predicates refer not only to the matching AST,
-but also to every other bound parameter; syntactially they need to occur after
-the ordinary AST predicates:
-
-.. code-block:: nimrod
-  template ex{a = b + c}(a: int{noalias}, b, c: int) =
-    # this transformation is only valid if 'b' and 'c' do not alias 'a':
-    a = b
-    inc a, b
-
-
-Pattern operators
-=================
-
-The operators ``*``,  ``**``, ``|``, ``~`` have a special meaning in patterns
-if they are written in infix notation.
-
-
-The ``|`` operator
-------------------
-
-The ``|`` operator if used as infix operator creates an ordered choice:
-
-.. code-block:: nimrod
-  template t{0|1}(): expr = 3
-  let a = 1
-  # outputs 3:
-  echo a
-
-The matching is performed after the compiler performed some optimizations like
-constant folding, so the following does not work:
-
-.. code-block:: nimrod
-  template t{0|1}(): expr = 3
-  # outputs 1:
-  echo 1
-
-The reason is that the compiler already transformed the 1 into "1" for
-the ``echo`` statement. However, a term rewriting macro should not change the
-semantics anyway. In fact they can be deactived with the ``--patterns:off``
-command line option or temporarily with the ``patterns`` pragma. 
-
-
-The ``{}`` operator
--------------------
-
-A pattern expression can be bound to a pattern parameter via the ``expr{param}``
-notation: 
-
-.. code-block:: nimrod
-  template t{(0|1|2){x}}(x: expr): expr = x+1
-  let a = 1
-  # outputs 2:
-  echo a
-
-
-The ``~`` operator
-------------------
-
-The ``~`` operator is the **not** operator in patterns:
-
-.. code-block:: nimrod
-  template t{x = (~x){y} and (~x){z}}(x, y, z: bool): stmt =
-    x = y
-    if x: x = z
-  
-  var
-    a = false
-    b = true
-    c = false
-  a = b and c
-  echo a
-
-
-The ``*`` operator
-------------------
-
-The ``*`` operator can *flatten* a nested binary expression like ``a & b & c``
-to ``&(a, b, c)``: 
-
-.. code-block:: nimrod
-  var
-    calls = 0
-    
-  proc `&&`(s: varargs[string]): string =
-    result = s[0]
-    for i in 1..len(s)-1: result.add s[i]
-    inc calls
-
-  template optConc{ `&&` * a }(a: string): expr = &&a
-
-  let space = " "
-  echo "my" && (space & "awe" && "some " ) && "concat"
-
-  # check that it's been optimized properly:
-  doAssert calls == 1
-
-
-The second operator of `*` must be a parameter; it is used to gather all the
-arguments. The expression ``"my" && (space & "awe" && "some " ) && "concat"``
-is passed to ``optConc`` in ``a`` as a special list (of kind ``nkArgList``) 
-which is flattened into a call expression; thus the invocation of ``optConc`` 
-produces:
-
-.. code-block:: nimrod
-   `&&`("my", space & "awe", "some ", "concat")
-
-
-The ``**`` operator
--------------------
-
-The ``**`` is much like the ``*`` operator, except that it gathers not only
-all the arguments, but also the matched operators in reverse polish notation:
-
-.. code-block:: nimrod
-  import macros
-
-  type
-    TMatrix = object
-      dummy: int
-
-  proc `*`(a, b: TMatrix): TMatrix = nil
-  proc `+`(a, b: TMatrix): TMatrix = nil
-  proc `-`(a, b: TMatrix): TMatrix = nil
-  proc `$`(a: TMatrix): string = result = $a.dummy
-  proc mat21(): TMatrix =
-    result.dummy = 21
-
-  macro optM{ (`+`|`-`|`*`) ** a }(a: TMatrix): expr =
-    echo treeRepr(a)
-    result = newCall(bindSym"mat21")
-
-  var x, y, z: TMatrix
-
-  echo x + y * z - x 
-
-This passes the expression ``x + y * z - x`` to the ``optM`` macro as
-an ``nnkArgList`` node containing::
-
-  Arglist
-    Sym "x"
-    Sym "y"
-    Sym "z"
-    Sym "*"
-    Sym "+"
-    Sym "x"
-    Sym "-"
-
-(Which is the reverse polish notation of ``x + y * z - x``.)
-
-
-Parameters
-==========
-
-Parameters in a pattern are type checked in the matching process. If a 
-parameter is of the type ``varargs`` it is treated specially and it can match
-0 or more arguments in the AST to be matched against:
-
-.. code-block:: nimrod
-  template optWrite{
-    write(f, x)
-    ((write|writeln){w})(f, y)
-  }(x, y: varargs[expr], f: TFile, w: expr) =
-    w(f, x, y)
-  
diff --git a/doc/tut1.txt b/doc/tut1.txt
index 46eda7ae3..a2aa835ee 100644
--- a/doc/tut1.txt
+++ b/doc/tut1.txt
@@ -1,4 +1,4 @@
-========================
+========================
 Nimrod Tutorial (Part I)
 ========================
 
@@ -110,7 +110,7 @@ useful for embedding HTML code templates for example.
 Comments
 --------
 
-`Comments`:idx: start anywhere outside a string or character literal with the
+Comments start anywhere outside a string or character literal with the
 hash character ``#``. Documentation comments start with ``##``. Multiline
 comments need to be aligned at the same column:
 
@@ -224,7 +224,7 @@ different values! For safety use only constant values.
 Constants
 =========
 
-`Constants`:idx: are symbols which are bound to a value. The constant's value
+Constants are symbols which are bound to a value. The constant's value
 cannot change. The compiler must be able to evaluate the expression in a
 constant declaration at compile time:
 
@@ -369,7 +369,7 @@ he types in nothing (only presses RETURN).
 For statement
 -------------
 
-The `for`:idx: statement is a construct to loop over any element an *iterator*
+The ``for`` statement is a construct to loop over any element an *iterator*
 provides. The example uses the built-in ``countup`` iterator:
 
 .. code-block:: nimrod
@@ -481,7 +481,7 @@ Example:
   else:
     echo("unknown operating system")
 
-The `when`:idx: statement is almost identical to the ``if`` statement with some
+The ``when`` statement is almost identical to the ``if`` statement with some
 differences:
 
 * Each condition has to be a constant expression since it is evaluated by the
@@ -791,7 +791,7 @@ However, this cannot be done for mutually recursive procedures:
 
 Here ``odd`` depends on ``even`` and vice versa. Thus ``even`` needs to be
 introduced to the compiler before it is completely defined. The syntax for
-such a `forward declaration`:idx: is simple: just omit the ``=`` and the
+such a forward declaration is simple: just omit the ``=`` and the
 procedure's body.
 
 Later versions of the language may get rid of the need for forward
@@ -863,7 +863,7 @@ that are available for them in detail.
 Booleans
 --------
 
-The `boolean`:idx: type is named ``bool`` in Nimrod and consists of the two
+The boolean type is named ``bool`` in Nimrod and consists of the two
 pre-defined values ``true`` and ``false``. Conditions in while,
 if, elif, when statements need to be of type bool.
 
@@ -1030,7 +1030,7 @@ Enumeration and object types cannot be defined on the fly, but only within a
 
 Enumerations
 ------------
-A variable of an `enumeration`:idx: type can only be assigned a value of a
+A variable of an enumeration type can only be assigned a value of a
 limited set. This set consists of ordered symbols. Each symbol is mapped
 to an integer value internally. The first symbol is represented
 at runtime by 0, the second by 1 and so on. Example:
@@ -1069,7 +1069,7 @@ An explicit ordered enum can have *holes*:
 Ordinal types
 -------------
 Enumerations without holes, integer types, ``char`` and ``bool`` (and
-subranges) are called `ordinal`:idx: types. Ordinal types have quite
+subranges) are called ordinal types. Ordinal types have quite
 a few special operations:
 
 -----------------     --------------------------------------------------------
@@ -1094,7 +1094,7 @@ checks turned on.)
 
 Subranges
 ---------
-A `subrange`:idx: type is a range of values from an integer or enumeration type
+A subrange type is a range of values from an integer or enumeration type
 (the base type). Example:
 
 .. code-block:: nimrod
@@ -1117,7 +1117,7 @@ avoid this common programming error.
 
 Sets
 ----
-The `set type`:idx: models the mathematical notion of a set. The set's
+The set type models the mathematical notion of a set. The set's
 basetype can only be an ordinal type. The reason is that sets are implemented
 as high performance bit vectors.
 
@@ -1161,7 +1161,7 @@ constants that should be ``or``'ed together.
 
 Arrays
 ------
-An `array`:idx: is a simple fixed length container. Each element in
+An array is a simple fixed length container. Each element in
 the array has the same type. The array's index type can be any ordinal type.
 
 Arrays can be constructed via ``[]``: 
@@ -1253,7 +1253,7 @@ to specify a range from zero to the specified index minus one:
 
 Sequences
 ---------
-`Sequences`:idx: are similar to arrays but of dynamic length which may change
+Sequences are similar to arrays but of dynamic length which may change
 during runtime (like strings). Since sequences are resizable they are always
 allocated on the heap and garbage collected.
 
@@ -1385,8 +1385,8 @@ Tuples
 A tuple type defines various named *fields* and an *order* of the fields.
 The constructor ``()`` can be used to construct tuples. The order of the
 fields in the constructor must match the order in the tuple's definition.
-Different tuple-types are *equivalent* if they specify the same fields of
-the same type in the same order.
+Different tuple-types are *equivalent* if they specify fields of
+the same type and of the same name in the same order.
 
 The assignment operator for tuples copies each component. The notation
 ``t.field`` is used to access a tuple's field. Another notation is
@@ -1471,7 +1471,7 @@ won't compile:
 
 Reference and pointer types
 ---------------------------
-References (similar to `pointers`:idx: in other programming languages) are a
+References (similar to pointers in other programming languages) are a
 way to introduce many-to-one relationships. This means different references can
 point to and modify the same location in memory.
 
@@ -1513,7 +1513,7 @@ If a reference points to *nothing*, it has the value ``nil``.
 
 Procedural type
 ---------------
-A `procedural type`:idx: is a (somewhat abstract) pointer to a procedure.
+A procedural type is a (somewhat abstract) pointer to a procedure.
 ``nil`` is an allowed value for a variable of a procedural type.
 Nimrod uses procedural types to achieve `functional`:idx: programming
 techniques.
@@ -1521,17 +1521,13 @@ techniques.
 Example:
 
 .. code-block:: nimrod
+  proc echoItem(x: int) = echo(x)
 
-  type
-    TCallback = proc (x: int)
-
-  proc echoItem(x: Int) = echo(x)
-
-  proc forEach(callback: TCallback) =
+  proc forEach(action: proc (x: int)) =
     const
       data = [2, 3, 5, 7, 11]
     for d in items(data):
-      callback(d)
+      action(d)
 
   forEach(echoItem)
 
@@ -1543,7 +1539,7 @@ listed in the `manual <manual.html>`_.
 
 Modules
 =======
-Nimrod supports splitting a program into pieces with a `module`:idx: concept.
+Nimrod supports splitting a program into pieces with a module concept.
 Each module is in its own file. Modules enable `information hiding`:idx: and
 `separate compilation`:idx:. A module may gain access to symbols of another
 module by the `import`:idx: statement. Only top-level symbols that are marked
@@ -1698,7 +1694,7 @@ define a shorter alias to use when qualifying symbols.
 
 Include statement
 -----------------
-The `include`:idx: statement does something fundamentally different than
+The ``include`` statement does something fundamentally different than
 importing a module: it merely includes the contents of a file. The ``include``
 statement is useful to split up a large module into several files:
 
diff --git a/doc/tut2.txt b/doc/tut2.txt
index ea6733c07..1e23618e0 100644
--- a/doc/tut2.txt
+++ b/doc/tut2.txt
@@ -135,7 +135,7 @@ The ``EInvalidObjectConversion`` exception is raised if ``x`` is not a
 Object variants
 ---------------
 Often an object hierarchy is overkill in certain situations where simple
-`variant`:idx: types are needed.
+variant types are needed.
 
 An example:
 
@@ -182,7 +182,7 @@ bound to a class. This has disadvantages:
   ``join`` a string method or an array method?
 
 Nimrod avoids these problems by not assigning methods to a class. All methods
-in Nimrod are `multi-methods`:idx:. As we will see later, multi-methods are
+in Nimrod are multi-methods. As we will see later, multi-methods are
 distinguished from procs only for dynamic binding purposes.
 
 
@@ -194,7 +194,7 @@ The syntax ``obj.method(args)`` can be used instead of ``method(obj, args)``.
 If there are no remaining arguments, the parentheses can be omitted:
 ``obj.len`` (instead of ``len(obj)``).
 
-This `method call syntax`:idx: is not restricted to objects, it can be used
+This method call syntax is not restricted to objects, it can be used
 for any type:
 
 .. code-block:: nimrod
@@ -343,7 +343,7 @@ evaluation or dead code elimination do not work with methods.
 Exceptions
 ==========
 
-In Nimrod `exceptions`:idx: are objects. By convention, exception types are
+In Nimrod exceptions are objects. By convention, exception types are
 prefixed with an 'E', not 'T'. The `system <system.html>`_ module defines an
 exception hierarchy that you might want to stick to. Exceptions derive from
 E_Base, which provides the common interface.
@@ -380,7 +380,7 @@ the template ``newException`` in the ``system`` module can be used:
 Try statement
 -------------
 
-The `try`:idx: statement handles exceptions:
+The ``try`` statement handles exceptions:
 
 .. code-block:: nimrod
   # read the first two lines of a text file that should contain numbers
@@ -501,7 +501,7 @@ with the file and line where the uncaught exception is being raised, which may
 help you locate the offending code which has changed.
 
 If you want to add the ``{.raises.}`` pragma to existing code, the compiler can
-also help you. You can add the ``{.effect.}`` pragma statement to your proc and
+also help you. You can add the ``{.effects.}`` pragma statement to your proc and
 the compiler will output all inferred effects up to that point (exception
 tracking is part of Nimrod's effect system). Another more roundabout way to
 find out the list of exceptions raised by a proc is to use the Nimrod ``doc2``
@@ -513,7 +513,7 @@ procs with the list of raised exceptions. You can read more about Nimrod's
 Generics
 ========
 
-`Generics`:idx: are Nimrod's means to parametrize procs, iterators or types
+Generics are Nimrod's means to parametrize procs, iterators or types
 with `type parameters`:idx:. They are most useful for efficient type safe
 containers:
 
@@ -714,9 +714,9 @@ know how the Nimrod concrete syntax is converted to an abstract syntax tree
 (AST). The AST is documented in the `macros <macros.html>`_ module.
 
 Once your macro is finished, there are two ways to invoke it:
-(1) invoking a macro like a procedure call (`expression macros`:idx:)
+(1) invoking a macro like a procedure call (expression macros)
 (2) invoking a macro with the special ``macrostmt``
-    syntax (`statement macros`:idx:)
+    syntax (statement macros)
 
 
 Expression Macros
diff --git a/examples/cross_calculator/android/scripts/jnibuild.sh b/examples/cross_calculator/android/scripts/jnibuild.sh
index 8b61f20f7..8b61f20f7 100755..100644
--- a/examples/cross_calculator/android/scripts/jnibuild.sh
+++ b/examples/cross_calculator/android/scripts/jnibuild.sh
diff --git a/examples/cross_calculator/android/scripts/nimbuild.sh b/examples/cross_calculator/android/scripts/nimbuild.sh
index 97130b8dd..97130b8dd 100755..100644
--- a/examples/cross_calculator/android/scripts/nimbuild.sh
+++ b/examples/cross_calculator/android/scripts/nimbuild.sh
diff --git a/examples/cross_calculator/android/scripts/tags.sh b/examples/cross_calculator/android/scripts/tags.sh
index 95507064f..95507064f 100755..100644
--- a/examples/cross_calculator/android/scripts/tags.sh
+++ b/examples/cross_calculator/android/scripts/tags.sh
diff --git a/examples/cross_calculator/ios/scripts/tags.sh b/examples/cross_calculator/ios/scripts/tags.sh
index 111e7a1c0..111e7a1c0 100755..100644
--- a/examples/cross_calculator/ios/scripts/tags.sh
+++ b/examples/cross_calculator/ios/scripts/tags.sh
diff --git a/examples/cross_calculator/ios/scripts/xcode_prebuild.sh b/examples/cross_calculator/ios/scripts/xcode_prebuild.sh
index c6d38f164..c6d38f164 100755..100644
--- a/examples/cross_calculator/ios/scripts/xcode_prebuild.sh
+++ b/examples/cross_calculator/ios/scripts/xcode_prebuild.sh
diff --git a/koch.nim b/koch.nim
index c203e0fd0..dff6ede98 100644
--- a/koch.nim
+++ b/koch.nim
@@ -6,6 +6,8 @@
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
 #
+#    See doc/koch.txt for documentation.
+#
 
 when defined(gcc) and defined(windows):
   when defined(x86):
@@ -91,10 +93,9 @@ proc buildTool(toolname, args: string) =
   copyFile(dest="bin"/ splitFile(toolname).name.exe, source=toolname.exe)
 
 proc inno(args: string) =
-  # make sure we have generated the c2nim and niminst executables:
+  # make sure we have generated the niminst executables:
   buildTool("tools/niminst/niminst", args)
   buildTool("tools/nimgrep", args)
-  buildTool("compiler/c2nim/c2nim", args)  
   exec("tools" / "niminst" / "niminst --var:version=$# inno compiler/nimrod" % 
        NimrodVersion)
 
@@ -152,7 +153,7 @@ proc boot(args: string) =
   copyExe(findStartNimrod(), 0.thVersion)
   for i in 0..2:
     echo "iteration: ", i+1
-    exec i.thVersion & " cc $# $# compiler" / "nimrod.nim" % [bootOptions, args]
+    exec i.thVersion & " c $# $# compiler" / "nimrod.nim" % [bootOptions, args]
     if sameFileContent(output, i.thVersion):
       copyExe(output, finalDest)
       echo "executables are equal: SUCCESS!"
diff --git a/lib/impure/db_mysql.nim b/lib/impure/db_mysql.nim
index 32cda3e4d..eec4daf00 100644
--- a/lib/impure/db_mysql.nim
+++ b/lib/impure/db_mysql.nim
@@ -24,6 +24,15 @@ type
   FReadDb* = object of FDb   ## effect that denotes a read operation
   FWriteDb* = object of FDb  ## effect that denotes a write operation
 
+proc sql*(query: string): TSqlQuery {.noSideEffect, inline.} =
+  ## constructs a TSqlQuery 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 
+  ## on, later versions will check the string for valid syntax.
+  result = TSqlQuery(query)
+
 proc dbError(db: TDbConn) {.noreturn.} = 
   ## raises an EDb exception.
   var e: ref EDb
diff --git a/lib/js/dom.nim b/lib/js/dom.nim
index d90067176..951d8e835 100644
--- a/lib/js/dom.nim
+++ b/lib/js/dom.nim
@@ -7,7 +7,8 @@
 #    distribution, for details about the copyright.
 #
 
-## Declaration of the Document Object Model for the JavaScript backend.
+## Declaration of the Document Object Model for the `JavaScript backend
+## <backends.html#the-javascript-target>`_.
 
 when not defined(js) and not defined(Nimdoc):
   {.error: "This module only works on the JavaScript platform".}
diff --git a/lib/packages/docutils/rstgen.nim b/lib/packages/docutils/rstgen.nim
index cead17f2b..fdbca4ca8 100644
--- a/lib/packages/docutils/rstgen.nim
+++ b/lib/packages/docutils/rstgen.nim
@@ -23,7 +23,8 @@
 ## many options and tweaking, but you are not limited to snippets and can
 ## generate `LaTeX documents <https://en.wikipedia.org/wiki/LaTeX>`_ too.
 
-import strutils, os, hashes, strtabs, rstast, rst, highlite
+import strutils, os, hashes, strtabs, rstast, rst, highlite, tables, sequtils,
+  algorithm
 
 const
   HtmlExt = "html"
@@ -56,6 +57,9 @@ type
     currentSection: string ## \
     ## Stores the empty string or the last headline/overline found in the rst
     ## document, so it can be used as a prettier name for term index generation.
+    seenIndexTerms: TTable[string, int] ## \
+    ## Keeps count of same text index terms to generate different identifiers
+    ## for hyperlinks. See renderIndexTerm proc for details.
   
   PDoc = var TRstGenerator ## Alias to type less.
 
@@ -68,10 +72,16 @@ proc initRstGenerator*(g: var TRstGenerator, target: TOutputTarget,
   ##
   ## You need to call this before using a ``TRstGenerator`` with any other
   ## procs in this module. Pass a non ``nil`` ``PStringTable`` value as
-  ## ``config`` with parameters used by the HTML output generator.  If you
-  ## don't know what to use, pass the results of the ``defaultConfig()`` proc.
-  ## The ``filename`` is symbolic and used only for error reporting, you can
-  ## pass any non ``nil`` string here.
+  ## `config` with parameters used by the HTML output generator.  If you don't
+  ## know what to use, pass the results of the `defaultConfig()
+  ## <#defaultConfig>_` proc.
+  ##
+  ## The `filename` parameter will be used for error reporting and creating
+  ## index hyperlinks to the file, but you can pass an empty string here if you
+  ## are parsing a stream in memory. If `filename` ends with the ``.nim``
+  ## extension, the title for the document will be set by default to ``Module
+  ## filename``.  This default title can be overriden by the embedded rst, but
+  ## it helps to prettify the generated index if no title is found.
   ##
   ## The ``TRstParseOptions``, ``TFindFileHandler`` and ``TMsgHandler`` types
   ## are defined in the the `packages/docutils/rst module <rst.html>`_.
@@ -111,6 +121,10 @@ proc initRstGenerator*(g: var TRstGenerator, target: TOutputTarget,
   g.options = options
   g.findFile = findFile
   g.currentSection = ""
+  let fileParts = filename.splitFile
+  if fileParts.ext == ".nim":
+    g.currentSection = "Module " & fileParts.name
+  g.seenIndexTerms = initTable[string, int]()
   g.msgHandler = msgHandler
   
   let s = config["split.item.toc"]
@@ -120,8 +134,8 @@ proc initRstGenerator*(g: var TRstGenerator, target: TOutputTarget,
 proc writeIndexFile*(g: var TRstGenerator, outfile: string) =
   ## Writes the current index buffer to the specified output file.
   ##
-  ## You previously need to add entries to the index with the ``setIndexTerm``
-  ## proc. If the index is empty the file won't be created.
+  ## You previously need to add entries to the index with the `setIndexTerm()
+  ## <#setIndexTerm>`_ proc. If the index is empty the file won't be created.
   if g.theIndex.len > 0: writeFile(outfile, g.theIndex)
   
 proc addXmlChar(dest: var string, c: char) = 
@@ -207,6 +221,9 @@ proc dispA(target: TOutputTarget, dest: var string,
   if target != outLatex: addf(dest, xml, args)
   else: addf(dest, tex, args)
   
+proc `or`(x, y: string): string {.inline.} =
+  result = if x.isNil: y else: x
+
 proc renderRstToOut*(d: var TRstGenerator, n: PRstNode, result: var string)
   ## Writes into ``result`` the rst ast ``n`` using the ``d`` configuration.
   ##
@@ -224,7 +241,7 @@ proc renderRstToOut*(d: var TRstGenerator, n: PRstNode, result: var string)
 proc renderAux(d: PDoc, n: PRstNode, result: var string) = 
   for i in countup(0, len(n)-1): renderRstToOut(d, n.sons[i], result)
 
-proc renderAux(d: PDoc, n: PRstNode, frmtA, frmtB: string, result: var string) = 
+proc renderAux(d: PDoc, n: PRstNode, frmtA, frmtB: string, result: var string) =
   var tmp = ""
   for i in countup(0, len(n)-1): renderRstToOut(d, n.sons[i], tmp)
   if d.target != outLatex:
@@ -254,25 +271,45 @@ proc setIndexTerm*(d: var TRstGenerator, id, term: string,
                    linkTitle, linkDesc = "") =
   ## Adds a `term` to the index using the specified hyperlink identifier.
   ##
-  ## The ``d.theIndex`` string will be used to append the term in the format
-  ## ``term<tab>file#id``. The anchor will be the based on the name of the file
-  ## currently being parsed plus the `id`, which will be appended after a hash.
+  ## A new entry will be added to the index using the format
+  ## ``term<tab>file#id``. The file part will come from the `filename`
+  ## parameter used in a previous call to the `initRstGenerator()
+  ## <#initRstGenerator>`_ proc.
+  ##
+  ## The `id` will be appended with a hash character only if its length is not
+  ## zero, otherwise no specific anchor will be generated. In general you
+  ## should only pass an empty `id` value for the title of standalone rst
+  ## documents (they are special for the `mergeIndexes() <#mergeIndexes>`_
+  ## proc, see `Index (idx) file format <docgen.html#index-idx-file-format>`_
+  ## for more information). Unlike other index terms, title entries are
+  ## inserted at the beginning of the accumulated buffer to maintain a logical
+  ## order of entries.
+  ##
   ## If `linkTitle` or `linkDesc` are not the empty string, two additional
   ## columns with their contents will be added.
   ##
-  ## The index won't be written to disk unless you call ``writeIndexFile``. The
-  ## purpose of the index is documented in the `docgen tools guide
-  ## <docgen.html#index-switch>`_.
-  d.theIndex.add(term)
-  d.theIndex.add('\t')
+  ## The index won't be written to disk unless you call `writeIndexFile()
+  ## <#writeIndexFile>`_. The purpose of the index is documented in the `docgen
+  ## tools guide <docgen.html#index-switch>`_.
+  assert(not d.theIndex.isNil)
+  var
+    entry = term
+    isTitle = false
+  entry.add('\t')
   let htmlFile = changeFileExt(extractFilename(d.filename), HtmlExt)
-  d.theIndex.add(htmlFile)
-  d.theIndex.add('#')
-  d.theIndex.add(id)
+  entry.add(htmlFile)
+  if id.len > 0:
+    entry.add('#')
+    entry.add(id)
+  else:
+    isTitle = true
   if linkTitle.len > 0 or linkDesc.len > 0:
-    d.theIndex.add('\t' & linkTitle.quoteIndexColumn)
-    d.theIndex.add('\t' & linkDesc.quoteIndexColumn)
-  d.theIndex.add("\n")
+    entry.add('\t' & linkTitle.quoteIndexColumn)
+    entry.add('\t' & linkDesc.quoteIndexColumn)
+  entry.add("\n")
+
+  if isTitle: d.theIndex.insert(entry)
+  else: d.theIndex.add(entry)
 
 proc hash(n: PRstNode): int =
   if n.kind == rnLeaf:
@@ -283,8 +320,20 @@ proc hash(n: PRstNode): int =
       result = result !& hash(n.sons[i])
     result = !$result
 
-proc renderIndexTerm(d: PDoc, n: PRstNode, result: var string) =
-  let id = rstnodeToRefname(n) & '_' & $abs(hash(n))
+proc renderIndexTerm*(d: PDoc, n: PRstNode, result: var string) =
+  ## Renders the string decorated within \`foobar\`\:idx\: markers.
+  ##
+  ## Additionally adds the encosed text to the index as a term. Since we are
+  ## interested in different instances of the same term to have different
+  ## entries, a table is used to keep track of the amount of times a term has
+  ## previously appeared to give a different identifier value for each.
+  let refname = n.rstnodeToRefname
+  if d.seenIndexTerms.hasKey(refname):
+    d.seenIndexTerms[refname] = d.seenIndexTerms[refname] + 1
+  else:
+    d.seenIndexTerms[refname] = 1
+  let id = refname & '_' & $d.seenIndexTerms[refname]
+
   var term = ""
   renderAux(d, n, term)
   setIndexTerm(d, id, term, d.currentSection)
@@ -298,12 +347,34 @@ type
     linkTitle: string ## If not nil, contains a prettier text for the href
     linkDesc: string ## If not nil, the title attribute of the final href
 
+  TIndexedDocs {.pure, final.} = TTable[TIndexEntry, seq[TIndexEntry]] ## \
+    ## Contains the index sequences for doc types.
+    ##
+    ## The key is a *fake* TIndexEntry which will contain the title of the
+    ## document in the `keyword` field and `link` will contain the html
+    ## filename for the document. `linkTitle` and `linkDesc` will be nil.
+    ##
+    ## The value indexed by this TIndexEntry is a sequence with the real index
+    ## entries found in the ``.idx`` file.
+
+
 proc cmp(a, b: TIndexEntry): int =
   ## Sorts two ``TIndexEntry`` first by `keyword` field, then by `link`.
   result = cmpIgnoreStyle(a.keyword, b.keyword)
   if result == 0:
     result = cmpIgnoreStyle(a.link, b.link)
 
+proc hash(x: TIndexEntry): THash =
+  ## Returns the hash for the combined fields of the type.
+  ##
+  ## The hash is computed as the chained hash of the individual string hashes.
+  assert(not x.keyword.isNil)
+  assert(not x.link.isNil)
+  result = x.keyword.hash !& x.link.hash
+  result = result !& (x.linkTitle or "").hash
+  result = result !& (x.linkDesc or "").hash
+  result = !$result
+
 proc `<-`(a: var TIndexEntry, b: TIndexEntry) =
   shallowCopy a.keyword, b.keyword
   shallowCopy a.link, b.link
@@ -332,43 +403,18 @@ proc sortIndex(a: var openArray[TIndexEntry]) =
       a[j] <- v
     if h == 1: break
 
-proc mergeIndexes*(dir: string): string =
-  ## merges all index files in `dir` and returns the generated index as HTML.
-  ## The result is no full HTML for flexibility.
-  var a: seq[TIndexEntry]
-  newSeq(a, 15_000)
-  setLen(a, 0)
-  var L = 0
-  for kind, path in walkDir(dir):
-    if kind == pcFile and path.endsWith(IndexExt):
-      for line in lines(path):
-        let s = line.find('\t')
-        if s < 0: continue
-        setLen(a, L+1)
-        a[L].keyword = line.substr(0, s-1)
-        a[L].link = line.substr(s+1)
-        if a[L].link.find('\t') > 0:
-          let extraCols = a[L].link.split('\t')
-          a[L].link = extraCols[0]
-          assert extraCols.len == 3
-          a[L].linkTitle = extraCols[1].unquoteIndexColumn
-          a[L].linkDesc = extraCols[2].unquoteIndexColumn
-        else:
-          a[L].linkTitle = nil
-          a[L].linkDesc = nil
-        inc L
-  sortIndex(a)
+proc generateSymbolIndex(symbols: seq[TIndexEntry]): string =
   result = ""
   var i = 0
-  while i < L:
-    result.addf("<dt><span>$1</span></dt><ul class=\"simple\"><dd>\n", 
-                [a[i].keyword])
+  while i < symbols.len:
+    result.addf("<dt><span>$1:</span></dt><ul class=\"simple\"><dd>\n",
+                [symbols[i].keyword])
     var j = i
-    while j < L and a[i].keyword == a[j].keyword:
+    while j < symbols.len and symbols[i].keyword == symbols[j].keyword:
       let
-        url = a[j].link
-        text = if not a[j].linkTitle.isNil: a[j].linkTitle else: url
-        desc = if not a[j].linkDesc.isNil: a[j].linkDesc else: ""
+        url = symbols[j].link
+        text = if not symbols[j].linkTitle.isNil: symbols[j].linkTitle else: url
+        desc = if not symbols[j].linkDesc.isNil: symbols[j].linkDesc else: ""
       if desc.len > 0:
         result.addf("""<li><a class="reference external"
           title="$3" href="$1">$2</a></li>
@@ -379,9 +425,246 @@ proc mergeIndexes*(dir: string): string =
       inc j
     result.add("</ul></dd>\n")
     i = j
+
+proc isDocumentationTitle(hyperlink: string): bool =
+  ## Returns true if the hyperlink is actually a documentation title.
+  ##
+  ## Documentation titles lack the hash. See `mergeIndexes() <#mergeIndexes>`_
+  ## for a more detailed explanation.
+  result = hyperlink.find('#') < 0
+
+proc stripTOCLevel(s: string): tuple[level: int, text: string] =
+  ## Returns the *level* of the toc along with the text without it.
+  for c in 0 .. <s.len:
+    result.level = c
+    if s[c] != ' ': break
+  result.text = s[result.level .. <s.len]
+
+proc indentToLevel(level: var int, newLevel: int): string =
+  ## Returns the sequence of <ul>|</ul> characters to switch to `newLevel`.
+  ##
+  ## The amount of lists added/removed will be based on the `level` variable,
+  ## which will be reset to `newLevel` at the end of the proc.
+  result = ""
+  if level == newLevel:
+    return
+  if newLevel > level:
+    result = repeatStr(newLevel - level, "<ul>")
+  else:
+    result = repeatStr(level - newLevel, "</ul>")
+  level = newLevel
+
+proc generateDocumentationTOC(entries: seq[TIndexEntry]): string =
+  ## Returns the sequence of index entries in an HTML hierarchical list.
+  result = ""
+  # Build a list of levels and extracted titles to make processing easier.
+  var
+    titleRef: string
+    levels: seq[tuple[level: int, text: string]]
+    L = 0
+    level = 1
+  levels.newSeq(entries.len)
+  for entry in entries:
+    let (rawLevel, rawText) = stripTOCLevel(entry.linkTitle or entry.keyword)
+    if rawLevel < 1:
+      # This is a normal symbol, push it *inside* one level from the last one.
+      levels[L].level = level + 1
+      # Also, ignore the linkTitle and use directly the keyword.
+      levels[L].text = entry.keyword
+    else:
+      # The level did change, update the level indicator.
+      level = rawLevel
+      levels[L].level = rawLevel
+      levels[L].text = rawText
+    inc L
+
+  # Now generate hierarchical lists based on the precalculated levels.
+  result = "<ul>\n"
+  level = 1
+  L = 0
+  while L < entries.len:
+    let link = entries[L].link
+    if link.isDocumentationTitle:
+      titleRef = link
+    else:
+      result.add(level.indentToLevel(levels[L].level))
+      result.add("<li><a href=\"" & link & "\">" &
+        levels[L].text & "</a>\n")
+    inc L
+  result.add(level.indentToLevel(1) & "</ul>\n")
+  assert(not titleRef.isNil,
+    "Can't use this proc on an API index, docs always have a title entry")
+
+proc generateDocumentationIndex(docs: TIndexedDocs): string =
+  ## Returns all the documentation TOCs in an HTML hierarchical list.
+  result = ""
+
+  # Sort the titles to generate their toc in alphabetical order.
+  var titles = toSeq(keys[TIndexEntry, seq[TIndexEntry]](docs))
+  sort(titles, cmp)
+
+  for title in titles:
+    let tocList = generateDocumentationTOC(docs[title])
+    result.add("<ul><li><a href=\"" &
+      title.link & "\">" & title.keyword & "</a>\n" & tocList & "</ul>\n")
+
+proc generateDocumentationJumps(docs: TIndexedDocs): string =
+  ## Returns a plain list of hyperlinks to documentation TOCs in HTML.
+  result = "Documents: "
+
+  # Sort the titles to generate their toc in alphabetical order.
+  var titles = toSeq(keys[TIndexEntry, seq[TIndexEntry]](docs))
+  sort(titles, cmp)
+
+  var chunks: seq[string] = @[]
+  for title in titles:
+    chunks.add("<a href=\"" & title.link & "\">" & title.keyword & "</a>")
+
+  result.add(chunks.join(", ") & ".<br>")
+
+proc generateModuleJumps(modules: seq[string]): string =
+  ## Returns a plain list of hyperlinks to the list of modules.
+  result = "Modules: "
+
+  var chunks: seq[string] = @[]
+  for name in modules:
+    chunks.add("<a href=\"" & name & ".html\">" & name & "</a>")
+
+  result.add(chunks.join(", ") & ".<br>")
+
+proc readIndexDir(dir: string):
+    tuple[modules: seq[string], symbols: seq[TIndexEntry], docs: TIndexedDocs] =
+  ## Walks `dir` reading ``.idx`` files converting them in TIndexEntry items.
+  ##
+  ## Returns the list of found module names, the list of free symbol entries
+  ## and the different documentation indexes. The list of modules is sorted.
+  ## See the documentation of ``mergeIndexes`` for details.
+  result.modules = @[]
+  result.docs = initTable[TIndexEntry, seq[TIndexEntry]](32)
+  newSeq(result.symbols, 15_000)
+  setLen(result.symbols, 0)
+  var L = 0
+  # Scan index files and build the list of symbols.
+  for kind, path in walkDir(dir):
+    if kind == pcFile and path.endsWith(IndexExt):
+      var
+        fileEntries: seq[TIndexEntry]
+        title: TIndexEntry
+        F = 0
+      newSeq(fileEntries, 500)
+      setLen(fileEntries, 0)
+      for line in lines(path):
+        let s = line.find('\t')
+        if s < 0: continue
+        setLen(fileEntries, F+1)
+        fileEntries[F].keyword = line.substr(0, s-1)
+        fileEntries[F].link = line.substr(s+1)
+        # See if we detect a title, a link without a `#foobar` trailing part.
+        if title.keyword.isNil and fileEntries[F].link.isDocumentationTitle:
+          title.keyword = fileEntries[F].keyword
+          title.link = fileEntries[F].link
+
+        if fileEntries[F].link.find('\t') > 0:
+          let extraCols = fileEntries[F].link.split('\t')
+          fileEntries[F].link = extraCols[0]
+          assert extraCols.len == 3
+          fileEntries[F].linkTitle = extraCols[1].unquoteIndexColumn
+          fileEntries[F].linkDesc = extraCols[2].unquoteIndexColumn
+        else:
+          fileEntries[F].linkTitle = nil
+          fileEntries[F].linkDesc = nil
+        inc F
+      # Depending on type add this to the list of symbols or table of APIs.
+      if title.keyword.isNil:
+        for i in 0 .. <F:
+          # Don't add to symbols TOC entries (they start with a whitespace).
+          let toc = fileEntries[i].linkTitle
+          if not toc.isNil and toc.len > 0 and toc[0] == ' ':
+            continue
+          # Ok, non TOC entry, add it.
+          setLen(result.symbols, L + 1)
+          result.symbols[L] = fileEntries[i]
+          inc L
+        result.modules.add(path.splitFile.name)
+      else:
+        # Generate the symbolic anchor for index quickjumps.
+        title.linkTitle = "doc_toc_" & $result.docs.len
+        result.docs[title] = fileEntries
+
+  sort(result.modules, system.cmp)
+
+proc mergeIndexes*(dir: string): string =
+  ## Merges all index files in `dir` and returns the generated index as HTML.
+  ##
+  ## This proc will first scan `dir` for index files with the ``.idx``
+  ## extension previously created by commands like ``nimrod doc|rst2html``
+  ## which use the ``--index:on`` switch. These index files are the result of
+  ## calls to `setIndexTerm() <#setIndexTerm>`_ and `writeIndexFile()
+  ## <#writeIndexFile>`_, so they are simple tab separated files.
+  ##
+  ## As convention this proc will split index files into two categories:
+  ## documentation and API. API indices will be all joined together into a
+  ## single big sorted index, making the bulk of the final index. This is good
+  ## for API documentation because many symbols are repated in different
+  ## modules. On the other hand, documentation indices are essentially table of
+  ## contents plus a few special markers. These documents will be rendered in a
+  ## separate section which tries to maintain the order and hierarchy of the
+  ## symbols in the index file.
+  ##
+  ## To differentiate between a documentation and API file a convention is
+  ## used: indices which contain one entry without the HTML hash character (#)
+  ## will be considered `documentation`, since this hash-less entry is the
+  ## explicit title of the document.  Indices without this explicit entry will
+  ## be considered `generated API` extracted out of a source ``.nim`` file.
+  ##
+  ## Returns the merged and sorted indices into a single HTML block which can
+  ## be further embedded into nimdoc templates.
+  var (modules, symbols, docs) = readIndexDir(dir)
+  assert(not symbols.isNil)
+
+  result = ""
+  # Generate a quick jump list of documents.
+  if docs.len > 0:
+    result.add(generateDocumentationJumps(docs))
+    result.add("<p />")
+
+  # Generate hyperlinks to all the linked modules.
+  if modules.len > 0:
+    result.add(generateModuleJumps(modules))
+    result.add("<p />")
+
+  # Generate the HTML block with API documents.
+  if docs.len > 0:
+    result.add("<h2>Documentation files</h2>\n")
+    result.add(generateDocumentationIndex(docs))
+
+  # Generate the HTML block with symbols.
+  if symbols.len > 0:
+    sortIndex(symbols)
+    result.add("<h2>API symbols</h2>\n")
+    result.add(generateSymbolIndex(symbols))
+
   
-# ----------------------------------------------------------------------------      
-  
+# ----------------------------------------------------------------------------
+
+proc stripTOCHTML(s: string): string =
+  ## Ugly quick hack to remove HTML tags from TOC titles.
+  ##
+  ## A TTocEntry.header field already contains rendered HTML tags. Instead of
+  ## implementing a proper version of renderRstToOut() which recursively
+  ## renders an rst tree to plain text, we simply remove text found between
+  ## angled brackets. Given the limited possibilities of rst inside TOC titles
+  ## this should be enough.
+  result = s
+  var first = result.find('<')
+  while first >= 0:
+    let last = result.find('>', first)
+    if last < 0:
+      # Abort, since we didn't found a closing angled bracket.
+      return
+    result.delete(first, last)
+    first = result.find('<', first)
+
 proc renderHeadline(d: PDoc, n: PRstNode, result: var string) = 
   var tmp = ""
   for i in countup(0, len(n) - 1): renderRstToOut(d, n.sons[i], tmp)
@@ -393,27 +676,30 @@ proc renderHeadline(d: PDoc, n: PRstNode, result: var string) =
     d.tocPart[length].refname = refname
     d.tocPart[length].n = n
     d.tocPart[length].header = tmp
-    
-    dispA(d.target, result,
-        "\n<h$1><a class=\"toc-backref\" id=\"$2\" href=\"#$2_toc\">$3</a></h$1>", 
-        "\\rsth$4{$3}\\label{$2}\n", [$n.level, 
-        d.tocPart[length].refname, tmp, 
-        $chr(n.level - 1 + ord('A'))])
+
+    dispA(d.target, result, "\n<h$1><a class=\"toc-backref\" " &
+      "id=\"$2\" href=\"#$2_toc\">$3</a></h$1>", "\\rsth$4{$3}\\label{$2}\n",
+      [$n.level, d.tocPart[length].refname, tmp, $chr(n.level - 1 + ord('A'))])
   else:
     dispA(d.target, result, "\n<h$1 id=\"$2\">$3</h$1>", 
                             "\\rsth$4{$3}\\label{$2}\n", [
         $n.level, refname, tmp, 
         $chr(n.level - 1 + ord('A'))])
-  
+
+  # Generate index entry using spaces to indicate TOC level for the output HTML.
+  assert n.level >= 0
+  setIndexTerm(d, refname, tmp.stripTOCHTML,
+    repeatChar(max(0, n.level), ' ') & tmp)
+
 proc renderOverline(d: PDoc, n: PRstNode, result: var string) = 
   if d.meta[metaTitle].len == 0:
-    d.currentSection = d.meta[metaTitle]
     for i in countup(0, len(n)-1):
       renderRstToOut(d, n.sons[i], d.meta[metaTitle])
+    d.currentSection = d.meta[metaTitle]
   elif d.meta[metaSubtitle].len == 0:
-    d.currentSection = d.meta[metaSubtitle]
     for i in countup(0, len(n)-1):
       renderRstToOut(d, n.sons[i], d.meta[metaSubtitle])
+    d.currentSection = d.meta[metaSubtitle]
   else:
     var tmp = ""
     for i in countup(0, len(n) - 1): renderRstToOut(d, n.sons[i], tmp)
@@ -428,7 +714,8 @@ proc renderTocEntry(d: PDoc, e: TTocEntry, result: var string) =
     "<li><a class=\"reference\" id=\"$1_toc\" href=\"#$1\">$2</a></li>\n", 
     "\\item\\label{$1_toc} $2\\ref{$1}\n", [e.refname, e.header])
 
-proc renderTocEntries*(d: var TRstGenerator, j: var int, lvl: int, result: var string) =
+proc renderTocEntries*(d: var TRstGenerator, j: var int, lvl: int,
+    result: var string) =
   var tmp = ""
   while j <= high(d.tocPart): 
     var a = abs(d.tocPart[j].n.level)
@@ -572,7 +859,8 @@ proc renderRstToOut(d: PDoc, n: PRstNode, result: var string) =
           [tmp])
   of rnField: renderField(d, n, result)
   of rnFieldName: 
-    renderAux(d, n, "<th class=\"docinfo-name\">$1:</th>", "\\item[$1:]", result)
+    renderAux(d, n, "<th class=\"docinfo-name\">$1:</th>",
+                    "\\item[$1:]", result)
   of rnFieldBody: 
     renderAux(d, n, "<td>$1</td>", " $1\n", result)
   of rnIndex: 
@@ -631,8 +919,9 @@ proc renderRstToOut(d: PDoc, n: PRstNode, result: var string) =
   of rnRef: 
     var tmp = ""
     renderAux(d, n, tmp)
-    dispA(d.target, result, "<a class=\"reference external\" href=\"#$2\">$1</a>", 
-                            "$1\\ref{$2}", [tmp, rstnodeToRefname(n)])
+    dispA(d.target, result,
+      "<a class=\"reference external\" href=\"#$2\">$1</a>",
+      "$1\\ref{$2}", [tmp, rstnodeToRefname(n)])
   of rnStandaloneHyperlink: 
     renderAux(d, n, 
       "<a class=\"reference external\" href=\"$1\">$1</a>", 
@@ -642,9 +931,9 @@ proc renderRstToOut(d: PDoc, n: PRstNode, result: var string) =
     var tmp1 = ""
     renderRstToOut(d, n.sons[0], tmp0)
     renderRstToOut(d, n.sons[1], tmp1)
-    dispA(d.target, result, "<a class=\"reference external\" href=\"$2\">$1</a>", 
-                   "\\href{$2}{$1}", 
-                   [tmp0, tmp1])
+    dispA(d.target, result,
+      "<a class=\"reference external\" href=\"$2\">$1</a>",
+      "\\href{$2}{$1}", [tmp0, tmp1])
   of rnDirArg, rnRaw: renderAux(d, n, result)
   of rnRawHtml:
     if d.target != outLatex:
diff --git a/lib/posix/posix.nim b/lib/posix/posix.nim
index e206447cc..8e66336c2 100644
--- a/lib/posix/posix.nim
+++ b/lib/posix/posix.nim
@@ -846,7 +846,7 @@ var
   FE_UPWARD* {.importc, header: "<fenv.h>".}: cint
   FE_DFL_ENV* {.importc, header: "<fenv.h>".}: cint
 
-when not defined(haiku):
+when not defined(haiku) and not defined(OpenBSD):
   var
     MM_HARD* {.importc, header: "<fmtmsg.h>".}: cint
       ## Source of the condition is hardware.
@@ -1578,8 +1578,17 @@ var
     ## Terminates a record (if supported by the protocol).
   MSG_OOB* {.importc, header: "<sys/socket.h>".}: cint
     ## Out-of-band data.
-  MSG_NOSIGNAL* {.importc, header: "<sys/socket.h>".}: cint
-    ## No SIGPIPE generated when an attempt to send is made on a stream-oriented socket that is no longer connected.
+
+when defined(macosx):
+  var
+    MSG_HAVEMORE* {.importc, header: "<sys/socket.h>".}: cint
+    MSG_NOSIGNAL* = MSG_HAVEMORE
+else:
+  var
+    MSG_NOSIGNAL* {.importc, header: "<sys/socket.h>".}: cint
+      ## No SIGPIPE generated when an attempt to send is made on a stream-oriented socket that is no longer connected.
+
+var
   MSG_PEEK* {.importc, header: "<sys/socket.h>".}: cint
     ## Leave received data in queue.
   MSG_TRUNC* {.importc, header: "<sys/socket.h>".}: cint
@@ -1816,7 +1825,7 @@ proc feholdexcept*(a1: ptr Tfenv): cint {.importc, header: "<fenv.h>".}
 proc fesetenv*(a1: ptr Tfenv): cint {.importc, header: "<fenv.h>".}
 proc feupdateenv*(a1: ptr Tfenv): cint {.importc, header: "<fenv.h>".}
 
-when not defined(haiku):
+when not defined(haiku) and not defined(OpenBSD):
   proc fmtmsg*(a1: int, a2: cstring, a3: cint,
               a4, a5, a6: cstring): cint {.importc, header: "<fmtmsg.h>".}
 
diff --git a/lib/pure/algorithm.nim b/lib/pure/algorithm.nim
index 37fbc948c..89c83a8a4 100644
--- a/lib/pure/algorithm.nim
+++ b/lib/pure/algorithm.nim
@@ -34,6 +34,20 @@ proc reverse*[T](a: var openArray[T]) =
   ## reverses the array `a`.
   reverse(a, 0, a.high)
 
+proc reversed*[T](a: openArray[T], first, last: int): seq[T] =
+  ## returns the reverse of the array `a[first..last]`.
+  result = newSeq[T](last - first + 1)
+  var x = first
+  var y = last
+  while x <= last:
+    result[x] = a[y]
+    dec(y)
+    inc(x)
+
+proc reversed*[T](a: openArray[T]): seq[T] =
+  ## returns the reverse of the array `a`.
+  reversed(a, 0, a.high)
+
 proc binarySearch*[T](a: openArray[T], key: T): int =
   ## binary search for `key` in `a`. Returns -1 if not found.
   var b = len(a)
@@ -150,6 +164,15 @@ proc sort*[T](a: var openArray[T],
   ##    # overload:
   ##    sort(myStrArray, system.cmp)
   ##
+  ## You can inline adhoc comparison procs with the `do notation
+  ## <manual.html#do-notation>`_. Example:
+  ##
+  ## .. code-block:: nimrod
+  ##
+  ##   people.sort do (x, y: Person) -> int:
+  ##     result = cmp(x.surname, y.surname)
+  ##     if result == 0:
+  ##       result = cmp(x.name, y.name)
   var n = a.len
   var b: seq[T]
   newSeq(b, n div 2)
diff --git a/lib/pure/asyncdispatch.nim b/lib/pure/asyncdispatch.nim
index fcf947831..d410f8ce1 100644
--- a/lib/pure/asyncdispatch.nim
+++ b/lib/pure/asyncdispatch.nim
@@ -11,8 +11,9 @@ include "system/inclrtl"
 
 import os, oids, tables, strutils, macros
 
-import rawsockets
-export TPort
+import rawsockets, net
+
+export TPort, TSocketFlags
 
 #{.injectStmt: newGcInvariant().}
 
@@ -26,10 +27,12 @@ export TPort
 ## **Note:** This module is still largely experimental.
 
 
-# TODO: Discarded void PFutures need to checked for exception.
-# TODO: Exceptions are currently uncatchable due to the limitation that 
-# you cannot have yield in a try stmt. Perhaps I can get the macro to put
-# a user's try except around ``future.read``.
+# TODO: Discarded void PFutures need to be checked for exception.
+# TODO: ``except`` statement (without `try`) does not work.
+# TODO: Multiple exception names in a ``except`` don't work.
+# TODO: The effect system (raises: []) has trouble with my try transformation.
+# TODO: Can't await in a 'except' body
+# TODO: getCurrentException(Msg) don't work
 
 # -- Futures
 
@@ -38,6 +41,7 @@ type
     cb: proc () {.closure,gcsafe.}
     finished: bool
     error*: ref EBase
+    stackTrace: string ## For debugging purposes only.
 
   PFuture*[T] = ref object of PFutureBase
     value: T
@@ -46,10 +50,23 @@ proc newFuture*[T](): PFuture[T] =
   ## Creates a new future.
   new(result)
   result.finished = false
+  result.stackTrace = getStackTrace()
+
+proc checkFinished[T](future: PFuture[T]) =
+  if future.finished:
+    echo("<----->")
+    echo(future.stackTrace)
+    echo("-----")
+    when T is string:
+      echo("Contents: ", future.value.repr)
+    echo("<----->")
+    echo("Future already finished, cannot finish twice.")
+    assert false
 
 proc complete*[T](future: PFuture[T], val: T) =
   ## Completes ``future`` with value ``val``.
-  assert(not future.finished, "Future already finished, cannot finish twice.")
+  #assert(not future.finished, "Future already finished, cannot finish twice.")
+  checkFinished(future)
   assert(future.error == nil)
   future.value = val
   future.finished = true
@@ -58,7 +75,8 @@ proc complete*[T](future: PFuture[T], val: T) =
 
 proc complete*(future: PFuture[void]) =
   ## Completes a void ``future``.
-  assert(not future.finished, "Future already finished, cannot finish twice.")
+  #assert(not future.finished, "Future already finished, cannot finish twice.")
+  checkFinished(future)
   assert(future.error == nil)
   future.finished = true
   if future.cb != nil:
@@ -66,11 +84,18 @@ proc complete*(future: PFuture[void]) =
 
 proc fail*[T](future: PFuture[T], error: ref EBase) =
   ## Completes ``future`` with ``error``.
-  assert(not future.finished, "Future already finished, cannot finish twice.")
+  #assert(not future.finished, "Future already finished, cannot finish twice.")
+  checkFinished(future)
   future.finished = true
   future.error = error
   if future.cb != nil:
     future.cb()
+  else:
+    # This is to prevent exceptions from being silently ignored when a future
+    # is discarded.
+    # TODO: This may turn out to be a bad idea.
+    # Turns out this is a bad idea.
+    #raise error
 
 proc `callback=`*(future: PFutureBase, cb: proc () {.closure,gcsafe.}) =
   ## Sets the callback proc to be called when the future completes.
@@ -118,6 +143,15 @@ proc failed*(future: PFutureBase): bool =
   ## Determines whether ``future`` completed with an error.
   future.error != nil
 
+proc asyncCheck*[T](future: PFuture[T]) =
+  ## Sets a callback on ``future`` which raises an exception if the future
+  ## finished with an error.
+  ##
+  ## This should be used instead of ``discard`` to discard void futures.
+  future.callback =
+    proc () =
+      if future.failed: raise future.error
+
 when defined(windows) or defined(nimdoc):
   import winlean, sets, hashes
   type
@@ -336,7 +370,7 @@ when defined(windows) or defined(nimdoc):
     return retFuture
 
   proc recv*(socket: TAsyncFD, size: int,
-             flags: int = 0): PFuture[string] =
+             flags = {TSocketFlags.SafeDisconn}): PFuture[string] =
     ## Reads **up to** ``size`` bytes from ``socket``. Returned future will
     ## complete once all the data requested is read, a part of the data has been
     ## read, or the socket has disconnected in which case the future will
@@ -356,7 +390,7 @@ when defined(windows) or defined(nimdoc):
     dataBuf.len = size
     
     var bytesReceived: DWord
-    var flagsio = flags.DWord
+    var flagsio = flags.toOSFlags().DWord
     var ol = PCustomOverlapped()
     GC_ref(ol)
     ol.data = TCompletionData(sock: socket, cb:
@@ -386,7 +420,10 @@ when defined(windows) or defined(nimdoc):
           dealloc dataBuf.buf
           dataBuf.buf = nil
         GC_unref(ol)
-        retFuture.fail(newException(EOS, osErrorMsg(err)))
+        if flags.isDisconnectionError(err):
+          retFuture.complete("")
+        else:
+          retFuture.fail(newException(EOS, osErrorMsg(err)))
     elif ret == 0 and bytesReceived == 0 and dataBuf.buf[0] == '\0':
       # We have to ensure that the buffer is empty because WSARecv will tell
       # us immediatelly when it was disconnected, even when there is still
@@ -417,7 +454,8 @@ when defined(windows) or defined(nimdoc):
       # free ``ol``.
     return retFuture
 
-  proc send*(socket: TAsyncFD, data: string): PFuture[void] =
+  proc send*(socket: TAsyncFD, data: string,
+             flags = {TSocketFlags.SafeDisconn}): PFuture[void] =
     ## Sends ``data`` to ``socket``. The returned future will complete once all
     ## data has been sent.
     verifyPresence(socket)
@@ -427,7 +465,7 @@ when defined(windows) or defined(nimdoc):
     dataBuf.buf = data # since this is not used in a callback, this is fine
     dataBuf.len = data.len
 
-    var bytesReceived, flags: DWord
+    var bytesReceived, lowFlags: DWord
     var ol = PCustomOverlapped()
     GC_ref(ol)
     ol.data = TCompletionData(sock: socket, cb:
@@ -440,12 +478,15 @@ when defined(windows) or defined(nimdoc):
     )
 
     let ret = WSASend(socket.TSocketHandle, addr dataBuf, 1, addr bytesReceived,
-                      flags, cast[POverlapped](ol), nil)
+                      lowFlags, cast[POverlapped](ol), nil)
     if ret == -1:
       let err = osLastError()
       if err.int32 != ERROR_IO_PENDING:
-        retFuture.fail(newException(EOS, osErrorMsg(err)))
         GC_unref(ol)
+        if flags.isDisconnectionError(err):
+          retFuture.complete()
+        else:
+          retFuture.fail(newException(EOS, osErrorMsg(err)))
     else:
       retFuture.complete()
       # We don't deallocate ``ol`` here because even though this completed
@@ -532,15 +573,30 @@ when defined(windows) or defined(nimdoc):
     result.TSocketHandle.setBlocking(false)
     register(result)
 
-  proc close*(socket: TAsyncFD) =
+  proc closeSocket*(socket: TAsyncFD) =
     ## Closes a socket and ensures that it is unregistered.
     socket.TSocketHandle.close()
     getGlobalDispatcher().handles.excl(socket)
 
+  proc unregister*(fd: TAsyncFD) =
+    ## Unregisters ``fd``.
+    getGlobalDispatcher().handles.excl(fd)
+
   initAll()
 else:
   import selectors
-  from posix import EINTR, EAGAIN, EINPROGRESS, EWOULDBLOCK, MSG_PEEK
+  when defined(windows):
+    import winlean
+    const
+      EINTR = WSAEINPROGRESS
+      EINPROGRESS = WSAEINPROGRESS
+      EWOULDBLOCK = WSAEWOULDBLOCK
+      EAGAIN = EINPROGRESS
+      MSG_NOSIGNAL = 0
+  else:
+    from posix import EINTR, EAGAIN, EINPROGRESS, EWOULDBLOCK, MSG_PEEK,
+                      MSG_NOSIGNAL
+  
   type
     TAsyncFD* = distinct cint
     TCallback = proc (sock: TAsyncFD): bool {.closure,gcsafe.}
@@ -581,11 +637,14 @@ else:
     result.TSocketHandle.setBlocking(false)
     register(result)
   
-  proc close*(sock: TAsyncFD) =
+  proc closeSocket*(sock: TAsyncFD) =
     let disp = getGlobalDispatcher()
     sock.TSocketHandle.close()
     disp.selector.unregister(sock.TSocketHandle)
 
+  proc unregister*(fd: TAsyncFD) =
+    getGlobalDispatcher().selector.unregister(fd.TSocketHandle)
+
   proc addRead(sock: TAsyncFD, cb: TCallback) =
     let p = getGlobalDispatcher()
     if sock.TSocketHandle notin p.selector:
@@ -671,20 +730,23 @@ else:
     return retFuture
 
   proc recv*(socket: TAsyncFD, size: int,
-             flags: int = 0): PFuture[string] =
+             flags = {TSocketFlags.SafeDisconn}): PFuture[string] =
     var retFuture = newFuture[string]()
     
     var readBuffer = newString(size)
 
     proc cb(sock: TAsyncFD): bool =
       result = true
-      let res = recv(sock.TSocketHandle, addr readBuffer[0], size,
-                     flags.cint)
+      let res = recv(sock.TSocketHandle, addr readBuffer[0], size.cint,
+                     flags.toOSFlags())
       #echo("recv cb res: ", res)
       if res < 0:
         let lastError = osLastError()
-        if lastError.int32 notin {EINTR, EWOULDBLOCK, EAGAIN}: 
-          retFuture.fail(newException(EOS, osErrorMsg(lastError)))
+        if lastError.int32 notin {EINTR, EWOULDBLOCK, EAGAIN}:
+          if flags.isDisconnectionError(lastError):
+            retFuture.complete("")
+          else:
+            retFuture.fail(newException(EOS, osErrorMsg(lastError)))
         else:
           result = false # We still want this callback to be called.
       elif res == 0:
@@ -693,11 +755,13 @@ else:
       else:
         readBuffer.setLen(res)
         retFuture.complete(readBuffer)
-  
+    # TODO: The following causes a massive slowdown.
+    #if not cb(socket):
     addRead(socket, cb)
     return retFuture
 
-  proc send*(socket: TAsyncFD, data: string): PFuture[void] =
+  proc send*(socket: TAsyncFD, data: string,
+             flags = {TSocketFlags.SafeDisconn}): PFuture[void] =
     var retFuture = newFuture[void]()
     
     var written = 0
@@ -706,11 +770,15 @@ else:
       result = true
       let netSize = data.len-written
       var d = data.cstring
-      let res = send(sock.TSocketHandle, addr d[written], netSize, 0.cint)
+      let res = send(sock.TSocketHandle, addr d[written], netSize.cint,
+                     MSG_NOSIGNAL)
       if res < 0:
         let lastError = osLastError()
         if lastError.int32 notin {EINTR, EWOULDBLOCK, EAGAIN}:
-          retFuture.fail(newException(EOS, osErrorMsg(lastError)))
+          if flags.isDisconnectionError(lastError):
+            retFuture.complete()
+          else:
+            retFuture.fail(newException(EOS, osErrorMsg(lastError)))
         else:
           result = false # We still want this callback to be called.
       else:
@@ -719,6 +787,8 @@ else:
           result = false # We still have data to send.
         else:
           retFuture.complete()
+    # TODO: The following causes crashes.
+    #if not cb(socket):
     addWrite(socket, cb)
     return retFuture
 
@@ -761,20 +831,23 @@ proc accept*(socket: TAsyncFD): PFuture[TAsyncFD] =
 
 # -- Await Macro
 
-template createCb*(retFutureSym, iteratorNameSym: expr): stmt {.immediate.} =
+template createCb*(retFutureSym, iteratorNameSym,
+                   name: expr): stmt {.immediate.} =
   var nameIterVar = iteratorNameSym
+  #{.push stackTrace: off.}
   proc cb {.closure,gcsafe.} =
     try:
       if not nameIterVar.finished:
         var next = nameIterVar()
         if next == nil:
-          assert retFutureSym.finished, "Async procedure's return Future was not finished."
+          assert retFutureSym.finished, "Async procedure's (" &
+                 name & ") return Future was not finished."
         else:
           next.callback = cb
     except:
       retFutureSym.fail(getCurrentException())
   cb()
-
+  #{.pop.}
 proc generateExceptionCheck(futSym,
     exceptBranch, rootReceiver: PNimrodNode): PNimrodNode {.compileTime.} =
   if exceptBranch == nil:
@@ -801,8 +874,9 @@ proc generateExceptionCheck(futSym,
     elseNode[0].add rootReceiver
     result.add elseNode
 
-template createVar(futSymName: string, asyncProc: PNimrodNode,
-                   valueReceiver, rootReceiver: expr) {.immediate, dirty.} =
+template createVar(result: var PNimrodNode, futSymName: string,
+                   asyncProc: PNimrodNode,
+                   valueReceiver, rootReceiver: expr) =
   result = newNimNode(nnkStmtList)
   var futSym = genSym(nskVar, "future")
   result.add newVarStmt(futSym, asyncProc) # -> var future<x> = y
@@ -839,7 +913,7 @@ proc processBody(node, retFutureSym: PNimrodNode,
       of nnkCall:
         # await foo(p, x)
         var futureValue: PNimrodNode
-        createVar("future" & $node[1][0].toStrLit, node[1], futureValue,
+        result.createVar("future" & $node[1][0].toStrLit, node[1], futureValue,
                   futureValue)
       else:
         error("Invalid node kind in 'await', got: " & $node[1].kind)
@@ -847,7 +921,7 @@ proc processBody(node, retFutureSym: PNimrodNode,
          node[1][0].ident == !"await":
       # foo await x
       var newCommand = node
-      createVar("future" & $node[0].toStrLit, node[1][1], newCommand[1],
+      result.createVar("future" & $node[0].toStrLit, node[1][1], newCommand[1],
                 newCommand)
 
   of nnkVarSection, nnkLetSection:
@@ -856,7 +930,7 @@ proc processBody(node, retFutureSym: PNimrodNode,
       if node[0][2][0].ident == !"await":
         # var x = await y
         var newVarSection = node # TODO: Should this use copyNimNode?
-        createVar("future" & $node[0][0].ident, node[0][2][1],
+        result.createVar("future" & $node[0][0].ident, node[0][2][1],
           newVarSection[0][2], newVarSection)
     else: discard
   of nnkAsgn:
@@ -865,14 +939,14 @@ proc processBody(node, retFutureSym: PNimrodNode,
       if node[1][0].ident == !"await":
         # x = await y
         var newAsgn = node
-        createVar("future" & $node[0].toStrLit, node[1][1], newAsgn[1], newAsgn)
+        result.createVar("future" & $node[0].toStrLit, node[1][1], newAsgn[1], newAsgn)
     else: discard
   of nnkDiscardStmt:
     # discard await x
     if node[0].kind != nnkEmpty and node[0][0].kind == nnkIdent and
           node[0][0].ident == !"await":
       var newDiscard = node
-      createVar("futureDiscard_" & $toStrLit(node[0][1]), node[0][1],
+      result.createVar("futureDiscard_" & $toStrLit(node[0][1]), node[0][1],
                 newDiscard[0], newDiscard)
   of nnkTryStmt:
     # try: await x; except: ...
@@ -909,14 +983,17 @@ proc getName(node: PNimrodNode): string {.compileTime.} =
     return $node[1].ident
   of nnkIdent:
     return $node.ident
+  of nnkEmpty:
+    return "anonymous"
   else:
-    assert false
+    error("Unknown name.")
 
 macro async*(prc: stmt): stmt {.immediate.} =
   ## Macro which processes async procedures into the appropriate
   ## iterators and yield statements.
-
-  expectKind(prc, nnkProcDef)
+  if prc.kind notin {nnkProcDef, nnkLambda}:
+    error("Cannot transform this node kind into an async proc." &
+          " Proc definition or lambda node expected.")
 
   hint("Processing " & prc[0].getName & " as an async proc.")
 
@@ -928,7 +1005,9 @@ macro async*(prc: stmt): stmt {.immediate.} =
     if $returnType[0] != "PFuture":
       error("Expected return type of 'PFuture' got '" & $returnType[0] & "'")
 
-  let subtypeIsVoid = returnType.kind == nnkEmpty
+  let subtypeIsVoid = returnType.kind == nnkEmpty or
+        (returnType.kind == nnkBracketExpr and
+         returnType[1].kind == nnkIdent and returnType[1].ident == !"void")
 
   var outerProcBody = newNimNode(nnkStmtList)
 
@@ -967,7 +1046,8 @@ macro async*(prc: stmt): stmt {.immediate.} =
 
   # -> createCb(retFuture)
   var cbName = newIdentNode("cb")
-  var procCb = newCall("createCb", retFutureSym, iteratorNameSym)
+  var procCb = newCall("createCb", retFutureSym, iteratorNameSym,
+                       newStrLitNode(prc[0].getName))
   outerProcBody.add procCb
 
   # -> return retFuture
@@ -977,17 +1057,18 @@ macro async*(prc: stmt): stmt {.immediate.} =
 
   # Remove the 'async' pragma.
   for i in 0 .. <result[4].len:
-    if result[4][i].ident == !"async":
+    if result[4][i].kind == nnkIdent and result[4][i].ident == !"async":
       result[4].del(i)
   if subtypeIsVoid:
     # Add discardable pragma.
-    result[4].add(newIdentNode("discardable"))
     if returnType.kind == nnkEmpty:
       # Add PFuture[void]
       result[3][0] = parseExpr("PFuture[void]")
 
   result[6] = outerProcBody
 
+  #echo(treeRepr(result))
+  #if prc[0].getName == "routeReq":
   #echo(toStrLit(result))
 
 proc recvLine*(socket: TAsyncFD): PFuture[string] {.async.} =
@@ -1015,7 +1096,7 @@ proc recvLine*(socket: TAsyncFD): PFuture[string] {.async.} =
     if c.len == 0:
       return ""
     if c == "\r":
-      c = await recv(socket, 1, MSG_PEEK)
+      c = await recv(socket, 1, {TSocketFlags.SafeDisconn, TSocketFlags.Peek})
       if c.len > 0 and c == "\L":
         discard await recv(socket, 1)
       addNLIfEmpty()
diff --git a/lib/pure/asynchttpserver.nim b/lib/pure/asynchttpserver.nim
index 6c2414d99..ee6658fd1 100644
--- a/lib/pure/asynchttpserver.nim
+++ b/lib/pure/asynchttpserver.nim
@@ -14,12 +14,13 @@
 import strtabs, asyncnet, asyncdispatch, parseutils, parseurl, strutils
 type
   TRequest* = object
-    client: PAsyncSocket # TODO: Separate this into a Response object?
+    client*: PAsyncSocket # TODO: Separate this into a Response object?
     reqMethod*: string
     headers*: PStringTable
     protocol*: tuple[orig: string, major, minor: int]
     url*: TURL
     hostname*: string ## The hostname of the client that made the request.
+    body*: string
 
   PAsyncHttpServer* = ref object
     socket: PAsyncSocket
@@ -50,10 +51,15 @@ proc `==`*(protocol: tuple[orig: string, major, minor: int],
 proc newAsyncHttpServer*(): PAsyncHttpServer =
   new result
 
-proc sendHeaders*(req: TRequest, headers: PStringTable) {.async.} =
-  ## Sends the specified headers to the requesting client.
+proc addHeaders(msg: var string, headers: PStringTable) =
   for k, v in headers:
-    await req.client.send(k & ": " & v & "\c\L")
+    msg.add(k & ": " & v & "\c\L")
+
+proc sendHeaders*(req: TRequest, headers: PStringTable): PFuture[void] =
+  ## Sends the specified headers to the requesting client.
+  var msg = ""
+  addHeaders(msg, headers)
+  return req.client.send(msg)
 
 proc respond*(req: TRequest, code: THttpCode,
         content: string, headers: PStringTable = newStringTable()) {.async.} =
@@ -63,9 +69,9 @@ proc respond*(req: TRequest, code: THttpCode,
   ## This procedure will **not** close the client socket.
   var customHeaders = headers
   customHeaders["Content-Length"] = $content.len
-  await req.client.send("HTTP/1.1 " & $code & "\c\L")
-  await sendHeaders(req, headers)
-  await req.client.send("\c\L" & content)
+  var msg = "HTTP/1.1 " & $code & "\c\L"
+  msg.addHeaders(customHeaders)
+  await req.client.send(msg & "\c\L" & content)
 
 proc newRequest(): TRequest =
   result.headers = newStringTable(modeCaseInsensitive)
@@ -77,7 +83,7 @@ proc parseHeader(line: string): tuple[key, value: string] =
   i += line.skipWhiteSpace(i)
   i += line.parseUntil(result.value, {'\c', '\L'}, i)
 
-proc parseProtocol(protocol: string):  tuple[orig: string, major, minor: int] =
+proc parseProtocol(protocol: string): tuple[orig: string, major, minor: int] =
   var i = protocol.skipIgnoreCase("HTTP/")
   if i != 5:
     raise newException(EInvalidValue, "Invalid request protocol. Got: " &
@@ -87,70 +93,95 @@ proc parseProtocol(protocol: string):  tuple[orig: string, major, minor: int] =
   i.inc # Skip .
   i.inc protocol.parseInt(result.minor, i)
 
+proc sendStatus(client: PAsyncSocket, status: string): PFuture[void] =
+  client.send("HTTP/1.1 " & status & "\c\L")
+
 proc processClient(client: PAsyncSocket, address: string,
                  callback: proc (request: TRequest): PFuture[void]) {.async.} =
-  # GET /path HTTP/1.1
-  # Header: val
-  # \n
-  var request = newRequest()
-  request.hostname = address
-  assert client != nil
-  request.client = client
-
-  # First line - GET /path HTTP/1.1
-  let line = await client.recvLine() # TODO: Timeouts.
-  if line == "":
-    client.close()
-    return
-  let lineParts = line.split(' ')
-  if lineParts.len != 3:
-    request.respond(Http400, "Invalid request. Got: " & line)
-    client.close()
-    return
-
-  let reqMethod = lineParts[0]
-  let path = lineParts[1]
-  let protocol = lineParts[2]
-
-  # Headers
-  var i = 0
   while true:
-    i = 0
-    let headerLine = await client.recvLine()
-    if headerLine == "":
-      client.close(); return
-    if headerLine == "\c\L": break
-    # TODO: Compiler crash
-    #let (key, value) = parseHeader(headerLine)
-    let kv = parseHeader(headerLine)
-    request.headers[kv.key] = kv.value
-
-  request.reqMethod = reqMethod
-  request.url = parseUrl(path)
-  try:
-    request.protocol = protocol.parseProtocol()
-  except EInvalidValue:
-    request.respond(Http400, "Invalid request protocol. Got: " & protocol)
-    return
-  
-  case reqMethod.normalize
-  of "get", "post", "head", "put", "delete", "trace", "options", "connect", "patch":
-    await callback(request)
-  else:
-    request.respond(Http400, "Invalid request method. Got: " & reqMethod)
-
-  # Persistent connections
-  if (request.protocol == HttpVer11 and
-      request.headers["connection"].normalize != "close") or
-     (request.protocol == HttpVer10 and
-      request.headers["connection"].normalize == "keep-alive"):
-    # In HTTP 1.1 we assume that connection is persistent. Unless connection
-    # header states otherwise.
-    # In HTTP 1.0 we assume that the connection should not be persistent.
-    # Unless the connection header states otherwise.
-    await processClient(client, address, callback)
-  else:
-    request.client.close()
+    # GET /path HTTP/1.1
+    # Header: val
+    # \n
+    var request = newRequest()
+    request.hostname = address
+    assert client != nil
+    request.client = client
+
+    # First line - GET /path HTTP/1.1
+    let line = await client.recvLine() # TODO: Timeouts.
+    if line == "":
+      client.close()
+      return
+    let lineParts = line.split(' ')
+    if lineParts.len != 3:
+      await request.respond(Http400, "Invalid request. Got: " & line)
+      continue
+
+    let reqMethod = lineParts[0]
+    let path = lineParts[1]
+    let protocol = lineParts[2]
+
+    # Headers
+    var i = 0
+    while true:
+      i = 0
+      let headerLine = await client.recvLine()
+      if headerLine == "":
+        client.close(); return
+      if headerLine == "\c\L": break
+      # TODO: Compiler crash
+      #let (key, value) = parseHeader(headerLine)
+      let kv = parseHeader(headerLine)
+      request.headers[kv.key] = kv.value
+
+    request.reqMethod = reqMethod
+    request.url = parseUrl(path)
+    try:
+      request.protocol = protocol.parseProtocol()
+    except EInvalidValue:
+      asyncCheck request.respond(Http400, "Invalid request protocol. Got: " &
+          protocol)
+      continue
+
+    if reqMethod.normalize == "post":
+      # Check for Expect header
+      if request.headers.hasKey("Expect"):
+        if request.headers["Expect"].toLower == "100-continue":
+          await client.sendStatus("100 Continue")
+        else:
+          await client.sendStatus("417 Expectation Failed")
+    
+      # Read the body
+      # - Check for Content-length header
+      if request.headers.hasKey("Content-Length"):
+        var contentLength = 0
+        if parseInt(request.headers["Content-Length"], contentLength) == 0:
+          await request.respond(Http400, "Bad Request. Invalid Content-Length.")
+        else:
+          request.body = await client.recv(contentLength)
+          assert request.body.len == contentLength
+      else:
+        await request.respond(Http400, "Bad Request. No Content-Length.")
+        continue
+
+    case reqMethod.normalize
+    of "get", "post", "head", "put", "delete", "trace", "options", "connect", "patch":
+      await callback(request)
+    else:
+      await request.respond(Http400, "Invalid request method. Got: " & reqMethod)
+
+    # Persistent connections
+    if (request.protocol == HttpVer11 and
+        request.headers["connection"].normalize != "close") or
+       (request.protocol == HttpVer10 and
+        request.headers["connection"].normalize == "keep-alive"):
+      # In HTTP 1.1 we assume that connection is persistent. Unless connection
+      # header states otherwise.
+      # In HTTP 1.0 we assume that the connection should not be persistent.
+      # Unless the connection header states otherwise.
+    else:
+      request.client.close()
+      break
 
 proc serve*(server: PAsyncHttpServer, port: TPort,
             callback: proc (request: TRequest): PFuture[void],
@@ -167,7 +198,11 @@ proc serve*(server: PAsyncHttpServer, port: TPort,
     # TODO: Causes compiler crash.
     #var (address, client) = await server.socket.acceptAddr()
     var fut = await server.socket.acceptAddr()
-    processClient(fut.client, fut.address, callback)
+    asyncCheck processClient(fut.client, fut.address, callback)
+
+proc close*(server: PAsyncHttpServer) =
+  ## Terminates the async http server instance.
+  server.socket.close()
 
 when isMainModule:
   var server = newAsyncHttpServer()
@@ -178,5 +213,5 @@ when isMainModule:
         "Content-type": "text/plain; charset=utf-8"}
     await req.respond(Http200, "Hello World", headers.newStringTable())
 
-  server.serve(TPort(5555), cb)
+  asyncCheck server.serve(TPort(5555), cb)
   runForever()
diff --git a/lib/pure/asyncnet.nim b/lib/pure/asyncnet.nim
index 9394078c8..374ac77e3 100644
--- a/lib/pure/asyncnet.nim
+++ b/lib/pure/asyncnet.nim
@@ -80,7 +80,8 @@ proc connect*(socket: PAsyncSocket, address: string, port: TPort,
   ## or an error occurs.
   result = connect(socket.fd.TAsyncFD, address, port, af)
 
-proc readIntoBuf(socket: PAsyncSocket, flags: int): PFuture[int] {.async.} =
+proc readIntoBuf(socket: PAsyncSocket,
+    flags: set[TSocketFlags]): PFuture[int] {.async.} =
   var data = await recv(socket.fd.TAsyncFD, BufferSize, flags)
   if data.len != 0:
     copyMem(addr socket.buffer[0], addr data[0], data.len)
@@ -89,7 +90,7 @@ proc readIntoBuf(socket: PAsyncSocket, flags: int): PFuture[int] {.async.} =
   result = data.len
 
 proc recv*(socket: PAsyncSocket, size: int,
-           flags: int = 0): PFuture[string] {.async.} =
+           flags = {TSocketFlags.SafeDisconn}): PFuture[string] {.async.} =
   ## Reads ``size`` bytes from ``socket``. Returned future will complete once
   ## all of the requested data is read. If socket is disconnected during the
   ## recv operation then the future may complete with only a part of the
@@ -100,7 +101,7 @@ proc recv*(socket: PAsyncSocket, size: int,
     let originalBufPos = socket.currPos
 
     if socket.bufLen == 0:
-      let res = await socket.readIntoBuf(flags and (not MSG_PEEK))
+      let res = await socket.readIntoBuf(flags - {TSocketFlags.Peek})
       if res == 0:
         result.setLen(0)
         return
@@ -108,32 +109,31 @@ proc recv*(socket: PAsyncSocket, size: int,
     var read = 0
     while read < size:
       if socket.currPos >= socket.bufLen:
-        if (flags and MSG_PEEK) == MSG_PEEK:
+        if TSocketFlags.Peek in flags:
           # We don't want to get another buffer if we're peeking.
-          result.setLen(read)
-          return
-        let res = await socket.readIntoBuf(flags and (not MSG_PEEK))
+          break
+        let res = await socket.readIntoBuf(flags - {TSocketFlags.Peek})
         if res == 0:
-          result.setLen(read)
-          return
+          break
 
       let chunk = min(socket.bufLen-socket.currPos, size-read)
       copyMem(addr(result[read]), addr(socket.buffer[socket.currPos]), chunk)
       read.inc(chunk)
       socket.currPos.inc(chunk)
 
-    if (flags and MSG_PEEK) == MSG_PEEK:
+    if TSocketFlags.Peek in flags:
       # Restore old buffer cursor position.
       socket.currPos = originalBufPos
     result.setLen(read)
   else:
     result = await recv(socket.fd.TAsyncFD, size, flags)
 
-proc send*(socket: PAsyncSocket, data: string): PFuture[void] =
+proc send*(socket: PAsyncSocket, data: string,
+           flags = {TSocketFlags.SafeDisconn}): PFuture[void] =
   ## Sends ``data`` to ``socket``. The returned future will complete once all
   ## data has been sent.
   assert socket != nil
-  result = send(socket.fd.TAsyncFD, data)
+  result = send(socket.fd.TAsyncFD, data, flags)
 
 proc acceptAddr*(socket: PAsyncSocket): 
       PFuture[tuple[address: string, client: PAsyncSocket]] =
@@ -168,7 +168,8 @@ proc accept*(socket: PAsyncSocket): PFuture[PAsyncSocket] =
         retFut.complete(future.read.client)
   return retFut
 
-proc recvLine*(socket: PAsyncSocket): PFuture[string] {.async.} =
+proc recvLine*(socket: PAsyncSocket,
+    flags = {TSocketFlags.SafeDisconn}): PFuture[string] {.async.} =
   ## Reads a line of data from ``socket``. Returned future will complete once
   ## a full line is read or an error occurs.
   ##
@@ -181,28 +182,60 @@ proc recvLine*(socket: PAsyncSocket): PFuture[string] {.async.} =
   ## If the socket is disconnected in the middle of a line (before ``\r\L``
   ## is read) then line will be set to ``""``.
   ## The partial line **will be lost**.
-  
+  ##
+  ## **Warning**: The ``Peek`` flag is not yet implemented.
   template addNLIfEmpty(): stmt =
     if result.len == 0:
       result.add("\c\L")
+  assert TSocketFlags.Peek notin flags ## TODO:
+  if socket.isBuffered:
+    result = ""
+    if socket.bufLen == 0:
+      let res = await socket.readIntoBuf(flags)
+      if res == 0:
+        return
+
+    var lastR = false
+    while true:
+      if socket.currPos >= socket.bufLen:
+        let res = await socket.readIntoBuf(flags)
+        if res == 0:
+          result = ""
+          break
 
-  result = ""
-  var c = ""
-  while true:
-    c = await recv(socket, 1)
-    if c.len == 0:
-      return ""
-    if c == "\r":
-      c = await recv(socket, 1, MSG_PEEK)
-      if c.len > 0 and c == "\L":
-        let dummy = await recv(socket, 1)
-        assert dummy == "\L"
-      addNLIfEmpty()
-      return
-    elif c == "\L":
-      addNLIfEmpty()
-      return
-    add(result.string, c)
+      case socket.buffer[socket.currPos]
+      of '\r':
+        lastR = true
+        addNLIfEmpty()
+      of '\L':
+        addNLIfEmpty()
+        socket.currPos.inc()
+        return
+      else:
+        if lastR:
+          socket.currPos.inc()
+          return
+        else:
+          result.add socket.buffer[socket.currPos]
+      socket.currPos.inc()
+  else:
+    result = ""
+    var c = ""
+    while true:
+      c = await recv(socket, 1, flags)
+      if c.len == 0:
+        return ""
+      if c == "\r":
+        c = await recv(socket, 1, flags + {TSocketFlags.Peek})
+        if c.len > 0 and c == "\L":
+          let dummy = await recv(socket, 1, flags)
+          assert dummy == "\L"
+        addNLIfEmpty()
+        return
+      elif c == "\L":
+        addNLIfEmpty()
+        return
+      add(result.string, c)
 
 proc bindAddr*(socket: PAsyncSocket, port = TPort(0), address = "") =
   ## Binds ``address``:``port`` to the socket.
@@ -220,7 +253,7 @@ proc listen*(socket: PAsyncSocket, backlog = SOMAXCONN) =
 
 proc close*(socket: PAsyncSocket) =
   ## Closes the socket.
-  socket.fd.TAsyncFD.close()
+  socket.fd.TAsyncFD.closeSocket()
   # TODO SSL
 
 when isMainModule:
@@ -241,7 +274,7 @@ when isMainModule:
           break
         else:
           echo("Got line: ", line)
-    main()
+    asyncCheck main()
   elif test == LowClient:
     var sock = newAsyncSocket()
     var f = connect(sock, "irc.freenode.net", TPort(6667))
diff --git a/lib/pure/collections/sequtils.nim b/lib/pure/collections/sequtils.nim
index f5db9d3fa..e760c5e02 100644
--- a/lib/pure/collections/sequtils.nim
+++ b/lib/pure/collections/sequtils.nim
@@ -47,19 +47,15 @@ proc concat*[T](seqs: varargs[seq[T]]): seq[T] =
       result[i] = itm
       inc(i)
 
-proc distnct*[T](seq1: seq[T]): seq[T] =
+proc deduplicate*[T](seq1: seq[T]): seq[T] =
   ## Returns a new sequence without duplicates.
   ##
-  ## This proc is `misspelled` on purpose to avoid a clash with the keyword
-  ## ``distinct`` used to `define a derived type incompatible with its base
-  ## type <manual.html#distinct-type>`_. Example:
-  ##
   ## .. code-block:: nimrod
   ##   let
   ##     dup1 = @[1, 1, 3, 4, 2, 2, 8, 1, 4]
   ##     dup2 = @["a", "a", "c", "d", "d"]
-  ##     unique1 = distnct(dup1)
-  ##     unique2 = distnct(dup2)
+  ##     unique1 = deduplicate(dup1)
+  ##     unique2 = deduplicate(dup2)
   ##   assert unique1 == @[1, 3, 4, 2, 8]
   ##   assert unique2 == @["a", "c", "d"]
   result = @[]
@@ -182,6 +178,24 @@ proc filter*[T](seq1: seq[T], pred: proc(item: T): bool {.closure.}): seq[T] =
   ##   assert f2 == @["yellow"]
   accumulateResult(filter(seq1, pred))
 
+proc keepIf*[T](seq1: var seq[T], pred: proc(item: T): bool {.closure.}) =
+  ## Keeps the items in the passed sequence if they fulfilled the predicate.
+  ## Same as the ``filter`` proc, but modifies the sequence directly.
+  ##
+  ## Example:
+  ##
+  ## .. code-block:: nimrod
+  ##   var floats = @[13.0, 12.5, 5.8, 2.0, 6.1, 9.9, 10.1]
+  ##   filter(floats, proc(x: float): bool = x > 10)
+  ##   assert floats == @[13.0, 12.5, 10.1]
+  var pos = 0
+  for i in 0 .. <len(seq1):
+    if pred(seq1[i]):
+      if pos != i:
+        seq1[pos] = seq1[i]
+      inc(pos)
+  setLen(seq1, pos)
+
 proc delete*[T](s: var seq[T], first=0, last=0) =
   ## Deletes in `s` the items at position `first` .. `last`. This modifies
   ## `s` itself, it does not return a copy.
@@ -252,6 +266,27 @@ template filterIt*(seq1, pred: expr): expr {.immediate.} =
     if pred: result.add(it)
   result
 
+template keepItIf*(varSeq, pred: expr) =
+  ## Convenience template around the ``keepIf`` proc to reduce typing.
+  ##
+  ## Unlike the `proc` version, the predicate needs to be an expression using
+  ## the ``it`` variable for testing, like: ``keepItIf("abcxyz", it == 'x')``.
+  ## Example:
+  ##
+  ## .. code-block:: nimrod
+  ##   var candidates = @["foo", "bar", "baz", "foobar"]
+  ##   keepItIf(candidates, it.len == 3 and it[0] == 'b')
+  ##   assert candidates == @["bar", "baz"]
+  var pos = 0
+  for i in 0 .. <len(varSeq):
+    let it {.inject.} = varSeq[i]
+    if pred:
+      if pos != i:
+        varSeq[pos] = varSeq[i]
+      inc(pos)
+  setLen(varSeq, pos)
+
+
 template toSeq*(iter: expr): expr {.immediate.} =
   ## Transforms any iterator into a sequence.
   ##
@@ -387,8 +422,8 @@ when isMainModule:
     let
       dup1 = @[1, 1, 3, 4, 2, 2, 8, 1, 4]
       dup2 = @["a", "a", "c", "d", "d"]
-      unique1 = distnct(dup1)
-      unique2 = distnct(dup2)
+      unique1 = deduplicate(dup1)
+      unique2 = deduplicate(dup2)
     assert unique1 == @[1, 3, 4, 2, 8]
     assert unique2 == @["a", "c", "d"]
 
@@ -418,6 +453,11 @@ when isMainModule:
       echo($n)
     # echoes 4, 8, 4 in separate lines
 
+  block: # keepIf test
+    var floats = @[13.0, 12.5, 5.8, 2.0, 6.1, 9.9, 10.1]
+    keepIf(floats, proc(x: float): bool = x > 10)
+    assert floats == @[13.0, 12.5, 10.1]
+
   block: # filterIt test
     let
       temperatures = @[-272.15, -2.0, 24.5, 44.31, 99.9, -113.44]
@@ -426,6 +466,11 @@ when isMainModule:
     assert acceptable == @[-2.0, 24.5, 44.31]
     assert notAcceptable == @[-272.15, 99.9, -113.44]
 
+  block: # keepItIf test
+    var candidates = @["foo", "bar", "baz", "foobar"]
+    keepItIf(candidates, it.len == 3 and it[0] == 'b')
+    assert candidates == @["bar", "baz"]
+
   block: # toSeq test
     let
       numeric = @[1, 2, 3, 4, 5, 6, 7, 8, 9]
diff --git a/lib/pure/collections/sets.nim b/lib/pure/collections/sets.nim
index bc249ed63..f1eed0004 100644
--- a/lib/pure/collections/sets.nim
+++ b/lib/pure/collections/sets.nim
@@ -112,6 +112,10 @@ proc incl*[A](s: var TSet[A], key: A) =
   ## includes an element `key` in `s`.
   inclImpl()
 
+proc incl*[A](s: var TSet[A], other: TSet[A]) =
+  ## includes everything in `other` in `s`
+  for item in other: incl(s, item)
+
 proc excl*[A](s: var TSet[A], key: A) =
   ## excludes `key` from the set `s`.
   var index = rawGet(s, key)
@@ -119,6 +123,10 @@ proc excl*[A](s: var TSet[A], key: A) =
     s.data[index].slot = seDeleted
     dec(s.counter)
 
+proc excl*[A](s: var TSet[A], other: TSet[A]) =
+  ## excludes everything in `other` from `s`.
+  for item in other: excl(s, item)
+
 proc containsOrIncl*[A](s: var TSet[A], key: A): bool =
   ## returns true if `s` contains `key`, otherwise `key` is included in `s`
   ## and false is returned.
@@ -147,6 +155,54 @@ proc `$`*[A](s: TSet[A]): string =
   ## The `$` operator for hash sets.
   dollarImpl()
 
+proc union*[A](s1, s2: TSet[A]): TSet[A] =
+  ## returns a new set of all items that are contained in at
+  ## least one of `s1` and `s2`
+  result = s1
+  incl(result, s2)
+
+proc intersection*[A](s1, s2: TSet[A]): TSet[A] =
+  ## returns a new set of all items that are contained in both `s1` and `s2`
+  result = initSet[A](min(s1.data.len, s2.data.len))
+  for item in s1:
+    if item in s2: incl(result, item)
+
+proc difference*[A](s1, s2: TSet[A]): TSet[A] =
+  ## returns a new set of all items that are contained in `s1`, but not in `s2`
+  result = initSet[A]()
+  for item in s1:
+    if not contains(s2, item):
+      incl(result, item)
+
+proc symmetricDifference*[A](s1, s2: TSet[A]): TSet[A] =
+  ## returns a new set of all items that are contained in either
+  ## `s1` or `s2`, but not both
+  result = s1
+  for item in s2:
+    if containsOrIncl(result, item): excl(result, item)
+
+proc `+`*[A](s1, s2: TSet[A]): TSet[A] {.inline.} =
+  ## alias for `union`
+  result = union(s1, s2)
+
+proc `*`*[A](s1, s2: TSet[A]): TSet[A] {.inline.} =
+  ## alias for `intersection`
+  result = intersection(s1, s2)
+
+proc `-`*[A](s1, s2: TSet[A]): TSet[A] {.inline.} =
+  ## alias for `difference`
+  result = difference(s1, s2)
+
+proc `-+-`*[A](s1, s2: TSet[A]): TSet[A] {.inline.} =
+  ## alias for `symmetricDifference`
+  result = symmetricDifference(s1, s2)
+
+proc disjoint*[A](s1, s2: TSet[A]): bool =
+  ## returns true iff `s1` and `s2` have no items in common
+  for item in s1:
+    if item in s2: return false
+  return true
+
 # ------------------------------ ordered set ------------------------------
 
 type
@@ -211,6 +267,10 @@ proc incl*[A](s: var TOrderedSet[A], key: A) =
   ## includes an element `key` in `s`.
   inclImpl()
 
+proc incl*[A](s: var TSet[A], other: TOrderedSet[A]) =
+  ## includes everything in `other` in `s`
+  for item in other: incl(s, item)
+
 proc containsOrIncl*[A](s: var TOrderedSet[A], key: A): bool =
   ## returns true if `s` contains `key`, otherwise `key` is included in `s`
   ## and false is returned.
diff --git a/lib/pure/collections/tables.nim b/lib/pure/collections/tables.nim
index 848f4b8ba..ce9df09e1 100644
--- a/lib/pure/collections/tables.nim
+++ b/lib/pure/collections/tables.nim
@@ -37,7 +37,8 @@
 ##     ## Piggyback on the already available string hash proc.
 ##     ##
 ##     ## Without this proc nothing works!
-##     result = hash(x.firstName & x.lastName)
+##     result = x.firstName.hash !& x.lastName.hash
+##     result = !$result
 ##
 ##   var
 ##     salaries = initTable[Person, int]()
@@ -145,6 +146,14 @@ proc mget*[A, B](t: var TTable[A, B], key: A): var B =
   if index >= 0: result = t.data[index].val
   else: raise newException(EInvalidKey, "key not found: " & $key)
 
+iterator allValues*[A, B](t: TTable[A, B]; key: A): B =
+  ## iterates over any value in the table `t` that belongs to the given `key`.
+  var h: THash = hash(key) and high(t.data)
+  while t.data[h].slot != seEmpty:
+    if t.data[h].key == key and t.data[h].slot == seFilled:
+      yield t.data[h].val
+    h = nextTry(h, high(t.data))
+
 proc hasKey*[A, B](t: TTable[A, B], key: A): bool =
   ## returns true iff `key` is in the table `t`.
   result = rawGet(t, key) >= 0
@@ -313,8 +322,7 @@ proc newTable*[A, B](initialSize=64): PTable[A, B] =
   new(result)
   result[] = initTable[A, B](initialSize)
 
-proc newTable*[A, B](pairs: openArray[tuple[key: A, 
-                    val: B]]): PTable[A, B] =
+proc newTable*[A, B](pairs: openArray[tuple[key: A, val: B]]): PTable[A, B] =
   ## creates a new hash table that contains the given `pairs`.
   new(result)
   result[] = toTable[A, B](pairs)
@@ -841,7 +849,8 @@ when isMainModule:
     ## Piggyback on the already available string hash proc.
     ##
     ## Without this proc nothing works!
-    result = hash(x.firstName & x.lastName)
+    result = x.firstName.hash !& x.lastName.hash
+    result = !$result
 
   var
     salaries = initTable[Person, int]()
diff --git a/lib/pure/complex.nim b/lib/pure/complex.nim
index df08ace72..1392b73aa 100644
--- a/lib/pure/complex.nim
+++ b/lib/pure/complex.nim
@@ -113,6 +113,45 @@ proc `*` *(x: TComplex, y: float): TComplex =
   result.im = x.im * y
 
 
+proc `+=` *(x: var TComplex, y: TComplex) =
+  ## Add `y` to `x`.
+  x.re += y.re
+  x.im += y.im
+
+proc `+=` *(x: var TComplex, y: float) =
+  ## Add `y` to the complex number `x`.
+  x.re += y
+
+proc `-=` *(x: var TComplex, y: TComplex) =
+  ## Subtract `y` from `x`.
+  x.re -= y.re
+  x.im -= y.im
+
+proc `-=` *(x: var TComplex, y: float) =
+  ## Subtract `y` from the complex number `x`.
+  x.re -= y
+
+proc `*=` *(x: var TComplex, y: TComplex) =
+  ## Multiply `y` to `x`.
+  let im = x.im * y.re + x.re * y.im
+  x.re = x.re * y.re - x.im * y.im
+  x.im = im
+
+proc `*=` *(x: var TComplex, y: float) =
+  ## Multiply `y` to the complex number `x`.
+  x.re *= y
+  x.im *= y
+
+proc `/=` *(x: var TComplex, y: TComplex) =
+  ## Divide `x` by `y` in place.
+  x = x / y
+
+proc `/=` *(x : var TComplex, y: float) =
+  ## Divide complex `x` by float `y` in place.
+  x.re /= y
+  x.im /= y
+
+
 proc abs*(z: TComplex): float =
   ## Return the distance from (0,0) to `z`.
 
diff --git a/lib/pure/concurrency/cpuinfo.nim b/lib/pure/concurrency/cpuinfo.nim
new file mode 100644
index 000000000..dfa819f64
--- /dev/null
+++ b/lib/pure/concurrency/cpuinfo.nim
@@ -0,0 +1,58 @@
+#
+#
+#            Nimrod's Runtime Library
+#        (c) Copyright 2014 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module implements procs to determine the number of CPUs / cores.
+
+include "system/inclrtl"
+
+import strutils, os
+
+when not defined(windows):
+  import posix
+
+when defined(linux):
+  import linux
+
+when defined(macosx) or defined(bsd):
+  const
+    CTL_HW = 6
+    HW_AVAILCPU = 25
+    HW_NCPU = 3
+  proc sysctl(x: ptr array[0..3, cint], y: cint, z: pointer,
+              a: var csize, b: pointer, c: int): cint {.
+             importc: "sysctl", header: "<sys/sysctl.h>".}
+
+proc countProcessors*(): int {.rtl, extern: "ncpi$1".} =
+  ## returns the numer of the processors/cores the machine has.
+  ## Returns 0 if it cannot be detected.
+  when defined(windows):
+    var x = getEnv("NUMBER_OF_PROCESSORS")
+    if x.len > 0: result = parseInt(x.string)
+  elif defined(macosx) or defined(bsd):
+    var
+      mib: array[0..3, cint]
+      numCPU: int
+      len: csize
+    mib[0] = CTL_HW
+    mib[1] = HW_AVAILCPU
+    len = sizeof(numCPU)
+    discard sysctl(addr(mib), 2, addr(numCPU), len, nil, 0)
+    if numCPU < 1:
+      mib[1] = HW_NCPU
+      discard sysctl(addr(mib), 2, addr(numCPU), len, nil, 0)
+    result = numCPU
+  elif defined(hpux):
+    result = mpctl(MPC_GETNUMSPUS, nil, nil)
+  elif defined(irix):
+    var SC_NPROC_ONLN {.importc: "_SC_NPROC_ONLN", header: "<unistd.h>".}: cint
+    result = sysconf(SC_NPROC_ONLN)
+  else:
+    result = sysconf(SC_NPROCESSORS_ONLN)
+  if result <= 0: result = 1
+
diff --git a/lib/pure/concurrency/cpuload.nim b/lib/pure/concurrency/cpuload.nim
new file mode 100644
index 000000000..3cf6a7392
--- /dev/null
+++ b/lib/pure/concurrency/cpuload.nim
@@ -0,0 +1,96 @@
+#
+#
+#            Nimrod's Runtime Library
+#        (c) Copyright 2014 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module implements a helper for a thread pool to determine whether
+## creating a thread is a good idea.
+
+when defined(windows):
+  import winlean, os, strutils, math
+
+  proc `-`(a, b: TFILETIME): int64 = a.rdFileTime - b.rdFileTime
+elif defined(linux):
+  from cpuinfo import countProcessors
+
+type
+  ThreadPoolAdvice* = enum
+    doNothing,
+    doCreateThread,  # create additional thread for throughput
+    doShutdownThread # too many threads are busy, shutdown one
+
+  ThreadPoolState* = object
+    when defined(windows):
+      prevSysKernel, prevSysUser, prevProcKernel, prevProcUser: TFILETIME
+    calls*: int
+
+proc advice*(s: var ThreadPoolState): ThreadPoolAdvice =
+  when defined(windows):
+    var
+      sysIdle, sysKernel, sysUser,
+        procCreation, procExit, procKernel, procUser: TFILETIME
+    if getSystemTimes(sysIdle, sysKernel, sysUser) == 0 or
+        getProcessTimes(THandle(-1), procCreation, procExit, 
+                        procKernel, procUser) == 0:
+      return doNothing
+    if s.calls > 0:
+      let
+        sysKernelDiff = sysKernel - s.prevSysKernel
+        sysUserDiff = sysUser - s.prevSysUser
+
+        procKernelDiff = procKernel - s.prevProcKernel
+        procUserDiff = procUser - s.prevProcUser
+
+        sysTotal = int(sysKernelDiff + sysUserDiff)
+        procTotal = int(procKernelDiff + procUserDiff)
+      # total CPU usage < 85% --> create a new worker thread.
+      # Measurements show that 100% and often even 90% is not reached even
+      # if all my cores are busy.
+      if sysTotal == 0 or procTotal / sysTotal < 0.85:
+        result = doCreateThread
+    s.prevSysKernel = sysKernel
+    s.prevSysUser = sysUser
+    s.prevProcKernel = procKernel
+    s.prevProcUser = procUser
+  elif defined(linux):
+    proc fscanf(c: TFile, frmt: cstring) {.varargs, importc, 
+      header: "<stdio.h>".}
+
+    var f = open("/proc/loadavg")
+    var b: float
+    var busy, total: int
+    fscanf(f,"%lf %lf %lf %ld/%ld",
+           addr b, addr b, addr b, addr busy, addr total)
+    f.close()
+    let cpus = countProcessors()
+    if busy-1 < cpus:
+      result = doCreateThread
+    elif busy-1 >= cpus*2:
+      result = doShutdownThread
+    else:
+      result = doNothing
+  else:
+    # XXX implement this for other OSes
+    result = doNothing
+  inc s.calls
+
+when isMainModule:
+  proc busyLoop() =
+    while true:
+      discard random(80)
+      os.sleep(100)
+
+  spawn busyLoop()
+  spawn busyLoop()
+  spawn busyLoop()
+  spawn busyLoop()
+
+  var s: ThreadPoolState
+
+  for i in 1 .. 70:
+    echo advice(s)
+    os.sleep(1000)
diff --git a/lib/pure/concurrency/threadpool.nim b/lib/pure/concurrency/threadpool.nim
new file mode 100644
index 000000000..fd1041918
--- /dev/null
+++ b/lib/pure/concurrency/threadpool.nim
@@ -0,0 +1,378 @@
+#
+#
+#            Nimrod's Runtime Library
+#        (c) Copyright 2014 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## Implements Nimrod's 'spawn'.
+
+import cpuinfo, cpuload, locks
+
+{.push stackTrace:off.}
+
+type
+  CondVar = object
+    c: TCond
+    L: TLock
+    counter: int
+
+proc createCondVar(): CondVar =
+  initCond(result.c)
+  initLock(result.L)
+
+proc destroyCondVar(cv: var CondVar) {.inline.} =
+  deinitCond(cv.c)
+  deinitLock(cv.L)
+
+proc await(cv: var CondVar) =
+  acquire(cv.L)
+  while cv.counter <= 0:
+    wait(cv.c, cv.L)
+  dec cv.counter
+  release(cv.L)
+
+proc signal(cv: var CondVar) =
+  acquire(cv.L)
+  inc cv.counter
+  release(cv.L)
+  signal(cv.c)
+
+const CacheLineSize = 32 # true for most archs
+
+type
+  Barrier {.compilerProc.} = object
+    entered: int
+    cv: CondVar # condvar takes 3 words at least
+    when sizeof(int) < 8:
+      cacheAlign: array[CacheLineSize-4*sizeof(int), byte]
+    left: int
+    cacheAlign2: array[CacheLineSize-sizeof(int), byte]
+    interest: bool ## wether the master is interested in the "all done" event
+
+proc barrierEnter(b: ptr Barrier) {.compilerProc, inline.} =
+  # due to the signaling between threads, it is ensured we are the only
+  # one with access to 'entered' so we don't need 'atomicInc' here:
+  inc b.entered
+  # also we need no 'fence' instructions here as soon 'nimArgsPassingDone'
+  # will be called which already will perform a fence for us.
+
+proc barrierLeave(b: ptr Barrier) {.compilerProc, inline.} =
+  atomicInc b.left
+  when not defined(x86): fence()
+  if b.interest and b.left == b.entered: signal(b.cv)
+
+proc openBarrier(b: ptr Barrier) {.compilerProc, inline.} =
+  b.entered = 0
+  b.left = 0
+  b.interest = false
+
+proc closeBarrier(b: ptr Barrier) {.compilerProc.} =
+  fence()
+  if b.left != b.entered:
+    b.cv = createCondVar()
+    fence()
+    b.interest = true
+    fence()
+    while b.left != b.entered: await(b.cv)
+    destroyCondVar(b.cv)
+
+{.pop.}
+
+# ----------------------------------------------------------------------------
+
+type
+  foreign* = object ## a region that indicates the pointer comes from a
+                    ## foreign thread heap.
+  AwaitInfo = object
+    cv: CondVar
+    idx: int
+
+  FlowVarBase* = ref FlowVarBaseObj ## untyped base class for 'FlowVar[T]'
+  FlowVarBaseObj = object of TObject
+    ready, usesCondVar: bool
+    cv: CondVar #\
+    # for 'awaitAny' support
+    ai: ptr AwaitInfo
+    idx: int
+    data: pointer  # we incRef and unref it to keep it alive
+    owner: pointer # ptr Worker
+
+  FlowVarObj[T] = object of FlowVarBaseObj
+    blob: T
+
+  FlowVar*{.compilerProc.}[T] = ref FlowVarObj[T] ## a data flow variable
+
+  ToFreeQueue = object
+    len: int
+    lock: TLock
+    empty: TCond
+    data: array[512, pointer]
+
+  WorkerProc = proc (thread, args: pointer) {.nimcall, gcsafe.}
+  Worker = object
+    taskArrived: CondVar
+    taskStarted: CondVar #\
+    # task data:
+    f: WorkerProc
+    data: pointer
+    ready: bool # put it here for correct alignment!
+    initialized: bool # whether it has even been initialized
+    shutdown: bool # the pool requests to shut down this worker thread
+    q: ToFreeQueue
+
+proc await*(fv: FlowVarBase) =
+  ## waits until the value for the flowVar arrives. Usually it is not necessary
+  ## to call this explicitly.
+  if fv.usesCondVar:
+    fv.usesCondVar = false
+    await(fv.cv)
+    destroyCondVar(fv.cv)
+
+proc finished(fv: FlowVarBase) =
+  doAssert fv.ai.isNil, "flowVar is still attached to an 'awaitAny'"
+  # we have to protect against the rare cases where the owner of the flowVar
+  # simply disregards the flowVar and yet the "flowVarr" has not yet written
+  # anything to it:
+  await(fv)
+  if fv.data.isNil: return
+  let owner = cast[ptr Worker](fv.owner)
+  let q = addr(owner.q)
+  var waited = false
+  while true:
+    acquire(q.lock)
+    if q.len < q.data.len:
+      q.data[q.len] = fv.data
+      inc q.len
+      release(q.lock)
+      break
+    else:
+      # the queue is exhausted! We block until it has been cleaned:
+      release(q.lock)
+      wait(q.empty, q.lock)
+      waited = true
+  fv.data = nil
+  # wakeup other potentially waiting threads:
+  if waited: signal(q.empty)
+
+proc cleanFlowVars(w: ptr Worker) =
+  let q = addr(w.q)
+  acquire(q.lock)
+  for i in 0 .. <q.len:
+    GC_unref(cast[PObject](q.data[i]))
+  q.len = 0
+  release(q.lock)
+  signal(q.empty)
+
+proc fvFinalizer[T](fv: FlowVar[T]) = finished(fv)
+
+proc nimCreateFlowVar[T](): FlowVar[T] {.compilerProc.} =
+  new(result, fvFinalizer)
+
+proc nimFlowVarCreateCondVar(fv: FlowVarBase) {.compilerProc.} =
+  fv.cv = createCondVar()
+  fv.usesCondVar = true
+
+proc nimFlowVarSignal(fv: FlowVarBase) {.compilerProc.} =
+  if fv.ai != nil:
+    acquire(fv.ai.cv.L)
+    fv.ai.idx = fv.idx
+    inc fv.ai.cv.counter
+    release(fv.ai.cv.L)
+    signal(fv.ai.cv.c)
+  if fv.usesCondVar: signal(fv.cv)
+
+proc awaitAndThen*[T](fv: FlowVar[T]; action: proc (x: T) {.closure.}) =
+  ## blocks until the ``fv`` is available and then passes its value
+  ## to ``action``. Note that due to Nimrod's parameter passing semantics this
+  ## means that ``T`` doesn't need to be copied and so ``awaitAndThen`` can
+  ## sometimes be more efficient than ``^``.
+  await(fv)
+  when T is string or T is seq:
+    action(cast[T](fv.data))
+  elif T is ref:
+    {.error: "'awaitAndThen' not available for FlowVar[ref]".}
+  else:
+    action(fv.blob)
+  finished(fv)
+
+proc `^`*[T](fv: FlowVar[ref T]): foreign ptr T =
+  ## blocks until the value is available and then returns this value.
+  await(fv)
+  result = cast[foreign ptr T](fv.data)
+
+proc `^`*[T](fv: FlowVar[T]): T =
+  ## blocks until the value is available and then returns this value.
+  await(fv)
+  when T is string or T is seq:
+    result = cast[T](fv.data)
+  else:
+    result = fv.blob
+
+proc awaitAny*(flowVars: openArray[FlowVarBase]): int =
+  ## awaits any of the given flowVars. Returns the index of one flowVar for
+  ## which a value arrived. A flowVar only supports one call to 'awaitAny' at
+  ## the same time. That means if you await([a,b]) and await([b,c]) the second
+  ## call will only await 'c'. If there is no flowVar left to be able to wait
+  ## on, -1 is returned.
+  ## **Note**: This results in non-deterministic behaviour and so should be
+  ## avoided.
+  var ai: AwaitInfo
+  ai.cv = createCondVar()
+  var conflicts = 0
+  for i in 0 .. flowVars.high:
+    if cas(addr flowVars[i].ai, nil, addr ai):
+      flowVars[i].idx = i
+    else:
+      inc conflicts
+  if conflicts < flowVars.len:
+    await(ai.cv)
+    result = ai.idx
+    for i in 0 .. flowVars.high:
+      discard cas(addr flowVars[i].ai, addr ai, nil)
+  else:
+    result = -1
+  destroyCondVar(ai.cv)
+
+proc nimArgsPassingDone(p: pointer) {.compilerProc.} =
+  let w = cast[ptr Worker](p)
+  signal(w.taskStarted)
+
+const
+  MaxThreadPoolSize* = 256 ## maximal size of the thread pool. 256 threads
+                           ## should be good enough for anybody ;-)
+
+var
+  currentPoolSize: int
+  maxPoolSize = MaxThreadPoolSize
+  minPoolSize = 4
+  gSomeReady = createCondVar()
+  readyWorker: ptr Worker
+
+proc slave(w: ptr Worker) {.thread.} =
+  while true:
+    w.ready = true
+    readyWorker = w
+    signal(gSomeReady)
+    await(w.taskArrived)
+    assert(not w.ready)
+    w.f(w, w.data)
+    if w.q.len != 0: w.cleanFlowVars
+    if w.shutdown:
+      w.shutdown = false
+      atomicDec currentPoolSize
+
+proc setMinPoolSize*(size: range[1..MaxThreadPoolSize]) =
+  ## sets the minimal thread pool size. The default value of this is 4.
+  minPoolSize = size
+
+proc setMaxPoolSize*(size: range[1..MaxThreadPoolSize]) =
+  ## sets the minimal thread pool size. The default value of this
+  ## is ``MaxThreadPoolSize``.
+  maxPoolSize = size
+
+var
+  workers: array[MaxThreadPoolSize, TThread[ptr Worker]]
+  workersData: array[MaxThreadPoolSize, Worker]
+
+proc activateThread(i: int) {.noinline.} =
+  workersData[i].taskArrived = createCondVar()
+  workersData[i].taskStarted = createCondVar()
+  workersData[i].initialized = true
+  initCond(workersData[i].q.empty)
+  initLock(workersData[i].q.lock)
+  createThread(workers[i], slave, addr(workersData[i]))
+
+proc setup() =
+  currentPoolSize = min(countProcessors(), MaxThreadPoolSize)
+  readyWorker = addr(workersData[0])
+  for i in 0.. <currentPoolSize: activateThread(i)
+
+proc preferSpawn*(): bool =
+  ## Use this proc to determine quickly if a 'spawn' or a direct call is
+  ## preferable. If it returns 'true' a 'spawn' may make sense. In general
+  ## it is not necessary to call this directly; use 'spawnX' instead.
+  result = gSomeReady.counter > 0
+
+proc spawn*(call: expr): expr {.magic: "Spawn".}
+  ## always spawns a new task, so that the 'call' is never executed on
+  ## the calling thread. 'call' has to be proc call 'p(...)' where 'p'
+  ## is gcsafe and has a return type that is either 'void' or compatible
+  ## with ``FlowVar[T]``.
+
+template spawnX*(call: expr): expr =
+  ## spawns a new task if a CPU core is ready, otherwise executes the
+  ## call in the calling thread. Usually it is advised to
+  ## use 'spawn' in order to not block the producer for an unknown
+  ## amount of time. 'call' has to be proc call 'p(...)' where 'p'
+  ## is gcsafe and has a return type that is either 'void' or compatible
+  ## with ``FlowVar[T]``.
+  (if preferSpawn(): spawn call else: call)
+
+proc parallel*(body: stmt) {.magic: "Parallel".}
+  ## a parallel section can be used to execute a block in parallel. ``body``
+  ## has to be in a DSL that is a particular subset of the language. Please
+  ## refer to the manual for further information.
+
+var
+  state: ThreadPoolState
+  stateLock: TLock
+
+initLock stateLock
+
+proc selectWorker(w: ptr Worker; fn: WorkerProc; data: pointer): bool =
+  if cas(addr w.ready, true, false):
+    w.data = data
+    w.f = fn
+    signal(w.taskArrived)
+    await(w.taskStarted)
+    result = true
+
+proc nimSpawn(fn: WorkerProc; data: pointer) {.compilerProc.} =
+  # implementation of 'spawn' that is used by the code generator.
+  while true:
+    if selectWorker(readyWorker, fn, data): return
+    for i in 0.. <currentPoolSize:
+      if selectWorker(addr(workersData[i]), fn, data): return
+    # determine what to do, but keep in mind this is expensive too:
+    # state.calls < maxPoolSize: warmup phase
+    # (state.calls and 127) == 0: periodic check
+    if state.calls < maxPoolSize or (state.calls and 127) == 0:
+      # ensure the call to 'advice' is atomic:
+      if tryAcquire(stateLock):
+        case advice(state)
+        of doNothing: discard
+        of doCreateThread:
+          if currentPoolSize < maxPoolSize:
+            if not workersData[currentPoolSize].initialized:
+              activateThread(currentPoolSize)
+            let w = addr(workersData[currentPoolSize])
+            atomicInc currentPoolSize
+            if selectWorker(w, fn, data):
+              release(stateLock)
+              return
+            # else we didn't succeed but some other thread, so do nothing.
+        of doShutdownThread:
+          if currentPoolSize > minPoolSize:
+            let w = addr(workersData[currentPoolSize-1])
+            w.shutdown = true
+          # we don't free anything here. Too dangerous.
+        release(stateLock)
+      # else the acquire failed, but this means some
+      # other thread succeeded, so we don't need to do anything here.
+    await(gSomeReady)
+
+proc sync*() =
+  ## a simple barrier to wait for all spawn'ed tasks. If you need more elaborate
+  ## waiting, you have to use an explicit barrier.
+  while true:
+    var allReady = true
+    for i in 0 .. <currentPoolSize:
+      if not allReady: break
+      allReady = allReady and workersData[i].ready
+    if allReady: break
+    await(gSomeReady)
+
+setup()
diff --git a/lib/pure/encodings.nim b/lib/pure/encodings.nim
index 94d21ed4e..633ea6020 100644
--- a/lib/pure/encodings.nim
+++ b/lib/pure/encodings.nim
@@ -41,6 +41,7 @@ when defined(windows):
 
   const 
     winEncodings = [
+      (1,   "OEMCP"), # current OEM codepage
       (037, "IBM037"), # IBM EBCDIC US-Canada 
       (437, "IBM437"), # OEM United States 
       (500, "IBM500"), # IBM EBCDIC International 
diff --git a/lib/pure/fsmonitor.nim b/lib/pure/fsmonitor.nim
index d6584c1a0..b35466771 100644
--- a/lib/pure/fsmonitor.nim
+++ b/lib/pure/fsmonitor.nim
@@ -119,8 +119,8 @@ proc getEvent(m: PFSMonitor, fd: cint): seq[TMonitorEvent] =
     var mev: TMonitorEvent
     mev.wd = event.wd
     if event.len.int != 0:
-      mev.name = newString(event.len.int)
-      copyMem(addr(mev.name[0]), addr event.name, event.len.int-1)
+      let cstr = event.name.addr.cstring
+      mev.name = $cstr
     else:
       mev.name = ""
     
@@ -211,4 +211,4 @@ when isMainModule:
       
   while true:
     if not disp.poll(): break
-  
\ No newline at end of file
+  
diff --git a/lib/pure/future.nim b/lib/pure/future.nim
index e0e4c4176..b7df05207 100644
--- a/lib/pure/future.nim
+++ b/lib/pure/future.nim
@@ -18,7 +18,6 @@ proc createProcType(p, b: PNimrodNode): PNimrodNode {.compileTime.} =
   result = newNimNode(nnkProcTy)
   var formalParams = newNimNode(nnkFormalParams)
 
-  expectKind(b, nnkIdent)
   formalParams.add b
 
   case p.kind
diff --git a/lib/pure/hashes.nim b/lib/pure/hashes.nim
index 5784a96c1..740355e55 100644
--- a/lib/pure/hashes.nim
+++ b/lib/pure/hashes.nim
@@ -8,7 +8,34 @@
 #
 
 ## This module implements efficient computations of hash values for diverse
-## Nimrod types.
+## Nimrod types. All the procs are based on these two building blocks: the `!&
+## proc <#!&>`_ used to start or mix a hash value, and the `!$ proc <#!$>`_
+## used to *finish* the hash value.  If you want to implement hash procs for
+## your custom types you will end up writing the following kind of skeleton of
+## code:
+##
+## .. code-block:: nimrod
+##  proc hash(x: Something): THash =
+##    ## Computes a THash from `x`.
+##    var h: THash = 0
+##    # Iterate over parts of `x`.
+##    for xAtom in x:
+##      # Mix the atom with the partial hash.
+##      h = h !& xAtom
+##    # Finish the hash.
+##    result = !$h
+##
+## If your custom types contain fields for which there already is a hash proc,
+## like for example objects made up of ``strings``, you can simply hash
+## together the hash value of the individual fields:
+##
+## .. code-block:: nimrod
+##  proc hash(x: Something): THash =
+##    ## Computes a THash from `x`.
+##    var h: THash = 0
+##    h = h &! hash(x.foo)
+##    h = h &! hash(x.bar)
+##    result = !$h
 
 import 
   strutils
diff --git a/lib/pure/httpclient.nim b/lib/pure/httpclient.nim
index be06a7b8e..9bacc80d6 100644
--- a/lib/pure/httpclient.nim
+++ b/lib/pure/httpclient.nim
@@ -654,7 +654,7 @@ when isMainModule:
       resp = await client.request("http://nimrod-lang.org/download.html")
       echo("Got response: ", resp.status)
 
-    main()
+    asyncCheck main()
     runForever()
 
   else:
diff --git a/lib/pure/json.nim b/lib/pure/json.nim
index 4250847e5..508e564c5 100644
--- a/lib/pure/json.nim
+++ b/lib/pure/json.nim
@@ -619,6 +619,44 @@ proc `%`*(elements: openArray[PJsonNode]): PJsonNode =
   newSeq(result.elems, elements.len)
   for i, p in pairs(elements): result.elems[i] = p
 
+proc `==`* (a,b: PJsonNode): bool =
+  ## Check two nodes for equality
+  if a.kind != b.kind: false
+  else:
+    case a.kind
+    of JString:
+      a.str == b.str
+    of JInt:
+      a.num == b.num
+    of JFloat:
+      a.fnum == b.fnum
+    of JBool:
+      a.bval == b.bval
+    of JNull:
+      true
+    of JArray:
+      a.elems == b.elems
+    of JObject:
+      a.fields == b.fields
+
+proc hash* (n:PJsonNode): THash =
+  ## Compute the hash for a JSON node
+  case n.kind
+  of JArray:
+    result = hash(n.elems)
+  of JObject:
+    result = hash(n.fields)
+  of JInt:
+    result = hash(n.num)
+  of JFloat:
+    result = hash(n.fnum)
+  of JBool:
+    result = hash(n.bval.int)
+  of JString:
+    result = hash(n.str)
+  of JNull:
+    result = hash(0)
+
 proc len*(n: PJsonNode): int = 
   ## If `n` is a `JArray`, it returns the number of elements.
   ## If `n` is a `JObject`, it returns the number of pairs.
@@ -629,7 +667,9 @@ proc len*(n: PJsonNode): int =
   else: discard
 
 proc `[]`*(node: PJsonNode, name: string): PJsonNode =
-  ## Gets a field from a `JObject`. Returns nil if the key is not found.
+  ## Gets a field from a `JObject`, which must not be nil.
+  ## If the value at `name` does not exist, returns nil
+  assert(not isNil(node))
   assert(node.kind == JObject)
   for key, item in items(node.fields):
     if key == name:
@@ -637,7 +677,9 @@ proc `[]`*(node: PJsonNode, name: string): PJsonNode =
   return nil
   
 proc `[]`*(node: PJsonNode, index: int): PJsonNode =
-  ## Gets the node at `index` in an Array.
+  ## Gets the node at `index` in an Array. Result is undefined if `index`
+  ## is out of bounds
+  assert(not isNil(node))
   assert(node.kind == JArray)
   return node.elems[index]
 
@@ -671,6 +713,23 @@ proc `[]=`*(obj: PJsonNode, key: string, val: PJsonNode) =
       return
   obj.fields.add((key, val))
 
+proc `{}`*(node: PJsonNode, key: string): PJsonNode =
+  ## Transverses the node and gets the given value. If any of the
+  ## names does not exist, returns nil
+  result = node
+  if isNil(node): return nil
+  result = result[key]
+
+proc `{}=`*(node: PJsonNode, names: varargs[string], value: PJsonNode) =
+  ## Transverses the node and tries to set the value at the given location
+  ## to `value` If any of the names are missing, they are added
+  var node = node
+  for i in 0..(names.len-2):
+    if isNil(node[names[i]]):
+      node[names[i]] = newJObject()
+    node = node[names[i]]
+  node[names[names.len-1]] = value
+
 proc delete*(obj: PJsonNode, key: string) =
   ## Deletes ``obj[key]`` preserving the order of the other (key, value)-pairs.
   assert(obj.kind == JObject)
@@ -996,6 +1055,28 @@ when isMainModule:
     raise newException(EInvalidValue, "That line was expected to fail")
   except EInvalidIndex: echo()
 
+  let testJson = parseJson"""{ "a": [1, 2, 3, 4], "b": "asd" }"""
+  # nil passthrough
+  assert(testJson{"doesnt_exist"}{"anything"}.isNil)
+  testJson{["c", "d"]} = %true
+  assert(testJson["c"]["d"].bval)
+
+  # Bounds checking
+  try:
+    let a = testJson["a"][9]
+    assert(false, "EInvalidIndex not thrown")
+  except EInvalidIndex:
+    discard
+  try:
+    let a = testJson["a"][-1]
+    assert(false, "EInvalidIndex not thrown")
+  except EInvalidIndex:
+    discard
+  try:
+    assert(testJson["a"][0].num == 1, "Index doesn't correspond to its value")
+  except:
+    assert(false, "EInvalidIndex thrown for valid index")
+
   discard """
   while true:
     var json = stdin.readLine()
diff --git a/lib/pure/math.nim b/lib/pure/math.nim
index 78ea02cbf..2f7a696b9 100644
--- a/lib/pure/math.nim
+++ b/lib/pure/math.nim
@@ -10,7 +10,8 @@
 ##   Constructive mathematics is naturally typed. -- Simon Thompson
 ## 
 ## Basic math routines for Nimrod.
-## This module is available for the JavaScript target.
+## This module is available for the `JavaScript target
+## <backends.html#the-javascript-target>`_.
 
 include "system/inclrtl"
 
diff --git a/lib/pure/net.nim b/lib/pure/net.nim
index 2f1a6fa46..ddc2bbe2d 100644
--- a/lib/pure/net.nim
+++ b/lib/pure/net.nim
@@ -11,7 +11,7 @@
 
 {.deadCodeElim: on.}
 import rawsockets, os, strutils, unsigned, parseutils, times
-export TPort
+export TPort, `$`
 
 const useWinVersion = defined(Windows) or defined(nimdoc)
 
@@ -350,6 +350,30 @@ type
 
   ETimeout* = object of ESynch
 
+  TSocketFlags* {.pure.} = enum
+    Peek,
+    SafeDisconn ## Ensures disconnection exceptions (ECONNRESET, EPIPE etc) are not thrown.
+
+proc isDisconnectionError*(flags: set[TSocketFlags],
+    lastError: TOSErrorCode): bool =
+  ## Determines whether ``lastError`` is a disconnection error. Only does this
+  ## if flags contains ``SafeDisconn``.
+  when useWinVersion:
+    TSocketFlags.SafeDisconn in flags and
+      lastError.int32 in {WSAECONNRESET, WSAECONNABORTED, WSAENETRESET,
+                          WSAEDISCON}
+  else:
+    TSocketFlags.SafeDisconn in flags and
+      lastError.int32 in {ECONNRESET, EPIPE, ENETRESET} 
+
+proc toOSFlags*(socketFlags: set[TSocketFlags]): cint =
+  ## Converts the flags into the underlying OS representation.
+  for f in socketFlags:
+    case f
+    of TSocketFlags.Peek:
+      result = result or MSG_PEEK
+    of TSocketFlags.SafeDisconn: continue
+
 proc createSocket(fd: TSocketHandle, isBuff: bool): PSocket =
   assert fd != osInvalidSocket
   new(result)
@@ -470,7 +494,8 @@ when defined(ssl):
     if SSLSetFd(socket.sslHandle, socket.fd) != 1:
       SSLError()
 
-proc socketError*(socket: PSocket, err: int = -1, async = false) =
+proc socketError*(socket: PSocket, err: int = -1, async = false,
+                  lastError = (-1).TOSErrorCode) =
   ## Raises an EOS error based on the error code returned by ``SSLGetError``
   ## (for SSL sockets) and ``osLastError`` otherwise.
   ##
@@ -500,17 +525,17 @@ proc socketError*(socket: PSocket, err: int = -1, async = false) =
         else: SSLError("Unknown Error")
   
   if err == -1 and not (when defined(ssl): socket.isSSL else: false):
-    let lastError = osLastError()
+    let lastE = if lastError.int == -1: osLastError() else: lastError
     if async:
       when useWinVersion:
-        if lastError.int32 == WSAEWOULDBLOCK:
+        if lastE.int32 == WSAEWOULDBLOCK:
           return
-        else: osError(lastError)
+        else: osError(lastE)
       else:
-        if lastError.int32 == EAGAIN or lastError.int32 == EWOULDBLOCK:
+        if lastE.int32 == EAGAIN or lastE.int32 == EWOULDBLOCK:
           return
-        else: osError(lastError)
-    else: osError(lastError)
+        else: osError(lastE)
+    else: osError(lastE)
 
 proc listen*(socket: PSocket, backlog = SOMAXCONN) {.tags: [FReadIO].} =
   ## Marks ``socket`` as accepting connections. 
@@ -881,7 +906,8 @@ proc recv*(socket: PSocket, data: pointer, size: int, timeout: int): int {.
   
   result = read
 
-proc recv*(socket: PSocket, data: var string, size: int, timeout = -1): int =
+proc recv*(socket: PSocket, data: var string, size: int, timeout = -1,
+           flags = {TSocketFlags.SafeDisconn}): int =
   ## Higher-level version of ``recv``.
   ##
   ## When 0 is returned the socket's connection has been closed.
@@ -893,11 +919,15 @@ proc recv*(socket: PSocket, data: var string, size: int, timeout = -1): int =
   ## within the time specified an ETimeout exception will be raised.
   ##
   ## **Note**: ``data`` must be initialised.
+  ##
+  ## **Warning**: Only the ``SafeDisconn`` flag is currently supported.
   data.setLen(size)
   result = recv(socket, cstring(data), size, timeout)
   if result < 0:
     data.setLen(0)
-    socket.socketError(result)
+    let lastError = osLastError()
+    if flags.isDisconnectionError(lastError): return
+    socket.socketError(result, lastError = lastError)
   data.setLen(result)
 
 proc peekChar(socket: PSocket, c: var char): int {.tags: [FReadIO].} =
@@ -920,7 +950,8 @@ proc peekChar(socket: PSocket, c: var char): int {.tags: [FReadIO].} =
         return
     result = recv(socket.fd, addr(c), 1, MSG_PEEK)
 
-proc readLine*(socket: PSocket, line: var TaintedString, timeout = -1) {.
+proc readLine*(socket: PSocket, line: var TaintedString, timeout = -1,
+               flags = {TSocketFlags.SafeDisconn}) {.
   tags: [FReadIO, FTime].} =
   ## Reads a line of data from ``socket``.
   ##
@@ -934,11 +965,18 @@ proc readLine*(socket: PSocket, line: var TaintedString, timeout = -1) {.
   ##
   ## A timeout can be specified in miliseconds, if data is not received within
   ## the specified time an ETimeout exception will be raised.
+  ##
+  ## **Warning**: Only the ``SafeDisconn`` flag is currently supported.
   
   template addNLIfEmpty(): stmt =
     if line.len == 0:
       line.add("\c\L")
 
+  template raiseSockError(): stmt {.dirty, immediate.} =
+    let lastError = osLastError()
+    if flags.isDisconnectionError(lastError): setLen(line.string, 0); return
+    socket.socketError(n, lastError = lastError)
+
   var waited = 0.0
 
   setLen(line.string, 0)
@@ -946,14 +984,14 @@ proc readLine*(socket: PSocket, line: var TaintedString, timeout = -1) {.
     var c: char
     discard waitFor(socket, waited, timeout, 1, "readLine")
     var n = recv(socket, addr(c), 1)
-    if n < 0: socket.socketError()
-    elif n == 0: return
+    if n < 0: raiseSockError()
+    elif n == 0: setLen(line.string, 0); return
     if c == '\r':
       discard waitFor(socket, waited, timeout, 1, "readLine")
       n = peekChar(socket, c)
       if n > 0 and c == '\L':
         discard recv(socket, addr(c), 1)
-      elif n <= 0: socket.socketError()
+      elif n <= 0: raiseSockError()
       addNLIfEmpty()
       return
     elif c == '\L': 
@@ -1021,11 +1059,14 @@ proc send*(socket: PSocket, data: pointer, size: int): int {.
       const MSG_NOSIGNAL = 0
     result = send(socket.fd, data, size, int32(MSG_NOSIGNAL))
 
-proc send*(socket: PSocket, data: string) {.tags: [FWriteIO].} =
+proc send*(socket: PSocket, data: string,
+           flags = {TSocketFlags.SafeDisconn}) {.tags: [FWriteIO].} =
   ## sends data to a socket.
   let sent = send(socket, cstring(data), data.len)
   if sent < 0:
-    socketError(socket)
+    let lastError = osLastError()
+    if flags.isDisconnectionError(lastError): return
+    socketError(socket, lastError = lastError)
 
   if sent != data.len:
     raise newException(EOS, "Could not send all data.")
diff --git a/lib/pure/oids.nim b/lib/pure/oids.nim
index b3e74d2a1..2843e6c65 100644
--- a/lib/pure/oids.nim
+++ b/lib/pure/oids.nim
@@ -62,9 +62,9 @@ var
 
 proc genOid*(): TOid =
   ## generates a new OID.
-  proc rand(): cint {.importc: "rand", nodecl.}
+  proc rand(): cint {.importc: "rand", header: "<stdlib.h>", nodecl.}
   proc gettime(dummy: ptr cint): cint {.importc: "time", header: "<time.h>".}
-  proc srand(seed: cint) {.importc: "srand", nodecl.}
+  proc srand(seed: cint) {.importc: "srand", header: "<stdlib.h>", nodecl.}
 
   var t = gettime(nil)
   
diff --git a/lib/pure/os.nim b/lib/pure/os.nim
index e2fc62d77..a7f4f7d91 100644
--- a/lib/pure/os.nim
+++ b/lib/pure/os.nim
@@ -1560,7 +1560,52 @@ proc getTempDir*(): string {.rtl, extern: "nos$1", tags: [FReadEnv].} =
   when defined(windows): return string(getEnv("TEMP")) & "\\"
   else: return "/tmp/"
 
-when defined(windows):
+when defined(nimdoc):
+  # Common forward declaration docstring block for parameter retrieval procs.
+  proc paramCount*(): int {.tags: [FReadIO].} =
+    ## Returns the number of `command line arguments`:idx: given to the
+    ## application.
+    ##
+    ## If your binary was called without parameters this will return zero.  You
+    ## can later query each individual paramater with `paramStr() <#paramStr>`_
+    ## or retrieve all of them in one go with `commandLineParams()
+    ## <#commandLineParams>`_.
+    ##
+    ## **Availability**: On Posix there is no portable way to get the command
+    ## line from a DLL and thus the proc isn't defined in this environment. You
+    ## can test for its availability with `defined() <system.html#defined>`_.
+    ## Example:
+    ##
+    ## .. code-block:: nimrod
+    ##   when defined(paramCount):
+    ##     # Use paramCount() here
+    ##   else:
+    ##     # Do something else!
+
+  proc paramStr*(i: int): TaintedString {.tags: [FReadIO].} =
+    ## Returns the `i`-th `command line argument`:idx: given to the application.
+    ##
+    ## `i` should be in the range `1..paramCount()`, the `EInvalidIndex`
+    ## exception will be raised for invalid values.  Instead of iterating over
+    ## `paramCount() <#paramCount>`_ with this proc you can call the
+    ## convenience `commandLineParams() <#commandLineParams>`_.
+    ##
+    ## It is possible to call ``paramStr(0)`` but this will return OS specific
+    ## contents (usually the name of the invoked executable). You should avoid
+    ## this and call `getAppFilename() <#getAppFilename>`_ instead.
+    ##
+    ## **Availability**: On Posix there is no portable way to get the command
+    ## line from a DLL and thus the proc isn't defined in this environment. You
+    ## can test for its availability with `defined() <system.html#defined>`_.
+    ## Example:
+    ##
+    ## .. code-block:: nimrod
+    ##   when defined(paramStr):
+    ##     # Use paramStr() here
+    ##   else:
+    ##     # Do something else!
+
+elif defined(windows):
   # Since we support GUI applications with Nimrod, we sometimes generate
   # a WinMain entry proc. But a WinMain proc has no access to the parsed
   # command line arguments. The way to get them differs. Thus we parse them
@@ -1570,18 +1615,13 @@ when defined(windows):
     ownArgv {.threadvar.}: seq[string]
 
   proc paramCount*(): int {.rtl, extern: "nos$1", tags: [FReadIO].} =
-    ## Returns the number of `command line arguments`:idx: given to the
-    ## application.
+    # Docstring in nimdoc block.
     if isNil(ownArgv): ownArgv = parseCmdLine($getCommandLine())
     result = ownArgv.len-1
 
   proc paramStr*(i: int): TaintedString {.rtl, extern: "nos$1",
     tags: [FReadIO].} =
-    ## Returns the `i`-th `command line argument`:idx: given to the
-    ## application.
-    ##
-    ## `i` should be in the range `1..paramCount()`, else
-    ## the `EOutOfIndex` exception is raised.
+    # Docstring in nimdoc block.
     if isNil(ownArgv): ownArgv = parseCmdLine($getCommandLine())
     return TaintedString(ownArgv[i])
 
@@ -1592,13 +1632,31 @@ elif not defined(createNimRtl):
     cmdLine {.importc: "cmdLine".}: cstringArray
 
   proc paramStr*(i: int): TaintedString {.tags: [FReadIO].} =
+    # Docstring in nimdoc block.
     if i < cmdCount and i >= 0: return TaintedString($cmdLine[i])
     raise newException(EInvalidIndex, "invalid index")
 
-  proc paramCount*(): int {.tags: [FReadIO].} = return cmdCount-1
+  proc paramCount*(): int {.tags: [FReadIO].} =
+    # Docstring in nimdoc block.
+    result = cmdCount-1
 
-when defined(paramCount):
+when defined(paramCount) or defined(nimdoc):
   proc commandLineParams*(): seq[TaintedString] =
+    ## Convenience proc which returns the command line parameters.
+    ##
+    ## This returns **only** the parameters. If you want to get the application
+    ## executable filename, call `getAppFilename() <#getAppFilename>`_.
+    ##
+    ## **Availability**: On Posix there is no portable way to get the command
+    ## line from a DLL and thus the proc isn't defined in this environment. You
+    ## can test for its availability with `defined() <system.html#defined>`_.
+    ## Example:
+    ##
+    ## .. code-block:: nimrod
+    ##   when defined(commandLineParams):
+    ##     # Use commandLineParams() here
+    ##   else:
+    ##     # Do something else!
     result = @[]
     for i in 1..paramCount():
       result.add(paramStr(i))
@@ -1769,16 +1827,16 @@ else:
     FileId = TIno
 
 type
-  FileInfo = object
+  FileInfo* = object
     ## Contains information associated with a file object.
-    id: tuple[device: DeviceId, file: FileId] # Device and file id.
-    kind: TPathComponent # Kind of file object - directory, symlink, etc.
-    size: BiggestInt # Size of file.
-    permissions: set[TFilePermission] # File permissions
-    linkCount: BiggestInt # Number of hard links the file object has.
-    lastAccessTime: TTime # Time file was last accessed.
-    lastWriteTime: TTime # Time file was last modified/written to.
-    creationTime: TTime # Time file was created. Not supported on all systems!
+    id*: tuple[device: DeviceId, file: FileId] # Device and file id.
+    kind*: TPathComponent # Kind of file object - directory, symlink, etc.
+    size*: BiggestInt # Size of file.
+    permissions*: set[TFilePermission] # File permissions
+    linkCount*: BiggestInt # Number of hard links the file object has.
+    lastAccessTime*: TTime # Time file was last accessed.
+    lastWriteTime*: TTime # Time file was last modified/written to.
+    creationTime*: TTime # Time file was created. Not supported on all systems!
 
 template rawToFormalFileInfo(rawInfo, formalInfo): expr =
   ## Transforms the native file info structure into the one nimrod uses.
diff --git a/lib/pure/osproc.nim b/lib/pure/osproc.nim
index 6e250f9d5..04a0c2403 100644
--- a/lib/pure/osproc.nim
+++ b/lib/pure/osproc.nim
@@ -1,7 +1,7 @@
 #
 #
 #            Nimrod's Runtime Library
-#        (c) Copyright 2013 Andreas Rumpf
+#        (c) Copyright 2014 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
@@ -13,7 +13,7 @@
 include "system/inclrtl"
 
 import
-  strutils, os, strtabs, streams
+  strutils, os, strtabs, streams, cpuinfo
 
 when defined(windows):
   import winlean
@@ -225,42 +225,10 @@ proc errorHandle*(p: PProcess): TFileHandle {.rtl, extern: "nosp$1",
   ## it is closed when closing the PProcess ``p``.
   result = p.errHandle
 
-when defined(macosx) or defined(bsd):
-  const
-    CTL_HW = 6
-    HW_AVAILCPU = 25
-    HW_NCPU = 3
-  proc sysctl(x: ptr array[0..3, cint], y: cint, z: pointer,
-              a: var csize, b: pointer, c: int): cint {.
-             importc: "sysctl", header: "<sys/sysctl.h>".}
-
 proc countProcessors*(): int {.rtl, extern: "nosp$1".} =
   ## returns the numer of the processors/cores the machine has.
   ## Returns 0 if it cannot be detected.
-  when defined(windows):
-    var x = getEnv("NUMBER_OF_PROCESSORS")
-    if x.len > 0: result = parseInt(x.string)
-  elif defined(macosx) or defined(bsd):
-    var
-      mib: array[0..3, cint]
-      numCPU: int
-      len: csize
-    mib[0] = CTL_HW
-    mib[1] = HW_AVAILCPU
-    len = sizeof(numCPU)
-    discard sysctl(addr(mib), 2, addr(numCPU), len, nil, 0)
-    if numCPU < 1:
-      mib[1] = HW_NCPU
-      discard sysctl(addr(mib), 2, addr(numCPU), len, nil, 0)
-    result = numCPU
-  elif defined(hpux):
-    result = mpctl(MPC_GETNUMSPUS, nil, nil)
-  elif defined(irix):
-    var SC_NPROC_ONLN {.importc: "_SC_NPROC_ONLN", header: "<unistd.h>".}: cint
-    result = sysconf(SC_NPROC_ONLN)
-  else:
-    result = sysconf(SC_NPROCESSORS_ONLN)
-  if result <= 0: result = 1
+  result = cpuinfo.countProcessors()
 
 proc execProcesses*(cmds: openArray[string],
                     options = {poStdErrToStdOut, poParentStreams},
@@ -800,8 +768,8 @@ elif not defined(useNimRtl):
 
   proc startProcessAfterFork(data: ptr TStartProcessData) =
     # Warning: no GC here!
-    # Or anythink that touches global structures - all called nimrod procs
-    # must be marked with noStackFrame. Inspect C code after making changes.
+    # Or anything that touches global structures - all called nimrod procs
+    # must be marked with stackTrace:off. Inspect C code after making changes.
     if not data.optionPoParentStreams:
       discard close(data.pStdin[writeIdx])
       if dup2(data.pStdin[readIdx], readIdx) < 0:
@@ -903,7 +871,7 @@ elif not defined(useNimRtl):
       createStream(p.errStream, p.errHandle, fmRead)
     return p.errStream
 
-  proc csystem(cmd: cstring): cint {.nodecl, importc: "system".}
+  proc csystem(cmd: cstring): cint {.nodecl, importc: "system", header: "<stdlib.h>".}
 
   proc execCmd(command: string): int =
     when defined(linux):
diff --git a/lib/pure/rawsockets.nim b/lib/pure/rawsockets.nim
index 07b647b68..d96741846 100644
--- a/lib/pure/rawsockets.nim
+++ b/lib/pure/rawsockets.nim
@@ -21,11 +21,12 @@ const useWinVersion = defined(Windows) or defined(nimdoc)
 
 when useWinVersion:
   import winlean
-  export WSAEWOULDBLOCK
+  export WSAEWOULDBLOCK, WSAECONNRESET, WSAECONNABORTED, WSAENETRESET,
+         WSAEDISCON
 else:
   import posix
   export fcntl, F_GETFL, O_NONBLOCK, F_SETFL, EAGAIN, EWOULDBLOCK, MSG_NOSIGNAL,
-    EINTR, EINPROGRESS
+    EINTR, EINPROGRESS, ECONNRESET, EPIPE, ENETRESET
 
 export TSocketHandle, TSockaddr_in, TAddrinfo, INADDR_ANY, TSockAddr, TSockLen,
   inet_ntoa, recv, `==`, connect, send, accept, recvfrom, sendto
@@ -39,7 +40,6 @@ export
   MSG_PEEK
 
 type
-  
   TPort* = distinct uint16  ## port type
   
   TDomain* = enum   ## domain, which specifies the protocol family of the
diff --git a/lib/pure/selectors.nim b/lib/pure/selectors.nim
index 498f41e83..bd53c2dbf 100644
--- a/lib/pure/selectors.nim
+++ b/lib/pure/selectors.nim
@@ -11,9 +11,12 @@
 
 import tables, os, unsigned, hashes
 
-when defined(linux): import posix, epoll
-elif defined(windows): import winlean
-else: import posix
+when defined(linux): 
+  import posix, epoll
+elif defined(windows): 
+  import winlean
+else: 
+  import posix
 
 proc hash*(x: TSocketHandle): THash {.borrow.}
 proc `$`*(x: TSocketHandle): string {.borrow.}
@@ -29,7 +32,36 @@ type
 
   TReadyInfo* = tuple[key: PSelectorKey, events: set[TEvent]]
 
-when defined(linux) or defined(nimdoc):
+when defined(nimdoc):
+  type
+    PSelector* = ref object
+      ## An object which holds file descripters to be checked for read/write
+      ## status.
+      fds: TTable[TSocketHandle, PSelectorKey]
+
+  proc register*(s: PSelector, fd: TSocketHandle, events: set[TEvent],
+                 data: PObject): PSelectorKey {.discardable.} =
+    ## Registers file descriptor ``fd`` to selector ``s`` with a set of TEvent
+    ## ``events``.
+
+  proc update*(s: PSelector, fd: TSocketHandle,
+               events: set[TEvent]): PSelectorKey {.discardable.} =
+    ## Updates the events which ``fd`` wants notifications for.
+
+  proc select*(s: PSelector, timeout: int): seq[TReadyInfo] =
+    ## The ``events`` field of the returned ``key`` contains the original events
+    ## for which the ``fd`` was bound. This is contrary to the ``events`` field
+    ## of the ``TReadyInfo`` tuple which determines which events are ready
+    ## on the ``fd``.
+
+  proc contains*(s: PSelector, fd: TSocketHandle): bool =
+    ## Determines whether selector contains a file descriptor.
+
+  proc `[]`*(s: PSelector, fd: TSocketHandle): PSelectorKey =
+    ## Retrieves the selector key for ``fd``.
+
+
+elif defined(linux):
   type
     PSelector* = ref object
       epollFD: cint
@@ -131,7 +163,7 @@ when defined(linux) or defined(nimdoc):
   proc newSelector*(): PSelector =
     new result
     result.epollFD = epoll_create(64)
-    result.events = cast[array[64, epoll_event]](alloc0(sizeof(epoll_event)*64))
+    #result.events = cast[array[64, epoll_event]](alloc0(sizeof(epoll_event)*64))
     result.fds = initTable[TSocketHandle, PSelectorKey]()
     if result.epollFD < 0:
       OSError(OSLastError())
@@ -151,7 +183,7 @@ when defined(linux) or defined(nimdoc):
     ## Retrieves the selector key for ``fd``.
     return s.fds[fd]
 
-else:
+elif not defined(nimdoc):
   # TODO: kqueue for bsd/mac os x.
   type
     PSelector* = ref object
@@ -250,7 +282,7 @@ proc contains*(s: PSelector, key: PSelectorKey): bool =
   ## the new one may have the same value.
   return key.fd in s and s.fds[key.fd] == key
 
-when isMainModule:
+when isMainModule and not defined(nimdoc):
   # Select()
   import sockets
   type
diff --git a/lib/pure/sockets.nim b/lib/pure/sockets.nim
index 8d96cbaaf..7b8b3d557 100644
--- a/lib/pure/sockets.nim
+++ b/lib/pure/sockets.nim
@@ -295,7 +295,7 @@ when defined(ssl):
     of protSSLv23:
       newCTX = SSL_CTX_new(SSLv23_method()) # SSlv2,3 and TLS1 support.
     of protSSLv2:
-      when not defined(linux):
+      when not defined(linux) and not defined(OpenBSD):
         newCTX = SSL_CTX_new(SSLv2_method())
       else:
         SSLError()
diff --git a/lib/pure/strutils.nim b/lib/pure/strutils.nim
index bd6814dcc..51392ba50 100644
--- a/lib/pure/strutils.nim
+++ b/lib/pure/strutils.nim
@@ -10,6 +10,8 @@
 ## This module contains various string utility routines.
 ## See the module `re <re.html>`_ for regular expression support.
 ## See the module `pegs <pegs.html>`_ for PEG support.
+## This module is available for the `JavaScript target
+## <backends.html#the-javascript-target>`_.
 
 import parseutils
 
@@ -533,7 +535,12 @@ proc wordWrap*(s: string, maxLineWidth = 80,
   ## word wraps `s`.
   result = newStringOfCap(s.len + s.len shr 6)
   var spaceLeft = maxLineWidth
+  var lastSep = ""
   for word, isSep in tokenize(s, seps):
+    if isSep:
+      lastSep = word
+      spaceLeft = spaceLeft - len(word)
+      continue
     if len(word) > spaceLeft:
       if splitLongWords and len(word) > maxLineWidth:
         result.add(substr(word, 0, spaceLeft-1))
@@ -552,7 +559,8 @@ proc wordWrap*(s: string, maxLineWidth = 80,
         result.add(word)
     else:
       spaceLeft = spaceLeft - len(word)
-      result.add(word)
+      result.add(lastSep & word)
+      lastSep.setLen(0)
 
 proc unindent*(s: string, eatAllIndent = false): string {.
                noSideEffect, rtl, extern: "nsuUnindent".} =
diff --git a/lib/pure/times.nim b/lib/pure/times.nim
index fdff06b2a..498511899 100644
--- a/lib/pure/times.nim
+++ b/lib/pure/times.nim
@@ -9,7 +9,8 @@
 
 
 ## This module contains routines and types for dealing with time.
-## This module is available for the JavaScript target.
+## This module is available for the `JavaScript target
+## <backends.html#the-javascript-target>`_.
 
 {.push debugger:off.} # the user does not want to trace a part
                       # of the standard library!
diff --git a/lib/pure/unidecode/gen.py b/lib/pure/unidecode/gen.py
index 8da0136ff..8da0136ff 100755..100644
--- a/lib/pure/unidecode/gen.py
+++ b/lib/pure/unidecode/gen.py
diff --git a/lib/system.nim b/lib/system.nim
index ad98540a7..3c42385b7 100644
--- a/lib/system.nim
+++ b/lib/system.nim
@@ -42,15 +42,18 @@ type
   cstring* {.magic: Cstring.} ## built-in cstring (*compatible string*) type
   pointer* {.magic: Pointer.} ## built-in pointer type, use the ``addr``
                               ## operator to get a pointer to a variable
-
 const
   on* = true    ## alias for ``true``
   off* = false  ## alias for ``false``
 
+{.push warning[GcMem]: off.}
 {.push hints: off.}
 
 type
   Ordinal* {.magic: Ordinal.}[T]
+  `ptr`* {.magic: Pointer.}[T] ## built-in generic untraced pointer type
+  `ref`* {.magic: Pointer.}[T] ## built-in generic traced pointer type
+
   `nil` {.magic: "Nil".}
   expr* {.magic: Expr.} ## meta type to denote an expression (for templates)
   stmt* {.magic: Stmt.} ## meta type to denote a statement (for templates)
@@ -88,6 +91,15 @@ proc defined*(x: expr): bool {.magic: "Defined", noSideEffect.}
   ##   when not defined(strutils.toUpper):
   ##     # provide our own toUpper proc here, because strutils is
   ##     # missing it.
+  ##
+  ## You can also check external symbols introduced through the compiler's
+  ## `-d:x switch <nimrodc.html#compile-time-symbols>`_ to enable build time
+  ## conditionals:
+  ##
+  ## .. code-block:: Nimrod
+  ##   when not defined(release):
+  ##     # Do here programmer friendly expensive sanity checks.
+  ##   # Put here the normal code
 
 when defined(useNimRtl):
   {.deadCodeElim: on.}
@@ -420,12 +432,12 @@ proc pred*[T](x: Ordinal[T], y = 1): T {.magic: "Pred", noSideEffect.}
   ## an ordinal type. If such a value does not exist, ``EOutOfRange`` is raised
   ## or a compile time error occurs.
 
-proc inc*[T](x: var Ordinal[T], y = 1) {.magic: "Inc", noSideEffect.}
+proc inc*[T: Ordinal|uint|uint64](x: var T, y = 1) {.magic: "Inc", noSideEffect.}
   ## increments the ordinal ``x`` by ``y``. If such a value does not
   ## exist, ``EOutOfRange`` is raised or a compile time error occurs. This is a
   ## short notation for: ``x = succ(x, y)``.
 
-proc dec*[T](x: var Ordinal[T], y = 1) {.magic: "Dec", noSideEffect.}
+proc dec*[T: Ordinal|uint|uint64](x: var T, y = 1) {.magic: "Dec", noSideEffect.}
   ## decrements the ordinal ``x`` by ``y``. If such a value does not
   ## exist, ``EOutOfRange`` is raised or a compile time error occurs. This is a
   ## short notation for: ``x = pred(x, y)``.
@@ -1434,6 +1446,20 @@ when not defined(nimrodVM) and hostOS != "standalone":
   proc getTotalMem*(): int {.rtl.}
     ## returns the number of bytes that are owned by the process.
 
+  when hasThreadSupport:
+    proc getOccupiedSharedMem*(): int {.rtl.}
+      ## returns the number of bytes that are owned by the process
+      ## on the shared heap and hold data. This is only available when
+      ## threads are enabled.
+
+    proc getFreeSharedMem*(): int {.rtl.}
+      ## returns the number of bytes that are owned by the
+      ## process on the shared heap, but do not hold any meaningful data.
+      ## This is only available when threads are enabled.
+
+    proc getTotalSharedMem*(): int {.rtl.}
+      ## returns the number of bytes on the shared heap that are owned by the
+      ## process. This is only available when threads are enabled.
 
 iterator countdown*[T](a, b: T, step = 1): T {.inline.} =
   ## Counts from ordinal value `a` down to `b` with the given
@@ -1753,9 +1779,38 @@ iterator fields*[S:tuple|object, T:tuple|object](x: S, y: T): tuple[a,b: expr] {
   ## in the loop body.
 iterator fieldPairs*[T: tuple|object](x: T): TObject {.
   magic: "FieldPairs", noSideEffect.}
-  ## iterates over every field of `x`. Warning: This really transforms
-  ## the 'for' and unrolls the loop. The current implementation also has a bug
-  ## that affects symbol binding in the loop body.
+  ## Iterates over every field of `x` returning their name and value.
+  ##
+  ## When you iterate over objects with different field types you have to use
+  ## the compile time ``when`` instead of a runtime ``if`` to select the code
+  ## you want to run for each type. To perform the comparison use the `is
+  ## operator <manual.html#is-operator>`_. Example:
+  ##
+  ## .. code-block:: Nimrod
+  ##
+  ##   type
+  ##     Custom = object
+  ##       foo: string
+  ##       bar: bool
+  ##
+  ##   proc `$`(x: Custom): string =
+  ##     result = "Custom:"
+  ##     for name, value in x.fieldPairs:
+  ##       when value is bool:
+  ##         result.add("\n\t" & name & " is " & $value)
+  ##       else:
+  ##         if value.isNil:
+  ##           result.add("\n\t" & name & " (nil)")
+  ##         else:
+  ##           result.add("\n\t" & name & " '" & value & "'")
+  ##
+  ## Another way to do the same without ``when`` is to leave the task of
+  ## picking the appropriate code to a secondary proc which you overload for
+  ## each field type and pass the `value` to.
+  ##
+  ## Warning: This really transforms the 'for' and unrolls the loop. The
+  ## current implementation also has a bug that affects symbol binding in the
+  ## loop body.
 iterator fieldPairs*[S: tuple|object, T: tuple|object](x: S, y: T): tuple[
   a, b: expr] {.
   magic: "FieldPairs", noSideEffect.}
@@ -2609,6 +2664,8 @@ when hostOS != "standalone":
 proc `[]`*[Idx, T](a: array[Idx, T], x: TSlice[int]): seq[T] =
   ## slice operation for arrays. Negative indexes are **not** supported
   ## because the array might have negative bounds.
+  when low(a) < 0:
+    {.error: "Slicing for arrays with negative indices is unsupported.".}
   var L = x.b - x.a + 1
   newSeq(result, L)
   for i in 0.. <L: result[i] = a[i + x.a]
@@ -2616,6 +2673,8 @@ proc `[]`*[Idx, T](a: array[Idx, T], x: TSlice[int]): seq[T] =
 proc `[]=`*[Idx, T](a: var array[Idx, T], x: TSlice[int], b: openArray[T]) =
   ## slice assignment for arrays. Negative indexes are **not** supported
   ## because the array might have negative bounds.
+  when low(a) < 0:
+    {.error: "Slicing for arrays with negative indices is unsupported.".}
   var L = x.b - x.a + 1
   if L == b.len:
     for i in 0 .. <L: a[i+x.a] = b[i]
@@ -2691,13 +2750,13 @@ proc staticExec*(command: string, input = ""): string {.
   ## inside a pragma like `passC <nimrodc.html#passc-pragma>`_ or `passL
   ## <nimrodc.html#passl-pragma>`_.
 
-proc `+=`*[T: TOrdinal](x: var T, y: T) {.magic: "Inc", noSideEffect.}
+proc `+=`*[T: TOrdinal|uint|uint64](x: var T, y: T) {.magic: "Inc", noSideEffect.}
   ## Increments an ordinal
 
-proc `-=`*[T: TOrdinal](x: var T, y: T) {.magic: "Dec", noSideEffect.}
+proc `-=`*[T: TOrdinal|uint|uint64](x: var T, y: T) {.magic: "Dec", noSideEffect.}
   ## Decrements an ordinal
 
-proc `*=`*[T: TOrdinal](x: var T, y: T) {.inline, noSideEffect.} =
+proc `*=`*[T: TOrdinal|uint|uint64](x: var T, y: T) {.inline, noSideEffect.} =
   ## Binary `*=` operator for ordinals
   x = x * y
 
@@ -2769,10 +2828,15 @@ when true:
     THide(raiseAssert)(msg)
 
 template assert*(cond: bool, msg = "") =
-  ## provides a means to implement `programming by contracts`:idx: in Nimrod.
+  ## Raises ``EAssertionFailure`` with `msg` if `cond` is false.
+  ##
+  ## Provides a means to implement `programming by contracts`:idx: in Nimrod.
   ## ``assert`` evaluates expression ``cond`` and if ``cond`` is false, it
-  ## raises an ``EAssertionFailure`` exception. However, the compiler may
-  ## not generate any code at all for ``assert`` if it is advised to do so.
+  ## raises an ``EAssertionFailure`` exception. However, the compiler may not
+  ## generate any code at all for ``assert`` if it is advised to do so through
+  ## the ``-d:release`` or ``--assertions:off`` `command line switches
+  ## <nimrodc.html#command-line-switches>`_.
+  ##
   ## Use ``assert`` for debugging purposes only.
   bind instantiationInfo
   mixin failedAssertImpl
@@ -2926,6 +2990,13 @@ proc locals*(): TObject {.magic: "Locals", noSideEffect.} =
   ##   # -> B is 1
   discard
 
+proc deepCopy*[T](x: T): T {.magic: "DeepCopy", noSideEffect.} =
+  ## performs a deep copy of `x`. This is also used by the code generator
+  ## for the implementation of ``spawn``.
+  discard
+
+{.pop.} #{.push warning[GcMem]: off.}
+
 when not defined(booting):
   type
     semistatic*[T] = static[T] | T
@@ -2934,6 +3005,3 @@ when not defined(booting):
 
   template isStatic*(x): expr = compiles(static(x))
     # checks whether `x` is a value known at compile-time
-
-when hasThreadSupport:
-  when hostOS != "standalone": include "system/sysspawn"
diff --git a/lib/system/alloc.nim b/lib/system/alloc.nim
index eaef6cd95..602e5c7fa 100644
--- a/lib/system/alloc.nim
+++ b/lib/system/alloc.nim
@@ -835,4 +835,20 @@ template instantiateForRegion(allocator: expr) =
     else:
       result = realloc(p, newsize)
 
+  when hasThreadSupport:
+
+    template sharedMemStatsShared(v: int) {.immediate.} =
+      acquireSys(heapLock)
+      result = v
+      releaseSys(heapLock)
+
+    proc getFreeSharedMem(): int =
+      sharedMemStatsShared(sharedHeap.freeMem)
+
+    proc getTotalSharedMem(): int =
+      sharedMemStatsShared(sharedHeap.currMem)
+
+    proc getOccupiedSharedMem(): int =
+      sharedMemStatsShared(sharedHeap.currMem - sharedHeap.freeMem)
+
 {.pop.}
diff --git a/lib/system/assign.nim b/lib/system/assign.nim
index 75c749633..2ae945fb1 100644
--- a/lib/system/assign.nim
+++ b/lib/system/assign.nim
@@ -179,7 +179,8 @@ when not defined(nimmixin):
     # internal proc used for destroying sequences and arrays
     for i in countup(0, r.len - 1): destroy(r[i])
 else:
-  # XXX Why is this exported and no compilerproc?
+  # XXX Why is this exported and no compilerproc? -> compilerprocs cannot be
+  # generic for now
   proc nimDestroyRange*[T](r: T) =
     # internal proc used for destroying sequences and arrays
     mixin destroy
diff --git a/lib/system/atomics.nim b/lib/system/atomics.nim
index b1a96b209..43b3f0438 100644
--- a/lib/system/atomics.nim
+++ b/lib/system/atomics.nim
@@ -1,15 +1,18 @@
 #
 #
 #            Nimrod's Runtime Library
-#        (c) Copyright 2012 Andreas Rumpf
+#        (c) Copyright 2014 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
 #
 
 ## Atomic operations for Nimrod.
+{.push stackTrace:off.}
 
-when (defined(gcc) or defined(llvm_gcc)) and hasThreadSupport:
+const someGcc = defined(gcc) or defined(llvm_gcc) or defined(clang)
+
+when someGcc and hasThreadSupport:
   type 
     AtomMemModel* = enum
       ATOMIC_RELAXED,  ## No barriers or synchronization. 
@@ -152,41 +155,16 @@ when (defined(gcc) or defined(llvm_gcc)) and hasThreadSupport:
     ## A value of 0 indicates typical alignment should be used. The compiler may also 
     ## ignore this parameter.
 
+  template fence*() = atomicThreadFence(ATOMIC_SEQ_CST)
 elif defined(vcc) and hasThreadSupport:
   proc addAndFetch*(p: ptr int, val: int): int {.
     importc: "NimXadd", nodecl.}
+
 else:
   proc addAndFetch*(p: ptr int, val: int): int {.inline.} =
     inc(p[], val)
     result = p[]
 
-# atomic compare and swap (CAS) funcitons to implement lock-free algorithms  
-      
-#if defined(windows) and not defined(gcc) and hasThreadSupport:
-#    proc InterlockedCompareExchangePointer(mem: ptr pointer,
-#      newValue: pointer, comparand: pointer) : pointer {.nodecl, 
-#        importc: "InterlockedCompareExchangePointer", header:"windows.h".}
-
-#    proc compareAndSwap*[T](mem: ptr T, 
-#      expected: T, newValue: T): bool {.inline.}=
-#      ## Returns true if successfully set value at mem to newValue when value
-#      ## at mem == expected
-#      return InterlockedCompareExchangePointer(addr(mem), 
-#        addr(newValue), addr(expected))[] == expected
-    
-#elif not hasThreadSupport:
-#  proc compareAndSwap*[T](mem: ptr T, 
-#                          expected: T, newValue: T): bool {.inline.} =
-#      ## Returns true if successfully set value at mem to newValue when value
-#      ## at mem == expected
-#      var oldval = mem[]
-#      if oldval == expected:
-#        mem[] = newValue
-#        return true
-#      return false
-
-
-# Some convenient functions 
 proc atomicInc*(memLoc: var int, x: int = 1): int =
   when defined(gcc) and hasThreadSupport:
     result = atomic_add_fetch(memLoc.addr, x, ATOMIC_RELAXED)
@@ -203,3 +181,37 @@ proc atomicDec*(memLoc: var int, x: int = 1): int =
   else:
     dec(memLoc, x)
     result = memLoc
+
+when defined(windows) and not someGcc:
+  proc interlockedCompareExchange(p: pointer; exchange, comparand: int32): int32
+    {.importc: "InterlockedCompareExchange", header: "<windows.h>", cdecl.}
+
+  proc cas*[T: bool|int|ptr](p: ptr T; oldValue, newValue: T): bool =
+    interlockedCompareExchange(p, newValue.int32, oldValue.int32) != 0
+  # XXX fix for 64 bit build
+else:
+  # this is valid for GCC and Intel C++
+  proc cas*[T: bool|int|ptr](p: ptr T; oldValue, newValue: T): bool
+    {.importc: "__sync_bool_compare_and_swap", nodecl.}
+  # XXX is this valid for 'int'?
+
+
+when (defined(x86) or defined(amd64)) and (defined(gcc) or defined(llvm_gcc)):
+  proc cpuRelax {.inline.} =
+    {.emit: """asm volatile("pause" ::: "memory");""".}
+elif (defined(x86) or defined(amd64)) and defined(vcc):
+  proc cpuRelax {.importc: "YieldProcessor", header: "<windows.h>".}
+elif defined(intelc):
+  proc cpuRelax {.importc: "_mm_pause", header: "xmmintrin.h".}
+elif false:
+  from os import sleep
+
+  proc cpuRelax {.inline.} = os.sleep(1)
+
+when not defined(fence) and hasThreadSupport:
+  # XXX fixme
+  proc fence*() {.inline.} =
+    var dummy: bool
+    discard cas(addr dummy, false, true)
+
+{.pop.}
diff --git a/lib/system/chcks.nim b/lib/system/chcks.nim
index f29e222e8..387b54ef1 100644
--- a/lib/system/chcks.nim
+++ b/lib/system/chcks.nim
@@ -67,6 +67,28 @@ proc chckObjAsgn(a, b: PNimType) {.compilerproc, inline.} =
   if a != b:
     sysFatal(EInvalidObjectAssignment, "invalid object assignment")
 
+type ObjCheckCache = array[0..1, PNimType]
+
+proc isObjSlowPath(obj, subclass: PNimType;
+                   cache: var ObjCheckCache): bool {.noinline.} =
+  # checks if obj is of type subclass:
+  var x = obj.base
+  while x != subclass:
+    if x == nil:
+      cache[0] = obj
+      return false
+    x = x.base
+  cache[1] = obj
+  return true
+
+proc isObjWithCache(obj, subclass: PNimType;
+                    cache: var ObjCheckCache): bool {.compilerProc, inline.} =
+  if obj == subclass: return true
+  if obj.base == subclass: return true
+  if cache[0] == obj: return false
+  if cache[1] == obj: return true
+  return isObjSlowPath(obj, subclass, cache)
+
 proc isObj(obj, subclass: PNimType): bool {.compilerproc.} =
   # checks if obj is of type subclass:
   var x = obj
diff --git a/lib/system/sets.nim b/lib/system/sets.nim
index 043d37533..794c65cb8 100644
--- a/lib/system/sets.nim
+++ b/lib/system/sets.nim
@@ -10,7 +10,7 @@
 # set handling
 
 type
-  TNimSet = array [0..4*2048-1, int8]
+  TNimSet = array [0..4*2048-1, uint8]
 
 proc countBits32(n: int32): int {.compilerproc.} =
   var v = n
@@ -25,4 +25,4 @@ proc countBits64(n: int64): int {.compilerproc.} =
 proc cardSet(s: TNimSet, len: int): int {.compilerproc.} =
   result = 0
   for i in countup(0, len-1):
-    inc(result, countBits32(int32(ze(s[i]))))
+    inc(result, countBits32(int32(s[i])))
diff --git a/lib/system/sysio.nim b/lib/system/sysio.nim
index 02c17b92b..32d4c3e91 100644
--- a/lib/system/sysio.nim
+++ b/lib/system/sysio.nim
@@ -115,10 +115,14 @@ proc readAllBuffer(file: TFile): string =
   # bytes we need to read before the buffer is empty.
   result = ""
   var buffer = newString(BufSize)
-  var bytesRead = BufSize
-  while bytesRead == BufSize:
-    bytesRead = readBuffer(file, addr(buffer[0]), BufSize)
-    result.add(buffer)
+  while true:
+    var bytesRead = readBuffer(file, addr(buffer[0]), BufSize)
+    if bytesRead == BufSize:
+      result.add(buffer)
+    else:
+      buffer.setLen(bytesRead)
+      result.add(buffer)
+      break
   
 proc rawFileSize(file: TFile): int = 
   # this does not raise an error opposed to `getFileSize`
diff --git a/lib/system/sysspawn.nim b/lib/system/sysspawn.nim
index dabf35a3e..95cdba65d 100644
--- a/lib/system/sysspawn.nim
+++ b/lib/system/sysspawn.nim
@@ -14,30 +14,6 @@ when not defined(NimString):
 
 {.push stackTrace:off.}
 
-when (defined(x86) or defined(amd64)) and defined(gcc):
-  proc cpuRelax {.inline.} =
-    {.emit: """asm volatile("pause" ::: "memory");""".}
-elif (defined(x86) or defined(amd64)) and defined(vcc):
-  proc cpuRelax {.importc: "YieldProcessor", header: "<windows.h>".}
-elif defined(intelc):
-  proc cpuRelax {.importc: "_mm_pause", header: "xmmintrin.h".}
-elif false:
-  from os import sleep
-
-  proc cpuRelax {.inline.} = os.sleep(1)
-
-when defined(windows) and not defined(gcc):
-  proc interlockedCompareExchange(p: pointer; exchange, comparand: int32): int32
-    {.importc: "InterlockedCompareExchange", header: "<windows.h>", cdecl.}
-
-  proc cas(p: ptr bool; oldValue, newValue: bool): bool =
-    interlockedCompareExchange(p, newValue.int32, oldValue.int32) != 0
-
-else:
-  # this is valid for GCC and Intel C++
-  proc cas(p: ptr bool; oldValue, newValue: bool): bool
-    {.importc: "__sync_bool_compare_and_swap", nodecl.}
-
 # We declare our own condition variables here to get rid of the dummy lock
 # on Windows:
 
@@ -54,6 +30,9 @@ proc createCondVar(): CondVar =
     initSysLock(result.stupidLock)
     #acquireSys(result.stupidLock)
 
+proc destroyCondVar(c: var CondVar) {.inline.} =
+  deinitSysCond(c.c)
+
 proc await(cv: var CondVar) =
   when defined(posix):
     acquireSys(cv.stupidLock)
@@ -100,6 +79,26 @@ proc signal(cv: var FastCondVar) =
   #if cas(addr cv.slowPath, true, false):
   signal(cv.slow)
 
+type
+  Barrier* {.compilerProc.} = object
+    counter: int
+    cv: CondVar
+
+proc barrierEnter*(b: ptr Barrier) {.compilerProc.} =
+  atomicInc b.counter
+
+proc barrierLeave*(b: ptr Barrier) {.compilerProc.} =
+  atomicDec b.counter
+  if b.counter <= 0: signal(b.cv)
+
+proc openBarrier*(b: ptr Barrier) {.compilerProc.} =
+  b.counter = 0
+  b.cv = createCondVar()
+
+proc closeBarrier*(b: ptr Barrier) {.compilerProc.} =
+  await(b.cv)
+  destroyCondVar(b.cv)
+
 {.pop.}
 
 # ----------------------------------------------------------------------------
diff --git a/lib/windows/windows.nim b/lib/windows/windows.nim
index dd743ffa4..5fd9127b3 100644
--- a/lib/windows/windows.nim
+++ b/lib/windows/windows.nim
@@ -62,7 +62,7 @@ type  # BaseTsd.h -- Type definitions for the basic sized types
 

 type  # WinDef.h -- Basic Windows Type Definitions

   # BaseTypes

-  UINT = int32
+  WINUINT* = int32

   ULONG* = int

   PULONG* = ptr int

   USHORT* = int16

@@ -137,7 +137,7 @@ type  # WinDef.h -- Basic Windows Type Definitions
 

   HFILE* = HANDLE

   HCURSOR* = HANDLE # = HICON

-  COLORREF* = int

+  COLORREF* = DWORD

   LPCOLORREF* = ptr COLORREF

 

   POINT* {.final, pure.} = object

@@ -238,7 +238,7 @@ type
   CALTYPE* = int

   CALID* = int

   CCHAR* = char

-  TCOLORREF* = int

+  TCOLORREF* = COLORREF

   WINT* = int32

   PINTEGER* = ptr int32

   PBOOL* = ptr WINBOOL

@@ -377,32 +377,32 @@ type
 #    Definitions for callback procedures

 #

 type

-  BFFCALLBACK* = proc (para1: HWND, para2: UINT, para3: LPARAM, para4: LPARAM): int32{.

+  BFFCALLBACK* = proc (para1: HWND, para2: WINUINT, para3: LPARAM, para4: LPARAM): int32{.

       stdcall.}

-  LPCCHOOKPROC* = proc (para1: HWND, para2: UINT, para3: WPARAM, para4: LPARAM): UINT{.

+  LPCCHOOKPROC* = proc (para1: HWND, para2: WINUINT, para3: WPARAM, para4: LPARAM): WINUINT{.

       stdcall.}

-  LPCFHOOKPROC* = proc (para1: HWND, para2: UINT, para3: WPARAM, para4: LPARAM): UINT{.

+  LPCFHOOKPROC* = proc (para1: HWND, para2: WINUINT, para3: WPARAM, para4: LPARAM): WINUINT{.

       stdcall.}

   PTHREAD_START_ROUTINE* = Pointer

   LPTHREAD_START_ROUTINE* = PTHREAD_START_ROUTINE

   EDITSTREAMCALLBACK* = proc (para1: DWORD, para2: LPBYTE, para3: LONG,

                               para4: LONG): DWORD{.stdcall.}

-  LPFRHOOKPROC* = proc (para1: HWND, para2: UINT, para3: WPARAM, para4: LPARAM): UINT{.

+  LPFRHOOKPROC* = proc (para1: HWND, para2: WINUINT, para3: WPARAM, para4: LPARAM): WINUINT{.

       stdcall.}

-  LPOFNHOOKPROC* = proc (para1: HWND, para2: UINT, para3: WPARAM, para4: LPARAM): UINT{.

+  LPOFNHOOKPROC* = proc (para1: HWND, para2: WINUINT, para3: WPARAM, para4: LPARAM): WINUINT{.

       stdcall.}

-  LPPRINTHOOKPROC* = proc (para1: HWND, para2: UINT, para3: WPARAM,

-                           para4: LPARAM): UINT{.stdcall.}

-  LPSETUPHOOKPROC* = proc (para1: HWND, para2: UINT, para3: WPARAM,

-                           para4: LPARAM): UINT{.stdcall.}

-  DLGPROC* = proc (para1: HWND, para2: UINT, para3: WPARAM, para4: LPARAM): LRESULT{.

+  LPPRINTHOOKPROC* = proc (para1: HWND, para2: WINUINT, para3: WPARAM,

+                           para4: LPARAM): WINUINT{.stdcall.}

+  LPSETUPHOOKPROC* = proc (para1: HWND, para2: WINUINT, para3: WPARAM,

+                           para4: LPARAM): WINUINT{.stdcall.}

+  DLGPROC* = proc (para1: HWND, para2: WINUINT, para3: WPARAM, para4: LPARAM): LRESULT{.

       stdcall.}

-  PFNPROPSHEETCALLBACK* = proc (para1: HWND, para2: UINT, para3: LPARAM): int32{.

+  PFNPROPSHEETCALLBACK* = proc (para1: HWND, para2: WINUINT, para3: LPARAM): int32{.

       stdcall.}

   LPSERVICE_MAIN_FUNCTION* = proc (para1: DWORD, para2: LPTSTR){.stdcall.}

   PFNTVCOMPARE* = proc (para1: LPARAM, para2: LPARAM, para3: LPARAM): int32{.

       stdcall.}

-  WNDPROC* = proc (para1: HWND, para2: UINT, para3: WPARAM, para4: LPARAM): LRESULT{.

+  WNDPROC* = proc (para1: HWND, para2: WINUINT, para3: WPARAM, para4: LPARAM): LRESULT{.

       stdcall.}

   FARPROC* = pointer

   TFarProc* = FARPROC

@@ -416,9 +416,9 @@ type
   DESKTOPENUMPROC* = FARPROC

   ENUMWINDOWSPROC* = proc (para1: HWND, para2: LPARAM): WINBOOL{.stdcall.}

   ENUMWINDOWSTATIONPROC* = proc (para1: LPTSTR, para2: LPARAM): WINBOOL{.stdcall.}

-  SENDASYNCPROC* = proc (para1: HWND, para2: UINT, para3: DWORD, para4: LRESULT){.

+  SENDASYNCPROC* = proc (para1: HWND, para2: WINUINT, para3: DWORD, para4: LRESULT){.

       stdcall.}

-  TIMERPROC* = proc (para1: HWND, para2: UINT, para3: UINT, para4: DWORD){.

+  TIMERPROC* = proc (para1: HWND, para2: WINUINT, para3: WINUINT, para4: DWORD){.

       stdcall.}

   GRAYSTRINGPROC* = FARPROC

   DRAWSTATEPROC* = proc (para1: HDC, para2: LPARAM, para3: WPARAM, para4: int32,

@@ -432,10 +432,10 @@ type
   ENUMOBJECTSPROC* = proc (para1: LPVOID, para2: LPARAM){.stdcall.}

   LINEDDAPROC* = proc (para1: int32, para2: int32, para3: LPARAM){.stdcall.}

   TABORTPROC* = proc (para1: HDC, para2: int32): WINBOOL{.stdcall.}

-  LPPAGEPAINTHOOK* = proc (para1: HWND, para2: UINT, para3: WPARAM,

-                           para4: LPARAM): UINT{.stdcall.}

-  LPPAGESETUPHOOK* = proc (para1: HWND, para2: UINT, para3: WPARAM,

-                           para4: LPARAM): UINT{.stdcall.}

+  LPPAGEPAINTHOOK* = proc (para1: HWND, para2: WINUINT, para3: WPARAM,

+                           para4: LPARAM): WINUINT{.stdcall.}

+  LPPAGESETUPHOOK* = proc (para1: HWND, para2: WINUINT, para3: WPARAM,

+                           para4: LPARAM): WINUINT{.stdcall.}

   ICMENUMPROC* = proc (para1: LPTSTR, para2: LPARAM): int32{.stdcall.}

   EDITWORDBREAKPROCEX* = proc (para1: cstring, para2: LONG, para3: int8,

                                para4: WINT): LONG{.stdcall.}

@@ -448,9 +448,9 @@ type
   CALINFO_ENUMPROC* = proc (para1: LPTSTR): WINBOOL{.stdcall.}

   PHANDLER_ROUTINE* = proc (para1: DWORD): WINBOOL{.stdcall.}

   LPHANDLER_FUNCTION* = proc (para1: DWORD): WINBOOL{.stdcall.}

-  PFNGETPROFILEPATH* = proc (para1: LPCTSTR, para2: LPSTR, para3: UINT): UINT{.

+  PFNGETPROFILEPATH* = proc (para1: LPCTSTR, para2: LPSTR, para3: WINUINT): WINUINT{.

       stdcall.}

-  PFNRECONCILEPROFILE* = proc (para1: LPCTSTR, para2: LPCTSTR, para3: DWORD): UINT{.

+  PFNRECONCILEPROFILE* = proc (para1: LPCTSTR, para2: LPCTSTR, para3: DWORD): WINUINT{.

       stdcall.}

   PFNPROCESSPOLICIES* = proc (para1: HWND, para2: LPCTSTR, para3: LPCTSTR,

                               para4: LPCTSTR, para5: DWORD): WINBOOL{.stdcall.}

@@ -498,7 +498,7 @@ else:
     SERVICES_FAILED_DATABASE* = SERVICES_FAILED_DATABASEA

     SC_GROUP_IDENTIFIER* = SC_GROUP_IDENTIFIERA

 type

-  PFNCALLBACK* = proc (para1, para2: UINT, para3: HCONV, para4, para5: HSZ,

+  PFNCALLBACK* = proc (para1, para2: WINUINT, para3: HCONV, para4, para5: HSZ,

                        para6: HDDEDATA, para7, para8: DWORD): HDDEData{.stdcall.}

   CALLB* = PFNCALLBACK

   SECURITY_CONTEXT_TRACKING_MODE* = WINBOOL

@@ -6872,7 +6872,7 @@ type
   va_list* = cstring

   TABC* {.final, pure.} = object

     abcA*: int32

-    abcB*: UINT

+    abcB*: WINUINT

     abcC*: int32

 

   LPABC* = ptr TABC

@@ -6913,7 +6913,7 @@ type
 

   TACCESS_DENIED_ACE* = ACCESS_DENIED_ACE

   ACCESSTIMEOUT* {.final, pure.} = object

-    cbSize*: UINT

+    cbSize*: WINUINT

     dwFlags*: DWORD

     iTimeOutMSec*: DWORD

 

@@ -6982,7 +6982,7 @@ type
   TADDJOB_INFO_1* = ADDJOB_INFO_1

   PADDJOB_INFO_1* = ptr ADDJOB_INFO_1

   ANIMATIONINFO* {.final, pure.} = object

-    cbSize*: UINT

+    cbSize*: WINUINT

     iMinAnimate*: int32

 

   LPANIMATIONINFO* = ptr ANIMATIONINFO

@@ -6992,8 +6992,8 @@ type
   APPBARDATA* {.final, pure.} = object

     cbSize*: DWORD

     hWnd*: HWND

-    uCallbackMessage*: UINT

-    uEdge*: UINT

+    uCallbackMessage*: WINUINT

+    uEdge*: WINUINT

     rc*: RECT

     lParam*: LPARAM

 

@@ -7147,7 +7147,7 @@ type
     pidlRoot*: LPCITEMIDLIST

     pszDisplayName*: LPSTR

     lpszTitle*: LPCSTR

-    ulFlags*: UINT

+    ulFlags*: WINUINT

     lpfn*: BFFCALLBACK

     lParam*: LPARAM

     iImage*: int32

@@ -7244,7 +7244,7 @@ type
   TCHAR_INFO* = CHAR_INFO

   PCHAR_INFO* = ptr CHAR_INFO

   CHARFORMAT* {.final, pure.} = object

-    cbSize*: UINT

+    cbSize*: WINUINT

     dwMask*: DWORD

     dwEffects*: DWORD

     yHeight*: LONG

@@ -7276,8 +7276,8 @@ type
   TFONTSIGNATURE* = FONTSIGNATURE

   PFONTSIGNATURE* = ptr FONTSIGNATURE

   CHARSETINFO* {.final, pure.} = object

-    ciCharset*: UINT

-    ciACP*: UINT

+    ciCharset*: WINUINT

+    ciACP*: WINUINT

     fs*: FONTSIGNATURE

 

   LPCHARSETINFO* = ptr CHARSETINFO

@@ -7359,15 +7359,15 @@ type
   LPCHOOSEFONT* = ptr TCHOOSEFONT

   PCHOOSEFONT* = ptr TCHOOSEFONT

   CIDA* {.final, pure.} = object

-    cidl*: UINT

-    aoffset*: array[0..0, UINT]

+    cidl*: WINUINT

+    aoffset*: array[0..0, WINUINT]

 

   LPIDA* = ptr CIDA

   TIDA* = CIDA

   PIDA* = ptr CIDA

   CLIENTCREATESTRUCT* {.final, pure.} = object

     hWindowMenu*: HANDLE

-    idFirstChild*: UINT

+    idFirstChild*: WINUINT

 

   LPCLIENTCREATESTRUCT* = ptr CLIENTCREATESTRUCT

   TCLIENTCREATESTRUCT* = CLIENTCREATESTRUCT

@@ -7537,12 +7537,12 @@ type
   TCOMMTIMEOUTS* = COMMTIMEOUTS

   PCOMMTIMEOUTS* = ptr COMMTIMEOUTS

   COMPAREITEMSTRUCT* {.final, pure.} = object

-    CtlType*: UINT

-    CtlID*: UINT

+    CtlType*: WINUINT

+    CtlID*: WINUINT

     hwndItem*: HWND

-    itemID1*: UINT

+    itemID1*: WINUINT

     itemData1*: ULONG_PTR

-    itemID2*: UINT

+    itemID2*: WINUINT

     itemData2*: ULONG_PTR

 

   TCOMPAREITEMSTRUCT* = COMPAREITEMSTRUCT

@@ -7936,9 +7936,9 @@ type
   PSECURITY_QUALITY_OF_SERVICE* = ptr SECURITY_QUALITY_OF_SERVICE

   TSECURITYQUALITYOFSERVICE* = SECURITY_QUALITY_OF_SERVICE

   CONVCONTEXT* {.final, pure.} = object

-    cb*: UINT

-    wFlags*: UINT

-    wCountryID*: UINT

+    cb*: WINUINT

+    wFlags*: WINUINT

+    wCountryID*: WINUINT

     iCodePage*: int32

     dwLangID*: DWORD

     dwSecurity*: DWORD

@@ -7954,11 +7954,11 @@ type
     hszServiceReq*: HSZ

     hszTopic*: HSZ

     hszItem*: HSZ

-    wFmt*: UINT

-    wType*: UINT

-    wStatus*: UINT

-    wConvst*: UINT

-    wLastError*: UINT

+    wFmt*: WINUINT

+    wType*: WINUINT

+    wStatus*: WINUINT

+    wConvst*: WINUINT

+    wLastError*: WINUINT

     hConvList*: HCONVLIST

     ConvCtxt*: CONVCONTEXT

     hwnd*: HWND

@@ -7974,7 +7974,7 @@ type
   TCOPYDATASTRUCT* = COPYDATASTRUCT

   PCOPYDATASTRUCT* = ptr COPYDATASTRUCT

   CPINFO* {.final, pure.} = object

-    MaxCharSize*: UINT

+    MaxCharSize*: WINUINT

     DefaultChar*: array[0..(MAX_DEFAULTCHAR) - 1, int8]

     LeadByte*: array[0..(MAX_LEADBYTES) - 1, int8]

 

@@ -8012,13 +8012,13 @@ type
   PCREATETHREADDEBUGINFO* = ptr CREATE_THREAD_DEBUG_INFO

 

   CURRENCYFMT* {.final, pure.} = object

-    NumDigits*: UINT

-    LeadingZero*: UINT

-    Grouping*: UINT

+    NumDigits*: WINUINT

+    LeadingZero*: WINUINT

+    Grouping*: WINUINT

     lpDecimalSep*: LPTSTR

     lpThousandSep*: LPTSTR

-    NegativeOrder*: UINT

-    PositiveOrder*: UINT

+    NegativeOrder*: WINUINT

+    PositiveOrder*: WINUINT

     lpCurrencySymbol*: LPTSTR

 

   Tcurrencyfmt* = CURRENCYFMT

@@ -8047,7 +8047,7 @@ type
   CWPSTRUCT* {.final, pure.} = object

     lParam*: LPARAM

     wParam*: WPARAM

-    message*: UINT

+    message*: WINUINT

     hwnd*: HWND

 

   TCWPSTRUCT* = CWPSTRUCT

@@ -8161,8 +8161,8 @@ proc fAckReq*(a: var DDELN): int16
 proc set_fAckReq*(a: var DDELN, fAckReq: int16)

 type

   DDEML_MSG_HOOK_DATA* {.final, pure.} = object

-    uiLo*: UINT

-    uiHi*: UINT

+    uiLo*: WINUINT

+    uiHi*: WINUINT

     cbData*: DWORD

     Data*: array[0..7, DWORD]

 

@@ -8329,9 +8329,9 @@ type
   TDEBUGHOOKINFO* = DEBUGHOOKINFO

   PDEBUGHOOKINFO* = ptr DEBUGHOOKINFO

   DELETEITEMSTRUCT* {.final, pure.} = object

-    CtlType*: UINT

-    CtlID*: UINT

-    itemID*: UINT

+    CtlType*: WINUINT

+    CtlID*: WINUINT

+    itemID*: WINUINT

     hwndItem*: HWND

     itemData*: ULONG_PTR

 

@@ -8572,7 +8572,7 @@ type
   TDOCINFOA* = DOCINFO

   PDOCINFO* = ptr DOCINFO

   DRAGLISTINFO* {.final, pure.} = object

-    uNotification*: UINT

+    uNotification*: WINUINT

     hWnd*: HWND

     ptCursor*: POINT

 

@@ -8580,11 +8580,11 @@ type
   TDRAGLISTINFO* = DRAGLISTINFO

   PDRAGLISTINFO* = ptr DRAGLISTINFO

   DRAWITEMSTRUCT* {.final, pure.} = object

-    CtlType*: UINT

-    CtlID*: UINT

-    itemID*: UINT

-    itemAction*: UINT

-    itemState*: UINT

+    CtlType*: WINUINT

+    CtlID*: WINUINT

+    itemID*: WINUINT

+    itemAction*: WINUINT

+    itemState*: WINUINT

     hwndItem*: HWND

     hDC*: HDC

     rcItem*: RECT

@@ -8594,11 +8594,11 @@ type
   TDRAWITEMSTRUCT* = DRAWITEMSTRUCT

   PDRAWITEMSTRUCT* = ptr DRAWITEMSTRUCT

   DRAWTEXTPARAMS* {.final, pure.} = object

-    cbSize*: UINT

+    cbSize*: WINUINT

     iTabLength*: int32

     iLeftMargin*: int32

     iRightMargin*: int32

-    uiLengthDrawn*: UINT

+    uiLengthDrawn*: WINUINT

 

   LPDRAWTEXTPARAMS* = ptr DRAWTEXTPARAMS

   TDRAWTEXTPARAMS* = DRAWTEXTPARAMS

@@ -8720,7 +8720,7 @@ type
   TEMRBITBLT* = EMRBITBLT

   PEMRBITBLT* = ptr EMRBITBLT

   LOGBRUSH* {.final, pure.} = object

-    lbStyle*: UINT

+    lbStyle*: WINUINT

     lbColor*: COLORREF

     lbHatch*: LONG

 

@@ -8806,7 +8806,7 @@ type
   TEMRCREATEPALETTE* = EMRCREATEPALETTE

   PEMRCREATEPALETTE* = ptr EMRCREATEPALETTE

   LOGPEN* {.final, pure.} = object

-    lopnStyle*: UINT

+    lopnStyle*: WINUINT

     lopnWidth*: POINT

     lopnColor*: COLORREF

 

@@ -8881,9 +8881,9 @@ type
   TEMREXTCREATEFONTINDIRECTW* = EMREXTCREATEFONTINDIRECTW

   PEMREXTCREATEFONTINDIRECTW* = ptr EMREXTCREATEFONTINDIRECTW

   EXTLOGPEN* {.final, pure.} = object

-    elpPenStyle*: UINT

-    elpWidth*: UINT

-    elpBrushStyle*: UINT

+    elpPenStyle*: WINUINT

+    elpWidth*: WINUINT

+    elpBrushStyle*: WINUINT

     elpColor*: COLORREF

     elpHatch*: LONG

     elpNumEntries*: DWORD

@@ -9424,8 +9424,8 @@ type
   PEMRENABLEICM* = ptr EMRSELECTCLIPPATH

   NMHDR* {.final, pure.} = object

     hwndFrom*: HWND

-    idFrom*: UINT

-    code*: UINT

+    idFrom*: WINUINT

+    code*: WINUINT

 

   TNMHDR* = NMHDR

   PNMHDR* = ptr NMHDR

@@ -9483,7 +9483,7 @@ type
   PENHMETARECORD* = ptr TENHMETARECORD

   TENPROTECTED* {.final, pure.} = object

     nmhdr*: NMHDR

-    msg*: UINT

+    msg*: WINUINT

     wParam*: WPARAM

     lParam*: LPARAM

     chrg*: CHARRANGE

@@ -9546,9 +9546,9 @@ type
   TEVENTLOGRECORD* = EVENTLOGRECORD

   PEVENTLOGRECORD* = ptr EVENTLOGRECORD

   EVENTMSG* {.final, pure.} = object

-    message*: UINT

-    paramL*: UINT

-    paramH*: UINT

+    message*: WINUINT

+    paramL*: WINUINT

+    paramH*: WINUINT

     time*: DWORD

     hwnd*: HWND

 

@@ -9570,7 +9570,7 @@ type
   TEXTBUTTON* = EXT_BUTTON

   PEXTBUTTON* = ptr EXT_BUTTON

   FILTERKEYS* {.final, pure.} = object

-    cbSize*: UINT

+    cbSize*: WINUINT

     dwFlags*: DWORD

     iWaitMSec*: DWORD

     iDelayMSec*: DWORD

@@ -9646,7 +9646,7 @@ type
     dwSize*: DWORD

     szMenuName*: array[0..(MENU_TEXT_LEN) - 1, TCHAR]

     hMenu*: HMENU

-    wMenuDelta*: UINT

+    wMenuDelta*: WINUINT

 

   TFMSLOAD* = FMS_LOAD

   PFMSLOAD* = ptr FMS_LOAD

@@ -9694,13 +9694,13 @@ type
   GCP_RESULTS* {.final, pure.} = object

     lStructSize*: DWORD

     lpOutString*: LPTSTR

-    lpOrder*: ptr UINT

+    lpOrder*: ptr WINUINT

     lpDx*: ptr WINT

     lpCaretPos*: ptr WINT

     lpClass*: LPTSTR

-    lpGlyphs*: ptr UINT

-    nGlyphs*: UINT

-    nMaxFit*: UINT

+    lpGlyphs*: ptr WINUINT

+    nGlyphs*: WINUINT

+    nMaxFit*: WINUINT

 

   LPGCP_RESULTS* = ptr GCP_RESULTS

   TGCPRESULTS* = GCP_RESULTS

@@ -9714,8 +9714,8 @@ type
   PGENERIC_MAPPING* = ptr GENERIC_MAPPING

   TGENERICMAPPING* = GENERIC_MAPPING

   GLYPHMETRICS* {.final, pure.} = object

-    gmBlackBoxX*: UINT

-    gmBlackBoxY*: UINT

+    gmBlackBoxX*: WINUINT

+    gmBlackBoxY*: WINUINT

     gmptGlyphOrigin*: POINT

     gmCellIncX*: SHORT

     gmCellIncY*: SHORT

@@ -9730,13 +9730,13 @@ type
   LPHANDLETABLE* = ptr HANDLETABLE

   HD_HITTESTINFO* {.final, pure.} = object

     pt*: POINT

-    flags*: UINT

+    flags*: WINUINT

     iItem*: int32

 

   THDHITTESTINFO* = HD_HITTESTINFO

   PHDHITTESTINFO* = ptr HD_HITTESTINFO

   HD_ITEM* {.final, pure.} = object

-    mask*: UINT

+    mask*: WINUINT

     cxy*: int32

     pszText*: LPTSTR

     hbm*: HBITMAP

@@ -9753,7 +9753,7 @@ type
     y*: int32

     cx*: int32

     cy*: int32

-    flags*: UINT

+    flags*: WINUINT

 

   LPWINDOWPOS* = ptr WINDOWPOS

   TWINDOWPOS* = WINDOWPOS

@@ -9773,7 +9773,7 @@ type
   THDNOTIFY* = HD_NOTIFY

   PHDNOTIFY* = ptr HD_NOTIFY

   HELPINFO* {.final, pure.} = object

-    cbSize*: UINT

+    cbSize*: WINUINT

     iContextType*: int32

     iCtrlId*: int32

     hItemHandle*: HANDLE

@@ -9795,7 +9795,7 @@ type
   THELPWININFO* = HELPWININFO

   PHELPWININFO* = ptr HELPWININFO

   HIGHCONTRAST* {.final, pure.} = object

-    cbSize*: UINT

+    cbSize*: WINUINT

     dwFlags*: DWORD

     lpszDefaultScheme*: LPTSTR

 

@@ -9818,7 +9818,7 @@ type
   TICONINFO* = ICONINFO

   PICONINFO* = ptr ICONINFO

   ICONMETRICS* {.final, pure.} = object

-    cbSize*: UINT

+    cbSize*: WINUINT

     iHorzSpacing*: int32

     iVertSpacing*: int32

     iTitleWrap*: int32

@@ -9860,7 +9860,7 @@ type
   TWINDOWBUFFERSIZERECORD* = WINDOW_BUFFER_SIZE_RECORD

   PWINDOWBUFFERSIZERECORD* = ptr WINDOW_BUFFER_SIZE_RECORD

   MENU_EVENT_RECORD* {.final, pure.} = object

-    dwCommandId*: UINT

+    dwCommandId*: WINUINT

 

   PMENU_EVENT_RECORD* = ptr MENU_EVENT_RECORD

   TMENUEVENTRECORD* = MENU_EVENT_RECORD

@@ -10039,7 +10039,7 @@ type
   PLUID_AND_ATTRIBUTES_ARRAY* = ptr LUID_AND_ATTRIBUTES_ARRAY

   TLUIDANDATTRIBUTESARRAY* = LUID_AND_ATTRIBUTES_ARRAY

   LV_COLUMN* {.final, pure.} = object

-    mask*: UINT

+    mask*: WINUINT

     fmt*: int32

     cx*: int32

     pszText*: LPTSTR

@@ -10049,11 +10049,11 @@ type
   TLVCOLUMN* = LV_COLUMN

   PLVCOLUMN* = ptr LV_COLUMN

   LV_ITEM* {.final, pure.} = object

-    mask*: UINT

+    mask*: WINUINT

     iItem*: int32

     iSubItem*: int32

-    state*: UINT

-    stateMask*: UINT

+    state*: WINUINT

+    stateMask*: WINUINT

     pszText*: LPTSTR

     cchTextMax*: int32

     iImage*: int32

@@ -10068,17 +10068,17 @@ type
   TLVDISPINFO* = LV_DISPINFO

   PLVDISPINFO* = ptr LV_DISPINFO

   LV_FINDINFO* {.final, pure.} = object

-    flags*: UINT

+    flags*: WINUINT

     psz*: LPCTSTR

     lParam*: LPARAM

     pt*: POINT

-    vkDirection*: UINT

+    vkDirection*: WINUINT

 

   TLVFINDINFO* = LV_FINDINFO

   PLVFINDINFO* = ptr LV_FINDINFO

   LV_HITTESTINFO* {.final, pure.} = object

     pt*: POINT

-    flags*: UINT

+    flags*: WINUINT

     iItem*: int32

 

   TLVHITTESTINFO* = LV_HITTESTINFO

@@ -10086,7 +10086,7 @@ type
   LV_KEYDOWN* {.final, pure.} = object

     hdr*: NMHDR

     wVKey*: int16

-    flags*: UINT

+    flags*: WINUINT

 

   TLVKEYDOWN* = LV_KEYDOWN

   PLVKEYDOWN* = ptr LV_KEYDOWN

@@ -10113,11 +10113,11 @@ type
   TMDICREATESTRUCT* = MDICREATESTRUCT

   PMDICREATESTRUCT* = ptr MDICREATESTRUCT

   MEASUREITEMSTRUCT* {.final, pure.} = object

-    CtlType*: UINT

-    CtlID*: UINT

-    itemID*: UINT

-    itemWidth*: UINT

-    itemHeight*: UINT

+    CtlType*: WINUINT

+    CtlID*: WINUINT

+    itemID*: WINUINT

+    itemWidth*: WINUINT

+    itemHeight*: WINUINT

     itemData*: ULONG_PTR

 

   LPMEASUREITEMSTRUCT* = ptr MEASUREITEMSTRUCT

@@ -10163,7 +10163,7 @@ type
   MENUEX_TEMPLATE_ITEM* {.final, pure.} = object

     dwType*: DWORD

     dwState*: DWORD

-    uId*: UINT

+    uId*: WINUINT

     bResInfo*: int8

     szText*: array[0..0, WCHAR]

     dwHelpId*: DWORD

@@ -10174,7 +10174,7 @@ type
     cbSize*: DWORD

     fMask*: DWORD

     dwStyle*: DWORD

-    cyMax*: UINT

+    cyMax*: WINUINT

     hbrBack*: HBRUSH

     dwContextHelpID*: DWORD

     dwMenuData*: ULONG_PTR

@@ -10184,17 +10184,17 @@ type
   TMENUINFO* = MENUINFO

   PMENUINFO* = ptr MENUINFO

   MENUITEMINFO* {.final, pure.} = object

-    cbSize*: UINT

-    fMask*: UINT

-    fType*: UINT

-    fState*: UINT

-    wID*: UINT

+    cbSize*: WINUINT

+    fMask*: WINUINT

+    fType*: WINUINT

+    fState*: WINUINT

+    wID*: WINUINT

     hSubMenu*: HMENU

     hbmpChecked*: HBITMAP

     hbmpUnchecked*: HBITMAP

     dwItemData*: ULONG_PTR

     dwTypeData*: LPTSTR

-    cch*: UINT

+    cch*: WINUINT

     hbmpItem*: HBITMAP

 

   LPMENUITEMINFO* = ptr MENUITEMINFO

@@ -10248,7 +10248,7 @@ type
   TMETARECORD* = METARECORD

   PMETARECORD* = ptr METARECORD

   MINIMIZEDMETRICS* {.final, pure.} = object

-    cbSize*: UINT

+    cbSize*: WINUINT

     iWidth*: int32

     iHorzGap*: int32

     iVertGap*: int32

@@ -10309,12 +10309,12 @@ type
   TMODEMSETTINGS* = MODEMSETTINGS

   PMODEMSETTINGS* = ptr MODEMSETTINGS

   MONCBSTRUCT* {.final, pure.} = object

-    cb*: UINT

+    cb*: WINUINT

     dwTime*: DWORD

     hTask*: HANDLE

     dwRet*: DWORD

-    wType*: UINT

-    wFmt*: UINT

+    wType*: WINUINT

+    wFmt*: WINUINT

     hConv*: HCONV

     hsz1*: HSZ

     hsz2*: HSZ

@@ -10328,7 +10328,7 @@ type
   TMONCBSTRUCT* = MONCBSTRUCT

   PMONCBSTRUCT* = ptr MONCBSTRUCT

   MONCONVSTRUCT* {.final, pure.} = object

-    cb*: UINT

+    cb*: WINUINT

     fConnect*: WINBOOL

     dwTime*: DWORD

     hTask*: HANDLE

@@ -10340,15 +10340,15 @@ type
   TMONCONVSTRUCT* = MONCONVSTRUCT

   PMONCONVSTRUCT* = ptr MONCONVSTRUCT

   MONERRSTRUCT* {.final, pure.} = object

-    cb*: UINT

-    wLastError*: UINT

+    cb*: WINUINT

+    wLastError*: WINUINT

     dwTime*: DWORD

     hTask*: HANDLE

 

   TMONERRSTRUCT* = MONERRSTRUCT

   PMONERRSTRUCT* = ptr MONERRSTRUCT

   MONHSZSTRUCT* {.final, pure.} = object

-    cb*: UINT

+    cb*: WINUINT

     fsAction*: WINBOOL

     dwTime*: DWORD

     hsz*: HSZ

@@ -10370,7 +10370,7 @@ type
   TMONITORINFO2* = MONITOR_INFO_2

   PMONITORINFO2* = ptr MONITOR_INFO_2

   MONLINKSTRUCT* {.final, pure.} = object

-    cb*: UINT

+    cb*: WINUINT

     dwTime*: DWORD

     hTask*: HANDLE

     fEstablished*: WINBOOL

@@ -10378,7 +10378,7 @@ type
     hszSvc*: HSZ

     hszTopic*: HSZ

     hszItem*: HSZ

-    wFmt*: UINT

+    wFmt*: WINUINT

     fServer*: WINBOOL

     hConvServer*: HCONV

     hConvClient*: HCONV

@@ -10386,11 +10386,11 @@ type
   TMONLINKSTRUCT* = MONLINKSTRUCT

   PMONLINKSTRUCT* = ptr MONLINKSTRUCT

   MONMSGSTRUCT* {.final, pure.} = object

-    cb*: UINT

+    cb*: WINUINT

     hwndTo*: HWND

     dwTime*: DWORD

     hTask*: HANDLE

-    wMsg*: UINT

+    wMsg*: WINUINT

     wParam*: WPARAM

     lParam*: LPARAM

     dmhd*: DDEML_MSG_HOOK_DATA

@@ -10400,7 +10400,7 @@ type
   MOUSEHOOKSTRUCT* {.final, pure.} = object

     pt*: POINT

     hwnd*: HWND

-    wHitTestCode*: UINT

+    wHitTestCode*: WINUINT

     dwExtraInfo*: DWORD

 

   LPMOUSEHOOKSTRUCT* = ptr MOUSEHOOKSTRUCT

@@ -10420,7 +10420,7 @@ type
   MSGBOXCALLBACK* = proc (lpHelpInfo: LPHELPINFO){.stdcall.}

   TMSGBOXCALLBACK* = MSGBOXCALLBACK

   MSGBOXPARAMS* {.final, pure.} = object

-    cbSize*: UINT

+    cbSize*: WINUINT

     hwndOwner*: HWND

     hInstance*: HINST

     lpszText*: LPCSTR

@@ -10437,7 +10437,7 @@ type
   PMSGBOXPARAMS* = ptr MSGBOXPARAMS

   MSGFILTER* {.final, pure.} = object

     nmhdr*: NMHDR

-    msg*: UINT

+    msg*: WINUINT

     wParam*: WPARAM

     lParam*: LPARAM

 

@@ -10546,9 +10546,9 @@ type
     tmPitchAndFamily*: int8

     tmCharSet*: int8

     ntmFlags*: DWORD

-    ntmSizeEM*: UINT

-    ntmCellHeight*: UINT

-    ntmAvgWidth*: UINT

+    ntmSizeEM*: WINUINT

+    ntmCellHeight*: WINUINT

+    ntmAvgWidth*: WINUINT

 

   TNEWTEXTMETRIC* = NEWTEXTMETRIC

   PNEWTEXTMETRIC* = ptr NEWTEXTMETRIC

@@ -10562,19 +10562,19 @@ type
     hdr*: NMHDR

     iItem*: int32

     iSubItem*: int32

-    uNewState*: UINT

-    uOldState*: UINT

-    uChanged*: UINT

+    uNewState*: WINUINT

+    uOldState*: WINUINT

+    uChanged*: WINUINT

     ptAction*: POINT

     lParam*: LPARAM

 

   TNMLISTVIEW* = NM_LISTVIEW

   PNMLISTVIEW* = ptr NM_LISTVIEW

   TV_ITEM* {.final, pure.} = object

-    mask*: UINT

+    mask*: WINUINT

     hItem*: HTREEITEM

-    state*: UINT

-    stateMask*: UINT

+    state*: WINUINT

+    stateMask*: WINUINT

     pszText*: LPTSTR

     cchTextMax*: int32

     iImage*: int32

@@ -10587,7 +10587,7 @@ type
   PTVITEM* = ptr TV_ITEM

   NM_TREEVIEW* {.final, pure.} = object

     hdr*: NMHDR

-    action*: UINT

+    action*: WINUINT

     itemOld*: TV_ITEM

     itemNew*: TV_ITEM

     ptDrag*: POINT

@@ -10603,7 +10603,7 @@ type
   TNMUPDOWN* = NM_UPDOWNW

   PNMUPDOWN* = ptr NM_UPDOWNW

   NONCLIENTMETRICS* {.final, pure.} = object

-    cbSize*: UINT

+    cbSize*: WINUINT

     iBorderWidth*: int32

     iScrollWidth*: int32

     iScrollHeight*: int32

@@ -10666,12 +10666,12 @@ type
   TNSSERVICEINFO* = NS_SERVICE_INFO

   PNSSERVICEINFO* = ptr NS_SERVICE_INFO

   NUMBERFMT* {.final, pure.} = object

-    NumDigits*: UINT

-    LeadingZero*: UINT

-    Grouping*: UINT

+    NumDigits*: WINUINT

+    LeadingZero*: WINUINT

+    Grouping*: WINUINT

     lpDecimalSep*: LPTSTR

     lpThousandSep*: LPTSTR

-    NegativeOrder*: UINT

+    NegativeOrder*: WINUINT

 

   Tnumberfmt* = NUMBERFMT

   Pnumberfmt* = ptr NUMBERFMT

@@ -10821,31 +10821,31 @@ type
   TTEXTMETRICW* = TEXTMETRICW

   PTEXTMETRICW* = ptr TEXTMETRICW

   OUTLINETEXTMETRIC* {.final, pure.} = object

-    otmSize*: UINT

+    otmSize*: WINUINT

     otmTextMetrics*: TEXTMETRIC

     otmFiller*: int8

     otmPanoseNumber*: PANOSE

-    otmfsSelection*: UINT

-    otmfsType*: UINT

+    otmfsSelection*: WINUINT

+    otmfsType*: WINUINT

     otmsCharSlopeRise*: int32

     otmsCharSlopeRun*: int32

     otmItalicAngle*: int32

-    otmEMSquare*: UINT

+    otmEMSquare*: WINUINT

     otmAscent*: int32

     otmDescent*: int32

-    otmLineGap*: UINT

-    otmsCapEmHeight*: UINT

-    otmsXHeight*: UINT

+    otmLineGap*: WINUINT

+    otmsCapEmHeight*: WINUINT

+    otmsXHeight*: WINUINT

     otmrcFontBox*: RECT

     otmMacAscent*: int32

     otmMacDescent*: int32

-    otmMacLineGap*: UINT

-    otmusMinimumPPEM*: UINT

+    otmMacLineGap*: WINUINT

+    otmusMinimumPPEM*: WINUINT

     otmptSubscriptSize*: POINT

     otmptSubscriptOffset*: POINT

     otmptSuperscriptSize*: POINT

     otmptSuperscriptOffset*: POINT

-    otmsStrikeoutSize*: UINT

+    otmsStrikeoutSize*: WINUINT

     otmsStrikeoutPosition*: int32

     otmsUnderscoreSize*: int32

     otmsUnderscorePosition*: int32

@@ -10900,7 +10900,7 @@ type
   TPAINTSTRUCT* = PAINTSTRUCT

   PPAINTSTRUCT* = ptr PAINTSTRUCT

   PARAFORMAT* {.final, pure.} = object

-    cbSize*: UINT

+    cbSize*: WINUINT

     dwMask*: DWORD

     wNumbering*: int16

     wReserved*: int16

@@ -10981,9 +10981,9 @@ type
   POLYTEXT* {.final, pure.} = object

     x*: int32

     y*: int32

-    n*: UINT

+    n*: WINUINT

     lpstr*: LPCTSTR

-    uiFlags*: UINT

+    uiFlags*: WINUINT

     rcl*: RECT

     pdx*: ptr int32

 

@@ -11169,7 +11169,7 @@ type
   LPPROCESS_INFORMATION* = ptr PROCESS_INFORMATION

   TPROCESSINFORMATION* = PROCESS_INFORMATION

   PPROCESSINFORMATION* = ptr PROCESS_INFORMATION

-  LPFNPSPCALLBACK* = proc (para1: HWND, para2: UINT, para3: LPVOID): UINT{.

+  LPFNPSPCALLBACK* = proc (para1: HWND, para2: WINUINT, para3: LPVOID): WINUINT{.

       stdcall.}

   TFNPSPCALLBACK* = LPFNPSPCALLBACK

   PROPSHEETPAGE* {.final, pure.} = object

@@ -11181,7 +11181,7 @@ type
     pfnDlgProc*: DLGPROC

     lParam*: LPARAM

     pfnCallback*: LPFNPSPCALLBACK

-    pcRefParent*: ptr UINT

+    pcRefParent*: ptr WINUINT

 

   LPPROPSHEETPAGE* = ptr PROPSHEETPAGE

   LPCPROPSHEETPAGE* = ptr PROPSHEETPAGE

@@ -11197,7 +11197,7 @@ type
     hInstance*: HINST

     pszIcon*: LPCTSTR

     pszCaption*: LPCTSTR

-    nPages*: UINT

+    nPages*: WINUINT

     pStartPage*: LPCTSTR

     phpage*: ptr HPROPSHEETPAGE

     pfnCallback*: PFNPROPSHEETCALLBACK

@@ -11243,7 +11243,7 @@ type
   TPSHNOTIFY* = PSHNOTIFY

   PPSHNOTIFY* = ptr PSHNOTIFY

   PUNCTUATION* {.final, pure.} = object

-    iSize*: UINT

+    iSize*: WINUINT

     szPunctuation*: LPSTR

 

   Tpunctuation* = PUNCTUATION

@@ -11395,11 +11395,11 @@ type
   TRGNDATA* = RGNDATA

   PRGNDATA* = ptr RGNDATA

   SCROLLINFO* {.final, pure.} = object

-    cbSize*: UINT

-    fMask*: UINT

+    cbSize*: WINUINT

+    fMask*: WINUINT

     nMin*: int32

     nMax*: int32

-    nPage*: UINT

+    nPage*: WINUINT

     nPos*: int32

     nTrackPos*: int32

 

@@ -11499,7 +11499,7 @@ type
   PFILEOPFLAGS* = ptr FILEOP_FLAGS

   SHFILEOPSTRUCT* {.final, pure.} = object

     hwnd*: HWND

-    wFunc*: UINT

+    wFunc*: WINUINT

     pFrom*: LPCSTR

     pTo*: LPCSTR

     fFlags*: FILEOP_FLAGS

@@ -11537,7 +11537,7 @@ type
   TSINGLELISTENTRY* = SINGLE_LIST_ENTRY

   PSINGLELISTENTRY* = ptr SINGLE_LIST_ENTRY

   SOUNDSENTRY* {.final, pure.} = object

-    cbSize*: UINT

+    cbSize*: WINUINT

     dwFlags*: DWORD

     iFSTextEffect*: DWORD

     iFSTextEffectMSec*: DWORD

@@ -11584,7 +11584,7 @@ type
   TSTICKYKEYS* = STICKYKEYS

   PSTICKYKEYS* = ptr STICKYKEYS

   STRRET* {.final, pure.} = object

-    uType*: UINT

+    uType*: WINUINT

     cStr*: array[0..(MAX_PATH) - 1, char]

 

   LPSTRRET* = ptr STRRET

@@ -11709,7 +11709,7 @@ type
   PTAPEWRITEMARKS* = ptr TAPE_WRITE_MARKS

   TTBADDBITMAP* {.final, pure.} = object

     hInst*: HINST

-    nID*: UINT

+    nID*: WINUINT

 

   LPTBADDBITMAP* = ptr TTBADDBITMAP

   PTBADDBITMAP* = ptr TTBADDBITMAP

@@ -11744,14 +11744,14 @@ type
   PTBSAVEPARAMS* = ptr TBSAVEPARAMS

   TC_HITTESTINFO* {.final, pure.} = object

     pt*: POINT

-    flags*: UINT

+    flags*: WINUINT

 

   TTCHITTESTINFO* = TC_HITTESTINFO

   PTCHITTESTINFO* = ptr TC_HITTESTINFO

   TC_ITEM* {.final, pure.} = object

-    mask*: UINT

-    lpReserved1*: UINT

-    lpReserved2*: UINT

+    mask*: WINUINT

+    lpReserved1*: WINUINT

+    lpReserved2*: WINUINT

     pszText*: LPTSTR

     cchTextMax*: int32

     iImage*: int32

@@ -11760,9 +11760,9 @@ type
   TTCITEM* = TC_ITEM

   PTCITEM* = ptr TC_ITEM

   TC_ITEMHEADER* {.final, pure.} = object

-    mask*: UINT

-    lpReserved1*: UINT

-    lpReserved2*: UINT

+    mask*: WINUINT

+    lpReserved1*: WINUINT

+    lpReserved2*: WINUINT

     pszText*: LPTSTR

     cchTextMax*: int32

     iImage*: int32

@@ -11772,7 +11772,7 @@ type
   TC_KEYDOWN* {.final, pure.} = object

     hdr*: NMHDR

     wVKey*: int16

-    flags*: UINT

+    flags*: WINUINT

 

   TTCKEYDOWN* = TC_KEYDOWN

   PTCKEYDOWN* = ptr TC_KEYDOWN

@@ -11855,10 +11855,10 @@ type
 

   PTOKENUSER* = ptr TTOKEN_USER

   TOOLINFO* {.final, pure.} = object

-    cbSize*: UINT

-    uFlags*: UINT

+    cbSize*: WINUINT

+    uFlags*: WINUINT

     hwnd*: HWND

-    uId*: UINT

+    uId*: WINUINT

     rect*: RECT

     hinst*: HINST

     lpszText*: LPTSTR

@@ -11871,13 +11871,13 @@ type
     lpszText*: LPTSTR

     szText*: array[0..79, char]

     hinst*: HINST

-    uFlags*: UINT

+    uFlags*: WINUINT

 

   LPTOOLTIPTEXT* = ptr TOOLTIPTEXT

   TTOOLTIPTEXT* = TOOLTIPTEXT

   PTOOLTIPTEXT* = ptr TOOLTIPTEXT

   TPMPARAMS* {.final, pure.} = object

-    cbSize*: UINT

+    cbSize*: WINUINT

     rcExclude*: RECT

 

   LPTPMPARAMS* = ptr TPMPARAMS

@@ -11923,7 +11923,7 @@ type
   PTVDISPINFO* = ptr TV_DISPINFO

   TV_HITTESTINFO* {.final, pure.} = object

     pt*: POINT

-    flags*: UINT

+    flags*: WINUINT

     hItem*: HTREEITEM

 

   LPTV_HITTESTINFO* = ptr TV_HITTESTINFO

@@ -11940,7 +11940,7 @@ type
   TV_KEYDOWN* {.final, pure.} = object

     hdr*: NMHDR

     wVKey*: int16

-    flags*: UINT

+    flags*: WINUINT

 

   TTVKEYDOWN* = TV_KEYDOWN

   PTVKEYDOWN* = ptr TV_KEYDOWN

@@ -11953,8 +11953,8 @@ type
   TTVSORTCB* = TV_SORTCB

   PTVSORTCB* = ptr TV_SORTCB

   UDACCEL* {.final, pure.} = object

-    nSec*: UINT

-    nInc*: UINT

+    nSec*: WINUINT

+    nInc*: WINUINT

 

   TUDACCEL* = UDACCEL

   PUDACCEL* = ptr UDACCEL

@@ -12045,9 +12045,9 @@ type
   TWIN32STREAMID* = WIN32_STREAM_ID

   PWIN32STREAMID* = ptr WIN32_STREAM_ID

   WINDOWPLACEMENT* {.final, pure.} = object

-    len*: UINT

-    flags*: UINT

-    showCmd*: UINT

+    len*: WINUINT

+    flags*: WINUINT

+    showCmd*: WINUINT

     ptMinPosition*: POINT

     ptMaxPosition*: POINT

     rcNormalPosition*: RECT

@@ -12055,7 +12055,7 @@ type
   TWINDOWPLACEMENT* = WINDOWPLACEMENT

   PWINDOWPLACEMENT* = ptr WINDOWPLACEMENT

   WNDCLASS* {.final, pure.} = object

-    style*: UINT

+    style*: WINUINT

     lpfnWndProc*: WNDPROC

     cbClsExtra*: int32

     cbWndExtra*: int32

@@ -12071,7 +12071,7 @@ type
   TWNDCLASSA* = WNDCLASS

   PWNDCLASS* = ptr WNDCLASS

   WNDCLASSW* {.final, pure.} = object

-    style*: UINT

+    style*: WINUINT

     lpfnWndProc*: WNDPROC

     cbClsExtra*: int32

     cbWndExtra*: int32

@@ -12086,8 +12086,8 @@ type
   TWNDCLASSW* = WNDCLASSW

   PWNDCLASSW* = ptr WNDCLASSW

   WNDCLASSEX* {.final, pure.} = object

-    cbSize*: UINT

-    style*: UINT

+    cbSize*: WINUINT

+    style*: WINUINT

     lpfnWndProc*: WNDPROC

     cbClsExtra*: int32

     cbWndExtra*: int32

@@ -12104,8 +12104,8 @@ type
   TWNDCLASSEXA* = WNDCLASSEX

   PWNDCLASSEX* = ptr WNDCLASSEX

   WNDCLASSEXW* {.final, pure.} = object

-    cbSize*: UINT

-    style*: UINT

+    cbSize*: WINUINT

+    style*: WINUINT

     lpfnWndProc*: WNDPROC

     cbClsExtra*: int32

     cbWndExtra*: int32

@@ -12362,9 +12362,9 @@ type
   NOTIFYICONDATAA* {.final, pure.} = object

     cbSize*: DWORD

     Wnd*: HWND

-    uID*: UINT

-    uFlags*: UINT

-    uCallbackMessage*: UINT

+    uID*: WINUINT

+    uFlags*: WINUINT

+    uCallbackMessage*: WINUINT

     hIcon*: HICON

     szTip*: array[0..63, Char]

 

@@ -12372,9 +12372,9 @@ type
   NOTIFYICONDATAW* {.final, pure.} = object

     cbSize*: DWORD

     Wnd*: HWND

-    uID*: UINT

-    uFlags*: UINT

-    uCallbackMessage*: UINT

+    uID*: WINUINT

+    uFlags*: WINUINT

+    uCallbackMessage*: WINUINT

     hIcon*: HICON

     szTip*: array[0..63, int16]

 

@@ -13519,7 +13519,7 @@ else:
 type

   MSG* {.final, pure.} = object

     hwnd*: HWND

-    message*: UINT

+    message*: WINUINT

     wParam*: WPARAM

     lParam*: LPARAM

     time*: DWORD

@@ -13530,20 +13530,20 @@ type
   PMSG* = ptr MSG

   PMessage* = ptr TMessage

   TMessage* {.final, pure.} = object          #fields according to ICS

-    msg*: UINT

+    msg*: WINUINT

     wParam*: WPARAM

     lParam*: LPARAM

     Result*: LRESULT

 

   TWMSize* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     SizeType*: WPARAM

     Width*: HALFPARAM

     Height*: HALFPARAM

     Result*: LRESULT

 

   TWMNoParams* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Unused*: array[0..3, HALFPARAM]

     Result*: LRESULT

 

@@ -13553,7 +13553,7 @@ type
   TWMClose* = TWMNoParams

   TWMQueryUIState* = TWMNoParams

   TWMUIState* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Action*: int16

     Flags*: int16

     Unused*: HRESULT

@@ -13561,7 +13561,7 @@ type
   TWMChangeUIState* = TWMUIState

   TWMUpdateUIState* = TWMUIState

   TWMKey* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     CharCode*: int16

     Unused*: int16

     KeyData*: int32

@@ -13574,7 +13574,7 @@ type
   TWMSysKeyDown* = TWMKey

   TWMSysKeyUp* = TWMKey

   TWMMenuChar* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     User*: Char

     MenuFlag*: int16

     Menu*: HMENU

@@ -13586,7 +13586,7 @@ type
   TWMSysColorChange* = TWMNoParams

   TWMQueryDragIcon* = TWMNoParams

   TWMScroll* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     ScrollCode*: HALFPARAM

     Pos*: HALFPARAM

     ScrollBar*: HWND

@@ -13595,59 +13595,59 @@ type
   TWMHScroll* = TWMScroll

   TWMVScroll* = TWMScroll

   TWMGetText* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     TextMax*: LPARAM

     Text*: cstring

     Result*: LRESULT

 

   TWMGetTextLength* = TWMNoParams

   TWMKillFocus* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     FocusedWnd*: HWND

     UnUsed*: WPARAM

     Result*: LRESULT

 

   TWMSetCursor* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     CursorWnd*: HWND

     HitTest*: HALFPARAM

     MouseMsg*: HALFPARAM

     Result*: LRESULT

 

   TWMSetFocus* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     FocusedWnd*: HWND

     Unused*: WPARAM

     Result*: LRESULT

 

   TWMSetFont* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Font*: HFONT

     Redraw*: HALFPARAMBOOL

     Unused*: HALFPARAM

     Result*: LRESULT

 

   TWMShowWindow* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Show*: HALFPARAMBOOL

     Unused*: HALFPARAM

     Status*: WPARAM

     Result*: LRESULT

 

   TWMEraseBkgnd* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     DC*: HDC

     Unused*: LPARAM

     Result*: LRESULT

 

   TWMNCHitTest* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Unused*: int32

     Pos*: TSmallPoint

     Result*: LRESULT

 

   TWMMouse* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Keys*: int32

     Pos*: TSmallPoint

     Result*: LRESULT

@@ -13659,14 +13659,14 @@ type
   TWMMButtonDown* = TWMMouse

   TWMMButtonUp* = TWMMouse

   TWMMouseWheel* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Keys*: int16

     WheelDelta*: int16

     Pos*: TSmallPoint

     Result*: LRESULT

 

   TWMNCHitMessage* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     HitTest*: int32

     XCursor*: int16

     YCursor*: int16

@@ -13684,51 +13684,51 @@ type
   TWMRButtonUp* = TWMMouse

   TWMMouseMove* = TWMMouse

   TWMPaint* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     DC*: HDC

     Unused*: int32

     Result*: LRESULT

 

   TWMCommand* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     ItemID*: int16

     NotifyCode*: int16

     Ctl*: HWND

     Result*: LRESULT

 

   TWMNotify* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     IDCtrl*: int32

     NMHdr*: PNMHdr

     Result*: LRESULT

 

   TWMPrint* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     DC*: HDC

     Flags*: int

     Result*: LRESULT

 

   TWMPrintClient* = TWMPrint

   TWMWinIniChange* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Unused*: int

     Section*: cstring

     Result*: LRESULT

 

   TWMContextMenu* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     hWnd*: HWND

     Pos*: TSmallPoint

     Result*: LRESULT

 

   TWMNCCalcSize* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     CalcValidRects*: WINBOOL

     CalcSize_Params*: PNCCalcSizeParams

     Result*: LRESULT

 

   TWMCharToItem* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Key*: int16

     CaretPos*: int16

     ListBox*: HWND

@@ -13737,7 +13737,7 @@ type
   TWMVKeyToItem* = TWMCharToItem

   TMyEventRange = range[0'i16..16000'i16]

   TWMParentNotify* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     case Event*: TMyEventRange

     of TMyEventRange(WM_CREATE), TMyEventRange(WM_DESTROY):

         ChildID*: int16

@@ -13756,7 +13756,7 @@ type
         Result*: LRESULT

 

   TWMSysCommand* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     CmdType*: int32

     XPos*: int16

     YPos*: int16

@@ -13774,13 +13774,13 @@ type
   #      Key*: int16

 

   TWMMove* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Unused*: int

     Pos*: TSmallPoint

     Result*: LRESULT

 

   TWMWindowPosMsg* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Unused*: int

     WindowPos*: PWindowPos

     Result*: LRESULT

@@ -13788,101 +13788,101 @@ type
   TWMWindowPosChanged* = TWMWindowPosMsg

   TWMWindowPosChanging* = TWMWindowPosMsg

   TWMCompareItem* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Ctl*: HWnd

     CompareItemStruct*: PCompareItemStruct

     Result*: LRESULT

 

   TWMDeleteItem* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Ctl*: HWND

     DeleteItemStruct*: PDeleteItemStruct

     Result*: LRESULT

 

   TWMDrawItem* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Ctl*: HWND

     DrawItemStruct*: PDrawItemStruct

     Result*: LRESULT

 

   TWMMeasureItem* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     IDCtl*: HWnd

     MeasureItemStruct*: PMeasureItemStruct

     Result*: LRESULT

 

   TWMNCCreate* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Unused*: int

     CreateStruct*: PCreateStruct

     Result*: LRESULT

 

   TWMInitMenuPopup* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     MenuPopup*: HMENU

     Pos*: int16

     SystemMenu*: WordBool

     Result*: LRESULT

 

   TWMMenuSelect* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     IDItem*: int16

     MenuFlag*: int16

     Menu*: HMENU

     Result*: LRESULT

 

   TWMActivate* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Active*: int16

     Minimized*: WordBool

     ActiveWindow*: HWND

     Result*: LRESULT

 

   TWMQueryEndSession* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Source*: int32

     Unused*: int32

     Result*: LRESULT

 

   TWMMDIActivate* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     DeactiveWnd*: HWND

     ActiveWnd*: HWND

     Result*: LRESULT

 

   TWMNextDlgCtl* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     CtlFocus*: int32

     Handle*: WordBool

     Unused*: int16

     Result*: LRESULT

 

   TWMHelp* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Unused*: int

     HelpInfo*: PHelpInfo

     Result*: LRESULT

 

   TWMGetMinMaxInfo* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Unused*: int

     MinMaxInfo*: PMinMaxInfo

     Result*: LRESULT

 

   TWMSettingChange* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Flag*: int

     Section*: cstring

     Result*: LRESULT

 

   TWMCreate* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Unused*: int

     CreateStruct*: PCreateStruct

     Result*: LRESULT

 

   TWMCtlColor* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     ChildDC*: HDC

     ChildWnd*: HWND

     Result*: LRESULT

@@ -13895,38 +13895,38 @@ type
   TWMCtlColorDlg* = TWMCtlColor

   TWMCtlColorEdit* = TWMCtlColor

   TWMInitDialog* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Focus*: HWND

     InitParam*: int32

     Result*: LRESULT

 

   TWMNCPaint* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     RGN*: HRGN

     Unused*: int32

     Result*: LRESULT

 

   TWMSetText* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Unused*: int32

     Text*: cstring

     Result*: LRESULT

 

   TWMSizeClipboard* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Viewer*: HWND

     RC*: THandle

     Result*: LRESULT

 

   TWMSpoolerStatus* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     JobStatus*: LPARAM

     JobsLeft*: WPARAM

     Unused*: WPARAM

     Result*: LRESULT

 

   TWMStyleChange* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     StyleType*: LPARAM

     StyleStruct*: PStyleStruct

     Result*: LRESULT

@@ -13934,42 +13934,42 @@ type
   TWMStyleChanged* = TWMStyleChange

   TWMStyleChanging* = TWMStyleChange

   TWMSysDeadChar* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     CharCode*: WPARAM

     Unused*: WPARAM

     KeyData*: LPARAM

     Result*: LRESULT

 

   TWMSystemError* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     ErrSpec*: WPARAM

     Unused*: LPARAM

     Result*: LRESULT

 

   TWMTimeChange* = TWMNoParams

   TWMTimer* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     TimerID*: LPARAM

     TimerProc*: TFarProc

     Result*: LRESULT

 

   TWMUndo* = TWMNoParams

   TWMVScrollClipboard* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Viewer*: HWND

     ScollCode*: WPARAM

     ThumbPos*: WPARAM

     Result*: LRESULT

 

   TWMDisplayChange* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     BitsPerPixel*: int

     Width*: WPARAM

     Height*: WPARAM

     Result*: LRESULT

 

   TWMDropFiles* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Drop*: THANDLE

     Unused*: LPARAM

     Result*: LRESULT

@@ -14042,7 +14042,7 @@ proc GetModuleFileNameA*(hModule: HINST, lpFilename: LPSTR, nSize: DWORD): DWORD
     stdcall, dynlib: "kernel32", importc.}

 proc GetModuleHandleA*(lpModuleName: LPCSTR): HMODULE{.stdcall,

      dynlib: "kernel32", importc.}

-proc FatalAppExitA*(uAction: UINT, lpMessageText: LPCSTR){.stdcall,

+proc FatalAppExitA*(uAction: WINUINT, lpMessageText: LPCSTR){.stdcall,

      dynlib: "kernel32", importc.}

 proc GetCommandLineA*(): LPSTR{.stdcall, dynlib: "kernel32", importc.}

 proc GetEnvironmentVariableA*(lpName: LPCSTR, lpBuffer: LPSTR, nSize: DWORD): DWORD{.

@@ -14080,15 +14080,15 @@ proc GlobalAddAtomA*(lpString: LPCSTR): ATOM{.stdcall, dynlib: "kernel32",
     importc: "GlobalAddAtomA".}

 proc GlobalFindAtomA*(lpString: LPCSTR): ATOM{.stdcall, dynlib: "kernel32",

     importc: "GlobalFindAtomA".}

-proc GlobalGetAtomNameA*(nAtom: ATOM, lpBuffer: LPSTR, nSize: int32): UINT{.

+proc GlobalGetAtomNameA*(nAtom: ATOM, lpBuffer: LPSTR, nSize: int32): WINUINT{.

     stdcall, dynlib: "kernel32", importc: "GlobalGetAtomNameA".}

 proc AddAtomA*(lpString: LPCSTR): ATOM{.stdcall, dynlib: "kernel32",

                                         importc: "AddAtomA".}

 proc FindAtomA*(lpString: LPCSTR): ATOM{.stdcall, dynlib: "kernel32",

     importc: "FindAtomA".}

-proc GetAtomNameA*(nAtom: ATOM, lpBuffer: LPSTR, nSize: int32): UINT{.stdcall,

+proc GetAtomNameA*(nAtom: ATOM, lpBuffer: LPSTR, nSize: int32): WINUINT{.stdcall,

     dynlib: "kernel32", importc: "GetAtomNameA".}

-proc GetProfileIntA*(lpAppName: LPCSTR, lpKeyName: LPCSTR, nDefault: WINT): UINT{.

+proc GetProfileIntA*(lpAppName: LPCSTR, lpKeyName: LPCSTR, nDefault: WINT): WINUINT{.

     stdcall, dynlib: "kernel32", importc: "GetProfileIntA".}

 proc GetProfileStringA*(lpAppName: LPCSTR, lpKeyName: LPCSTR, lpDefault: LPCSTR,

                         lpReturnedString: LPSTR, nSize: DWORD): DWORD{.stdcall,

@@ -14101,7 +14101,7 @@ proc GetProfileSectionA*(lpAppName: LPCSTR, lpReturnedString: LPSTR,
 proc WriteProfileSectionA*(lpAppName: LPCSTR, lpString: LPCSTR): WINBOOL{.

     stdcall, dynlib: "kernel32", importc: "WriteProfileSectionA".}

 proc GetPrivateProfileIntA*(lpAppName: LPCSTR, lpKeyName: LPCSTR,

-                            nDefault: WINT, lpFileName: LPCSTR): UINT{.stdcall,

+                            nDefault: WINT, lpFileName: LPCSTR): WINUINT{.stdcall,

     dynlib: "kernel32", importc: "GetPrivateProfileIntA".}

 proc GetPrivateProfileStringA*(lpAppName: LPCSTR, lpKeyName: LPCSTR,

                                lpDefault: LPCSTR, lpReturnedString: LPSTR,

@@ -14117,16 +14117,16 @@ proc GetPrivateProfileSectionA*(lpAppName: LPCSTR, lpReturnedString: LPSTR,
 proc WritePrivateProfileSectionA*(lpAppName: LPCSTR, lpString: LPCSTR,

                                   lpFileName: LPCSTR): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "WritePrivateProfileSectionA".}

-proc GetDriveTypeA*(lpRootPathName: LPCSTR): UINT{.stdcall, dynlib: "kernel32",

+proc GetDriveTypeA*(lpRootPathName: LPCSTR): WINUINT{.stdcall, dynlib: "kernel32",

     importc: "GetDriveTypeA".}

-proc GetSystemDirectoryA*(lpBuffer: LPSTR, uSize: UINT): UINT{.stdcall,

+proc GetSystemDirectoryA*(lpBuffer: LPSTR, uSize: WINUINT): WINUINT{.stdcall,

     dynlib: "kernel32", importc: "GetSystemDirectoryA".}

 proc GetTempPathA*(nBufferLength: DWORD, lpBuffer: LPSTR): DWORD{.stdcall,

     dynlib: "kernel32", importc: "GetTempPathA".}

 proc GetTempFileNameA*(lpPathName: LPCSTR, lpPrefixString: LPCSTR,

-                       uUnique: UINT, lpTempFileName: LPSTR): UINT{.stdcall,

+                       uUnique: WINUINT, lpTempFileName: LPSTR): WINUINT{.stdcall,

     dynlib: "kernel32", importc: "GetTempFileNameA".}

-proc GetWindowsDirectoryA*(lpBuffer: LPSTR, uSize: UINT): UINT{.stdcall,

+proc GetWindowsDirectoryA*(lpBuffer: LPSTR, uSize: WINUINT): WINUINT{.stdcall,

     dynlib: "kernel32", importc: "GetWindowsDirectoryA".}

 proc SetCurrentDirectoryA*(lpPathName: LPCSTR): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "SetCurrentDirectoryA".}

@@ -14267,7 +14267,7 @@ proc GetFileSecurityA*(lpFileName: LPCSTR,
 proc FindFirstChangeNotificationA*(lpPathName: LPCSTR, bWatchSubtree: WINBOOL,

                                    dwNotifyFilter: DWORD): HANDLE{.stdcall,

     dynlib: "kernel32", importc: "FindFirstChangeNotificationA".}

-proc IsBadStringPtrA*(lpsz: LPCSTR, ucchMax: UINT): WINBOOL{.stdcall,

+proc IsBadStringPtrA*(lpsz: LPCSTR, ucchMax: WINUINT): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "IsBadStringPtrA".}

 proc LookupAccountSidA*(lpSystemName: LPCSTR, Sid: PSID, Name: LPSTR,

                         cbName: LPDWORD, ReferencedDomainName: LPSTR,

@@ -14304,7 +14304,7 @@ proc SetComputerNameA*(lpComputerName: LPCSTR): WINBOOL{.stdcall,
     dynlib: "kernel32", importc: "SetComputerNameA".}

 proc GetUserNameA*(lpBuffer: LPSTR, nSize: LPDWORD): WINBOOL{.stdcall,

     dynlib: "advapi32", importc: "GetUserNameA".}

-proc LoadKeyboardLayoutA*(pwszKLID: LPCSTR, Flags: UINT): HKL{.stdcall,

+proc LoadKeyboardLayoutA*(pwszKLID: LPCSTR, Flags: WINUINT): HKL{.stdcall,

     dynlib: "user32", importc: "LoadKeyboardLayoutA".}

 proc GetKeyboardLayoutNameA*(pwszKLID: LPSTR): WINBOOL{.stdcall,

     dynlib: "user32", importc: "GetKeyboardLayoutNameA".}

@@ -14332,35 +14332,35 @@ proc GetUserObjectInformationA*(hObj: HANDLE, nIndex: int32, pvInfo: PVOID,
 proc SetUserObjectInformationA*(hObj: HANDLE, nIndex: int32, pvInfo: PVOID,

                                 nLength: DWORD): WINBOOL{.stdcall,

     dynlib: "user32", importc: "SetUserObjectInformationA".}

-proc RegisterWindowMessageA*(lpString: LPCSTR): UINT{.stdcall, dynlib: "user32",

+proc RegisterWindowMessageA*(lpString: LPCSTR): WINUINT{.stdcall, dynlib: "user32",

     importc: "RegisterWindowMessageA".}

-proc GetMessageA*(lpMsg: LPMSG, wnd: HWND, wMsgFilterMin: UINT,

-                  wMsgFilterMax: UINT): WINBOOL{.stdcall, dynlib: "user32",

+proc GetMessageA*(lpMsg: LPMSG, wnd: HWND, wMsgFilterMin: WINUINT,

+                  wMsgFilterMax: WINUINT): WINBOOL{.stdcall, dynlib: "user32",

     importc: "GetMessageA".}

 proc DispatchMessageA*(lpMsg: LPMSG): LONG{.stdcall, dynlib: "user32",

     importc: "DispatchMessageA".}

-proc PeekMessageA*(lpMsg: LPMSG, wnd: HWND, wMsgFilterMin: UINT,

-                   wMsgFilterMax: UINT, wRemoveMsg: UINT): WINBOOL{.stdcall,

+proc PeekMessageA*(lpMsg: LPMSG, wnd: HWND, wMsgFilterMin: WINUINT,

+                   wMsgFilterMax: WINUINT, wRemoveMsg: WINUINT): WINBOOL{.stdcall,

     dynlib: "user32", importc: "PeekMessageA".}

-proc SendMessageA*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): LRESULT{.

+proc SendMessageA*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): LRESULT{.

     stdcall, dynlib: "user32", importc: "SendMessageA".}

-proc SendMessageTimeoutA*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM,

-                          fuFlags: UINT, uTimeout: UINT, lpdwResult: LPDWORD): LRESULT{.

+proc SendMessageTimeoutA*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM,

+                          fuFlags: WINUINT, uTimeout: WINUINT, lpdwResult: LPDWORD): LRESULT{.

     stdcall, dynlib: "user32", importc: "SendMessageTimeoutA".}

-proc SendNotifyMessageA*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): WINBOOL{.

+proc SendNotifyMessageA*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): WINBOOL{.

     stdcall, dynlib: "user32", importc: "SendNotifyMessageA".}

-proc SendMessageCallbackA*(wnd: HWND, Msg: UINT, wp: WPARAM,

+proc SendMessageCallbackA*(wnd: HWND, Msg: WINUINT, wp: WPARAM,

                            lp: LPARAM, lpResultCallBack: SENDASYNCPROC,

                            dwData: DWORD): WINBOOL{.stdcall, dynlib: "user32",

     importc: "SendMessageCallbackA".}

-proc PostMessageA*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): WINBOOL{.

+proc PostMessageA*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): WINBOOL{.

     stdcall, dynlib: "user32", importc: "PostMessageA".}

-proc PostThreadMessageA*(idThread: DWORD, Msg: UINT, wp: WPARAM,

+proc PostThreadMessageA*(idThread: DWORD, Msg: WINUINT, wp: WPARAM,

                          lp: LPARAM): WINBOOL{.stdcall, dynlib: "user32",

     importc: "PostThreadMessageA".}

-proc DefWindowProcA*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): LRESULT{.

+proc DefWindowProcA*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): LRESULT{.

     stdcall, dynlib: "user32", importc: "DefWindowProcA".}

-proc CallWindowProcA*(lpPrevWndFunc: WNDPROC, wnd: HWND, Msg: UINT,

+proc CallWindowProcA*(lpPrevWndFunc: WNDPROC, wnd: HWND, Msg: WINUINT,

                       wp: WPARAM, lp: LPARAM): LRESULT{.stdcall,

     dynlib: "user32", importc: "CallWindowProcA".}

 proc RegisterClassA*(lpWndClass: LPWNDCLASS): ATOM{.stdcall, dynlib: "user32",

@@ -14398,18 +14398,18 @@ proc DialogBoxIndirectParamA*(hInstance: HINST, hDialogTemplate: LPCDLGTEMPLATE,
 proc SetDlgItemTextA*(hDlg: HWND, nIDDlgItem: int32, lpString: LPCSTR): WINBOOL{.

     stdcall, dynlib: "user32", importc: "SetDlgItemTextA".}

 proc GetDlgItemTextA*(hDlg: HWND, nIDDlgItem: int32, lpString: LPSTR,

-                      nMaxCount: int32): UINT{.stdcall, dynlib: "user32",

+                      nMaxCount: int32): WINUINT{.stdcall, dynlib: "user32",

     importc: "GetDlgItemTextA".}

-proc SendDlgItemMessageA*(hDlg: HWND, nIDDlgItem: int32, Msg: UINT,

+proc SendDlgItemMessageA*(hDlg: HWND, nIDDlgItem: int32, Msg: WINUINT,

                           wp: WPARAM, lp: LPARAM): LONG{.stdcall,

     dynlib: "user32", importc: "SendDlgItemMessageA".}

-proc DefDlgProcA*(hDlg: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): LRESULT{.

+proc DefDlgProcA*(hDlg: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): LRESULT{.

     stdcall, dynlib: "user32", importc: "DefDlgProcA".}

 proc CallMsgFilterA*(lpMsg: LPMSG, nCode: int32): WINBOOL{.stdcall,

     dynlib: "user32", importc: "CallMsgFilterA".}

-proc RegisterClipboardFormatA*(lpszFormat: LPCSTR): UINT{.stdcall,

+proc RegisterClipboardFormatA*(lpszFormat: LPCSTR): WINUINT{.stdcall,

     dynlib: "user32", importc: "RegisterClipboardFormatA".}

-proc GetClipboardFormatNameA*(format: UINT, lpszFormatName: LPSTR,

+proc GetClipboardFormatNameA*(format: WINUINT, lpszFormatName: LPSTR,

                               cchMaxCount: int32): int32{.stdcall,

     dynlib: "user32", importc: "GetClipboardFormatNameA".}

 proc CharToOemA*(lpszSrc: LPCSTR, lpszDst: LPSTR): WINBOOL{.stdcall,

@@ -14446,9 +14446,9 @@ proc VkKeyScanA*(ch: CHAR): SHORT{.stdcall, dynlib: "user32",
                                    importc: "VkKeyScanA".}

 proc VkKeyScanExA*(ch: CHAR, dwhkl: HKL): SHORT{.stdcall, dynlib: "user32",

     importc: "VkKeyScanExA".}

-proc MapVirtualKeyA*(uCode: UINT, uMapType: UINT): UINT{.stdcall,

+proc MapVirtualKeyA*(uCode: WINUINT, uMapType: WINUINT): WINUINT{.stdcall,

     dynlib: "user32", importc: "MapVirtualKeyA".}

-proc MapVirtualKeyExA*(uCode: UINT, uMapType: UINT, dwhkl: HKL): UINT{.stdcall,

+proc MapVirtualKeyExA*(uCode: WINUINT, uMapType: WINUINT, dwhkl: HKL): WINUINT{.stdcall,

     dynlib: "user32", importc: "MapVirtualKeyExA".}

 proc LoadAcceleratorsA*(hInstance: HINST, lpTableName: LPCSTR): HACCEL{.stdcall,

     dynlib: "user32", importc: "LoadAcceleratorsA".}

@@ -14463,35 +14463,35 @@ proc LoadMenuA*(hInstance: HINST, lpMenuName: LPCSTR): HMENU{.stdcall,
     dynlib: "user32", importc: "LoadMenuA".}

 proc LoadMenuIndirectA*(lpMenuTemplate: LPMENUTEMPLATE): HMENU{.stdcall,

     dynlib: "user32", importc: "LoadMenuIndirectA".}

-proc ChangeMenuA*(menu: HMENU, cmd: UINT, lpszNewItem: LPCSTR, cmdInsert: UINT,

-                  flags: UINT): WINBOOL{.stdcall, dynlib: "user32",

+proc ChangeMenuA*(menu: HMENU, cmd: WINUINT, lpszNewItem: LPCSTR, cmdInsert: WINUINT,

+                  flags: WINUINT): WINBOOL{.stdcall, dynlib: "user32",

     importc: "ChangeMenuA".}

-proc GetMenuStringA*(menu: HMENU, uIDItem: UINT, lpString: LPSTR,

-                     nMaxCount: int32, uFlag: UINT): int32{.stdcall,

+proc GetMenuStringA*(menu: HMENU, uIDItem: WINUINT, lpString: LPSTR,

+                     nMaxCount: int32, uFlag: WINUINT): int32{.stdcall,

     dynlib: "user32", importc: "GetMenuStringA".}

-proc InsertMenuA*(menu: HMENU, uPosition: UINT, uFlags: UINT, uIDNewItem: UINT,

+proc InsertMenuA*(menu: HMENU, uPosition: WINUINT, uFlags: WINUINT, uIDNewItem: WINUINT,

                   lpNewItem: LPCSTR): WINBOOL{.stdcall, dynlib: "user32",

     importc: "InsertMenuA".}

-proc AppendMenuA*(menu: HMENU, uFlags: UINT, uIDNewItem: UINT,

+proc AppendMenuA*(menu: HMENU, uFlags: WINUINT, uIDNewItem: WINUINT,

                   lpNewItem: LPCSTR): WINBOOL{.stdcall, dynlib: "user32",

     importc: "AppendMenuA".}

-proc ModifyMenuA*(hMnu: HMENU, uPosition: UINT, uFlags: UINT, uIDNewItem: UINT,

+proc ModifyMenuA*(hMnu: HMENU, uPosition: WINUINT, uFlags: WINUINT, uIDNewItem: WINUINT,

                   lpNewItem: LPCSTR): WINBOOL{.stdcall, dynlib: "user32",

     importc: "ModifyMenuA".}

-proc InsertMenuItemA*(para1: HMENU, para2: UINT, para3: WINBOOL,

+proc InsertMenuItemA*(para1: HMENU, para2: WINUINT, para3: WINBOOL,

                       para4: LPCMENUITEMINFO): WINBOOL{.stdcall,

     dynlib: "user32", importc: "InsertMenuItemA".}

-proc GetMenuItemInfoA*(para1: HMENU, para2: UINT, para3: WINBOOL,

+proc GetMenuItemInfoA*(para1: HMENU, para2: WINUINT, para3: WINBOOL,

                        para4: LPMENUITEMINFO): WINBOOL{.stdcall,

     dynlib: "user32", importc: "GetMenuItemInfoA".}

-proc SetMenuItemInfoA*(para1: HMENU, para2: UINT, para3: WINBOOL,

+proc SetMenuItemInfoA*(para1: HMENU, para2: WINUINT, para3: WINBOOL,

                        para4: LPCMENUITEMINFO): WINBOOL{.stdcall,

     dynlib: "user32", importc: "SetMenuItemInfoA".}

 proc DrawTextA*(hDC: HDC, lpString: LPCSTR, nCount: int32, lpRect: LPRECT,

-                uFormat: UINT): int32{.stdcall, dynlib: "user32",

+                uFormat: WINUINT): int32{.stdcall, dynlib: "user32",

                                        importc: "DrawTextA".}

 proc DrawTextExA*(para1: HDC, para2: LPSTR, para3: int32, para4: LPRECT,

-                  para5: UINT, para6: LPDRAWTEXTPARAMS): int32{.stdcall,

+                  para5: WINUINT, para6: LPDRAWTEXTPARAMS): int32{.stdcall,

     dynlib: "user32", importc: "DrawTextExA".}

 proc GrayStringA*(hDC: HDC, hBrush: HBRUSH, lpOutputFunc: GRAYSTRINGPROC,

                   lpData: LPARAM, nCount: int32, X: int32, Y: int32,

@@ -14499,7 +14499,7 @@ proc GrayStringA*(hDC: HDC, hBrush: HBRUSH, lpOutputFunc: GRAYSTRINGPROC,
     dynlib: "user32", importc: "GrayStringA".}

 proc DrawStateA*(para1: HDC, para2: HBRUSH, para3: DRAWSTATEPROC, para4: LPARAM,

                  para5: WPARAM, para6: int32, para7: int32, para8: int32,

-                 para9: int32, para10: UINT): WINBOOL{.stdcall,

+                 para9: int32, para10: WINUINT): WINBOOL{.stdcall,

     dynlib: "user32", importc: "DrawStateA".}

 proc TabbedTextOutA*(hDC: HDC, X: int32, Y: int32, lpString: LPCSTR,

                      nCount: int32, nTabPositions: int32,

@@ -14526,7 +14526,7 @@ proc GetWindowTextLengthA*(wnd: HWND): int32{.stdcall, dynlib: "user32",
     importc: "GetWindowTextLengthA".}

 proc MessageBoxA*(wnd: HWND, lpText: LPCSTR, lpCaption: LPCSTR, uType: int): int32{.

     stdcall, dynlib: "user32", importc: "MessageBoxA".}

-proc MessageBoxExA*(wnd: HWND, lpText: LPCSTR, lpCaption: LPCSTR, uType: UINT,

+proc MessageBoxExA*(wnd: HWND, lpText: LPCSTR, lpCaption: LPCSTR, uType: WINUINT,

                     wLanguageId: int16): int32{.stdcall, dynlib: "user32",

     importc: "MessageBoxExA".}

 proc MessageBoxIndirectA*(para1: LPMSGBOXPARAMS): int32{.stdcall,

@@ -14574,44 +14574,44 @@ proc LoadCursorFromFileA*(lpFileName: LPCSTR): HCURSOR{.stdcall,
     dynlib: "user32", importc: "LoadCursorFromFileA".}

 proc LoadIconA*(hInstance: HINST, lpIconName: LPCSTR): HICON{.stdcall,

     dynlib: "user32", importc: "LoadIconA".}

-proc LoadImageA*(para1: HINST, para2: LPCSTR, para3: UINT, para4: int32,

-                 para5: int32, para6: UINT): HANDLE{.stdcall, dynlib: "user32",

+proc LoadImageA*(para1: HINST, para2: LPCSTR, para3: WINUINT, para4: int32,

+                 para5: int32, para6: WINUINT): HANDLE{.stdcall, dynlib: "user32",

     importc: "LoadImageA".}

-proc LoadStringA*(hInstance: HINST, uID: UINT, lpBuffer: LPSTR,

+proc LoadStringA*(hInstance: HINST, uID: WINUINT, lpBuffer: LPSTR,

                   nBufferMax: int32): int32{.stdcall, dynlib: "user32",

     importc: "LoadStringA".}

 proc IsDialogMessageA*(hDlg: HWND, lpMsg: LPMSG): WINBOOL{.stdcall,

     dynlib: "user32", importc: "IsDialogMessageA".}

 proc DlgDirListA*(hDlg: HWND, lpPathSpec: LPSTR, nIDListBox: int32,

-                  nIDStaticPath: int32, uFileType: UINT): int32{.stdcall,

+                  nIDStaticPath: int32, uFileType: WINUINT): int32{.stdcall,

     dynlib: "user32", importc: "DlgDirListA".}

 proc DlgDirSelectExA*(hDlg: HWND, lpString: LPSTR, nCount: int32,

                       nIDListBox: int32): WINBOOL{.stdcall, dynlib: "user32",

     importc: "DlgDirSelectExA".}

 proc DlgDirListComboBoxA*(hDlg: HWND, lpPathSpec: LPSTR, nIDComboBox: int32,

-                          nIDStaticPath: int32, uFiletype: UINT): int32{.

+                          nIDStaticPath: int32, uFiletype: WINUINT): int32{.

     stdcall, dynlib: "user32", importc: "DlgDirListComboBoxA".}

 proc DlgDirSelectComboBoxExA*(hDlg: HWND, lpString: LPSTR, nCount: int32,

                               nIDComboBox: int32): WINBOOL{.stdcall,

     dynlib: "user32", importc: "DlgDirSelectComboBoxExA".}

-proc DefFrameProcA*(wnd: HWND, hWndMDIClient: HWND, uMsg: UINT, wp: WPARAM,

+proc DefFrameProcA*(wnd: HWND, hWndMDIClient: HWND, uMsg: WINUINT, wp: WPARAM,

                     lp: LPARAM): LRESULT{.stdcall, dynlib: "user32",

     importc: "DefFrameProcA".}

-proc DefMDIChildProcA*(wnd: HWND, uMsg: UINT, wp: WPARAM, lp: LPARAM): LRESULT{.

+proc DefMDIChildProcA*(wnd: HWND, uMsg: WINUINT, wp: WPARAM, lp: LPARAM): LRESULT{.

     stdcall, dynlib: "user32", importc: "DefMDIChildProcA".}

 proc CreateMDIWindowA*(lpClassName: LPSTR, lpWindowName: LPSTR, dwStyle: DWORD,

                        X: int32, Y: int32, nWidth: int32, nHeight: int32,

                        hWndParent: HWND, hInstance: HINST, lp: LPARAM): HWND{.

     stdcall, dynlib: "user32", importc: "CreateMDIWindowA".}

-proc WinHelpA*(hWndMain: HWND, lpszHelp: LPCSTR, uCommand: UINT, dwData: DWORD): WINBOOL{.

+proc WinHelpA*(hWndMain: HWND, lpszHelp: LPCSTR, uCommand: WINUINT, dwData: DWORD): WINBOOL{.

     stdcall, dynlib: "user32", importc: "WinHelpA".}

 proc ChangeDisplaySettingsA*(lpDevMode: LPDEVMODE, dwFlags: DWORD): LONG{.

     stdcall, dynlib: "user32", importc: "ChangeDisplaySettingsA".}

 proc EnumDisplaySettingsA*(lpszDeviceName: LPCSTR, iModeNum: DWORD,

                            lpDevMode: LPDEVMODE): WINBOOL{.stdcall,

     dynlib: "user32", importc: "EnumDisplaySettingsA".}

-proc SystemParametersInfoA*(uiAction: UINT, uiParam: UINT, pvParam: PVOID,

-                            fWinIni: UINT): WINBOOL{.stdcall, dynlib: "user32",

+proc SystemParametersInfoA*(uiAction: WINUINT, uiParam: WINUINT, pvParam: PVOID,

+                            fWinIni: WINUINT): WINBOOL{.stdcall, dynlib: "user32",

     importc: "SystemParametersInfoA".}

 proc AddFontResourceA*(para1: LPCSTR): int32{.stdcall, dynlib: "gdi32",

     importc: "AddFontResourceA".}

@@ -14643,24 +14643,24 @@ proc EnumFontsA*(para1: HDC, para2: LPCSTR, para3: ENUMFONTSPROC, para4: LPARAM)
     stdcall, dynlib: "gdi32", importc: "EnumFontsA".}

 proc EnumFontsA*(para1: HDC, para2: LPCSTR, para3: ENUMFONTSPROC, para4: pointer): int32{.

     stdcall, dynlib: "gdi32", importc: "EnumFontsA".}

-proc GetCharWidthA*(para1: HDC, para2: UINT, para3: UINT, para4: LPINT): WINBOOL{.

+proc GetCharWidthA*(para1: HDC, para2: WINUINT, para3: WINUINT, para4: LPINT): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "GetCharWidthA".}

-proc GetCharWidth32A*(para1: HDC, para2: UINT, para3: UINT, para4: LPINT): WINBOOL{.

+proc GetCharWidth32A*(para1: HDC, para2: WINUINT, para3: WINUINT, para4: LPINT): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "GetCharWidth32A".}

-proc GetCharWidthFloatA*(para1: HDC, para2: UINT, para3: UINT, para4: ptr float32): WINBOOL{.

+proc GetCharWidthFloatA*(para1: HDC, para2: WINUINT, para3: WINUINT, para4: ptr float32): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "GetCharWidthFloatA".}

-proc GetCharABCWidthsA*(para1: HDC, para2: UINT, para3: UINT, para4: LPABC): WINBOOL{.

+proc GetCharABCWidthsA*(para1: HDC, para2: WINUINT, para3: WINUINT, para4: LPABC): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "GetCharABCWidthsA".}

-proc GetCharABCWidthsFloatA*(para1: HDC, para2: UINT, para3: UINT,

+proc GetCharABCWidthsFloatA*(para1: HDC, para2: WINUINT, para3: WINUINT,

                              para4: LPABCFLOAT): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "GetCharABCWidthsFloatA".}

-proc GetGlyphOutlineA*(para1: HDC, para2: UINT, para3: UINT,

+proc GetGlyphOutlineA*(para1: HDC, para2: WINUINT, para3: WINUINT,

                        para4: LPGLYPHMETRICS, para5: DWORD, para6: LPVOID,

                        para7: PMAT2): DWORD{.stdcall, dynlib: "gdi32",

     importc: "GetGlyphOutlineA".}

 proc GetMetaFileA*(para1: LPCSTR): HMETAFILE{.stdcall, dynlib: "gdi32",

     importc: "GetMetaFileA".}

-proc GetOutlineTextMetricsA*(para1: HDC, para2: UINT, para3: LPOUTLINETEXTMETRIC): UINT{.

+proc GetOutlineTextMetricsA*(para1: HDC, para2: WINUINT, para3: LPOUTLINETEXTMETRIC): WINUINT{.

     stdcall, dynlib: "gdi32", importc: "GetOutlineTextMetricsA".}

 proc GetTextExtentPointA*(para1: HDC, para2: LPCSTR, para3: int32, para4: LPSIZE): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "GetTextExtentPointA".}

@@ -14684,7 +14684,7 @@ proc CreateEnhMetaFileA*(para1: HDC, para2: LPCSTR, para3: LPRECT, para4: LPCSTR
     stdcall, dynlib: "gdi32", importc: "CreateEnhMetaFileA".}

 proc GetEnhMetaFileA*(para1: LPCSTR): HENHMETAFILE{.stdcall, dynlib: "gdi32",

     importc: "GetEnhMetaFileA".}

-proc GetEnhMetaFileDescriptionA*(para1: HENHMETAFILE, para2: UINT, para3: LPSTR): UINT{.

+proc GetEnhMetaFileDescriptionA*(para1: HENHMETAFILE, para2: WINUINT, para3: LPSTR): WINUINT{.

     stdcall, dynlib: "gdi32", importc: "GetEnhMetaFileDescriptionA".}

 proc GetTextMetricsA*(para1: HDC, para2: LPTEXTMETRIC): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "GetTextMetricsA".}

@@ -14695,8 +14695,8 @@ proc GetObjectA*(para1: HGDIOBJ, para2: int32, para3: LPVOID): int32{.stdcall,
 proc TextOutA*(para1: HDC, para2: int32, para3: int32, para4: LPCSTR,

                para5: int32): WINBOOL{.stdcall, dynlib: "gdi32",

                                        importc: "TextOutA".}

-proc ExtTextOutA*(para1: HDC, para2: int32, para3: int32, para4: UINT,

-                  para5: LPRECT, para6: LPCSTR, para7: UINT, para8: LPINT): WINBOOL{.

+proc ExtTextOutA*(para1: HDC, para2: int32, para3: int32, para4: WINUINT,

+                  para5: LPRECT, para6: LPCSTR, para7: WINUINT, para8: LPINT): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "ExtTextOutA".}

 proc PolyTextOutA*(para1: HDC, para2: PPOLYTEXT, para3: int32): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "PolyTextOutA".}

@@ -14712,19 +14712,19 @@ proc GetICMProfileA*(para1: HDC, para2: DWORD, para3: LPSTR): WINBOOL{.stdcall,
     dynlib: "gdi32", importc: "GetICMProfileA".}

 proc SetICMProfileA*(para1: HDC, para2: LPSTR): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "SetICMProfileA".}

-proc UpdateICMRegKeyA*(para1: DWORD, para2: DWORD, para3: LPSTR, para4: UINT): WINBOOL{.

+proc UpdateICMRegKeyA*(para1: DWORD, para2: DWORD, para3: LPSTR, para4: WINUINT): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "UpdateICMRegKeyA".}

 proc EnumICMProfilesA*(para1: HDC, para2: ICMENUMPROC, para3: LPARAM): int32{.

     stdcall, dynlib: "gdi32", importc: "EnumICMProfilesA".}

 proc PropertySheetA*(lppsph: LPCPROPSHEETHEADER): int32{.stdcall,

     dynlib: "comctl32", importc: "PropertySheetA".}

 proc ImageList_LoadImageA*(hi: HINST, lpbmp: LPCSTR, cx: int32, cGrow: int32,

-                           crMask: COLORREF, uType: UINT, uFlags: UINT): HIMAGELIST{.

+                           crMask: COLORREF, uType: WINUINT, uFlags: WINUINT): HIMAGELIST{.

     stdcall, dynlib: "comctl32", importc: "ImageList_LoadImageA".}

 proc CreateStatusWindowA*(style: LONG, lpszText: LPCSTR, hwndParent: HWND,

-                          wID: UINT): HWND{.stdcall, dynlib: "comctl32",

+                          wID: WINUINT): HWND{.stdcall, dynlib: "comctl32",

     importc: "CreateStatusWindowA".}

-proc DrawStatusTextA*(hDC: HDC, lprc: LPRECT, pszText: LPCSTR, uFlags: UINT){.

+proc DrawStatusTextA*(hDC: HDC, lprc: LPRECT, pszText: LPCSTR, uFlags: WINUINT){.

     stdcall, dynlib: "comctl32", importc: "DrawStatusTextA".}

 proc GetOpenFileNameA*(para1: LPOPENFILENAME): WINBOOL{.stdcall,

     dynlib: "comdlg32", importc: "GetOpenFileNameA".}

@@ -15077,7 +15077,7 @@ proc Shell_NotifyIconA*(dwMessage: DWORD, lpData: PNotifyIconDataA): WINBOOL{.
 proc DdeCreateStringHandleA*(para1: DWORD, para2: cstring, para3: int32): HSZ{.

     stdcall, dynlib: "user32", importc: "DdeCreateStringHandleA".}

 proc DdeInitializeA*(para1: LPDWORD, para2: PFNCALLBACK, para3: DWORD,

-                     para4: DWORD): UINT{.stdcall, dynlib: "user32",

+                     para4: DWORD): WINUINT{.stdcall, dynlib: "user32",

     importc: "DdeInitializeA".}

 proc DdeQueryStringA*(para1: DWORD, para2: HSZ, para3: cstring, para4: DWORD,

                       para5: int32): DWORD{.stdcall, dynlib: "user32",

@@ -15157,7 +15157,7 @@ proc GetModuleFileNameW*(hModule: HINST, lpFilename: LPWSTR, nSize: DWORD): DWOR
     stdcall, dynlib: "kernel32", importc: "GetModuleFileNameW".}

 proc GetModuleHandleW*(lpModuleName: LPCWSTR): HMODULE{.stdcall,

     dynlib: "kernel32", importc: "GetModuleHandleW".}

-proc FatalAppExitW*(uAction: UINT, lpMessageText: LPCWSTR){.stdcall,

+proc FatalAppExitW*(uAction: WINUINT, lpMessageText: LPCWSTR){.stdcall,

     dynlib: "kernel32", importc: "FatalAppExitW".}

 proc GetCommandLineW*(): LPWSTR{.stdcall, dynlib: "kernel32",

                                  importc: "GetCommandLineW".}

@@ -15194,15 +15194,15 @@ proc GlobalAddAtomW*(lpString: LPCWSTR): ATOM{.stdcall, dynlib: "kernel32",
     importc: "GlobalAddAtomW".}

 proc GlobalFindAtomW*(lpString: LPCWSTR): ATOM{.stdcall, dynlib: "kernel32",

     importc: "GlobalFindAtomW".}

-proc GlobalGetAtomNameW*(nAtom: ATOM, lpBuffer: LPWSTR, nSize: int32): UINT{.

+proc GlobalGetAtomNameW*(nAtom: ATOM, lpBuffer: LPWSTR, nSize: int32): WINUINT{.

     stdcall, dynlib: "kernel32", importc: "GlobalGetAtomNameW".}

 proc AddAtomW*(lpString: LPCWSTR): ATOM{.stdcall, dynlib: "kernel32",

     importc: "AddAtomW".}

 proc FindAtomW*(lpString: LPCWSTR): ATOM{.stdcall, dynlib: "kernel32",

     importc: "FindAtomW".}

-proc GetAtomNameW*(nAtom: ATOM, lpBuffer: LPWSTR, nSize: int32): UINT{.stdcall,

+proc GetAtomNameW*(nAtom: ATOM, lpBuffer: LPWSTR, nSize: int32): WINUINT{.stdcall,

     dynlib: "kernel32", importc: "GetAtomNameW".}

-proc GetProfileIntW*(lpAppName: LPCWSTR, lpKeyName: LPCWSTR, nDefault: WINT): UINT{.

+proc GetProfileIntW*(lpAppName: LPCWSTR, lpKeyName: LPCWSTR, nDefault: WINT): WINUINT{.

     stdcall, dynlib: "kernel32", importc: "GetProfileIntW".}

 proc GetProfileStringW*(lpAppName: LPCWSTR, lpKeyName: LPCWSTR,

                         lpDefault: LPCWSTR, lpReturnedString: LPWSTR,

@@ -15217,7 +15217,7 @@ proc GetProfileSectionW*(lpAppName: LPCWSTR, lpReturnedString: LPWSTR,
 proc WriteProfileSectionW*(lpAppName: LPCWSTR, lpString: LPCWSTR): WINBOOL{.

     stdcall, dynlib: "kernel32", importc: "WriteProfileSectionW".}

 proc GetPrivateProfileIntW*(lpAppName: LPCWSTR, lpKeyName: LPCWSTR,

-                            nDefault: WINT, lpFileName: LPCWSTR): UINT{.stdcall,

+                            nDefault: WINT, lpFileName: LPCWSTR): WINUINT{.stdcall,

     dynlib: "kernel32", importc: "GetPrivateProfileIntW".}

 proc GetPrivateProfileStringW*(lpAppName: LPCWSTR, lpKeyName: LPCWSTR,

                                lpDefault: LPCWSTR, lpReturnedString: LPWSTR,

@@ -15232,16 +15232,16 @@ proc GetPrivateProfileSectionW*(lpAppName: LPCWSTR, lpReturnedString: LPWSTR,
 proc WritePrivateProfileSectionW*(lpAppName: LPCWSTR, lpString: LPCWSTR,

                                   lpFileName: LPCWSTR): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "WritePrivateProfileSectionW".}

-proc GetDriveTypeW*(lpRootPathName: LPCWSTR): UINT{.stdcall, dynlib: "kernel32",

+proc GetDriveTypeW*(lpRootPathName: LPCWSTR): WINUINT{.stdcall, dynlib: "kernel32",

     importc: "GetDriveTypeW".}

-proc GetSystemDirectoryW*(lpBuffer: LPWSTR, uSize: UINT): UINT{.stdcall,

+proc GetSystemDirectoryW*(lpBuffer: LPWSTR, uSize: WINUINT): WINUINT{.stdcall,

     dynlib: "kernel32", importc: "GetSystemDirectoryW".}

 proc GetTempPathW*(nBufferLength: DWORD, lpBuffer: LPWSTR): DWORD{.stdcall,

     dynlib: "kernel32", importc: "GetTempPathW".}

 proc GetTempFileNameW*(lpPathName: LPCWSTR, lpPrefixString: LPCWSTR,

-                       uUnique: UINT, lpTempFileName: LPWSTR): UINT{.stdcall,

+                       uUnique: WINUINT, lpTempFileName: LPWSTR): WINUINT{.stdcall,

     dynlib: "kernel32", importc: "GetTempFileNameW".}

-proc GetWindowsDirectoryW*(lpBuffer: LPWSTR, uSize: UINT): UINT{.stdcall,

+proc GetWindowsDirectoryW*(lpBuffer: LPWSTR, uSize: WINUINT): WINUINT{.stdcall,

     dynlib: "kernel32", importc: "GetWindowsDirectoryW".}

 proc SetCurrentDirectoryW*(lpPathName: LPCWSTR): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "SetCurrentDirectoryW".}

@@ -15382,7 +15382,7 @@ proc GetFileSecurityW*(lpFileName: LPCWSTR,
 proc FindFirstChangeNotificationW*(lpPathName: LPCWSTR, bWatchSubtree: WINBOOL,

                                    dwNotifyFilter: DWORD): HANDLE{.stdcall,

     dynlib: "kernel32", importc: "FindFirstChangeNotificationW".}

-proc IsBadStringPtrW*(lpsz: LPCWSTR, ucchMax: UINT): WINBOOL{.stdcall,

+proc IsBadStringPtrW*(lpsz: LPCWSTR, ucchMax: WINUINT): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "IsBadStringPtrW".}

 proc LookupAccountSidW*(lpSystemName: LPCWSTR, Sid: PSID, Name: LPWSTR,

                         cbName: LPDWORD, ReferencedDomainName: LPWSTR,

@@ -15421,7 +15421,7 @@ proc SetComputerNameW*(lpComputerName: LPCWSTR): WINBOOL{.stdcall,
     dynlib: "kernel32", importc: "SetComputerNameW".}

 proc GetUserNameW*(lpBuffer: LPWSTR, nSize: LPDWORD): WINBOOL{.stdcall,

     dynlib: "advapi32", importc: "GetUserNameW".}

-proc LoadKeyboardLayoutW*(pwszKLID: LPCWSTR, Flags: UINT): HKL{.stdcall,

+proc LoadKeyboardLayoutW*(pwszKLID: LPCWSTR, Flags: WINUINT): HKL{.stdcall,

     dynlib: "user32", importc: "LoadKeyboardLayoutW".}

 proc GetKeyboardLayoutNameW*(pwszKLID: LPWSTR): WINBOOL{.stdcall,

     dynlib: "user32", importc: "GetKeyboardLayoutNameW".}

@@ -15449,35 +15449,35 @@ proc GetUserObjectInformationW*(hObj: HANDLE, nIndex: int32, pvInfo: PVOID,
 proc SetUserObjectInformationW*(hObj: HANDLE, nIndex: int32, pvInfo: PVOID,

                                 nLength: DWORD): WINBOOL{.stdcall,

     dynlib: "user32", importc: "SetUserObjectInformationW".}

-proc RegisterWindowMessageW*(lpString: LPCWSTR): UINT{.stdcall,

+proc RegisterWindowMessageW*(lpString: LPCWSTR): WINUINT{.stdcall,

     dynlib: "user32", importc: "RegisterWindowMessageW".}

-proc GetMessageW*(lpMsg: LPMSG, wnd: HWND, wMsgFilterMin: UINT,

-                  wMsgFilterMax: UINT): WINBOOL{.stdcall, dynlib: "user32",

+proc GetMessageW*(lpMsg: LPMSG, wnd: HWND, wMsgFilterMin: WINUINT,

+                  wMsgFilterMax: WINUINT): WINBOOL{.stdcall, dynlib: "user32",

     importc: "GetMessageW".}

 proc DispatchMessageW*(lpMsg: LPMSG): LONG{.stdcall, dynlib: "user32",

     importc: "DispatchMessageW".}

-proc PeekMessageW*(lpMsg: LPMSG, wnd: HWND, wMsgFilterMin: UINT,

-                   wMsgFilterMax: UINT, wRemoveMsg: UINT): WINBOOL{.stdcall,

+proc PeekMessageW*(lpMsg: LPMSG, wnd: HWND, wMsgFilterMin: WINUINT,

+                   wMsgFilterMax: WINUINT, wRemoveMsg: WINUINT): WINBOOL{.stdcall,

     dynlib: "user32", importc: "PeekMessageW".}

-proc SendMessageW*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): LRESULT{.

+proc SendMessageW*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): LRESULT{.

     stdcall, dynlib: "user32", importc: "SendMessageW".}

-proc SendMessageTimeoutW*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM,

-                          fuFlags: UINT, uTimeout: UINT, lpdwResult: LPDWORD): LRESULT{.

+proc SendMessageTimeoutW*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM,

+                          fuFlags: WINUINT, uTimeout: WINUINT, lpdwResult: LPDWORD): LRESULT{.

     stdcall, dynlib: "user32", importc: "SendMessageTimeoutW".}

-proc SendNotifyMessageW*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): WINBOOL{.

+proc SendNotifyMessageW*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): WINBOOL{.

     stdcall, dynlib: "user32", importc: "SendNotifyMessageW".}

-proc SendMessageCallbackW*(wnd: HWND, Msg: UINT, wp: WPARAM,

+proc SendMessageCallbackW*(wnd: HWND, Msg: WINUINT, wp: WPARAM,

                            lp: LPARAM, lpResultCallBack: SENDASYNCPROC,

                            dwData: DWORD): WINBOOL{.stdcall, dynlib: "user32",

     importc: "SendMessageCallbackW".}

-proc PostMessageW*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): WINBOOL{.

+proc PostMessageW*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): WINBOOL{.

     stdcall, dynlib: "user32", importc: "PostMessageW".}

-proc PostThreadMessageW*(idThread: DWORD, Msg: UINT, wp: WPARAM,

+proc PostThreadMessageW*(idThread: DWORD, Msg: WINUINT, wp: WPARAM,

                          lp: LPARAM): WINBOOL{.stdcall, dynlib: "user32",

     importc: "PostThreadMessageW".}

-proc DefWindowProcW*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): LRESULT{.

+proc DefWindowProcW*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): LRESULT{.

     stdcall, dynlib: "user32", importc: "DefWindowProcW".}

-proc CallWindowProcW*(lpPrevWndFunc: WNDPROC, wnd: HWND, Msg: UINT,

+proc CallWindowProcW*(lpPrevWndFunc: WNDPROC, wnd: HWND, Msg: WINUINT,

                       wp: WPARAM, lp: LPARAM): LRESULT{.stdcall,

     dynlib: "user32", importc: "CallWindowProcW".}

 proc RegisterClassW*(lpWndClass: LPWNDCLASSW): ATOM{.stdcall, dynlib: "user32",

@@ -15515,18 +15515,18 @@ proc DialogBoxIndirectParamW*(hInstance: HINST, hDialogTemplate: LPCDLGTEMPLATE,
 proc SetDlgItemTextW*(hDlg: HWND, nIDDlgItem: int32, lpString: LPCWSTR): WINBOOL{.

     stdcall, dynlib: "user32", importc: "SetDlgItemTextW".}

 proc GetDlgItemTextW*(hDlg: HWND, nIDDlgItem: int32, lpString: LPWSTR,

-                      nMaxCount: int32): UINT{.stdcall, dynlib: "user32",

+                      nMaxCount: int32): WINUINT{.stdcall, dynlib: "user32",

     importc: "GetDlgItemTextW".}

-proc SendDlgItemMessageW*(hDlg: HWND, nIDDlgItem: int32, Msg: UINT,

+proc SendDlgItemMessageW*(hDlg: HWND, nIDDlgItem: int32, Msg: WINUINT,

                           wp: WPARAM, lp: LPARAM): LONG{.stdcall,

     dynlib: "user32", importc: "SendDlgItemMessageW".}

-proc DefDlgProcW*(hDlg: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): LRESULT{.

+proc DefDlgProcW*(hDlg: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): LRESULT{.

     stdcall, dynlib: "user32", importc: "DefDlgProcW".}

 proc CallMsgFilterW*(lpMsg: LPMSG, nCode: int32): WINBOOL{.stdcall,

     dynlib: "user32", importc: "CallMsgFilterW".}

-proc RegisterClipboardFormatW*(lpszFormat: LPCWSTR): UINT{.stdcall,

+proc RegisterClipboardFormatW*(lpszFormat: LPCWSTR): WINUINT{.stdcall,

     dynlib: "user32", importc: "RegisterClipboardFormatW".}

-proc GetClipboardFormatNameW*(format: UINT, lpszFormatName: LPWSTR,

+proc GetClipboardFormatNameW*(format: WINUINT, lpszFormatName: LPWSTR,

                               cchMaxCount: int32): int32{.stdcall,

     dynlib: "user32", importc: "GetClipboardFormatNameW".}

 proc CharToOemW*(lpszSrc: LPCWSTR, lpszDst: LPSTR): WINBOOL{.stdcall,

@@ -15563,9 +15563,9 @@ proc VkKeyScanW*(ch: WCHAR): SHORT{.stdcall, dynlib: "user32",
                                     importc: "VkKeyScanW".}

 proc VkKeyScanExW*(ch: WCHAR, dwhkl: HKL): SHORT{.stdcall, dynlib: "user32",

     importc: "VkKeyScanExW".}

-proc MapVirtualKeyW*(uCode: UINT, uMapType: UINT): UINT{.stdcall,

+proc MapVirtualKeyW*(uCode: WINUINT, uMapType: WINUINT): WINUINT{.stdcall,

     dynlib: "user32", importc: "MapVirtualKeyW".}

-proc MapVirtualKeyExW*(uCode: UINT, uMapType: UINT, dwhkl: HKL): UINT{.stdcall,

+proc MapVirtualKeyExW*(uCode: WINUINT, uMapType: WINUINT, dwhkl: HKL): WINUINT{.stdcall,

     dynlib: "user32", importc: "MapVirtualKeyExW".}

 proc LoadAcceleratorsW*(hInstance: HINST, lpTableName: LPCWSTR): HACCEL{.

     stdcall, dynlib: "user32", importc: "LoadAcceleratorsW".}

@@ -15580,35 +15580,35 @@ proc LoadMenuW*(hInstance: HINST, lpMenuName: LPCWSTR): HMENU{.stdcall,
     dynlib: "user32", importc: "LoadMenuW".}

 proc LoadMenuIndirectW*(lpMenuTemplate: LPMENUTEMPLATE): HMENU{.stdcall,

     dynlib: "user32", importc: "LoadMenuIndirectW".}

-proc ChangeMenuW*(menu: HMENU, cmd: UINT, lpszNewItem: LPCWSTR,

-                  cmdInsert: UINT, flags: UINT): WINBOOL{.stdcall,

+proc ChangeMenuW*(menu: HMENU, cmd: WINUINT, lpszNewItem: LPCWSTR,

+                  cmdInsert: WINUINT, flags: WINUINT): WINBOOL{.stdcall,

     dynlib: "user32", importc: "ChangeMenuW".}

-proc GetMenuStringW*(menu: HMENU, uIDItem: UINT, lpString: LPWSTR,

-                     nMaxCount: int32, uFlag: UINT): int32{.stdcall,

+proc GetMenuStringW*(menu: HMENU, uIDItem: WINUINT, lpString: LPWSTR,

+                     nMaxCount: int32, uFlag: WINUINT): int32{.stdcall,

     dynlib: "user32", importc: "GetMenuStringW".}

-proc InsertMenuW*(menu: HMENU, uPosition: UINT, uFlags: UINT, uIDNewItem: UINT,

+proc InsertMenuW*(menu: HMENU, uPosition: WINUINT, uFlags: WINUINT, uIDNewItem: WINUINT,

                   lpNewItem: LPCWSTR): WINBOOL{.stdcall, dynlib: "user32",

     importc: "InsertMenuW".}

-proc AppendMenuW*(menu: HMENU, uFlags: UINT, uIDNewItem: UINT,

+proc AppendMenuW*(menu: HMENU, uFlags: WINUINT, uIDNewItem: WINUINT,

                   lpNewItem: LPCWSTR): WINBOOL{.stdcall, dynlib: "user32",

     importc: "AppendMenuW".}

-proc ModifyMenuW*(hMnu: HMENU, uPosition: UINT, uFlags: UINT, uIDNewItem: UINT,

+proc ModifyMenuW*(hMnu: HMENU, uPosition: WINUINT, uFlags: WINUINT, uIDNewItem: WINUINT,

                   lpNewItem: LPCWSTR): WINBOOL{.stdcall, dynlib: "user32",

     importc: "ModifyMenuW".}

-proc InsertMenuItemW*(para1: HMENU, para2: UINT, para3: WINBOOL,

+proc InsertMenuItemW*(para1: HMENU, para2: WINUINT, para3: WINBOOL,

                       para4: LPCMENUITEMINFO): WINBOOL{.stdcall,

     dynlib: "user32", importc: "InsertMenuItemW".}

-proc GetMenuItemInfoW*(para1: HMENU, para2: UINT, para3: WINBOOL,

+proc GetMenuItemInfoW*(para1: HMENU, para2: WINUINT, para3: WINBOOL,

                        para4: LPMENUITEMINFO): WINBOOL{.stdcall,

     dynlib: "user32", importc: "GetMenuItemInfoW".}

-proc SetMenuItemInfoW*(para1: HMENU, para2: UINT, para3: WINBOOL,

+proc SetMenuItemInfoW*(para1: HMENU, para2: WINUINT, para3: WINBOOL,

                        para4: LPCMENUITEMINFO): WINBOOL{.stdcall,

     dynlib: "user32", importc: "SetMenuItemInfoW".}

 proc DrawTextW*(hDC: HDC, lpString: LPCWSTR, nCount: int32, lpRect: LPRECT,

-                uFormat: UINT): int32{.stdcall, dynlib: "user32",

+                uFormat: WINUINT): int32{.stdcall, dynlib: "user32",

                                        importc: "DrawTextW".}

 proc DrawTextExW*(para1: HDC, para2: LPWSTR, para3: int32, para4: LPRECT,

-                  para5: UINT, para6: LPDRAWTEXTPARAMS): int32{.stdcall,

+                  para5: WINUINT, para6: LPDRAWTEXTPARAMS): int32{.stdcall,

     dynlib: "user32", importc: "DrawTextExW".}

 proc GrayStringW*(hDC: HDC, hBrush: HBRUSH, lpOutputFunc: GRAYSTRINGPROC,

                   lpData: LPARAM, nCount: int32, X: int32, Y: int32,

@@ -15616,7 +15616,7 @@ proc GrayStringW*(hDC: HDC, hBrush: HBRUSH, lpOutputFunc: GRAYSTRINGPROC,
     dynlib: "user32", importc: "GrayStringW".}

 proc DrawStateW*(para1: HDC, para2: HBRUSH, para3: DRAWSTATEPROC, para4: LPARAM,

                  para5: WPARAM, para6: int32, para7: int32, para8: int32,

-                 para9: int32, para10: UINT): WINBOOL{.stdcall,

+                 para9: int32, para10: WINUINT): WINBOOL{.stdcall,

     dynlib: "user32", importc: "DrawStateW".}

 proc TabbedTextOutW*(hDC: HDC, X: int32, Y: int32, lpString: LPCWSTR,

                      nCount: int32, nTabPositions: int32,

@@ -15641,10 +15641,10 @@ proc GetWindowTextW*(wnd: HWND, lpString: LPWSTR, nMaxCount: int32): int32{.
     stdcall, dynlib: "user32", importc: "GetWindowTextW".}

 proc GetWindowTextLengthW*(wnd: HWND): int32{.stdcall, dynlib: "user32",

     importc: "GetWindowTextLengthW".}

-proc MessageBoxW*(wnd: HWND, lpText: LPCWSTR, lpCaption: LPCWSTR, uType: UINT): int32{.

+proc MessageBoxW*(wnd: HWND, lpText: LPCWSTR, lpCaption: LPCWSTR, uType: WINUINT): int32{.

     stdcall, dynlib: "user32", importc: "MessageBoxW".}

 proc MessageBoxExW*(wnd: HWND, lpText: LPCWSTR, lpCaption: LPCWSTR,

-                    uType: UINT, wLanguageId: int16): int32{.stdcall,

+                    uType: WINUINT, wLanguageId: int16): int32{.stdcall,

     dynlib: "user32", importc: "MessageBoxExW".}

 proc MessageBoxIndirectW*(para1: LPMSGBOXPARAMS): int32{.stdcall,

     dynlib: "user32", importc: "MessageBoxIndirectW".}

@@ -15691,45 +15691,45 @@ proc LoadCursorFromFileW*(lpFileName: LPCWSTR): HCURSOR{.stdcall,
     dynlib: "user32", importc: "LoadCursorFromFileW".}

 proc LoadIconW*(hInstance: HINST, lpIconName: LPCWSTR): HICON{.stdcall,

     dynlib: "user32", importc: "LoadIconW".}

-proc LoadImageW*(para1: HINST, para2: LPCWSTR, para3: UINT, para4: int32,

-                 para5: int32, para6: UINT): HANDLE{.stdcall, dynlib: "user32",

+proc LoadImageW*(para1: HINST, para2: LPCWSTR, para3: WINUINT, para4: int32,

+                 para5: int32, para6: WINUINT): HANDLE{.stdcall, dynlib: "user32",

     importc: "LoadImageW".}

-proc LoadStringW*(hInstance: HINST, uID: UINT, lpBuffer: LPWSTR,

+proc LoadStringW*(hInstance: HINST, uID: WINUINT, lpBuffer: LPWSTR,

                   nBufferMax: int32): int32{.stdcall, dynlib: "user32",

     importc: "LoadStringW".}

 proc IsDialogMessageW*(hDlg: HWND, lpMsg: LPMSG): WINBOOL{.stdcall,

     dynlib: "user32", importc: "IsDialogMessageW".}

 proc DlgDirListW*(hDlg: HWND, lpPathSpec: LPWSTR, nIDListBox: int32,

-                  nIDStaticPath: int32, uFileType: UINT): int32{.stdcall,

+                  nIDStaticPath: int32, uFileType: WINUINT): int32{.stdcall,

     dynlib: "user32", importc: "DlgDirListW".}

 proc DlgDirSelectExW*(hDlg: HWND, lpString: LPWSTR, nCount: int32,

                       nIDListBox: int32): WINBOOL{.stdcall, dynlib: "user32",

     importc: "DlgDirSelectExW".}

 proc DlgDirListComboBoxW*(hDlg: HWND, lpPathSpec: LPWSTR, nIDComboBox: int32,

-                          nIDStaticPath: int32, uFiletype: UINT): int32{.

+                          nIDStaticPath: int32, uFiletype: WINUINT): int32{.

     stdcall, dynlib: "user32", importc: "DlgDirListComboBoxW".}

 proc DlgDirSelectComboBoxExW*(hDlg: HWND, lpString: LPWSTR, nCount: int32,

                               nIDComboBox: int32): WINBOOL{.stdcall,

     dynlib: "user32", importc: "DlgDirSelectComboBoxExW".}

-proc DefFrameProcW*(wnd: HWND, hWndMDIClient: HWND, uMsg: UINT, w: WPARAM,

+proc DefFrameProcW*(wnd: HWND, hWndMDIClient: HWND, uMsg: WINUINT, w: WPARAM,

                     lp: LPARAM): LRESULT{.stdcall, dynlib: "user32",

     importc: "DefFrameProcW".}

-proc DefMDIChildProcW*(wnd: HWND, uMsg: UINT, wp: WPARAM, lp: LPARAM): LRESULT{.

+proc DefMDIChildProcW*(wnd: HWND, uMsg: WINUINT, wp: WPARAM, lp: LPARAM): LRESULT{.

     stdcall, dynlib: "user32", importc: "DefMDIChildProcW".}

 proc CreateMDIWindowW*(lpClassName: LPWSTR, lpWindowName: LPWSTR,

                        dwStyle: DWORD, X: int32, Y: int32, nWidth: int32,

                        nHeight: int32, hWndParent: HWND, hInstance: HINST,

                        lp: LPARAM): HWND{.stdcall, dynlib: "user32",

     importc: "CreateMDIWindowW".}

-proc WinHelpW*(hWndMain: HWND, lpszHelp: LPCWSTR, uCommand: UINT, dwData: DWORD): WINBOOL{.

+proc WinHelpW*(hWndMain: HWND, lpszHelp: LPCWSTR, uCommand: WINUINT, dwData: DWORD): WINBOOL{.

     stdcall, dynlib: "user32", importc: "WinHelpW".}

 proc ChangeDisplaySettingsW*(lpDevMode: LPDEVMODEW, dwFlags: DWORD): LONG{.

     stdcall, dynlib: "user32", importc: "ChangeDisplaySettingsW".}

 proc EnumDisplaySettingsW*(lpszDeviceName: LPCWSTR, iModeNum: DWORD,

                            lpDevMode: LPDEVMODEW): WINBOOL{.stdcall,

     dynlib: "user32", importc: "EnumDisplaySettingsW".}

-proc SystemParametersInfoW*(uiAction: UINT, uiParam: UINT, pvParam: PVOID,

-                            fWinIni: UINT): WINBOOL{.stdcall, dynlib: "user32",

+proc SystemParametersInfoW*(uiAction: WINUINT, uiParam: WINUINT, pvParam: PVOID,

+                            fWinIni: WINUINT): WINBOOL{.stdcall, dynlib: "user32",

     importc: "SystemParametersInfoW".}

 proc AddFontResourceW*(para1: LPCWSTR): int32{.stdcall, dynlib: "gdi32",

     importc: "AddFontResourceW".}

@@ -15763,24 +15763,24 @@ proc EnumFontsW*(para1: HDC, para2: LPCWSTR, para3: ENUMFONTSPROC, para4: LPARAM
 proc EnumFontsW*(para1: HDC, para2: LPCWSTR, para3: ENUMFONTSPROC,

                  para4: pointer): int32{.stdcall, dynlib: "gdi32",

     importc: "EnumFontsW".}

-proc GetCharWidthW*(para1: HDC, para2: UINT, para3: UINT, para4: LPINT): WINBOOL{.

+proc GetCharWidthW*(para1: HDC, para2: WINUINT, para3: WINUINT, para4: LPINT): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "GetCharWidthW".}

-proc GetCharWidth32W*(para1: HDC, para2: UINT, para3: UINT, para4: LPINT): WINBOOL{.

+proc GetCharWidth32W*(para1: HDC, para2: WINUINT, para3: WINUINT, para4: LPINT): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "GetCharWidth32W".}

-proc GetCharWidthFloatW*(para1: HDC, para2: UINT, para3: UINT, para4: ptr float32): WINBOOL{.

+proc GetCharWidthFloatW*(para1: HDC, para2: WINUINT, para3: WINUINT, para4: ptr float32): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "GetCharWidthFloatW".}

-proc GetCharABCWidthsW*(para1: HDC, para2: UINT, para3: UINT, para4: LPABC): WINBOOL{.

+proc GetCharABCWidthsW*(para1: HDC, para2: WINUINT, para3: WINUINT, para4: LPABC): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "GetCharABCWidthsW".}

-proc GetCharABCWidthsFloatW*(para1: HDC, para2: UINT, para3: UINT,

+proc GetCharABCWidthsFloatW*(para1: HDC, para2: WINUINT, para3: WINUINT,

                              para4: LPABCFLOAT): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "GetCharABCWidthsFloatW".}

-proc GetGlyphOutlineW*(para1: HDC, para2: UINT, para3: UINT,

+proc GetGlyphOutlineW*(para1: HDC, para2: WINUINT, para3: WINUINT,

                        para4: LPGLYPHMETRICS, para5: DWORD, para6: LPVOID,

                        para7: PMAT2): DWORD{.stdcall, dynlib: "gdi32",

     importc: "GetGlyphOutlineW".}

 proc GetMetaFileW*(para1: LPCWSTR): HMETAFILE{.stdcall, dynlib: "gdi32",

     importc: "GetMetaFileW".}

-proc GetOutlineTextMetricsW*(para1: HDC, para2: UINT, para3: LPOUTLINETEXTMETRIC): UINT{.

+proc GetOutlineTextMetricsW*(para1: HDC, para2: WINUINT, para3: LPOUTLINETEXTMETRIC): WINUINT{.

     stdcall, dynlib: "gdi32", importc: "GetOutlineTextMetricsW".}

 proc GetTextExtentPointW*(para1: HDC, para2: LPCWSTR, para3: int32,

                           para4: LPSIZE): WINBOOL{.stdcall, dynlib: "gdi32",

@@ -15806,7 +15806,7 @@ proc CreateEnhMetaFileW*(para1: HDC, para2: LPCWSTR, para3: LPRECT,
     importc: "CreateEnhMetaFileW".}

 proc GetEnhMetaFileW*(para1: LPCWSTR): HENHMETAFILE{.stdcall, dynlib: "gdi32",

     importc: "GetEnhMetaFileW".}

-proc GetEnhMetaFileDescriptionW*(para1: HENHMETAFILE, para2: UINT, para3: LPWSTR): UINT{.

+proc GetEnhMetaFileDescriptionW*(para1: HENHMETAFILE, para2: WINUINT, para3: LPWSTR): WINUINT{.

     stdcall, dynlib: "gdi32", importc: "GetEnhMetaFileDescriptionW".}

 proc GetTextMetricsW*(para1: HDC, para2: LPTEXTMETRIC): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "GetTextMetricsW".}

@@ -15817,8 +15817,8 @@ proc GetObjectW*(para1: HGDIOBJ, para2: int32, para3: LPVOID): int32{.stdcall,
 proc TextOutW*(para1: HDC, para2: int32, para3: int32, para4: LPCWSTR,

                para5: int32): WINBOOL{.stdcall, dynlib: "gdi32",

                                        importc: "TextOutW".}

-proc ExtTextOutW*(para1: HDC, para2: int32, para3: int32, para4: UINT,

-                  para5: LPRECT, para6: LPCWSTR, para7: UINT, para8: LPINT): WINBOOL{.

+proc ExtTextOutW*(para1: HDC, para2: int32, para3: int32, para4: WINUINT,

+                  para5: LPRECT, para6: LPCWSTR, para7: WINUINT, para8: LPINT): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "ExtTextOutW".}

 proc PolyTextOutW*(para1: HDC, para2: PPOLYTEXT, para3: int32): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "PolyTextOutW".}

@@ -15834,7 +15834,7 @@ proc GetICMProfileW*(para1: HDC, para2: DWORD, para3: LPWSTR): WINBOOL{.stdcall,
     dynlib: "gdi32", importc: "GetICMProfileW".}

 proc SetICMProfileW*(para1: HDC, para2: LPWSTR): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "SetICMProfileW".}

-proc UpdateICMRegKeyW*(para1: DWORD, para2: DWORD, para3: LPWSTR, para4: UINT): WINBOOL{.

+proc UpdateICMRegKeyW*(para1: DWORD, para2: DWORD, para3: LPWSTR, para4: WINUINT): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "UpdateICMRegKeyW".}

 proc EnumICMProfilesW*(para1: HDC, para2: ICMENUMPROC, para3: LPARAM): int32{.

     stdcall, dynlib: "gdi32", importc: "EnumICMProfilesW".}

@@ -15843,12 +15843,12 @@ proc CreatePropertySheetPageW*(lppsp: LPCPROPSHEETPAGE): HPROPSHEETPAGE{.
 proc PropertySheetW*(lppsph: LPCPROPSHEETHEADER): int32{.stdcall,

     dynlib: "comctl32", importc: "PropertySheetW".}

 proc ImageList_LoadImageW*(hi: HINST, lpbmp: LPCWSTR, cx: int32, cGrow: int32,

-                           crMask: COLORREF, uType: UINT, uFlags: UINT): HIMAGELIST{.

+                           crMask: COLORREF, uType: WINUINT, uFlags: WINUINT): HIMAGELIST{.

     stdcall, dynlib: "comctl32", importc: "ImageList_LoadImageW".}

 proc CreateStatusWindowW*(style: LONG, lpszText: LPCWSTR, hwndParent: HWND,

-                          wID: UINT): HWND{.stdcall, dynlib: "comctl32",

+                          wID: WINUINT): HWND{.stdcall, dynlib: "comctl32",

     importc: "CreateStatusWindowW".}

-proc DrawStatusTextW*(hDC: HDC, lprc: LPRECT, pszText: LPCWSTR, uFlags: UINT){.

+proc DrawStatusTextW*(hDC: HDC, lprc: LPRECT, pszText: LPCWSTR, uFlags: WINUINT){.

     stdcall, dynlib: "comctl32", importc: "DrawStatusTextW".}

 proc GetOpenFileNameW*(para1: LPOPENFILENAME): WINBOOL{.stdcall,

     dynlib: "comdlg32", importc: "GetOpenFileNameW".}

@@ -16203,7 +16203,7 @@ proc Shell_NotifyIconW*(dwMessage: DWORD, lpData: PNotifyIconDataA): WINBOOL{.
 proc DdeCreateStringHandleW*(para1: DWORD, para2: LPCWSTR, para3: int32): HSZ{.

     stdcall, dynlib: "user32", importc: "DdeCreateStringHandleW".}

 proc DdeInitializeW*(para1: LPDWORD, para2: PFNCALLBACK, para3: DWORD,

-                     para4: DWORD): UINT{.stdcall, dynlib: "user32",

+                     para4: DWORD): WINUINT{.stdcall, dynlib: "user32",

     importc: "DdeInitializeW".}

 proc DdeQueryStringW*(para1: DWORD, para2: HSZ, para3: LPCWSTR, para4: DWORD,

                       para5: int32): DWORD{.stdcall, dynlib: "user32",

@@ -16286,7 +16286,7 @@ when defined(winUnicode):
       stdcall, dynlib: "kernel32", importc: "GetModuleFileNameW".}

   proc GetModuleHandle*(lpModuleName: LPCWSTR): HMODULE{.stdcall,

       dynlib: "kernel32", importc: "GetModuleHandleW".}

-  proc FatalAppExit*(uAction: UINT, lpMessageText: LPCWSTR){.stdcall,

+  proc FatalAppExit*(uAction: WINUINT, lpMessageText: LPCWSTR){.stdcall,

       dynlib: "kernel32", importc: "FatalAppExitW".}

   proc GetCommandLine*(): LPWSTR{.stdcall, dynlib: "kernel32",

                                   importc: "GetCommandLineW".}

@@ -16324,15 +16324,15 @@ when defined(winUnicode):
       importc: "GlobalAddAtomW".}

   proc GlobalFindAtom*(lpString: LPCWSTR): ATOM{.stdcall, dynlib: "kernel32",

       importc: "GlobalFindAtomW".}

-  proc GlobalGetAtomName*(nAtom: ATOM, lpBuffer: LPWSTR, nSize: int32): UINT{.

+  proc GlobalGetAtomName*(nAtom: ATOM, lpBuffer: LPWSTR, nSize: int32): WINUINT{.

       stdcall, dynlib: "kernel32", importc: "GlobalGetAtomNameW".}

   proc AddAtom*(lpString: LPCWSTR): ATOM{.stdcall, dynlib: "kernel32",

       importc: "AddAtomW".}

   proc FindAtom*(lpString: LPCWSTR): ATOM{.stdcall, dynlib: "kernel32",

       importc: "FindAtomW".}

-  proc GetAtomName*(nAtom: ATOM, lpBuffer: LPWSTR, nSize: int32): UINT{.stdcall,

+  proc GetAtomName*(nAtom: ATOM, lpBuffer: LPWSTR, nSize: int32): WINUINT{.stdcall,

       dynlib: "kernel32", importc: "GetAtomNameW".}

-  proc GetProfileInt*(lpAppName: LPCWSTR, lpKeyName: LPCWSTR, nDefault: WINT): UINT{.

+  proc GetProfileInt*(lpAppName: LPCWSTR, lpKeyName: LPCWSTR, nDefault: WINT): WINUINT{.

       stdcall, dynlib: "kernel32", importc: "GetProfileIntW".}

   proc GetProfileString*(lpAppName: LPCWSTR, lpKeyName: LPCWSTR,

                          lpDefault: LPCWSTR, lpReturnedString: LPWSTR,

@@ -16347,7 +16347,7 @@ when defined(winUnicode):
   proc WriteProfileSection*(lpAppName: LPCWSTR, lpString: LPCWSTR): WINBOOL{.

       stdcall, dynlib: "kernel32", importc: "WriteProfileSectionW".}

   proc GetPrivateProfileInt*(lpAppName: LPCWSTR, lpKeyName: LPCWSTR,

-                             nDefault: WINT, lpFileName: LPCWSTR): UINT{.

+                             nDefault: WINT, lpFileName: LPCWSTR): WINUINT{.

       stdcall, dynlib: "kernel32", importc: "GetPrivateProfileIntW".}

   proc GetPrivateProfileString*(lpAppName: LPCWSTR, lpKeyName: LPCWSTR,

                                 lpDefault: LPCWSTR, lpReturnedString: LPWSTR,

@@ -16362,16 +16362,16 @@ when defined(winUnicode):
   proc WritePrivateProfileSection*(lpAppName: LPCWSTR, lpString: LPCWSTR,

                                    lpFileName: LPCWSTR): WINBOOL{.stdcall,

       dynlib: "kernel32", importc: "WritePrivateProfileSectionW".}

-  proc GetDriveType*(lpRootPathName: LPCWSTR): UINT{.stdcall,

+  proc GetDriveType*(lpRootPathName: LPCWSTR): WINUINT{.stdcall,

       dynlib: "kernel32", importc: "GetDriveTypeW".}

-  proc GetSystemDirectory*(lpBuffer: LPWSTR, uSize: UINT): UINT{.stdcall,

+  proc GetSystemDirectory*(lpBuffer: LPWSTR, uSize: WINUINT): WINUINT{.stdcall,

       dynlib: "kernel32", importc: "GetSystemDirectoryW".}

   proc GetTempPath*(nBufferLength: DWORD, lpBuffer: LPWSTR): DWORD{.stdcall,

       dynlib: "kernel32", importc: "GetTempPathW".}

   proc GetTempFileName*(lpPathName: LPCWSTR, lpPrefixString: LPCWSTR,

-                        uUnique: UINT, lpTempFileName: LPWSTR): UINT{.stdcall,

+                        uUnique: WINUINT, lpTempFileName: LPWSTR): WINUINT{.stdcall,

       dynlib: "kernel32", importc: "GetTempFileNameW".}

-  proc GetWindowsDirectory*(lpBuffer: LPWSTR, uSize: UINT): UINT{.stdcall,

+  proc GetWindowsDirectory*(lpBuffer: LPWSTR, uSize: WINUINT): WINUINT{.stdcall,

       dynlib: "kernel32", importc: "GetWindowsDirectoryW".}

   proc SetCurrentDirectory*(lpPathName: LPCWSTR): WINBOOL{.stdcall,

       dynlib: "kernel32", importc: "SetCurrentDirectoryW".}

@@ -16513,7 +16513,7 @@ when defined(winUnicode):
   proc FindFirstChangeNotification*(lpPathName: LPCWSTR, bWatchSubtree: WINBOOL,

                                     dwNotifyFilter: DWORD): HANDLE{.stdcall,

       dynlib: "kernel32", importc: "FindFirstChangeNotificationW".}

-  proc IsBadStringPtr*(lpsz: LPCWSTR, ucchMax: UINT): WINBOOL{.stdcall,

+  proc IsBadStringPtr*(lpsz: LPCWSTR, ucchMax: WINUINT): WINBOOL{.stdcall,

       dynlib: "kernel32", importc: "IsBadStringPtrW".}

   proc LookupAccountSid*(lpSystemName: LPCWSTR, Sid: PSID, Name: LPWSTR,

                          cbName: LPDWORD, ReferencedDomainName: LPWSTR,

@@ -16553,7 +16553,7 @@ when defined(winUnicode):
       dynlib: "kernel32", importc: "SetComputerNameW".}

   proc GetUserName*(lpBuffer: LPWSTR, nSize: LPDWORD): WINBOOL{.stdcall,

       dynlib: "advapi32", importc: "GetUserNameW".}

-  proc LoadKeyboardLayout*(pwszKLID: LPCWSTR, Flags: UINT): HKL{.stdcall,

+  proc LoadKeyboardLayout*(pwszKLID: LPCWSTR, Flags: WINUINT): HKL{.stdcall,

       dynlib: "user32", importc: "LoadKeyboardLayoutW".}

   proc GetKeyboardLayoutName*(pwszKLID: LPWSTR): WINBOOL{.stdcall,

       dynlib: "user32", importc: "GetKeyboardLayoutNameW".}

@@ -16581,36 +16581,36 @@ when defined(winUnicode):
   proc SetUserObjectInformation*(hObj: HANDLE, nIndex: int32, pvInfo: PVOID,

                                  nLength: DWORD): WINBOOL{.stdcall,

       dynlib: "user32", importc: "SetUserObjectInformationW".}

-  proc RegisterWindowMessage*(lpString: LPCWSTR): UINT{.stdcall,

+  proc RegisterWindowMessage*(lpString: LPCWSTR): WINUINT{.stdcall,

       dynlib: "user32", importc: "RegisterWindowMessageW".}

-  proc GetMessage*(lpMsg: LPMSG, wnd: HWND, wMsgFilterMin: UINT,

-                   wMsgFilterMax: UINT): WINBOOL{.stdcall, dynlib: "user32",

+  proc GetMessage*(lpMsg: LPMSG, wnd: HWND, wMsgFilterMin: WINUINT,

+                   wMsgFilterMax: WINUINT): WINBOOL{.stdcall, dynlib: "user32",

       importc: "GetMessageW".}

   proc DispatchMessage*(lpMsg: LPMSG): LONG{.stdcall, dynlib: "user32",

       importc: "DispatchMessageW".}

-  proc PeekMessage*(lpMsg: LPMSG, wnd: HWND, wMsgFilterMin: UINT,

-                    wMsgFilterMax: UINT, wRemoveMsg: UINT): WINBOOL{.stdcall,

+  proc PeekMessage*(lpMsg: LPMSG, wnd: HWND, wMsgFilterMin: WINUINT,

+                    wMsgFilterMax: WINUINT, wRemoveMsg: WINUINT): WINBOOL{.stdcall,

       dynlib: "user32", importc: "PeekMessageW".}

-  proc SendMessage*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): LRESULT{.

+  proc SendMessage*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): LRESULT{.

       stdcall, dynlib: "user32", importc: "SendMessageW".}

-  proc SendMessageTimeout*(wnd: HWND, Msg: UINT, wp: WPARAM,

-                           lp: LPARAM, fuFlags: UINT, uTimeout: UINT,

+  proc SendMessageTimeout*(wnd: HWND, Msg: WINUINT, wp: WPARAM,

+                           lp: LPARAM, fuFlags: WINUINT, uTimeout: WINUINT,

                            lpdwResult: LPDWORD): LRESULT{.stdcall,

       dynlib: "user32", importc: "SendMessageTimeoutW".}

-  proc SendNotifyMessage*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): WINBOOL{.

+  proc SendNotifyMessage*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): WINBOOL{.

       stdcall, dynlib: "user32", importc: "SendNotifyMessageW".}

-  proc SendMessageCallback*(wnd: HWND, Msg: UINT, wp: WPARAM,

+  proc SendMessageCallback*(wnd: HWND, Msg: WINUINT, wp: WPARAM,

                             lp: LPARAM, lpResultCallBack: SENDASYNCPROC,

                             dwData: DWORD): WINBOOL{.stdcall, dynlib: "user32",

       importc: "SendMessageCallbackW".}

-  proc PostMessage*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): WINBOOL{.

+  proc PostMessage*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): WINBOOL{.

       stdcall, dynlib: "user32", importc: "PostMessageW".}

-  proc PostThreadMessage*(idThread: DWORD, Msg: UINT, wp: WPARAM,

+  proc PostThreadMessage*(idThread: DWORD, Msg: WINUINT, wp: WPARAM,

                           lp: LPARAM): WINBOOL{.stdcall, dynlib: "user32",

       importc: "PostThreadMessageW".}

-  proc DefWindowProc*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): LRESULT{.

+  proc DefWindowProc*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): LRESULT{.

       stdcall, dynlib: "user32", importc: "DefWindowProcW".}

-  proc CallWindowProc*(lpPrevWndFunc: WNDPROC, wnd: HWND, Msg: UINT,

+  proc CallWindowProc*(lpPrevWndFunc: WNDPROC, wnd: HWND, Msg: WINUINT,

                        wp: WPARAM, lp: LPARAM): LRESULT{.stdcall,

       dynlib: "user32", importc: "CallWindowProcW".}

   proc RegisterClass*(lpWndClass: LPWNDCLASS): ATOM{.stdcall, dynlib: "user32",

@@ -16650,18 +16650,18 @@ when defined(winUnicode):
   proc SetDlgItemText*(hDlg: HWND, nIDDlgItem: int32, lpString: LPCWSTR): WINBOOL{.

       stdcall, dynlib: "user32", importc: "SetDlgItemTextW".}

   proc GetDlgItemText*(hDlg: HWND, nIDDlgItem: int32, lpString: LPWSTR,

-                       nMaxCount: int32): UINT{.stdcall, dynlib: "user32",

+                       nMaxCount: int32): WINUINT{.stdcall, dynlib: "user32",

       importc: "GetDlgItemTextW".}

-  proc SendDlgItemMessage*(hDlg: HWND, nIDDlgItem: int32, Msg: UINT,

+  proc SendDlgItemMessage*(hDlg: HWND, nIDDlgItem: int32, Msg: WINUINT,

                            wp: WPARAM, lp: LPARAM): LONG{.stdcall,

       dynlib: "user32", importc: "SendDlgItemMessageW".}

-  proc DefDlgProc*(hDlg: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): LRESULT{.

+  proc DefDlgProc*(hDlg: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): LRESULT{.

       stdcall, dynlib: "user32", importc: "DefDlgProcW".}

   proc CallMsgFilter*(lpMsg: LPMSG, nCode: int32): WINBOOL{.stdcall,

       dynlib: "user32", importc: "CallMsgFilterW".}

-  proc RegisterClipboardFormat*(lpszFormat: LPCWSTR): UINT{.stdcall,

+  proc RegisterClipboardFormat*(lpszFormat: LPCWSTR): WINUINT{.stdcall,

       dynlib: "user32", importc: "RegisterClipboardFormatW".}

-  proc GetClipboardFormatName*(format: UINT, lpszFormatName: LPWSTR,

+  proc GetClipboardFormatName*(format: WINUINT, lpszFormatName: LPWSTR,

                                cchMaxCount: int32): int32{.stdcall,

       dynlib: "user32", importc: "GetClipboardFormatNameW".}

   proc CharToOem*(lpszSrc: LPCWSTR, lpszDst: LPSTR): WINBOOL{.stdcall,

@@ -16698,9 +16698,9 @@ when defined(winUnicode):
                                      importc: "VkKeyScanW".}

   proc VkKeyScanEx*(ch: WCHAR, dwhkl: HKL): SHORT{.stdcall, dynlib: "user32",

       importc: "VkKeyScanExW".}

-  proc MapVirtualKey*(uCode: UINT, uMapType: UINT): UINT{.stdcall,

+  proc MapVirtualKey*(uCode: WINUINT, uMapType: WINUINT): WINUINT{.stdcall,

       dynlib: "user32", importc: "MapVirtualKeyW".}

-  proc MapVirtualKeyEx*(uCode: UINT, uMapType: UINT, dwhkl: HKL): UINT{.stdcall,

+  proc MapVirtualKeyEx*(uCode: WINUINT, uMapType: WINUINT, dwhkl: HKL): WINUINT{.stdcall,

       dynlib: "user32", importc: "MapVirtualKeyExW".}

   proc LoadAccelerators*(hInstance: HINST, lpTableName: LPCWSTR): HACCEL{.

       stdcall, dynlib: "user32", importc: "LoadAcceleratorsW".}

@@ -16715,35 +16715,35 @@ when defined(winUnicode):
       dynlib: "user32", importc: "LoadMenuW".}

   proc LoadMenuIndirect*(lpMenuTemplate: LPMENUTEMPLATE): HMENU{.stdcall,

       dynlib: "user32", importc: "LoadMenuIndirectW".}

-  proc ChangeMenu*(menu: HMENU, cmd: UINT, lpszNewItem: LPCWSTR,

-                   cmdInsert: UINT, flags: UINT): WINBOOL{.stdcall,

+  proc ChangeMenu*(menu: HMENU, cmd: WINUINT, lpszNewItem: LPCWSTR,

+                   cmdInsert: WINUINT, flags: WINUINT): WINBOOL{.stdcall,

       dynlib: "user32", importc: "ChangeMenuW".}

-  proc GetMenuString*(menu: HMENU, uIDItem: UINT, lpString: LPWSTR,

-                      nMaxCount: int32, uFlag: UINT): int32{.stdcall,

+  proc GetMenuString*(menu: HMENU, uIDItem: WINUINT, lpString: LPWSTR,

+                      nMaxCount: int32, uFlag: WINUINT): int32{.stdcall,

       dynlib: "user32", importc: "GetMenuStringW".}

-  proc InsertMenu*(menu: HMENU, uPosition: UINT, uFlags: UINT,

-                   uIDNewItem: UINT, lpNewItem: LPCWSTR): WINBOOL{.stdcall,

+  proc InsertMenu*(menu: HMENU, uPosition: WINUINT, uFlags: WINUINT,

+                   uIDNewItem: WINUINT, lpNewItem: LPCWSTR): WINBOOL{.stdcall,

       dynlib: "user32", importc: "InsertMenuW".}

-  proc AppendMenu*(menu: HMENU, uFlags: UINT, uIDNewItem: UINT,

+  proc AppendMenu*(menu: HMENU, uFlags: WINUINT, uIDNewItem: WINUINT,

                    lpNewItem: LPCWSTR): WINBOOL{.stdcall, dynlib: "user32",

       importc: "AppendMenuW".}

-  proc ModifyMenu*(hMnu: HMENU, uPosition: UINT, uFlags: UINT, uIDNewItem: UINT,

+  proc ModifyMenu*(hMnu: HMENU, uPosition: WINUINT, uFlags: WINUINT, uIDNewItem: WINUINT,

                    lpNewItem: LPCWSTR): WINBOOL{.stdcall, dynlib: "user32",

       importc: "ModifyMenuW".}

-  proc InsertMenuItem*(para1: HMENU, para2: UINT, para3: WINBOOL,

+  proc InsertMenuItem*(para1: HMENU, para2: WINUINT, para3: WINBOOL,

                        para4: LPCMENUITEMINFO): WINBOOL{.stdcall,

       dynlib: "user32", importc: "InsertMenuItemW".}

-  proc GetMenuItemInfo*(para1: HMENU, para2: UINT, para3: WINBOOL,

+  proc GetMenuItemInfo*(para1: HMENU, para2: WINUINT, para3: WINBOOL,

                         para4: LPMENUITEMINFO): WINBOOL{.stdcall,

       dynlib: "user32", importc: "GetMenuItemInfoW".}

-  proc SetMenuItemInfo*(para1: HMENU, para2: UINT, para3: WINBOOL,

+  proc SetMenuItemInfo*(para1: HMENU, para2: WINUINT, para3: WINBOOL,

                         para4: LPCMENUITEMINFO): WINBOOL{.stdcall,

       dynlib: "user32", importc: "SetMenuItemInfoW".}

   proc DrawText*(hDC: HDC, lpString: LPCWSTR, nCount: int32, lpRect: LPRECT,

-                 uFormat: UINT): int32{.stdcall, dynlib: "user32",

+                 uFormat: WINUINT): int32{.stdcall, dynlib: "user32",

                                         importc: "DrawTextW".}

   proc DrawTextEx*(para1: HDC, para2: LPWSTR, para3: int32, para4: LPRECT,

-                   para5: UINT, para6: LPDRAWTEXTPARAMS): int32{.stdcall,

+                   para5: WINUINT, para6: LPDRAWTEXTPARAMS): int32{.stdcall,

       dynlib: "user32", importc: "DrawTextExW".}

   proc GrayString*(hDC: HDC, hBrush: HBRUSH, lpOutputFunc: GRAYSTRINGPROC,

                    lpData: LPARAM, nCount: int32, X: int32, Y: int32,

@@ -16751,7 +16751,7 @@ when defined(winUnicode):
       dynlib: "user32", importc: "GrayStringW".}

   proc DrawState*(para1: HDC, para2: HBRUSH, para3: DRAWSTATEPROC,

                   para4: LPARAM, para5: WPARAM, para6: int32, para7: int32,

-                  para8: int32, para9: int32, para10: UINT): WINBOOL{.stdcall,

+                  para8: int32, para9: int32, para10: WINUINT): WINBOOL{.stdcall,

       dynlib: "user32", importc: "DrawStateW".}

   proc TabbedTextOut*(hDC: HDC, X: int32, Y: int32, lpString: LPCWSTR,

                       nCount: int32, nTabPositions: int32,

@@ -16776,10 +16776,10 @@ when defined(winUnicode):
       stdcall, dynlib: "user32", importc: "GetWindowTextW".}

   proc GetWindowTextLength*(wnd: HWND): int32{.stdcall, dynlib: "user32",

       importc: "GetWindowTextLengthW".}

-  proc MessageBox*(wnd: HWND, lpText: LPCWSTR, lpCaption: LPCWSTR, uType: UINT): int32{.

+  proc MessageBox*(wnd: HWND, lpText: LPCWSTR, lpCaption: LPCWSTR, uType: WINUINT): int32{.

       stdcall, dynlib: "user32", importc: "MessageBoxW".}

   proc MessageBoxEx*(wnd: HWND, lpText: LPCWSTR, lpCaption: LPCWSTR,

-                     uType: UINT, wLanguageId: int16): int32{.stdcall,

+                     uType: WINUINT, wLanguageId: int16): int32{.stdcall,

       dynlib: "user32", importc: "MessageBoxExW".}

   proc MessageBoxIndirect*(para1: LPMSGBOXPARAMS): int32{.stdcall,

       dynlib: "user32", importc: "MessageBoxIndirectW".}

@@ -16826,45 +16826,45 @@ when defined(winUnicode):
       dynlib: "user32", importc: "LoadCursorFromFileW".}

   proc LoadIcon*(hInstance: HINST, lpIconName: LPCWSTR): HICON{.stdcall,

       dynlib: "user32", importc: "LoadIconW".}

-  proc LoadImage*(para1: HINST, para2: LPCWSTR, para3: UINT, para4: int32,

-                  para5: int32, para6: UINT): HANDLE{.stdcall, dynlib: "user32",

+  proc LoadImage*(para1: HINST, para2: LPCWSTR, para3: WINUINT, para4: int32,

+                  para5: int32, para6: WINUINT): HANDLE{.stdcall, dynlib: "user32",

       importc: "LoadImageW".}

-  proc LoadString*(hInstance: HINST, uID: UINT, lpBuffer: LPWSTR,

+  proc LoadString*(hInstance: HINST, uID: WINUINT, lpBuffer: LPWSTR,

                    nBufferMax: int32): int32{.stdcall, dynlib: "user32",

       importc: "LoadStringW".}

   proc IsDialogMessage*(hDlg: HWND, lpMsg: LPMSG): WINBOOL{.stdcall,

       dynlib: "user32", importc: "IsDialogMessageW".}

   proc DlgDirList*(hDlg: HWND, lpPathSpec: LPWSTR, nIDListBox: int32,

-                   nIDStaticPath: int32, uFileType: UINT): int32{.stdcall,

+                   nIDStaticPath: int32, uFileType: WINUINT): int32{.stdcall,

       dynlib: "user32", importc: "DlgDirListW".}

   proc DlgDirSelectEx*(hDlg: HWND, lpString: LPWSTR, nCount: int32,

                        nIDListBox: int32): WINBOOL{.stdcall, dynlib: "user32",

       importc: "DlgDirSelectExW".}

   proc DlgDirListComboBox*(hDlg: HWND, lpPathSpec: LPWSTR, nIDComboBox: int32,

-                           nIDStaticPath: int32, uFiletype: UINT): int32{.

+                           nIDStaticPath: int32, uFiletype: WINUINT): int32{.

       stdcall, dynlib: "user32", importc: "DlgDirListComboBoxW".}

   proc DlgDirSelectComboBoxEx*(hDlg: HWND, lpString: LPWSTR, nCount: int32,

                                nIDComboBox: int32): WINBOOL{.stdcall,

       dynlib: "user32", importc: "DlgDirSelectComboBoxExW".}

-  proc DefFrameProc*(wnd: HWND, hWndMDIClient: HWND, uMsg: UINT,

+  proc DefFrameProc*(wnd: HWND, hWndMDIClient: HWND, uMsg: WINUINT,

                      wp: WPARAM, lp: LPARAM): LRESULT{.stdcall,

       dynlib: "user32", importc: "DefFrameProcW".}

-  proc DefMDIChildProc*(wnd: HWND, uMsg: UINT, wp: WPARAM, lp: LPARAM): LRESULT{.

+  proc DefMDIChildProc*(wnd: HWND, uMsg: WINUINT, wp: WPARAM, lp: LPARAM): LRESULT{.

       stdcall, dynlib: "user32", importc: "DefMDIChildProcW".}

   proc CreateMDIWindow*(lpClassName: LPWSTR, lpWindowName: LPWSTR,

                         dwStyle: DWORD, X: int32, Y: int32, nWidth: int32,

                         nHeight: int32, hWndParent: HWND, hInstance: HINST,

                         lp: LPARAM): HWND{.stdcall, dynlib: "user32",

       importc: "CreateMDIWindowW".}

-  proc WinHelp*(hWndMain: HWND, lpszHelp: LPCWSTR, uCommand: UINT, dwData: DWORD): WINBOOL{.

+  proc WinHelp*(hWndMain: HWND, lpszHelp: LPCWSTR, uCommand: WINUINT, dwData: DWORD): WINBOOL{.

       stdcall, dynlib: "user32", importc: "WinHelpW".}

   proc ChangeDisplaySettings*(lpDevMode: LPDEVMODE, dwFlags: DWORD): LONG{.

       stdcall, dynlib: "user32", importc: "ChangeDisplaySettingsW".}

   proc EnumDisplaySettings*(lpszDeviceName: LPCWSTR, iModeNum: DWORD,

                             lpDevMode: LPDEVMODEW): WINBOOL{.stdcall,

       dynlib: "user32", importc: "EnumDisplaySettingsW".}

-  proc SystemParametersInfo*(uiAction: UINT, uiParam: UINT, pvParam: PVOID,

-                             fWinIni: UINT): WINBOOL{.stdcall, dynlib: "user32",

+  proc SystemParametersInfo*(uiAction: WINUINT, uiParam: WINUINT, pvParam: PVOID,

+                             fWinIni: WINUINT): WINBOOL{.stdcall, dynlib: "user32",

       importc: "SystemParametersInfoW".}

   proc AddFontResource*(para1: LPCWSTR): int32{.stdcall, dynlib: "gdi32",

       importc: "AddFontResourceW".}

@@ -16899,25 +16899,25 @@ when defined(winUnicode):
   proc EnumFonts*(para1: HDC, para2: LPCWSTR, para3: ENUMFONTSPROC,

                   para4: pointer): int32{.stdcall, dynlib: "gdi32",

       importc: "EnumFontsW".}

-  proc GetCharWidth*(para1: HDC, para2: UINT, para3: UINT, para4: LPINT): WINBOOL{.

+  proc GetCharWidth*(para1: HDC, para2: WINUINT, para3: WINUINT, para4: LPINT): WINBOOL{.

       stdcall, dynlib: "gdi32", importc: "GetCharWidthW".}

-  proc GetCharWidth32*(para1: HDC, para2: UINT, para3: UINT, para4: LPINT): WINBOOL{.

+  proc GetCharWidth32*(para1: HDC, para2: WINUINT, para3: WINUINT, para4: LPINT): WINBOOL{.

       stdcall, dynlib: "gdi32", importc: "GetCharWidth32W".}

-  proc GetCharWidthFloat*(para1: HDC, para2: UINT, para3: UINT, para4: ptr float32): WINBOOL{.

+  proc GetCharWidthFloat*(para1: HDC, para2: WINUINT, para3: WINUINT, para4: ptr float32): WINBOOL{.

       stdcall, dynlib: "gdi32", importc: "GetCharWidthFloatW".}

-  proc GetCharABCWidths*(para1: HDC, para2: UINT, para3: UINT, para4: LPABC): WINBOOL{.

+  proc GetCharABCWidths*(para1: HDC, para2: WINUINT, para3: WINUINT, para4: LPABC): WINBOOL{.

       stdcall, dynlib: "gdi32", importc: "GetCharABCWidthsW".}

-  proc GetCharABCWidthsFloat*(para1: HDC, para2: UINT, para3: UINT,

+  proc GetCharABCWidthsFloat*(para1: HDC, para2: WINUINT, para3: WINUINT,

                               para4: LPABCFLOAT): WINBOOL{.stdcall,

       dynlib: "gdi32", importc: "GetCharABCWidthsFloatW".}

-  proc GetGlyphOutline*(para1: HDC, para2: UINT, para3: UINT,

+  proc GetGlyphOutline*(para1: HDC, para2: WINUINT, para3: WINUINT,

                         para4: LPGLYPHMETRICS, para5: DWORD, para6: LPVOID,

                         para7: PMAT2): DWORD{.stdcall, dynlib: "gdi32",

       importc: "GetGlyphOutlineW".}

   proc GetMetaFile*(para1: LPCWSTR): HMETAFILE{.stdcall, dynlib: "gdi32",

       importc: "GetMetaFileW".}

-  proc GetOutlineTextMetrics*(para1: HDC, para2: UINT,

-                              para3: LPOUTLINETEXTMETRIC): UINT{.stdcall,

+  proc GetOutlineTextMetrics*(para1: HDC, para2: WINUINT,

+                              para3: LPOUTLINETEXTMETRIC): WINUINT{.stdcall,

       dynlib: "gdi32", importc: "GetOutlineTextMetricsW".}

   proc GetTextExtentPoint*(para1: HDC, para2: LPCWSTR, para3: int32,

                            para4: LPSIZE): WINBOOL{.stdcall, dynlib: "gdi32",

@@ -16943,8 +16943,8 @@ when defined(winUnicode):
       importc: "CreateEnhMetaFileW".}

   proc GetEnhMetaFile*(para1: LPCWSTR): HENHMETAFILE{.stdcall, dynlib: "gdi32",

       importc: "GetEnhMetaFileW".}

-  proc GetEnhMetaFileDescription*(para1: HENHMETAFILE, para2: UINT,

-                                  para3: LPWSTR): UINT{.stdcall,

+  proc GetEnhMetaFileDescription*(para1: HENHMETAFILE, para2: WINUINT,

+                                  para3: LPWSTR): WINUINT{.stdcall,

       dynlib: "gdi32", importc: "GetEnhMetaFileDescriptionW".}

   proc GetTextMetrics*(para1: HDC, para2: LPTEXTMETRIC): WINBOOL{.stdcall,

       dynlib: "gdi32", importc: "GetTextMetricsW".}

@@ -16955,8 +16955,8 @@ when defined(winUnicode):
   proc TextOut*(para1: HDC, para2: int32, para3: int32, para4: LPCWSTR,

                 para5: int32): WINBOOL{.stdcall, dynlib: "gdi32",

                                         importc: "TextOutW".}

-  proc ExtTextOut*(para1: HDC, para2: int32, para3: int32, para4: UINT,

-                   para5: LPRECT, para6: LPCWSTR, para7: UINT, para8: LPINT): WINBOOL{.

+  proc ExtTextOut*(para1: HDC, para2: int32, para3: int32, para4: WINUINT,

+                   para5: LPRECT, para6: LPCWSTR, para7: WINUINT, para8: LPINT): WINBOOL{.

       stdcall, dynlib: "gdi32", importc: "ExtTextOutW".}

   proc PolyTextOut*(para1: HDC, para2: PPOLYTEXT, para3: int32): WINBOOL{.

       stdcall, dynlib: "gdi32", importc: "PolyTextOutW".}

@@ -16974,7 +16974,7 @@ when defined(winUnicode):
   proc SetICMProfile*(para1: HDC, para2: LPWSTR): WINBOOL{.stdcall,

 

       dynlib: "gdi32", importc: "SetICMProfileW".}

-  proc UpdateICMRegKey*(para1: DWORD, para2: DWORD, para3: LPWSTR, para4: UINT): WINBOOL{.

+  proc UpdateICMRegKey*(para1: DWORD, para2: DWORD, para3: LPWSTR, para4: WINUINT): WINBOOL{.

       stdcall, dynlib: "gdi32", importc: "UpdateICMRegKeyW".}

   proc EnumICMProfiles*(para1: HDC, para2: ICMENUMPROC, para3: LPARAM): int32{.

       stdcall, dynlib: "gdi32", importc: "EnumICMProfilesW".}

@@ -16983,12 +16983,12 @@ when defined(winUnicode):
   proc PropertySheet*(lppsph: LPCPROPSHEETHEADER): int32{.stdcall,

       dynlib: "comctl32", importc: "PropertySheetW".}

   proc ImageList_LoadImage*(hi: HINST, lpbmp: LPCWSTR, cx: int32, cGrow: int32,

-                            crMask: COLORREF, uType: UINT, uFlags: UINT): HIMAGELIST{.

+                            crMask: COLORREF, uType: WINUINT, uFlags: WINUINT): HIMAGELIST{.

       stdcall, dynlib: "comctl32", importc: "ImageList_LoadImageW".}

   proc CreateStatusWindow*(style: LONG, lpszText: LPCWSTR, hwndParent: HWND,

-                           wID: UINT): HWND{.stdcall, dynlib: "comctl32",

+                           wID: WINUINT): HWND{.stdcall, dynlib: "comctl32",

       importc: "CreateStatusWindowW".}

-  proc DrawStatusText*(hDC: HDC, lprc: LPRECT, pszText: LPCWSTR, uFlags: UINT){.

+  proc DrawStatusText*(hDC: HDC, lprc: LPRECT, pszText: LPCWSTR, uFlags: WINUINT){.

       stdcall, dynlib: "comctl32", importc: "DrawStatusTextW".}

   proc GetOpenFileName*(para1: LPOPENFILENAME): WINBOOL{.stdcall,

       dynlib: "comdlg32", importc: "GetOpenFileNameW".}

@@ -17348,7 +17348,7 @@ when defined(winUnicode):
   proc DdeCreateStringHandle*(para1: DWORD, para2: LPCWSTR, para3: int32): HSZ{.

       stdcall, dynlib: "user32", importc: "DdeCreateStringHandleW".}

   proc DdeInitialize*(para1: LPDWORD, para2: PFNCALLBACK, para3: DWORD,

-                      para4: DWORD): UINT{.stdcall, dynlib: "user32",

+                      para4: DWORD): WINUINT{.stdcall, dynlib: "user32",

       importc: "DdeInitializeW".}

   proc DdeQueryString*(para1: DWORD, para2: HSZ, para3: LPCWSTR, para4: DWORD,

                        para5: int32): DWORD{.stdcall, dynlib: "user32",

@@ -17429,7 +17429,7 @@ else:
       stdcall, dynlib: "kernel32", importc: "GetModuleFileNameA".}

   proc GetModuleHandle*(lpModuleName: LPCSTR): HMODULE{.stdcall,

       dynlib: "kernel32", importc: "GetModuleHandleA".}

-  proc FatalAppExit*(uAction: UINT, lpMessageText: LPCSTR){.stdcall,

+  proc FatalAppExit*(uAction: WINUINT, lpMessageText: LPCSTR){.stdcall,

       dynlib: "kernel32", importc: "FatalAppExitA".}

   proc GetCommandLine*(): LPSTR{.stdcall, dynlib: "kernel32",

                                  importc: "GetCommandLineA".}

@@ -17466,15 +17466,15 @@ else:
       importc: "GlobalAddAtomA".}

   proc GlobalFindAtom*(lpString: LPCSTR): ATOM{.stdcall, dynlib: "kernel32",

       importc: "GlobalFindAtomA".}

-  proc GlobalGetAtomName*(nAtom: ATOM, lpBuffer: LPSTR, nSize: int32): UINT{.

+  proc GlobalGetAtomName*(nAtom: ATOM, lpBuffer: LPSTR, nSize: int32): WINUINT{.

       stdcall, dynlib: "kernel32", importc: "GlobalGetAtomNameA".}

   proc AddAtom*(lpString: LPCSTR): ATOM{.stdcall, dynlib: "kernel32",

       importc: "AddAtomA".}

   proc FindAtom*(lpString: LPCSTR): ATOM{.stdcall, dynlib: "kernel32",

       importc: "FindAtomA".}

-  proc GetAtomName*(nAtom: ATOM, lpBuffer: LPSTR, nSize: int32): UINT{.stdcall,

+  proc GetAtomName*(nAtom: ATOM, lpBuffer: LPSTR, nSize: int32): WINUINT{.stdcall,

       dynlib: "kernel32", importc: "GetAtomNameA".}

-  proc GetProfileInt*(lpAppName: LPCSTR, lpKeyName: LPCSTR, nDefault: WINT): UINT{.

+  proc GetProfileInt*(lpAppName: LPCSTR, lpKeyName: LPCSTR, nDefault: WINT): WINUINT{.

       stdcall, dynlib: "kernel32", importc: "GetProfileIntA".}

   proc GetProfileString*(lpAppName: LPCSTR, lpKeyName: LPCSTR,

                          lpDefault: LPCSTR, lpReturnedString: LPSTR,

@@ -17489,7 +17489,7 @@ else:
   proc WriteProfileSection*(lpAppName: LPCSTR, lpString: LPCSTR): WINBOOL{.

       stdcall, dynlib: "kernel32", importc: "WriteProfileSectionA".}

   proc GetPrivateProfileInt*(lpAppName: LPCSTR, lpKeyName: LPCSTR,

-                             nDefault: WINT, lpFileName: LPCSTR): UINT{.stdcall,

+                             nDefault: WINT, lpFileName: LPCSTR): WINUINT{.stdcall,

       dynlib: "kernel32", importc: "GetPrivateProfileIntA".}

   proc GetPrivateProfileString*(lpAppName: LPCSTR, lpKeyName: LPCSTR,

                                 lpDefault: LPCSTR, lpReturnedString: LPSTR,

@@ -17504,16 +17504,16 @@ else:
   proc WritePrivateProfileSection*(lpAppName: LPCSTR, lpString: LPCSTR,

                                    lpFileName: LPCSTR): WINBOOL{.stdcall,

       dynlib: "kernel32", importc: "WritePrivateProfileSectionA".}

-  proc GetDriveType*(lpRootPathName: LPCSTR): UINT{.stdcall, dynlib: "kernel32",

+  proc GetDriveType*(lpRootPathName: LPCSTR): WINUINT{.stdcall, dynlib: "kernel32",

       importc: "GetDriveTypeA".}

-  proc GetSystemDirectory*(lpBuffer: LPSTR, uSize: UINT): UINT{.stdcall,

+  proc GetSystemDirectory*(lpBuffer: LPSTR, uSize: WINUINT): WINUINT{.stdcall,

       dynlib: "kernel32", importc: "GetSystemDirectoryA".}

   proc GetTempPath*(nBufferLength: DWORD, lpBuffer: LPSTR): DWORD{.stdcall,

       dynlib: "kernel32", importc: "GetTempPathA".}

   proc GetTempFileName*(lpPathName: LPCSTR, lpPrefixString: LPCSTR,

-                        uUnique: UINT, lpTempFileName: LPSTR): UINT{.stdcall,

+                        uUnique: WINUINT, lpTempFileName: LPSTR): WINUINT{.stdcall,

       dynlib: "kernel32", importc: "GetTempFileNameA".}

-  proc GetWindowsDirectory*(lpBuffer: LPSTR, uSize: UINT): UINT{.stdcall,

+  proc GetWindowsDirectory*(lpBuffer: LPSTR, uSize: WINUINT): WINUINT{.stdcall,

       dynlib: "kernel32", importc: "GetWindowsDirectoryA".}

   proc SetCurrentDirectory*(lpPathName: LPCSTR): WINBOOL{.stdcall,

       dynlib: "kernel32", importc: "SetCurrentDirectoryA".}

@@ -17654,7 +17654,7 @@ else:
   proc FindFirstChangeNotification*(lpPathName: LPCSTR, bWatchSubtree: WINBOOL,

                                     dwNotifyFilter: DWORD): HANDLE{.stdcall,

       dynlib: "kernel32", importc: "FindFirstChangeNotificationA".}

-  proc IsBadStringPtr*(lpsz: LPCSTR, ucchMax: UINT): WINBOOL{.stdcall,

+  proc IsBadStringPtr*(lpsz: LPCSTR, ucchMax: WINUINT): WINBOOL{.stdcall,

       dynlib: "kernel32", importc: "IsBadStringPtrA".}

   proc LookupAccountSid*(lpSystemName: LPCSTR, Sid: PSID, Name: LPSTR,

                          cbName: LPDWORD, ReferencedDomainName: LPSTR,

@@ -17694,7 +17694,7 @@ else:
       dynlib: "advapi32", importc: "GetUserNameA".}

   proc wvsprintf*(para1: LPSTR, para2: LPCSTR, arglist: va_list): int32{.

       stdcall, dynlib: "user32", importc: "wvsprintfA".}

-  proc LoadKeyboardLayout*(pwszKLID: LPCSTR, Flags: UINT): HKL{.stdcall,

+  proc LoadKeyboardLayout*(pwszKLID: LPCSTR, Flags: WINUINT): HKL{.stdcall,

       dynlib: "user32", importc: "LoadKeyboardLayoutA".}

   proc GetKeyboardLayoutName*(pwszKLID: LPSTR): WINBOOL{.stdcall,

       dynlib: "user32", importc: "GetKeyboardLayoutNameA".}

@@ -17722,36 +17722,36 @@ else:
   proc SetUserObjectInformation*(hObj: HANDLE, nIndex: int32, pvInfo: PVOID,

                                  nLength: DWORD): WINBOOL{.stdcall,

       dynlib: "user32", importc: "SetUserObjectInformationA".}

-  proc RegisterWindowMessage*(lpString: LPCSTR): UINT{.stdcall,

+  proc RegisterWindowMessage*(lpString: LPCSTR): WINUINT{.stdcall,

       dynlib: "user32", importc: "RegisterWindowMessageA".}

-  proc GetMessage*(lpMsg: LPMSG, wnd: HWND, wMsgFilterMin: UINT,

-                   wMsgFilterMax: UINT): WINBOOL{.stdcall, dynlib: "user32",

+  proc GetMessage*(lpMsg: LPMSG, wnd: HWND, wMsgFilterMin: WINUINT,

+                   wMsgFilterMax: WINUINT): WINBOOL{.stdcall, dynlib: "user32",

       importc: "GetMessageA".}

   proc DispatchMessage*(lpMsg: LPMSG): LONG{.stdcall, dynlib: "user32",

       importc: "DispatchMessageA".}

-  proc PeekMessage*(lpMsg: LPMSG, wnd: HWND, wMsgFilterMin: UINT,

-                    wMsgFilterMax: UINT, wRemoveMsg: UINT): WINBOOL{.stdcall,

+  proc PeekMessage*(lpMsg: LPMSG, wnd: HWND, wMsgFilterMin: WINUINT,

+                    wMsgFilterMax: WINUINT, wRemoveMsg: WINUINT): WINBOOL{.stdcall,

       dynlib: "user32", importc: "PeekMessageA".}

-  proc SendMessage*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): LRESULT{.

+  proc SendMessage*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): LRESULT{.

       stdcall, dynlib: "user32", importc: "SendMessageA".}

-  proc SendMessageTimeout*(wnd: HWND, Msg: UINT, wp: WPARAM,

-                           lp: LPARAM, fuFlags: UINT, uTimeout: UINT,

+  proc SendMessageTimeout*(wnd: HWND, Msg: WINUINT, wp: WPARAM,

+                           lp: LPARAM, fuFlags: WINUINT, uTimeout: WINUINT,

                            lpdwResult: LPDWORD): LRESULT{.stdcall,

       dynlib: "user32", importc: "SendMessageTimeoutA".}

-  proc SendNotifyMessage*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): WINBOOL{.

+  proc SendNotifyMessage*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): WINBOOL{.

       stdcall, dynlib: "user32", importc: "SendNotifyMessageA".}

-  proc SendMessageCallback*(wnd: HWND, Msg: UINT, wp: WPARAM,

+  proc SendMessageCallback*(wnd: HWND, Msg: WINUINT, wp: WPARAM,

                             lp: LPARAM, lpResultCallBack: SENDASYNCPROC,

                             dwData: DWORD): WINBOOL{.stdcall, dynlib: "user32",

       importc: "SendMessageCallbackA".}

-  proc PostMessage*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): WINBOOL{.

+  proc PostMessage*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): WINBOOL{.

       stdcall, dynlib: "user32", importc: "PostMessageA".}

-  proc PostThreadMessage*(idThread: DWORD, Msg: UINT, wp: WPARAM,

+  proc PostThreadMessage*(idThread: DWORD, Msg: WINUINT, wp: WPARAM,

                           lp: LPARAM): WINBOOL{.stdcall, dynlib: "user32",

       importc: "PostThreadMessageA".}

-  proc DefWindowProc*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): LRESULT{.

+  proc DefWindowProc*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): LRESULT{.

       stdcall, dynlib: "user32", importc: "DefWindowProcA".}

-  proc CallWindowProc*(lpPrevWndFunc: WNDPROC, wnd: HWND, Msg: UINT,

+  proc CallWindowProc*(lpPrevWndFunc: WNDPROC, wnd: HWND, Msg: WINUINT,

                        wp: WPARAM, lp: LPARAM): LRESULT{.stdcall,

       dynlib: "user32", importc: "CallWindowProcA".}

   proc RegisterClass*(lpWndClass: LPWNDCLASS): ATOM{.stdcall, dynlib: "user32",

@@ -17791,18 +17791,18 @@ else:
   proc SetDlgItemText*(hDlg: HWND, nIDDlgItem: int32, lpString: LPCSTR): WINBOOL{.

       stdcall, dynlib: "user32", importc: "SetDlgItemTextA".}

   proc GetDlgItemText*(hDlg: HWND, nIDDlgItem: int32, lpString: LPSTR,

-                       nMaxCount: int32): UINT{.stdcall, dynlib: "user32",

+                       nMaxCount: int32): WINUINT{.stdcall, dynlib: "user32",

       importc: "GetDlgItemTextA".}

-  proc SendDlgItemMessage*(hDlg: HWND, nIDDlgItem: int32, Msg: UINT,

+  proc SendDlgItemMessage*(hDlg: HWND, nIDDlgItem: int32, Msg: WINUINT,

                            wp: WPARAM, lp: LPARAM): LONG{.stdcall,

       dynlib: "user32", importc: "SendDlgItemMessageA".}

-  proc DefDlgProc*(hDlg: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): LRESULT{.

+  proc DefDlgProc*(hDlg: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): LRESULT{.

       stdcall, dynlib: "user32", importc: "DefDlgProcA".}

   proc CallMsgFilter*(lpMsg: LPMSG, nCode: int32): WINBOOL{.stdcall,

       dynlib: "user32", importc: "CallMsgFilterA".}

-  proc RegisterClipboardFormat*(lpszFormat: LPCSTR): UINT{.stdcall,

+  proc RegisterClipboardFormat*(lpszFormat: LPCSTR): WINUINT{.stdcall,

       dynlib: "user32", importc: "RegisterClipboardFormatA".}

-  proc GetClipboardFormatName*(format: UINT, lpszFormatName: LPSTR,

+  proc GetClipboardFormatName*(format: WINUINT, lpszFormatName: LPSTR,

                                cchMaxCount: int32): int32{.stdcall,

       dynlib: "user32", importc: "GetClipboardFormatNameA".}

   proc CharToOem*(lpszSrc: LPCSTR, lpszDst: LPSTR): WINBOOL{.stdcall,

@@ -17839,9 +17839,9 @@ else:
                                     importc: "VkKeyScanA".}

   proc VkKeyScanEx*(ch: CHAR, dwhkl: HKL): SHORT{.stdcall, dynlib: "user32",

       importc: "VkKeyScanExA".}

-  proc MapVirtualKey*(uCode: UINT, uMapType: UINT): UINT{.stdcall,

+  proc MapVirtualKey*(uCode: WINUINT, uMapType: WINUINT): WINUINT{.stdcall,

       dynlib: "user32", importc: "MapVirtualKeyA".}

-  proc MapVirtualKeyEx*(uCode: UINT, uMapType: UINT, dwhkl: HKL): UINT{.stdcall,

+  proc MapVirtualKeyEx*(uCode: WINUINT, uMapType: WINUINT, dwhkl: HKL): WINUINT{.stdcall,

       dynlib: "user32", importc: "MapVirtualKeyExA".}

   proc LoadAccelerators*(hInstance: HINST, lpTableName: LPCSTR): HACCEL{.

       stdcall, dynlib: "user32", importc: "LoadAcceleratorsA".}

@@ -17856,35 +17856,35 @@ else:
       dynlib: "user32", importc: "LoadMenuA".}

   proc LoadMenuIndirect*(lpMenuTemplate: LPMENUTEMPLATE): HMENU{.stdcall,

       dynlib: "user32", importc: "LoadMenuIndirectA".}

-  proc ChangeMenu*(menu: HMENU, cmd: UINT, lpszNewItem: LPCSTR,

-                   cmdInsert: UINT, flags: UINT): WINBOOL{.stdcall,

+  proc ChangeMenu*(menu: HMENU, cmd: WINUINT, lpszNewItem: LPCSTR,

+                   cmdInsert: WINUINT, flags: WINUINT): WINBOOL{.stdcall,

       dynlib: "user32", importc: "ChangeMenuA".}

-  proc GetMenuString*(menu: HMENU, uIDItem: UINT, lpString: LPSTR,

-                      nMaxCount: int32, uFlag: UINT): int32{.stdcall,

+  proc GetMenuString*(menu: HMENU, uIDItem: WINUINT, lpString: LPSTR,

+                      nMaxCount: int32, uFlag: WINUINT): int32{.stdcall,

       dynlib: "user32", importc: "GetMenuStringA".}

-  proc InsertMenu*(menu: HMENU, uPosition: UINT, uFlags: UINT,

-                   uIDNewItem: UINT, lpNewItem: LPCSTR): WINBOOL{.stdcall,

+  proc InsertMenu*(menu: HMENU, uPosition: WINUINT, uFlags: WINUINT,

+                   uIDNewItem: WINUINT, lpNewItem: LPCSTR): WINBOOL{.stdcall,

       dynlib: "user32", importc: "InsertMenuA".}

-  proc AppendMenu*(menu: HMENU, uFlags: UINT, uIDNewItem: UINT,

+  proc AppendMenu*(menu: HMENU, uFlags: WINUINT, uIDNewItem: WINUINT,

                    lpNewItem: LPCSTR): WINBOOL{.stdcall, dynlib: "user32",

       importc: "AppendMenuA".}

-  proc ModifyMenu*(hMnu: HMENU, uPosition: UINT, uFlags: UINT, uIDNewItem: UINT,

+  proc ModifyMenu*(hMnu: HMENU, uPosition: WINUINT, uFlags: WINUINT, uIDNewItem: WINUINT,

                    lpNewItem: LPCSTR): WINBOOL{.stdcall, dynlib: "user32",

       importc: "ModifyMenuA".}

-  proc InsertMenuItem*(para1: HMENU, para2: UINT, para3: WINBOOL,

+  proc InsertMenuItem*(para1: HMENU, para2: WINUINT, para3: WINBOOL,

                        para4: LPCMENUITEMINFO): WINBOOL{.stdcall,

       dynlib: "user32", importc: "InsertMenuItemA".}

-  proc GetMenuItemInfo*(para1: HMENU, para2: UINT, para3: WINBOOL,

+  proc GetMenuItemInfo*(para1: HMENU, para2: WINUINT, para3: WINBOOL,

                         para4: LPMENUITEMINFO): WINBOOL{.stdcall,

       dynlib: "user32", importc: "GetMenuItemInfoA".}

-  proc SetMenuItemInfo*(para1: HMENU, para2: UINT, para3: WINBOOL,

+  proc SetMenuItemInfo*(para1: HMENU, para2: WINUINT, para3: WINBOOL,

                         para4: LPCMENUITEMINFO): WINBOOL{.stdcall,

       dynlib: "user32", importc: "SetMenuItemInfoA".}

   proc DrawText*(hDC: HDC, lpString: LPCSTR, nCount: int32, lpRect: LPRECT,

-                 uFormat: UINT): int32{.stdcall, dynlib: "user32",

+                 uFormat: WINUINT): int32{.stdcall, dynlib: "user32",

                                         importc: "DrawTextA".}

   proc DrawTextEx*(para1: HDC, para2: LPSTR, para3: int32, para4: LPRECT,

-                   para5: UINT, para6: LPDRAWTEXTPARAMS): int32{.stdcall,

+                   para5: WINUINT, para6: LPDRAWTEXTPARAMS): int32{.stdcall,

       dynlib: "user32", importc: "DrawTextExA".}

   proc GrayString*(hDC: HDC, hBrush: HBRUSH, lpOutputFunc: GRAYSTRINGPROC,

                    lpData: LPARAM, nCount: int32, X: int32, Y: int32,

@@ -17892,7 +17892,7 @@ else:
       dynlib: "user32", importc: "GrayStringA".}

   proc DrawState*(para1: HDC, para2: HBRUSH, para3: DRAWSTATEPROC,

                   para4: LPARAM, para5: WPARAM, para6: int32, para7: int32,

-                  para8: int32, para9: int32, para10: UINT): WINBOOL{.stdcall,

+                  para8: int32, para9: int32, para10: WINUINT): WINBOOL{.stdcall,

       dynlib: "user32", importc: "DrawStateA".}

   proc TabbedTextOut*(dc: HDC, X: int32, Y: int32, lpString: LPCSTR,

                       nCount: int32, nTabPositions: int32,

@@ -17917,9 +17917,9 @@ else:
       stdcall, dynlib: "user32", importc: "GetWindowTextA".}

   proc GetWindowTextLength*(wnd: HWND): int32{.stdcall, dynlib: "user32",

       importc: "GetWindowTextLengthA".}

-  proc MessageBox*(wnd: HWND, lpText: LPCSTR, lpCaption: LPCSTR, uType: UINT): int32{.

+  proc MessageBox*(wnd: HWND, lpText: LPCSTR, lpCaption: LPCSTR, uType: WINUINT): int32{.

       stdcall, dynlib: "user32", importc: "MessageBoxA".}

-  proc MessageBoxEx*(wnd: HWND, lpText: LPCSTR, lpCaption: LPCSTR, uType: UINT,

+  proc MessageBoxEx*(wnd: HWND, lpText: LPCSTR, lpCaption: LPCSTR, uType: WINUINT,

                      wLanguageId: int16): int32{.stdcall, dynlib: "user32",

       importc: "MessageBoxExA".}

   proc MessageBoxIndirect*(para1: LPMSGBOXPARAMS): int32{.stdcall,

@@ -17967,44 +17967,44 @@ else:
       dynlib: "user32", importc: "LoadCursorFromFileA".}

   proc LoadIcon*(hInstance: HINST, lpIconName: LPCSTR): HICON{.stdcall,

       dynlib: "user32", importc: "LoadIconA".}

-  proc LoadImage*(para1: HINST, para2: LPCSTR, para3: UINT, para4: int32,

-                  para5: int32, para6: UINT): HANDLE{.stdcall, dynlib: "user32",

+  proc LoadImage*(para1: HINST, para2: LPCSTR, para3: WINUINT, para4: int32,

+                  para5: int32, para6: WINUINT): HANDLE{.stdcall, dynlib: "user32",

       importc: "LoadImageA".}

-  proc LoadString*(hInstance: HINST, uID: UINT, lpBuffer: LPSTR,

+  proc LoadString*(hInstance: HINST, uID: WINUINT, lpBuffer: LPSTR,

                    nBufferMax: int32): int32{.stdcall, dynlib: "user32",

       importc: "LoadStringA".}

   proc IsDialogMessage*(hDlg: HWND, lpMsg: LPMSG): WINBOOL{.stdcall,

       dynlib: "user32", importc: "IsDialogMessageA".}

   proc DlgDirList*(hDlg: HWND, lpPathSpec: LPSTR, nIDListBox: int32,

-                   nIDStaticPath: int32, uFileType: UINT): int32{.stdcall,

+                   nIDStaticPath: int32, uFileType: WINUINT): int32{.stdcall,

       dynlib: "user32", importc: "DlgDirListA".}

   proc DlgDirSelectEx*(hDlg: HWND, lpString: LPSTR, nCount: int32,

                        nIDListBox: int32): WINBOOL{.stdcall, dynlib: "user32",

       importc: "DlgDirSelectExA".}

   proc DlgDirListComboBox*(hDlg: HWND, lpPathSpec: LPSTR, nIDComboBox: int32,

-                           nIDStaticPath: int32, uFiletype: UINT): int32{.

+                           nIDStaticPath: int32, uFiletype: WINUINT): int32{.

       stdcall, dynlib: "user32", importc: "DlgDirListComboBoxA".}

   proc DlgDirSelectComboBoxEx*(hDlg: HWND, lpString: LPSTR, nCount: int32,

                                nIDComboBox: int32): WINBOOL{.stdcall,

       dynlib: "user32", importc: "DlgDirSelectComboBoxExA".}

-  proc DefFrameProc*(wnd: HWND, hWndMDIClient: HWND, uMsg: UINT,

+  proc DefFrameProc*(wnd: HWND, hWndMDIClient: HWND, uMsg: WINUINT,

                      wp: WPARAM, lp: LPARAM): LRESULT{.stdcall,

       dynlib: "user32", importc: "DefFrameProcA".}

-  proc DefMDIChildProc*(wnd: HWND, uMsg: UINT, wp: WPARAM, lp: LPARAM): LRESULT{.

+  proc DefMDIChildProc*(wnd: HWND, uMsg: WINUINT, wp: WPARAM, lp: LPARAM): LRESULT{.

       stdcall, dynlib: "user32", importc: "DefMDIChildProcA".}

   proc CreateMDIWindow*(lpClassName: LPSTR, lpWindowName: LPSTR, dwStyle: DWORD,

                         X: int32, Y: int32, nWidth: int32, nHeight: int32,

                         hWndParent: HWND, hInstance: HINST, lp: LPARAM): HWND{.

       stdcall, dynlib: "user32", importc: "CreateMDIWindowA".}

-  proc WinHelp*(hWndMain: HWND, lpszHelp: LPCSTR, uCommand: UINT, dwData: DWORD): WINBOOL{.

+  proc WinHelp*(hWndMain: HWND, lpszHelp: LPCSTR, uCommand: WINUINT, dwData: DWORD): WINBOOL{.

       stdcall, dynlib: "user32", importc: "WinHelpA".}

   proc ChangeDisplaySettings*(lpDevMode: LPDEVMODE, dwFlags: DWORD): LONG{.

       stdcall, dynlib: "user32", importc: "ChangeDisplaySettingsA".}

   proc EnumDisplaySettings*(lpszDeviceName: LPCSTR, iModeNum: DWORD,

                             lpDevMode: LPDEVMODE): WINBOOL{.stdcall,

       dynlib: "user32", importc: "EnumDisplaySettingsA".}

-  proc SystemParametersInfo*(uiAction: UINT, uiParam: UINT, pvParam: PVOID,

-                             fWinIni: UINT): WINBOOL{.stdcall, dynlib: "user32",

+  proc SystemParametersInfo*(uiAction: WINUINT, uiParam: WINUINT, pvParam: PVOID,

+                             fWinIni: WINUINT): WINBOOL{.stdcall, dynlib: "user32",

       importc: "SystemParametersInfoA".}

   proc AddFontResource*(para1: LPCSTR): int32{.stdcall, dynlib: "gdi32",

       importc: "AddFontResourceA".}

@@ -18037,25 +18037,25 @@ else:
   proc EnumFonts*(para1: HDC, para2: LPCSTR, para3: ENUMFONTSPROC,

                   para4: pointer): int32{.stdcall, dynlib: "gdi32",

       importc: "EnumFontsA".}

-  proc GetCharWidth*(para1: HDC, para2: UINT, para3: UINT, para4: LPINT): WINBOOL{.

+  proc GetCharWidth*(para1: HDC, para2: WINUINT, para3: WINUINT, para4: LPINT): WINBOOL{.

       stdcall, dynlib: "gdi32", importc: "GetCharWidthA".}

-  proc GetCharWidth32*(para1: HDC, para2: UINT, para3: UINT, para4: LPINT): WINBOOL{.

+  proc GetCharWidth32*(para1: HDC, para2: WINUINT, para3: WINUINT, para4: LPINT): WINBOOL{.

       stdcall, dynlib: "gdi32", importc: "GetCharWidth32A".}

-  proc GetCharWidthFloat*(para1: HDC, para2: UINT, para3: UINT, para4: ptr float32): WINBOOL{.

+  proc GetCharWidthFloat*(para1: HDC, para2: WINUINT, para3: WINUINT, para4: ptr float32): WINBOOL{.

       stdcall, dynlib: "gdi32", importc: "GetCharWidthFloatA".}

-  proc GetCharABCWidths*(para1: HDC, para2: UINT, para3: UINT, para4: LPABC): WINBOOL{.

+  proc GetCharABCWidths*(para1: HDC, para2: WINUINT, para3: WINUINT, para4: LPABC): WINBOOL{.

       stdcall, dynlib: "gdi32", importc: "GetCharABCWidthsA".}

-  proc GetCharABCWidthsFloat*(para1: HDC, para2: UINT, para3: UINT,

+  proc GetCharABCWidthsFloat*(para1: HDC, para2: WINUINT, para3: WINUINT,

                               para4: LPABCFLOAT): WINBOOL{.stdcall,

       dynlib: "gdi32", importc: "GetCharABCWidthsFloatA".}

-  proc GetGlyphOutline*(para1: HDC, para2: UINT, para3: UINT,

+  proc GetGlyphOutline*(para1: HDC, para2: WINUINT, para3: WINUINT,

                         para4: LPGLYPHMETRICS, para5: DWORD, para6: LPVOID,

                         para7: PMAT2): DWORD{.stdcall, dynlib: "gdi32",

       importc: "GetGlyphOutlineA".}

   proc GetMetaFile*(para1: LPCSTR): HMETAFILE{.stdcall, dynlib: "gdi32",

       importc: "GetMetaFileA".}

-  proc GetOutlineTextMetrics*(para1: HDC, para2: UINT,

-                              para3: LPOUTLINETEXTMETRIC): UINT{.stdcall,

+  proc GetOutlineTextMetrics*(para1: HDC, para2: WINUINT,

+                              para3: LPOUTLINETEXTMETRIC): WINUINT{.stdcall,

       dynlib: "gdi32", importc: "GetOutlineTextMetricsA".}

   proc GetTextExtentPoint*(para1: HDC, para2: LPCSTR, para3: int32,

                            para4: LPSIZE): WINBOOL{.stdcall, dynlib: "gdi32",

@@ -18081,7 +18081,7 @@ else:
       importc: "CreateEnhMetaFileA".}

   proc GetEnhMetaFile*(para1: LPCSTR): HENHMETAFILE{.stdcall, dynlib: "gdi32",

       importc: "GetEnhMetaFileA".}

-  proc GetEnhMetaFileDescription*(para1: HENHMETAFILE, para2: UINT, para3: LPSTR): UINT{.

+  proc GetEnhMetaFileDescription*(para1: HENHMETAFILE, para2: WINUINT, para3: LPSTR): WINUINT{.

       stdcall, dynlib: "gdi32", importc: "GetEnhMetaFileDescriptionA".}

   proc GetTextMetrics*(para1: HDC, para2: LPTEXTMETRIC): WINBOOL{.stdcall,

       dynlib: "gdi32", importc: "GetTextMetricsA".}

@@ -18092,8 +18092,8 @@ else:
   proc TextOut*(para1: HDC, para2: int32, para3: int32, para4: LPCSTR,

                 para5: int32): WINBOOL{.stdcall, dynlib: "gdi32",

                                         importc: "TextOutA".}

-  proc ExtTextOut*(para1: HDC, para2: int32, para3: int32, para4: UINT,

-                   para5: LPRECT, para6: LPCSTR, para7: UINT, para8: LPINT): WINBOOL{.

+  proc ExtTextOut*(para1: HDC, para2: int32, para3: int32, para4: WINUINT,

+                   para5: LPRECT, para6: LPCSTR, para7: WINUINT, para8: LPINT): WINBOOL{.

       stdcall, dynlib: "gdi32", importc: "ExtTextOutA".}

   proc PolyTextOut*(para1: HDC, para2: PPOLYTEXT, para3: int32): WINBOOL{.

       stdcall, dynlib: "gdi32", importc: "PolyTextOutA".}

@@ -18110,19 +18110,19 @@ else:
       dynlib: "gdi32", importc: "GetICMProfileA".}

   proc SetICMProfile*(para1: HDC, para2: LPSTR): WINBOOL{.stdcall,

       dynlib: "gdi32", importc: "SetICMProfileA".}

-  proc UpdateICMRegKey*(para1: DWORD, para2: DWORD, para3: LPSTR, para4: UINT): WINBOOL{.

+  proc UpdateICMRegKey*(para1: DWORD, para2: DWORD, para3: LPSTR, para4: WINUINT): WINBOOL{.

       stdcall, dynlib: "gdi32", importc: "UpdateICMRegKeyA".}

   proc EnumICMProfiles*(para1: HDC, para2: ICMENUMPROC, para3: LPARAM): int32{.

       stdcall, dynlib: "gdi32", importc: "EnumICMProfilesA".}

   proc PropertySheet*(lppsph: LPCPROPSHEETHEADER): int32{.stdcall,

       dynlib: "comctl32", importc: "PropertySheetA".}

   proc ImageList_LoadImage*(hi: HINST, lpbmp: LPCSTR, cx: int32, cGrow: int32,

-                            crMask: COLORREF, uType: UINT, uFlags: UINT): HIMAGELIST{.

+                            crMask: COLORREF, uType: WINUINT, uFlags: WINUINT): HIMAGELIST{.

       stdcall, dynlib: "comctl32", importc: "ImageList_LoadImageA".}

   proc CreateStatusWindow*(style: LONG, lpszText: LPCSTR, hwndParent: HWND,

-                           wID: UINT): HWND{.stdcall, dynlib: "comctl32",

+                           wID: WINUINT): HWND{.stdcall, dynlib: "comctl32",

       importc: "CreateStatusWindowA".}

-  proc DrawStatusText*(hDC: HDC, lprc: LPRECT, pszText: LPCSTR, uFlags: UINT){.

+  proc DrawStatusText*(hDC: HDC, lprc: LPRECT, pszText: LPCSTR, uFlags: WINUINT){.

       stdcall, dynlib: "comctl32", importc: "DrawStatusTextA".}

   proc GetOpenFileName*(para1: LPOPENFILENAME): WINBOOL{.stdcall,

       dynlib: "comdlg32", importc: "GetOpenFileNameA".}

@@ -18477,7 +18477,7 @@ else:
   proc DdeCreateStringHandle*(para1: DWORD, para2: cstring, para3: int32): HSZ{.

       stdcall, dynlib: "user32", importc: "DdeCreateStringHandleA".}

   proc DdeInitialize*(para1: LPDWORD, para2: PFNCALLBACK, para3: DWORD,

-                      para4: DWORD): UINT{.stdcall, dynlib: "user32",

+                      para4: DWORD): WINUINT{.stdcall, dynlib: "user32",

       importc: "DdeInitializeA".}

   proc DdeQueryString*(para1: DWORD, para2: HSZ, para3: cstring, para4: DWORD,

                        para5: int32): DWORD{.stdcall, dynlib: "user32",

@@ -18519,7 +18519,7 @@ proc GlobalReAlloc*(hMem: HGLOBAL, dwBytes: DWORD, uFlags: INT): HGLOBAL{.
     stdcall, dynlib: "kernel32", importc: "GlobalReAlloc".}

 proc GlobalSize*(hMem: HGLOBAL): DWORD{.stdcall, dynlib: "kernel32",

                                         importc: "GlobalSize".}

-proc GlobalFlags*(hMem: HGLOBAL): UINT{.stdcall, dynlib: "kernel32",

+proc GlobalFlags*(hMem: HGLOBAL): WINUINT{.stdcall, dynlib: "kernel32",

                                         importc: "GlobalFlags".}

 proc GlobalLock*(hMem: HGLOBAL): LPVOID{.stdcall, dynlib: "kernel32",

     importc: "GlobalLock".}

@@ -18529,7 +18529,7 @@ proc GlobalUnlock*(hMem: HGLOBAL): WINBOOL{.stdcall, dynlib: "kernel32",
     importc: "GlobalUnlock".}

 proc GlobalFree*(hMem: HGLOBAL): HGLOBAL{.stdcall, dynlib: "kernel32",

     importc: "GlobalFree".}

-proc GlobalCompact*(dwMinFree: DWORD): UINT{.stdcall, dynlib: "kernel32",

+proc GlobalCompact*(dwMinFree: DWORD): WINUINT{.stdcall, dynlib: "kernel32",

     importc: "GlobalCompact".}

 proc GlobalFix*(hMem: HGLOBAL){.stdcall, dynlib: "kernel32",

                                 importc: "GlobalFix".}

@@ -18541,9 +18541,9 @@ proc GlobalUnWire*(hMem: HGLOBAL): WINBOOL{.stdcall, dynlib: "kernel32",
     importc: "GlobalUnWire".}

 proc GlobalMemoryStatus*(lpBuffer: LPMEMORYSTATUS){.stdcall, dynlib: "kernel32",

     importc: "GlobalMemoryStatus".}

-proc LocalAlloc*(uFlags: UINT, uBytes: UINT): HLOCAL{.stdcall,

+proc LocalAlloc*(uFlags: WINUINT, uBytes: WINUINT): HLOCAL{.stdcall,

     dynlib: "kernel32", importc: "LocalAlloc".}

-proc LocalReAlloc*(hMem: HLOCAL, uBytes: UINT, uFlags: UINT): HLOCAL{.stdcall,

+proc LocalReAlloc*(hMem: HLOCAL, uBytes: WINUINT, uFlags: WINUINT): HLOCAL{.stdcall,

     dynlib: "kernel32", importc: "LocalReAlloc".}

 proc LocalLock*(hMem: HLOCAL): LPVOID{.stdcall, dynlib: "kernel32",

                                        importc: "LocalLock".}

@@ -18551,15 +18551,15 @@ proc LocalHandle*(pMem: LPCVOID): HLOCAL{.stdcall, dynlib: "kernel32",
     importc: "LocalHandle".}

 proc LocalUnlock*(hMem: HLOCAL): WINBOOL{.stdcall, dynlib: "kernel32",

     importc: "LocalUnlock".}

-proc LocalSize*(hMem: HLOCAL): UINT{.stdcall, dynlib: "kernel32",

+proc LocalSize*(hMem: HLOCAL): WINUINT{.stdcall, dynlib: "kernel32",

                                      importc: "LocalSize".}

-proc LocalFlags*(hMem: HLOCAL): UINT{.stdcall, dynlib: "kernel32",

+proc LocalFlags*(hMem: HLOCAL): WINUINT{.stdcall, dynlib: "kernel32",

                                       importc: "LocalFlags".}

 proc LocalFree*(hMem: HLOCAL): HLOCAL{.stdcall, dynlib: "kernel32",

                                        importc: "LocalFree".}

-proc LocalShrink*(hMem: HLOCAL, cbNewSize: UINT): UINT{.stdcall,

+proc LocalShrink*(hMem: HLOCAL, cbNewSize: WINUINT): WINUINT{.stdcall,

     dynlib: "kernel32", importc: "LocalShrink".}

-proc LocalCompact*(uMinFree: UINT): UINT{.stdcall, dynlib: "kernel32",

+proc LocalCompact*(uMinFree: WINUINT): WINUINT{.stdcall, dynlib: "kernel32",

     importc: "LocalCompact".}

 proc FlushInstructionCache*(hProcess: HANDLE, lpBaseAddress: LPCVOID,

                             dwSize: DWORD): WINBOOL{.stdcall,

@@ -18595,7 +18595,7 @@ proc HeapSize*(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPCVOID): DWORD{.stdcall,
     dynlib: "kernel32", importc: "HeapSize".}

 proc HeapValidate*(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPCVOID): WINBOOL{.

     stdcall, dynlib: "kernel32", importc: "HeapValidate".}

-proc HeapCompact*(hHeap: HANDLE, dwFlags: DWORD): UINT{.stdcall,

+proc HeapCompact*(hHeap: HANDLE, dwFlags: DWORD): WINUINT{.stdcall,

     dynlib: "kernel32", importc: "HeapCompact".}

 proc GetProcessHeap*(): HANDLE{.stdcall, dynlib: "kernel32",

                                 importc: "GetProcessHeap".}

@@ -18628,9 +18628,9 @@ proc GetCurrentProcess*(): HANDLE{.stdcall, dynlib: "kernel32",
                                    importc: "GetCurrentProcess".}

 proc GetCurrentProcessId*(): DWORD{.stdcall, dynlib: "kernel32",

                                     importc: "GetCurrentProcessId".}

-proc ExitProcess*(uExitCode: UINT){.stdcall, dynlib: "kernel32",

+proc ExitProcess*(uExitCode: WINUINT){.stdcall, dynlib: "kernel32",

                                     importc: "ExitProcess".}

-proc TerminateProcess*(hProcess: HANDLE, uExitCode: UINT): WINBOOL{.stdcall,

+proc TerminateProcess*(hProcess: HANDLE, uExitCode: WINUINT): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "TerminateProcess".}

 proc SetProcessAffinityMask*(hProcess: THandle, dwProcessAffinityMask: DWORD): WINBOOL{.

     stdcall, dynlib: "kernel32", importc: "SetProcessAffinityMask".}

@@ -18681,7 +18681,7 @@ proc CreateIoCompletionPort*(FileHandle: HANDLE, ExistingCompletionPort: HANDLE,
                              CompletionKey: DWORD,

                              NumberOfConcurrentThreads: DWORD): HANDLE{.stdcall,

     dynlib: "kernel32", importc: "CreateIoCompletionPort".}

-proc SetErrorMode*(uMode: UINT): UINT{.stdcall, dynlib: "kernel32",

+proc SetErrorMode*(uMode: WINUINT): WINUINT{.stdcall, dynlib: "kernel32",

                                        importc: "SetErrorMode".}

 proc ReadProcessMemory*(hProcess: HANDLE, lpBaseAddress: LPCVOID,

                         lpBuffer: LPVOID, nSize: DWORD,

@@ -18741,7 +18741,7 @@ proc InitAtomTable*(nSize: DWORD): WINBOOL{.stdcall, dynlib: "kernel32",
     importc: "InitAtomTable".}

 proc DeleteAtom*(nAtom: ATOM): ATOM{.stdcall, dynlib: "kernel32",

                                      importc: "DeleteAtom".}

-proc SetHandleCount*(uNumber: UINT): UINT{.stdcall, dynlib: "kernel32",

+proc SetHandleCount*(uNumber: WINUINT): WINUINT{.stdcall, dynlib: "kernel32",

     importc: "SetHandleCount".}

 proc GetLogicalDrives*(): DWORD{.stdcall, dynlib: "kernel32",

                                  importc: "GetLogicalDrives".}

@@ -18803,7 +18803,7 @@ proc SetHandleInformation*(hObject: HANDLE, dwMask: DWORD, dwFlags: DWORD): WINB
     stdcall, dynlib: "kernel32", importc: "SetHandleInformation".}

 proc LoadModule*(lpModuleName: LPCSTR, lpParameterBlock: LPVOID): DWORD{.

     stdcall, dynlib: "kernel32", importc: "LoadModule".}

-proc WinExec*(lpCmdLine: LPCSTR, uCmdShow: UINT): UINT{.stdcall,

+proc WinExec*(lpCmdLine: LPCSTR, uCmdShow: WINUINT): WINUINT{.stdcall,

     dynlib: "kernel32", importc: "WinExec".}

 proc ClearCommBreak*(hFile: HANDLE): WINBOOL{.stdcall, dynlib: "kernel32",

     importc: "ClearCommBreak".}

@@ -18954,15 +18954,15 @@ proc FlushViewOfFile*(lpBaseAddress: LPCVOID, dwNumberOfBytesToFlush: DWORD): WI
     stdcall, dynlib: "kernel32", importc: "FlushViewOfFile".}

 proc UnmapViewOfFile*(lpBaseAddress: LPVOID): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "UnmapViewOfFile".}

-proc OpenFile*(lpFileName: LPCSTR, lpReOpenBuff: LPOFSTRUCT, uStyle: UINT): HFILE{.

+proc OpenFile*(lpFileName: LPCSTR, lpReOpenBuff: LPOFSTRUCT, uStyle: WINUINT): HFILE{.

     stdcall, dynlib: "kernel32", importc: "OpenFile".}

 proc lopen*(lpPathName: LPCSTR, iReadWrite: int32): HFILE{.stdcall,

     dynlib: "kernel32", importc: "_lopen".}

 proc lcreat*(lpPathName: LPCSTR, iAttribute: int32): HFILE{.stdcall,

     dynlib: "kernel32", importc: "_lcreat".}

-proc lread*(hFile: HFILE, lpBuffer: LPVOID, uBytes: UINT): UINT{.stdcall,

+proc lread*(hFile: HFILE, lpBuffer: LPVOID, uBytes: WINUINT): WINUINT{.stdcall,

     dynlib: "kernel32", importc: "_lread".}

-proc lwrite*(hFile: HFILE, lpBuffer: LPCSTR, uBytes: UINT): UINT{.stdcall,

+proc lwrite*(hFile: HFILE, lpBuffer: LPCSTR, uBytes: WINUINT): WINUINT{.stdcall,

     dynlib: "kernel32", importc: "_lwrite".}

 proc hread*(hFile: HFILE, lpBuffer: LPVOID, lBytes: int32): int32{.stdcall,

     dynlib: "kernel32", importc: "_hread".}

@@ -19233,13 +19233,13 @@ proc SetPriorityClass*(hProcess: HANDLE, dwPriorityClass: DWORD): WINBOOL{.
     stdcall, dynlib: "kernel32", importc: "SetPriorityClass".}

 proc GetPriorityClass*(hProcess: HANDLE): DWORD{.stdcall, dynlib: "kernel32",

     importc: "GetPriorityClass".}

-proc IsBadReadPtr*(lp: pointer, ucb: UINT): WINBOOL{.stdcall,

+proc IsBadReadPtr*(lp: pointer, ucb: WINUINT): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "IsBadReadPtr".}

-proc IsBadWritePtr*(lp: LPVOID, ucb: UINT): WINBOOL{.stdcall,

+proc IsBadWritePtr*(lp: LPVOID, ucb: WINUINT): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "IsBadWritePtr".}

-proc IsBadHugeReadPtr*(lp: pointer, ucb: UINT): WINBOOL{.stdcall,

+proc IsBadHugeReadPtr*(lp: pointer, ucb: WINUINT): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "IsBadHugeReadPtr".}

-proc IsBadHugeWritePtr*(lp: LPVOID, ucb: UINT): WINBOOL{.stdcall,

+proc IsBadHugeWritePtr*(lp: LPVOID, ucb: WINUINT): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "IsBadHugeWritePtr".}

 proc IsBadCodePtr*(lpfn: FARPROC): WINBOOL{.stdcall, dynlib: "kernel32",

     importc: "IsBadCodePtr".}

@@ -19249,7 +19249,7 @@ proc QueryPerformanceCounter*(lpPerformanceCount: PLARGE_INTEGER): WINBOOL{.
     stdcall, dynlib: "kernel32", importc: "QueryPerformanceCounter".}

 proc QueryPerformanceFrequency*(lpFrequency: PLARGE_INTEGER): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "QueryPerformanceFrequency".}

-proc ActivateKeyboardLayout*(hkl: HKL, Flags: UINT): WINBOOL{.stdcall,

+proc ActivateKeyboardLayout*(hkl: HKL, Flags: WINUINT): WINBOOL{.stdcall,

     dynlib: "user32", importc: "ActivateKeyboardLayout".}

 proc UnloadKeyboardLayout*(hkl: HKL): WINBOOL{.stdcall, dynlib: "user32",

     importc: "UnloadKeyboardLayout".}

@@ -19286,11 +19286,11 @@ proc TranslateMessage*(lpMsg: LPMSG): WINBOOL{.stdcall, dynlib: "user32",
     importc: "TranslateMessage".}

 proc SetMessageQueue*(cMessagesMax: int32): WINBOOL{.stdcall, dynlib: "user32",

     importc: "SetMessageQueue".}

-proc RegisterHotKey*(wnd: HWND, anID: int32, fsModifiers: UINT, vk: UINT): WINBOOL{.

+proc RegisterHotKey*(wnd: HWND, anID: int32, fsModifiers: WINUINT, vk: WINUINT): WINBOOL{.

     stdcall, dynlib: "user32", importc: "RegisterHotKey".}

 proc UnregisterHotKey*(wnd: HWND, anID: int32): WINBOOL{.stdcall,

     dynlib: "user32", importc: "UnregisterHotKey".}

-proc ExitWindowsEx*(uFlags: UINT, dwReserved: DWORD): WINBOOL{.stdcall,

+proc ExitWindowsEx*(uFlags: WINUINT, dwReserved: DWORD): WINBOOL{.stdcall,

     dynlib: "user32", importc: "ExitWindowsEx".}

 proc SwapMouseButton*(fSwap: WINBOOL): WINBOOL{.stdcall, dynlib: "user32",

     importc: "SwapMouseButton".}

@@ -19302,7 +19302,7 @@ proc GetMessageExtraInfo*(): LONG{.stdcall, dynlib: "user32",
                                    importc: "GetMessageExtraInfo".}

 proc SetMessageExtraInfo*(lp: LPARAM): LPARAM{.stdcall, dynlib: "user32",

     importc: "SetMessageExtraInfo".}

-proc BroadcastSystemMessage*(para1: DWORD, para2: LPDWORD, para3: UINT,

+proc BroadcastSystemMessage*(para1: DWORD, para2: LPDWORD, para3: WINUINT,

                              para4: WPARAM, para5: LPARAM): int32{.stdcall,

     dynlib: "user32", importc: "BroadcastSystemMessage".}

 proc AttachThreadInput*(idAttach: DWORD, idAttachTo: DWORD, fAttach: WINBOOL): WINBOOL{.

@@ -19316,9 +19316,9 @@ proc PostQuitMessage*(nExitCode: int32){.stdcall, dynlib: "user32",
     importc: "PostQuitMessage".}

 proc InSendMessage*(): WINBOOL{.stdcall, dynlib: "user32",

                                 importc: "InSendMessage".}

-proc GetDoubleClickTime*(): UINT{.stdcall, dynlib: "user32",

+proc GetDoubleClickTime*(): WINUINT{.stdcall, dynlib: "user32",

                                   importc: "GetDoubleClickTime".}

-proc SetDoubleClickTime*(para1: UINT): WINBOOL{.stdcall, dynlib: "user32",

+proc SetDoubleClickTime*(para1: WINUINT): WINBOOL{.stdcall, dynlib: "user32",

     importc: "SetDoubleClickTime".}

 proc IsWindow*(wnd: HWND): WINBOOL{.stdcall, dynlib: "user32",

                                      importc: "IsWindow".}

@@ -19344,7 +19344,7 @@ proc MoveWindow*(wnd: HWND, X: int32, Y: int32, nWidth: int32, nHeight: int32,
                  bRepaint: WINBOOL): WINBOOL{.stdcall, dynlib: "user32",

     importc: "MoveWindow".}

 proc SetWindowPos*(wnd: HWND, hWndInsertAfter: HWND, X: int32, Y: int32,

-                   cx: int32, cy: int32, uFlags: UINT): WINBOOL{.stdcall,

+                   cx: int32, cy: int32, uFlags: WINUINT): WINBOOL{.stdcall,

     dynlib: "user32", importc: "SetWindowPos".}

 proc GetWindowPlacement*(wnd: HWND, lpwndpl: var WINDOWPLACEMENT): WINBOOL{.

     stdcall, dynlib: "user32", importc: "GetWindowPlacement".}

@@ -19357,7 +19357,7 @@ proc SetWindowPlacement*(wnd: HWND, lpwndpl: PWINDOWPLACEMENT): WINBOOL{.
 proc BeginDeferWindowPos*(nNumWindows: int32): HDWP{.stdcall, dynlib: "user32",

     importc: "BeginDeferWindowPos".}

 proc DeferWindowPos*(hWinPosInfo: HDWP, wnd: HWND, hWndInsertAfter: HWND,

-                     x: int32, y: int32, cx: int32, cy: int32, uFlags: UINT): HDWP{.

+                     x: int32, y: int32, cx: int32, cy: int32, uFlags: WINUINT): HDWP{.

     stdcall, dynlib: "user32", importc: "DeferWindowPos".}

 proc EndDeferWindowPos*(hWinPosInfo: HDWP): WINBOOL{.stdcall, dynlib: "user32",

     importc: "EndDeferWindowPos".}

@@ -19374,18 +19374,18 @@ proc EndDialog*(hDlg: HWND, nResult: int32): WINBOOL{.stdcall, dynlib: "user32",
     importc: "EndDialog".}

 proc GetDlgItem*(hDlg: HWND, nIDDlgItem: int32): HWND{.stdcall,

     dynlib: "user32", importc: "GetDlgItem".}

-proc SetDlgItemInt*(hDlg: HWND, nIDDlgItem: int32, uValue: UINT,

+proc SetDlgItemInt*(hDlg: HWND, nIDDlgItem: int32, uValue: WINUINT,

                     bSigned: WINBOOL): WINBOOL{.stdcall, dynlib: "user32",

     importc: "SetDlgItemInt".}

 proc GetDlgItemInt*(hDlg: HWND, nIDDlgItem: int32, lpTranslated: var WINBOOL,

-                    bSigned: WINBOOL): UINT{.stdcall, dynlib: "user32",

+                    bSigned: WINBOOL): WINUINT{.stdcall, dynlib: "user32",

     importc: "GetDlgItemInt".}

-proc CheckDlgButton*(hDlg: HWND, nIDButton: int32, uCheck: UINT): WINBOOL{.

+proc CheckDlgButton*(hDlg: HWND, nIDButton: int32, uCheck: WINUINT): WINBOOL{.

     stdcall, dynlib: "user32", importc: "CheckDlgButton".}

 proc CheckRadioButton*(hDlg: HWND, nIDFirstButton: int32, nIDLastButton: int32,

                        nIDCheckButton: int32): WINBOOL{.stdcall,

     dynlib: "user32", importc: "CheckRadioButton".}

-proc IsDlgButtonChecked*(hDlg: HWND, nIDButton: int32): UINT{.stdcall,

+proc IsDlgButtonChecked*(hDlg: HWND, nIDButton: int32): WINUINT{.stdcall,

     dynlib: "user32", importc: "IsDlgButtonChecked".}

 proc GetNextDlgGroupItem*(hDlg: HWND, hCtl: HWND, bPrevious: WINBOOL): HWND{.

     stdcall, dynlib: "user32", importc: "GetNextDlgGroupItem".}

@@ -19407,19 +19407,19 @@ proc GetClipboardViewer*(): HWND{.stdcall, dynlib: "user32",
                                   importc: "GetClipboardViewer".}

 proc ChangeClipboardChain*(hWndRemove: HWND, hWndNewNext: HWND): WINBOOL{.

     stdcall, dynlib: "user32", importc: "ChangeClipboardChain".}

-proc SetClipboardData*(uFormat: UINT, hMem: HANDLE): HANDLE{.stdcall,

+proc SetClipboardData*(uFormat: WINUINT, hMem: HANDLE): HANDLE{.stdcall,

     dynlib: "user32", importc: "SetClipboardData".}

-proc GetClipboardData*(uFormat: UINT): HANDLE{.stdcall, dynlib: "user32",

+proc GetClipboardData*(uFormat: WINUINT): HANDLE{.stdcall, dynlib: "user32",

     importc: "GetClipboardData".}

 proc CountClipboardFormats*(): int32{.stdcall, dynlib: "user32",

                                       importc: "CountClipboardFormats".}

-proc EnumClipboardFormats*(format: UINT): UINT{.stdcall, dynlib: "user32",

+proc EnumClipboardFormats*(format: WINUINT): WINUINT{.stdcall, dynlib: "user32",

     importc: "EnumClipboardFormats".}

 proc EmptyClipboard*(): WINBOOL{.stdcall, dynlib: "user32",

                                  importc: "EmptyClipboard".}

-proc IsClipboardFormatAvailable*(format: UINT): WINBOOL{.stdcall,

+proc IsClipboardFormatAvailable*(format: WINUINT): WINBOOL{.stdcall,

     dynlib: "user32", importc: "IsClipboardFormatAvailable".}

-proc GetPriorityClipboardFormat*(paFormatPriorityList: var UINT, cFormats: int32): int32{.

+proc GetPriorityClipboardFormat*(paFormatPriorityList: var WINUINT, cFormats: int32): int32{.

     stdcall, dynlib: "user32", importc: "GetPriorityClipboardFormat".}

 proc GetOpenClipboardWindow*(): HWND{.stdcall, dynlib: "user32",

                                       importc: "GetOpenClipboardWindow".}

@@ -19432,7 +19432,7 @@ proc SetFocus*(wnd: HWND): HWND{.stdcall, dynlib: "user32", importc: "SetFocus".
 proc GetActiveWindow*(): HWND{.stdcall, dynlib: "user32",

                                importc: "GetActiveWindow".}

 proc GetFocus*(): HWND{.stdcall, dynlib: "user32", importc: "GetFocus".}

-proc GetKBCodePage*(): UINT{.stdcall, dynlib: "user32", importc: "GetKBCodePage".}

+proc GetKBCodePage*(): WINUINT{.stdcall, dynlib: "user32", importc: "GetKBCodePage".}

 proc GetKeyState*(nVirtKey: int32): SHORT{.stdcall, dynlib: "user32",

     importc: "GetKeyState".}

 proc GetAsyncKeyState*(vKey: int32): SHORT{.stdcall, dynlib: "user32",

@@ -19443,14 +19443,14 @@ proc SetKeyboardState*(lpKeyState: LPBYTE): WINBOOL{.stdcall, dynlib: "user32",
     importc: "SetKeyboardState".}

 proc GetKeyboardType*(nTypeFlag: int32): int32{.stdcall, dynlib: "user32",

     importc: "GetKeyboardType".}

-proc ToAscii*(uVirtKey: UINT, uScanCode: UINT, lpKeyState: PBYTE,

-              lpChar: LPWORD, uFlags: UINT): int32{.stdcall, dynlib: "user32",

+proc ToAscii*(uVirtKey: WINUINT, uScanCode: WINUINT, lpKeyState: PBYTE,

+              lpChar: LPWORD, uFlags: WINUINT): int32{.stdcall, dynlib: "user32",

     importc: "ToAscii".}

-proc ToAsciiEx*(uVirtKey: UINT, uScanCode: UINT, lpKeyState: PBYTE,

-                lpChar: LPWORD, uFlags: UINT, dwhkl: HKL): int32{.stdcall,

+proc ToAsciiEx*(uVirtKey: WINUINT, uScanCode: WINUINT, lpKeyState: PBYTE,

+                lpChar: LPWORD, uFlags: WINUINT, dwhkl: HKL): int32{.stdcall,

     dynlib: "user32", importc: "ToAsciiEx".}

-proc ToUnicode*(wVirtKey: UINT, wScanCode: UINT, lpKeyState: PBYTE,

-                pwszBuff: LPWSTR, cchBuff: int32, wFlags: UINT): int32{.stdcall,

+proc ToUnicode*(wVirtKey: WINUINT, wScanCode: WINUINT, lpKeyState: PBYTE,

+                pwszBuff: LPWSTR, cchBuff: int32, wFlags: WINUINT): int32{.stdcall,

     dynlib: "user32", importc: "ToUnicode".}

 proc OemKeyScan*(wOemChar: int16): DWORD{.stdcall, dynlib: "user32",

     importc: "OemKeyScan".}

@@ -19461,7 +19461,7 @@ proc mouse_event*(dwFlags: DWORD, dx: DWORD, dy: DWORD, cButtons: DWORD,
                                        importc: "mouse_event".}

 proc GetInputState*(): WINBOOL{.stdcall, dynlib: "user32",

                                 importc: "GetInputState".}

-proc GetQueueStatus*(flags: UINT): DWORD{.stdcall, dynlib: "user32",

+proc GetQueueStatus*(flags: WINUINT): DWORD{.stdcall, dynlib: "user32",

     importc: "GetQueueStatus".}

 proc GetCapture*(): HWND{.stdcall, dynlib: "user32", importc: "GetCapture".}

 proc SetCapture*(wnd: HWND): HWND{.stdcall, dynlib: "user32",

@@ -19472,9 +19472,9 @@ proc MsgWaitForMultipleObjects*(nCount: DWORD, pHandles: LPHANDLE,
                                 fWaitAll: WINBOOL, dwMilliseconds: DWORD,

                                 dwWakeMask: DWORD): DWORD{.stdcall,

     dynlib: "user32", importc: "MsgWaitForMultipleObjects".}

-proc SetTimer*(wnd: HWND, nIDEvent: UINT, uElapse: UINT, lpTimerFunc: TIMERPROC): UINT{.

+proc SetTimer*(wnd: HWND, nIDEvent: WINUINT, uElapse: WINUINT, lpTimerFunc: TIMERPROC): WINUINT{.

     stdcall, dynlib: "user32", importc: "SetTimer".}

-proc KillTimer*(wnd: HWND, uIDEvent: UINT): WINBOOL{.stdcall, dynlib: "user32",

+proc KillTimer*(wnd: HWND, uIDEvent: WINUINT): WINBOOL{.stdcall, dynlib: "user32",

     importc: "KillTimer".}

 proc IsWindowUnicode*(wnd: HWND): WINBOOL{.stdcall, dynlib: "user32",

     importc: "IsWindowUnicode".}

@@ -19489,10 +19489,10 @@ proc GetSystemMetrics*(nIndex: int32): int32{.stdcall, dynlib: "user32",
 proc GetMenu*(wnd: HWND): HMENU{.stdcall, dynlib: "user32", importc: "GetMenu".}

 proc SetMenu*(wnd: HWND, menu: HMENU): WINBOOL{.stdcall, dynlib: "user32",

     importc: "SetMenu".}

-proc HiliteMenuItem*(wnd: HWND, menu: HMENU, uIDHiliteItem: UINT,

-                     uHilite: UINT): WINBOOL{.stdcall, dynlib: "user32",

+proc HiliteMenuItem*(wnd: HWND, menu: HMENU, uIDHiliteItem: WINUINT,

+                     uHilite: WINUINT): WINBOOL{.stdcall, dynlib: "user32",

     importc: "HiliteMenuItem".}

-proc GetMenuState*(menu: HMENU, uId: UINT, uFlags: UINT): UINT{.stdcall,

+proc GetMenuState*(menu: HMENU, uId: WINUINT, uFlags: WINUINT): WINUINT{.stdcall,

     dynlib: "user32", importc: "GetMenuState".}

 proc DrawMenuBar*(wnd: HWND): WINBOOL{.stdcall, dynlib: "user32",

                                         importc: "DrawMenuBar".}

@@ -19503,37 +19503,37 @@ proc CreatePopupMenu*(): HMENU{.stdcall, dynlib: "user32",
                                 importc: "CreatePopupMenu".}

 proc DestroyMenu*(menu: HMENU): WINBOOL{.stdcall, dynlib: "user32",

     importc: "DestroyMenu".}

-proc CheckMenuItem*(menu: HMENU, uIDCheckItem: UINT, uCheck: UINT): DWORD{.

+proc CheckMenuItem*(menu: HMENU, uIDCheckItem: WINUINT, uCheck: WINUINT): DWORD{.

     stdcall, dynlib: "user32", importc: "CheckMenuItem".}

-proc EnableMenuItem*(menu: HMENU, uIDEnableItem: UINT, uEnable: UINT): WINBOOL{.

+proc EnableMenuItem*(menu: HMENU, uIDEnableItem: WINUINT, uEnable: WINUINT): WINBOOL{.

     stdcall, dynlib: "user32", importc: "EnableMenuItem".}

 proc GetSubMenu*(menu: HMENU, nPos: int32): HMENU{.stdcall, dynlib: "user32",

     importc: "GetSubMenu".}

-proc GetMenuItemID*(menu: HMENU, nPos: int32): UINT{.stdcall, dynlib: "user32",

+proc GetMenuItemID*(menu: HMENU, nPos: int32): WINUINT{.stdcall, dynlib: "user32",

     importc: "GetMenuItemID".}

 proc GetMenuItemCount*(menu: HMENU): int32{.stdcall, dynlib: "user32",

     importc: "GetMenuItemCount".}

-proc RemoveMenu*(menu: HMENU, uPosition: UINT, uFlags: UINT): WINBOOL{.stdcall,

+proc RemoveMenu*(menu: HMENU, uPosition: WINUINT, uFlags: WINUINT): WINBOOL{.stdcall,

     dynlib: "user32", importc: "RemoveMenu".}

-proc DeleteMenu*(menu: HMENU, uPosition: UINT, uFlags: UINT): WINBOOL{.stdcall,

+proc DeleteMenu*(menu: HMENU, uPosition: WINUINT, uFlags: WINUINT): WINBOOL{.stdcall,

     dynlib: "user32", importc: "DeleteMenu".}

-proc SetMenuItemBitmaps*(menu: HMENU, uPosition: UINT, uFlags: UINT,

+proc SetMenuItemBitmaps*(menu: HMENU, uPosition: WINUINT, uFlags: WINUINT,

                          hBitmapUnchecked: HBITMAP, hBitmapChecked: HBITMAP): WINBOOL{.

     stdcall, dynlib: "user32", importc: "SetMenuItemBitmaps".}

 proc GetMenuCheckMarkDimensions*(): LONG{.stdcall, dynlib: "user32",

     importc: "GetMenuCheckMarkDimensions".}

-proc TrackPopupMenu*(menu: HMENU, uFlags: UINT, x: int32, y: int32,

+proc TrackPopupMenu*(menu: HMENU, uFlags: WINUINT, x: int32, y: int32,

                      nReserved: int32, wnd: HWND, prcRect: var RECT): WINBOOL{.

     stdcall, dynlib: "user32", importc: "TrackPopupMenu".}

-proc GetMenuDefaultItem*(menu: HMENU, fByPos: UINT, gmdiFlags: UINT): UINT{.

+proc GetMenuDefaultItem*(menu: HMENU, fByPos: WINUINT, gmdiFlags: WINUINT): WINUINT{.

     stdcall, dynlib: "user32", importc: "GetMenuDefaultItem".}

-proc SetMenuDefaultItem*(menu: HMENU, uItem: UINT, fByPos: UINT): WINBOOL{.

+proc SetMenuDefaultItem*(menu: HMENU, uItem: WINUINT, fByPos: WINUINT): WINBOOL{.

     stdcall, dynlib: "user32", importc: "SetMenuDefaultItem".}

-proc GetMenuItemRect*(wnd: HWND, menu: HMENU, uItem: UINT, lprcItem: LPRECT): WINBOOL{.

+proc GetMenuItemRect*(wnd: HWND, menu: HMENU, uItem: WINUINT, lprcItem: LPRECT): WINBOOL{.

     stdcall, dynlib: "user32", importc: "GetMenuItemRect".}

 proc MenuItemFromPoint*(wnd: HWND, menu: HMENU, ptScreen: POINT): int32{.

     stdcall, dynlib: "user32", importc: "MenuItemFromPoint".}

-proc DragObject*(para1: HWND, para2: HWND, para3: UINT, para4: DWORD,

+proc DragObject*(para1: HWND, para2: HWND, para3: WINUINT, para4: DWORD,

                  para5: HCURSOR): DWORD{.stdcall, dynlib: "user32",

     importc: "DragObject".}

 proc DragDetect*(wnd: HWND, pt: POINT): WINBOOL{.stdcall, dynlib: "user32",

@@ -19586,9 +19586,9 @@ proc InvalidateRgn*(wnd: HWND, hRgn: HRGN, bErase: WINBOOL): WINBOOL{.stdcall,
 proc ValidateRgn*(wnd: HWND, hRgn: HRGN): WINBOOL{.stdcall, dynlib: "user32",

     importc: "ValidateRgn".}

 proc RedrawWindow*(wnd: HWND, lprcUpdate: var RECT, hrgnUpdate: HRGN,

-                   flags: UINT): WINBOOL{.stdcall, dynlib: "user32",

+                   flags: WINUINT): WINBOOL{.stdcall, dynlib: "user32",

     importc: "RedrawWindow".}

-proc RedrawWindow*(wnd: HWND, lprcUpdate: LPRECT, hrgnUpdate: HRGN, flags: UINT): WINBOOL{.

+proc RedrawWindow*(wnd: HWND, lprcUpdate: LPRECT, hrgnUpdate: HRGN, flags: WINUINT): WINBOOL{.

     stdcall, dynlib: "user32", importc: "RedrawWindow".}

 proc LockWindowUpdate*(hWndLock: HWND): WINBOOL{.stdcall, dynlib: "user32",

     importc: "LockWindowUpdate".}

@@ -19600,7 +19600,7 @@ proc ScrollDC*(hDC: HDC, dx: int32, dy: int32, lprcScroll: var RECT,
     stdcall, dynlib: "user32", importc: "ScrollDC".}

 proc ScrollWindowEx*(wnd: HWND, dx: int32, dy: int32, prcScroll: var RECT,

                      prcClip: var RECT, hrgnUpdate: HRGN, prcUpdate: LPRECT,

-                     flags: UINT): int32{.stdcall, dynlib: "user32",

+                     flags: WINUINT): int32{.stdcall, dynlib: "user32",

     importc: "ScrollWindowEx".}

 proc SetScrollPos*(wnd: HWND, nBar: int32, nPos: int32, bRedraw: WINBOOL): int32{.

     stdcall, dynlib: "user32", importc: "SetScrollPos".}

@@ -19613,7 +19613,7 @@ proc GetScrollRange*(wnd: HWND, nBar: int32, lpMinPos: LPINT, lpMaxPos: LPINT):
     stdcall, dynlib: "user32", importc: "GetScrollRange".}

 proc ShowScrollBar*(wnd: HWND, wBar: int32, bShow: WINBOOL): WINBOOL{.stdcall,

     dynlib: "user32", importc: "ShowScrollBar".}

-proc EnableScrollBar*(wnd: HWND, wSBflags: UINT, wArrows: UINT): WINBOOL{.

+proc EnableScrollBar*(wnd: HWND, wSBflags: WINUINT, wArrows: WINUINT): WINBOOL{.

     stdcall, dynlib: "user32", importc: "EnableScrollBar".}

 proc GetClientRect*(wnd: HWND, lpRect: LPRECT): WINBOOL{.stdcall,

     dynlib: "user32", importc: "GetClientRect".}

@@ -19632,7 +19632,7 @@ proc SetMenuContextHelpId*(para1: HMENU, para2: DWORD): WINBOOL{.stdcall,
     dynlib: "user32", importc: "SetMenuContextHelpId".}

 proc GetMenuContextHelpId*(para1: HMENU): DWORD{.stdcall, dynlib: "user32",

     importc: "GetMenuContextHelpId".}

-proc MessageBeep*(uType: UINT): WINBOOL{.stdcall, dynlib: "user32",

+proc MessageBeep*(uType: WINUINT): WINBOOL{.stdcall, dynlib: "user32",

     importc: "MessageBeep".}

 proc ShowCursor*(bShow: WINBOOL): int32{.stdcall, dynlib: "user32",

     importc: "ShowCursor".}

@@ -19649,9 +19649,9 @@ proc GetClipCursor*(lpRect: LPRECT): WINBOOL{.stdcall, dynlib: "user32",
 proc GetCursor*(): HCURSOR{.stdcall, dynlib: "user32", importc: "GetCursor".}

 proc CreateCaret*(wnd: HWND, hBitmap: HBITMAP, nWidth: int32, nHeight: int32): WINBOOL{.

     stdcall, dynlib: "user32", importc: "CreateCaret".}

-proc GetCaretBlinkTime*(): UINT{.stdcall, dynlib: "user32",

+proc GetCaretBlinkTime*(): WINUINT{.stdcall, dynlib: "user32",

                                  importc: "GetCaretBlinkTime".}

-proc SetCaretBlinkTime*(uMSeconds: UINT): WINBOOL{.stdcall, dynlib: "user32",

+proc SetCaretBlinkTime*(uMSeconds: WINUINT): WINBOOL{.stdcall, dynlib: "user32",

     importc: "SetCaretBlinkTime".}

 proc DestroyCaret*(): WINBOOL{.stdcall, dynlib: "user32",

                                importc: "DestroyCaret".}

@@ -19668,7 +19668,7 @@ proc ClientToScreen*(wnd: HWND, lpPoint: LPPOINT): WINBOOL{.stdcall,
 proc ScreenToClient*(wnd: HWND, lpPoint: LPPOINT): WINBOOL{.stdcall,

     dynlib: "user32", importc: "ScreenToClient".}

 proc MapWindowPoints*(hWndFrom: HWND, hWndTo: HWND, lpPoints: LPPOINT,

-                      cPoints: UINT): int32{.stdcall, dynlib: "user32",

+                      cPoints: WINUINT): int32{.stdcall, dynlib: "user32",

     importc: "MapWindowPoints".}

 proc WindowFromPoint*(Point: POINT): HWND{.stdcall, dynlib: "user32",

     importc: "WindowFromPoint".}

@@ -19683,7 +19683,7 @@ proc SetSysColors*(cElements: int32, lpaElements: var wINT,
     dynlib: "user32", importc: "SetSysColors".}

 proc DrawFocusRect*(hDC: HDC, lprc: var RECT): WINBOOL{.stdcall,

     dynlib: "user32", importc: "DrawFocusRect".}

-proc FillRect*(hDC: HDC, lprc: RECT, hbr: HBRUSH): int32{.stdcall,

+proc FillRect*(hDC: HDC, lprc: var RECT, hbr: HBRUSH): int32{.stdcall,

     dynlib: "user32", importc: "FillRect".}

 proc FrameRect*(hDC: HDC, lprc: var RECT, hbr: HBRUSH): int32{.stdcall,

     dynlib: "user32", importc: "FrameRect".}

@@ -19743,7 +19743,7 @@ proc GetWindowThreadProcessId*(wnd: HWND, lpdwProcessId: LPDWORD): DWORD{.
     stdcall, dynlib: "user32", importc: "GetWindowThreadProcessId".}

 proc GetLastActivePopup*(wnd: HWND): HWND{.stdcall, dynlib: "user32",

     importc: "GetLastActivePopup".}

-proc GetWindow*(wnd: HWND, uCmd: UINT): HWND{.stdcall, dynlib: "user32",

+proc GetWindow*(wnd: HWND, uCmd: WINUINT): HWND{.stdcall, dynlib: "user32",

     importc: "GetWindow".}

 proc UnhookWindowsHook*(nCode: int32, pfnFilterProc: HOOKPROC): WINBOOL{.

     stdcall, dynlib: "user32", importc: "UnhookWindowsHook".}

@@ -19751,8 +19751,8 @@ proc UnhookWindowsHookEx*(hhk: HHOOK): WINBOOL{.stdcall, dynlib: "user32",
     importc: "UnhookWindowsHookEx".}

 proc CallNextHookEx*(hhk: HHOOK, nCode: int32, wp: WPARAM, lp: LPARAM): LRESULT{.

     stdcall, dynlib: "user32", importc: "CallNextHookEx".}

-proc CheckMenuRadioItem*(para1: HMENU, para2: UINT, para3: UINT, para4: UINT,

-                         para5: UINT): WINBOOL{.stdcall, dynlib: "user32",

+proc CheckMenuRadioItem*(para1: HMENU, para2: WINUINT, para3: WINUINT, para4: WINUINT,

+                         para5: WINUINT): WINBOOL{.stdcall, dynlib: "user32",

     importc: "CheckMenuRadioItem".}

 proc CreateCursor*(hInst: HINST, xHotSpot: int32, yHotSpot: int32,

                    nWidth: int32, nHeight: int32, pvANDPlane: pointer,

@@ -19771,17 +19771,17 @@ proc LookupIconIdFromDirectory*(presbits: PBYTE, fIcon: WINBOOL): int32{.
     stdcall, dynlib: "user32", importc: "LookupIconIdFromDirectory".}

 proc LookupIconIdFromDirectoryEx*(presbits: PBYTE, fIcon: WINBOOL,

                                   cxDesired: int32, cyDesired: int32,

-                                  Flags: UINT): int32{.stdcall,

+                                  Flags: WINUINT): int32{.stdcall,

     dynlib: "user32", importc: "LookupIconIdFromDirectoryEx".}

 proc CreateIconFromResource*(presbits: PBYTE, dwResSize: DWORD, fIcon: WINBOOL,

                              dwVer: DWORD): HICON{.stdcall, dynlib: "user32",

     importc: "CreateIconFromResource".}

 proc CreateIconFromResourceEx*(presbits: PBYTE, dwResSize: DWORD,

                                fIcon: WINBOOL, dwVer: DWORD, cxDesired: int32,

-                               cyDesired: int32, Flags: UINT): HICON{.stdcall,

+                               cyDesired: int32, Flags: WINUINT): HICON{.stdcall,

     dynlib: "user32", importc: "CreateIconFromResourceEx".}

-proc CopyImage*(para1: HANDLE, para2: UINT, para3: int32, para4: int32,

-                para5: UINT): HICON{.stdcall, dynlib: "user32",

+proc CopyImage*(para1: HANDLE, para2: WINUINT, para3: int32, para4: int32,

+                para5: WINUINT): HICON{.stdcall, dynlib: "user32",

                                      importc: "CopyImage".}

 proc CreateIconIndirect*(piconinfo: PICONINFO): HICON{.stdcall,

     dynlib: "user32", importc: "CreateIconIndirect".}

@@ -19798,37 +19798,37 @@ proc GetScrollInfo*(para1: HWND, para2: int32, para3: LPSCROLLINFO): WINBOOL{.
     stdcall, dynlib: "user32", importc: "GetScrollInfo".}

 proc TranslateMDISysAccel*(hWndClient: HWND, lpMsg: LPMSG): WINBOOL{.stdcall,

     dynlib: "user32", importc: "TranslateMDISysAccel".}

-proc ArrangeIconicWindows*(wnd: HWND): UINT{.stdcall, dynlib: "user32",

+proc ArrangeIconicWindows*(wnd: HWND): WINUINT{.stdcall, dynlib: "user32",

     importc: "ArrangeIconicWindows".}

-proc TileWindows*(hwndParent: HWND, wHow: UINT, lpRect: var RECT, cKids: UINT,

+proc TileWindows*(hwndParent: HWND, wHow: WINUINT, lpRect: var RECT, cKids: WINUINT,

                   lpKids: var HWND): int16{.stdcall, dynlib: "user32",

     importc: "TileWindows".}

-proc CascadeWindows*(hwndParent: HWND, wHow: UINT, lpRect: var RECT,

-                     cKids: UINT, lpKids: var HWND): int16{.stdcall,

+proc CascadeWindows*(hwndParent: HWND, wHow: WINUINT, lpRect: var RECT,

+                     cKids: WINUINT, lpKids: var HWND): int16{.stdcall,

     dynlib: "user32", importc: "CascadeWindows".}

 proc SetLastErrorEx*(dwErrCode: DWORD, dwType: DWORD){.stdcall,

     dynlib: "user32", importc: "SetLastErrorEx".}

 proc SetDebugErrorLevel*(dwLevel: DWORD){.stdcall, dynlib: "user32",

     importc: "SetDebugErrorLevel".}

-proc DrawEdge*(hdc: HDC, qrc: LPRECT, edge: UINT, grfFlags: UINT): WINBOOL{.

+proc DrawEdge*(hdc: HDC, qrc: LPRECT, edge: WINUINT, grfFlags: WINUINT): WINBOOL{.

     stdcall, dynlib: "user32", importc: "DrawEdge".}

-proc DrawFrameControl*(para1: HDC, para2: LPRECT, para3: UINT, para4: UINT): WINBOOL{.

+proc DrawFrameControl*(para1: HDC, para2: LPRECT, para3: WINUINT, para4: WINUINT): WINBOOL{.

     stdcall, dynlib: "user32", importc: "DrawFrameControl".}

-proc DrawCaption*(para1: HWND, para2: HDC, para3: var RECT, para4: UINT): WINBOOL{.

+proc DrawCaption*(para1: HWND, para2: HDC, para3: var RECT, para4: WINUINT): WINBOOL{.

     stdcall, dynlib: "user32", importc: "DrawCaption".}

 proc DrawAnimatedRects*(wnd: HWND, idAni: int32, lprcFrom: var RECT,

                         lprcTo: var RECT): WINBOOL{.stdcall, dynlib: "user32",

     importc: "DrawAnimatedRects".}

-proc TrackPopupMenuEx*(para1: HMENU, para2: UINT, para3: int32, para4: int32,

+proc TrackPopupMenuEx*(para1: HMENU, para2: WINUINT, para3: int32, para4: int32,

                        para5: HWND, para6: LPTPMPARAMS): WINBOOL{.stdcall,

     dynlib: "user32", importc: "TrackPopupMenuEx".}

-proc ChildWindowFromPointEx*(para1: HWND, para2: POINT, para3: UINT): HWND{.

+proc ChildWindowFromPointEx*(para1: HWND, para2: POINT, para3: WINUINT): HWND{.

     stdcall, dynlib: "user32", importc: "ChildWindowFromPointEx".}

 proc DrawIconEx*(hdc: HDC, xLeft: int32, yTop: int32, icon: HICON,

-                 cxWidth: int32, cyWidth: int32, istepIfAniCur: UINT,

-                 hbrFlickerFreeDraw: HBRUSH, diFlags: UINT): WINBOOL{.stdcall,

+                 cxWidth: int32, cyWidth: int32, istepIfAniCur: WINUINT,

+                 hbrFlickerFreeDraw: HBRUSH, diFlags: WINUINT): WINBOOL{.stdcall,

     dynlib: "user32", importc: "DrawIconEx".}

-proc AnimatePalette*(para1: HPALETTE, para2: UINT, para3: UINT,

+proc AnimatePalette*(para1: HPALETTE, para2: WINUINT, para3: WINUINT,

                      para4: var PALETTEENTRY): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "AnimatePalette".}

 proc Arc*(para1: HDC, para2: int32, para3: int32, para4: int32, para5: int32,

@@ -19846,7 +19846,7 @@ proc CloseMetaFile*(para1: HDC): HMETAFILE{.stdcall, dynlib: "gdi32",
     importc: "CloseMetaFile".}

 proc CombineRgn*(para1: HRGN, para2: HRGN, para3: HRGN, para4: int32): int32{.

     stdcall, dynlib: "gdi32", importc: "CombineRgn".}

-proc CreateBitmap*(para1: int32, para2: int32, para3: UINT, para4: UINT,

+proc CreateBitmap*(para1: int32, para2: int32, para3: WINUINT, para4: WINUINT,

                    para5: pointer): HBITMAP{.stdcall, dynlib: "gdi32",

     importc: "CreateBitmap".}

 proc CreateBitmapIndirect*(para1: var BITMAP): HBITMAP{.stdcall,

@@ -19860,11 +19860,11 @@ proc CreateDiscardableBitmap*(para1: HDC, para2: int32, para3: int32): HBITMAP{.
 proc CreateCompatibleDC*(para1: HDC): HDC{.stdcall, dynlib: "gdi32",

     importc: "CreateCompatibleDC".}

 proc CreateDIBitmap*(para1: HDC, para2: var BITMAPINFOHEADER, para3: DWORD,

-                     para4: pointer, para5: var BITMAPINFO, para6: UINT): HBITMAP{.

+                     para4: pointer, para5: var BITMAPINFO, para6: WINUINT): HBITMAP{.

     stdcall, dynlib: "gdi32", importc: "CreateDIBitmap".}

-proc CreateDIBPatternBrush*(para1: HGLOBAL, para2: UINT): HBRUSH{.stdcall,

+proc CreateDIBPatternBrush*(para1: HGLOBAL, para2: WINUINT): HBRUSH{.stdcall,

     dynlib: "gdi32", importc: "CreateDIBPatternBrush".}

-proc CreateDIBPatternBrushPt*(para1: pointer, para2: UINT): HBRUSH{.stdcall,

+proc CreateDIBPatternBrushPt*(para1: pointer, para2: WINUINT): HBRUSH{.stdcall,

     dynlib: "gdi32", importc: "CreateDIBPatternBrushPt".}

 proc CreateEllipticRgn*(para1: int32, para2: int32, para3: int32, para4: int32): HRGN{.

     stdcall, dynlib: "gdi32", importc: "CreateEllipticRgn".}

@@ -19918,7 +19918,7 @@ proc ExcludeClipRect*(para1: HDC, para2: int32, para3: int32, para4: int32,
 proc ExtCreateRegion*(para1: var XFORM, para2: DWORD, para3: var RGNDATA): HRGN{.

     stdcall, dynlib: "gdi32", importc: "ExtCreateRegion".}

 proc ExtFloodFill*(para1: HDC, para2: int32, para3: int32, para4: COLORREF,

-                   para5: UINT): WINBOOL{.stdcall, dynlib: "gdi32",

+                   para5: WINUINT): WINBOOL{.stdcall, dynlib: "gdi32",

     importc: "ExtFloodFill".}

 proc FillRgn*(para1: HDC, para2: HRGN, para3: HBRUSH): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "FillRgn".}

@@ -19938,7 +19938,7 @@ proc GetBitmapBits*(para1: HBITMAP, para2: LONG, para3: LPVOID): LONG{.stdcall,
     dynlib: "gdi32", importc: "GetBitmapBits".}

 proc GetBitmapDimensionEx*(para1: HBITMAP, para2: LPSIZE): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "GetBitmapDimensionEx".}

-proc GetBoundsRect*(para1: HDC, para2: LPRECT, para3: UINT): UINT{.stdcall,

+proc GetBoundsRect*(para1: HDC, para2: LPRECT, para3: WINUINT): WINUINT{.stdcall,

     dynlib: "gdi32", importc: "GetBoundsRect".}

 proc GetBrushOrgEx*(para1: HDC, para2: LPPOINT): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "GetBrushOrgEx".}

@@ -19948,14 +19948,14 @@ proc GetClipRgn*(para1: HDC, para2: HRGN): int32{.stdcall, dynlib: "gdi32",
     importc: "GetClipRgn".}

 proc GetMetaRgn*(para1: HDC, para2: HRGN): int32{.stdcall, dynlib: "gdi32",

     importc: "GetMetaRgn".}

-proc GetCurrentObject*(para1: HDC, para2: UINT): HGDIOBJ{.stdcall,

+proc GetCurrentObject*(para1: HDC, para2: WINUINT): HGDIOBJ{.stdcall,

     dynlib: "gdi32", importc: "GetCurrentObject".}

 proc GetCurrentPositionEx*(para1: HDC, para2: LPPOINT): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "GetCurrentPositionEx".}

 proc GetDeviceCaps*(para1: HDC, para2: int32): int32{.stdcall, dynlib: "gdi32",

     importc: "GetDeviceCaps".}

-proc GetDIBits*(para1: HDC, para2: HBITMAP, para3: UINT, para4: UINT,

-                para5: LPVOID, para6: LPBITMAPINFO, para7: UINT): int32{.

+proc GetDIBits*(para1: HDC, para2: HBITMAP, para3: WINUINT, para4: WINUINT,

+                para5: LPVOID, para6: LPBITMAPINFO, para7: WINUINT): int32{.

     stdcall, dynlib: "gdi32", importc: "GetDIBits".}

 proc GetFontData*(para1: HDC, para2: DWORD, para3: DWORD, para4: LPVOID,

                   para5: DWORD): DWORD{.stdcall, dynlib: "gdi32",

@@ -19964,16 +19964,16 @@ proc GetGraphicsMode*(para1: HDC): int32{.stdcall, dynlib: "gdi32",
     importc: "GetGraphicsMode".}

 proc GetMapMode*(para1: HDC): int32{.stdcall, dynlib: "gdi32",

                                      importc: "GetMapMode".}

-proc GetMetaFileBitsEx*(para1: HMETAFILE, para2: UINT, para3: LPVOID): UINT{.

+proc GetMetaFileBitsEx*(para1: HMETAFILE, para2: WINUINT, para3: LPVOID): WINUINT{.

     stdcall, dynlib: "gdi32", importc: "GetMetaFileBitsEx".}

 proc GetNearestColor*(para1: HDC, para2: COLORREF): COLORREF{.stdcall,

     dynlib: "gdi32", importc: "GetNearestColor".}

-proc GetNearestPaletteIndex*(para1: HPALETTE, para2: COLORREF): UINT{.stdcall,

+proc GetNearestPaletteIndex*(para1: HPALETTE, para2: COLORREF): WINUINT{.stdcall,

     dynlib: "gdi32", importc: "GetNearestPaletteIndex".}

 proc GetObjectType*(h: HGDIOBJ): DWORD{.stdcall, dynlib: "gdi32",

                                         importc: "GetObjectType".}

-proc GetPaletteEntries*(para1: HPALETTE, para2: UINT, para3: UINT,

-                        para4: LPPALETTEENTRY): UINT{.stdcall, dynlib: "gdi32",

+proc GetPaletteEntries*(para1: HPALETTE, para2: WINUINT, para3: WINUINT,

+                        para4: LPPALETTEENTRY): WINUINT{.stdcall, dynlib: "gdi32",

     importc: "GetPaletteEntries".}

 proc GetPixel*(para1: HDC, para2: int32, para3: int32): COLORREF{.stdcall,

     dynlib: "gdi32", importc: "GetPixel".}

@@ -19981,7 +19981,7 @@ proc GetPixelFormat*(para1: HDC): int32{.stdcall, dynlib: "gdi32",
     importc: "GetPixelFormat".}

 proc GetPolyFillMode*(para1: HDC): int32{.stdcall, dynlib: "gdi32",

     importc: "GetPolyFillMode".}

-proc GetRasterizerCaps*(para1: LPRASTERIZER_STATUS, para2: UINT): WINBOOL{.

+proc GetRasterizerCaps*(para1: LPRASTERIZER_STATUS, para2: WINUINT): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "GetRasterizerCaps".}

 proc GetRegionData*(para1: HRGN, para2: DWORD, para3: LPRGNDATA): DWORD{.

     stdcall, dynlib: "gdi32", importc: "GetRegionData".}

@@ -19991,14 +19991,14 @@ proc GetStockObject*(para1: int32): HGDIOBJ{.stdcall, dynlib: "gdi32",
     importc: "GetStockObject".}

 proc GetStretchBltMode*(para1: HDC): int32{.stdcall, dynlib: "gdi32",

     importc: "GetStretchBltMode".}

-proc GetSystemPaletteEntries*(para1: HDC, para2: UINT, para3: UINT,

-                              para4: LPPALETTEENTRY): UINT{.stdcall,

+proc GetSystemPaletteEntries*(para1: HDC, para2: WINUINT, para3: WINUINT,

+                              para4: LPPALETTEENTRY): WINUINT{.stdcall,

     dynlib: "gdi32", importc: "GetSystemPaletteEntries".}

-proc GetSystemPaletteUse*(para1: HDC): UINT{.stdcall, dynlib: "gdi32",

+proc GetSystemPaletteUse*(para1: HDC): WINUINT{.stdcall, dynlib: "gdi32",

     importc: "GetSystemPaletteUse".}

 proc GetTextCharacterExtra*(para1: HDC): int32{.stdcall, dynlib: "gdi32",

     importc: "GetTextCharacterExtra".}

-proc GetTextAlign*(para1: HDC): UINT{.stdcall, dynlib: "gdi32",

+proc GetTextAlign*(para1: HDC): WINUINT{.stdcall, dynlib: "gdi32",

                                       importc: "GetTextAlign".}

 proc GetTextColor*(para1: HDC): COLORREF{.stdcall, dynlib: "gdi32",

     importc: "GetTextColor".}

@@ -20064,12 +20064,12 @@ proc Rectangle*(para1: HDC, para2: int32, para3: int32, para4: int32,
                                         importc: "Rectangle".}

 proc RestoreDC*(para1: HDC, para2: int32): WINBOOL{.stdcall, dynlib: "gdi32",

     importc: "RestoreDC".}

-proc RealizePalette*(para1: HDC): UINT{.stdcall, dynlib: "gdi32",

+proc RealizePalette*(para1: HDC): WINUINT{.stdcall, dynlib: "gdi32",

                                         importc: "RealizePalette".}

 proc RoundRect*(para1: HDC, para2: int32, para3: int32, para4: int32,

                 para5: int32, para6: int32, para7: int32): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "RoundRect".}

-proc ResizePalette*(para1: HPALETTE, para2: UINT): WINBOOL{.stdcall,

+proc ResizePalette*(para1: HPALETTE, para2: WINUINT): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "ResizePalette".}

 proc SaveDC*(para1: HDC): int32{.stdcall, dynlib: "gdi32", importc: "SaveDC".}

 proc SelectClipRgn*(para1: HDC, para2: HRGN): int32{.stdcall, dynlib: "gdi32",

@@ -20088,15 +20088,15 @@ proc SetBkMode*(para1: HDC, para2: int32): int32{.stdcall, dynlib: "gdi32",
     importc: "SetBkMode".}

 proc SetBitmapBits*(para1: HBITMAP, para2: DWORD, para3: pointer): LONG{.

     stdcall, dynlib: "gdi32", importc: "SetBitmapBits".}

-proc SetBoundsRect*(para1: HDC, para2: var RECT, para3: UINT): UINT{.stdcall,

+proc SetBoundsRect*(para1: HDC, para2: var RECT, para3: WINUINT): WINUINT{.stdcall,

     dynlib: "gdi32", importc: "SetBoundsRect".}

-proc SetDIBits*(para1: HDC, para2: HBITMAP, para3: UINT, para4: UINT,

-                para5: pointer, para6: PBITMAPINFO, para7: UINT): int32{.

+proc SetDIBits*(para1: HDC, para2: HBITMAP, para3: WINUINT, para4: WINUINT,

+                para5: pointer, para6: PBITMAPINFO, para7: WINUINT): int32{.

     stdcall, dynlib: "gdi32", importc: "SetDIBits".}

 proc SetDIBitsToDevice*(para1: HDC, para2: int32, para3: int32, para4: DWORD,

-                        para5: DWORD, para6: int32, para7: int32, para8: UINT,

-                        para9: UINT, para10: pointer, para11: var BITMAPINFO,

-                        para12: UINT): int32{.stdcall, dynlib: "gdi32",

+                        para5: DWORD, para6: int32, para7: int32, para8: WINUINT,

+                        para9: WINUINT, para10: pointer, para11: var BITMAPINFO,

+                        para12: WINUINT): int32{.stdcall, dynlib: "gdi32",

     importc: "SetDIBitsToDevice".}

 proc SetMapperFlags*(para1: HDC, para2: DWORD): DWORD{.stdcall, dynlib: "gdi32",

     importc: "SetMapperFlags".}

@@ -20104,10 +20104,10 @@ proc SetGraphicsMode*(hdc: HDC, iMode: int32): int32{.stdcall, dynlib: "gdi32",
     importc: "SetGraphicsMode".}

 proc SetMapMode*(para1: HDC, para2: int32): int32{.stdcall, dynlib: "gdi32",

     importc: "SetMapMode".}

-proc SetMetaFileBitsEx*(para1: UINT, para2: var int8): HMETAFILE{.stdcall,

+proc SetMetaFileBitsEx*(para1: WINUINT, para2: var int8): HMETAFILE{.stdcall,

     dynlib: "gdi32", importc: "SetMetaFileBitsEx".}

-proc SetPaletteEntries*(para1: HPALETTE, para2: UINT, para3: UINT,

-                        para4: var PALETTEENTRY): UINT{.stdcall,

+proc SetPaletteEntries*(para1: HPALETTE, para2: WINUINT, para3: WINUINT,

+                        para4: var PALETTEENTRY): WINUINT{.stdcall,

     dynlib: "gdi32", importc: "SetPaletteEntries".}

 proc SetPixel*(para1: HDC, para2: int32, para3: int32, para4: COLORREF): COLORREF{.

     stdcall, dynlib: "gdi32", importc: "SetPixel".}

@@ -20125,26 +20125,26 @@ proc SetRectRgn*(para1: HRGN, para2: int32, para3: int32, para4: int32,
 proc StretchDIBits*(para1: HDC, para2: int32, para3: int32, para4: int32,

                     para5: int32, para6: int32, para7: int32, para8: int32,

                     para9: int32, para10: pointer, para11: var BITMAPINFO,

-                    para12: UINT, para13: DWORD): int32{.stdcall,

+                    para12: WINUINT, para13: DWORD): int32{.stdcall,

     dynlib: "gdi32", importc: "StretchDIBits".}

 proc SetROP2*(para1: HDC, para2: int32): int32{.stdcall, dynlib: "gdi32",

     importc: "SetROP2".}

 proc SetStretchBltMode*(para1: HDC, para2: int32): int32{.stdcall,

     dynlib: "gdi32", importc: "SetStretchBltMode".}

-proc SetSystemPaletteUse*(para1: HDC, para2: UINT): UINT{.stdcall,

+proc SetSystemPaletteUse*(para1: HDC, para2: WINUINT): WINUINT{.stdcall,

     dynlib: "gdi32", importc: "SetSystemPaletteUse".}

 proc SetTextCharacterExtra*(para1: HDC, para2: int32): int32{.stdcall,

     dynlib: "gdi32", importc: "SetTextCharacterExtra".}

 proc SetTextColor*(para1: HDC, para2: COLORREF): COLORREF{.stdcall,

     dynlib: "gdi32", importc: "SetTextColor".}

-proc SetTextAlign*(para1: HDC, para2: UINT): UINT{.stdcall, dynlib: "gdi32",

+proc SetTextAlign*(para1: HDC, para2: WINUINT): WINUINT{.stdcall, dynlib: "gdi32",

     importc: "SetTextAlign".}

 proc SetTextJustification*(para1: HDC, para2: int32, para3: int32): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "SetTextJustification".}

 proc UpdateColors*(para1: HDC): WINBOOL{.stdcall, dynlib: "gdi32",

     importc: "UpdateColors".}

 proc PlayMetaFileRecord*(para1: HDC, para2: LPHANDLETABLE, para3: LPMETARECORD,

-                         para4: UINT): WINBOOL{.stdcall, dynlib: "gdi32",

+                         para4: WINUINT): WINBOOL{.stdcall, dynlib: "gdi32",

     importc: "PlayMetaFileRecord".}

 proc EnumMetaFile*(para1: HDC, para2: HMETAFILE, para3: ENUMMETAFILEPROC,

                    para4: LPARAM): WINBOOL{.stdcall, dynlib: "gdi32",

@@ -20156,28 +20156,28 @@ proc DeleteEnhMetaFile*(para1: HENHMETAFILE): WINBOOL{.stdcall, dynlib: "gdi32",
 proc EnumEnhMetaFile*(para1: HDC, para2: HENHMETAFILE, para3: ENHMETAFILEPROC,

                       para4: LPVOID, para5: var RECT): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "EnumEnhMetaFile".}

-proc GetEnhMetaFileHeader*(para1: HENHMETAFILE, para2: UINT,

-                           para3: LPENHMETAHEADER): UINT{.stdcall,

+proc GetEnhMetaFileHeader*(para1: HENHMETAFILE, para2: WINUINT,

+                           para3: LPENHMETAHEADER): WINUINT{.stdcall,

     dynlib: "gdi32", importc: "GetEnhMetaFileHeader".}

-proc GetEnhMetaFilePaletteEntries*(para1: HENHMETAFILE, para2: UINT,

-                                   para3: LPPALETTEENTRY): UINT{.stdcall,

+proc GetEnhMetaFilePaletteEntries*(para1: HENHMETAFILE, para2: WINUINT,

+                                   para3: LPPALETTEENTRY): WINUINT{.stdcall,

     dynlib: "gdi32", importc: "GetEnhMetaFilePaletteEntries".}

-proc GetEnhMetaFileBits*(para1: HENHMETAFILE, para2: UINT, para3: LPBYTE): UINT{.

+proc GetEnhMetaFileBits*(para1: HENHMETAFILE, para2: WINUINT, para3: LPBYTE): WINUINT{.

     stdcall, dynlib: "gdi32", importc: "GetEnhMetaFileBits".}

-proc GetWinMetaFileBits*(para1: HENHMETAFILE, para2: UINT, para3: LPBYTE,

-                         para4: wINT, para5: HDC): UINT{.stdcall,

+proc GetWinMetaFileBits*(para1: HENHMETAFILE, para2: WINUINT, para3: LPBYTE,

+                         para4: wINT, para5: HDC): WINUINT{.stdcall,

     dynlib: "gdi32", importc: "GetWinMetaFileBits".}

 proc PlayEnhMetaFile*(para1: HDC, para2: HENHMETAFILE, para3: RECT): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "PlayEnhMetaFile".}

 proc PlayEnhMetaFileRecord*(para1: HDC, para2: LPHANDLETABLE,

-                            para3: var TENHMETARECORD, para4: UINT): WINBOOL{.

+                            para3: var TENHMETARECORD, para4: WINUINT): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "PlayEnhMetaFileRecord".}

-proc SetEnhMetaFileBits*(para1: UINT, para2: var int8): HENHMETAFILE{.stdcall,

+proc SetEnhMetaFileBits*(para1: WINUINT, para2: var int8): HENHMETAFILE{.stdcall,

     dynlib: "gdi32", importc: "SetEnhMetaFileBits".}

-proc SetWinMetaFileBits*(para1: UINT, para2: var int8, para3: HDC,

+proc SetWinMetaFileBits*(para1: WINUINT, para2: var int8, para3: HDC,

                          para4: var METAFILEPICT): HENHMETAFILE{.stdcall,

     dynlib: "gdi32", importc: "SetWinMetaFileBits".}

-proc GdiComment*(para1: HDC, para2: UINT, para3: var int8): WINBOOL{.stdcall,

+proc GdiComment*(para1: HDC, para2: WINUINT, para3: var int8): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "GdiComment".}

 proc AngleArc*(para1: HDC, para2: int32, para3: int32, para4: DWORD,

                para5: float32, para6: float32): WINBOOL{.stdcall,

@@ -20192,12 +20192,12 @@ proc ModifyWorldTransform*(para1: HDC, para2: var XFORM, para3: DWORD): WINBOOL{
     stdcall, dynlib: "gdi32", importc: "ModifyWorldTransform".}

 proc CombineTransform*(para1: LPXFORM, para2: var XFORM, para3: var XFORM): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "CombineTransform".}

-proc CreateDIBSection*(para1: HDC, para2: var BITMAPINFO, para3: UINT,

+proc CreateDIBSection*(para1: HDC, para2: var BITMAPINFO, para3: WINUINT,

                        para4: var pointer, para5: HANDLE, para6: DWORD): HBITMAP{.

     stdcall, dynlib: "gdi32", importc: "CreateDIBSection".}

-proc GetDIBColorTable*(para1: HDC, para2: UINT, para3: UINT, para4: var RGBQUAD): UINT{.

+proc GetDIBColorTable*(para1: HDC, para2: WINUINT, para3: WINUINT, para4: var RGBQUAD): WINUINT{.

     stdcall, dynlib: "gdi32", importc: "GetDIBColorTable".}

-proc SetDIBColorTable*(para1: HDC, para2: UINT, para3: UINT, para4: var RGBQUAD): UINT{.

+proc SetDIBColorTable*(para1: HDC, para2: WINUINT, para3: WINUINT, para4: var RGBQUAD): WINUINT{.

     stdcall, dynlib: "gdi32", importc: "SetDIBColorTable".}

 proc SetColorAdjustment*(para1: HDC, para2: var COLORADJUSTMENT): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "SetColorAdjustment".}

@@ -20324,7 +20324,7 @@ proc DestroyPropertySheetPage*(hPSPage: HPROPSHEETPAGE): WINBOOL{.stdcall,
 proc InitCommonControls*(){.stdcall, dynlib: "comctl32",

                             importc: "InitCommonControls".}

 proc ImageList_AddIcon*(himl: HIMAGELIST, hicon: HICON): int32

-proc ImageList_Create*(cx: int32, cy: int32, flags: UINT, cInitial: int32,

+proc ImageList_Create*(cx: int32, cy: int32, flags: WINUINT, cInitial: int32,

                        cGrow: int32): HIMAGELIST{.stdcall, dynlib: "comctl32",

     importc: "ImageList_Create".}

 proc ImageList_Destroy*(himl: HIMAGELIST): WINBOOL{.stdcall, dynlib: "comctl32",

@@ -20342,7 +20342,7 @@ proc ImageList_GetBkColor*(himl: HIMAGELIST): COLORREF{.stdcall,
 proc ImageList_SetOverlayImage*(himl: HIMAGELIST, iImage: int32, iOverlay: int32): WINBOOL{.

     stdcall, dynlib: "comctl32", importc: "ImageList_SetOverlayImage".}

 proc ImageList_Draw*(himl: HIMAGELIST, i: int32, hdcDst: HDC, x: int32,

-                     y: int32, fStyle: UINT): WINBOOL{.stdcall,

+                     y: int32, fStyle: WINUINT): WINBOOL{.stdcall,

     dynlib: "comctl32", importc: "ImageList_Draw".}

 proc ImageList_Replace*(himl: HIMAGELIST, i: int32, hbmImage: HBITMAP,

                         hbmMask: HBITMAP): WINBOOL{.stdcall, dynlib: "comctl32",

@@ -20351,11 +20351,11 @@ proc ImageList_AddMasked*(himl: HIMAGELIST, hbmImage: HBITMAP, crMask: COLORREF)
     stdcall, dynlib: "comctl32", importc: "ImageList_AddMasked".}

 proc ImageList_DrawEx*(himl: HIMAGELIST, i: int32, hdcDst: HDC, x: int32,

                        y: int32, dx: int32, dy: int32, rgbBk: COLORREF,

-                       rgbFg: COLORREF, fStyle: UINT): WINBOOL{.stdcall,

+                       rgbFg: COLORREF, fStyle: WINUINT): WINBOOL{.stdcall,

     dynlib: "comctl32", importc: "ImageList_DrawEx".}

 proc ImageList_Remove*(himl: HIMAGELIST, i: int32): WINBOOL{.stdcall,

     dynlib: "comctl32", importc: "ImageList_Remove".}

-proc ImageList_GetIcon*(himl: HIMAGELIST, i: int32, flags: UINT): HICON{.

+proc ImageList_GetIcon*(himl: HIMAGELIST, i: int32, flags: WINUINT): HICON{.

     stdcall, dynlib: "comctl32", importc: "ImageList_GetIcon".}

 proc ImageList_BeginDrag*(himlTrack: HIMAGELIST, iTrack: int32,

                           dxHotspot: int32, dyHotspot: int32): WINBOOL{.stdcall,

@@ -20385,20 +20385,20 @@ proc ImageList_GetImageInfo*(himl: HIMAGELIST, i: int32,
 proc ImageList_Merge*(himl1: HIMAGELIST, i1: int32, himl2: HIMAGELIST,

                       i2: int32, dx: int32, dy: int32): HIMAGELIST{.stdcall,

     dynlib: "comctl32", importc: "ImageList_Merge".}

-proc ImageList_SetImageCount*(himl: HIMAGELIST, uNewCount: UINT): int{.stdcall,

+proc ImageList_SetImageCount*(himl: HIMAGELIST, uNewCount: WINUINT): int{.stdcall,

     dynlib: "comctl32.dll", importc: "ImageList_SetImageCount".}

-proc CreateToolbarEx*(wnd: HWND, ws: DWORD, wID: UINT, nBitmaps: int32,

-                      hBMInst: HINST, wBMID: UINT, lpButtons: LPCTBBUTTON,

+proc CreateToolbarEx*(wnd: HWND, ws: DWORD, wID: WINUINT, nBitmaps: int32,

+                      hBMInst: HINST, wBMID: WINUINT, lpButtons: LPCTBBUTTON,

                       iNumButtons: int32, dxButton: int32, dyButton: int32,

-                      dxBitmap: int32, dyBitmap: int32, uStructSize: UINT): HWND{.

+                      dxBitmap: int32, dyBitmap: int32, uStructSize: WINUINT): HWND{.

     stdcall, dynlib: "comctl32", importc: "CreateToolbarEx".}

-proc CreateMappedBitmap*(hInstance: HINST, idBitmap: int32, wFlags: UINT,

+proc CreateMappedBitmap*(hInstance: HINST, idBitmap: int32, wFlags: WINUINT,

                          lpColorMap: LPCOLORMAP, iNumMaps: int32): HBITMAP{.

     stdcall, dynlib: "comctl32", importc: "CreateMappedBitmap".}

-proc MenuHelp*(uMsg: UINT, wp: WPARAM, lp: LPARAM, hMainMenu: HMENU,

-               hInst: HINST, hwndStatus: HWND, lpwIDs: var UINT){.stdcall,

+proc MenuHelp*(uMsg: WINUINT, wp: WPARAM, lp: LPARAM, hMainMenu: HMENU,

+               hInst: HINST, hwndStatus: HWND, lpwIDs: var WINUINT){.stdcall,

     dynlib: "comctl32", importc: "MenuHelp".}

-proc ShowHideMenuCtl*(wnd: HWND, uFlags: UINT, lpInfo: LPINT): WINBOOL{.

+proc ShowHideMenuCtl*(wnd: HWND, uFlags: WINUINT, lpInfo: LPINT): WINBOOL{.

     stdcall, dynlib: "comctl32", importc: "ShowHideMenuCtl".}

 proc GetEffectiveClientRect*(wnd: HWND, lprc: LPRECT, lpInfo: LPINT){.stdcall,

     dynlib: "comctl32", importc: "GetEffectiveClientRect".}

@@ -20428,21 +20428,21 @@ proc RegNotifyChangeKeyValue*(key: HKEY, bWatchSubtree: WINBOOL,
                               dwNotifyFilter: DWORD, hEvent: HANDLE,

                               fAsynchronus: WINBOOL): LONG{.stdcall,

     dynlib: "advapi32", importc: "RegNotifyChangeKeyValue".}

-proc IsValidCodePage*(CodePage: UINT): WINBOOL{.stdcall, dynlib: "kernel32",

+proc IsValidCodePage*(CodePage: WINUINT): WINBOOL{.stdcall, dynlib: "kernel32",

     importc: "IsValidCodePage".}

-proc GetACP*(): UINT{.stdcall, dynlib: "kernel32", importc: "GetACP".}

-proc GetOEMCP*(): UINT{.stdcall, dynlib: "kernel32", importc: "GetOEMCP".}

-proc GetCPInfo*(para1: UINT, para2: LPCPINFO): WINBOOL{.stdcall,

+proc GetACP*(): WINUINT{.stdcall, dynlib: "kernel32", importc: "GetACP".}

+proc GetOEMCP*(): WINUINT{.stdcall, dynlib: "kernel32", importc: "GetOEMCP".}

+proc GetCPInfo*(para1: WINUINT, para2: LPCPINFO): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "GetCPInfo".}

 proc IsDBCSLeadByte*(TestChar: int8): WINBOOL{.stdcall, dynlib: "kernel32",

     importc: "IsDBCSLeadByte".}

-proc IsDBCSLeadByteEx*(CodePage: UINT, TestChar: int8): WINBOOL{.stdcall,

+proc IsDBCSLeadByteEx*(CodePage: WINUINT, TestChar: int8): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "IsDBCSLeadByteEx".}

-proc MultiByteToWideChar*(CodePage: UINT, dwFlags: DWORD,

+proc MultiByteToWideChar*(CodePage: WINUINT, dwFlags: DWORD,

                           lpMultiByteStr: LPCSTR, cchMultiByte: int32,

                           lpWideCharStr: LPWSTR, cchWideChar: int32): int32{.

     stdcall, dynlib: "kernel32", importc: "MultiByteToWideChar".}

-proc WideCharToMultiByte*(CodePage: UINT, dwFlags: DWORD,

+proc WideCharToMultiByte*(CodePage: WINUINT, dwFlags: DWORD,

                           lpWideCharStr: LPCWSTR, cchWideChar: int32,

                           lpMultiByteStr: LPSTR, cchMultiByte: int32,

                           lpDefaultChar: LPCSTR, lpUsedDefaultChar: LPBOOL): int32{.

@@ -20520,12 +20520,12 @@ proc CreateConsoleScreenBuffer*(dwDesiredAccess: DWORD, dwShareMode: DWORD,
                                 lpSecurityAttributes: var SECURITY_ATTRIBUTES,

                                 dwFlags: DWORD, lpScreenBufferData: LPVOID): HANDLE{.

     stdcall, dynlib: "kernel32", importc: "CreateConsoleScreenBuffer".}

-proc GetConsoleCP*(): UINT{.stdcall, dynlib: "kernel32", importc: "GetConsoleCP".}

-proc SetConsoleCP*(wCodePageID: UINT): WINBOOL{.stdcall, dynlib: "kernel32",

+proc GetConsoleCP*(): WINUINT{.stdcall, dynlib: "kernel32", importc: "GetConsoleCP".}

+proc SetConsoleCP*(wCodePageID: WINUINT): WINBOOL{.stdcall, dynlib: "kernel32",

     importc: "SetConsoleCP".}

-proc GetConsoleOutputCP*(): UINT{.stdcall, dynlib: "kernel32",

+proc GetConsoleOutputCP*(): WINUINT{.stdcall, dynlib: "kernel32",

                                   importc: "GetConsoleOutputCP".}

-proc SetConsoleOutputCP*(wCodePageID: UINT): WINBOOL{.stdcall,

+proc SetConsoleOutputCP*(wCodePageID: WINUINT): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "SetConsoleOutputCP".}

 proc WNetConnectionDialog*(wnd: HWND, dwType: DWORD): DWORD{.stdcall,

     dynlib: "mpr", importc: "WNetConnectionDialog".}

@@ -20562,7 +20562,7 @@ proc UnlockServiceDatabase*(ScLock: SC_LOCK): WINBOOL{.stdcall,
     dynlib: "advapi32", importc: "UnlockServiceDatabase".}

 proc ChoosePixelFormat*(para1: HDC, para2: PPIXELFORMATDESCRIPTOR): int32{.

     stdcall, dynlib: "gdi32", importc: "ChoosePixelFormat".}

-proc DescribePixelFormat*(para1: HDC, para2: int32, para3: UINT,

+proc DescribePixelFormat*(para1: HDC, para2: int32, para3: WINUINT,

                           para4: LPPIXELFORMATDESCRIPTOR): int32{.stdcall,

     dynlib: "gdi32", importc: "DescribePixelFormat".}

 proc SetPixelFormat*(para1: HDC, para2: int32, para3: PPIXELFORMATDESCRIPTOR): WINBOOL{.

@@ -20584,7 +20584,7 @@ proc DdeAccessData*(para1: HDDEDATA, para2: PDWORD): PBYTE{.stdcall,
 proc DdeAddData*(para1: HDDEDATA, para2: PBYTE, para3: DWORD, para4: DWORD): HDDEDATA{.

     stdcall, dynlib: "user32", importc: "DdeAddData".}

 proc DdeClientTransaction*(para1: PBYTE, para2: DWORD, para3: HCONV, para4: HSZ,

-                           para5: UINT, para6: UINT, para7: DWORD, para8: PDWORD): HDDEDATA{.

+                           para5: WINUINT, para6: WINUINT, para7: DWORD, para8: PDWORD): HDDEDATA{.

     stdcall, dynlib: "user32", importc: "DdeClientTransaction".}

 proc DdeCmpStringHandles*(para1: HSZ, para2: HSZ): int32{.stdcall,

     dynlib: "user32", importc: "DdeCmpStringHandles".}

@@ -20594,13 +20594,13 @@ proc DdeConnectList*(para1: DWORD, para2: HSZ, para3: HSZ, para4: HCONVLIST,
                      para5: PCONVCONTEXT): HCONVLIST{.stdcall, dynlib: "user32",

     importc: "DdeConnectList".}

 proc DdeCreateDataHandle*(para1: DWORD, para2: LPBYTE, para3: DWORD,

-                          para4: DWORD, para5: HSZ, para6: UINT, para7: UINT): HDDEDATA{.

+                          para4: DWORD, para5: HSZ, para6: WINUINT, para7: WINUINT): HDDEDATA{.

     stdcall, dynlib: "user32", importc: "DdeCreateDataHandle".}

 proc DdeDisconnect*(para1: HCONV): WINBOOL{.stdcall, dynlib: "user32",

     importc: "DdeDisconnect".}

 proc DdeDisconnectList*(para1: HCONVLIST): WINBOOL{.stdcall, dynlib: "user32",

     importc: "DdeDisconnectList".}

-proc DdeEnableCallback*(para1: DWORD, para2: HCONV, para3: UINT): WINBOOL{.

+proc DdeEnableCallback*(para1: DWORD, para2: HCONV, para3: WINUINT): WINBOOL{.

     stdcall, dynlib: "user32", importc: "DdeEnableCallback".}

 proc DdeFreeDataHandle*(para1: HDDEDATA): WINBOOL{.stdcall, dynlib: "user32",

     importc: "DdeFreeDataHandle".}

@@ -20608,17 +20608,17 @@ proc DdeFreeStringHandle*(para1: DWORD, para2: HSZ): WINBOOL{.stdcall,
     dynlib: "user32", importc: "DdeFreeStringHandle".}

 proc DdeGetData*(para1: HDDEDATA, para2: LPBYTE, para3: DWORD, para4: DWORD): DWORD{.

     stdcall, dynlib: "user32", importc: "DdeGetData".}

-proc DdeGetLastError*(para1: DWORD): UINT{.stdcall, dynlib: "user32",

+proc DdeGetLastError*(para1: DWORD): WINUINT{.stdcall, dynlib: "user32",

     importc: "DdeGetLastError".}

 proc DdeImpersonateClient*(para1: HCONV): WINBOOL{.stdcall, dynlib: "user32",

     importc: "DdeImpersonateClient".}

 proc DdeKeepStringHandle*(para1: DWORD, para2: HSZ): WINBOOL{.stdcall,

     dynlib: "user32", importc: "DdeKeepStringHandle".}

-proc DdeNameService*(para1: DWORD, para2: HSZ, para3: HSZ, para4: UINT): HDDEDATA{.

+proc DdeNameService*(para1: DWORD, para2: HSZ, para3: HSZ, para4: WINUINT): HDDEDATA{.

     stdcall, dynlib: "user32", importc: "DdeNameService".}

 proc DdePostAdvise*(para1: DWORD, para2: HSZ, para3: HSZ): WINBOOL{.stdcall,

     dynlib: "user32", importc: "DdePostAdvise".}

-proc DdeQueryConvInfo*(para1: HCONV, para2: DWORD, para3: PCONVINFO): UINT{.

+proc DdeQueryConvInfo*(para1: HCONV, para2: DWORD, para3: PCONVINFO): WINUINT{.

     stdcall, dynlib: "user32", importc: "DdeQueryConvInfo".}

 proc DdeQueryNextServer*(para1: HCONVLIST, para2: HCONV): HCONV{.stdcall,

     dynlib: "user32", importc: "DdeQueryNextServer".}

@@ -20630,18 +20630,18 @@ proc DdeUnaccessData*(para1: HDDEDATA): WINBOOL{.stdcall, dynlib: "user32",
     importc: "DdeUnaccessData".}

 proc DdeUninitialize*(para1: DWORD): WINBOOL{.stdcall, dynlib: "user32",

     importc: "DdeUninitialize".}

-proc SHAddToRecentDocs*(para1: UINT, para2: LPCVOID){.stdcall,

+proc SHAddToRecentDocs*(para1: WINUINT, para2: LPCVOID){.stdcall,

     dynlib: "shell32", importc: "SHAddToRecentDocs".}

 proc SHBrowseForFolder*(para1: LPBROWSEINFO): LPITEMIDLIST{.stdcall,

     dynlib: "shell32", importc: "SHBrowseForFolder".}

-proc SHChangeNotify*(para1: LONG, para2: UINT, para3: LPCVOID, para4: LPCVOID){.

+proc SHChangeNotify*(para1: LONG, para2: WINUINT, para3: LPCVOID, para4: LPCVOID){.

     stdcall, dynlib: "shell32", importc: "SHChangeNotify".}

 proc SHFileOperation*(para1: LPSHFILEOPSTRUCT): int32{.stdcall,

     dynlib: "shell32", importc: "SHFileOperation".}

 proc SHFreeNameMappings*(para1: HANDLE){.stdcall, dynlib: "shell32",

     importc: "SHFreeNameMappings".}

 proc SHGetFileInfo*(para1: LPCTSTR, para2: DWORD, para3: var SHFILEINFO,

-                    para4: UINT, para5: UINT): DWORD{.stdcall,

+                    para4: WINUINT, para5: WINUINT): DWORD{.stdcall,

     dynlib: "shell32", importc: "SHGetFileInfo".}

 proc SHGetPathFromIDList*(para1: LPCITEMIDLIST, para2: LPTSTR): WINBOOL{.

     stdcall, dynlib: "shell32", importc: "SHGetPathFromIDList".}

@@ -20657,7 +20657,7 @@ proc wglCreateContext*(para1: HDC): HGLRC{.stdcall, dynlib: "opengl32",
     importc: "wglCreateContext".}

 proc wglCreateLayerContext*(para1: HDC, para2: int32): HGLRC{.stdcall,

     dynlib: "opengl32", importc: "wglCreateLayerContext".}

-proc wglCopyContext*(para1: HGLRC, para2: HGLRC, para3: UINT): WINBOOL{.stdcall,

+proc wglCopyContext*(para1: HGLRC, para2: HGLRC, para3: WINUINT): WINBOOL{.stdcall,

     dynlib: "opengl32", importc: "wglCopyContext".}

 proc wglDeleteContext*(para1: HGLRC): WINBOOL{.stdcall, dynlib: "opengl32",

     importc: "wglDeleteContext".}

@@ -20681,7 +20681,7 @@ proc wglUseFontOutlinesA*(para1: HDC, para2: DWORD, para3: DWORD, para4: DWORD,
                           para5: float32, para6: float32, para7: int32,

                           para8: LPGLYPHMETRICSFLOAT): WINBOOL{.stdcall,

     dynlib: "opengl32", importc: "wglUseFontOutlinesA".}

-proc wglDescribeLayerPlane*(para1: HDC, para2: int32, para3: int32, para4: UINT,

+proc wglDescribeLayerPlane*(para1: HDC, para2: int32, para3: int32, para4: WINUINT,

                             para5: LPLAYERPLANEDESCRIPTOR): WINBOOL{.stdcall,

     dynlib: "opengl32", importc: "wglDescribeLayerPlane".}

 proc wglGetLayerPaletteEntries*(para1: HDC, para2: int32, para3: int32,

@@ -20694,7 +20694,7 @@ proc wglRealizeLayerPalette*(para1: HDC, para2: int32, para3: WINBOOL): WINBOOL{
 proc wglSetLayerPaletteEntries*(para1: HDC, para2: int32, para3: int32,

                                 para4: int32, para5: var COLORREF): int32{.

     stdcall, dynlib: "opengl32", importc: "wglSetLayerPaletteEntries".}

-proc wglSwapLayerBuffers*(para1: HDC, para2: UINT): WINBOOL{.stdcall,

+proc wglSwapLayerBuffers*(para1: HDC, para2: WINUINT): WINBOOL{.stdcall,

     dynlib: "opengl32", importc: "wglSwapLayerBuffers".}

 proc wglUseFontOutlinesW*(para1: HDC, para2: DWORD, para3: DWORD, para4: DWORD,

                           para5: float32, para6: float32, para7: int32,

@@ -20703,7 +20703,7 @@ proc wglUseFontOutlinesW*(para1: HDC, para2: DWORD, para3: DWORD, para4: DWORD,
   # translated macros

 proc Animate_Create*(hWndP: HWND, id: HMENU, dwStyle: DWORD, hInstance: HINST): HWND

 proc Animate_Open*(wnd: HWND, szName: LPTSTR): LRESULT

-proc Animate_Play*(wnd: HWND, `from`, `to`: int32, rep: UINT): LRESULT

+proc Animate_Play*(wnd: HWND, `from`, `to`: int32, rep: WINUINT): LRESULT

 

 proc Animate_Stop*(wnd: HWND): LRESULT

 proc Animate_Close*(wnd: HWND): LRESULT

@@ -20734,7 +20734,7 @@ proc Header_GetItemCount*(hwndHD: HWND): int32
 proc Header_InsertItem*(hwndHD: HWND, index: int32, hdi: var HD_ITEM): int32

 proc Header_Layout*(hwndHD: HWND, layout: var HD_LAYOUT): WINBOOL

 proc Header_SetItem*(hwndHD: HWND, index: int32, hdi: var HD_ITEM): WINBOOL

-proc ListView_Arrange*(hwndLV: HWND, code: UINT): LRESULT

+proc ListView_Arrange*(hwndLV: HWND, code: WINUINT): LRESULT

 proc ListView_CreateDragImage*(wnd: HWND, i: int32, lpptUpLeft: LPPOINT): LRESULT

 proc ListView_DeleteAllItems*(wnd: HWND): LRESULT

 proc ListView_DeleteColumn*(wnd: HWND, iCol: int32): LRESULT

@@ -20769,7 +20769,7 @@ proc ListView_InsertItem*(wnd: HWND, item: var LV_ITEM): LRESULT
 proc ListView_RedrawItems*(hwndLV: HWND, iFirst, iLast: int32): LRESULT

 proc ListView_Scroll*(hwndLV: HWND, dx, dy: int32): LRESULT

 proc ListView_SetBkColor*(wnd: HWND, clrBk: COLORREF): LRESULT

-proc ListView_SetCallbackMask*(wnd: HWND, mask: UINT): LRESULT

+proc ListView_SetCallbackMask*(wnd: HWND, mask: WINUINT): LRESULT

 proc ListView_SetColumn*(wnd: HWND, iCol: int32, col: var LV_COLUMN): LRESULT

 proc ListView_SetColumnWidth*(wnd: HWND, iCol, cx: int32): LRESULT

 proc ListView_SetImageList*(wnd: HWND, himl: int32, iImageList: HIMAGELIST): LRESULT

@@ -20842,7 +20842,7 @@ proc TabCtrl_GetToolTips*(wnd: HWND): LRESULT
 proc TabCtrl_SetToolTips*(wnd: HWND, hwndTT: int32): LRESULT

 proc TabCtrl_GetCurFocus*(wnd: HWND): LRESULT

 proc TabCtrl_SetCurFocus*(wnd: HWND, i: int32): LRESULT

-proc SNDMSG*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): LRESULT

+proc SNDMSG*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): LRESULT

 proc CommDlg_OpenSave_GetSpecA*(hdlg: HWND, psz: LPSTR, cbmax: int32): LRESULT

 proc CommDlg_OpenSave_GetSpecW*(hdlg: HWND, psz: LPWSTR, cbmax: int32): LRESULT

 when defined(winUnicode):

@@ -20865,7 +20865,7 @@ proc CommDlg_OpenSave_GetFolderIDList*(hdlg: HWND, pidl: LPVOID, cbmax: int32):
 proc CommDlg_OpenSave_SetControlText*(hdlg: HWND, id: int32, text: LPSTR): LRESULT

 proc CommDlg_OpenSave_HideControl*(hdlg: HWND, id: int32): LRESULT

 proc CommDlg_OpenSave_SetDefExt*(hdlg: HWND, pszext: LPSTR): LRESULT

-proc GetNextWindow*(wnd: HWND, uCmd: UINT): HWND{.stdcall, dynlib: "user32",

+proc GetNextWindow*(wnd: HWND, uCmd: WINUINT): HWND{.stdcall, dynlib: "user32",

     importc: "GetWindow".}

 proc GlobalAllocPtr*(flags, cb: DWord): Pointer

 proc GlobalFreePtr*(lp: Pointer): Pointer

@@ -21183,9 +21183,9 @@ proc CreateDialogIndirectParam*(hInstance: HINST, lpTemplate: TDlgTemplate,
     dynlib: "user32", importc: "CreateDialogIndirectParamA".}

   #function CreateDialogIndirectParamA(hInstance: HINST; const lpTemplate: TDlgTemplate; hWndParent: HWND; lpDialogFunc: TFNDlgProc; dwInitParam: LPARAM): HWND; stdcall; external 'user32' name 'CreateDialogIndirectParamA';

   #function CreateDialogIndirectParamW(hInstance: HINST; const lpTemplate: TDlgTemplate; hWndParent: HWND; lpDialogFunc: TFNDlgProc; dwInitParam: LPARAM): HWND; stdcall; external 'user32' name 'CreateDialogIndirectParamW';

-  #function CreateDIBitmap(DC: HDC; var InfoHeader: TBitmapInfoHeader; dwUsage: DWORD; InitBits: PChar; var InitInfo: TBitmapInfo; wUsage: UINT): HBITMAP; stdcall; external 'gdi32' name 'CreateDIBitmap';

-  #function CreateDIBPatternBrushPt(const p1: Pointer; p2: UINT): HBRUSH; stdcall; external 'gdi32' name 'CreateDIBPatternBrushPt';

-  #function CreateDIBSection(DC: HDC; const p2: TBitmapInfo; p3: UINT; var p4: Pointer; p5: THandle; p6: DWORD): HBITMAP; stdcall; external 'gdi32' name 'CreateDIBSection';

+  #function CreateDIBitmap(DC: HDC; var InfoHeader: TBitmapInfoHeader; dwUsage: DWORD; InitBits: PChar; var InitInfo: TBitmapInfo; wUsage: WINUINT): HBITMAP; stdcall; external 'gdi32' name 'CreateDIBitmap';

+  #function CreateDIBPatternBrushPt(const p1: Pointer; p2: WINUINT): HBRUSH; stdcall; external 'gdi32' name 'CreateDIBPatternBrushPt';

+  #function CreateDIBSection(DC: HDC; const p2: TBitmapInfo; p3: WINUINT; var p4: Pointer; p5: THandle; p6: DWORD): HBITMAP; stdcall; external 'gdi32' name 'CreateDIBSection';

   #function CreateEllipticRgnIndirect(const p1: TRect): HRGN; stdcall; external 'gdi32' name 'CreateEllipticRgnIndirect';

   #function CreateFontIndirect(const p1: TLogFont): HFONT;stdcall; external 'gdi32' name 'CreateFontIndirectA';

   #function CreateFontIndirectA(const p1: TLogFontA): HFONT; stdcall; external 'gdi32' name 'CreateFontIndirectA';

@@ -21251,7 +21251,7 @@ proc DdeSetQualityOfService*(hWndClient: HWnd,
                              pqosPrev: PSecurityQualityOfService): WINBOOL{.

     stdcall, dynlib: "user32", importc: "DdeSetQualityOfService".}

   #function DeleteAce(var pAcl: TACL; dwAceIndex: DWORD): WINBOOL; stdcall; external 'advapi32' name 'DeleteAce';

-proc DescribePixelFormat*(DC: HDC, p2: int, p3: UINT,

+proc DescribePixelFormat*(DC: HDC, p2: int, p3: WINUINT,

                           p4: var TPixelFormatDescriptor): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "DescribePixelFormat".}

   #function DestroyPrivateObjectSecurity(var ObjectDescriptor: PSecurityDescriptor): WINBOOL; stdcall; external 'advapi32' name 'DestroyPrivateObjectSecurity';

@@ -21283,29 +21283,29 @@ proc DosDateTimeToFileTime*(wFatDate, wFatTime: int16, lpFileTime: var TFileTime
 proc DPtoLP*(DC: HDC, Points: pointer, Count: int): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "DPtoLP".}

   # function DrawAnimatedRects(wnd: HWND; idAni: Integer; const lprcFrom, lprcTo: TRect): WINBOOL; stdcall; external 'user32' name 'DrawAnimatedRects';

-  #function DrawCaption(p1: HWND; p2: HDC; const p3: TRect; p4: UINT): WINBOOL; stdcall; external 'user32' name 'DrawCaption';

-proc DrawEdge*(hdc: HDC, qrc: var TRect, edge: UINT, grfFlags: UINT): WINBOOL{.

+  #function DrawCaption(p1: HWND; p2: HDC; const p3: TRect; p4: WINUINT): WINBOOL; stdcall; external 'user32' name 'DrawCaption';

+proc DrawEdge*(hdc: HDC, qrc: var TRect, edge: WINUINT, grfFlags: WINUINT): WINBOOL{.

     stdcall, dynlib: "user32", importc: "DrawEdge".}

   #function DrawFocusRect(hDC: HDC; const lprc: TRect): WINBOOL; stdcall; external 'user32' name 'DrawFocusRect';

-proc DrawFrameControl*(DC: HDC, Rect: TRect, uType, uState: UINT): WINBOOL{.

+proc DrawFrameControl*(DC: HDC, Rect: TRect, uType, uState: WINUINT): WINBOOL{.

     stdcall, dynlib: "user32", importc: "DrawFrameControl".}

 proc DrawText*(hDC: HDC, lpString: cstring, nCount: int, lpRect: var TRect,

-               uFormat: UINT): int{.stdcall, dynlib: "user32",

+               uFormat: WINUINT): int{.stdcall, dynlib: "user32",

                                     importc: "DrawTextA".}

 proc DrawTextA*(hDC: HDC, lpString: LPCSTR, nCount: int, lpRect: var TRect,

-                uFormat: UINT): int{.stdcall, dynlib: "user32",

+                uFormat: WINUINT): int{.stdcall, dynlib: "user32",

                                      importc: "DrawTextA".}

 proc DrawTextEx*(DC: HDC, lpchText: cstring, cchText: int, p4: var TRect,

-                 dwDTFormat: UINT, DTParams: PDrawTextParams): int{.stdcall,

+                 dwDTFormat: WINUINT, DTParams: PDrawTextParams): int{.stdcall,

     dynlib: "user32", importc: "DrawTextExA".}

 proc DrawTextExA*(DC: HDC, lpchText: LPCSTR, cchText: int, p4: var TRect,

-                  dwDTFormat: UINT, DTParams: PDrawTextParams): int{.stdcall,

+                  dwDTFormat: WINUINT, DTParams: PDrawTextParams): int{.stdcall,

     dynlib: "user32", importc: "DrawTextExA".}

 proc DrawTextExW*(DC: HDC, lpchText: LPWSTR, cchText: int, p4: var TRect,

-                  dwDTFormat: UINT, DTParams: PDrawTextParams): int{.stdcall,

+                  dwDTFormat: WINUINT, DTParams: PDrawTextParams): int{.stdcall,

     dynlib: "user32", importc: "DrawTextExW".}

 proc DrawTextW*(hDC: HDC, lpString: LPWSTR, nCount: int, lpRect: var TRect,

-                uFormat: UINT): int{.stdcall, dynlib: "user32",

+                uFormat: WINUINT): int{.stdcall, dynlib: "user32",

                                      importc: "DrawTextW".}

   #function DuplicateTokenEx(hExistingToken: THandle; dwDesiredAccess: DWORD; lpTokenAttributes: PSecurityAttributes; ImpersonationLevel: TSecurityImpersonationLevel; TokenType: TTokenType; var phNewToken: THandle): WINBOOL;

   #  stdcall; external 'advapi32' name 'DuplicateTokenEx';

@@ -21377,9 +21377,9 @@ proc FindNextFileW*(hFindFile: THandle, lpFindFileData: var TWIN32FindDataW): WI
   #function FrameRect(hDC: HDC; const lprc: TRect; hbr: HBRUSH): Integer; stdcall; external 'user32' name 'FrameRect';

   #function GetAce(const pAcl: TACL; dwAceIndex: DWORD; var pAce: Pointer): WINBOOL; stdcall; external 'advapi32' name 'GetAce';

   #function GetAclInformation(const pAcl: TACL; pAclInformation: Pointer; nAclInformationLength: DWORD; dwAclInformationClass: TAclInformationClass): WINBOOL; stdcall; external 'advapi32' name 'GetAclInformation';

-  #function GetAltTabInfo(wnd: HWND; iItem: Integer; var pati: TAltTabInfo; pszItemText: PChar; cchItemText: UINT): WINBOOL;stdcall; external 'user32' name 'GetAltTabInfoA';

-  #function GetAltTabInfoA(wnd: HWND; iItem: Integer; var pati: TAltTabInfo; pszItemText: LPCSTR; cchItemText: UINT): WINBOOL;stdcall; external 'user32' name 'GetAltTabInfoA';

-  #function GetAltTabInfoW(wnd: HWND; iItem: Integer; var pati: TAltTabInfo; pszItemText: LPWSTR; cchItemText: UINT): WINBOOL;stdcall; external 'user32' name 'GetAltTabInfoW';

+  #function GetAltTabInfo(wnd: HWND; iItem: Integer; var pati: TAltTabInfo; pszItemText: PChar; cchItemText: WINUINT): WINBOOL;stdcall; external 'user32' name 'GetAltTabInfoA';

+  #function GetAltTabInfoA(wnd: HWND; iItem: Integer; var pati: TAltTabInfo; pszItemText: LPCSTR; cchItemText: WINUINT): WINBOOL;stdcall; external 'user32' name 'GetAltTabInfoA';

+  #function GetAltTabInfoW(wnd: HWND; iItem: Integer; var pati: TAltTabInfo; pszItemText: LPWSTR; cchItemText: WINUINT): WINBOOL;stdcall; external 'user32' name 'GetAltTabInfoW';

 proc GetAspectRatioFilterEx*(DC: HDC, p2: var TSize): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "GetAspectRatioFilterEx".}

 proc GetBinaryType*(lpApplicationName: cstring, lpBinaryType: var DWORD): WINBOOL{.

@@ -21390,24 +21390,24 @@ proc GetBinaryTypeW*(lpApplicationName: LPWSTR, lpBinaryType: var DWORD): WINBOO
     stdcall, dynlib: "kernel32", importc: "GetBinaryTypeW".}

 proc GetBitmapDimensionEx*(p1: HBITMAP, p2: var TSize): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "GetBitmapDimensionEx".}

-proc GetBoundsRect*(DC: HDC, p2: var TRect, p3: UINT): UINT{.stdcall,

+proc GetBoundsRect*(DC: HDC, p2: var TRect, p3: WINUINT): WINUINT{.stdcall,

     dynlib: "gdi32", importc: "GetBoundsRect".}

 proc GetBrushOrgEx*(DC: HDC, p2: var TPoint): WINBOOL{.stdcall, dynlib: "gdi32",

     importc: "GetBrushOrgEx".}

 proc GetCaretPos*(lpPoint: var TPoint): WINBOOL{.stdcall, dynlib: "user32",

     importc: "GetCaretPos".}

-proc GetCharABCWidths*(DC: HDC, p2, p3: UINT, ABCStructs: pointer): WINBOOL{.

+proc GetCharABCWidths*(DC: HDC, p2, p3: WINUINT, ABCStructs: pointer): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "GetCharABCWidthsA".}

-proc GetCharABCWidthsA*(DC: HDC, p2, p3: UINT, ABCStructs: pointer): WINBOOL{.

+proc GetCharABCWidthsA*(DC: HDC, p2, p3: WINUINT, ABCStructs: pointer): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "GetCharABCWidthsA".}

-proc GetCharABCWidthsFloat*(DC: HDC, p2, p3: UINT, ABCFloatSturcts: pointer): WINBOOL{.

+proc GetCharABCWidthsFloat*(DC: HDC, p2, p3: WINUINT, ABCFloatSturcts: pointer): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "GetCharABCWidthsFloatA".}

-proc GetCharABCWidthsFloatA*(DC: HDC, p2, p3: UINT, ABCFloatSturcts: pointer): WINBOOL{.

+proc GetCharABCWidthsFloatA*(DC: HDC, p2, p3: WINUINT, ABCFloatSturcts: pointer): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "GetCharABCWidthsFloatA".}

-proc GetCharABCWidthsFloatW*(DC: HDC, p2, p3: UINT, ABCFloatSturcts: pointer): WINBOOL{.

+proc GetCharABCWidthsFloatW*(DC: HDC, p2, p3: WINUINT, ABCFloatSturcts: pointer): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "GetCharABCWidthsFloatW".}

-  #function GetCharABCWidthsI(DC: HDC; p2, p3: UINT; p4: PWORD; const Widths): WINBOOL;stdcall; external 'gdi32' name 'GetCharABCWidthsI';

-proc GetCharABCWidthsW*(DC: HDC, p2, p3: UINT, ABCStructs: pointer): WINBOOL{.

+  #function GetCharABCWidthsI(DC: HDC; p2, p3: WINUINT; p4: PWORD; const Widths): WINBOOL;stdcall; external 'gdi32' name 'GetCharABCWidthsI';

+proc GetCharABCWidthsW*(DC: HDC, p2, p3: WINUINT, ABCStructs: pointer): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "GetCharABCWidthsW".}

 proc GetCharacterPlacement*(DC: HDC, p2: cstring, p3, p4: WINBOOL,

                             p5: var TGCPResults, p6: DWORD): DWORD{.stdcall,

@@ -21418,24 +21418,24 @@ proc GetCharacterPlacementA*(DC: HDC, p2: LPCSTR, p3, p4: WINBOOL,
 proc GetCharacterPlacementW*(DC: HDC, p2: LPWSTR, p3, p4: WINBOOL,

                              p5: var TGCPResults, p6: DWORD): DWORD{.stdcall,

     dynlib: "gdi32", importc: "GetCharacterPlacementW".}

-proc GetCharWidth*(DC: HDC, p2, p3: UINT, Widths: pointer): WINBOOL{.stdcall,

+proc GetCharWidth*(DC: HDC, p2, p3: WINUINT, Widths: pointer): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "GetCharWidthA".}

-proc GetCharWidth32*(DC: HDC, p2, p3: UINT, Widths: pointer): WINBOOL{.stdcall,

+proc GetCharWidth32*(DC: HDC, p2, p3: WINUINT, Widths: pointer): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "GetCharWidth32A".}

-proc GetCharWidth32A*(DC: HDC, p2, p3: UINT, Widths: pointer): WINBOOL{.stdcall,

+proc GetCharWidth32A*(DC: HDC, p2, p3: WINUINT, Widths: pointer): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "GetCharWidth32A".}

-proc GetCharWidth32W*(DC: HDC, p2, p3: UINT, Widths: pointer): WINBOOL{.stdcall,

+proc GetCharWidth32W*(DC: HDC, p2, p3: WINUINT, Widths: pointer): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "GetCharWidth32W".}

-proc GetCharWidthA*(DC: HDC, p2, p3: UINT, Widths: pointer): WINBOOL{.stdcall,

+proc GetCharWidthA*(DC: HDC, p2, p3: WINUINT, Widths: pointer): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "GetCharWidthA".}

-proc GetCharWidthFloat*(DC: HDC, p2, p3: UINT, Widths: pointer): WINBOOL{.

+proc GetCharWidthFloat*(DC: HDC, p2, p3: WINUINT, Widths: pointer): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "GetCharWidthFloatA".}

-proc GetCharWidthFloatA*(DC: HDC, p2, p3: UINT, Widths: pointer): WINBOOL{.

+proc GetCharWidthFloatA*(DC: HDC, p2, p3: WINUINT, Widths: pointer): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "GetCharWidthFloatA".}

-proc GetCharWidthFloatW*(DC: HDC, p2, p3: UINT, Widths: pointer): WINBOOL{.

+proc GetCharWidthFloatW*(DC: HDC, p2, p3: WINUINT, Widths: pointer): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "GetCharWidthFloatW".}

-  #function GetCharWidthI(DC: HDC; p2, p3: UINT; p4: PWORD; const Widths:pointer): WINBOOL;stdcall; external 'gdi32' name 'GetCharWidthI';

-proc GetCharWidthW*(DC: HDC, p2, p3: UINT, Widths: pointer): WINBOOL{.stdcall,

+  #function GetCharWidthI(DC: HDC; p2, p3: WINUINT; p4: PWORD; const Widths:pointer): WINBOOL;stdcall; external 'gdi32' name 'GetCharWidthI';

+proc GetCharWidthW*(DC: HDC, p2, p3: WINUINT, Widths: pointer): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "GetCharWidthW".}

 proc GetClassInfo*(hInstance: HINST, lpClassName: cstring,

                    lpWndClass: var TWndClass): WINBOOL{.stdcall,

@@ -21484,7 +21484,7 @@ proc GetConsoleMode*(hConsoleHandle: THandle, lpMode: var DWORD): WINBOOL{.
 proc GetConsoleScreenBufferInfo*(hConsoleOutput: THandle,

     lpConsoleScreenBufferInfo: var TConsoleScreenBufferInfo): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "GetConsoleScreenBufferInfo".}

-proc GetCPInfo*(CodePage: UINT, lpCPInfo: var TCPInfo): WINBOOL{.stdcall,

+proc GetCPInfo*(CodePage: WINUINT, lpCPInfo: var TCPInfo): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "GetCPInfo".}

   #function GetCurrentHwProfile(var lpHwProfileInfo: THWProfileInfo): WINBOOL;stdcall; external 'advapi32' name 'GetCurrentHwProfileA';

   #function GetCurrentHwProfileA(var lpHwProfileInfo: THWProfileInfoA): WINBOOL;stdcall; external 'advapi32' name 'GetCurrentHwProfileA';

@@ -21504,10 +21504,10 @@ proc GetDefaultCommConfigA*(lpszName: LPCSTR, lpCC: var TCommConfig,
 proc GetDefaultCommConfigW*(lpszName: LPWSTR, lpCC: var TCommConfig,

                             lpdwSize: var DWORD): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "GetDefaultCommConfigW".}

-proc GetDIBColorTable*(DC: HDC, p2, p3: UINT, RGBQuadStructs: pointer): UINT{.

+proc GetDIBColorTable*(DC: HDC, p2, p3: WINUINT, RGBQuadStructs: pointer): WINUINT{.

     stdcall, dynlib: "gdi32", importc: "GetDIBColorTable".}

-proc GetDIBits*(DC: HDC, Bitmap: HBitmap, StartScan, NumScans: UINT,

-                Bits: Pointer, BitInfo: var TBitmapInfo, Usage: UINT): int{.

+proc GetDIBits*(DC: HDC, Bitmap: HBitmap, StartScan, NumScans: WINUINT,

+                Bits: Pointer, BitInfo: var TBitmapInfo, Usage: WINUINT): int{.

     stdcall, dynlib: "gdi32", importc: "GetDIBits".}

 proc GetDiskFreeSpace*(lpRootPathName: cstring, lpSectorsPerCluster,

     lpBytesPerSector, lpNumberOfFreeClusters, lpTotalNumberOfClusters: var DWORD): WINBOOL{.

@@ -21539,7 +21539,7 @@ proc GetDiskFreeSpaceExA*(lpDirectoryName: LPCSTR, lpFreeBytesAvailableToCaller,
 proc GetDiskFreeSpaceExW*(lpDirectoryName: LPWSTR, lpFreeBytesAvailableToCaller,

     lpTotalNumberOfBytes: pLargeInteger, lpTotalNumberOfFreeBytes: PLargeInteger): WINBOOL{.

     stdcall, dynlib: "kernel32", importc: "GetDiskFreeSpaceExW".}

-  #function GetEnhMetaFilePixelFormat(p1: HENHMETAFILE; p2: Cardinal; var p3: TPixelFormatDescriptor): UINT;stdcall; external 'gdi32' name 'GetEnhMetaFilePixelFormat';

+  #function GetEnhMetaFilePixelFormat(p1: HENHMETAFILE; p2: Cardinal; var p3: TPixelFormatDescriptor): WINUINT;stdcall; external 'gdi32' name 'GetEnhMetaFilePixelFormat';

 proc GetExitCodeProcess*(hProcess: THandle, lpExitCode: var DWORD): WINBOOL{.

     stdcall, dynlib: "kernel32", importc: "GetExitCodeProcess".}

 proc GetExitCodeThread*(hThread: THandle, lpExitCode: var DWORD): WINBOOL{.

@@ -21559,13 +21559,13 @@ proc GetFileVersionInfoSizeW*(lptstrFilename: LPWSTR, lpdwHandle: var DWORD): DW
   # function GetFullPathName(lpFileName: PChar; nBufferLength: DWORD; lpBuffer: PChar; var lpFilePart: PChar): DWORD;stdcall; external 'kernel32' name 'GetFullPathNameA';

   # function GetFullPathNameA(lpFileName: LPCSTR; nBufferLength: DWORD; lpBuffer: LPCSTR; var lpFilePart: LPCSTR): DWORD; stdcall; external 'kernel32' name 'GetFullPathNameA';

   # function GetFullPathNameW(lpFileName: LPWSTR; nBufferLength: DWORD; lpBuffer: LPWSTR; var lpFilePart: LPWSTR): DWORD; stdcall; external 'kernel32' name 'GetFullPathNameW';

-proc GetGlyphOutline*(DC: HDC, p2, p3: UINT, p4: TGlyphMetrics, p5: DWORD,

+proc GetGlyphOutline*(DC: HDC, p2, p3: WINUINT, p4: TGlyphMetrics, p5: DWORD,

                       p6: Pointer, p7: TMat2): DWORD{.stdcall, dynlib: "gdi32",

     importc: "GetGlyphOutlineA".}

-proc GetGlyphOutlineA*(DC: HDC, p2, p3: UINT, p4: TGlyphMetrics, p5: DWORD,

+proc GetGlyphOutlineA*(DC: HDC, p2, p3: WINUINT, p4: TGlyphMetrics, p5: DWORD,

                        p6: Pointer, p7: TMat2): DWORD{.stdcall, dynlib: "gdi32",

     importc: "GetGlyphOutlineA".}

-proc GetGlyphOutlineW*(DC: HDC, p2, p3: UINT, p4: TGlyphMetrics, p5: DWORD,

+proc GetGlyphOutlineW*(DC: HDC, p2, p3: WINUINT, p4: TGlyphMetrics, p5: DWORD,

                        p6: Pointer, p7: TMat2): DWORD{.stdcall, dynlib: "gdi32",

     importc: "GetGlyphOutlineW".}

   #function GetGUIThreadInfo(idThread: DWORD; var pgui: TGUIThreadinfo): WINBOOL;stdcall; external 'user32' name 'GetGUIThreadInfo';

@@ -21579,7 +21579,7 @@ proc GetIconInfo*(icon: HICON, piconinfo: var TIconInfo): WINBOOL{.stdcall,
   #function GetKernelObjectSecurity(Handle: THandle; RequestedInformation: SECURITY_INFORMATION; pSecurityDescriptor: PSecurityDescriptor; nLength: DWORD; var lpnLengthNeeded: DWORD): WINBOOL; stdcall; external 'advapi32' name 'GetKernelObjectSecurity';

 proc GetKerningPairs*(DC: HDC, Count: DWORD, KerningPairs: pointer): DWORD{.

     stdcall, dynlib: "gdi32", importc: "GetKerningPairs".}

-proc GetKeyboardLayoutList*(nBuff: int, List: pointer): UINT{.stdcall,

+proc GetKeyboardLayoutList*(nBuff: int, List: pointer): WINUINT{.stdcall,

     dynlib: "user32", importc: "GetKeyboardLayoutList".}

   #function GetKeyboardState(var KeyState: TKeyboardState): WINBOOL; stdcall; external 'user32' name 'GetKeyboardState';

   #function GetLastInputInfo(var plii: TLastInputInfo): WINBOOL;stdcall; external 'user32' name 'GetLastInputInfo';

@@ -21606,24 +21606,24 @@ proc GetMailslotInfo*(hMailslot: THandle, lpMaxMessageSize: Pointer,
     dynlib: "kernel32", importc: "GetMailslotInfo".}

   #function GetMenuBarInfo(hend: HWND; idObject, idItem: Longint; var pmbi: TMenuBarInfo): WINBOOL;stdcall; external 'user32' name 'GetMenuBarInfo';

   #function GetMenuInfo(menu: HMENU; var lpmi: TMenuInfo): WINBOOL;stdcall; external 'user32' name 'GetMenuInfo';

-proc GetMenuItemInfo*(p1: HMENU, p2: UINT, p3: WINBOOL, p4: var TMenuItemInfo): WINBOOL{.

+proc GetMenuItemInfo*(p1: HMENU, p2: WINUINT, p3: WINBOOL, p4: var TMenuItemInfo): WINBOOL{.

     stdcall, dynlib: "user32", importc: "GetMenuItemInfoA".}

-proc GetMenuItemInfoA*(p1: HMENU, p2: UINT, p3: WINBOOL, p4: var TMenuItemInfoA): WINBOOL{.

+proc GetMenuItemInfoA*(p1: HMENU, p2: WINUINT, p3: WINBOOL, p4: var TMenuItemInfoA): WINBOOL{.

     stdcall, dynlib: "user32", importc: "GetMenuItemInfoA".}

-  #function GetMenuItemInfoW(p1: HMENU; p2: UINT; p3: WINBOOL; var p4: TMenuItemInfoW): WINBOOL; stdcall; external 'user32' name 'GetMenuItemInfoW';

-proc GetMenuItemRect*(wnd: HWND, menu: HMENU, uItem: UINT, lprcItem: var TRect): WINBOOL{.

+  #function GetMenuItemInfoW(p1: HMENU; p2: WINUINT; p3: WINBOOL; var p4: TMenuItemInfoW): WINBOOL; stdcall; external 'user32' name 'GetMenuItemInfoW';

+proc GetMenuItemRect*(wnd: HWND, menu: HMENU, uItem: WINUINT, lprcItem: var TRect): WINBOOL{.

     stdcall, dynlib: "user32", importc: "GetMenuItemRect".}

-proc GetMessage*(lpMsg: var TMsg, wnd: HWND, wMsgFilterMin, wMsgFilterMax: UINT): WINBOOL{.

+proc GetMessage*(lpMsg: var TMsg, wnd: HWND, wMsgFilterMin, wMsgFilterMax: WINUINT): WINBOOL{.

     stdcall, dynlib: "user32", importc: "GetMessageA".}

 proc GetMessageA*(lpMsg: var TMsg, wnd: HWND,

-                  wMsgFilterMin, wMsgFilterMax: UINT): WINBOOL{.stdcall,

+                  wMsgFilterMin, wMsgFilterMax: WINUINT): WINBOOL{.stdcall,

     dynlib: "user32", importc: "GetMessageA".}

 proc GetMessageW*(lpMsg: var TMsg, wnd: HWND,

-                  wMsgFilterMin, wMsgFilterMax: UINT): WINBOOL{.stdcall,

+                  wMsgFilterMin, wMsgFilterMax: WINUINT): WINBOOL{.stdcall,

     dynlib: "user32", importc: "GetMessageW".}

 proc GetMiterLimit*(DC: HDC, Limit: var float32): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "GetMiterLimit".}

-  #function GetMouseMovePoints(cbSize: UINT; var lppt, lpptBuf: TMouseMovePoint; nBufPoints: Integer; resolution: DWORD): Integer;stdcall; external 'user32' name 'GetMouseMovePoints';

+  #function GetMouseMovePoints(cbSize: WINUINT; var lppt, lpptBuf: TMouseMovePoint; nBufPoints: Integer; resolution: DWORD): Integer;stdcall; external 'user32' name 'GetMouseMovePoints';

 proc GetNamedPipeInfo*(hNamedPipe: THandle, lpFlags: var DWORD,

                        lpOutBufferSize, lpInBufferSize, lpMaxInstances: Pointer): WINBOOL{.

     stdcall, dynlib: "kernel32", importc: "GetNamedPipeInfo".}

@@ -21637,8 +21637,8 @@ proc GetNumberOfConsoleMouseButtons*(lpNumberOfMouseButtons: var DWORD): WINBOOL
 proc GetOverlappedResult*(hFile: THandle, lpOverlapped: TOverlapped,

                           lpNumberOfBytesTransferred: var DWORD, bWait: WINBOOL): WINBOOL{.

     stdcall, dynlib: "kernel32", importc: "GetOverlappedResult".}

-proc GetPaletteEntries*(Palette: HPALETTE, StartIndex, NumEntries: UINT,

-                        PaletteEntries: pointer): UINT{.stdcall,

+proc GetPaletteEntries*(Palette: HPALETTE, StartIndex, NumEntries: WINUINT,

+                        PaletteEntries: pointer): WINUINT{.stdcall,

     dynlib: "gdi32", importc: "GetPaletteEntries".}

 proc GetPath*(DC: HDC, Points, Types: pointer, nSize: int): int{.stdcall,

     dynlib: "gdi32", importc: "GetPath".}

@@ -21656,13 +21656,13 @@ proc GetPrivateProfileSectionNames*(lpszReturnBuffer: LPTSTR, nSize: DWORD,
                                     lpFileName: LPCTSTR): DWORD{.stdcall,

     dynlib: "kernel32", importc: "GetPrivateProfileSectionNamesA".}

 proc GetPrivateProfileStructA*(lpszSection, lpszKey: LPCSTR, lpStruct: LPVOID,

-                               uSizeStruct: UINT, szFile: LPCSTR): WINBOOL{.

+                               uSizeStruct: WINUINT, szFile: LPCSTR): WINBOOL{.

     stdcall, dynlib: "kernel32", importc: "GetPrivateProfileStructA".}

 proc GetPrivateProfileStructW*(lpszSection, lpszKey: LPCWSTR, lpStruct: LPVOID,

-                               uSizeStruct: UINT, szFile: LPCWSTR): WINBOOL{.

+                               uSizeStruct: WINUINT, szFile: LPCWSTR): WINBOOL{.

     stdcall, dynlib: "kernel32", importc: "GetPrivateProfileStructW".}

 proc GetPrivateProfileStruct*(lpszSection, lpszKey: LPCTSTR, lpStruct: LPVOID,

-                              uSizeStruct: UINT, szFile: LPCTSTR): WINBOOL{.

+                              uSizeStruct: WINUINT, szFile: LPCTSTR): WINBOOL{.

     stdcall, dynlib: "kernel32", importc: "GetPrivateProfileStructA".}

 proc GetProcessAffinityMask*(hProcess: THandle, lpProcessAffinityMask,

     lpSystemAffinityMask: var DWORD): WINBOOL{.stdcall, dynlib: "kernel32",

@@ -21685,7 +21685,7 @@ proc GetQueuedCompletionStatus*(CompletionPort: THandle,
                                 lpOverlapped: var POverlapped,

                                 dwMilliseconds: DWORD): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "GetQueuedCompletionStatus".}

-proc GetRasterizerCaps*(p1: var TRasterizerStatus, p2: UINT): WINBOOL{.stdcall,

+proc GetRasterizerCaps*(p1: var TRasterizerStatus, p2: WINUINT): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "GetRasterizerCaps".}

 proc GetRgnBox*(RGN: HRGN, p2: var TRect): int{.stdcall, dynlib: "gdi32",

     importc: "GetRgnBox".}

@@ -21715,8 +21715,8 @@ proc GetStringTypeExW*(Locale: LCID, dwInfoType: DWORD, lpSrcStr: LPWSTR,
 proc GetStringTypeW*(dwInfoType: DWORD, lpSrcStr: WCHAR, cchSrc: WINBOOL,

                      lpCharType: var int16): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "GetStringTypeW".}

-proc GetSystemPaletteEntries*(DC: HDC, StartIndex, NumEntries: UINT,

-                              PaletteEntries: pointer): UINT{.stdcall,

+proc GetSystemPaletteEntries*(DC: HDC, StartIndex, NumEntries: WINUINT,

+                              PaletteEntries: pointer): WINUINT{.stdcall,

     dynlib: "gdi32", importc: "GetSystemPaletteEntries".}

 proc GetSystemPowerStatus*(lpSystemPowerStatus: var TSystemPowerStatus): WINBOOL{.

     stdcall, dynlib: "kernel32", importc: "GetSystemPowerStatus".}

@@ -21859,9 +21859,9 @@ proc InitializeAcl*(pAcl: var TACL, nAclLength, dwAclRevision: DWORD): WINBOOL{.
 proc InitializeSid*(Sid: Pointer, pIdentifierAuthority: TSIDIdentifierAuthority,

                     nSubAuthorityCount: int8): WINBOOL{.stdcall,

     dynlib: "advapi32", importc: "InitializeSid".}

-proc InsertMenuItemA*(p1: HMENU, p2: UINT, p3: WINBOOL, p4: TMenuItemInfoA): WINBOOL{.

+proc InsertMenuItemA*(p1: HMENU, p2: WINUINT, p3: WINBOOL, p4: TMenuItemInfoA): WINBOOL{.

     stdcall, dynlib: "user32", importc: "InsertMenuItemA".}

-  #function InsertMenuItemW(p1: HMENU; p2: UINT; p3: WINBOOL; const p4: TMenuItemInfoW): WINBOOL; stdcall; external 'user32' name 'InsertMenuItemW';

+  #function InsertMenuItemW(p1: HMENU; p2: WINUINT; p3: WINBOOL; const p4: TMenuItemInfoW): WINBOOL; stdcall; external 'user32' name 'InsertMenuItemW';

 proc IntersectRect*(lprcDst: var TRect, lprcSrc1, lprcSrc2: TRect): WINBOOL{.

     stdcall, dynlib: "user32", importc: "IntersectRect".}

   #function InvertRect(hDC: HDC; const lprc: TRect): WINBOOL; stdcall; external 'user32' name 'InvertRect';

@@ -21967,7 +21967,7 @@ proc MakeSelfRelativeSD*(pAbsoluteSecurityDescriptor: PSecurityDescriptor,
     dynlib: "advapi32", importc: "MakeSelfRelativeSD".}

 proc MapDialogRect*(hDlg: HWND, lpRect: var TRect): WINBOOL{.stdcall,

     dynlib: "user32", importc: "MapDialogRect".}

-proc MapWindowPoints*(hWndFrom, hWndTo: HWND, lpPoints: pointer, cPoints: UINT): int{.

+proc MapWindowPoints*(hWndFrom, hWndTo: HWND, lpPoints: pointer, cPoints: WINUINT): int{.

     stdcall, dynlib: "user32", importc: "MapWindowPoints".}

 proc MessageBoxIndirect*(MsgBoxParams: TMsgBoxParams): WINBOOL{.stdcall,

     dynlib: "user32", importc: "MessageBoxIndirectA".}

@@ -21982,7 +21982,7 @@ proc MsgWaitForMultipleObjects*(nCount: DWORD, pHandles: pointer,
 proc MsgWaitForMultipleObjectsEx*(nCount: DWORD, pHandles: pointer,

                                   dwMilliseconds, dwWakeMask, dwFlags: DWORD): DWORD{.

     stdcall, dynlib: "user32", importc: "MsgWaitForMultipleObjectsEx".}

-  # function MultiByteToWideChar(CodePage: UINT; dwFlags: DWORD; const lpMultiByteStr: LPCSTR; cchMultiByte: Integer; lLPWSTRStr: LPWSTR; cchWideChar: Integer): Integer; stdcall; external 'kernel32' name 'MultiByteToWideChar';

+  # function MultiByteToWideChar(CodePage: WINUINT; dwFlags: DWORD; const lpMultiByteStr: LPCSTR; cchMultiByte: Integer; lLPWSTRStr: LPWSTR; cchWideChar: Integer): Integer; stdcall; external 'kernel32' name 'MultiByteToWideChar';

 proc ObjectOpenAuditAlarm*(SubsystemName: cstring, HandleId: Pointer,

                            ObjectTypeName: cstring, ObjectName: cstring,

                            pSecurityDescriptor: PSecurityDescriptor,

@@ -22031,7 +22031,7 @@ proc OffsetViewportOrgEx*(DC: HDC, X, Y: int, Points: pointer): WINBOOL{.
     stdcall, dynlib: "gdi32", importc: "OffsetViewportOrgEx".}

 proc OffsetWindowOrgEx*(DC: HDC, X, Y: int, Points: pointer): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "OffsetWindowOrgEx".}

-proc OpenFile*(lpFileName: LPCSTR, lpReOpenBuff: var TOFStruct, uStyle: UINT): HFILE{.

+proc OpenFile*(lpFileName: LPCSTR, lpReOpenBuff: var TOFStruct, uStyle: WINUINT): HFILE{.

     stdcall, dynlib: "kernel32", importc: "OpenFile".}

 proc OpenProcessToken*(ProcessHandle: THandle, DesiredAccess: DWORD,

                        TokenHandle: var THandle): WINBOOL{.stdcall,

@@ -22049,19 +22049,19 @@ proc PeekConsoleInputW*(hConsoleInput: THandle, lpBuffer: var TInputRecord,
                         nLength: DWORD, lpNumberOfEventsRead: var DWORD): WINBOOL{.

     stdcall, dynlib: "kernel32", importc: "PeekConsoleInputW".}

 proc PeekMessage*(lpMsg: var TMsg, wnd: HWND,

-                  wMsgFilterMin, wMsgFilterMax, wRemoveMsg: UINT): WINBOOL{.

+                  wMsgFilterMin, wMsgFilterMax, wRemoveMsg: WINUINT): WINBOOL{.

     stdcall, dynlib: "user32", importc: "PeekMessageA".}

 proc PeekMessageA*(lpMsg: var TMsg, wnd: HWND,

-                   wMsgFilterMin, wMsgFilterMax, wRemoveMsg: UINT): WINBOOL{.

+                   wMsgFilterMin, wMsgFilterMax, wRemoveMsg: WINUINT): WINBOOL{.

     stdcall, dynlib: "user32", importc: "PeekMessageA".}

 proc PeekMessageW*(lpMsg: var TMsg, wnd: HWND,

-                   wMsgFilterMin, wMsgFilterMax, wRemoveMsg: UINT): WINBOOL{.

+                   wMsgFilterMin, wMsgFilterMax, wRemoveMsg: WINUINT): WINBOOL{.

     stdcall, dynlib: "user32", importc: "PeekMessageW".}

   #function PlayEnhMetaFile(DC: HDC; p2: HENHMETAFILE; const p3: TRect): WINBOOL; stdcall; external 'gdi32' name 'PlayEnhMetaFile';

 proc PlayEnhMetaFileRecord*(DC: HDC, p2: var THandleTable, p3: TEnhMetaRecord,

-                            p4: UINT): WINBOOL{.stdcall, dynlib: "gdi32",

+                            p4: WINUINT): WINBOOL{.stdcall, dynlib: "gdi32",

     importc: "PlayEnhMetaFileRecord".}

-proc PlayMetaFileRecord*(DC: HDC, p2: THandleTable, p3: TMetaRecord, p4: UINT): WINBOOL{.

+proc PlayMetaFileRecord*(DC: HDC, p2: THandleTable, p3: TMetaRecord, p4: WINUINT): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "PlayMetaFileRecord".}

 proc PlgBlt*(DC: HDC, PointsArray: pointer, p3: HDC, p4, p5, p6, p7: int,

              p8: HBITMAP, p9, p10: int): WINBOOL{.stdcall, dynlib: "gdi32",

@@ -22328,21 +22328,21 @@ proc ScrollWindow*(wnd: HWND, XAmount: int32, YAmount: int32, rect: LPRECT,
     importc: "ScrollWindow".}

 proc ScrollWindowEx*(wnd: HWND, dx: int32, dy: int32, prcScroll: lpRECT,

                      prcClip: lpRECT, hrgnUpdate: HRGN, prcUpdate: LPRECT,

-                     flags: UINT): int32{.stdcall, dynlib: "user32",

+                     flags: WINUINT): int32{.stdcall, dynlib: "user32",

     importc: "ScrollWindowEx".}

   #function ScrollDC(DC: HDC; DX, DY: Integer; var Scroll, Clip: TRect; Rgn: HRGN; Update: PRect): WINBOOL; stdcall; external 'user32' name 'ScrollDC';

   #function SearchPath(lpPath, lpFileName, lpExtension: PChar; nBufferLength: DWORD; lpBuffer: PChar; var lpFilePart: PChar): DWORD;stdcall; external 'kernel32' name 'SearchPathA';

   #function SearchPathA(lpPath, lpFileName, lpExtension: LPCSTR; nBufferLength: DWORD; lpBuffer: LPCSTR; var lpFilePart: LPCSTR): DWORD; stdcall; external 'kernel32' name 'SearchPathA';

   #function SearchPathW(lpPath, lpFileName, lpExtension: LPWSTR; nBufferLength: DWORD; lpBuffer: LPWSTR; var lpFilePart: LPWSTR): DWORD; stdcall; external 'kernel32' name 'SearchPathW';

-  #function SendInput(cInputs: UINT; var pInputs: TInput; cbSize: Integer): UINT;stdcall; external 'user32' name 'SendInput';

-proc SendMessageTimeout*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM,

-                         fuFlags, uTimeout: UINT, lpdwResult: var DWORD): LRESULT{.

+  #function SendInput(cInputs: WINUINT; var pInputs: TInput; cbSize: Integer): WINUINT;stdcall; external 'user32' name 'SendInput';

+proc SendMessageTimeout*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM,

+                         fuFlags, uTimeout: WINUINT, lpdwResult: var DWORD): LRESULT{.

     stdcall, dynlib: "user32", importc: "SendMessageTimeoutA".}

-proc SendMessageTimeoutA*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM,

-                          fuFlags, uTimeout: UINT, lpdwResult: var DWORD): LRESULT{.

+proc SendMessageTimeoutA*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM,

+                          fuFlags, uTimeout: WINUINT, lpdwResult: var DWORD): LRESULT{.

     stdcall, dynlib: "user32", importc: "SendMessageTimeoutA".}

-proc SendMessageTimeoutW*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM,

-                          fuFlags, uTimeout: UINT, lpdwResult: var DWORD): LRESULT{.

+proc SendMessageTimeoutW*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM,

+                          fuFlags, uTimeout: WINUINT, lpdwResult: var DWORD): LRESULT{.

     stdcall, dynlib: "user32", importc: "SendMessageTimeoutW".}

   #function SetAclInformation(var pAcl: TACL; pAclInformation: Pointer; nAclInformationLength: DWORD; dwAclInformationClass: TAclInformationClass): WINBOOL; stdcall; external 'advapi32' name 'SetAclInformation';

   #function SetColorAdjustment(DC: HDC; const p2: TColorAdjustment): WINBOOL; stdcall; external 'gdi32' name 'SetColorAdjustment';

@@ -22356,13 +22356,13 @@ proc SetConsoleCursorInfo*(hConsoleOutput: THandle,
                            lpConsoleCursorInfo: TConsoleCursorInfo): WINBOOL{.

     stdcall, dynlib: "kernel32", importc: "SetConsoleCursorInfo".}

   #function SetConsoleWindowInfo(hConsoleOutput: THandle; bAbsolute: WINBOOL; const lpConsoleWindow: TSmallRect): WINBOOL; stdcall; external 'kernel32' name 'SetConsoleWindowInfo';

-proc SetDIBColorTable*(DC: HDC, p2, p3: UINT, RGBQuadSTructs: pointer): UINT{.

+proc SetDIBColorTable*(DC: HDC, p2, p3: WINUINT, RGBQuadSTructs: pointer): WINUINT{.

     stdcall, dynlib: "gdi32", importc: "SetDIBColorTable".}

-proc SetDIBits*(DC: HDC, Bitmap: HBITMAP, StartScan, NumScans: UINT,

-                Bits: Pointer, BitsInfo: var TBitmapInfo, Usage: UINT): int{.

+proc SetDIBits*(DC: HDC, Bitmap: HBITMAP, StartScan, NumScans: WINUINT,

+                Bits: Pointer, BitsInfo: var TBitmapInfo, Usage: WINUINT): int{.

     stdcall, dynlib: "gdi32", importc: "SetDIBits".}

-  #function SetDIBitsToDevice(DC: HDC; DestX, DestY: Integer; Width, Height: DWORD; SrcX, SrcY: Integer; nStartScan, NumScans: UINT; Bits: Pointer; var BitsInfo: TBitmapInfo; Usage: UINT): Integer; stdcall; external 'gdi32' name 'SetDIBitsToDevice';

-proc SetEnhMetaFileBits*(para1: UINT, para2: pointer): HENHMETAFILE{.stdcall,

+  #function SetDIBitsToDevice(DC: HDC; DestX, DestY: Integer; Width, Height: DWORD; SrcX, SrcY: Integer; nStartScan, NumScans: WINUINT; Bits: Pointer; var BitsInfo: TBitmapInfo; Usage: WINUINT): Integer; stdcall; external 'gdi32' name 'SetDIBitsToDevice';

+proc SetEnhMetaFileBits*(para1: WINUINT, para2: pointer): HENHMETAFILE{.stdcall,

     dynlib: "gdi32", importc: "SetEnhMetaFileBits".}

 proc SetFileTime*(hFile: HANDLE, lpCreationTime: var FILETIME,

                   lpLastAccessTime: var FILETIME, lpLastWriteTime: var FILETIME): WINBOOL{.

@@ -22370,18 +22370,18 @@ proc SetFileTime*(hFile: HANDLE, lpCreationTime: var FILETIME,
   #function SetKeyboardState(var KeyState: TKeyboardState): WINBOOL; stdcall; external 'user32' name 'SetKeyboardState';

   #function SetLocalTime(const lpSystemTime: TSystemTime): WINBOOL; stdcall; external 'kernel32' name 'SetLocalTime';

   #function SetMenuInfo(menu: HMENU; const lpcmi: TMenuInfo): WINBOOL;stdcall; external 'user32' name 'SetMenuInfo';

-proc SetMenuItemInfo*(p1: HMENU, p2: UINT, p3: WINBOOL, p4: TMenuItemInfo): WINBOOL{.

+proc SetMenuItemInfo*(p1: HMENU, p2: WINUINT, p3: WINBOOL, p4: TMenuItemInfo): WINBOOL{.

     stdcall, dynlib: "user32", importc: "SetMenuItemInfoA".}

-proc SetMenuItemInfoA*(p1: HMENU, p2: UINT, p3: WINBOOL, p4: TMenuItemInfoA): WINBOOL{.

+proc SetMenuItemInfoA*(p1: HMENU, p2: WINUINT, p3: WINBOOL, p4: TMenuItemInfoA): WINBOOL{.

     stdcall, dynlib: "user32", importc: "SetMenuItemInfoA".}

-  #function SetMenuItemInfoW(p1: HMENU; p2: UINT; p3: WINBOOL; const p4: TMenuItemInfoW): WINBOOL; stdcall; external 'user32' name 'SetMenuItemInfoW';

-proc SetMetaFileBitsEx*(p1: UINT, p2: cstring): HMETAFILE{.stdcall,

+  #function SetMenuItemInfoW(p1: HMENU; p2: WINUINT; p3: WINBOOL; const p4: TMenuItemInfoW): WINBOOL; stdcall; external 'user32' name 'SetMenuItemInfoW';

+proc SetMetaFileBitsEx*(p1: WINUINT, p2: cstring): HMETAFILE{.stdcall,

     dynlib: "gdi32", importc: "SetMetaFileBitsEx".}

 proc SetNamedPipeHandleState*(hNamedPipe: THandle, lpMode: var DWORD,

     lpMaxCollectionCount, lpCollectDataTimeout: Pointer): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "SetNamedPipeHandleState".}

-proc SetPaletteEntries*(Palette: HPALETTE, StartIndex, NumEntries: UINT,

-                        PaletteEntries: pointer): UINT{.stdcall,

+proc SetPaletteEntries*(Palette: HPALETTE, StartIndex, NumEntries: WINUINT,

+                        PaletteEntries: pointer): WINUINT{.stdcall,

     dynlib: "gdi32", importc: "SetPaletteEntries".}

   #function SetPrivateObjectSecurity(SecurityInformation: SECURITY_INFORMATION; ModificationDescriptor: PSecurityDescriptor; var ObjectsSecurityDescriptor: PSecurityDescriptor; const GenericMapping: TGenericMapping; Token: THandle): WINBOOL;

   #  stdcall; external 'advapi32' name 'SetPrivateObjectSecurity';

@@ -22407,7 +22407,7 @@ proc SetWaitableTimer*(hTimer: THandle, lpDueTime: var TLargeInteger,
                        lPeriod: int32, pfnCompletionRoutine: TFNTimerAPCRoutine,

                        lpArgToCompletionRoutine: Pointer, fResume: WINBOOL): WINBOOL{.

     stdcall, dynlib: "kernel32", importc: "SetWaitableTimer".}

-proc SetWinMetaFileBits*(p1: UINT, p2: cstring, p3: HDC, p4: TMetaFilePict): HENHMETAFILE{.

+proc SetWinMetaFileBits*(p1: WINUINT, p2: cstring, p3: HDC, p4: TMetaFilePict): HENHMETAFILE{.

     stdcall, dynlib: "gdi32", importc: "SetWinMetaFileBits".}

   #function SetWorldTransform(DC: HDC; const p2: TXForm): WINBOOL; stdcall; external 'gdi32' name 'SetWorldTransform';

 proc StartDoc*(DC: HDC, p2: TDocInfo): int{.stdcall, dynlib: "gdi32",

@@ -22415,7 +22415,7 @@ proc StartDoc*(DC: HDC, p2: TDocInfo): int{.stdcall, dynlib: "gdi32",
 proc StartDocA*(DC: HDC, p2: TDocInfoA): int{.stdcall, dynlib: "gdi32",

     importc: "StartDocA".}

   #function StartDocW(DC: HDC; const p2: TDocInfoW): Integer; stdcall; external 'gdi32' name 'StartDocW';

-  #function StretchDIBits(DC: HDC; DestX, DestY, DestWidth, DestHegiht, SrcX, SrcY, SrcWidth, SrcHeight: Integer; Bits: Pointer; var BitsInfo: TBitmapInfo; Usage: UINT; Rop: DWORD): Integer; stdcall; external 'gdi32' name 'StretchDIBits';

+  #function StretchDIBits(DC: HDC; DestX, DestY, DestWidth, DestHegiht, SrcX, SrcY, SrcWidth, SrcHeight: Integer; Bits: Pointer; var BitsInfo: TBitmapInfo; Usage: WINUINT; Rop: DWORD): Integer; stdcall; external 'gdi32' name 'StretchDIBits';

 proc SubtractRect*(lprcDst: var TRect, lprcSrc1, lprcSrc2: TRect): WINBOOL{.

     stdcall, dynlib: "user32", importc: "SubtractRect".}

 proc SystemTimeToFileTime*(lpSystemTime: TSystemTime, lpFileTime: var TFileTime): WINBOOL{.

@@ -22435,15 +22435,15 @@ proc TabbedTextOutW*(hDC: HDC, X, Y: int, lpString: LPWSTR,
                      nCount, nTabPositions: int, lpnTabStopPositions: pointer,

                      nTabOrigin: int): int32{.stdcall, dynlib: "user32",

     importc: "TabbedTextOutW".}

-  #function ToAscii(uVirtKey, uScanCode: UINT; const KeyState: TKeyboardState; lpChar: PChar; uFlags: UINT): Integer; stdcall; external 'user32' name 'ToAscii';

-  #function ToAsciiEx(uVirtKey: UINT; uScanCode: UINT; const KeyState: TKeyboardState; lpChar: PChar; uFlags: UINT; dwhkl: HKL): Integer; stdcall; external 'user32' name 'ToAsciiEx';

-  #function ToUnicode(wVirtKey, wScanCode: UINT; const KeyState: TKeyboardState; var pwszBuff; cchBuff: Integer; wFlags: UINT): Integer; stdcall; external 'user32' name 'ToUnicode';

+  #function ToAscii(uVirtKey, uScanCode: WINUINT; const KeyState: TKeyboardState; lpChar: PChar; uFlags: WINUINT): Integer; stdcall; external 'user32' name 'ToAscii';

+  #function ToAsciiEx(uVirtKey: WINUINT; uScanCode: WINUINT; const KeyState: TKeyboardState; lpChar: PChar; uFlags: WINUINT; dwhkl: HKL): Integer; stdcall; external 'user32' name 'ToAsciiEx';

+  #function ToUnicode(wVirtKey, wScanCode: WINUINT; const KeyState: TKeyboardState; var pwszBuff; cchBuff: Integer; wFlags: WINUINT): Integer; stdcall; external 'user32' name 'ToUnicode';

   # Careful, NT and higher only.

 proc TrackMouseEvent*(EventTrack: var TTrackMouseEvent): WINBOOL{.stdcall,

     dynlib: "user32", importc: "TrackMouseEvent".}

 proc TrackMouseEvent*(lpEventTrack: PTrackMouseEvent): WINBOOL{.stdcall,

     dynlib: "user32", importc: "TrackMouseEvent".}

-proc TrackPopupMenu*(menu: HMENU, uFlags: UINT, x: int32, y: int32,

+proc TrackPopupMenu*(menu: HMENU, uFlags: WINUINT, x: int32, y: int32,

                      nReserved: int32, wnd: HWND, prcRect: PRect): WINBOOL{.

     stdcall, dynlib: "user32", importc: "TrackPopupMenu".}

 proc TransactNamedPipe*(hNamedPipe: THandle, lpInBuffer: Pointer,

@@ -22464,7 +22464,7 @@ proc TranslateMDISysAccel*(hWndClient: HWND, lpMsg: TMsg): WINBOOL{.stdcall,
     dynlib: "user32", importc: "TranslateMDISysAccel".}

 proc TranslateMessage*(lpMsg: TMsg): WINBOOL{.stdcall, dynlib: "user32",

     importc: "TranslateMessage".}

-  #function TransparentDIBits(DC: HDC; p2, p3, p4, p5: Integer; const p6: Pointer; const p7: PBitmapInfo; p8: UINT; p9, p10, p11, p12: Integer; p13: UINT): WINBOOL;stdcall; external 'gdi32' name 'TransparentDIBits';

+  #function TransparentDIBits(DC: HDC; p2, p3, p4, p5: Integer; const p6: Pointer; const p7: PBitmapInfo; p8: WINUINT; p9, p10, p11, p12: Integer; p13: WINUINT): WINBOOL;stdcall; external 'gdi32' name 'TransparentDIBits';

 proc UnhandledExceptionFilter*(ExceptionInfo: TExceptionPointers): int32{.

     stdcall, dynlib: "kernel32", importc: "UnhandledExceptionFilter".}

 proc UnionRect*(lprcDst: var TRect, lprcSrc1, lprcSrc2: TRect): WINBOOL{.

@@ -22474,39 +22474,39 @@ proc UnlockFileEx*(hFile: THandle, dwReserved, nNumberOfBytesToUnlockLow: DWORD,
     stdcall, dynlib: "kernel32", importc: "UnlockFileEx".}

 proc VerFindFile*(uFlags: DWORD,

                   szFileName, szWinDir, szAppDir, szCurDir: cstring,

-                  lpuCurDirLen: var UINT, szDestDir: cstring,

-                  lpuDestDirLen: var UINT): DWORD{.stdcall, dynlib: "version",

+                  lpuCurDirLen: var WINUINT, szDestDir: cstring,

+                  lpuDestDirLen: var WINUINT): DWORD{.stdcall, dynlib: "version",

     importc: "VerFindFileA".}

 proc VerFindFileA*(uFlags: DWORD,

                    szFileName, szWinDir, szAppDir, szCurDir: LPCSTR,

-                   lpuCurDirLen: var UINT, szDestDir: LPCSTR,

-                   lpuDestDirLen: var UINT): DWORD{.stdcall, dynlib: "version",

+                   lpuCurDirLen: var WINUINT, szDestDir: LPCSTR,

+                   lpuDestDirLen: var WINUINT): DWORD{.stdcall, dynlib: "version",

     importc: "VerFindFileA".}

 proc VerFindFileW*(uFlags: DWORD,

                    szFileName, szWinDir, szAppDir, szCurDir: LPWSTR,

-                   lpuCurDirLen: var UINT, szDestDir: LPWSTR,

-                   lpuDestDirLen: var UINT): DWORD{.stdcall, dynlib: "version",

+                   lpuCurDirLen: var WINUINT, szDestDir: LPWSTR,

+                   lpuDestDirLen: var WINUINT): DWORD{.stdcall, dynlib: "version",

     importc: "VerFindFileW".}

 proc VerInstallFile*(uFlags: DWORD, szSrcFileName, szDestFileName, szSrcDir,

                                     szDestDir, szCurDir, szTmpFile: cstring,

-                     lpuTmpFileLen: var UINT): DWORD{.stdcall,

+                     lpuTmpFileLen: var WINUINT): DWORD{.stdcall,

     dynlib: "version", importc: "VerInstallFileA".}

 proc VerInstallFileA*(uFlags: DWORD, szSrcFileName, szDestFileName, szSrcDir,

                                      szDestDir, szCurDir, szTmpFile: LPCSTR,

-                      lpuTmpFileLen: var UINT): DWORD{.stdcall,

+                      lpuTmpFileLen: var WINUINT): DWORD{.stdcall,

     dynlib: "version", importc: "VerInstallFileA".}

 proc VerInstallFileW*(uFlags: DWORD, szSrcFileName, szDestFileName, szSrcDir,

                                      szDestDir, szCurDir, szTmpFile: LPWSTR,

-                      lpuTmpFileLen: var UINT): DWORD{.stdcall,

+                      lpuTmpFileLen: var WINUINT): DWORD{.stdcall,

     dynlib: "version", importc: "VerInstallFileW".}

 proc VerQueryValue*(pBlock: Pointer, lpSubBlock: cstring,

-                    lplpBuffer: var Pointer, puLen: var UINT): WINBOOL{.stdcall,

+                    lplpBuffer: var Pointer, puLen: var WINUINT): WINBOOL{.stdcall,

     dynlib: "version", importc: "VerQueryValueA".}

 proc VerQueryValueA*(pBlock: Pointer, lpSubBlock: LPCSTR,

-                     lplpBuffer: var Pointer, puLen: var UINT): WINBOOL{.

+                     lplpBuffer: var Pointer, puLen: var WINUINT): WINBOOL{.

     stdcall, dynlib: "version", importc: "VerQueryValueA".}

 proc VerQueryValueW*(pBlock: Pointer, lpSubBlock: LPWSTR,

-                     lplpBuffer: var Pointer, puLen: var UINT): WINBOOL{.

+                     lplpBuffer: var Pointer, puLen: var WINUINT): WINBOOL{.

     stdcall, dynlib: "version", importc: "VerQueryValueW".}

 proc VirtualQuery*(lpAddress: Pointer, lpBuffer: var TMemoryBasicInformation,

                    dwLength: DWORD): DWORD{.stdcall, dynlib: "kernel32",

@@ -22526,7 +22526,7 @@ proc wglGetLayerPaletteEntries*(p1: HDC, p2, p3, p4: int, pcr: pointer): int{.
     stdcall, dynlib: "opengl32", importc: "wglGetLayerPaletteEntries".}

 proc wglSetLayerPaletteEntries*(p1: HDC, p2, p3, p4: int, pcr: pointer): int{.

     stdcall, dynlib: "opengl32", importc: "wglSetLayerPaletteEntries".}

-  #function wglSwapMultipleBuffers(p1: UINT; const p2: PWGLSwap): DWORD;stdcall; external 'opengl32' name 'wglSwapMultipleBuffers';

+  #function wglSwapMultipleBuffers(p1: WINUINT; const p2: PWGLSwap): DWORD;stdcall; external 'opengl32' name 'wglSwapMultipleBuffers';

   #function WinSubmitCertificate(var lpCertificate: TWinCertificate): WINBOOL;stdcall; external 'imaghlp' name 'WinSubmitCertificate';

   #function WinVerifyTrust(wnd: HWND; const ActionID: TGUID; ActionData: Pointer): Longint;stdcall; external 'imaghlp' name 'WinVerifyTrust';

 proc WNetAddConnection2*(lpNetResource: var TNetResource,

@@ -22698,14 +22698,14 @@ proc WriteFileEx*(hFile: THandle, lpBuffer: Pointer,
                   lpCompletionRoutine: FARPROC): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "WriteFileEx".}

 proc WritePrivateProfileStructA*(lpszSection, lpszKey: LPCSTR, lpStruct: LPVOID,

-                                 uSizeStruct: UINT, szFile: LPCSTR): WINBOOL{.

+                                 uSizeStruct: WINUINT, szFile: LPCSTR): WINBOOL{.

     stdcall, dynlib: "kernel32", importc: "WritePrivateProfileStructA".}

 proc WritePrivateProfileStructW*(lpszSection, lpszKey: LPCWSTR,

-                                 lpStruct: LPVOID, uSizeStruct: UINT,

+                                 lpStruct: LPVOID, uSizeStruct: WINUINT,

                                  szFile: LPCWSTR): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "WritePrivateProfileStructW".}

 proc WritePrivateProfileStruct*(lpszSection, lpszKey: LPCTSTR, lpStruct: LPVOID,

-                                uSizeStruct: UINT, szFile: LPCTSTR): WINBOOL{.

+                                uSizeStruct: WINUINT, szFile: LPCTSTR): WINBOOL{.

     stdcall, dynlib: "kernel32", importc: "WritePrivateProfileStructA".}

 proc WriteProcessMemory*(hProcess: THandle, lpBaseAddress: Pointer,

                          lpBuffer: Pointer, nSize: DWORD,

@@ -22758,12 +22758,12 @@ proc LocalDiscard*(hlocMem: HLOCAL): HLOCAL =
 

 # WinGDI.h

 

-proc GetGValue*(rgb: int32): int8 =

-  result = toU8(rgb shr 8'i32)

+discard """proc GetGValue*(rgb: int32): int8 =

+  result = toU8(rgb shr 8'i32)"""

 proc RGB*(r, g, b: int): COLORREF =

   result = toU32(r) or (toU32(g) shl 8) or (toU32(b) shl 16)

 proc RGB*(r, g, b: range[0 .. 255]): COLORREF =

-  result = r or g shl 8 or b shl 16

+  result = toU32(r) or (toU32(g) shl 8) or (toU32(b) shl 16)

 

 proc PALETTERGB*(r, g, b: range[0..255]): COLORREF =

   result = 0x02000000 or RGB(r, g, b)

@@ -23363,7 +23363,7 @@ proc Animate_Create(hWndP: HWND, id: HMENU, dwStyle: DWORD, hInstance: HINST): H
 proc Animate_Open(wnd: HWND, szName: LPTSTR): LRESULT =

   result = SendMessage(wnd, ACM_OPEN, 0, cast[LPARAM](szName))

 

-proc Animate_Play(wnd: HWND, `from`, `to`: int32, rep: UINT): LRESULT =

+proc Animate_Play(wnd: HWND, `from`, `to`: int32, rep: WINUINT): LRESULT =

   result = SendMessage(wnd, ACM_PLAY, WPARAM(rep),

                        LPARAM(MAKELONG(`from`, `to`)))

 

@@ -23458,7 +23458,7 @@ proc Header_SetItem(hwndHD: HWND, index: int32, hdi: var HD_ITEM): WINBOOL =
   result = WINBOOL(SendMessage(hwndHD, HDM_SETITEM, WPARAM(index),

                                cast[LPARAM](addr(hdi))))

 

-proc ListView_Arrange(hwndLV: HWND, code: UINT): LRESULT =

+proc ListView_Arrange(hwndLV: HWND, code: WINUINT): LRESULT =

   result = SendMessage(hwndLV, LVM_ARRANGE, WPARAM(code), 0)

 

 proc ListView_CreateDragImage(wnd: HWND, i: int32, lpptUpLeft: LPPOINT): LRESULT =

@@ -23481,7 +23481,7 @@ proc ListView_EnsureVisible(hwndLV: HWND, i, fPartialOK: int32): LRESULT =
                        MAKELPARAM(fPartialOK, 0))

 

 proc ListView_FindItem(wnd: HWND, iStart: int32, lvfi: var LV_FINDINFO): int32 =

-  result = SendMessage(wnd, LVM_FINDITEM, WPARAM(iStart), 
+  result = SendMessage(wnd, LVM_FINDITEM, WPARAM(iStart), 

                        cast[LPARAM](addr(lvfi))).int32

 

 proc ListView_GetBkColor(wnd: HWND): LRESULT =

@@ -23566,7 +23566,7 @@ proc ListView_Scroll(hwndLV: HWND, dx, dy: int32): LRESULT =
 proc ListView_SetBkColor(wnd: HWND, clrBk: COLORREF): LRESULT =

   result = SendMessage(wnd, LVM_SETBKCOLOR, 0, LPARAM(clrBk))

 

-proc ListView_SetCallbackMask(wnd: HWND, mask: UINT): LRESULT =

+proc ListView_SetCallbackMask(wnd: HWND, mask: WINUINT): LRESULT =

   result = SendMessage(wnd, LVM_SETCALLBACKMASK, WPARAM(mask), 0)

 

 proc ListView_SetColumn(wnd: HWND, iCol: int32, col: var LV_COLUMN): LRESULT =

@@ -23577,7 +23577,7 @@ proc ListView_SetColumnWidth(wnd: HWND, iCol, cx: int32): LRESULT =
 

 proc ListView_SetImageList(wnd: HWND, himl: int32, iImageList: HIMAGELIST): LRESULT =

   result = SendMessage(wnd, LVM_SETIMAGELIST, WPARAM(iImageList),

-                       LPARAM(UINT(himl)))

+                       LPARAM(WINUINT(himl)))

 

 proc ListView_SetItem(wnd: HWND, item: var LV_ITEM): LRESULT =

   result = SendMessage(wnd, LVM_SETITEM, 0, cast[LPARAM](addr(item)))

@@ -23597,8 +23597,8 @@ proc ListView_SetItemPosition32(hwndLV: HWND, i, x, y: int32): LRESULT =
 

 proc ListView_SetItemState(hwndLV: HWND, i, data, mask: int32): LRESULT =

   var gnu_lvi: LV_ITEM

-  gnu_lvi.stateMask = uint(mask)

-  gnu_lvi.state = uint(data)

+  gnu_lvi.stateMask = WINUINT(mask)

+  gnu_lvi.state = WINUINT(data)

   result = SendMessage(hwndLV, LVM_SETITEMSTATE, WPARAM(i),

                        cast[LPARAM](addr(gnu_lvi)))

 

@@ -23648,7 +23648,7 @@ proc TreeView_GetImageList(wnd: HWND, iImage: WPARAM): LRESULT =
   result = SendMessage(wnd, TVM_GETIMAGELIST, iImage, 0)

 

 proc TreeView_SetImageList(wnd: HWND, himl: HIMAGELIST, iImage: WPARAM): LRESULT =

-  result = SendMessage(wnd, TVM_SETIMAGELIST, iImage, LPARAM(UINT(himl)))

+  result = SendMessage(wnd, TVM_SETIMAGELIST, iImage, LPARAM(WINUINT(himl)))

 

 proc TreeView_GetNextItem(wnd: HWND, hitem: HTREEITEM, code: int32): LRESULT =

   result = SendMessage(wnd, TVM_GETNEXTITEM, WPARAM(code), cast[LPARAM](hitem))

@@ -23735,7 +23735,7 @@ proc TabCtrl_GetImageList(wnd: HWND): LRESULT =
   result = SendMessage(wnd, TCM_GETIMAGELIST, 0, 0)

 

 proc TabCtrl_SetImageList(wnd: HWND, himl: HIMAGELIST): LRESULT =

-  result = SendMessage(wnd, TCM_SETIMAGELIST, 0, LPARAM(UINT(himl)))

+  result = SendMessage(wnd, TCM_SETIMAGELIST, 0, LPARAM(WINUINT(himl)))

 

 proc TabCtrl_GetItemCount(wnd: HWND): LRESULT =

   result = SendMessage(wnd, TCM_GETITEMCOUNT, 0, 0)

@@ -23797,7 +23797,7 @@ proc TabCtrl_GetCurFocus(wnd: HWND): LRESULT =
 proc TabCtrl_SetCurFocus(wnd: HWND, i: int32): LRESULT =

   result = SendMessage(wnd, TCM_SETCURFOCUS, i, 0)

 

-proc SNDMSG(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): LRESULT =

+proc SNDMSG(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): LRESULT =

   result = SendMessage(wnd, Msg, wp, lp)

 

 proc CommDlg_OpenSave_GetSpecA(hdlg: HWND, psz: LPSTR, cbmax: int32): LRESULT =

diff --git a/lib/wrappers/openssl.nim b/lib/wrappers/openssl.nim
index 90c398dce..4dc71bffd 100644
--- a/lib/wrappers/openssl.nim
+++ b/lib/wrappers/openssl.nim
@@ -270,7 +270,7 @@ proc OPENSSL_config*(configName: cstring){.cdecl, dynlib: DLLSSLName, importc.}
 
 when not defined(windows):
   proc CRYPTO_set_mem_functions(a,b,c: pointer){.cdecl, 
-    dynlib: DLLSSLName, importc.}
+    dynlib: DLLUtilName, importc.}
 
 proc CRYPTO_malloc_init*() =
   when not defined(windows):
@@ -433,3 +433,70 @@ else:
   proc SSLGetMode(s: PSSL): int = 
     result = SSLctrl(s, SSL_CTRL_MODE, 0, nil)
 
+# <openssl/md5.h>
+type 
+  MD5_LONG* = cuint
+const 
+  MD5_CBLOCK* = 64
+  MD5_LBLOCK* = int(MD5_CBLOCK div 4)
+  MD5_DIGEST_LENGTH* = 16
+type 
+  MD5_CTX* = object 
+    A,B,C,D,Nl,Nh: MD5_LONG
+    data: array[MD5_LBLOCK, MD5_LONG]
+    num: cuint
+
+{.pragma: ic, importc: "$1".}
+{.push callconv:cdecl, dynlib:DLLUtilName.}
+proc MD5_Init*(c: var MD5_CTX): cint{.ic.}
+proc MD5_Update*(c: var MD5_CTX; data: pointer; len: csize): cint{.ic.}
+proc MD5_Final*(md: cstring; c: var MD5_CTX): cint{.ic.}
+proc MD5*(d: ptr cuchar; n: csize; md: ptr cuchar): ptr cuchar{.ic.}
+proc MD5_Transform*(c: var MD5_CTX; b: ptr cuchar){.ic.}
+{.pop.}
+
+from strutils import toHex,toLower
+
+proc hexStr (buf:cstring): string =
+  # turn md5s output into a nice hex str 
+  result = newStringOfCap(32)
+  for i in 0 .. <16:
+    result.add toHex(buf[i].ord, 2).toLower
+
+proc MD5_File* (file: string): string {.raises:[EIO,Ebase].} =
+  ## Generate MD5 hash for a file. Result is a 32 character
+  # hex string with lowercase characters (like the output
+  # of `md5sum`
+  const
+    sz = 512
+  let f = open(file,fmRead)
+  var
+    buf: array[sz,char]
+    ctx: MD5_CTX
+
+  discard md5_init(ctx)
+  while(let bytes = f.readChars(buf, 0, sz); bytes > 0):
+    discard md5_update(ctx, buf[0].addr, bytes)
+
+  discard md5_final( buf[0].addr, ctx )
+  f.close
+  
+  result = hexStr(buf)
+
+proc MD5_Str* (str:string): string {.raises:[EIO].} =
+  ##Generate MD5 hash for a string. Result is a 32 character
+  #hex string with lowercase characters
+  var 
+    ctx: MD5_CTX
+    res: array[MD5_DIGEST_LENGTH,char]
+    input = str.cstring
+  discard md5_init(ctx)
+
+  var i = 0
+  while i < str.len:
+    let L = min(str.len - i, 512)
+    discard md5_update(ctx, input[i].addr, L)
+    i += L
+
+  discard md5_final(res,ctx)
+  result = hexStr(res)
diff --git a/lib/wrappers/pdcurses.nim b/lib/wrappers/pdcurses.nim
index f014c5e9c..a53289bce 100644
--- a/lib/wrappers/pdcurses.nim
+++ b/lib/wrappers/pdcurses.nim
@@ -554,14 +554,12 @@ template BUTTON_CHANGED*(x: expr): expr =
 template BUTTON_STATUS*(x: expr): expr = 
   (Mouse_status.button[(x) - 1])
 
-template ACS_PICK*(w, n: expr): expr = 
-  (cast[int32](w) or A_ALTCHARSET)
+template ACS_PICK*(w, n: expr): expr = int32(w) or A_ALTCHARSET
 
-template KEY_F*(n: expr): expr = 
-  (KEY_F0 + (n))
+template KEY_F*(n: expr): expr = KEY_F0 + n
 
 template COLOR_PAIR*(n: expr): expr = 
-  ((cast[cunsignedlong]((n)) shl COLOR_SHIFT) and A_COLOR)
+  ((cunsignedlong(n) shl COLOR_SHIFT) and A_COLOR)
 
 template PAIR_NUMBER*(n: expr): expr = 
   (((n) and A_COLOR) shr COLOR_SHIFT)
diff --git a/lib/wrappers/readline/readline.nim b/lib/wrappers/readline/readline.nim
index 1f0dd564f..bbe416534 100644
--- a/lib/wrappers/readline/readline.nim
+++ b/lib/wrappers/readline/readline.nim
@@ -29,8 +29,8 @@ elif defined(macosx):
 else: 
   const 
     readlineDll* = "libreadline.so.6(|.0)"
-##  mangle "'TCommandFunc'" TCommandFunc
-##  mangle TvcpFunc TvcpFunc
+#  mangle "'TCommandFunc'" TCommandFunc
+#  mangle TvcpFunc TvcpFunc
 
 import rltypedefs
 
diff --git a/readme.md b/readme.md
index 38e04233f..e8c081d4e 100644
--- a/readme.md
+++ b/readme.md
@@ -39,8 +39,9 @@ $ bin/nimrod c koch
 $ ./koch boot -d:release
 ```
 
-``koch install [dir]`` may then be used to install Nimrod, or you
-can simply add it to your PATH.
+``koch install [dir]`` may then be used to install Nimrod, or you can simply
+add it to your PATH. More ``koch`` related options are documented in
+[doc/koch.txt](doc/koch.txt).
 
 The above steps can be performed on Windows in a similar fashion, the
 ``build.bat`` and ``build64.bat`` (for x86_64 systems) are provided to be used
diff --git a/readme.txt b/readme.txt
index 3eaef0b35..3f6aef05c 100644
--- a/readme.txt
+++ b/readme.txt
@@ -39,8 +39,9 @@ $ bin/nimrod c koch
 $ ./koch boot -d:release
 ```
 
-``koch install [dir]`` may then be used to install Nimrod, or you
-can simply add it to your PATH.
+``koch install [dir]`` may then be used to install Nimrod, or you can simply
+add it to your PATH. More ``koch`` related options are documented in
+[doc/koch.txt](doc/koch.txt).
 
 The above steps can be performed on Windows in a similar fashion, the
 ``build.bat`` and ``build64.bat`` (for x86_64 systems) are provided to be used
diff --git a/tests/async/tasyncawait.nim b/tests/async/tasyncawait.nim
index ffceeaee6..2d65db4bd 100644
--- a/tests/async/tasyncawait.nim
+++ b/tests/async/tasyncawait.nim
@@ -23,19 +23,19 @@ proc launchSwarm(port: TPort) {.async.} =
     await connect(sock, "localhost", port)
     when true:
       await sendMessages(sock)
-      close(sock)
+      closeSocket(sock)
     else:
       # Issue #932: https://github.com/Araq/Nimrod/issues/932
       var msgFut = sendMessages(sock)
       msgFut.callback =
         proc () =
-          close(sock)
+          closeSocket(sock)
 
 proc readMessages(client: TAsyncFD) {.async.} =
   while true:
     var line = await recvLine(client)
     if line == "":
-      close(client)
+      closeSocket(client)
       clientCount.inc
       break
     else:
@@ -61,11 +61,11 @@ proc createServer(port: TPort) {.async.} =
   discard server.TSocketHandle.listen()
   while true:
     var client = await accept(server)
-    readMessages(client)
+    asyncCheck readMessages(client)
     # TODO: Test: readMessages(disp, await disp.accept(server))
 
-createServer(TPort(10335))
-launchSwarm(TPort(10335))
+asyncCheck createServer(TPort(10335))
+asyncCheck launchSwarm(TPort(10335))
 while true:
   poll()
   if clientCount == swarmSize: break
diff --git a/tests/async/tasyncdiscard.nim b/tests/async/tasyncdiscard.nim
index 48d8a8c4d..966851acc 100644
--- a/tests/async/tasyncdiscard.nim
+++ b/tests/async/tasyncdiscard.nim
@@ -36,4 +36,4 @@ proc main {.async.} =
   discard await g()
   echo 6
 
-main()
+asyncCheck main()
diff --git a/tests/async/tnestedpfuturetypeparam.nim b/tests/async/tnestedpfuturetypeparam.nim
index d0d87e567..1db442170 100644
--- a/tests/async/tnestedpfuturetypeparam.nim
+++ b/tests/async/tnestedpfuturetypeparam.nim
@@ -5,4 +5,4 @@ proc main {.async.} =
     await newAsyncSocket().connect("www.google.com", TPort(80))
   let x = await f()
 
-main()
+asyncCheck main()
diff --git a/tests/casestmt/tcase_arrayconstr.nim b/tests/casestmt/tcase_arrayconstr.nim
new file mode 100644
index 000000000..cd7156600
--- /dev/null
+++ b/tests/casestmt/tcase_arrayconstr.nim
@@ -0,0 +1,19 @@
+discard """
+  output: '''Not found!
+Found!'''
+"""
+
+const
+  md_extension = [".md", ".markdown"]
+
+proc test(ext: string) =
+  case ext
+  of ".txt", md_extension:
+    echo "Found!"
+  else:
+    echo "Not found!"
+
+test(".something")
+# ensure it's not evaluated at compile-time:
+var foo = ".markdown"
+test(foo)
diff --git a/tests/closure/tclosure.nim b/tests/closure/tclosure.nim
index d9e7b8ee4..764aaa97d 100644
--- a/tests/closure/tclosure.nim
+++ b/tests/closure/tclosure.nim
@@ -1,7 +1,6 @@
 discard """
   file: "tclosure.nim"
-  output: "2 4 6 8 10"
-  disabled: true
+  output: "1 3 6 11 20"
 """
 # Test the closure implementation
 
@@ -30,7 +29,8 @@ proc testA() =
 testA()
 
 myData.each do (x: int):
-  write(stout, x)
+  write(stdout, x)
+  write(stdout, " ")
 
 #OUT 2 4 6 8 10
 
@@ -42,6 +42,6 @@ type
 proc getInterf(): ITest =
   var shared: int
   
-  return (setter: proc (x) = shared = x,
+  return (setter: proc (x: int) = shared = x,
           getter: proc (): int = return shared)
 
diff --git a/tests/closure/tjester.nim b/tests/closure/tjester.nim
new file mode 100644
index 000000000..48e5186f0
--- /dev/null
+++ b/tests/closure/tjester.nim
@@ -0,0 +1,32 @@
+discard """
+  output: '''baro0'''
+"""
+
+type
+  Future[T] = ref object
+    data: T
+    callback: proc () {.closure.}
+
+proc cbOuter(response: string) {.closure, discardable.} =
+  iterator cbIter(): Future[int] {.closure.} =
+    for i in 0..7:
+      proc foo(): int =
+        iterator fooIter(): Future[int] {.closure.} =
+          echo response, i
+          yield Future[int](data: 17)
+        var iterVar = fooIter
+        iterVar().data
+      yield Future[int](data: foo())
+      
+  var iterVar2 = cbIter
+  proc cb2() {.closure.} =
+    try:
+      if not finished(iterVar2):
+        let next = iterVar2()
+        if next != nil:
+          next.callback = cb2
+    except:
+      echo "WTF"
+  cb2()
+
+cbOuter "baro"
diff --git a/tests/closure/tnestedclosure.nim b/tests/closure/tnestedclosure.nim
new file mode 100644
index 000000000..c8f1e231b
--- /dev/null
+++ b/tests/closure/tnestedclosure.nim
@@ -0,0 +1,51 @@
+discard """
+  output: '''foo88
+23 24foo 88
+foo88
+23 24foo 88
+hohoho'''
+"""
+
+# test nested closure
+proc main(param: int) =
+  var foo = 23
+  proc outer(outerParam: string) =
+    var outerVar = 88
+    echo outerParam, outerVar
+    proc inner() =
+      block Test:
+        echo foo, " ", param, outerParam, " ", outerVar
+    inner()
+  outer("foo")
+
+# test simple closure within dummy 'main':
+proc dummy =
+  proc main2(param: int) =
+    var foo = 23
+    proc outer(outerParam: string) =
+      var outerVar = 88
+      echo outerParam, outerVar
+      proc inner() =
+        block Test:
+          echo foo, " ", param, outerParam, " ", outerVar
+      inner()
+    outer("foo")
+  main2(24)
+
+dummy()
+
+main(24)
+
+# Jester + async triggered this bug:
+proc cbOuter() =
+  var response = "hohoho"
+  block:
+    proc cbIter() =
+      block:
+        proc fooIter() =
+          echo response
+        fooIter()
+        
+    cbIter()
+
+cbOuter()
diff --git a/tests/exprs/tstmtexprs.nim b/tests/exprs/tstmtexprs.nim
index ed0066287..d6b827b6d 100644
--- a/tests/exprs/tstmtexprs.nim
+++ b/tests/exprs/tstmtexprs.nim
@@ -4,7 +4,8 @@ discard """
 1244
 6
 abcdefghijklmnopqrstuvwxyz
-145 23'''
+145 23
+3'''
 """
 
 import strutils
@@ -92,3 +93,32 @@ proc parseResponse(): PJsonNode =
 #bug #992
 var se = @[1,2]
 let b = (se[1] = 1; 1)
+
+
+# bug #1161
+
+type
+  PFooBase = ref object of PObject
+    field: int
+
+  PFoo[T] = ref object of PFooBase
+    field2: T
+
+var testIf =
+  if true:
+    2
+  else:
+    3
+
+var testCase =
+  case 8
+  of 8: 9
+  else: 10
+
+var testTry =
+  try:
+    PFoo[string](field: 3, field2: "asfasf")
+  except:
+    PFooBase(field: 5)
+
+echo(testTry.field)
diff --git a/tests/generics/mdotlookup.nim b/tests/generics/mdotlookup.nim
new file mode 100644
index 000000000..7a5e0ccbf
--- /dev/null
+++ b/tests/generics/mdotlookup.nim
@@ -0,0 +1,8 @@
+proc baz(o: any): int = 5 # if bar is exported, it works
+
+type MyObj = object
+  x: int
+
+proc foo*(b: any) =
+  var o: MyObj
+  echo b.baz, " ", o.x.baz, " ", b.baz()
diff --git a/tests/generics/tdotlookup.nim b/tests/generics/tdotlookup.nim
new file mode 100644
index 000000000..b886cd8c9
--- /dev/null
+++ b/tests/generics/tdotlookup.nim
@@ -0,0 +1,7 @@
+discard """
+  output: '''5 5 5'''
+"""
+
+import mdotlookup
+
+foo(7)
diff --git a/tests/macros/tbindsym.nim b/tests/macros/tbindsym.nim
new file mode 100644
index 000000000..e1e3b5112
--- /dev/null
+++ b/tests/macros/tbindsym.nim
@@ -0,0 +1,25 @@
+discard """
+  output: '''TFoo
+TBar'''
+"""
+
+# bug #1319
+
+import macros
+
+type
+  TTextKind = enum
+    TFoo, TBar
+
+macro test: stmt =
+  var x = @[TFoo, TBar]
+  result = newStmtList()
+  for i in x:
+    result.add newCall(newIdentNode("echo"),
+      case i
+      of TFoo:
+        bindSym("TFoo")
+      of TBar:
+        bindSym("TBar"))
+
+test()
diff --git a/tests/macros/tbugs.nim b/tests/macros/tbugs.nim
new file mode 100644
index 000000000..3db851dd1
--- /dev/null
+++ b/tests/macros/tbugs.nim
@@ -0,0 +1,90 @@
+discard """
+msg: '''a
+s
+d
+f
+TTaa
+TTaa
+TTaa
+TTaa
+true
+true
+nil'''
+
+output: '''test
+2'''
+"""
+
+type
+  Foo = object
+    s: char
+
+iterator test2(f: string): Foo =
+  for i in f:
+    yield Foo(s: i)
+
+macro test(): stmt =
+  for i in test2("asdf"):
+    echo i.s
+
+test()
+
+
+# bug 1297
+
+import macros
+
+type TType = tuple[s: string]
+
+macro echotest(): stmt =
+  var t: TType
+  t.s = ""
+  t.s.add("test")
+  result = newCall(newIdentNode("echo"), newStrLitNode(t.s))
+
+echotest()
+
+# bug #1103
+
+type 
+    Td = tuple
+        a:string
+        b:int
+
+proc get_data(d: Td) : string {.compileTime.} =
+    result = d.a # Works if a literal string is used here. 
+    # Bugs if line A or B is active. Works with C
+    result &= "aa"          # A
+    #result.add("aa")       # B
+    #result = result & "aa" # C
+
+macro m(s:static[Td]) : stmt =
+    echo get_data(s)
+    echo get_data(s)
+    result = newEmptyNode()
+
+const s=("TT", 3)
+m(s)
+m(s)
+
+# bug #933
+
+proc nilcheck(): PNimrodNode {.compileTime.} =
+  echo(result == nil) # true
+  echo(result.isNil) # true
+  echo(repr(result)) # nil
+
+macro testnilcheck(): stmt =
+  result = newNimNode(nnkStmtList)
+  discard nilcheck()
+
+testnilcheck()
+
+# bug #1323
+
+proc calc(): array[1, int] =
+  result[0].inc()
+  result[0].inc()
+
+const c = calc()
+echo c[0]
diff --git a/tests/macros/tdumptree.nim b/tests/macros/tdumptree.nim
index 5299a94e3..e5160b7ba 100644
--- a/tests/macros/tdumptree.nim
+++ b/tests/macros/tdumptree.nim
@@ -1,6 +1,5 @@
 discard """
-disabled: true
-output: '''StmtList
+msg: '''StmtList
   VarSection
     IdentDefs
       Ident !"x"
diff --git a/tests/manyloc/keineschweine/lib/gl.nim b/tests/manyloc/keineschweine/lib/gl.nim
new file mode 100644
index 000000000..9387b5bc9
--- /dev/null
+++ b/tests/manyloc/keineschweine/lib/gl.nim
@@ -0,0 +1,1536 @@
+#
+#
+#  Adaption of the delphi3d.net OpenGL units to FreePascal
+#  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              
+#******************************************************************************
+
+when defined(windows): 
+  {.push, callconv: stdcall.}
+else: 
+  {.push, callconv: cdecl.}
+when defined(windows): 
+  const 
+    dllname* = "opengl32.dll"
+elif defined(macosx): 
+  const 
+    dllname* = "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib"
+else: 
+  const 
+    dllname* = "libGL.so.1"
+type 
+  PGLenum* = ptr TGLenum
+  PGLboolean* = ptr TGLboolean
+  PGLbitfield* = ptr TGLbitfield
+  TGLbyte* = int8
+  PGLbyte* = ptr TGlbyte
+  PGLshort* = ptr TGLshort
+  PGLint* = ptr TGLint
+  PGLsizei* = ptr TGLsizei
+  PGLubyte* = ptr TGLubyte
+  PGLushort* = ptr TGLushort
+  PGLuint* = ptr TGLuint
+  PGLfloat* = ptr TGLfloat
+  PGLclampf* = ptr TGLclampf
+  PGLdouble* = ptr TGLdouble
+  PGLclampd* = ptr TGLclampd
+  PGLvoid* = Pointer
+  PPGLvoid* = ptr PGLvoid
+  TGLenum* = cint
+  TGLboolean* = bool
+  TGLbitfield* = cint
+  TGLshort* = int16
+  TGLint* = cint
+  TGLsizei* = int
+  TGLubyte* = int8
+  TGLushort* = int16
+  TGLuint* = cint
+  TGLfloat* = float32
+  TGLclampf* = float32
+  TGLdouble* = float
+  TGLclampd* = float
+
+const                         # Version
+  GL_VERSION_1_1* = 1         # AccumOp
+  constGL_ACCUM* = 0x00000100
+  GL_LOAD* = 0x00000101
+  GL_RETURN* = 0x00000102
+  GL_MULT* = 0x00000103
+  GL_ADD* = 0x00000104        # AlphaFunction
+  GL_NEVER* = 0x00000200
+  GL_LESS* = 0x00000201
+  GL_EQUAL* = 0x00000202
+  GL_LEQUAL* = 0x00000203
+  GL_GREATER* = 0x00000204
+  GL_NOTEQUAL* = 0x00000205
+  GL_GEQUAL* = 0x00000206
+  GL_ALWAYS* = 0x00000207     # AttribMask
+  GL_CURRENT_BIT* = 0x00000001
+  GL_POINT_BIT* = 0x00000002
+  GL_LINE_BIT* = 0x00000004
+  GL_POLYGON_BIT* = 0x00000008
+  GL_POLYGON_STIPPLE_BIT* = 0x00000010
+  GL_PIXEL_MODE_BIT* = 0x00000020
+  GL_LIGHTING_BIT* = 0x00000040
+  GL_FOG_BIT* = 0x00000080
+  GL_DEPTH_BUFFER_BIT* = 0x00000100
+  GL_ACCUM_BUFFER_BIT* = 0x00000200
+  GL_STENCIL_BUFFER_BIT* = 0x00000400
+  GL_VIEWPORT_BIT* = 0x00000800
+  GL_TRANSFORM_BIT* = 0x00001000
+  GL_ENABLE_BIT* = 0x00002000
+  GL_COLOR_BUFFER_BIT* = 0x00004000
+  GL_HINT_BIT* = 0x00008000
+  GL_EVAL_BIT* = 0x00010000
+  GL_LIST_BIT* = 0x00020000
+  GL_TEXTURE_BIT* = 0x00040000
+  GL_SCISSOR_BIT* = 0x00080000
+  GL_ALL_ATTRIB_BITS* = 0x000FFFFF # BeginMode
+  GL_POINTS* = 0x00000000
+  GL_LINES* = 0x00000001
+  GL_LINE_LOOP* = 0x00000002
+  GL_LINE_STRIP* = 0x00000003
+  GL_TRIANGLES* = 0x00000004
+  GL_TRIANGLE_STRIP* = 0x00000005
+  GL_TRIANGLE_FAN* = 0x00000006
+  GL_QUADS* = 0x00000007
+  GL_QUAD_STRIP* = 0x00000008
+  GL_POLYGON* = 0x00000009    # BlendingFactorDest
+  GL_ZERO* = 0
+  GL_ONE* = 1
+  GL_SRC_COLOR* = 0x00000300
+  GL_ONE_MINUS_SRC_COLOR* = 0x00000301
+  GL_SRC_ALPHA* = 0x00000302
+  GL_ONE_MINUS_SRC_ALPHA* = 0x00000303
+  GL_DST_ALPHA* = 0x00000304
+  GL_ONE_MINUS_DST_ALPHA* = 0x00000305 # BlendingFactorSrc
+                                       #      GL_ZERO
+                                       #      GL_ONE
+  GL_DST_COLOR* = 0x00000306
+  GL_ONE_MINUS_DST_COLOR* = 0x00000307
+  GL_SRC_ALPHA_SATURATE* = 0x00000308 #      GL_SRC_ALPHA
+                                      #      GL_ONE_MINUS_SRC_ALPHA
+                                      #      GL_DST_ALPHA
+                                      #      GL_ONE_MINUS_DST_ALPHA
+                                      # Boolean
+  GL_TRUE* = 1
+  GL_FALSE* = 0               # ClearBufferMask
+                              #      GL_COLOR_BUFFER_BIT
+                              #      GL_ACCUM_BUFFER_BIT
+                              #      GL_STENCIL_BUFFER_BIT
+                              #      GL_DEPTH_BUFFER_BIT
+                              # ClientArrayType
+                              #      GL_VERTEX_ARRAY
+                              #      GL_NORMAL_ARRAY
+                              #      GL_COLOR_ARRAY
+                              #      GL_INDEX_ARRAY
+                              #      GL_TEXTURE_COORD_ARRAY
+                              #      GL_EDGE_FLAG_ARRAY
+                              # ClipPlaneName
+  GL_CLIP_PLANE0* = 0x00003000
+  GL_CLIP_PLANE1* = 0x00003001
+  GL_CLIP_PLANE2* = 0x00003002
+  GL_CLIP_PLANE3* = 0x00003003
+  GL_CLIP_PLANE4* = 0x00003004
+  GL_CLIP_PLANE5* = 0x00003005 # ColorMaterialFace
+                               #      GL_FRONT
+                               #      GL_BACK
+                               #      GL_FRONT_AND_BACK
+                               # ColorMaterialParameter
+                               #      GL_AMBIENT
+                               #      GL_DIFFUSE
+                               #      GL_SPECULAR
+                               #      GL_EMISSION
+                               #      GL_AMBIENT_AND_DIFFUSE
+                               # ColorPointerType
+                               #      GL_BYTE
+                               #      GL_UNSIGNED_BYTE
+                               #      GL_SHORT
+                               #      GL_UNSIGNED_SHORT
+                               #      GL_INT
+                               #      GL_UNSIGNED_INT
+                               #      GL_FLOAT
+                               #      GL_DOUBLE
+                               # CullFaceMode
+                               #      GL_FRONT
+                               #      GL_BACK
+                               #      GL_FRONT_AND_BACK
+                               # DataType
+  GL_BYTE* = 0x00001400
+  GL_UNSIGNED_BYTE* = 0x00001401
+  GL_SHORT* = 0x00001402
+  GL_UNSIGNED_SHORT* = 0x00001403
+  GL_INT* = 0x00001404
+  GL_UNSIGNED_INT* = 0x00001405
+  GL_FLOAT* = 0x00001406
+  GL_2_BYTES* = 0x00001407
+  GL_3_BYTES* = 0x00001408
+  GL_4_BYTES* = 0x00001409
+  GL_DOUBLE* = 0x0000140A     # DepthFunction
+                              #      GL_NEVER
+                              #      GL_LESS
+                              #      GL_EQUAL
+                              #      GL_LEQUAL
+                              #      GL_GREATER
+                              #      GL_NOTEQUAL
+                              #      GL_GEQUAL
+                              #      GL_ALWAYS
+                              # DrawBufferMode
+  GL_NONE* = 0
+  GL_FRONT_LEFT* = 0x00000400
+  GL_FRONT_RIGHT* = 0x00000401
+  GL_BACK_LEFT* = 0x00000402
+  GL_BACK_RIGHT* = 0x00000403
+  GL_FRONT* = 0x00000404
+  GL_BACK* = 0x00000405
+  GL_LEFT* = 0x00000406
+  GL_RIGHT* = 0x00000407
+  GL_FRONT_AND_BACK* = 0x00000408
+  GL_AUX0* = 0x00000409
+  GL_AUX1* = 0x0000040A
+  GL_AUX2* = 0x0000040B
+  GL_AUX3* = 0x0000040C       # Enable
+                              #      GL_FOG
+                              #      GL_LIGHTING
+                              #      GL_TEXTURE_1D
+                              #      GL_TEXTURE_2D
+                              #      GL_LINE_STIPPLE
+                              #      GL_POLYGON_STIPPLE
+                              #      GL_CULL_FACE
+                              #      GL_ALPHA_TEST
+                              #      GL_BLEND
+                              #      GL_INDEX_LOGIC_OP
+                              #      GL_COLOR_LOGIC_OP
+                              #      GL_DITHER
+                              #      GL_STENCIL_TEST
+                              #      GL_DEPTH_TEST
+                              #      GL_CLIP_PLANE0
+                              #      GL_CLIP_PLANE1
+                              #      GL_CLIP_PLANE2
+                              #      GL_CLIP_PLANE3
+                              #      GL_CLIP_PLANE4
+                              #      GL_CLIP_PLANE5
+                              #      GL_LIGHT0
+                              #      GL_LIGHT1
+                              #      GL_LIGHT2
+                              #      GL_LIGHT3
+                              #      GL_LIGHT4
+                              #      GL_LIGHT5
+                              #      GL_LIGHT6
+                              #      GL_LIGHT7
+                              #      GL_TEXTURE_GEN_S
+                              #      GL_TEXTURE_GEN_T
+                              #      GL_TEXTURE_GEN_R
+                              #      GL_TEXTURE_GEN_Q
+                              #      GL_MAP1_VERTEX_3
+                              #      GL_MAP1_VERTEX_4
+                              #      GL_MAP1_COLOR_4
+                              #      GL_MAP1_INDEX
+                              #      GL_MAP1_NORMAL
+                              #      GL_MAP1_TEXTURE_COORD_1
+                              #      GL_MAP1_TEXTURE_COORD_2
+                              #      GL_MAP1_TEXTURE_COORD_3
+                              #      GL_MAP1_TEXTURE_COORD_4
+                              #      GL_MAP2_VERTEX_3
+                              #      GL_MAP2_VERTEX_4
+                              #      GL_MAP2_COLOR_4
+                              #      GL_MAP2_INDEX
+                              #      GL_MAP2_NORMAL
+                              #      GL_MAP2_TEXTURE_COORD_1
+                              #      GL_MAP2_TEXTURE_COORD_2
+                              #      GL_MAP2_TEXTURE_COORD_3
+                              #      GL_MAP2_TEXTURE_COORD_4
+                              #      GL_POINT_SMOOTH
+                              #      GL_LINE_SMOOTH
+                              #      GL_POLYGON_SMOOTH
+                              #      GL_SCISSOR_TEST
+                              #      GL_COLOR_MATERIAL
+                              #      GL_NORMALIZE
+                              #      GL_AUTO_NORMAL
+                              #      GL_VERTEX_ARRAY
+                              #      GL_NORMAL_ARRAY
+                              #      GL_COLOR_ARRAY
+                              #      GL_INDEX_ARRAY
+                              #      GL_TEXTURE_COORD_ARRAY
+                              #      GL_EDGE_FLAG_ARRAY
+                              #      GL_POLYGON_OFFSET_POINT
+                              #      GL_POLYGON_OFFSET_LINE
+                              #      GL_POLYGON_OFFSET_FILL
+                              # ErrorCode
+  GL_NO_ERROR* = 0
+  GL_INVALID_ENUM* = 0x00000500
+  GL_INVALID_VALUE* = 0x00000501
+  GL_INVALID_OPERATION* = 0x00000502
+  GL_STACK_OVERFLOW* = 0x00000503
+  GL_STACK_UNDERFLOW* = 0x00000504
+  GL_OUT_OF_MEMORY* = 0x00000505 # FeedBackMode
+  GL_2D* = 0x00000600
+  GL_3D* = 0x00000601
+  GL_3D_COLOR* = 0x00000602
+  GL_3D_COLOR_TEXTURE* = 0x00000603
+  GL_4D_COLOR_TEXTURE* = 0x00000604 # FeedBackToken
+  GL_PASS_THROUGH_TOKEN* = 0x00000700
+  GL_POINT_TOKEN* = 0x00000701
+  GL_LINE_TOKEN* = 0x00000702
+  GL_POLYGON_TOKEN* = 0x00000703
+  GL_BITMAP_TOKEN* = 0x00000704
+  GL_DRAW_PIXEL_TOKEN* = 0x00000705
+  GL_COPY_PIXEL_TOKEN* = 0x00000706
+  GL_LINE_RESET_TOKEN* = 0x00000707 # FogMode
+                                    #      GL_LINEAR
+  GL_EXP* = 0x00000800
+  GL_EXP2* = 0x00000801       # FogParameter
+                              #      GL_FOG_COLOR
+                              #      GL_FOG_DENSITY
+                              #      GL_FOG_END
+                              #      GL_FOG_INDEX
+                              #      GL_FOG_MODE
+                              #      GL_FOG_START
+                              # FrontFaceDirection
+  GL_CW* = 0x00000900
+  GL_CCW* = 0x00000901        # GetMapTarget
+  GL_COEFF* = 0x00000A00
+  GL_ORDER* = 0x00000A01
+  GL_DOMAIN* = 0x00000A02     # GetPixelMap
+                              #      GL_PIXEL_MAP_I_TO_I
+                              #      GL_PIXEL_MAP_S_TO_S
+                              #      GL_PIXEL_MAP_I_TO_R
+                              #      GL_PIXEL_MAP_I_TO_G
+                              #      GL_PIXEL_MAP_I_TO_B
+                              #      GL_PIXEL_MAP_I_TO_A
+                              #      GL_PIXEL_MAP_R_TO_R
+                              #      GL_PIXEL_MAP_G_TO_G
+                              #      GL_PIXEL_MAP_B_TO_B
+                              #      GL_PIXEL_MAP_A_TO_A
+                              # GetPointerTarget
+                              #      GL_VERTEX_ARRAY_POINTER
+                              #      GL_NORMAL_ARRAY_POINTER
+                              #      GL_COLOR_ARRAY_POINTER
+                              #      GL_INDEX_ARRAY_POINTER
+                              #      GL_TEXTURE_COORD_ARRAY_POINTER
+                              #      GL_EDGE_FLAG_ARRAY_POINTER
+                              # GetTarget
+  GL_CURRENT_COLOR* = 0x00000B00
+  GL_CURRENT_INDEX* = 0x00000B01
+  GL_CURRENT_NORMAL* = 0x00000B02
+  GL_CURRENT_TEXTURE_COORDS* = 0x00000B03
+  GL_CURRENT_RASTER_COLOR* = 0x00000B04
+  GL_CURRENT_RASTER_INDEX* = 0x00000B05
+  GL_CURRENT_RASTER_TEXTURE_COORDS* = 0x00000B06
+  GL_CURRENT_RASTER_POSITION* = 0x00000B07
+  GL_CURRENT_RASTER_POSITION_VALID* = 0x00000B08
+  GL_CURRENT_RASTER_DISTANCE* = 0x00000B09
+  GL_POINT_SMOOTH* = 0x00000B10
+  constGL_POINT_SIZE* = 0x00000B11
+  GL_POINT_SIZE_RANGE* = 0x00000B12
+  GL_POINT_SIZE_GRANULARITY* = 0x00000B13
+  GL_LINE_SMOOTH* = 0x00000B20
+  constGL_LINE_WIDTH* = 0x00000B21
+  GL_LINE_WIDTH_RANGE* = 0x00000B22
+  GL_LINE_WIDTH_GRANULARITY* = 0x00000B23
+  constGL_LINE_STIPPLE* = 0x00000B24
+  GL_LINE_STIPPLE_PATTERN* = 0x00000B25
+  GL_LINE_STIPPLE_REPEAT* = 0x00000B26
+  GL_LIST_MODE* = 0x00000B30
+  GL_MAX_LIST_NESTING* = 0x00000B31
+  constGL_LIST_BASE* = 0x00000B32
+  GL_LIST_INDEX* = 0x00000B33
+  constGL_POLYGON_MODE* = 0x00000B40
+  GL_POLYGON_SMOOTH* = 0x00000B41
+  constGL_POLYGON_STIPPLE* = 0x00000B42
+  constGL_EDGE_FLAG* = 0x00000B43
+  constGL_CULL_FACE* = 0x00000B44
+  GL_CULL_FACE_MODE* = 0x00000B45
+  constGL_FRONT_FACE* = 0x00000B46
+  GL_LIGHTING* = 0x00000B50
+  GL_LIGHT_MODEL_LOCAL_VIEWER* = 0x00000B51
+  GL_LIGHT_MODEL_TWO_SIDE* = 0x00000B52
+  GL_LIGHT_MODEL_AMBIENT* = 0x00000B53
+  constGL_SHADE_MODEL* = 0x00000B54
+  GL_COLOR_MATERIAL_FACE* = 0x00000B55
+  GL_COLOR_MATERIAL_PARAMETER* = 0x00000B56
+  constGL_COLOR_MATERIAL* = 0x00000B57
+  GL_FOG* = 0x00000B60
+  GL_FOG_INDEX* = 0x00000B61
+  GL_FOG_DENSITY* = 0x00000B62
+  GL_FOG_START* = 0x00000B63
+  GL_FOG_END* = 0x00000B64
+  GL_FOG_MODE* = 0x00000B65
+  GL_FOG_COLOR* = 0x00000B66
+  constGL_DEPTH_RANGE* = 0x00000B70
+  GL_DEPTH_TEST* = 0x00000B71
+  GL_DEPTH_WRITEMASK* = 0x00000B72
+  GL_DEPTH_CLEAR_VALUE* = 0x00000B73
+  constGL_DEPTH_FUNC* = 0x00000B74
+  GL_ACCUM_CLEAR_VALUE* = 0x00000B80
+  GL_STENCIL_TEST* = 0x00000B90
+  GL_STENCIL_CLEAR_VALUE* = 0x00000B91
+  constGL_STENCIL_FUNC* = 0x00000B92
+  GL_STENCIL_VALUE_MASK* = 0x00000B93
+  GL_STENCIL_FAIL* = 0x00000B94
+  GL_STENCIL_PASS_DEPTH_FAIL* = 0x00000B95
+  GL_STENCIL_PASS_DEPTH_PASS* = 0x00000B96
+  GL_STENCIL_REF* = 0x00000B97
+  GL_STENCIL_WRITEMASK* = 0x00000B98
+  constGL_MATRIX_MODE* = 0x00000BA0
+  GL_NORMALIZE* = 0x00000BA1
+  constGL_VIEWPORT* = 0x00000BA2
+  GL_MODELVIEW_STACK_DEPTH* = 0x00000BA3
+  GL_PROJECTION_STACK_DEPTH* = 0x00000BA4
+  GL_TEXTURE_STACK_DEPTH* = 0x00000BA5
+  GL_MODELVIEW_MATRIX* = 0x00000BA6
+  GL_PROJECTION_MATRIX* = 0x00000BA7
+  GL_TEXTURE_MATRIX* = 0x00000BA8
+  GL_ATTRIB_STACK_DEPTH* = 0x00000BB0
+  GL_CLIENT_ATTRIB_STACK_DEPTH* = 0x00000BB1
+  GL_ALPHA_TEST* = 0x00000BC0
+  GL_ALPHA_TEST_FUNC* = 0x00000BC1
+  GL_ALPHA_TEST_REF* = 0x00000BC2
+  GL_DITHER* = 0x00000BD0
+  GL_BLEND_DST* = 0x00000BE0
+  GL_BLEND_SRC* = 0x00000BE1
+  GL_BLEND* = 0x00000BE2
+  GL_LOGIC_OP_MODE* = 0x00000BF0
+  GL_INDEX_LOGIC_OP* = 0x00000BF1
+  GL_COLOR_LOGIC_OP* = 0x00000BF2
+  GL_AUX_BUFFERS* = 0x00000C00
+  constGL_DRAW_BUFFER* = 0x00000C01
+  constGL_READ_BUFFER* = 0x00000C02
+  GL_SCISSOR_BOX* = 0x00000C10
+  GL_SCISSOR_TEST* = 0x00000C11
+  GL_INDEX_CLEAR_VALUE* = 0x00000C20
+  GL_INDEX_WRITEMASK* = 0x00000C21
+  GL_COLOR_CLEAR_VALUE* = 0x00000C22
+  GL_COLOR_WRITEMASK* = 0x00000C23
+  GL_INDEX_MODE* = 0x00000C30
+  GL_RGBA_MODE* = 0x00000C31
+  GL_DOUBLEBUFFER* = 0x00000C32
+  GL_STEREO* = 0x00000C33
+  constGL_RENDER_MODE* = 0x00000C40
+  GL_PERSPECTIVE_CORRECTION_HINT* = 0x00000C50
+  GL_POINT_SMOOTH_HINT* = 0x00000C51
+  GL_LINE_SMOOTH_HINT* = 0x00000C52
+  GL_POLYGON_SMOOTH_HINT* = 0x00000C53
+  GL_FOG_HINT* = 0x00000C54
+  GL_TEXTURE_GEN_S* = 0x00000C60
+  GL_TEXTURE_GEN_T* = 0x00000C61
+  GL_TEXTURE_GEN_R* = 0x00000C62
+  GL_TEXTURE_GEN_Q* = 0x00000C63
+  GL_PIXEL_MAP_I_TO_I* = 0x00000C70
+  GL_PIXEL_MAP_S_TO_S* = 0x00000C71
+  GL_PIXEL_MAP_I_TO_R* = 0x00000C72
+  GL_PIXEL_MAP_I_TO_G* = 0x00000C73
+  GL_PIXEL_MAP_I_TO_B* = 0x00000C74
+  GL_PIXEL_MAP_I_TO_A* = 0x00000C75
+  GL_PIXEL_MAP_R_TO_R* = 0x00000C76
+  GL_PIXEL_MAP_G_TO_G* = 0x00000C77
+  GL_PIXEL_MAP_B_TO_B* = 0x00000C78
+  GL_PIXEL_MAP_A_TO_A* = 0x00000C79
+  GL_PIXEL_MAP_I_TO_I_SIZE* = 0x00000CB0
+  GL_PIXEL_MAP_S_TO_S_SIZE* = 0x00000CB1
+  GL_PIXEL_MAP_I_TO_R_SIZE* = 0x00000CB2
+  GL_PIXEL_MAP_I_TO_G_SIZE* = 0x00000CB3
+  GL_PIXEL_MAP_I_TO_B_SIZE* = 0x00000CB4
+  GL_PIXEL_MAP_I_TO_A_SIZE* = 0x00000CB5
+  GL_PIXEL_MAP_R_TO_R_SIZE* = 0x00000CB6
+  GL_PIXEL_MAP_G_TO_G_SIZE* = 0x00000CB7
+  GL_PIXEL_MAP_B_TO_B_SIZE* = 0x00000CB8
+  GL_PIXEL_MAP_A_TO_A_SIZE* = 0x00000CB9
+  GL_UNPACK_SWAP_BYTES* = 0x00000CF0
+  GL_UNPACK_LSB_FIRST* = 0x00000CF1
+  GL_UNPACK_ROW_LENGTH* = 0x00000CF2
+  GL_UNPACK_SKIP_ROWS* = 0x00000CF3
+  GL_UNPACK_SKIP_PIXELS* = 0x00000CF4
+  GL_UNPACK_ALIGNMENT* = 0x00000CF5
+  GL_PACK_SWAP_BYTES* = 0x00000D00
+  GL_PACK_LSB_FIRST* = 0x00000D01
+  GL_PACK_ROW_LENGTH* = 0x00000D02
+  GL_PACK_SKIP_ROWS* = 0x00000D03
+  GL_PACK_SKIP_PIXELS* = 0x00000D04
+  GL_PACK_ALIGNMENT* = 0x00000D05
+  GL_MAP_COLOR* = 0x00000D10
+  GL_MAP_STENCIL* = 0x00000D11
+  GL_INDEX_SHIFT* = 0x00000D12
+  GL_INDEX_OFFSET* = 0x00000D13
+  GL_RED_SCALE* = 0x00000D14
+  GL_RED_BIAS* = 0x00000D15
+  GL_ZOOM_X* = 0x00000D16
+  GL_ZOOM_Y* = 0x00000D17
+  GL_GREEN_SCALE* = 0x00000D18
+  GL_GREEN_BIAS* = 0x00000D19
+  GL_BLUE_SCALE* = 0x00000D1A
+  GL_BLUE_BIAS* = 0x00000D1B
+  GL_ALPHA_SCALE* = 0x00000D1C
+  GL_ALPHA_BIAS* = 0x00000D1D
+  GL_DEPTH_SCALE* = 0x00000D1E
+  GL_DEPTH_BIAS* = 0x00000D1F
+  GL_MAX_EVAL_ORDER* = 0x00000D30
+  GL_MAX_LIGHTS* = 0x00000D31
+  GL_MAX_CLIP_PLANES* = 0x00000D32
+  GL_MAX_TEXTURE_SIZE* = 0x00000D33
+  GL_MAX_PIXEL_MAP_TABLE* = 0x00000D34
+  GL_MAX_ATTRIB_STACK_DEPTH* = 0x00000D35
+  GL_MAX_MODELVIEW_STACK_DEPTH* = 0x00000D36
+  GL_MAX_NAME_STACK_DEPTH* = 0x00000D37
+  GL_MAX_PROJECTION_STACK_DEPTH* = 0x00000D38
+  GL_MAX_TEXTURE_STACK_DEPTH* = 0x00000D39
+  GL_MAX_VIEWPORT_DIMS* = 0x00000D3A
+  GL_MAX_CLIENT_ATTRIB_STACK_DEPTH* = 0x00000D3B
+  GL_SUBPIXEL_BITS* = 0x00000D50
+  GL_INDEX_BITS* = 0x00000D51
+  GL_RED_BITS* = 0x00000D52
+  GL_GREEN_BITS* = 0x00000D53
+  GL_BLUE_BITS* = 0x00000D54
+  GL_ALPHA_BITS* = 0x00000D55
+  GL_DEPTH_BITS* = 0x00000D56
+  GL_STENCIL_BITS* = 0x00000D57
+  GL_ACCUM_RED_BITS* = 0x00000D58
+  GL_ACCUM_GREEN_BITS* = 0x00000D59
+  GL_ACCUM_BLUE_BITS* = 0x00000D5A
+  GL_ACCUM_ALPHA_BITS* = 0x00000D5B
+  GL_NAME_STACK_DEPTH* = 0x00000D70
+  GL_AUTO_NORMAL* = 0x00000D80
+  GL_MAP1_COLOR_4* = 0x00000D90
+  GL_MAP1_INDEX* = 0x00000D91
+  GL_MAP1_NORMAL* = 0x00000D92
+  GL_MAP1_TEXTURE_COORD_1* = 0x00000D93
+  GL_MAP1_TEXTURE_COORD_2* = 0x00000D94
+  GL_MAP1_TEXTURE_COORD_3* = 0x00000D95
+  GL_MAP1_TEXTURE_COORD_4* = 0x00000D96
+  GL_MAP1_VERTEX_3* = 0x00000D97
+  GL_MAP1_VERTEX_4* = 0x00000D98
+  GL_MAP2_COLOR_4* = 0x00000DB0
+  GL_MAP2_INDEX* = 0x00000DB1
+  GL_MAP2_NORMAL* = 0x00000DB2
+  GL_MAP2_TEXTURE_COORD_1* = 0x00000DB3
+  GL_MAP2_TEXTURE_COORD_2* = 0x00000DB4
+  GL_MAP2_TEXTURE_COORD_3* = 0x00000DB5
+  GL_MAP2_TEXTURE_COORD_4* = 0x00000DB6
+  GL_MAP2_VERTEX_3* = 0x00000DB7
+  GL_MAP2_VERTEX_4* = 0x00000DB8
+  GL_MAP1_GRID_DOMAIN* = 0x00000DD0
+  GL_MAP1_GRID_SEGMENTS* = 0x00000DD1
+  GL_MAP2_GRID_DOMAIN* = 0x00000DD2
+  GL_MAP2_GRID_SEGMENTS* = 0x00000DD3
+  GL_TEXTURE_1D* = 0x00000DE0
+  GL_TEXTURE_2D* = 0x00000DE1
+  GL_FEEDBACK_BUFFER_POINTER* = 0x00000DF0
+  GL_FEEDBACK_BUFFER_SIZE* = 0x00000DF1
+  GL_FEEDBACK_BUFFER_TYPE* = 0x00000DF2
+  GL_SELECTION_BUFFER_POINTER* = 0x00000DF3
+  GL_SELECTION_BUFFER_SIZE* = 0x00000DF4 #      GL_TEXTURE_BINDING_1D
+                                         #      GL_TEXTURE_BINDING_2D
+                                         #      GL_VERTEX_ARRAY
+                                         #      GL_NORMAL_ARRAY
+                                         #      GL_COLOR_ARRAY
+                                         #      GL_INDEX_ARRAY
+                                         #      GL_TEXTURE_COORD_ARRAY
+                                         #      GL_EDGE_FLAG_ARRAY
+                                         #      GL_VERTEX_ARRAY_SIZE
+                                         #      GL_VERTEX_ARRAY_TYPE
+                                         #      GL_VERTEX_ARRAY_STRIDE
+                                         #      GL_NORMAL_ARRAY_TYPE
+                                         #      GL_NORMAL_ARRAY_STRIDE
+                                         #      GL_COLOR_ARRAY_SIZE
+                                         #      GL_COLOR_ARRAY_TYPE
+                                         #      GL_COLOR_ARRAY_STRIDE
+                                         #      GL_INDEX_ARRAY_TYPE
+                                         #      GL_INDEX_ARRAY_STRIDE
+                                         #      GL_TEXTURE_COORD_ARRAY_SIZE
+                                         #      GL_TEXTURE_COORD_ARRAY_TYPE
+                                         #      GL_TEXTURE_COORD_ARRAY_STRIDE
+                                         #      GL_EDGE_FLAG_ARRAY_STRIDE
+                                         #      GL_POLYGON_OFFSET_FACTOR
+                                         #      GL_POLYGON_OFFSET_UNITS
+                                         # GetTextureParameter
+                                         #      GL_TEXTURE_MAG_FILTER
+                                         #      GL_TEXTURE_MIN_FILTER
+                                         #      GL_TEXTURE_WRAP_S
+                                         #      GL_TEXTURE_WRAP_T
+  GL_TEXTURE_WIDTH* = 0x00001000
+  GL_TEXTURE_HEIGHT* = 0x00001001
+  GL_TEXTURE_INTERNAL_FORMAT* = 0x00001003
+  GL_TEXTURE_BORDER_COLOR* = 0x00001004
+  GL_TEXTURE_BORDER* = 0x00001005 #      GL_TEXTURE_RED_SIZE
+                                  #      GL_TEXTURE_GREEN_SIZE
+                                  #      GL_TEXTURE_BLUE_SIZE
+                                  #      GL_TEXTURE_ALPHA_SIZE
+                                  #      GL_TEXTURE_LUMINANCE_SIZE
+                                  #      GL_TEXTURE_INTENSITY_SIZE
+                                  #      GL_TEXTURE_PRIORITY
+                                  #      GL_TEXTURE_RESIDENT
+                                  # HintMode
+  GL_DONT_CARE* = 0x00001100
+  GL_FASTEST* = 0x00001101
+  GL_NICEST* = 0x00001102     # HintTarget
+                              #      GL_PERSPECTIVE_CORRECTION_HINT
+                              #      GL_POINT_SMOOTH_HINT
+                              #      GL_LINE_SMOOTH_HINT
+                              #      GL_POLYGON_SMOOTH_HINT
+                              #      GL_FOG_HINT
+                              # IndexPointerType
+                              #      GL_SHORT
+                              #      GL_INT
+                              #      GL_FLOAT
+                              #      GL_DOUBLE
+                              # LightModelParameter
+                              #      GL_LIGHT_MODEL_AMBIENT
+                              #      GL_LIGHT_MODEL_LOCAL_VIEWER
+                              #      GL_LIGHT_MODEL_TWO_SIDE
+                              # LightName
+  GL_LIGHT0* = 0x00004000
+  GL_LIGHT1* = 0x00004001
+  GL_LIGHT2* = 0x00004002
+  GL_LIGHT3* = 0x00004003
+  GL_LIGHT4* = 0x00004004
+  GL_LIGHT5* = 0x00004005
+  GL_LIGHT6* = 0x00004006
+  GL_LIGHT7* = 0x00004007     # LightParameter
+  GL_AMBIENT* = 0x00001200
+  GL_DIFFUSE* = 0x00001201
+  GL_SPECULAR* = 0x00001202
+  GL_POSITION* = 0x00001203
+  GL_SPOT_DIRECTION* = 0x00001204
+  GL_SPOT_EXPONENT* = 0x00001205
+  GL_SPOT_CUTOFF* = 0x00001206
+  GL_CONSTANT_ATTENUATION* = 0x00001207
+  GL_LINEAR_ATTENUATION* = 0x00001208
+  GL_QUADRATIC_ATTENUATION* = 0x00001209 # InterleavedArrays
+                                         #      GL_V2F
+                                         #      GL_V3F
+                                         #      GL_C4UB_V2F
+                                         #      GL_C4UB_V3F
+                                         #      GL_C3F_V3F
+                                         #      GL_N3F_V3F
+                                         #      GL_C4F_N3F_V3F
+                                         #      GL_T2F_V3F
+                                         #      GL_T4F_V4F
+                                         #      GL_T2F_C4UB_V3F
+                                         #      GL_T2F_C3F_V3F
+                                         #      GL_T2F_N3F_V3F
+                                         #      GL_T2F_C4F_N3F_V3F
+                                         #      GL_T4F_C4F_N3F_V4F
+                                         # ListMode
+  GL_COMPILE* = 0x00001300
+  GL_COMPILE_AND_EXECUTE* = 0x00001301 # ListNameType
+                                       #      GL_BYTE
+                                       #      GL_UNSIGNED_BYTE
+                                       #      GL_SHORT
+                                       #      GL_UNSIGNED_SHORT
+                                       #      GL_INT
+                                       #      GL_UNSIGNED_INT
+                                       #      GL_FLOAT
+                                       #      GL_2_BYTES
+                                       #      GL_3_BYTES
+                                       #      GL_4_BYTES
+                                       # LogicOp
+  constGL_CLEAR* = 0x00001500
+  GL_AND* = 0x00001501
+  GL_AND_REVERSE* = 0x00001502
+  GL_COPY* = 0x00001503
+  GL_AND_INVERTED* = 0x00001504
+  GL_NOOP* = 0x00001505
+  GL_XOR* = 0x00001506
+  GL_OR* = 0x00001507
+  GL_NOR* = 0x00001508
+  GL_EQUIV* = 0x00001509
+  GL_INVERT* = 0x0000150A
+  GL_OR_REVERSE* = 0x0000150B
+  GL_COPY_INVERTED* = 0x0000150C
+  GL_OR_INVERTED* = 0x0000150D
+  GL_NAND* = 0x0000150E
+  GL_SET* = 0x0000150F        # MapTarget
+                              #      GL_MAP1_COLOR_4
+                              #      GL_MAP1_INDEX
+                              #      GL_MAP1_NORMAL
+                              #      GL_MAP1_TEXTURE_COORD_1
+                              #      GL_MAP1_TEXTURE_COORD_2
+                              #      GL_MAP1_TEXTURE_COORD_3
+                              #      GL_MAP1_TEXTURE_COORD_4
+                              #      GL_MAP1_VERTEX_3
+                              #      GL_MAP1_VERTEX_4
+                              #      GL_MAP2_COLOR_4
+                              #      GL_MAP2_INDEX
+                              #      GL_MAP2_NORMAL
+                              #      GL_MAP2_TEXTURE_COORD_1
+                              #      GL_MAP2_TEXTURE_COORD_2
+                              #      GL_MAP2_TEXTURE_COORD_3
+                              #      GL_MAP2_TEXTURE_COORD_4
+                              #      GL_MAP2_VERTEX_3
+                              #      GL_MAP2_VERTEX_4
+                              # MaterialFace
+                              #      GL_FRONT
+                              #      GL_BACK
+                              #      GL_FRONT_AND_BACK
+                              # MaterialParameter
+  GL_EMISSION* = 0x00001600
+  GL_SHININESS* = 0x00001601
+  GL_AMBIENT_AND_DIFFUSE* = 0x00001602
+  GL_COLOR_INDEXES* = 0x00001603 #      GL_AMBIENT
+                                 #      GL_DIFFUSE
+                                 #      GL_SPECULAR
+                                 # MatrixMode
+  GL_MODELVIEW* = 0x00001700
+  GL_PROJECTION* = 0x00001701
+  GL_TEXTURE* = 0x00001702    # MeshMode1
+                              #      GL_POINT
+                              #      GL_LINE
+                              # MeshMode2
+                              #      GL_POINT
+                              #      GL_LINE
+                              #      GL_FILL
+                              # NormalPointerType
+                              #      GL_BYTE
+                              #      GL_SHORT
+                              #      GL_INT
+                              #      GL_FLOAT
+                              #      GL_DOUBLE
+                              # PixelCopyType
+  GL_COLOR* = 0x00001800
+  GL_DEPTH* = 0x00001801
+  GL_STENCIL* = 0x00001802    # PixelFormat
+  GL_COLOR_INDEX* = 0x00001900
+  GL_STENCIL_INDEX* = 0x00001901
+  GL_DEPTH_COMPONENT* = 0x00001902
+  GL_RED* = 0x00001903
+  GL_GREEN* = 0x00001904
+  GL_BLUE* = 0x00001905
+  GL_ALPHA* = 0x00001906
+  GL_RGB* = 0x00001907
+  GL_RGBA* = 0x00001908
+  GL_LUMINANCE* = 0x00001909
+  GL_LUMINANCE_ALPHA* = 0x0000190A # PixelMap
+                                   #      GL_PIXEL_MAP_I_TO_I
+                                   #      GL_PIXEL_MAP_S_TO_S
+                                   #      GL_PIXEL_MAP_I_TO_R
+                                   #      GL_PIXEL_MAP_I_TO_G
+                                   #      GL_PIXEL_MAP_I_TO_B
+                                   #      GL_PIXEL_MAP_I_TO_A
+                                   #      GL_PIXEL_MAP_R_TO_R
+                                   #      GL_PIXEL_MAP_G_TO_G
+                                   #      GL_PIXEL_MAP_B_TO_B
+                                   #      GL_PIXEL_MAP_A_TO_A
+                                   # PixelStore
+                                   #      GL_UNPACK_SWAP_BYTES
+                                   #      GL_UNPACK_LSB_FIRST
+                                   #      GL_UNPACK_ROW_LENGTH
+                                   #      GL_UNPACK_SKIP_ROWS
+                                   #      GL_UNPACK_SKIP_PIXELS
+                                   #      GL_UNPACK_ALIGNMENT
+                                   #      GL_PACK_SWAP_BYTES
+                                   #      GL_PACK_LSB_FIRST
+                                   #      GL_PACK_ROW_LENGTH
+                                   #      GL_PACK_SKIP_ROWS
+                                   #      GL_PACK_SKIP_PIXELS
+                                   #      GL_PACK_ALIGNMENT
+                                   # PixelTransfer
+                                   #      GL_MAP_COLOR
+                                   #      GL_MAP_STENCIL
+                                   #      GL_INDEX_SHIFT
+                                   #      GL_INDEX_OFFSET
+                                   #      GL_RED_SCALE
+                                   #      GL_RED_BIAS
+                                   #      GL_GREEN_SCALE
+                                   #      GL_GREEN_BIAS
+                                   #      GL_BLUE_SCALE
+                                   #      GL_BLUE_BIAS
+                                   #      GL_ALPHA_SCALE
+                                   #      GL_ALPHA_BIAS
+                                   #      GL_DEPTH_SCALE
+                                   #      GL_DEPTH_BIAS
+                                   # PixelType
+  constGL_BITMAP* = 0x00001A00
+  GL_POINT* = 0x00001B00
+  GL_LINE* = 0x00001B01
+  GL_FILL* = 0x00001B02       # ReadBufferMode
+                              #      GL_FRONT_LEFT
+                              #      GL_FRONT_RIGHT
+                              #      GL_BACK_LEFT
+                              #      GL_BACK_RIGHT
+                              #      GL_FRONT
+                              #      GL_BACK
+                              #      GL_LEFT
+                              #      GL_RIGHT
+                              #      GL_AUX0
+                              #      GL_AUX1
+                              #      GL_AUX2
+                              #      GL_AUX3
+                              # RenderingMode
+  GL_RENDER* = 0x00001C00
+  GL_FEEDBACK* = 0x00001C01
+  GL_SELECT* = 0x00001C02     # ShadingModel
+  GL_FLAT* = 0x00001D00
+  GL_SMOOTH* = 0x00001D01     # StencilFunction
+                              #      GL_NEVER
+                              #      GL_LESS
+                              #      GL_EQUAL
+                              #      GL_LEQUAL
+                              #      GL_GREATER
+                              #      GL_NOTEQUAL
+                              #      GL_GEQUAL
+                              #      GL_ALWAYS
+                              # StencilOp
+                              #      GL_ZERO
+  GL_KEEP* = 0x00001E00
+  GL_REPLACE* = 0x00001E01
+  GL_INCR* = 0x00001E02
+  GL_DECR* = 0x00001E03       #      GL_INVERT
+                              # StringName
+  GL_VENDOR* = 0x00001F00
+  GL_RENDERER* = 0x00001F01
+  GL_VERSION* = 0x00001F02
+  GL_EXTENSIONS* = 0x00001F03 # TextureCoordName
+  GL_S* = 0x00002000
+  GL_T* = 0x00002001
+  GL_R* = 0x00002002
+  GL_Q* = 0x00002003          # TexCoordPointerType
+                              #      GL_SHORT
+                              #      GL_INT
+                              #      GL_FLOAT
+                              #      GL_DOUBLE
+                              # TextureEnvMode
+  GL_MODULATE* = 0x00002100
+  GL_DECAL* = 0x00002101      #      GL_BLEND
+                              #      GL_REPLACE
+                              # TextureEnvParameter
+  GL_TEXTURE_ENV_MODE* = 0x00002200
+  GL_TEXTURE_ENV_COLOR* = 0x00002201 # TextureEnvTarget
+  GL_TEXTURE_ENV* = 0x00002300 # TextureGenMode
+  GL_EYE_LINEAR* = 0x00002400
+  GL_OBJECT_LINEAR* = 0x00002401
+  GL_SPHERE_MAP* = 0x00002402 # TextureGenParameter
+  GL_TEXTURE_GEN_MODE* = 0x00002500
+  GL_OBJECT_PLANE* = 0x00002501
+  GL_EYE_PLANE* = 0x00002502  # TextureMagFilter
+  GL_NEAREST* = 0x00002600
+  GL_LINEAR* = 0x00002601     # TextureMinFilter
+                              #      GL_NEAREST
+                              #      GL_LINEAR
+  GL_NEAREST_MIPMAP_NEAREST* = 0x00002700
+  GL_LINEAR_MIPMAP_NEAREST* = 0x00002701
+  GL_NEAREST_MIPMAP_LINEAR* = 0x00002702
+  GL_LINEAR_MIPMAP_LINEAR* = 0x00002703 # TextureParameterName
+  GL_TEXTURE_MAG_FILTER* = 0x00002800
+  GL_TEXTURE_MIN_FILTER* = 0x00002801
+  GL_TEXTURE_WRAP_S* = 0x00002802
+  GL_TEXTURE_WRAP_T* = 0x00002803 #      GL_TEXTURE_BORDER_COLOR
+                                  #      GL_TEXTURE_PRIORITY
+                                  # TextureTarget
+                                  #      GL_TEXTURE_1D
+                                  #      GL_TEXTURE_2D
+                                  #      GL_PROXY_TEXTURE_1D
+                                  #      GL_PROXY_TEXTURE_2D
+                                  # TextureWrapMode
+  GL_CLAMP* = 0x00002900
+  GL_REPEAT* = 0x00002901     # VertexPointerType
+                              #      GL_SHORT
+                              #      GL_INT
+                              #      GL_FLOAT
+                              #      GL_DOUBLE
+                              # ClientAttribMask
+  GL_CLIENT_PIXEL_STORE_BIT* = 0x00000001
+  GL_CLIENT_VERTEX_ARRAY_BIT* = 0x00000002
+  GL_CLIENT_ALL_ATTRIB_BITS* = 0xFFFFFFFF # polygon_offset
+  GL_POLYGON_OFFSET_FACTOR* = 0x00008038
+  GL_POLYGON_OFFSET_UNITS* = 0x00002A00
+  GL_POLYGON_OFFSET_POINT* = 0x00002A01
+  GL_POLYGON_OFFSET_LINE* = 0x00002A02
+  GL_POLYGON_OFFSET_FILL* = 0x00008037 # texture
+  GL_ALPHA4* = 0x0000803B
+  GL_ALPHA8* = 0x0000803C
+  GL_ALPHA12* = 0x0000803D
+  GL_ALPHA16* = 0x0000803E
+  GL_LUMINANCE4* = 0x0000803F
+  GL_LUMINANCE8* = 0x00008040
+  GL_LUMINANCE12* = 0x00008041
+  GL_LUMINANCE16* = 0x00008042
+  GL_LUMINANCE4_ALPHA4* = 0x00008043
+  GL_LUMINANCE6_ALPHA2* = 0x00008044
+  GL_LUMINANCE8_ALPHA8* = 0x00008045
+  GL_LUMINANCE12_ALPHA4* = 0x00008046
+  GL_LUMINANCE12_ALPHA12* = 0x00008047
+  GL_LUMINANCE16_ALPHA16* = 0x00008048
+  GL_INTENSITY* = 0x00008049
+  GL_INTENSITY4* = 0x0000804A
+  GL_INTENSITY8* = 0x0000804B
+  GL_INTENSITY12* = 0x0000804C
+  GL_INTENSITY16* = 0x0000804D
+  GL_R3_G3_B2* = 0x00002A10
+  GL_RGB4* = 0x0000804F
+  GL_RGB5* = 0x00008050
+  GL_RGB8* = 0x00008051
+  GL_RGB10* = 0x00008052
+  GL_RGB12* = 0x00008053
+  GL_RGB16* = 0x00008054
+  GL_RGBA2* = 0x00008055
+  GL_RGBA4* = 0x00008056
+  GL_RGB5_A1* = 0x00008057
+  GL_RGBA8* = 0x00008058
+  GL_RGB10_A2* = 0x00008059
+  GL_RGBA12* = 0x0000805A
+  GL_RGBA16* = 0x0000805B
+  GL_TEXTURE_RED_SIZE* = 0x0000805C
+  GL_TEXTURE_GREEN_SIZE* = 0x0000805D
+  GL_TEXTURE_BLUE_SIZE* = 0x0000805E
+  GL_TEXTURE_ALPHA_SIZE* = 0x0000805F
+  GL_TEXTURE_LUMINANCE_SIZE* = 0x00008060
+  GL_TEXTURE_INTENSITY_SIZE* = 0x00008061
+  GL_PROXY_TEXTURE_1D* = 0x00008063
+  GL_PROXY_TEXTURE_2D* = 0x00008064 # texture_object
+  GL_TEXTURE_PRIORITY* = 0x00008066
+  GL_TEXTURE_RESIDENT* = 0x00008067
+  GL_TEXTURE_BINDING_1D* = 0x00008068
+  GL_TEXTURE_BINDING_2D* = 0x00008069 # vertex_array
+  GL_VERTEX_ARRAY* = 0x00008074
+  GL_NORMAL_ARRAY* = 0x00008075
+  GL_COLOR_ARRAY* = 0x00008076
+  GL_INDEX_ARRAY* = 0x00008077
+  GL_TEXTURE_COORD_ARRAY* = 0x00008078
+  GL_EDGE_FLAG_ARRAY* = 0x00008079
+  GL_VERTEX_ARRAY_SIZE* = 0x0000807A
+  GL_VERTEX_ARRAY_TYPE* = 0x0000807B
+  GL_VERTEX_ARRAY_STRIDE* = 0x0000807C
+  GL_NORMAL_ARRAY_TYPE* = 0x0000807E
+  GL_NORMAL_ARRAY_STRIDE* = 0x0000807F
+  GL_COLOR_ARRAY_SIZE* = 0x00008081
+  GL_COLOR_ARRAY_TYPE* = 0x00008082
+  GL_COLOR_ARRAY_STRIDE* = 0x00008083
+  GL_INDEX_ARRAY_TYPE* = 0x00008085
+  GL_INDEX_ARRAY_STRIDE* = 0x00008086
+  GL_TEXTURE_COORD_ARRAY_SIZE* = 0x00008088
+  GL_TEXTURE_COORD_ARRAY_TYPE* = 0x00008089
+  GL_TEXTURE_COORD_ARRAY_STRIDE* = 0x0000808A
+  GL_EDGE_FLAG_ARRAY_STRIDE* = 0x0000808C
+  GL_VERTEX_ARRAY_POINTER* = 0x0000808E
+  GL_NORMAL_ARRAY_POINTER* = 0x0000808F
+  GL_COLOR_ARRAY_POINTER* = 0x00008090
+  GL_INDEX_ARRAY_POINTER* = 0x00008091
+  GL_TEXTURE_COORD_ARRAY_POINTER* = 0x00008092
+  GL_EDGE_FLAG_ARRAY_POINTER* = 0x00008093
+  GL_V2F* = 0x00002A20
+  GL_V3F* = 0x00002A21
+  GL_C4UB_V2F* = 0x00002A22
+  GL_C4UB_V3F* = 0x00002A23
+  GL_C3F_V3F* = 0x00002A24
+  GL_N3F_V3F* = 0x00002A25
+  GL_C4F_N3F_V3F* = 0x00002A26
+  GL_T2F_V3F* = 0x00002A27
+  GL_T4F_V4F* = 0x00002A28
+  GL_T2F_C4UB_V3F* = 0x00002A29
+  GL_T2F_C3F_V3F* = 0x00002A2A
+  GL_T2F_N3F_V3F* = 0x00002A2B
+  GL_T2F_C4F_N3F_V3F* = 0x00002A2C
+  GL_T4F_C4F_N3F_V4F* = 0x00002A2D # Extensions
+  GL_EXT_vertex_array* = 1
+  GL_WIN_swap_hint* = 1
+  GL_EXT_bgra* = 1
+  GL_EXT_paletted_texture* = 1 # EXT_vertex_array
+  GL_VERTEX_ARRAY_EXT* = 0x00008074
+  GL_NORMAL_ARRAY_EXT* = 0x00008075
+  GL_COLOR_ARRAY_EXT* = 0x00008076
+  GL_INDEX_ARRAY_EXT* = 0x00008077
+  GL_TEXTURE_COORD_ARRAY_EXT* = 0x00008078
+  GL_EDGE_FLAG_ARRAY_EXT* = 0x00008079
+  GL_VERTEX_ARRAY_SIZE_EXT* = 0x0000807A
+  GL_VERTEX_ARRAY_TYPE_EXT* = 0x0000807B
+  GL_VERTEX_ARRAY_STRIDE_EXT* = 0x0000807C
+  GL_VERTEX_ARRAY_COUNT_EXT* = 0x0000807D
+  GL_NORMAL_ARRAY_TYPE_EXT* = 0x0000807E
+  GL_NORMAL_ARRAY_STRIDE_EXT* = 0x0000807F
+  GL_NORMAL_ARRAY_COUNT_EXT* = 0x00008080
+  GL_COLOR_ARRAY_SIZE_EXT* = 0x00008081
+  GL_COLOR_ARRAY_TYPE_EXT* = 0x00008082
+  GL_COLOR_ARRAY_STRIDE_EXT* = 0x00008083
+  GL_COLOR_ARRAY_COUNT_EXT* = 0x00008084
+  GL_INDEX_ARRAY_TYPE_EXT* = 0x00008085
+  GL_INDEX_ARRAY_STRIDE_EXT* = 0x00008086
+  GL_INDEX_ARRAY_COUNT_EXT* = 0x00008087
+  GL_TEXTURE_COORD_ARRAY_SIZE_EXT* = 0x00008088
+  GL_TEXTURE_COORD_ARRAY_TYPE_EXT* = 0x00008089
+  GL_TEXTURE_COORD_ARRAY_STRIDE_EXT* = 0x0000808A
+  GL_TEXTURE_COORD_ARRAY_COUNT_EXT* = 0x0000808B
+  GL_EDGE_FLAG_ARRAY_STRIDE_EXT* = 0x0000808C
+  GL_EDGE_FLAG_ARRAY_COUNT_EXT* = 0x0000808D
+  GL_VERTEX_ARRAY_POINTER_EXT* = 0x0000808E
+  GL_NORMAL_ARRAY_POINTER_EXT* = 0x0000808F
+  GL_COLOR_ARRAY_POINTER_EXT* = 0x00008090
+  GL_INDEX_ARRAY_POINTER_EXT* = 0x00008091
+  GL_TEXTURE_COORD_ARRAY_POINTER_EXT* = 0x00008092
+  GL_EDGE_FLAG_ARRAY_POINTER_EXT* = 0x00008093
+  GL_DOUBLE_EXT* = GL_DOUBLE  # EXT_bgra
+  GL_BGR_EXT* = 0x000080E0
+  GL_BGRA_EXT* = 0x000080E1   # EXT_paletted_texture
+                              # These must match the GL_COLOR_TABLE_*_SGI enumerants
+  GL_COLOR_TABLE_FORMAT_EXT* = 0x000080D8
+  GL_COLOR_TABLE_WIDTH_EXT* = 0x000080D9
+  GL_COLOR_TABLE_RED_SIZE_EXT* = 0x000080DA
+  GL_COLOR_TABLE_GREEN_SIZE_EXT* = 0x000080DB
+  GL_COLOR_TABLE_BLUE_SIZE_EXT* = 0x000080DC
+  GL_COLOR_TABLE_ALPHA_SIZE_EXT* = 0x000080DD
+  GL_COLOR_TABLE_LUMINANCE_SIZE_EXT* = 0x000080DE
+  GL_COLOR_TABLE_INTENSITY_SIZE_EXT* = 0x000080DF
+  GL_COLOR_INDEX1_EXT* = 0x000080E2
+  GL_COLOR_INDEX2_EXT* = 0x000080E3
+  GL_COLOR_INDEX4_EXT* = 0x000080E4
+  GL_COLOR_INDEX8_EXT* = 0x000080E5
+  GL_COLOR_INDEX12_EXT* = 0x000080E6
+  GL_COLOR_INDEX16_EXT* = 0x000080E7 # For compatibility with OpenGL v1.0
+  constGL_LOGIC_OP* = GL_INDEX_LOGIC_OP
+  GL_TEXTURE_COMPONENTS* = GL_TEXTURE_INTERNAL_FORMAT
+
+proc glAccum*(op: TGLenum, value: TGLfloat){.dynlib: dllname, importc: "glAccum".}
+proc glAlphaFunc*(func: TGLenum, theref: TGLclampf){.dynlib: dllname, 
+    importc: "glAlphaFunc".}
+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, 
+    importc: "glBindTexture".}
+proc glBitmap*(width, height: TGLsizei, xorig, yorig: TGLfloat, 
+               xmove, ymove: TGLfloat, bitmap: PGLubyte){.dynlib: dllname, 
+    importc: "glBitmap".}
+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, 
+    importc: "glCallLists".}
+proc glClear*(mask: TGLbitfield){.dynlib: dllname, importc: "glClear".}
+proc glClearAccum*(red, green, blue, alpha: TGLfloat){.dynlib: dllname, 
+    importc: "glClearAccum".}
+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, 
+    importc: "glClipPlane".}
+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, 
+    importc: "glColor3d".}
+proc glColor3dv*(v: PGLdouble){.dynlib: dllname, importc: "glColor3dv".}
+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, 
+    importc: "glColor3s".}
+proc glColor3sv*(v: PGLshort){.dynlib: dllname, importc: "glColor3sv".}
+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, 
+    importc: "glColor3ui".}
+proc glColor3uiv*(v: PGLuint){.dynlib: dllname, importc: "glColor3uiv".}
+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, 
+    importc: "glColor4b".}
+proc glColor4bv*(v: PGLbyte){.dynlib: dllname, importc: "glColor4bv".}
+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, 
+    importc: "glColor4f".}
+proc glColor4fv*(v: PGLfloat){.dynlib: dllname, importc: "glColor4fv".}
+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, 
+    importc: "glColor4s".}
+proc glColor4sv*(v: PGLshort){.dynlib: dllname, importc: "glColor4sv".}
+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, 
+    importc: "glColor4ui".}
+proc glColor4uiv*(v: PGLuint){.dynlib: dllname, importc: "glColor4uiv".}
+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, 
+    importc: "glColorMask".}
+proc glColorMaterial*(face, mode: TGLenum){.dynlib: dllname, 
+    importc: "glColorMaterial".}
+proc glColorPointer*(size: TGLint, atype: TGLenum, stride: TGLsizei, 
+                     pointer: 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, 
+                       x, y: TGLint, width: TGLsizei, border: TGLint){.
+    dynlib: dllname, importc: "glCopyTexImage1D".}
+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, 
+    importc: "glCopyTexSubImage1D".}
+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, 
+    importc: "glDeleteLists".}
+proc glDeleteTextures*(n: TGLsizei, textures: PGLuint){.dynlib: dllname, 
+    importc: "glDeleteTextures".}
+proc glDepthFunc*(func: TGLenum){.dynlib: dllname, importc: "glDepthFunc".}
+proc glDepthMask*(flag: TGLboolean){.dynlib: dllname, importc: "glDepthMask".}
+proc glDepthRange*(zNear, zFar: TGLclampd){.dynlib: dllname, 
+    importc: "glDepthRange".}
+proc glDisable*(cap: TGLenum){.dynlib: dllname, importc: "glDisable".}
+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, 
+                                        importc: "glDrawElements".}
+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, pointer: 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, 
+    importc: "glEnableClientState".}
+proc glEnd*(){.dynlib: dllname, importc: "glEnd".}
+proc glEndList*(){.dynlib: dllname, importc: "glEndList".}
+proc glEvalCoord1d*(u: TGLdouble){.dynlib: dllname, importc: "glEvalCoord1d".}
+proc glEvalCoord1dv*(u: PGLdouble){.dynlib: dllname, importc: "glEvalCoord1dv".}
+proc glEvalCoord1f*(u: TGLfloat){.dynlib: dllname, importc: "glEvalCoord1f".}
+proc glEvalCoord1fv*(u: PGLfloat){.dynlib: dllname, importc: "glEvalCoord1fv".}
+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, 
+    importc: "glEvalMesh1".}
+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".}
+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, 
+    importc: "glFogf".}
+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, 
+    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, 
+    importc: "glGenLists".}
+proc glGenTextures*(n: TGLsizei, textures: PGLuint){.dynlib: dllname, 
+    importc: "glGenTextures".}
+proc glGetBooleanv*(pname: TGLenum, params: PGLboolean){.dynlib: dllname, 
+    importc: "glGetBooleanv".}
+proc glGetClipPlane*(plane: TGLenum, equation: PGLdouble){.dynlib: dllname, 
+    importc: "glGetClipPlane".}
+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, 
+    importc: "glGetFloatv".}
+proc glGetIntegerv*(pname: TGLenum, params: PGLint){.dynlib: dllname, 
+    importc: "glGetIntegerv".}
+proc glGetLightfv*(light, pname: TGLenum, params: PGLfloat){.dynlib: dllname, 
+    importc: "glGetLightfv".}
+proc glGetLightiv*(light, pname: TGLenum, params: PGLint){.dynlib: dllname, 
+    importc: "glGetLightiv".}
+proc glGetMapdv*(target, query: TGLenum, v: PGLdouble){.dynlib: dllname, 
+    importc: "glGetMapdv".}
+proc glGetMapfv*(target, query: TGLenum, v: PGLfloat){.dynlib: dllname, 
+    importc: "glGetMapfv".}
+proc glGetMapiv*(target, query: TGLenum, v: PGLint){.dynlib: dllname, 
+    importc: "glGetMapiv".}
+proc glGetMaterialfv*(face, pname: TGLenum, params: PGLfloat){.dynlib: dllname, 
+    importc: "glGetMaterialfv".}
+proc glGetMaterialiv*(face, pname: TGLenum, params: PGLint){.dynlib: dllname, 
+    importc: "glGetMaterialiv".}
+proc glGetPixelMapfv*(map: TGLenum, values: PGLfloat){.dynlib: dllname, 
+    importc: "glGetPixelMapfv".}
+proc glGetPixelMapuiv*(map: TGLenum, values: PGLuint){.dynlib: dllname, 
+    importc: "glGetPixelMapuiv".}
+proc glGetPixelMapusv*(map: TGLenum, values: PGLushort){.dynlib: dllname, 
+    importc: "glGetPixelMapusv".}
+proc glGetPointerv*(pname: TGLenum, params: Pointer){.dynlib: dllname, 
+    importc: "glGetPointerv".}
+proc glGetPolygonStipple*(mask: PGLubyte){.dynlib: dllname, 
+    importc: "glGetPolygonStipple".}
+proc glGetString*(name: TGLenum): cstring{.dynlib: dllname, 
+    importc: "glGetString".}
+proc glGetTexEnvfv*(target, pname: TGLenum, params: PGLfloat){.dynlib: dllname, 
+    importc: "glGetTexEnvfv".}
+proc glGetTexEnviv*(target, pname: TGLenum, params: PGLint){.dynlib: dllname, 
+    importc: "glGetTexEnviv".}
+proc glGetTexGendv*(coord, pname: TGLenum, params: PGLdouble){.dynlib: dllname, 
+    importc: "glGetTexGendv".}
+proc glGetTexGenfv*(coord, pname: TGLenum, params: PGLfloat){.dynlib: dllname, 
+    importc: "glGetTexGenfv".}
+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, 
+    importc: "glGetTexImage".}
+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, 
+    importc: "glGetTexLevelParameteriv".}
+proc glGetTexParameterfv*(target, pname: TGLenum, params: PGLfloat){.
+    dynlib: dllname, importc: "glGetTexParameterfv".}
+proc glGetTexParameteriv*(target, pname: TGLenum, params: PGLint){.
+    dynlib: dllname, importc: "glGetTexParameteriv".}
+proc glHint*(target, mode: TGLenum){.dynlib: dllname, importc: "glHint".}
+proc glIndexMask*(mask: TGLuint){.dynlib: dllname, importc: "glIndexMask".}
+proc glIndexPointer*(atype: TGLenum, stride: TGLsizei, pointer: Pointer){.
+    dynlib: dllname, importc: "glIndexPointer".}
+proc glIndexd*(c: TGLdouble){.dynlib: dllname, importc: "glIndexd".}
+proc glIndexdv*(c: PGLdouble){.dynlib: dllname, importc: "glIndexdv".}
+proc glIndexf*(c: TGLfloat){.dynlib: dllname, importc: "glIndexf".}
+proc glIndexfv*(c: PGLfloat){.dynlib: dllname, importc: "glIndexfv".}
+proc glIndexi*(c: TGLint){.dynlib: dllname, importc: "glIndexi".}
+proc glIndexiv*(c: PGLint){.dynlib: dllname, importc: "glIndexiv".}
+proc glIndexs*(c: TGLshort){.dynlib: dllname, importc: "glIndexs".}
+proc glIndexsv*(c: PGLshort){.dynlib: dllname, importc: "glIndexsv".}
+proc glIndexub*(c: TGLubyte){.dynlib: dllname, importc: "glIndexub".}
+proc glIndexubv*(c: PGLubyte){.dynlib: dllname, importc: "glIndexubv".}
+proc glInitNames*(){.dynlib: dllname, importc: "glInitNames".}
+proc glInterleavedArrays*(format: TGLenum, stride: TGLsizei, pointer: Pointer){.
+    dynlib: dllname, importc: "glInterleavedArrays".}
+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, 
+    importc: "glIsTexture".}
+proc glLightModelf*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, 
+    importc: "glLightModelf".}
+proc glLightModelfv*(pname: TGLenum, params: PGLfloat){.dynlib: dllname, 
+    importc: "glLightModelfv".}
+proc glLightModeli*(pname: TGLenum, param: TGLint){.dynlib: dllname, 
+    importc: "glLightModeli".}
+proc glLightModeliv*(pname: TGLenum, params: PGLint){.dynlib: dllname, 
+    importc: "glLightModeliv".}
+proc glLightf*(light, pname: TGLenum, param: TGLfloat){.dynlib: dllname, 
+    importc: "glLightf".}
+proc glLightfv*(light, pname: TGLenum, params: PGLfloat){.dynlib: dllname, 
+    importc: "glLightfv".}
+proc glLighti*(light, pname: TGLenum, param: TGLint){.dynlib: dllname, 
+    importc: "glLighti".}
+proc glLightiv*(light, pname: TGLenum, params: PGLint){.dynlib: dllname, 
+    importc: "glLightiv".}
+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".}
+proc glLoadIdentity*(){.dynlib: dllname, importc: "glLoadIdentity".}
+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, 
+              points: PGLdouble){.dynlib: dllname, importc: "glMap1d".}
+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, 
+              v1, v2: TGLdouble, vstride, vorder: TGLint, points: PGLdouble){.
+    dynlib: dllname, importc: "glMap2d".}
+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, 
+    importc: "glMapGrid1d".}
+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, 
+    importc: "glMaterialf".}
+proc glMaterialfv*(face, pname: TGLenum, params: PGLfloat){.dynlib: dllname, 
+    importc: "glMaterialfv".}
+proc glMateriali*(face, pname: TGLenum, param: TGLint){.dynlib: dllname, 
+    importc: "glMateriali".}
+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, 
+    importc: "glNewList".}
+proc glNormal3b*(nx, ny, nz: TGlbyte){.dynlib: dllname, importc: "glNormal3b".}
+proc glNormal3bv*(v: PGLbyte){.dynlib: dllname, importc: "glNormal3bv".}
+proc glNormal3d*(nx, ny, nz: TGLdouble){.dynlib: dllname, importc: "glNormal3d".}
+proc glNormal3dv*(v: PGLdouble){.dynlib: dllname, importc: "glNormal3dv".}
+proc glNormal3f*(nx, ny, nz: TGLfloat){.dynlib: dllname, importc: "glNormal3f".}
+proc glNormal3fv*(v: PGLfloat){.dynlib: dllname, importc: "glNormal3fv".}
+proc glNormal3i*(nx, ny, nz: TGLint){.dynlib: dllname, importc: "glNormal3i".}
+proc glNormal3iv*(v: PGLint){.dynlib: dllname, importc: "glNormal3iv".}
+proc glNormal3s*(nx, ny, nz: TGLshort){.dynlib: dllname, importc: "glNormal3s".}
+proc glNormal3sv*(v: PGLshort){.dynlib: dllname, importc: "glNormal3sv".}
+proc glNormalPointer*(atype: TGLenum, stride: TGLsizei, pointer: Pointer){.
+    dynlib: dllname, importc: "glNormalPointer".}
+proc glOrtho*(left, right, bottom, top, zNear, zFar: TGLdouble){.
+    dynlib: dllname, importc: "glOrtho".}
+proc glPassThrough*(token: TGLfloat){.dynlib: dllname, importc: "glPassThrough".}
+proc glPixelMapfv*(map: TGLenum, mapsize: TGLsizei, values: PGLfloat){.
+    dynlib: dllname, importc: "glPixelMapfv".}
+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, 
+    importc: "glPixelStoref".}
+proc glPixelStorei*(pname: TGLenum, param: TGLint){.dynlib: dllname, 
+    importc: "glPixelStorei".}
+proc glPixelTransferf*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, 
+    importc: "glPixelTransferf".}
+proc glPixelTransferi*(pname: TGLenum, param: TGLint){.dynlib: dllname, 
+    importc: "glPixelTransferi".}
+proc glPixelZoom*(xfactor, yfactor: TGLfloat){.dynlib: dllname, 
+    importc: "glPixelZoom".}
+proc glPointSize*(size: TGLfloat){.dynlib: dllname, importc: "glPointSize".}
+proc glPolygonMode*(face, mode: TGLenum){.dynlib: dllname, 
+    importc: "glPolygonMode".}
+proc glPolygonOffset*(factor, units: TGLfloat){.dynlib: dllname, 
+    importc: "glPolygonOffset".}
+proc glPolygonStipple*(mask: PGLubyte){.dynlib: dllname, 
+                                        importc: "glPolygonStipple".}
+proc glPopAttrib*(){.dynlib: dllname, importc: "glPopAttrib".}
+proc glPopClientAttrib*(){.dynlib: dllname, importc: "glPopClientAttrib".}
+proc glPopMatrix*(){.dynlib: dllname, importc: "glPopMatrix".}
+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, 
+    importc: "glPushClientAttrib".}
+proc glPushMatrix*(){.dynlib: dllname, importc: "glPushMatrix".}
+proc glPushName*(name: TGLuint){.dynlib: dllname, importc: "glPushName".}
+proc glRasterPos2d*(x, y: TGLdouble){.dynlib: dllname, importc: "glRasterPos2d".}
+proc glRasterPos2dv*(v: PGLdouble){.dynlib: dllname, importc: "glRasterPos2dv".}
+proc glRasterPos2f*(x, y: TGLfloat){.dynlib: dllname, importc: "glRasterPos2f".}
+proc glRasterPos2fv*(v: PGLfloat){.dynlib: dllname, importc: "glRasterPos2fv".}
+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, 
+    importc: "glRasterPos3d".}
+proc glRasterPos3dv*(v: PGLdouble){.dynlib: dllname, importc: "glRasterPos3dv".}
+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, 
+                                        importc: "glRasterPos3s".}
+proc glRasterPos3sv*(v: PGLshort){.dynlib: dllname, importc: "glRasterPos3sv".}
+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, 
+    importc: "glRasterPos4f".}
+proc glRasterPos4fv*(v: PGLfloat){.dynlib: dllname, importc: "glRasterPos4fv".}
+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, 
+    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, 
+    importc: "glReadPixels".}
+proc glRectd*(x1, y1, x2, y2: TGLdouble){.dynlib: dllname, importc: "glRectd".}
+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".}
+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, 
+    importc: "glRenderMode".}
+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, 
+    importc: "glScissor".}
+proc glSelectBuffer*(size: TGLsizei, buffer: PGLuint){.dynlib: dllname, 
+    importc: "glSelectBuffer".}
+proc glShadeModel*(mode: TGLenum){.dynlib: dllname, importc: "glShadeModel".}
+proc glStencilFunc*(func: 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, 
+    importc: "glStencilOp".}
+proc glTexCoord1d*(s: TGLdouble){.dynlib: dllname, importc: "glTexCoord1d".}
+proc glTexCoord1dv*(v: PGLdouble){.dynlib: dllname, importc: "glTexCoord1dv".}
+proc glTexCoord1f*(s: TGLfloat){.dynlib: dllname, importc: "glTexCoord1f".}
+proc glTexCoord1fv*(v: PGLfloat){.dynlib: dllname, importc: "glTexCoord1fv".}
+proc glTexCoord1i*(s: TGLint){.dynlib: dllname, importc: "glTexCoord1i".}
+proc glTexCoord1iv*(v: PGLint){.dynlib: dllname, importc: "glTexCoord1iv".}
+proc glTexCoord1s*(s: TGLshort){.dynlib: dllname, importc: "glTexCoord1s".}
+proc glTexCoord1sv*(v: PGLshort){.dynlib: dllname, importc: "glTexCoord1sv".}
+proc glTexCoord2d*(s, t: TGLdouble){.dynlib: dllname, importc: "glTexCoord2d".}
+proc glTexCoord2dv*(v: PGLdouble){.dynlib: dllname, importc: "glTexCoord2dv".}
+proc glTexCoord2f*(s, t: TGLfloat){.dynlib: dllname, importc: "glTexCoord2f".}
+proc glTexCoord2fv*(v: PGLfloat){.dynlib: dllname, importc: "glTexCoord2fv".}
+proc glTexCoord2i*(s, t: TGLint){.dynlib: dllname, importc: "glTexCoord2i".}
+proc glTexCoord2iv*(v: PGLint){.dynlib: dllname, importc: "glTexCoord2iv".}
+proc glTexCoord2s*(s, t: TGLshort){.dynlib: dllname, importc: "glTexCoord2s".}
+proc glTexCoord2sv*(v: PGLshort){.dynlib: dllname, importc: "glTexCoord2sv".}
+proc glTexCoord3d*(s, t, r: TGLdouble){.dynlib: dllname, importc: "glTexCoord3d".}
+proc glTexCoord3dv*(v: PGLdouble){.dynlib: dllname, importc: "glTexCoord3dv".}
+proc glTexCoord3f*(s, t, r: TGLfloat){.dynlib: dllname, importc: "glTexCoord3f".}
+proc glTexCoord3fv*(v: PGLfloat){.dynlib: dllname, importc: "glTexCoord3fv".}
+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, 
+    importc: "glTexCoord4d".}
+proc glTexCoord4dv*(v: PGLdouble){.dynlib: dllname, importc: "glTexCoord4dv".}
+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, 
+    importc: "glTexCoord4s".}
+proc glTexCoord4sv*(v: PGLshort){.dynlib: dllname, importc: "glTexCoord4sv".}
+proc glTexCoordPointer*(size: TGLint, atype: TGLenum, stride: TGLsizei, 
+                        pointer: Pointer){.dynlib: dllname, 
+    importc: "glTexCoordPointer".}
+proc glTexEnvf*(target: TGLenum, pname: TGLenum, param: TGLfloat){.
+    dynlib: dllname, importc: "glTexEnvf".}
+proc glTexEnvfv*(target: TGLenum, pname: TGLenum, params: PGLfloat){.
+    dynlib: dllname, importc: "glTexEnvfv".}
+proc glTexEnvi*(target: TGLenum, pname: TGLenum, param: TGLint){.
+    dynlib: dllname, importc: "glTexEnvi".}
+proc glTexEnviv*(target: TGLenum, pname: TGLenum, params: PGLint){.
+    dynlib: dllname, importc: "glTexEnviv".}
+proc glTexGend*(coord: TGLenum, pname: TGLenum, param: TGLdouble){.
+    dynlib: dllname, importc: "glTexGend".}
+proc glTexGendv*(coord: TGLenum, pname: TGLenum, params: PGLdouble){.
+    dynlib: dllname, importc: "glTexGendv".}
+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, 
+    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, 
+                   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, 
+    importc: "glTexImage2D".}
+proc glTexParameterf*(target: TGLenum, pname: TGLenum, param: TGLfloat){.
+    dynlib: dllname, importc: "glTexParameterf".}
+proc glTexParameterfv*(target: TGLenum, pname: TGLenum, params: PGLfloat){.
+    dynlib: dllname, importc: "glTexParameterfv".}
+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, 
+    importc: "glTexSubImage1D".}
+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".}
+proc glVertex2d*(x, y: TGLdouble){.dynlib: dllname, importc: "glVertex2d".}
+proc glVertex2dv*(v: PGLdouble){.dynlib: dllname, importc: "glVertex2dv".}
+proc glVertex2f*(x, y: TGLfloat){.dynlib: dllname, importc: "glVertex2f".}
+proc glVertex2fv*(v: PGLfloat){.dynlib: dllname, importc: "glVertex2fv".}
+proc glVertex2i*(x, y: TGLint){.dynlib: dllname, importc: "glVertex2i".}
+proc glVertex2iv*(v: PGLint){.dynlib: dllname, importc: "glVertex2iv".}
+proc glVertex2s*(x, y: TGLshort){.dynlib: dllname, importc: "glVertex2s".}
+proc glVertex2sv*(v: PGLshort){.dynlib: dllname, importc: "glVertex2sv".}
+proc glVertex3d*(x, y, z: TGLdouble){.dynlib: dllname, importc: "glVertex3d".}
+proc glVertex3dv*(v: PGLdouble){.dynlib: dllname, importc: "glVertex3dv".}
+proc glVertex3f*(x, y, z: TGLfloat){.dynlib: dllname, importc: "glVertex3f".}
+proc glVertex3fv*(v: PGLfloat){.dynlib: dllname, importc: "glVertex3fv".}
+proc glVertex3i*(x, y, z: TGLint){.dynlib: dllname, importc: "glVertex3i".}
+proc glVertex3iv*(v: PGLint){.dynlib: dllname, importc: "glVertex3iv".}
+proc glVertex3s*(x, y, z: TGLshort){.dynlib: dllname, importc: "glVertex3s".}
+proc glVertex3sv*(v: PGLshort){.dynlib: dllname, importc: "glVertex3sv".}
+proc glVertex4d*(x, y, z, w: TGLdouble){.dynlib: dllname, importc: "glVertex4d".}
+proc glVertex4dv*(v: PGLdouble){.dynlib: dllname, importc: "glVertex4dv".}
+proc glVertex4f*(x, y, z, w: TGLfloat){.dynlib: dllname, importc: "glVertex4f".}
+proc glVertex4fv*(v: PGLfloat){.dynlib: dllname, importc: "glVertex4fv".}
+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, 
+                      pointer: Pointer){.dynlib: dllname, 
+    importc: "glVertexPointer".}
+proc glViewport*(x, y: TGLint, width, height: TGLsizei){.dynlib: dllname, 
+    importc: "glViewport".}
+type 
+  PFN_GLARRAY_ELEMENT_EXTPROC* = proc (i: TGLint)
+  PFN_GLDRAW_ARRAYS_EXTPROC* = proc (mode: TGLenum, first: TGLint, 
+                                     count: TGLsizei)
+  PFN_GLVERTEX_POINTER_EXTPROC* = proc (size: TGLint, atype: TGLenum, 
+                                        stride, count: TGLsizei, 
+                                        pointer: Pointer)
+  PFN_GLNORMAL_POINTER_EXTPROC* = proc (atype: TGLenum, stride, count: TGLsizei, 
+                                        pointer: Pointer)
+  PFN_GLCOLOR_POINTER_EXTPROC* = proc (size: TGLint, atype: TGLenum, 
+                                       stride, count: TGLsizei, pointer: Pointer)
+  PFN_GLINDEX_POINTER_EXTPROC* = proc (atype: TGLenum, stride, count: TGLsizei, 
+                                       pointer: Pointer)
+  PFN_GLTEXCOORD_POINTER_EXTPROC* = proc (size: TGLint, atype: TGLenum, 
+      stride, count: TGLsizei, pointer: Pointer)
+  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, 
+      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, 
+                                     data: Pointer)
+  PFN_GLCOLOR_SUBTABLE_EXTPROC* = proc (target: TGLenum, start, count: TGLsizei, 
+                                        format, atype: TGLenum, data: Pointer)
+  PFN_GLGETCOLOR_TABLE_EXTPROC* = proc (target, format, atype: TGLenum, 
+                                        data: Pointer)
+  PFN_GLGETCOLOR_TABLE_PARAMETER_IVEXTPROC* = proc (target, pname: TGLenum, 
+      params: PGLint)
+  PFN_GLGETCOLOR_TABLE_PARAMETER_FVEXTPROC* = proc (target, pname: TGLenum, 
+      params: PGLfloat)
+
+{.pop.}
+# implementation
diff --git a/tests/manyloc/keineschweine/lib/glext.nim b/tests/manyloc/keineschweine/lib/glext.nim
new file mode 100644
index 000000000..32871df0e
--- /dev/null
+++ b/tests/manyloc/keineschweine/lib/glext.nim
@@ -0,0 +1,4673 @@
+#
+#
+#  Adaption of the delphi3d.net OpenGL units to FreePascal
+#  Sebastian Guenther (sg@freepascal.org) in 2002
+#  These units are free to use
+#
+#
+
+#*************************************************
+# *        OpenGL extension loading library        *
+# * Generated by MetaGLext, written by Tom Nuydens *
+# *  (tom@delphi3d.net -- http://www.delphi3d.net  *
+# *************************************************
+#*** Generated on 10/11/2002
+
+when defined(windows): 
+  {.push, callconv: stdcall.}
+else: 
+  {.push, callconv: cdecl.}
+import 
+  gl
+
+type 
+  GLcharARB* = Char
+  TGLcharARB* = GLcharARB
+  PGLcharARB* = ptr GLcharARB
+  GLhandleARB* = int
+  TGLhandleARB* = GLhandleARB
+  PGLhandleARB* = ptr GLhandleARB
+  GLintptr* = int
+  TGLintptr* = GLintptr
+  PGLintptr* = ptr GLintptr
+  GLsizeiptr* = int
+  TGLsizeiptr* = GLsizeiptr
+  PGLsizeiptr* = ptr GLsizeiptr
+  GLchar* = Char
+  TGLchar* = GLchar
+  PGLchar* = cstring          #***** GL_version_1_2 *****//
+
+const 
+  GL_UNSIGNED_BYTE_3_3_2* = 0x00008032
+  GL_UNSIGNED_SHORT_4_4_4_4* = 0x00008033
+  GL_UNSIGNED_SHORT_5_5_5_1* = 0x00008034
+  GL_UNSIGNED_INT_8_8_8_8* = 0x00008035
+  GL_UNSIGNED_INT_10_10_10_2* = 0x00008036
+  GL_RESCALE_NORMAL* = 0x0000803A
+  GL_UNSIGNED_BYTE_2_3_3_REV* = 0x00008362
+  GL_UNSIGNED_SHORT_5_6_5* = 0x00008363
+  GL_UNSIGNED_SHORT_5_6_5_REV* = 0x00008364
+  GL_UNSIGNED_SHORT_4_4_4_4_REV* = 0x00008365
+  GL_UNSIGNED_SHORT_1_5_5_5_REV* = 0x00008366
+  GL_UNSIGNED_INT_8_8_8_8_REV* = 0x00008367
+  GL_UNSIGNED_INT_2_10_10_10_REV* = 0x00008368
+  GL_BGR* = 0x000080E0
+  GL_BGRA* = 0x000080E1
+  GL_MAX_ELEMENTS_VERTICES* = 0x000080E8
+  GL_MAX_ELEMENTS_INDICES* = 0x000080E9
+  GL_CLAMP_TO_EDGE* = 0x0000812F
+  GL_TEXTURE_MIN_LOD* = 0x0000813A
+  GL_TEXTURE_MAX_LOD* = 0x0000813B
+  GL_TEXTURE_BASE_LEVEL* = 0x0000813C
+  GL_TEXTURE_MAX_LEVEL* = 0x0000813D
+  GL_LIGHT_MODEL_COLOR_CONTROL* = 0x000081F8
+  GL_SINGLE_COLOR* = 0x000081F9
+  GL_SEPARATE_SPECULAR_COLOR* = 0x000081FA
+  GL_SMOOTH_POINT_SIZE_RANGE* = 0x00000B12
+  GL_SMOOTH_POINT_SIZE_GRANULARITY* = 0x00000B13
+  GL_SMOOTH_LINE_WIDTH_RANGE* = 0x00000B22
+  GL_SMOOTH_LINE_WIDTH_GRANULARITY* = 0x00000B23
+  GL_ALIASED_POINT_SIZE_RANGE* = 0x0000846D
+  GL_ALIASED_LINE_WIDTH_RANGE* = 0x0000846E
+  GL_PACK_SKIP_IMAGES* = 0x0000806B
+  GL_PACK_IMAGE_HEIGHT* = 0x0000806C
+  GL_UNPACK_SKIP_IMAGES* = 0x0000806D
+  GL_UNPACK_IMAGE_HEIGHT* = 0x0000806E
+  GL_TEXTURE_3D* = 0x0000806F
+  GL_PROXY_TEXTURE_3D* = 0x00008070
+  GL_TEXTURE_DEPTH* = 0x00008071
+  GL_TEXTURE_WRAP_R* = 0x00008072
+  GL_MAX_3D_TEXTURE_SIZE* = 0x00008073
+
+proc glBlendColor*(red: TGLclampf, green: TGLclampf, blue: TGLclampf, 
+                   alpha: TGLclampf){.dynlib: dllname, importc: "glBlendColor".}
+proc glBlendEquation*(mode: TGLenum){.dynlib: dllname, 
+                                      importc: "glBlendEquation".}
+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, 
+                   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, 
+    importc: "glCopyColorTable".}
+proc glGetColorTable*(target: TGLenum, format: TGLenum, thetype: TGLenum, 
+                      table: PGLvoid){.dynlib: dllname, 
+                                       importc: "glGetColorTable".}
+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, 
+                      format: TGLenum, thetype: TGLenum, data: PGLvoid){.
+    dynlib: dllname, importc: "glColorSubTable".}
+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, 
+    importc: "glConvolutionFilter1D".}
+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".}
+proc glConvolutionParameterfv*(target: TGLenum, pname: TGLenum, params: PGLfloat){.
+    dynlib: dllname, importc: "glConvolutionParameterfv".}
+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, 
+                                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, 
+    importc: "glCopyConvolutionFilter2D".}
+proc glGetConvolutionFilter*(target: TGLenum, format: TGLenum, thetype: TGLenum, 
+                             image: PGLvoid){.dynlib: dllname, 
+    importc: "glGetConvolutionFilter".}
+proc glGetConvolutionParameterfv*(target: TGLenum, pname: TGLenum, 
+                                  params: PGLfloat){.dynlib: dllname, 
+    importc: "glGetConvolutionParameterfv".}
+proc glGetConvolutionParameteriv*(target: TGLenum, pname: TGLenum, 
+                                  params: PGLint){.dynlib: dllname, 
+    importc: "glGetConvolutionParameteriv".}
+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, 
+                          thetype: TGLenum, row: PGLvoid, column: PGLvoid){.
+    dynlib: dllname, importc: "glSeparableFilter2D".}
+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, 
+    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, 
+    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, 
+                  sink: TGLboolean){.dynlib: dllname, importc: "glHistogram".}
+proc glMinmax*(target: TGLenum, internalformat: TGLenum, sink: TGLboolean){.
+    dynlib: dllname, importc: "glMinmax".}
+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, 
+                   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, 
+    importc: "glTexSubImage3D".}
+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, 
+    importc: "glActiveTextureARB".}
+proc glClientActiveTextureARB*(texture: TGLenum){.dynlib: dllname, 
+    importc: "glClientActiveTextureARB".}
+proc glMultiTexCoord1dARB*(target: TGLenum, s: TGLdouble){.dynlib: dllname, 
+    importc: "glMultiTexCoord1dARB".}
+proc glMultiTexCoord1dvARB*(target: TGLenum, v: PGLdouble){.dynlib: dllname, 
+    importc: "glMultiTexCoord1dvARB".}
+proc glMultiTexCoord1fARB*(target: TGLenum, s: TGLfloat){.dynlib: dllname, 
+    importc: "glMultiTexCoord1fARB".}
+proc glMultiTexCoord1fvARB*(target: TGLenum, v: PGLfloat){.dynlib: dllname, 
+    importc: "glMultiTexCoord1fvARB".}
+proc glMultiTexCoord1iARB*(target: TGLenum, s: TGLint){.dynlib: dllname, 
+    importc: "glMultiTexCoord1iARB".}
+proc glMultiTexCoord1ivARB*(target: TGLenum, v: PGLint){.dynlib: dllname, 
+    importc: "glMultiTexCoord1ivARB".}
+proc glMultiTexCoord1sARB*(target: TGLenum, s: TGLshort){.dynlib: dllname, 
+    importc: "glMultiTexCoord1sARB".}
+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, 
+    importc: "glMultiTexCoord2dvARB".}
+proc glMultiTexCoord2fARB*(target: TGLenum, s: TGLfloat, t: TGLfloat){.
+    dynlib: dllname, importc: "glMultiTexCoord2fARB".}
+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, 
+    importc: "glMultiTexCoord2ivARB".}
+proc glMultiTexCoord2sARB*(target: TGLenum, s: TGLshort, t: TGLshort){.
+    dynlib: dllname, importc: "glMultiTexCoord2sARB".}
+proc glMultiTexCoord2svARB*(target: TGLenum, v: PGLshort){.dynlib: dllname, 
+    importc: "glMultiTexCoord2svARB".}
+proc glMultiTexCoord3dARB*(target: TGLenum, s: TGLdouble, t: TGLdouble, 
+                           r: TGLdouble){.dynlib: dllname, 
+    importc: "glMultiTexCoord3dARB".}
+proc glMultiTexCoord3dvARB*(target: TGLenum, v: PGLdouble){.dynlib: dllname, 
+    importc: "glMultiTexCoord3dvARB".}
+proc glMultiTexCoord3fARB*(target: TGLenum, s: TGLfloat, t: TGLfloat, 
+                           r: TGLfloat){.dynlib: dllname, 
+    importc: "glMultiTexCoord3fARB".}
+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, 
+    importc: "glMultiTexCoord3ivARB".}
+proc glMultiTexCoord3sARB*(target: TGLenum, s: TGLshort, t: TGLshort, 
+                           r: TGLshort){.dynlib: dllname, 
+    importc: "glMultiTexCoord3sARB".}
+proc glMultiTexCoord3svARB*(target: TGLenum, v: PGLshort){.dynlib: dllname, 
+    importc: "glMultiTexCoord3svARB".}
+proc glMultiTexCoord4dARB*(target: TGLenum, s: TGLdouble, t: TGLdouble, 
+                           r: TGLdouble, q: TGLdouble){.dynlib: dllname, 
+    importc: "glMultiTexCoord4dARB".}
+proc glMultiTexCoord4dvARB*(target: TGLenum, v: PGLdouble){.dynlib: dllname, 
+    importc: "glMultiTexCoord4dvARB".}
+proc glMultiTexCoord4fARB*(target: TGLenum, s: TGLfloat, t: TGLfloat, 
+                           r: TGLfloat, q: TGLfloat){.dynlib: dllname, 
+    importc: "glMultiTexCoord4fARB".}
+proc glMultiTexCoord4fvARB*(target: TGLenum, v: PGLfloat){.dynlib: dllname, 
+    importc: "glMultiTexCoord4fvARB".}
+proc glMultiTexCoord4iARB*(target: TGLenum, s: TGLint, t: TGLint, r: TGLint, 
+                           q: TGLint){.dynlib: dllname, 
+                                       importc: "glMultiTexCoord4iARB".}
+proc glMultiTexCoord4ivARB*(target: TGLenum, v: PGLint){.dynlib: dllname, 
+    importc: "glMultiTexCoord4ivARB".}
+proc glMultiTexCoord4sARB*(target: TGLenum, s: TGLshort, t: TGLshort, 
+                           r: TGLshort, q: TGLshort){.dynlib: dllname, 
+    importc: "glMultiTexCoord4sARB".}
+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, 
+    importc: "glWeightbvARB".}
+proc glWeightsvARB*(size: TGLint, weights: PGLshort){.dynlib: dllname, 
+    importc: "glWeightsvARB".}
+proc glWeightivARB*(size: TGLint, weights: PGLint){.dynlib: dllname, 
+    importc: "glWeightivARB".}
+proc glWeightfvARB*(size: TGLint, weights: PGLfloat){.dynlib: dllname, 
+    importc: "glWeightfvARB".}
+proc glWeightdvARB*(size: TGLint, weights: PGLdouble){.dynlib: dllname, 
+    importc: "glWeightdvARB".}
+proc glWeightvARB*(size: TGLint, weights: PGLdouble){.dynlib: dllname, 
+    importc: "glWeightvARB".}
+proc glWeightubvARB*(size: TGLint, weights: PGLubyte){.dynlib: dllname, 
+    importc: "glWeightubvARB".}
+proc glWeightusvARB*(size: TGLint, weights: PGLushort){.dynlib: dllname, 
+    importc: "glWeightusvARB".}
+proc glWeightuivARB*(size: TGLint, weights: PGLuint){.dynlib: dllname, 
+    importc: "glWeightuivARB".}
+proc glWeightPointerARB*(size: TGLint, thetype: TGLenum, stride: TGLsizei, 
+                         pointer: PGLvoid){.dynlib: dllname, 
+    importc: "glWeightPointerARB".}
+proc glVertexBlendARB*(count: TGLint){.dynlib: dllname, 
+                                       importc: "glVertexBlendARB".}
+proc glVertexAttrib1sARB*(index: TGLuint, x: TGLshort){.dynlib: dllname, 
+    importc: "glVertexAttrib1sARB".}
+proc glVertexAttrib1fARB*(index: TGLuint, x: TGLfloat){.dynlib: dllname, 
+    importc: "glVertexAttrib1fARB".}
+proc glVertexAttrib1dARB*(index: TGLuint, x: TGLdouble){.dynlib: dllname, 
+    importc: "glVertexAttrib1dARB".}
+proc glVertexAttrib2sARB*(index: TGLuint, x: TGLshort, y: TGLshort){.
+    dynlib: dllname, importc: "glVertexAttrib2sARB".}
+proc glVertexAttrib2fARB*(index: TGLuint, x: TGLfloat, y: TGLfloat){.
+    dynlib: dllname, importc: "glVertexAttrib2fARB".}
+proc glVertexAttrib2dARB*(index: TGLuint, x: TGLdouble, y: TGLdouble){.
+    dynlib: dllname, importc: "glVertexAttrib2dARB".}
+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, 
+    importc: "glVertexAttrib3dARB".}
+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, 
+                                        importc: "glVertexAttrib4fARB".}
+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, 
+    importc: "glVertexAttrib4NubARB".}
+proc glVertexAttrib1svARB*(index: TGLuint, v: PGLshort){.dynlib: dllname, 
+    importc: "glVertexAttrib1svARB".}
+proc glVertexAttrib1fvARB*(index: TGLuint, v: PGLfloat){.dynlib: dllname, 
+    importc: "glVertexAttrib1fvARB".}
+proc glVertexAttrib1dvARB*(index: TGLuint, v: PGLdouble){.dynlib: dllname, 
+    importc: "glVertexAttrib1dvARB".}
+proc glVertexAttrib2svARB*(index: TGLuint, v: PGLshort){.dynlib: dllname, 
+    importc: "glVertexAttrib2svARB".}
+proc glVertexAttrib2fvARB*(index: TGLuint, v: PGLfloat){.dynlib: dllname, 
+    importc: "glVertexAttrib2fvARB".}
+proc glVertexAttrib2dvARB*(index: TGLuint, v: PGLdouble){.dynlib: dllname, 
+    importc: "glVertexAttrib2dvARB".}
+proc glVertexAttrib3svARB*(index: TGLuint, v: PGLshort){.dynlib: dllname, 
+    importc: "glVertexAttrib3svARB".}
+proc glVertexAttrib3fvARB*(index: TGLuint, v: PGLfloat){.dynlib: dllname, 
+    importc: "glVertexAttrib3fvARB".}
+proc glVertexAttrib3dvARB*(index: TGLuint, v: PGLdouble){.dynlib: dllname, 
+    importc: "glVertexAttrib3dvARB".}
+proc glVertexAttrib4bvARB*(index: TGLuint, v: PGLbyte){.dynlib: dllname, 
+    importc: "glVertexAttrib4bvARB".}
+proc glVertexAttrib4svARB*(index: TGLuint, v: PGLshort){.dynlib: dllname, 
+    importc: "glVertexAttrib4svARB".}
+proc glVertexAttrib4ivARB*(index: TGLuint, v: PGLint){.dynlib: dllname, 
+    importc: "glVertexAttrib4ivARB".}
+proc glVertexAttrib4ubvARB*(index: TGLuint, v: PGLubyte){.dynlib: dllname, 
+    importc: "glVertexAttrib4ubvARB".}
+proc glVertexAttrib4usvARB*(index: TGLuint, v: PGLushort){.dynlib: dllname, 
+    importc: "glVertexAttrib4usvARB".}
+proc glVertexAttrib4uivARB*(index: TGLuint, v: PGLuint){.dynlib: dllname, 
+    importc: "glVertexAttrib4uivARB".}
+proc glVertexAttrib4fvARB*(index: TGLuint, v: PGLfloat){.dynlib: dllname, 
+    importc: "glVertexAttrib4fvARB".}
+proc glVertexAttrib4dvARB*(index: TGLuint, v: PGLdouble){.dynlib: dllname, 
+    importc: "glVertexAttrib4dvARB".}
+proc glVertexAttrib4NbvARB*(index: TGLuint, v: PGLbyte){.dynlib: dllname, 
+    importc: "glVertexAttrib4NbvARB".}
+proc glVertexAttrib4NsvARB*(index: TGLuint, v: PGLshort){.dynlib: dllname, 
+    importc: "glVertexAttrib4NsvARB".}
+proc glVertexAttrib4NivARB*(index: TGLuint, v: PGLint){.dynlib: dllname, 
+    importc: "glVertexAttrib4NivARB".}
+proc glVertexAttrib4NubvARB*(index: TGLuint, v: PGLubyte){.dynlib: dllname, 
+    importc: "glVertexAttrib4NubvARB".}
+proc glVertexAttrib4NusvARB*(index: TGLuint, v: PGLushort){.dynlib: dllname, 
+    importc: "glVertexAttrib4NusvARB".}
+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, 
+    importc: "glVertexAttribPointerARB".}
+proc glEnableVertexAttribArrayARB*(index: TGLuint){.dynlib: dllname, 
+    importc: "glEnableVertexAttribArrayARB".}
+proc glDisableVertexAttribArrayARB*(index: TGLuint){.dynlib: dllname, 
+    importc: "glDisableVertexAttribArrayARB".}
+proc glProgramStringARB*(target: TGLenum, format: TGLenum, length: TGLsizei, 
+                         str: PGLvoid){.dynlib: dllname, 
+                                        importc: "glProgramStringARB".}
+proc glBindProgramARB*(target: TGLenum, theProgram: TGLuint){.dynlib: dllname, 
+    importc: "glBindProgramARB".}
+proc glDeleteProgramsARB*(n: TGLsizei, programs: PGLuint){.dynlib: dllname, 
+    importc: "glDeleteProgramsARB".}
+proc glGenProgramsARB*(n: TGLsizei, programs: PGLuint){.dynlib: dllname, 
+    importc: "glGenProgramsARB".}
+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, 
+    importc: "glProgramEnvParameter4dvARB".}
+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, 
+    importc: "glProgramEnvParameter4fvARB".}
+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, 
+    importc: "glProgramLocalParameter4dvARB".}
+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, 
+    importc: "glProgramLocalParameter4fvARB".}
+proc glGetProgramEnvParameterdvARB*(target: TGLenum, index: TGLuint, 
+                                    params: PGLdouble){.dynlib: dllname, 
+    importc: "glGetProgramEnvParameterdvARB".}
+proc glGetProgramEnvParameterfvARB*(target: TGLenum, index: TGLuint, 
+                                    params: PGLfloat){.dynlib: dllname, 
+    importc: "glGetProgramEnvParameterfvARB".}
+proc glGetProgramLocalParameterdvARB*(target: TGLenum, index: TGLuint, 
+                                      params: PGLdouble){.dynlib: dllname, 
+    importc: "glGetProgramLocalParameterdvARB".}
+proc glGetProgramLocalParameterfvARB*(target: TGLenum, index: TGLuint, 
+                                      params: PGLfloat){.dynlib: dllname, 
+    importc: "glGetProgramLocalParameterfvARB".}
+proc glGetProgramivARB*(target: TGLenum, pname: TGLenum, params: PGLint){.
+    dynlib: dllname, importc: "glGetProgramivARB".}
+proc glGetProgramStringARB*(target: TGLenum, pname: TGLenum, str: PGLvoid){.
+    dynlib: dllname, importc: "glGetProgramStringARB".}
+proc glGetVertexAttribdvARB*(index: TGLuint, pname: TGLenum, params: PGLdouble){.
+    dynlib: dllname, importc: "glGetVertexAttribdvARB".}
+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, 
+    importc: "glGetVertexAttribPointervARB".}
+proc glIsProgramARB*(theProgram: TGLuint): TGLboolean{.dynlib: dllname, 
+    importc: "glIsProgramARB".}
+  #***** GL_ARB_window_pos *****//
+proc glWindowPos2dARB*(x: TGLdouble, y: TGLdouble){.dynlib: dllname, 
+    importc: "glWindowPos2dARB".}
+proc glWindowPos2fARB*(x: TGLfloat, y: TGLfloat){.dynlib: dllname, 
+    importc: "glWindowPos2fARB".}
+proc glWindowPos2iARB*(x: TGLint, y: TGLint){.dynlib: dllname, 
+    importc: "glWindowPos2iARB".}
+proc glWindowPos2sARB*(x: TGLshort, y: TGLshort){.dynlib: dllname, 
+    importc: "glWindowPos2sARB".}
+proc glWindowPos2dvARB*(p: PGLdouble){.dynlib: dllname, 
+                                       importc: "glWindowPos2dvARB".}
+proc glWindowPos2fvARB*(p: PGLfloat){.dynlib: dllname, 
+                                      importc: "glWindowPos2fvARB".}
+proc glWindowPos2ivARB*(p: PGLint){.dynlib: dllname, 
+                                    importc: "glWindowPos2ivARB".}
+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, 
+    importc: "glWindowPos3fARB".}
+proc glWindowPos3iARB*(x: TGLint, y: TGLint, z: TGLint){.dynlib: dllname, 
+    importc: "glWindowPos3iARB".}
+proc glWindowPos3sARB*(x: TGLshort, y: TGLshort, z: TGLshort){.dynlib: dllname, 
+    importc: "glWindowPos3sARB".}
+proc glWindowPos3dvARB*(p: PGLdouble){.dynlib: dllname, 
+                                       importc: "glWindowPos3dvARB".}
+proc glWindowPos3fvARB*(p: PGLfloat){.dynlib: dllname, 
+                                      importc: "glWindowPos3fvARB".}
+proc glWindowPos3ivARB*(p: PGLint){.dynlib: dllname, 
+                                    importc: "glWindowPos3ivARB".}
+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, 
+    importc: "glDrawBuffers".}
+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, 
+    importc: "glStencilFuncSeparate".}
+proc glStencilMaskSeparate*(face: TGLenum, mask: TGLuint){.dynlib: dllname, 
+    importc: "glStencilMaskSeparate".}
+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, 
+                                        importc: "glCompileShader".}
+proc glCreateProgram*(): TGLuint{.dynlib: dllname, importc: "glCreateProgram".}
+proc glCreateShader*(thetype: TGLenum): TGLuint{.dynlib: dllname, 
+    importc: "glCreateShader".}
+proc glDeleteProgram*(theProgram: TGLuint){.dynlib: dllname, 
+    importc: "glDeleteProgram".}
+proc glDeleteShader*(shader: TGLuint){.dynlib: dllname, 
+                                       importc: "glDeleteShader".}
+proc glDetachShader*(theProgram: TGLuint, shader: TGLuint){.dynlib: dllname, 
+    importc: "glDetachShader".}
+proc glDisableVertexAttribArray*(index: TGLuint){.dynlib: dllname, 
+    importc: "glDisableVertexAttribArray".}
+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, 
+                                        importc: "glGetActiveAttrib".}
+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, 
+    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, 
+    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, 
+    importc: "glGetShaderInfoLog".}
+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".}
+proc glGetUniformfv*(theProgram: TGLuint, location: TGLint, params: PGLfloat){.
+    dynlib: dllname, importc: "glGetUniformfv".}
+proc glGetUniformiv*(theProgram: TGLuint, location: TGLint, params: PGLint){.
+    dynlib: dllname, importc: "glGetUniformiv".}
+proc glGetVertexAttribdv*(index: TGLuint, pname: TGLenum, params: PGLdouble){.
+    dynlib: dllname, importc: "glGetVertexAttribdv".}
+proc glGetVertexAttribfv*(index: TGLuint, pname: TGLenum, params: PGLfloat){.
+    dynlib: dllname, importc: "glGetVertexAttribfv".}
+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, 
+    importc: "glIsProgram".}
+proc glIsShader*(shader: TGLuint): TGLboolean{.dynlib: dllname, 
+    importc: "glIsShader".}
+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, 
+    importc: "glUseProgram".}
+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, 
+                  v3: TGLfloat){.dynlib: dllname, importc: "glUniform4f".}
+proc glUniform1i*(location: TGLint, v0: TGLint){.dynlib: dllname, 
+    importc: "glUniform1i".}
+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, 
+                  v3: TGLint){.dynlib: dllname, importc: "glUniform4i".}
+proc glUniform1fv*(location: TGLint, count: TGLsizei, value: PGLfloat){.
+    dynlib: dllname, importc: "glUniform1fv".}
+proc glUniform2fv*(location: TGLint, count: TGLsizei, value: PGLfloat){.
+    dynlib: dllname, importc: "glUniform2fv".}
+proc glUniform3fv*(location: TGLint, count: TGLsizei, value: PGLfloat){.
+    dynlib: dllname, importc: "glUniform3fv".}
+proc glUniform4fv*(location: TGLint, count: TGLsizei, value: PGLfloat){.
+    dynlib: dllname, importc: "glUniform4fv".}
+proc glUniform1iv*(location: TGLint, count: TGLsizei, value: PGLint){.
+    dynlib: dllname, importc: "glUniform1iv".}
+proc glUniform2iv*(location: TGLint, count: TGLsizei, value: PGLint){.
+    dynlib: dllname, importc: "glUniform2iv".}
+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, 
+                         transpose: TGLboolean, value: PGLfloat){.
+    dynlib: dllname, importc: "glUniformMatrix2fv".}
+proc glUniformMatrix3fv*(location: TGLint, count: TGLsizei, 
+                         transpose: TGLboolean, value: PGLfloat){.
+    dynlib: dllname, importc: "glUniformMatrix3fv".}
+proc glUniformMatrix4fv*(location: TGLint, count: TGLsizei, 
+                         transpose: TGLboolean, value: PGLfloat){.
+    dynlib: dllname, importc: "glUniformMatrix4fv".}
+proc glValidateProgram*(theProgram: TGLuint){.dynlib: dllname, 
+    importc: "glValidateProgram".}
+proc glVertexAttrib1d*(index: TGLuint, x: TGLdouble){.dynlib: dllname, 
+    importc: "glVertexAttrib1d".}
+proc glVertexAttrib1dv*(index: TGLuint, v: PGLdouble){.dynlib: dllname, 
+    importc: "glVertexAttrib1dv".}
+proc glVertexAttrib1f*(index: TGLuint, x: TGLfloat){.dynlib: dllname, 
+    importc: "glVertexAttrib1f".}
+proc glVertexAttrib1fv*(index: TGLuint, v: PGLfloat){.dynlib: dllname, 
+    importc: "glVertexAttrib1fv".}
+proc glVertexAttrib1s*(index: TGLuint, x: TGLshort){.dynlib: dllname, 
+    importc: "glVertexAttrib1s".}
+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, 
+    importc: "glVertexAttrib2dv".}
+proc glVertexAttrib2f*(index: TGLuint, x: TGLfloat, y: TGLfloat){.
+    dynlib: dllname, importc: "glVertexAttrib2f".}
+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, 
+    importc: "glVertexAttrib2sv".}
+proc glVertexAttrib3d*(index: TGLuint, x: TGLdouble, y: TGLdouble, z: TGLdouble){.
+    dynlib: dllname, importc: "glVertexAttrib3d".}
+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, 
+    importc: "glVertexAttrib3fv".}
+proc glVertexAttrib3s*(index: TGLuint, x: TGLshort, y: TGLshort, z: TGLshort){.
+    dynlib: dllname, importc: "glVertexAttrib3s".}
+proc glVertexAttrib3sv*(index: TGLuint, v: PGLshort){.dynlib: dllname, 
+    importc: "glVertexAttrib3sv".}
+proc glVertexAttrib4Nbv*(index: TGLuint, v: PGLbyte){.dynlib: dllname, 
+    importc: "glVertexAttrib4Nbv".}
+proc glVertexAttrib4Niv*(index: TGLuint, v: PGLint){.dynlib: dllname, 
+    importc: "glVertexAttrib4Niv".}
+proc glVertexAttrib4Nsv*(index: TGLuint, v: PGLshort){.dynlib: dllname, 
+    importc: "glVertexAttrib4Nsv".}
+proc glVertexAttrib4Nub*(index: TGLuint, x: TGLubyte, y: TGLubyte, z: TGLubyte, 
+                         w: TGLubyte){.dynlib: dllname, 
+                                       importc: "glVertexAttrib4Nub".}
+proc glVertexAttrib4Nubv*(index: TGLuint, v: PGLubyte){.dynlib: dllname, 
+    importc: "glVertexAttrib4Nubv".}
+proc glVertexAttrib4Nuiv*(index: TGLuint, v: PGLuint){.dynlib: dllname, 
+    importc: "glVertexAttrib4Nuiv".}
+proc glVertexAttrib4Nusv*(index: TGLuint, v: PGLushort){.dynlib: dllname, 
+    importc: "glVertexAttrib4Nusv".}
+proc glVertexAttrib4bv*(index: TGLuint, v: PGLbyte){.dynlib: dllname, 
+    importc: "glVertexAttrib4bv".}
+proc glVertexAttrib4d*(index: TGLuint, x: TGLdouble, y: TGLdouble, z: TGLdouble, 
+                       w: TGLdouble){.dynlib: dllname, 
+                                      importc: "glVertexAttrib4d".}
+proc glVertexAttrib4dv*(index: TGLuint, v: PGLdouble){.dynlib: dllname, 
+    importc: "glVertexAttrib4dv".}
+proc glVertexAttrib4f*(index: TGLuint, x: TGLfloat, y: TGLfloat, z: TGLfloat, 
+                       w: TGLfloat){.dynlib: dllname, 
+                                     importc: "glVertexAttrib4f".}
+proc glVertexAttrib4fv*(index: TGLuint, v: PGLfloat){.dynlib: dllname, 
+    importc: "glVertexAttrib4fv".}
+proc glVertexAttrib4iv*(index: TGLuint, v: PGLint){.dynlib: dllname, 
+    importc: "glVertexAttrib4iv".}
+proc glVertexAttrib4s*(index: TGLuint, x: TGLshort, y: TGLshort, z: TGLshort, 
+                       w: TGLshort){.dynlib: dllname, 
+                                     importc: "glVertexAttrib4s".}
+proc glVertexAttrib4sv*(index: TGLuint, v: PGLshort){.dynlib: dllname, 
+    importc: "glVertexAttrib4sv".}
+proc glVertexAttrib4ubv*(index: TGLuint, v: PGLubyte){.dynlib: dllname, 
+    importc: "glVertexAttrib4ubv".}
+proc glVertexAttrib4uiv*(index: TGLuint, v: PGLuint){.dynlib: dllname, 
+    importc: "glVertexAttrib4uiv".}
+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, 
+    importc: "glVertexAttribPointer".}
+const 
+  GL_CONSTANT_COLOR* = 0x00008001
+  GL_ONE_MINUS_CONSTANT_COLOR* = 0x00008002
+  GL_CONSTANT_ALPHA* = 0x00008003
+  GL_ONE_MINUS_CONSTANT_ALPHA* = 0x00008004
+  constGL_BLEND_COLOR* = 0x00008005
+  GL_FUNC_ADD* = 0x00008006
+  GL_MIN* = 0x00008007
+  GL_MAX* = 0x00008008
+  constGL_BLEND_EQUATION* = 0x00008009
+  GL_FUNC_SUBTRACT* = 0x0000800A
+  GL_FUNC_REVERSE_SUBTRACT* = 0x0000800B
+  GL_CONVOLUTION_1D* = 0x00008010
+  GL_CONVOLUTION_2D* = 0x00008011
+  GL_SEPARABLE_2D* = 0x00008012
+  GL_CONVOLUTION_BORDER_MODE* = 0x00008013
+  GL_CONVOLUTION_FILTER_SCALE* = 0x00008014
+  GL_CONVOLUTION_FILTER_BIAS* = 0x00008015
+  GL_REDUCE* = 0x00008016
+  GL_CONVOLUTION_FORMAT* = 0x00008017
+  GL_CONVOLUTION_WIDTH* = 0x00008018
+  GL_CONVOLUTION_HEIGHT* = 0x00008019
+  GL_MAX_CONVOLUTION_WIDTH* = 0x0000801A
+  GL_MAX_CONVOLUTION_HEIGHT* = 0x0000801B
+  GL_POST_CONVOLUTION_RED_SCALE* = 0x0000801C
+  GL_POST_CONVOLUTION_GREEN_SCALE* = 0x0000801D
+  GL_POST_CONVOLUTION_BLUE_SCALE* = 0x0000801E
+  GL_POST_CONVOLUTION_ALPHA_SCALE* = 0x0000801F
+  GL_POST_CONVOLUTION_RED_BIAS* = 0x00008020
+  GL_POST_CONVOLUTION_GREEN_BIAS* = 0x00008021
+  GL_POST_CONVOLUTION_BLUE_BIAS* = 0x00008022
+  GL_POST_CONVOLUTION_ALPHA_BIAS* = 0x00008023
+  constGL_HISTOGRAM* = 0x00008024
+  GL_PROXY_HISTOGRAM* = 0x00008025
+  GL_HISTOGRAM_WIDTH* = 0x00008026
+  GL_HISTOGRAM_FORMAT* = 0x00008027
+  GL_HISTOGRAM_RED_SIZE* = 0x00008028
+  GL_HISTOGRAM_GREEN_SIZE* = 0x00008029
+  GL_HISTOGRAM_BLUE_SIZE* = 0x0000802A
+  GL_HISTOGRAM_ALPHA_SIZE* = 0x0000802B
+  GL_HISTOGRAM_LUMINANCE_SIZE* = 0x0000802C
+  GL_HISTOGRAM_SINK* = 0x0000802D
+  constGL_MINMAX* = 0x0000802E
+  GL_MINMAX_FORMAT* = 0x0000802F
+  GL_MINMAX_SINK* = 0x00008030
+  GL_TABLE_TOO_LARGE* = 0x00008031
+  GL_COLOR_MATRIX* = 0x000080B1
+  GL_COLOR_MATRIX_STACK_DEPTH* = 0x000080B2
+  GL_MAX_COLOR_MATRIX_STACK_DEPTH* = 0x000080B3
+  GL_POST_COLOR_MATRIX_RED_SCALE* = 0x000080B4
+  GL_POST_COLOR_MATRIX_GREEN_SCALE* = 0x000080B5
+  GL_POST_COLOR_MATRIX_BLUE_SCALE* = 0x000080B6
+  GL_POST_COLOR_MATRIX_ALPHA_SCALE* = 0x000080B7
+  GL_POST_COLOR_MATRIX_RED_BIAS* = 0x000080B8
+  GL_POST_COLOR_MATRIX_GREEN_BIAS* = 0x000080B9
+  GL_POST_COLOR_MATRIX_BLUE_BIAS* = 0x000080BA
+  GL_POST_COLOR_MATIX_ALPHA_BIAS* = 0x000080BB
+  constGL_COLOR_TABLE* = 0x000080D0
+  GL_POST_CONVOLUTION_COLOR_TABLE* = 0x000080D1
+  GL_POST_COLOR_MATRIX_COLOR_TABLE* = 0x000080D2
+  GL_PROXY_COLOR_TABLE* = 0x000080D3
+  GL_PROXY_POST_CONVOLUTION_COLOR_TABLE* = 0x000080D4
+  GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE* = 0x000080D5
+  GL_COLOR_TABLE_SCALE* = 0x000080D6
+  GL_COLOR_TABLE_BIAS* = 0x000080D7
+  GL_COLOR_TABLE_FORMAT* = 0x000080D8
+  GL_COLOR_TABLE_WIDTH* = 0x000080D9
+  GL_COLOR_TABLE_RED_SIZE* = 0x000080DA
+  GL_COLOR_TABLE_GREEN_SIZE* = 0x000080DB
+  GL_COLOR_TABLE_BLUE_SIZE* = 0x000080DC
+  GL_COLOR_TABLE_ALPHA_SIZE* = 0x000080DD
+  GL_COLOR_TABLE_LUMINANCE_SIZE* = 0x000080DE
+  GL_COLOR_TABLE_INTENSITY_SIZE* = 0x000080DF
+  GL_IGNORE_BORDER* = 0x00008150
+  GL_CONSTANT_BORDER* = 0x00008151
+  GL_WRAP_BORDER* = 0x00008152
+  GL_REPLICATE_BORDER* = 0x00008153
+  GL_CONVOLUTION_BORDER_COLOR* = 0x00008154
+
+proc glActiveTexture*(texture: TGLenum){.dynlib: dllname, 
+    importc: "glActiveTexture".}
+proc glClientActiveTexture*(texture: TGLenum){.dynlib: dllname, 
+    importc: "glClientActiveTexture".}
+proc glMultiTexCoord1d*(target: TGLenum, s: TGLdouble){.dynlib: dllname, 
+    importc: "glMultiTexCoord1d".}
+proc glMultiTexCoord1dv*(target: TGLenum, v: PGLdouble){.dynlib: dllname, 
+    importc: "glMultiTexCoord1dv".}
+proc glMultiTexCoord1f*(target: TGLenum, s: TGLfloat){.dynlib: dllname, 
+    importc: "glMultiTexCoord1f".}
+proc glMultiTexCoord1fv*(target: TGLenum, v: PGLfloat){.dynlib: dllname, 
+    importc: "glMultiTexCoord1fv".}
+proc glMultiTexCoord1i*(target: TGLenum, s: TGLint){.dynlib: dllname, 
+    importc: "glMultiTexCoord1i".}
+proc glMultiTexCoord1iv*(target: TGLenum, v: PGLint){.dynlib: dllname, 
+    importc: "glMultiTexCoord1iv".}
+proc glMultiTexCoord1s*(target: TGLenum, s: TGLshort){.dynlib: dllname, 
+    importc: "glMultiTexCoord1s".}
+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, 
+    importc: "glMultiTexCoord2dv".}
+proc glMultiTexCoord2f*(target: TGLenum, s: TGLfloat, t: TGLfloat){.
+    dynlib: dllname, importc: "glMultiTexCoord2f".}
+proc glMultiTexCoord2fv*(target: TGLenum, v: PGLfloat){.dynlib: dllname, 
+    importc: "glMultiTexCoord2fv".}
+proc glMultiTexCoord2i*(target: TGLenum, s: TGLint, t: TGLint){.dynlib: dllname, 
+    importc: "glMultiTexCoord2i".}
+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, 
+    importc: "glMultiTexCoord2sv".}
+proc glMultiTexCoord3d*(target: TGLenum, s: TGLdouble, t: TGLdouble, 
+                        r: TGLdouble){.dynlib: dllname, 
+                                       importc: "glMultiTexCoord3d".}
+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, 
+    importc: "glMultiTexCoord3fv".}
+proc glMultiTexCoord3i*(target: TGLenum, s: TGLint, t: TGLint, r: TGLint){.
+    dynlib: dllname, importc: "glMultiTexCoord3i".}
+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, 
+    importc: "glMultiTexCoord3sv".}
+proc glMultiTexCoord4d*(target: TGLenum, s: TGLdouble, t: TGLdouble, 
+                        r: TGLdouble, q: TGLdouble){.dynlib: dllname, 
+    importc: "glMultiTexCoord4d".}
+proc glMultiTexCoord4dv*(target: TGLenum, v: PGLdouble){.dynlib: dllname, 
+    importc: "glMultiTexCoord4dv".}
+proc glMultiTexCoord4f*(target: TGLenum, s: TGLfloat, t: TGLfloat, r: TGLfloat, 
+                        q: TGLfloat){.dynlib: dllname, 
+                                      importc: "glMultiTexCoord4f".}
+proc glMultiTexCoord4fv*(target: TGLenum, v: PGLfloat){.dynlib: dllname, 
+    importc: "glMultiTexCoord4fv".}
+proc glMultiTexCoord4i*(target: TGLenum, s: TGLint, t: TGLint, r: TGLint, 
+                        q: TGLint){.dynlib: dllname, 
+                                    importc: "glMultiTexCoord4i".}
+proc glMultiTexCoord4iv*(target: TGLenum, v: PGLint){.dynlib: dllname, 
+    importc: "glMultiTexCoord4iv".}
+proc glMultiTexCoord4s*(target: TGLenum, s: TGLshort, t: TGLshort, r: TGLshort, 
+                        q: TGLshort){.dynlib: dllname, 
+                                      importc: "glMultiTexCoord4s".}
+proc glMultiTexCoord4sv*(target: TGLenum, v: PGLshort){.dynlib: dllname, 
+    importc: "glMultiTexCoord4sv".}
+proc glLoadTransposeMatrixf*(m: PGLfloat){.dynlib: dllname, 
+    importc: "glLoadTransposeMatrixf".}
+proc glLoadTransposeMatrixd*(m: PGLdouble){.dynlib: dllname, 
+    importc: "glLoadTransposeMatrixd".}
+proc glMultTransposeMatrixf*(m: PGLfloat){.dynlib: dllname, 
+    importc: "glMultTransposeMatrixf".}
+proc glMultTransposeMatrixd*(m: PGLdouble){.dynlib: dllname, 
+    importc: "glMultTransposeMatrixd".}
+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, 
+                             imageSize: TGLsizei, data: PGLvoid){.
+    dynlib: dllname, importc: "glCompressedTexImage3D".}
+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, 
+                             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, 
+                                imageSize: TGLsizei, data: PGLvoid){.
+    dynlib: dllname, importc: "glCompressedTexSubImage3D".}
+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, 
+                                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 
+  GL_TEXTURE0* = 0x000084C0
+  GL_TEXTURE1* = 0x000084C1
+  GL_TEXTURE2* = 0x000084C2
+  GL_TEXTURE3* = 0x000084C3
+  GL_TEXTURE4* = 0x000084C4
+  GL_TEXTURE5* = 0x000084C5
+  GL_TEXTURE6* = 0x000084C6
+  GL_TEXTURE7* = 0x000084C7
+  GL_TEXTURE8* = 0x000084C8
+  GL_TEXTURE9* = 0x000084C9
+  GL_TEXTURE10* = 0x000084CA
+  GL_TEXTURE11* = 0x000084CB
+  GL_TEXTURE12* = 0x000084CC
+  GL_TEXTURE13* = 0x000084CD
+  GL_TEXTURE14* = 0x000084CE
+  GL_TEXTURE15* = 0x000084CF
+  GL_TEXTURE16* = 0x000084D0
+  GL_TEXTURE17* = 0x000084D1
+  GL_TEXTURE18* = 0x000084D2
+  GL_TEXTURE19* = 0x000084D3
+  GL_TEXTURE20* = 0x000084D4
+  GL_TEXTURE21* = 0x000084D5
+  GL_TEXTURE22* = 0x000084D6
+  GL_TEXTURE23* = 0x000084D7
+  GL_TEXTURE24* = 0x000084D8
+  GL_TEXTURE25* = 0x000084D9
+  GL_TEXTURE26* = 0x000084DA
+  GL_TEXTURE27* = 0x000084DB
+  GL_TEXTURE28* = 0x000084DC
+  GL_TEXTURE29* = 0x000084DD
+  GL_TEXTURE30* = 0x000084DE
+  GL_TEXTURE31* = 0x000084DF
+  constGL_ACTIVE_TEXTURE* = 0x000084E0
+  constGL_CLIENT_ACTIVE_TEXTURE* = 0x000084E1
+  GL_MAX_TEXTURE_UNITS* = 0x000084E2
+  GL_TRANSPOSE_MODELVIEW_MATRIX* = 0x000084E3
+  GL_TRANSPOSE_PROJECTION_MATRIX* = 0x000084E4
+  GL_TRANSPOSE_TEXTURE_MATRIX* = 0x000084E5
+  GL_TRANSPOSE_COLOR_MATRIX* = 0x000084E6
+  GL_MULTISAMPLE* = 0x0000809D
+  GL_SAMPLE_ALPHA_TO_COVERAGE* = 0x0000809E
+  GL_SAMPLE_ALPHA_TO_ONE* = 0x0000809F
+  constGL_SAMPLE_COVERAGE* = 0x000080A0
+  GL_SAMPLE_BUFFERS* = 0x000080A8
+  GL_SAMPLES* = 0x000080A9
+  GL_SAMPLE_COVERAGE_VALUE* = 0x000080AA
+  GL_SAMPLE_COVERAGE_INVERT* = 0x000080AB
+  GL_MULTISAMPLE_BIT* = 0x20000000
+  GL_NORMAL_MAP* = 0x00008511
+  GL_REFLECTION_MAP* = 0x00008512
+  GL_TEXTURE_CUBE_MAP* = 0x00008513
+  GL_TEXTURE_BINDING_CUBE_MAP* = 0x00008514
+  GL_TEXTURE_CUBE_MAP_POSITIVE_X* = 0x00008515
+  GL_TEXTURE_CUBE_MAP_NEGATIVE_X* = 0x00008516
+  GL_TEXTURE_CUBE_MAP_POSITIVE_Y* = 0x00008517
+  GL_TEXTURE_CUBE_MAP_NEGATIVE_Y* = 0x00008518
+  GL_TEXTURE_CUBE_MAP_POSITIVE_Z* = 0x00008519
+  GL_TEXTURE_CUBE_MAP_NEGATIVE_Z* = 0x0000851A
+  GL_PROXY_TEXTURE_CUBE_MAP* = 0x0000851B
+  GL_MAX_CUBE_MAP_TEXTURE_SIZE* = 0x0000851C
+  GL_COMPRESSED_ALPHA* = 0x000084E9
+  GL_COMPRESSED_LUMINANCE* = 0x000084EA
+  GL_COMPRESSED_LUMINANCE_ALPHA* = 0x000084EB
+  GL_COMPRESSED_INTENSITY* = 0x000084EC
+  GL_COMPRESSED_RGB* = 0x000084ED
+  GL_COMPRESSED_RGBA* = 0x000084EE
+  GL_TEXTURE_COMPRESSION_HINT* = 0x000084EF
+  GL_TEXTURE_COMPRESSED_IMAGE_SIZE* = 0x000086A0
+  GL_TEXTURE_COMPRESSED* = 0x000086A1
+  GL_NUM_COMPRESSED_TEXTURE_FORMATS* = 0x000086A2
+  GL_COMPRESSED_TEXTURE_FORMATS* = 0x000086A3
+  GL_CLAMP_TO_BORDER* = 0x0000812D
+  GL_CLAMP_TO_BORDER_SGIS* = 0x0000812D
+  GL_COMBINE* = 0x00008570
+  GL_COMBINE_RGB* = 0x00008571
+  GL_COMBINE_ALPHA* = 0x00008572
+  GL_SOURCE0_RGB* = 0x00008580
+  GL_SOURCE1_RGB* = 0x00008581
+  GL_SOURCE2_RGB* = 0x00008582
+  GL_SOURCE0_ALPHA* = 0x00008588
+  GL_SOURCE1_ALPHA* = 0x00008589
+  GL_SOURCE2_ALPHA* = 0x0000858A
+  GL_OPERAND0_RGB* = 0x00008590
+  GL_OPERAND1_RGB* = 0x00008591
+  GL_OPERAND2_RGB* = 0x00008592
+  GL_OPERAND0_ALPHA* = 0x00008598
+  GL_OPERAND1_ALPHA* = 0x00008599
+  GL_OPERAND2_ALPHA* = 0x0000859A
+  GL_RGB_SCALE* = 0x00008573
+  GL_ADD_SIGNED* = 0x00008574
+  GL_INTERPOLATE* = 0x00008575
+  GL_SUBTRACT* = 0x000084E7
+  GL_CONSTANT* = 0x00008576
+  GL_PRIMARY_COLOR* = 0x00008577
+  GL_PREVIOUS* = 0x00008578
+  GL_DOT3_RGB* = 0x000086AE
+  GL_DOT3_RGBA* = 0x000086AF
+
+const 
+  GL_TEXTURE0_ARB* = 0x000084C0
+  GL_TEXTURE1_ARB* = 0x000084C1
+  GL_TEXTURE2_ARB* = 0x000084C2
+  GL_TEXTURE3_ARB* = 0x000084C3
+  GL_TEXTURE4_ARB* = 0x000084C4
+  GL_TEXTURE5_ARB* = 0x000084C5
+  GL_TEXTURE6_ARB* = 0x000084C6
+  GL_TEXTURE7_ARB* = 0x000084C7
+  GL_TEXTURE8_ARB* = 0x000084C8
+  GL_TEXTURE9_ARB* = 0x000084C9
+  GL_TEXTURE10_ARB* = 0x000084CA
+  GL_TEXTURE11_ARB* = 0x000084CB
+  GL_TEXTURE12_ARB* = 0x000084CC
+  GL_TEXTURE13_ARB* = 0x000084CD
+  GL_TEXTURE14_ARB* = 0x000084CE
+  GL_TEXTURE15_ARB* = 0x000084CF
+  GL_TEXTURE16_ARB* = 0x000084D0
+  GL_TEXTURE17_ARB* = 0x000084D1
+  GL_TEXTURE18_ARB* = 0x000084D2
+  GL_TEXTURE19_ARB* = 0x000084D3
+  GL_TEXTURE20_ARB* = 0x000084D4
+  GL_TEXTURE21_ARB* = 0x000084D5
+  GL_TEXTURE22_ARB* = 0x000084D6
+  GL_TEXTURE23_ARB* = 0x000084D7
+  GL_TEXTURE24_ARB* = 0x000084D8
+  GL_TEXTURE25_ARB* = 0x000084D9
+  GL_TEXTURE26_ARB* = 0x000084DA
+  GL_TEXTURE27_ARB* = 0x000084DB
+  GL_TEXTURE28_ARB* = 0x000084DC
+  GL_TEXTURE29_ARB* = 0x000084DD
+  GL_TEXTURE30_ARB* = 0x000084DE
+  GL_TEXTURE31_ARB* = 0x000084DF
+  constGL_ACTIVE_TEXTURE_ARB* = 0x000084E0
+  constGL_CLIENT_ACTIVE_TEXTURE_ARB* = 0x000084E1
+  GL_MAX_TEXTURE_UNITS_ARB* = 0x000084E2
+  #***** GL_ARB_transpose_matrix *****//
+
+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, 
+    importc: "glLoadTransposeMatrixfARB".}
+proc glLoadTransposeMatrixdARB*(m: PGLdouble){.dynlib: dllname, 
+    importc: "glLoadTransposeMatrixdARB".}
+proc glMultTransposeMatrixfARB*(m: PGLfloat){.dynlib: dllname, 
+    importc: "glMultTransposeMatrixfARB".}
+proc glMultTransposeMatrixdARB*(m: PGLdouble){.dynlib: dllname, 
+    importc: "glMultTransposeMatrixdARB".}
+const 
+  WGL_SAMPLE_BUFFERS_ARB* = 0x00002041
+  WGL_SAMPLES_ARB* = 0x00002042
+  GL_MULTISAMPLE_ARB* = 0x0000809D
+  GL_SAMPLE_ALPHA_TO_COVERAGE_ARB* = 0x0000809E
+  GL_SAMPLE_ALPHA_TO_ONE_ARB* = 0x0000809F
+  constGL_SAMPLE_COVERAGE_ARB* = 0x000080A0
+  GL_MULTISAMPLE_BIT_ARB* = 0x20000000
+  GL_SAMPLE_BUFFERS_ARB* = 0x000080A8
+  GL_SAMPLES_ARB* = 0x000080A9
+  GL_SAMPLE_COVERAGE_VALUE_ARB* = 0x000080AA
+  GL_SAMPLE_COVERAGE_INVERT_ARB* = 0x000080AB
+
+const 
+  GL_NORMAL_MAP_ARB* = 0x00008511
+  GL_REFLECTION_MAP_ARB* = 0x00008512
+  GL_TEXTURE_CUBE_MAP_ARB* = 0x00008513
+  GL_TEXTURE_BINDING_CUBE_MAP_ARB* = 0x00008514
+  GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB* = 0x00008515
+  GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB* = 0x00008516
+  GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB* = 0x00008517
+  GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB* = 0x00008518
+  GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB* = 0x00008519
+  GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB* = 0x0000851A
+  GL_PROXY_TEXTURE_CUBE_MAP_ARB* = 0x0000851B
+  GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB* = 0x0000851C
+
+const 
+  GL_DEPTH_COMPONENT16_ARB* = 0x000081A5
+  GL_DEPTH_COMPONENT24_ARB* = 0x000081A6
+  GL_DEPTH_COMPONENT32_ARB* = 0x000081A7
+  GL_TEXTURE_DEPTH_SIZE_ARB* = 0x0000884A
+  GL_DEPTH_TEXTURE_MODE_ARB* = 0x0000884B
+  #***** GL_ARB_point_parameters *****//
+
+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, 
+    importc: "glPointParameterfARB".}
+proc glPointParameterfvARB*(pname: TGLenum, params: PGLfloat){.dynlib: dllname, 
+    importc: "glPointParameterfvARB".}
+const 
+  GL_TEXTURE_COMPARE_MODE_ARB* = 0x0000884C
+  GL_TEXTURE_COMPARE_FUNC_ARB* = 0x0000884D
+  GL_COMPARE_R_TO_TEXTURE_ARB* = 0x0000884E
+
+const 
+  GL_TEXTURE_COMPARE_FAIL_VALUE_ARB* = 0x000080BF
+  GL_CLAMP_TO_BORDER_ARB* = 0x0000812D
+
+const 
+  GL_COMPRESSED_ALPHA_ARB* = 0x000084E9
+  GL_COMPRESSED_LUMINANCE_ARB* = 0x000084EA
+  GL_COMPRESSED_LUMINANCE_ALPHA_ARB* = 0x000084EB
+  GL_COMPRESSED_INTENSITY_ARB* = 0x000084EC
+  GL_COMPRESSED_RGB_ARB* = 0x000084ED
+  GL_COMPRESSED_RGBA_ARB* = 0x000084EE
+  GL_TEXTURE_COMPRESSION_HINT_ARB* = 0x000084EF
+  GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB* = 0x000086A0
+  GL_TEXTURE_COMPRESSED_ARB* = 0x000086A1
+  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, 
+    importc: "glCompressedTexImage3DARB".}
+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, 
+    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, 
+    importc: "glCompressedTexSubImage3DARB".}
+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, 
+    importc: "glCompressedTexSubImage1DARB".}
+proc glGetCompressedTexImageARB*(target: TGLenum, lod: TGLint, img: PGLvoid){.
+    dynlib: dllname, importc: "glGetCompressedTexImageARB".}
+  #***** GL_ARB_texture_env_combine *****//
+const 
+  GL_COMBINE_ARB* = 0x00008570
+  GL_COMBINE_RGB_ARB* = 0x00008571
+  GL_COMBINE_ALPHA_ARB* = 0x00008572
+  GL_SOURCE0_RGB_ARB* = 0x00008580
+  GL_SOURCE1_RGB_ARB* = 0x00008581
+  GL_SOURCE2_RGB_ARB* = 0x00008582
+  GL_SOURCE0_ALPHA_ARB* = 0x00008588
+  GL_SOURCE1_ALPHA_ARB* = 0x00008589
+  GL_SOURCE2_ALPHA_ARB* = 0x0000858A
+  GL_OPERAND0_RGB_ARB* = 0x00008590
+  GL_OPERAND1_RGB_ARB* = 0x00008591
+  GL_OPERAND2_RGB_ARB* = 0x00008592
+  GL_OPERAND0_ALPHA_ARB* = 0x00008598
+  GL_OPERAND1_ALPHA_ARB* = 0x00008599
+  GL_OPERAND2_ALPHA_ARB* = 0x0000859A
+  GL_RGB_SCALE_ARB* = 0x00008573
+  GL_ADD_SIGNED_ARB* = 0x00008574
+  GL_INTERPOLATE_ARB* = 0x00008575
+  GL_SUBTRACT_ARB* = 0x000084E7
+  GL_CONSTANT_ARB* = 0x00008576
+  GL_PRIMARY_COLOR_ARB* = 0x00008577
+  GL_PREVIOUS_ARB* = 0x00008578
+  #***** GL_ARB_texture_env_crossbar *****//
+  #***** GL_ARB_texture_env_dot3 *****//
+
+const 
+  GL_DOT3_RGB_ARB* = 0x000086AE
+  GL_DOT3_RGBA_ARB* = 0x000086AF
+  #***** GL_ARB_texture_mirrored_repeat *****//
+
+const 
+  GL_MIRRORED_REPEAT_ARB* = 0x00008370
+  #***** GL_ARB_vertex_blend *****//
+
+const 
+  GL_MAX_VERTEX_UNITS_ARB* = 0x000086A4
+  GL_ACTIVE_VERTEX_UNITS_ARB* = 0x000086A5
+  GL_WEIGHT_SUM_UNITY_ARB* = 0x000086A6
+  constGL_VERTEX_BLEND_ARB* = 0x000086A7
+  GL_MODELVIEW0_ARB* = 0x00001700
+  GL_MODELVIEW1_ARB* = 0x0000850A
+  GL_MODELVIEW2_ARB* = 0x00008722
+  GL_MODELVIEW3_ARB* = 0x00008723
+  GL_MODELVIEW4_ARB* = 0x00008724
+  GL_MODELVIEW5_ARB* = 0x00008725
+  GL_MODELVIEW6_ARB* = 0x00008726
+  GL_MODELVIEW7_ARB* = 0x00008727
+  GL_MODELVIEW8_ARB* = 0x00008728
+  GL_MODELVIEW9_ARB* = 0x00008729
+  GL_MODELVIEW10_ARB* = 0x0000872A
+  GL_MODELVIEW11_ARB* = 0x0000872B
+  GL_MODELVIEW12_ARB* = 0x0000872C
+  GL_MODELVIEW13_ARB* = 0x0000872D
+  GL_MODELVIEW14_ARB* = 0x0000872E
+  GL_MODELVIEW15_ARB* = 0x0000872F
+  GL_MODELVIEW16_ARB* = 0x00008730
+  GL_MODELVIEW17_ARB* = 0x00008731
+  GL_MODELVIEW18_ARB* = 0x00008732
+  GL_MODELVIEW19_ARB* = 0x00008733
+  GL_MODELVIEW20_ARB* = 0x00008734
+  GL_MODELVIEW21_ARB* = 0x00008735
+  GL_MODELVIEW22_ARB* = 0x00008736
+  GL_MODELVIEW23_ARB* = 0x00008737
+  GL_MODELVIEW24_ARB* = 0x00008738
+  GL_MODELVIEW25_ARB* = 0x00008739
+  GL_MODELVIEW26_ARB* = 0x0000873A
+  GL_MODELVIEW27_ARB* = 0x0000873B
+  GL_MODELVIEW28_ARB* = 0x0000873C
+  GL_MODELVIEW29_ARB* = 0x0000873D
+  GL_MODELVIEW30_ARB* = 0x0000873E
+  GL_MODELVIEW31_ARB* = 0x0000873F
+  GL_CURRENT_WEIGHT_ARB* = 0x000086A8
+  GL_WEIGHT_ARRAY_TYPE_ARB* = 0x000086A9
+  GL_WEIGHT_ARRAY_STRIDE_ARB* = 0x000086AA
+  GL_WEIGHT_ARRAY_SIZE_ARB* = 0x000086AB
+  GL_WEIGHT_ARRAY_POINTER_ARB* = 0x000086AC
+  GL_WEIGHT_ARRAY_ARB* = 0x000086AD
+
+const 
+  GL_VERTEX_PROGRAM_ARB* = 0x00008620
+  GL_VERTEX_PROGRAM_POINT_SIZE_ARB* = 0x00008642
+  GL_VERTEX_PROGRAM_TWO_SIDE_ARB* = 0x00008643
+  GL_COLOR_SUM_ARB* = 0x00008458
+  GL_PROGRAM_FORMAT_ASCII_ARB* = 0x00008875
+  GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB* = 0x00008622
+  GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB* = 0x00008623
+  GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB* = 0x00008624
+  GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB* = 0x00008625
+  GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB* = 0x0000886A
+  GL_CURRENT_VERTEX_ATTRIB_ARB* = 0x00008626
+  GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB* = 0x00008645
+  GL_PROGRAM_LENGTH_ARB* = 0x00008627
+  GL_PROGRAM_FORMAT_ARB* = 0x00008876
+  GL_PROGRAM_BINDING_ARB* = 0x00008677
+  GL_PROGRAM_INSTRUCTIONS_ARB* = 0x000088A0
+  GL_MAX_PROGRAM_INSTRUCTIONS_ARB* = 0x000088A1
+  GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB* = 0x000088A2
+  GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB* = 0x000088A3
+  GL_PROGRAM_TEMPORARIES_ARB* = 0x000088A4
+  GL_MAX_PROGRAM_TEMPORARIES_ARB* = 0x000088A5
+  GL_PROGRAM_NATIVE_TEMPORARIES_ARB* = 0x000088A6
+  GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB* = 0x000088A7
+  GL_PROGRAM_PARAMETERS_ARB* = 0x000088A8
+  GL_MAX_PROGRAM_PARAMETERS_ARB* = 0x000088A9
+  GL_PROGRAM_NATIVE_PARAMETERS_ARB* = 0x000088AA
+  GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB* = 0x000088AB
+  GL_PROGRAM_ATTRIBS_ARB* = 0x000088AC
+  GL_MAX_PROGRAM_ATTRIBS_ARB* = 0x000088AD
+  GL_PROGRAM_NATIVE_ATTRIBS_ARB* = 0x000088AE
+  GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB* = 0x000088AF
+  GL_PROGRAM_ADDRESS_REGISTERS_ARB* = 0x000088B0
+  GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB* = 0x000088B1
+  GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB* = 0x000088B2
+  GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB* = 0x000088B3
+  GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB* = 0x000088B4
+  GL_MAX_PROGRAM_ENV_PARAMETERS_ARB* = 0x000088B5
+  GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB* = 0x000088B6
+  constGL_PROGRAM_STRING_ARB* = 0x00008628
+  GL_PROGRAM_ERROR_POSITION_ARB* = 0x0000864B
+  GL_CURRENT_MATRIX_ARB* = 0x00008641
+  GL_TRANSPOSE_CURRENT_MATRIX_ARB* = 0x000088B7
+  GL_CURRENT_MATRIX_STACK_DEPTH_ARB* = 0x00008640
+  GL_MAX_VERTEX_ATTRIBS_ARB* = 0x00008869
+  GL_MAX_PROGRAM_MATRICES_ARB* = 0x0000862F
+  GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB* = 0x0000862E
+  GL_PROGRAM_ERROR_STRING_ARB* = 0x00008874
+  GL_MATRIX0_ARB* = 0x000088C0
+  GL_MATRIX1_ARB* = 0x000088C1
+  GL_MATRIX2_ARB* = 0x000088C2
+  GL_MATRIX3_ARB* = 0x000088C3
+  GL_MATRIX4_ARB* = 0x000088C4
+  GL_MATRIX5_ARB* = 0x000088C5
+  GL_MATRIX6_ARB* = 0x000088C6
+  GL_MATRIX7_ARB* = 0x000088C7
+  GL_MATRIX8_ARB* = 0x000088C8
+  GL_MATRIX9_ARB* = 0x000088C9
+  GL_MATRIX10_ARB* = 0x000088CA
+  GL_MATRIX11_ARB* = 0x000088CB
+  GL_MATRIX12_ARB* = 0x000088CC
+  GL_MATRIX13_ARB* = 0x000088CD
+  GL_MATRIX14_ARB* = 0x000088CE
+  GL_MATRIX15_ARB* = 0x000088CF
+  GL_MATRIX16_ARB* = 0x000088D0
+  GL_MATRIX17_ARB* = 0x000088D1
+  GL_MATRIX18_ARB* = 0x000088D2
+  GL_MATRIX19_ARB* = 0x000088D3
+  GL_MATRIX20_ARB* = 0x000088D4
+  GL_MATRIX21_ARB* = 0x000088D5
+  GL_MATRIX22_ARB* = 0x000088D6
+  GL_MATRIX23_ARB* = 0x000088D7
+  GL_MATRIX24_ARB* = 0x000088D8
+  GL_MATRIX25_ARB* = 0x000088D9
+  GL_MATRIX26_ARB* = 0x000088DA
+  GL_MATRIX27_ARB* = 0x000088DB
+  GL_MATRIX28_ARB* = 0x000088DC
+  GL_MATRIX29_ARB* = 0x000088DD
+  GL_MATRIX30_ARB* = 0x000088DE
+  GL_MATRIX31_ARB* = 0x000088DF
+
+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 
+  GL_ABGR_EXT* = 0x00008000
+  #***** GL_EXT_bgra *****//
+
+const 
+  GL_BGR_EXT* = 0x000080E0
+  GL_BGRA_EXT* = 0x000080E1
+  #***** GL_EXT_blend_color *****//
+
+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, 
+    importc: "glBlendColorEXT".}
+  #***** GL_EXT_blend_func_separate *****//
+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, 
+                             sfactorAlpha: TGLenum, dfactorAlpha: TGLenum){.
+    dynlib: dllname, importc: "glBlendFuncSeparateEXT".}
+  #***** GL_EXT_blend_logic_op *****//
+  #***** GL_EXT_blend_minmax *****//
+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, 
+    importc: "glBlendEquationEXT".}
+  #***** GL_EXT_blend_subtract *****//
+const 
+  GL_FUNC_SUBTRACT_EXT* = 0x0000800A
+  GL_FUNC_REVERSE_SUBTRACT_EXT* = 0x0000800B
+  #***** GL_EXT_clip_volume_hint *****//
+
+const 
+  GL_CLIP_VOLUME_CLIPPING_HINT_EXT* = 0x000080F0
+  #***** GL_EXT_color_subtable *****//
+
+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, 
+    importc: "glCopyColorSubTableEXT".}
+  #***** GL_EXT_compiled_vertex_array *****//
+const 
+  GL_ARRAY_ELEMENT_LOCK_FIRST_EXT* = 0x000081A8
+  GL_ARRAY_ELEMENT_LOCK_COUNT_EXT* = 0x000081A9
+
+proc glLockArraysEXT*(first: TGLint, count: TGLsizei){.dynlib: dllname, 
+    importc: "glLockArraysEXT".}
+proc glUnlockArraysEXT*(){.dynlib: dllname, importc: "glUnlockArraysEXT".}
+  #***** GL_EXT_convolution *****//
+const 
+  GL_CONVOLUTION_1D_EXT* = 0x00008010
+  GL_CONVOLUTION_2D_EXT* = 0x00008011
+  GL_SEPARABLE_2D_EXT* = 0x00008012
+  GL_CONVOLUTION_BORDER_MODE_EXT* = 0x00008013
+  GL_CONVOLUTION_FILTER_SCALE_EXT* = 0x00008014
+  GL_CONVOLUTION_FILTER_BIAS_EXT* = 0x00008015
+  GL_REDUCE_EXT* = 0x00008016
+  GL_CONVOLUTION_FORMAT_EXT* = 0x00008017
+  GL_CONVOLUTION_WIDTH_EXT* = 0x00008018
+  GL_CONVOLUTION_HEIGHT_EXT* = 0x00008019
+  GL_MAX_CONVOLUTION_WIDTH_EXT* = 0x0000801A
+  GL_MAX_CONVOLUTION_HEIGHT_EXT* = 0x0000801B
+  GL_POST_CONVOLUTION_RED_SCALE_EXT* = 0x0000801C
+  GL_POST_CONVOLUTION_GREEN_SCALE_EXT* = 0x0000801D
+  GL_POST_CONVOLUTION_BLUE_SCALE_EXT* = 0x0000801E
+  GL_POST_CONVOLUTION_ALPHA_SCALE_EXT* = 0x0000801F
+  GL_POST_CONVOLUTION_RED_BIAS_EXT* = 0x00008020
+  GL_POST_CONVOLUTION_GREEN_BIAS_EXT* = 0x00008021
+  GL_POST_CONVOLUTION_BLUE_BIAS_EXT* = 0x00008022
+  GL_POST_CONVOLUTION_ALPHA_BIAS_EXT* = 0x00008023
+
+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, 
+                               format: TGLenum, thetype: TGLenum, image: PGLvoid){.
+    dynlib: dllname, importc: "glConvolutionFilter2DEXT".}
+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, 
+    importc: "glCopyConvolutionFilter2DEXT".}
+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, 
+                             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, 
+    importc: "glGetSeparableFilterEXT".}
+proc glConvolutionParameteriEXT*(target: TGLenum, pname: TGLenum, param: TGLint){.
+    dynlib: dllname, importc: "glConvolutionParameteriEXT".}
+proc glConvolutionParameterivEXT*(target: TGLenum, pname: TGLenum, 
+                                  params: PGLint){.dynlib: dllname, 
+    importc: "glConvolutionParameterivEXT".}
+proc glConvolutionParameterfEXT*(target: TGLenum, pname: TGLenum, 
+                                 param: TGLfloat){.dynlib: dllname, 
+    importc: "glConvolutionParameterfEXT".}
+proc glConvolutionParameterfvEXT*(target: TGLenum, pname: TGLenum, 
+                                  params: PGLfloat){.dynlib: dllname, 
+    importc: "glConvolutionParameterfvEXT".}
+proc glGetConvolutionParameterivEXT*(target: TGLenum, pname: TGLenum, 
+                                     params: PGLint){.dynlib: dllname, 
+    importc: "glGetConvolutionParameterivEXT".}
+proc glGetConvolutionParameterfvEXT*(target: TGLenum, pname: TGLenum, 
+                                     params: PGLfloat){.dynlib: dllname, 
+    importc: "glGetConvolutionParameterfvEXT".}
+  #***** GL_EXT_fog_coord *****//
+const 
+  GL_FOG_COORDINATE_SOURCE_EXT* = 0x00008450
+  GL_FOG_COORDINATE_EXT* = 0x00008451
+  GL_FRAGMENT_DEPTH_EXT* = 0x00008452
+  GL_CURRENT_FOG_COORDINATE_EXT* = 0x00008453
+  GL_FOG_COORDINATE_ARRAY_TYPE_EXT* = 0x00008454
+  GL_FOG_COORDINATE_ARRAY_STRIDE_EXT* = 0x00008455
+  GL_FOG_COORDINATE_ARRAY_POINTER_EXT* = 0x00008456
+  GL_FOG_COORDINATE_ARRAY_EXT* = 0x00008457
+
+proc glFogCoordfEXfloat*(coord: TGLfloat){.dynlib: dllname, 
+    importc: "glFogCoordfEXfloat".}
+proc glFogCoorddEXdouble*(coord: TGLdouble){.dynlib: dllname, 
+    importc: "glFogCoorddEXdouble".}
+proc glFogCoordfvEXfloat*(coord: TGLfloat){.dynlib: dllname, 
+    importc: "glFogCoordfvEXfloat".}
+proc glFogCoorddvEXdouble*(coord: TGLdouble){.dynlib: dllname, 
+    importc: "glFogCoorddvEXdouble".}
+proc glFogCoordPointerEXT*(thetype: TGLenum, stride: TGLsizei, pointer: PGLvoid){.
+    dynlib: dllname, importc: "glFogCoordPointerEXT".}
+  #***** GL_EXT_histogram *****//
+const 
+  constGL_HISTOGRAM_EXT* = 0x00008024
+  GL_PROXY_HISTOGRAM_EXT* = 0x00008025
+  GL_HISTOGRAM_WIDTH_EXT* = 0x00008026
+  GL_HISTOGRAM_FORMAT_EXT* = 0x00008027
+  GL_HISTOGRAM_RED_SIZE_EXT* = 0x00008028
+  GL_HISTOGRAM_GREEN_SIZE_EXT* = 0x00008029
+  GL_HISTOGRAM_BLUE_SIZE_EXT* = 0x0000802A
+  GL_HISTOGRAM_ALPHA_SIZE_EXT* = 0x0000802B
+  GL_HISTOGRAM_LUMINANCE_SIZE_EXT* = 0x0000802C
+  GL_HISTOGRAM_SINK_EXT* = 0x0000802D
+  constGL_MINMAX_EXT* = 0x0000802E
+  GL_MINMAX_FORMAT_EXT* = 0x0000802F
+  GL_MINMAX_SINK_EXT* = 0x00008030
+
+proc glHistogramEXT*(target: TGLenum, width: TGLsizei, internalformat: TGLenum, 
+                     sink: TGLboolean){.dynlib: dllname, 
+                                        importc: "glHistogramEXT".}
+proc glResetHistogramEXT*(target: TGLenum){.dynlib: dllname, 
+    importc: "glResetHistogramEXT".}
+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, 
+    importc: "glGetHistogramParameterivEXT".}
+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, 
+    importc: "glResetMinmaxEXT".}
+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, 
+    importc: "glGetMinmaxParameterfvEXT".}
+  #***** GL_EXT_multi_draw_arrays *****//
+proc glMultiDrawArraysEXT*(mode: TGLenum, first: PGLint, count: PGLsizei, 
+                           primcount: TGLsizei){.dynlib: dllname, 
+    importc: "glMultiDrawArraysEXT".}
+proc glMultiDrawElementsEXT*(mode: TGLenum, count: PGLsizei, thetype: TGLenum, 
+                             indices: PGLvoid, primcount: TGLsizei){.
+    dynlib: dllname, importc: "glMultiDrawElementsEXT".}
+  #***** GL_EXT_packed_pixels *****//
+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
+  GL_UNSIGNED_INT_8_8_8_8_EXT* = 0x00008035
+  GL_UNSIGNED_INT_10_10_10_2_EXT* = 0x00008036
+  #***** GL_EXT_paletted_texture *****//
+
+const 
+  GL_COLOR_INDEX1_EXT* = 0x000080E2
+  GL_COLOR_INDEX2_EXT* = 0x000080E3
+  GL_COLOR_INDEX4_EXT* = 0x000080E4
+  GL_COLOR_INDEX8_EXT* = 0x000080E5
+  GL_COLOR_INDEX12_EXT* = 0x000080E6
+  GL_COLOR_INDEX16_EXT* = 0x000080E7
+  GL_COLOR_TABLE_FORMAT_EXT* = 0x000080D8
+  GL_COLOR_TABLE_WIDTH_EXT* = 0x000080D9
+  GL_COLOR_TABLE_RED_SIZE_EXT* = 0x000080DA
+  GL_COLOR_TABLE_GREEN_SIZE_EXT* = 0x000080DB
+  GL_COLOR_TABLE_BLUE_SIZE_EXT* = 0x000080DC
+  GL_COLOR_TABLE_ALPHA_SIZE_EXT* = 0x000080DD
+  GL_COLOR_TABLE_LUMINANCE_SIZE_EXT* = 0x000080DE
+  GL_COLOR_TABLE_INTENSITY_SIZE_EXT* = 0x000080DF
+  GL_TEXTURE_INDEX_SIZE_EXT* = 0x000080ED
+  GL_TEXTURE_1D* = 0x00000DE0
+  GL_TEXTURE_2D* = 0x00000DE1
+  GL_TEXTURE_3D_EXT* = 0x0000806F # GL_TEXTURE_CUBE_MAP_ARB  { already defined }
+  GL_PROXY_TEXTURE_1D* = 0x00008063
+  GL_PROXY_TEXTURE_2D* = 0x00008064
+  GL_PROXY_TEXTURE_3D_EXT* = 0x00008070 # GL_PROXY_TEXTURE_CUBE_MAP_ARB  { already defined }
+                                        # GL_TEXTURE_1D  { already defined }
+                                        # GL_TEXTURE_2D  { already defined }
+                                        # GL_TEXTURE_3D_EXT  { already defined }
+                                        # GL_TEXTURE_CUBE_MAP_ARB  { already defined }
+
+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, 
+    importc: "glGetColorTableEXT".}
+proc glGetColorTableParameterivEXT*(target: TGLenum, pname: TGLenum, 
+                                    params: PGLint){.dynlib: dllname, 
+    importc: "glGetColorTableParameterivEXT".}
+proc glGetColorTableParameterfvEXT*(target: TGLenum, pname: TGLenum, 
+                                    params: PGLfloat){.dynlib: dllname, 
+    importc: "glGetColorTableParameterfvEXT".}
+  #***** GL_EXT_point_parameters *****//
+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, 
+    importc: "glPointParameterfEXT".}
+proc glPointParameterfvEXT*(pname: TGLenum, params: PGLfloat){.dynlib: dllname, 
+    importc: "glPointParameterfvEXT".}
+  #***** GL_EXT_polygon_offset *****//
+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, 
+    importc: "glPolygonOffsetEXT".}
+  #***** GL_EXT_secondary_color *****//
+const 
+  GL_COLOR_SUM_EXT* = 0x00008458
+  GL_CURRENT_SECONDARY_COLOR_EXT* = 0x00008459
+  GL_SECONDARY_COLOR_ARRAY_SIZE_EXT* = 0x0000845A
+  GL_SECONDARY_COLOR_ARRAY_TYPE_EXT* = 0x0000845B
+  GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT* = 0x0000845C
+  GL_SECONDARY_COLOR_ARRAY_POINTER_EXT* = 0x0000845D
+  GL_SECONDARY_COLOR_ARRAY_EXT* = 0x0000845E
+
+proc glSecondaryColor3bEXT*(components: TGLbyte){.dynlib: dllname, 
+    importc: "glSecondaryColor3bEXT".}
+proc glSecondaryColor3sEXT*(components: TGLshort){.dynlib: dllname, 
+    importc: "glSecondaryColor3sEXT".}
+proc glSecondaryColor3iEXT*(components: TGLint){.dynlib: dllname, 
+    importc: "glSecondaryColor3iEXT".}
+proc glSecondaryColor3fEXT*(components: TGLfloat){.dynlib: dllname, 
+    importc: "glSecondaryColor3fEXT".}
+proc glSecondaryColor3dEXT*(components: TGLdouble){.dynlib: dllname, 
+    importc: "glSecondaryColor3dEXT".}
+proc glSecondaryColor3ubEXT*(components: TGLubyte){.dynlib: dllname, 
+    importc: "glSecondaryColor3ubEXT".}
+proc glSecondaryColor3usEXT*(components: TGLushort){.dynlib: dllname, 
+    importc: "glSecondaryColor3usEXT".}
+proc glSecondaryColor3uiEXT*(components: TGLuint){.dynlib: dllname, 
+    importc: "glSecondaryColor3uiEXT".}
+proc glSecondaryColor3bvEXT*(components: TGLbyte){.dynlib: dllname, 
+    importc: "glSecondaryColor3bvEXT".}
+proc glSecondaryColor3svEXT*(components: TGLshort){.dynlib: dllname, 
+    importc: "glSecondaryColor3svEXT".}
+proc glSecondaryColor3ivEXT*(components: TGLint){.dynlib: dllname, 
+    importc: "glSecondaryColor3ivEXT".}
+proc glSecondaryColor3fvEXT*(components: TGLfloat){.dynlib: dllname, 
+    importc: "glSecondaryColor3fvEXT".}
+proc glSecondaryColor3dvEXT*(components: TGLdouble){.dynlib: dllname, 
+    importc: "glSecondaryColor3dvEXT".}
+proc glSecondaryColor3ubvEXT*(components: TGLubyte){.dynlib: dllname, 
+    importc: "glSecondaryColor3ubvEXT".}
+proc glSecondaryColor3usvEXT*(components: TGLushort){.dynlib: dllname, 
+    importc: "glSecondaryColor3usvEXT".}
+proc glSecondaryColor3uivEXT*(components: TGLuint){.dynlib: dllname, 
+    importc: "glSecondaryColor3uivEXT".}
+proc glSecondaryColorPointerEXT*(size: TGLint, thetype: TGLenum, 
+                                 stride: TGLsizei, pointer: PGLvoid){.
+    dynlib: dllname, importc: "glSecondaryColorPointerEXT".}
+  #***** GL_EXT_separate_specular_color *****//
+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 
+  GL_SHARED_TEXTURE_PALETTE_EXT* = 0x000081FB
+  #***** GL_EXT_stencil_two_side *****//
+
+const 
+  GL_STENCIL_TEST_TWO_SIDE_EXT* = 0x00008910
+  constGL_ACTIVE_STENCIL_FACE_EXT* = 0x00008911
+
+proc glActiveStencilFaceEXT*(face: TGLenum){.dynlib: dllname, 
+    importc: "glActiveStencilFaceEXT".}
+  #***** GL_EXT_stencil_wrap *****//
+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, 
+    importc: "glTexSubImage1DEXT".}
+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, 
+    importc: "glTexSubImage3DEXT".}
+  #***** GL_EXT_texture3D *****//
+const 
+  GL_PACK_SKIP_IMAGES_EXT* = 0x0000806B
+  GL_PACK_IMAGE_HEIGHT_EXT* = 0x0000806C
+  GL_UNPACK_SKIP_IMAGES_EXT* = 0x0000806D
+  GL_UNPACK_IMAGE_HEIGHT_EXT* = 0x0000806E # GL_TEXTURE_3D_EXT  { already defined }
+                                           # GL_PROXY_TEXTURE_3D_EXT  { already defined }
+  GL_TEXTURE_DEPTH_EXT* = 0x00008071
+  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, 
+                                        importc: "glTexImage3DEXT".}
+  #***** GL_EXT_texture_compression_s3tc *****//
+const 
+  GL_COMPRESSED_RGB_S3TC_DXT1_EXT* = 0x000083F0
+  GL_COMPRESSED_RGBA_S3TC_DXT1_EXT* = 0x000083F1
+  GL_COMPRESSED_RGBA_S3TC_DXT3_EXT* = 0x000083F2
+  GL_COMPRESSED_RGBA_S3TC_DXT5_EXT* = 0x000083F3
+  #***** GL_EXT_texture_env_add *****//
+  #***** GL_EXT_texture_env_combine *****//
+
+const 
+  GL_COMBINE_EXT* = 0x00008570
+  GL_COMBINE_RGB_EXT* = 0x00008571
+  GL_COMBINE_ALPHA_EXT* = 0x00008572
+  GL_SOURCE0_RGB_EXT* = 0x00008580
+  GL_SOURCE1_RGB_EXT* = 0x00008581
+  GL_SOURCE2_RGB_EXT* = 0x00008582
+  GL_SOURCE0_ALPHA_EXT* = 0x00008588
+  GL_SOURCE1_ALPHA_EXT* = 0x00008589
+  GL_SOURCE2_ALPHA_EXT* = 0x0000858A
+  GL_OPERAND0_RGB_EXT* = 0x00008590
+  GL_OPERAND1_RGB_EXT* = 0x00008591
+  GL_OPERAND2_RGB_EXT* = 0x00008592
+  GL_OPERAND0_ALPHA_EXT* = 0x00008598
+  GL_OPERAND1_ALPHA_EXT* = 0x00008599
+  GL_OPERAND2_ALPHA_EXT* = 0x0000859A
+  GL_RGB_SCALE_EXT* = 0x00008573
+  GL_ADD_SIGNED_EXT* = 0x00008574
+  GL_INTERPOLATE_EXT* = 0x00008575
+  GL_CONSTANT_EXT* = 0x00008576
+  GL_PRIMARY_COLOR_EXT* = 0x00008577
+  GL_PREVIOUS_EXT* = 0x00008578
+  #***** GL_EXT_texture_env_dot3 *****//
+
+const 
+  GL_DOT3_RGB_EXT* = 0x00008740
+  GL_DOT3_RGBA_EXT* = 0x00008741
+  #***** GL_EXT_texture_filter_anisotropic *****//
+
+const 
+  GL_TEXTURE_MAX_ANISOTROPY_EXT* = 0x000084FE
+  GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT* = 0x000084FF
+  #***** GL_EXT_texture_lod_bias *****//
+
+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 
+  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, 
+    importc: "glGenTexturesEXT".}
+proc glDeleteTexturesEXT*(n: TGLsizei, textures: PGLuint){.dynlib: dllname, 
+    importc: "glDeleteTexturesEXT".}
+proc glBindTextureEXT*(target: TGLenum, texture: TGLuint){.dynlib: dllname, 
+    importc: "glBindTextureEXT".}
+proc glPrioritizeTexturesEXT*(n: TGLsizei, textures: PGLuint, 
+                              priorities: PGLclampf){.dynlib: dllname, 
+    importc: "glPrioritizeTexturesEXT".}
+proc glAreTexturesResidentEXT*(n: TGLsizei, textures: PGLuint, 
+                               residences: PGLboolean): TGLboolean{.
+    dynlib: dllname, importc: "glAreTexturesResidentEXT".}
+proc glIsTextureEXT*(texture: TGLuint): TGLboolean{.dynlib: dllname, 
+    importc: "glIsTextureEXT".}
+  #***** GL_EXT_vertex_array *****//
+const 
+  GL_VERTEX_ARRAY_EXT* = 0x00008074
+  GL_NORMAL_ARRAY_EXT* = 0x00008075
+  GL_COLOR_ARRAY_EXT* = 0x00008076
+  GL_INDEX_ARRAY_EXT* = 0x00008077
+  GL_TEXTURE_COORD_ARRAY_EXT* = 0x00008078
+  GL_EDGE_FLAG_ARRAY_EXT* = 0x00008079
+  GL_DOUBLE_EXT* = 0x0000140A
+  GL_VERTEX_ARRAY_SIZE_EXT* = 0x0000807A
+  GL_VERTEX_ARRAY_TYPE_EXT* = 0x0000807B
+  GL_VERTEX_ARRAY_STRIDE_EXT* = 0x0000807C
+  GL_VERTEX_ARRAY_COUNT_EXT* = 0x0000807D
+  GL_NORMAL_ARRAY_TYPE_EXT* = 0x0000807E
+  GL_NORMAL_ARRAY_STRIDE_EXT* = 0x0000807F
+  GL_NORMAL_ARRAY_COUNT_EXT* = 0x00008080
+  GL_COLOR_ARRAY_SIZE_EXT* = 0x00008081
+  GL_COLOR_ARRAY_TYPE_EXT* = 0x00008082
+  GL_COLOR_ARRAY_STRIDE_EXT* = 0x00008083
+  GL_COLOR_ARRAY_COUNT_EXT* = 0x00008084
+  GL_INDEX_ARRAY_TYPE_EXT* = 0x00008085
+  GL_INDEX_ARRAY_STRIDE_EXT* = 0x00008086
+  GL_INDEX_ARRAY_COUNT_EXT* = 0x00008087
+  GL_TEXTURE_COORD_ARRAY_SIZE_EXT* = 0x00008088
+  GL_TEXTURE_COORD_ARRAY_TYPE_EXT* = 0x00008089
+  GL_TEXTURE_COORD_ARRAY_STRIDE_EXT* = 0x0000808A
+  GL_TEXTURE_COORD_ARRAY_COUNT_EXT* = 0x0000808B
+  GL_EDGE_FLAG_ARRAY_STRIDE_EXT* = 0x0000808C
+  GL_EDGE_FLAG_ARRAY_COUNT_EXT* = 0x0000808D
+  GL_VERTEX_ARRAY_POINTER_EXT* = 0x0000808E
+  GL_NORMAL_ARRAY_POINTER_EXT* = 0x0000808F
+  GL_COLOR_ARRAY_POINTER_EXT* = 0x00008090
+  GL_INDEX_ARRAY_POINTER_EXT* = 0x00008091
+  GL_TEXTURE_COORD_ARRAY_POINTER_EXT* = 0x00008092
+  GL_EDGE_FLAG_ARRAY_POINTER_EXT* = 0x00008093
+
+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, 
+    importc: "glVertexPointerEXT".}
+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, 
+    importc: "glColorPointerEXT".}
+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, 
+    importc: "glTexCoordPointerEXT".}
+proc glEdgeFlagPointerEXT*(stride: TGLsizei, count: TGLsizei, 
+                           pointer: PGLboolean){.dynlib: dllname, 
+    importc: "glEdgeFlagPointerEXT".}
+proc glGetPointervEXT*(pname: TGLenum, params: PGLvoid){.dynlib: dllname, 
+    importc: "glGetPointervEXT".}
+  #***** GL_EXT_vertex_shader *****//
+const 
+  GL_VERTEX_SHADER_EXT* = 0x00008780
+  GL_VARIANT_VALUE_EXT* = 0x000087E4
+  GL_VARIANT_DATATYPE_EXT* = 0x000087E5
+  GL_VARIANT_ARRAY_STRIDE_EXT* = 0x000087E6
+  GL_VARIANT_ARRAY_TYPE_EXT* = 0x000087E7
+  GL_VARIANT_ARRAY_EXT* = 0x000087E8
+  GL_VARIANT_ARRAY_POINTER_EXT* = 0x000087E9
+  GL_INVARIANT_VALUE_EXT* = 0x000087EA
+  GL_INVARIANT_DATATYPE_EXT* = 0x000087EB
+  GL_LOCAL_CONSTANT_VALUE_EXT* = 0x000087EC
+  GL_LOCAL_CONSTANT_DATATYPE_EXT* = 0x000087ED
+  GL_OP_INDEX_EXT* = 0x00008782
+  GL_OP_NEGATE_EXT* = 0x00008783
+  GL_OP_DOT3_EXT* = 0x00008784
+  GL_OP_DOT4_EXT* = 0x00008785
+  GL_OP_MUL_EXT* = 0x00008786
+  GL_OP_ADD_EXT* = 0x00008787
+  GL_OP_MADD_EXT* = 0x00008788
+  GL_OP_FRAC_EXT* = 0x00008789
+  GL_OP_MAX_EXT* = 0x0000878A
+  GL_OP_MIN_EXT* = 0x0000878B
+  GL_OP_SET_GE_EXT* = 0x0000878C
+  GL_OP_SET_LT_EXT* = 0x0000878D
+  GL_OP_CLAMP_EXT* = 0x0000878E
+  GL_OP_FLOOR_EXT* = 0x0000878F
+  GL_OP_ROUND_EXT* = 0x00008790
+  GL_OP_EXP_BASE_2_EXT* = 0x00008791
+  GL_OP_LOG_BASE_2_EXT* = 0x00008792
+  GL_OP_POWER_EXT* = 0x00008793
+  GL_OP_RECIP_EXT* = 0x00008794
+  GL_OP_RECIP_SQRT_EXT* = 0x00008795
+  GL_OP_SUB_EXT* = 0x00008796
+  GL_OP_CROSS_PRODUCT_EXT* = 0x00008797
+  GL_OP_MULTIPLY_MATRIX_EXT* = 0x00008798
+  GL_OP_MOV_EXT* = 0x00008799
+  GL_OUTPUT_VERTEX_EXT* = 0x0000879A
+  GL_OUTPUT_COLOR0_EXT* = 0x0000879B
+  GL_OUTPUT_COLOR1_EXT* = 0x0000879C
+  GL_OUTPUT_TEXTURE_COORD0_EXT* = 0x0000879D
+  GL_OUTPUT_TEXTURE_COORD1_EXT* = 0x0000879E
+  GL_OUTPUT_TEXTURE_COORD2_EXT* = 0x0000879F
+  GL_OUTPUT_TEXTURE_COORD3_EXT* = 0x000087A0
+  GL_OUTPUT_TEXTURE_COORD4_EXT* = 0x000087A1
+  GL_OUTPUT_TEXTURE_COORD5_EXT* = 0x000087A2
+  GL_OUTPUT_TEXTURE_COORD6_EXT* = 0x000087A3
+  GL_OUTPUT_TEXTURE_COORD7_EXT* = 0x000087A4
+  GL_OUTPUT_TEXTURE_COORD8_EXT* = 0x000087A5
+  GL_OUTPUT_TEXTURE_COORD9_EXT* = 0x000087A6
+  GL_OUTPUT_TEXTURE_COORD10_EXT* = 0x000087A7
+  GL_OUTPUT_TEXTURE_COORD11_EXT* = 0x000087A8
+  GL_OUTPUT_TEXTURE_COORD12_EXT* = 0x000087A9
+  GL_OUTPUT_TEXTURE_COORD13_EXT* = 0x000087AA
+  GL_OUTPUT_TEXTURE_COORD14_EXT* = 0x000087AB
+  GL_OUTPUT_TEXTURE_COORD15_EXT* = 0x000087AC
+  GL_OUTPUT_TEXTURE_COORD16_EXT* = 0x000087AD
+  GL_OUTPUT_TEXTURE_COORD17_EXT* = 0x000087AE
+  GL_OUTPUT_TEXTURE_COORD18_EXT* = 0x000087AF
+  GL_OUTPUT_TEXTURE_COORD19_EXT* = 0x000087B0
+  GL_OUTPUT_TEXTURE_COORD20_EXT* = 0x000087B1
+  GL_OUTPUT_TEXTURE_COORD21_EXT* = 0x000087B2
+  GL_OUTPUT_TEXTURE_COORD22_EXT* = 0x000087B3
+  GL_OUTPUT_TEXTURE_COORD23_EXT* = 0x000087B4
+  GL_OUTPUT_TEXTURE_COORD24_EXT* = 0x000087B5
+  GL_OUTPUT_TEXTURE_COORD25_EXT* = 0x000087B6
+  GL_OUTPUT_TEXTURE_COORD26_EXT* = 0x000087B7
+  GL_OUTPUT_TEXTURE_COORD27_EXT* = 0x000087B8
+  GL_OUTPUT_TEXTURE_COORD28_EXT* = 0x000087B9
+  GL_OUTPUT_TEXTURE_COORD29_EXT* = 0x000087BA
+  GL_OUTPUT_TEXTURE_COORD30_EXT* = 0x000087BB
+  GL_OUTPUT_TEXTURE_COORD31_EXT* = 0x000087BC
+  GL_OUTPUT_FOG_EXT* = 0x000087BD
+  GL_SCALAR_EXT* = 0x000087BE
+  GL_VECTOR_EXT* = 0x000087BF
+  GL_MATRIX_EXT* = 0x000087C0
+  GL_VARIANT_EXT* = 0x000087C1
+  GL_INVARIANT_EXT* = 0x000087C2
+  GL_LOCAL_CONSTANT_EXT* = 0x000087C3
+  GL_LOCAL_EXT* = 0x000087C4
+  GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT* = 0x000087C5
+  GL_MAX_VERTEX_SHADER_VARIANTS_EXT* = 0x000087C6
+  GL_MAX_VERTEX_SHADER_INVARIANTS_EXT* = 0x000087C7
+  GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT* = 0x000087C8
+  GL_MAX_VERTEX_SHADER_LOCALS_EXT* = 0x000087C9
+  GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT* = 0x000087CA
+  GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT* = 0x000087CB
+  GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT* = 0x000087CC
+  GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT* = 0x000087CD
+  GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT* = 0x000087CE
+  GL_VERTEX_SHADER_INSTRUCTIONS_EXT* = 0x000087CF
+  GL_VERTEX_SHADER_VARIANTS_EXT* = 0x000087D0
+  GL_VERTEX_SHADER_INVARIANTS_EXT* = 0x000087D1
+  GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT* = 0x000087D2
+  GL_VERTEX_SHADER_LOCALS_EXT* = 0x000087D3
+  GL_VERTEX_SHADER_BINDING_EXT* = 0x00008781
+  GL_VERTEX_SHADER_OPTIMIZED_EXT* = 0x000087D4
+  GL_X_EXT* = 0x000087D5
+  GL_Y_EXT* = 0x000087D6
+  GL_Z_EXT* = 0x000087D7
+  GL_W_EXT* = 0x000087D8
+  GL_NEGATIVE_X_EXT* = 0x000087D9
+  GL_NEGATIVE_Y_EXT* = 0x000087DA
+  GL_NEGATIVE_Z_EXT* = 0x000087DB
+  GL_NEGATIVE_W_EXT* = 0x000087DC
+  GL_ZERO_EXT* = 0x000087DD
+  GL_ONE_EXT* = 0x000087DE
+  GL_NEGATIVE_ONE_EXT* = 0x000087DF
+  GL_NORMALIZED_RANGE_EXT* = 0x000087E0
+  GL_FULL_RANGE_EXT* = 0x000087E1
+  GL_CURRENT_VERTEX_EXT* = 0x000087E2
+  GL_MVP_MATRIX_EXT* = 0x000087E3
+
+proc glBeginVertexShaderEXT*(){.dynlib: dllname, 
+                                importc: "glBeginVertexShaderEXT".}
+proc glEndVertexShaderEXT*(){.dynlib: dllname, importc: "glEndVertexShaderEXT".}
+proc glBindVertexShaderEXT*(id: TGLuint){.dynlib: dllname, 
+    importc: "glBindVertexShaderEXT".}
+proc glGenVertexShadersEXT*(range: TGLuint): TGLuint{.dynlib: dllname, 
+    importc: "glGenVertexShadersEXT".}
+proc glDeleteVertexShaderEXT*(id: TGLuint){.dynlib: dllname, 
+    importc: "glDeleteVertexShaderEXT".}
+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, 
+                     arg3: TGLuint){.dynlib: dllname, importc: "glShaderOp3EXT".}
+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, 
+    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, 
+    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, 
+    importc: "glVariantbvEXT".}
+proc glVariantsvEXT*(id: TGLuint, address: PGLshort){.dynlib: dllname, 
+    importc: "glVariantsvEXT".}
+proc glVariantivEXT*(id: TGLuint, address: PGLint){.dynlib: dllname, 
+    importc: "glVariantivEXT".}
+proc glVariantfvEXT*(id: TGLuint, address: PGLfloat){.dynlib: dllname, 
+    importc: "glVariantfvEXT".}
+proc glVariantdvEXT*(id: TGLuint, address: PGLdouble){.dynlib: dllname, 
+    importc: "glVariantdvEXT".}
+proc glVariantubvEXT*(id: TGLuint, address: PGLubyte){.dynlib: dllname, 
+    importc: "glVariantubvEXT".}
+proc glVariantusvEXT*(id: TGLuint, address: PGLushort){.dynlib: dllname, 
+    importc: "glVariantusvEXT".}
+proc glVariantuivEXT*(id: TGLuint, address: PGLuint){.dynlib: dllname, 
+    importc: "glVariantuivEXT".}
+proc glVariantPointerEXT*(id: TGLuint, thetype: TGLenum, stride: TGLuint, 
+                          address: PGLvoid){.dynlib: dllname, 
+    importc: "glVariantPointerEXT".}
+proc glEnableVariantClientStateEXT*(id: TGLuint){.dynlib: dllname, 
+    importc: "glEnableVariantClientStateEXT".}
+proc glDisableVariantClientStateEXT*(id: TGLuint){.dynlib: dllname, 
+    importc: "glDisableVariantClientStateEXT".}
+proc glBindLightParameterEXT*(light: TGLenum, value: TGLenum): TGLuint{.
+    dynlib: dllname, importc: "glBindLightParameterEXT".}
+proc glBindMaterialParameterEXT*(face: TGLenum, value: TGLenum): TGLuint{.
+    dynlib: dllname, importc: "glBindMaterialParameterEXT".}
+proc glBindTexGenParameterEXT*(theunit: TGLenum, coord: TGLenum, value: TGLenum): TGLuint{.
+    dynlib: dllname, importc: "glBindTexGenParameterEXT".}
+proc glBindTextureUnitParameterEXT*(theunit: TGLenum, value: TGLenum): TGLuint{.
+    dynlib: dllname, importc: "glBindTextureUnitParameterEXT".}
+proc glBindParameterEXT*(value: TGLenum): TGLuint{.dynlib: dllname, 
+    importc: "glBindParameterEXT".}
+proc glIsVariantEnabledEXT*(id: TGLuint, cap: TGLenum): TGLboolean{.
+    dynlib: dllname, importc: "glIsVariantEnabledEXT".}
+proc glGetVariantBooleanvEXT*(id: TGLuint, value: TGLenum, data: PGLboolean){.
+    dynlib: dllname, importc: "glGetVariantBooleanvEXT".}
+proc glGetVariantIntegervEXT*(id: TGLuint, value: TGLenum, data: PGLint){.
+    dynlib: dllname, importc: "glGetVariantIntegervEXT".}
+proc glGetVariantFloatvEXT*(id: TGLuint, value: TGLenum, data: PGLfloat){.
+    dynlib: dllname, importc: "glGetVariantFloatvEXT".}
+proc glGetVariantPointervEXT*(id: TGLuint, value: TGLenum, data: PGLvoid){.
+    dynlib: dllname, importc: "glGetVariantPointervEXT".}
+proc glGetInvariantBooleanvEXT*(id: TGLuint, value: TGLenum, data: PGLboolean){.
+    dynlib: dllname, importc: "glGetInvariantBooleanvEXT".}
+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, 
+    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 
+  GL_VERTEX_WEIGHTING_EXT* = 0x00008509
+  GL_MODELVIEW0_EXT* = 0x00001700
+  GL_MODELVIEW1_EXT* = 0x0000850A
+  GL_MODELVIEW0_MATRIX_EXT* = 0x00000BA6
+  GL_MODELVIEW1_MATRIX_EXT* = 0x00008506
+  GL_CURRENT_VERTEX_WEIGHT_EXT* = 0x0000850B
+  GL_VERTEX_WEIGHT_ARRAY_EXT* = 0x0000850C
+  GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT* = 0x0000850D
+  GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT* = 0x0000850E
+  GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT* = 0x0000850F
+  GL_MODELVIEW0_STACK_DEPTH_EXT* = 0x00000BA3
+  GL_MODELVIEW1_STACK_DEPTH_EXT* = 0x00008502
+  GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT* = 0x00008510
+
+proc glVertexWeightfEXT*(weight: TGLfloat){.dynlib: dllname, 
+    importc: "glVertexWeightfEXT".}
+proc glVertexWeightfvEXT*(weight: PGLfloat){.dynlib: dllname, 
+    importc: "glVertexWeightfvEXT".}
+proc glVertexWeightPointerEXT*(size: TGLint, thetype: TGLenum, stride: TGLsizei, 
+                               pointer: PGLvoid){.dynlib: dllname, 
+    importc: "glVertexWeightPointerEXT".}
+  #***** GL_HP_occlusion_test *****//
+const 
+  GL_OCCLUSION_TEST_HP* = 0x00008165
+  GL_OCCLUSION_TEST_RESULT_HP* = 0x00008166
+  #***** GL_NV_blend_square *****//
+  #***** GL_NV_copy_depth_to_color *****//
+
+const 
+  GL_DEPTH_STENCIL_TO_RGBA_NV* = 0x0000886E
+  GL_DEPTH_STENCIL_TO_BGRA_NV* = 0x0000886F
+  #***** GL_NV_depth_clamp *****//
+
+const 
+  GL_DEPTH_CLAMP_NV* = 0x0000864F
+  #***** GL_NV_evaluators *****//
+
+const 
+  GL_EVAL_2D_NV* = 0x000086C0
+  GL_EVAL_TRIANGULAR_2D_NV* = 0x000086C1
+  GL_MAP_TESSELLATION_NV* = 0x000086C2
+  GL_MAP_ATTRIB_U_ORDER_NV* = 0x000086C3
+  GL_MAP_ATTRIB_V_ORDER_NV* = 0x000086C4
+  GL_EVAL_FRACTIONAL_TESSELLATION_NV* = 0x000086C5
+  GL_EVAL_VERTEX_ATTRIB0_NV* = 0x000086C6
+  GL_EVAL_VERTEX_ATTRIB1_NV* = 0x000086C7
+  GL_EVAL_VERTEX_ATTRIB2_NV* = 0x000086C8
+  GL_EVAL_VERTEX_ATTRIB3_NV* = 0x000086C9
+  GL_EVAL_VERTEX_ATTRIB4_NV* = 0x000086CA
+  GL_EVAL_VERTEX_ATTRIB5_NV* = 0x000086CB
+  GL_EVAL_VERTEX_ATTRIB6_NV* = 0x000086CC
+  GL_EVAL_VERTEX_ATTRIB7_NV* = 0x000086CD
+  GL_EVAL_VERTEX_ATTRIB8_NV* = 0x000086CE
+  GL_EVAL_VERTEX_ATTRIB9_NV* = 0x000086CF
+  GL_EVAL_VERTEX_ATTRIB10_NV* = 0x000086D0
+  GL_EVAL_VERTEX_ATTRIB11_NV* = 0x000086D1
+  GL_EVAL_VERTEX_ATTRIB12_NV* = 0x000086D2
+  GL_EVAL_VERTEX_ATTRIB13_NV* = 0x000086D3
+  GL_EVAL_VERTEX_ATTRIB14_NV* = 0x000086D4
+  GL_EVAL_VERTEX_ATTRIB15_NV* = 0x000086D5
+  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, 
+    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, 
+                              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, 
+                                  pname: TGLenum, params: PGLint){.
+    dynlib: dllname, importc: "glGetMapAttribParameterivNV".}
+proc glGetMapAttribParameterfvNV*(target: TGLenum, index: TGLuint, 
+                                  pname: TGLenum, params: PGLfloat){.
+    dynlib: dllname, importc: "glGetMapAttribParameterfvNV".}
+proc glEvalMapsNV*(target: TGLenum, mode: TGLenum){.dynlib: dllname, 
+    importc: "glEvalMapsNV".}
+  #***** GL_NV_fence *****//
+const 
+  GL_ALL_COMPLETED_NV* = 0x000084F2
+  GL_FENCE_STATUS_NV* = 0x000084F3
+  GL_FENCE_CONDITION_NV* = 0x000084F4
+
+proc glGenFencesNV*(n: TGLsizei, fences: PGLuint){.dynlib: dllname, 
+    importc: "glGenFencesNV".}
+proc glDeleteFencesNV*(n: TGLsizei, fences: PGLuint){.dynlib: dllname, 
+    importc: "glDeleteFencesNV".}
+proc glSetFenceNV*(fence: TGLuint, condition: TGLenum){.dynlib: dllname, 
+    importc: "glSetFenceNV".}
+proc glTestFenceNV*(fence: TGLuint): TGLboolean{.dynlib: dllname, 
+    importc: "glTestFenceNV".}
+proc glFinishFenceNV*(fence: TGLuint){.dynlib: dllname, 
+                                       importc: "glFinishFenceNV".}
+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 
+  GL_FOG_DISTANCE_MODE_NV* = 0x0000855A
+  GL_EYE_RADIAL_NV* = 0x0000855B
+  GL_EYE_PLANE_ABSOLUTE_NV* = 0x0000855C
+  #***** GL_NV_light_max_exponent *****//
+
+const 
+  GL_MAX_SHININESS_NV* = 0x00008504
+  GL_MAX_SPOT_EXPONENT_NV* = 0x00008505
+  #***** GL_NV_multisample_filter_hint *****//
+
+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 
+  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, 
+    importc: "glGenOcclusionQueriesNV".}
+proc glDeleteOcclusionQueriesNV*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, 
+    importc: "glDeleteOcclusionQueriesNV".}
+proc glIsOcclusionQueryNV*(id: TGLuint): TGLboolean{.dynlib: dllname, 
+    importc: "glIsOcclusionQueryNV".}
+proc glBeginOcclusionQueryNV*(id: TGLuint){.dynlib: dllname, 
+    importc: "glBeginOcclusionQueryNV".}
+proc glEndOcclusionQueryNV*(){.dynlib: dllname, importc: "glEndOcclusionQueryNV".}
+proc glGetOcclusionQueryivNV*(id: TGLuint, pname: TGLenum, params: PGLint){.
+    dynlib: dllname, importc: "glGetOcclusionQueryivNV".}
+proc glGetOcclusionQueryuivNV*(id: TGLuint, pname: TGLenum, params: PGLuint){.
+    dynlib: dllname, importc: "glGetOcclusionQueryuivNV".}
+  #***** GL_NV_packed_depth_stencil *****//
+const 
+  GL_DEPTH_STENCIL_NV* = 0x000084F9
+  GL_UNSIGNED_INT_24_8_NV* = 0x000084FA
+  #***** GL_NV_point_sprite *****//
+
+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, 
+    importc: "glPointParameteriNV".}
+proc glPointParameterivNV*(pname: TGLenum, params: PGLint){.dynlib: dllname, 
+    importc: "glPointParameterivNV".}
+  #***** GL_NV_register_combiners *****//
+const 
+  GL_REGISTER_COMBINERS_NV* = 0x00008522
+  GL_COMBINER0_NV* = 0x00008550
+  GL_COMBINER1_NV* = 0x00008551
+  GL_COMBINER2_NV* = 0x00008552
+  GL_COMBINER3_NV* = 0x00008553
+  GL_COMBINER4_NV* = 0x00008554
+  GL_COMBINER5_NV* = 0x00008555
+  GL_COMBINER6_NV* = 0x00008556
+  GL_COMBINER7_NV* = 0x00008557
+  GL_VARIABLE_A_NV* = 0x00008523
+  GL_VARIABLE_B_NV* = 0x00008524
+  GL_VARIABLE_C_NV* = 0x00008525
+  GL_VARIABLE_D_NV* = 0x00008526
+  GL_VARIABLE_E_NV* = 0x00008527
+  GL_VARIABLE_F_NV* = 0x00008528
+  GL_VARIABLE_G_NV* = 0x00008529
+  GL_CONSTANT_COLOR0_NV* = 0x0000852A
+  GL_CONSTANT_COLOR1_NV* = 0x0000852B
+  GL_PRIMARY_COLOR_NV* = 0x0000852C
+  GL_SECONDARY_COLOR_NV* = 0x0000852D
+  GL_SPARE0_NV* = 0x0000852E
+  GL_SPARE1_NV* = 0x0000852F
+  GL_UNSIGNED_IDENTITY_NV* = 0x00008536
+  GL_UNSIGNED_INVERT_NV* = 0x00008537
+  GL_EXPAND_NORMAL_NV* = 0x00008538
+  GL_EXPAND_NEGATE_NV* = 0x00008539
+  GL_HALF_BIAS_NORMAL_NV* = 0x0000853A
+  GL_HALF_BIAS_NEGATE_NV* = 0x0000853B
+  GL_SIGNED_IDENTITY_NV* = 0x0000853C
+  GL_SIGNED_NEGATE_NV* = 0x0000853D
+  GL_E_TIMES_F_NV* = 0x00008531
+  GL_SPARE0_PLUS_SECONDARY_COLOR_NV* = 0x00008532
+  GL_SCALE_BY_TWO_NV* = 0x0000853E
+  GL_SCALE_BY_FOUR_NV* = 0x0000853F
+  GL_SCALE_BY_ONE_HALF_NV* = 0x00008540
+  GL_BIAS_BY_NEGATIVE_ONE_HALF_NV* = 0x00008541
+  GL_DISCARD_NV* = 0x00008530
+  constGL_COMBINER_INPUT_NV* = 0x00008542
+  GL_COMBINER_MAPPING_NV* = 0x00008543
+  GL_COMBINER_COMPONENT_USAGE_NV* = 0x00008544
+  GL_COMBINER_AB_DOT_PRODUCT_NV* = 0x00008545
+  GL_COMBINER_CD_DOT_PRODUCT_NV* = 0x00008546
+  GL_COMBINER_MUX_SUM_NV* = 0x00008547
+  GL_COMBINER_SCALE_NV* = 0x00008548
+  GL_COMBINER_BIAS_NV* = 0x00008549
+  GL_COMBINER_AB_OUTPUT_NV* = 0x0000854A
+  GL_COMBINER_CD_OUTPUT_NV* = 0x0000854B
+  GL_COMBINER_SUM_OUTPUT_NV* = 0x0000854C
+  GL_NUM_GENERAL_COMBINERS_NV* = 0x0000854E
+  GL_COLOR_SUM_CLAMP_NV* = 0x0000854F
+  GL_MAX_GENERAL_COMBINERS_NV* = 0x0000854D
+
+proc glCombinerParameterfvNV*(pname: TGLenum, params: PGLfloat){.
+    dynlib: dllname, importc: "glCombinerParameterfvNV".}
+proc glCombinerParameterivNV*(pname: TGLenum, params: PGLint){.dynlib: dllname, 
+    importc: "glCombinerParameterivNV".}
+proc glCombinerParameterfNV*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, 
+    importc: "glCombinerParameterfNV".}
+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, 
+    importc: "glCombinerInputNV".}
+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, 
+                             mapping: TGLenum, componentUsage: TGLenum){.
+    dynlib: dllname, importc: "glFinalCombinerInputNV".}
+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, 
+    importc: "glGetCombinerInputParameterivNV".}
+proc glGetCombinerOutputParameterfvNV*(stage: TGLenum, portion: TGLenum, 
+                                       pname: TGLenum, params: PGLfloat){.
+    dynlib: dllname, importc: "glGetCombinerOutputParameterfvNV".}
+proc glGetCombinerOutputParameterivNV*(stage: TGLenum, portion: TGLenum, 
+                                       pname: TGLenum, params: PGLint){.
+    dynlib: dllname, importc: "glGetCombinerOutputParameterivNV".}
+proc glGetFinalCombinerInputParameterfvNV*(variable: TGLenum, pname: TGLenum, 
+    params: PGLfloat){.dynlib: dllname, 
+                       importc: "glGetFinalCombinerInputParameterfvNV".}
+proc glGetFinalCombinerInputParameterivNV*(variable: TGLenum, pname: TGLenum, 
+    params: PGLint){.dynlib: dllname, 
+                     importc: "glGetFinalCombinerInputParameterivNV".}
+  #***** GL_NV_register_combiners2 *****//
+const 
+  GL_PER_STAGE_CONSTANTS_NV* = 0x00008535
+
+proc glCombinerStageParameterfvNV*(stage: TGLenum, pname: TGLenum, 
+                                   params: PGLfloat){.dynlib: dllname, 
+    importc: "glCombinerStageParameterfvNV".}
+proc glGetCombinerStageParameterfvNV*(stage: TGLenum, pname: TGLenum, 
+                                      params: PGLfloat){.dynlib: dllname, 
+    importc: "glGetCombinerStageParameterfvNV".}
+  #***** GL_NV_texgen_emboss *****//
+const 
+  GL_EMBOSS_MAP_NV* = 0x0000855F
+  GL_EMBOSS_LIGHT_NV* = 0x0000855D
+  GL_EMBOSS_CONSTANT_NV* = 0x0000855E
+  #***** GL_NV_texgen_reflection *****//
+
+const 
+  GL_NORMAL_MAP_NV* = 0x00008511
+  GL_REFLECTION_MAP_NV* = 0x00008512
+  #***** GL_NV_texture_compression_vtc *****//
+  # GL_COMPRESSED_RGB_S3TC_DXT1_EXT  { already defined }
+  # GL_COMPRESSED_RGBA_S3TC_DXT1_EXT  { already defined }
+  # GL_COMPRESSED_RGBA_S3TC_DXT3_EXT  { already defined }
+  # GL_COMPRESSED_RGBA_S3TC_DXT5_EXT  { already defined }
+  #***** GL_NV_texture_env_combine4 *****//
+
+const 
+  GL_COMBINE4_NV* = 0x00008503
+  GL_SOURCE3_RGB_NV* = 0x00008583
+  GL_SOURCE3_ALPHA_NV* = 0x0000858B
+  GL_OPERAND3_RGB_NV* = 0x00008593
+  GL_OPERAND3_ALPHA_NV* = 0x0000859B
+  #***** GL_NV_texture_rectangle *****//
+
+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 
+  GL_TEXTURE_SHADER_NV* = 0x000086DE
+  GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV* = 0x000086D9
+  GL_SHADER_OPERATION_NV* = 0x000086DF
+  GL_CULL_MODES_NV* = 0x000086E0
+  GL_OFFSET_TEXTURE_MATRIX_NV* = 0x000086E1
+  GL_OFFSET_TEXTURE_SCALE_NV* = 0x000086E2
+  GL_OFFSET_TEXTURE_BIAS_NV* = 0x000086E3
+  GL_PREVIOUS_TEXTURE_INPUT_NV* = 0x000086E4
+  GL_CONST_EYE_NV* = 0x000086E5
+  GL_SHADER_CONSISTENT_NV* = 0x000086DD
+  GL_PASS_THROUGH_NV* = 0x000086E6
+  GL_CULL_FRAGMENT_NV* = 0x000086E7
+  GL_OFFSET_TEXTURE_2D_NV* = 0x000086E8
+  GL_OFFSET_TEXTURE_RECTANGLE_NV* = 0x0000864C
+  GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV* = 0x0000864D
+  GL_DEPENDENT_AR_TEXTURE_2D_NV* = 0x000086E9
+  GL_DEPENDENT_GB_TEXTURE_2D_NV* = 0x000086EA
+  GL_DOT_PRODUCT_NV* = 0x000086EC
+  GL_DOT_PRODUCT_DEPTH_REPLACE_NV* = 0x000086ED
+  GL_DOT_PRODUCT_TEXTURE_2D_NV* = 0x000086EE
+  GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV* = 0x0000864E
+  GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV* = 0x000086F0
+  GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV* = 0x000086F1
+  GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV* = 0x000086F2
+  GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV* = 0x000086F3
+  GL_HILO_NV* = 0x000086F4
+  GL_DSDT_NV* = 0x000086F5
+  GL_DSDT_MAG_NV* = 0x000086F6
+  GL_DSDT_MAG_VIB_NV* = 0x000086F7
+  GL_UNSIGNED_INT_S8_S8_8_8_NV* = 0x000086DA
+  GL_UNSIGNED_INT_8_8_S8_S8_REV_NV* = 0x000086DB
+  GL_SIGNED_RGBA_NV* = 0x000086FB
+  GL_SIGNED_RGBA8_NV* = 0x000086FC
+  GL_SIGNED_RGB_NV* = 0x000086FE
+  GL_SIGNED_RGB8_NV* = 0x000086FF
+  GL_SIGNED_LUMINANCE_NV* = 0x00008701
+  GL_SIGNED_LUMINANCE8_NV* = 0x00008702
+  GL_SIGNED_LUMINANCE_ALPHA_NV* = 0x00008703
+  GL_SIGNED_LUMINANCE8_ALPHA8_NV* = 0x00008704
+  GL_SIGNED_ALPHA_NV* = 0x00008705
+  GL_SIGNED_ALPHA8_NV* = 0x00008706
+  GL_SIGNED_INTENSITY_NV* = 0x00008707
+  GL_SIGNED_INTENSITY8_NV* = 0x00008708
+  GL_SIGNED_RGB_UNSIGNED_ALPHA_NV* = 0x0000870C
+  GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV* = 0x0000870D
+  GL_HILO16_NV* = 0x000086F8
+  GL_SIGNED_HILO_NV* = 0x000086F9
+  GL_SIGNED_HILO16_NV* = 0x000086FA
+  GL_DSDT8_NV* = 0x00008709
+  GL_DSDT8_MAG8_NV* = 0x0000870A
+  GL_DSDT_MAG_INTENSITY_NV* = 0x000086DC
+  GL_DSDT8_MAG8_INTENSITY8_NV* = 0x0000870B
+  GL_HI_SCALE_NV* = 0x0000870E
+  GL_LO_SCALE_NV* = 0x0000870F
+  GL_DS_SCALE_NV* = 0x00008710
+  GL_DT_SCALE_NV* = 0x00008711
+  GL_MAGNITUDE_SCALE_NV* = 0x00008712
+  GL_VIBRANCE_SCALE_NV* = 0x00008713
+  GL_HI_BIAS_NV* = 0x00008714
+  GL_LO_BIAS_NV* = 0x00008715
+  GL_DS_BIAS_NV* = 0x00008716
+  GL_DT_BIAS_NV* = 0x00008717
+  GL_MAGNITUDE_BIAS_NV* = 0x00008718
+  GL_VIBRANCE_BIAS_NV* = 0x00008719
+  GL_TEXTURE_BORDER_VALUES_NV* = 0x0000871A
+  GL_TEXTURE_HI_SIZE_NV* = 0x0000871B
+  GL_TEXTURE_LO_SIZE_NV* = 0x0000871C
+  GL_TEXTURE_DS_SIZE_NV* = 0x0000871D
+  GL_TEXTURE_DT_SIZE_NV* = 0x0000871E
+  GL_TEXTURE_MAG_SIZE_NV* = 0x0000871F
+  #***** GL_NV_texture_shader2 *****//
+
+const 
+  GL_DOT_PRODUCT_TEXTURE_3D_NV* = 0x000086EF # GL_HILO_NV  { already defined }
+                                             # GL_DSDT_NV  { already defined }
+                                             # GL_DSDT_MAG_NV  { already defined }
+                                             # GL_DSDT_MAG_VIB_NV  { already defined }
+                                             # GL_UNSIGNED_INT_S8_S8_8_8_NV  { already defined }
+                                             # GL_UNSIGNED_INT_8_8_S8_S8_REV_NV  { already defined }
+                                             # GL_SIGNED_RGBA_NV  { already defined }
+                                             # GL_SIGNED_RGBA8_NV  { already defined }
+                                             # GL_SIGNED_RGB_NV  { already defined }
+                                             # GL_SIGNED_RGB8_NV  { already defined }
+                                             # GL_SIGNED_LUMINANCE_NV  { already defined }
+                                             # GL_SIGNED_LUMINANCE8_NV  { already defined }
+                                             # GL_SIGNED_LUMINANCE_ALPHA_NV  { already defined }
+                                             # GL_SIGNED_LUMINANCE8_ALPHA8_NV  { already defined }
+                                             # GL_SIGNED_ALPHA_NV  { already defined }
+                                             # GL_SIGNED_ALPHA8_NV  { already defined }
+                                             # GL_SIGNED_INTENSITY_NV  { already defined }
+                                             # GL_SIGNED_INTENSITY8_NV  { already defined }
+                                             # GL_SIGNED_RGB_UNSIGNED_ALPHA_NV  { already defined }
+                                             # GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV  { already defined }
+                                             # GL_HILO16_NV  { already defined }
+                                             # GL_SIGNED_HILO_NV  { already defined }
+                                             # GL_SIGNED_HILO16_NV  { already defined }
+                                             # GL_DSDT8_NV  { already defined }
+                                             # GL_DSDT8_MAG8_NV  { already defined }
+                                             # GL_DSDT_MAG_INTENSITY_NV  { already defined }
+                                             # GL_DSDT8_MAG8_INTENSITY8_NV  { already defined }
+  #***** GL_NV_texture_shader3 *****//
+
+const 
+  GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV* = 0x00008850
+  GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV* = 0x00008851
+  GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV* = 0x00008852
+  GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV* = 0x00008853
+  GL_OFFSET_HILO_TEXTURE_2D_NV* = 0x00008854
+  GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV* = 0x00008855
+  GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV* = 0x00008856
+  GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV* = 0x00008857
+  GL_DEPENDENT_HILO_TEXTURE_2D_NV* = 0x00008858
+  GL_DEPENDENT_RGB_TEXTURE_3D_NV* = 0x00008859
+  GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV* = 0x0000885A
+  GL_DOT_PRODUCT_PASS_THROUGH_NV* = 0x0000885B
+  GL_DOT_PRODUCT_TEXTURE_1D_NV* = 0x0000885C
+  GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV* = 0x0000885D
+  GL_HILO8_NV* = 0x0000885E
+  GL_SIGNED_HILO8_NV* = 0x0000885F
+  GL_FORCE_BLUE_TO_ONE_NV* = 0x00008860
+  #***** GL_NV_vertex_array_range *****//
+
+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, 
+    importc: "glVertexArrayRangeNV".}
+proc glFlushVertexArrayRangeNV*(){.dynlib: dllname, 
+                                   importc: "glFlushVertexArrayRangeNV".}
+  #***** GL_NV_vertex_array_range2 *****//
+const 
+  GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV* = 0x00008533
+  #***** GL_NV_vertex_program *****//
+
+const 
+  GL_VERTEX_PROGRAM_NV* = 0x00008620
+  GL_VERTEX_PROGRAM_POINT_SIZE_NV* = 0x00008642
+  GL_VERTEX_PROGRAM_TWO_SIDE_NV* = 0x00008643
+  GL_VERTEX_STATE_PROGRAM_NV* = 0x00008621
+  GL_ATTRIB_ARRAY_SIZE_NV* = 0x00008623
+  GL_ATTRIB_ARRAY_STRIDE_NV* = 0x00008624
+  GL_ATTRIB_ARRAY_TYPE_NV* = 0x00008625
+  GL_CURRENT_ATTRIB_NV* = 0x00008626
+  GL_PROGRAM_PARAMETER_NV* = 0x00008644
+  GL_ATTRIB_ARRAY_POINTER_NV* = 0x00008645
+  GL_PROGRAM_TARGET_NV* = 0x00008646
+  GL_PROGRAM_LENGTH_NV* = 0x00008627
+  GL_PROGRAM_RESIDENT_NV* = 0x00008647
+  GL_PROGRAM_STRING_NV* = 0x00008628
+  constGL_TRACK_MATRIX_NV* = 0x00008648
+  GL_TRACK_MATRIX_TRANSFORM_NV* = 0x00008649
+  GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV* = 0x0000862E
+  GL_MAX_TRACK_MATRICES_NV* = 0x0000862F
+  GL_CURRENT_MATRIX_STACK_DEPTH_NV* = 0x00008640
+  GL_CURRENT_MATRIX_NV* = 0x00008641
+  GL_VERTEX_PROGRAM_BINDING_NV* = 0x0000864A
+  GL_PROGRAM_ERROR_POSITION_NV* = 0x0000864B
+  GL_MODELVIEW_PROJECTION_NV* = 0x00008629
+  GL_MATRIX0_NV* = 0x00008630
+  GL_MATRIX1_NV* = 0x00008631
+  GL_MATRIX2_NV* = 0x00008632
+  GL_MATRIX3_NV* = 0x00008633
+  GL_MATRIX4_NV* = 0x00008634
+  GL_MATRIX5_NV* = 0x00008635
+  GL_MATRIX6_NV* = 0x00008636
+  GL_MATRIX7_NV* = 0x00008637
+  GL_IDENTITY_NV* = 0x0000862A
+  GL_INVERSE_NV* = 0x0000862B
+  GL_TRANSPOSE_NV* = 0x0000862C
+  GL_INVERSE_TRANSPOSE_NV* = 0x0000862D
+  GL_VERTEX_ATTRIB_ARRAY0_NV* = 0x00008650
+  GL_VERTEX_ATTRIB_ARRAY1_NV* = 0x00008651
+  GL_VERTEX_ATTRIB_ARRAY2_NV* = 0x00008652
+  GL_VERTEX_ATTRIB_ARRAY3_NV* = 0x00008653
+  GL_VERTEX_ATTRIB_ARRAY4_NV* = 0x00008654
+  GL_VERTEX_ATTRIB_ARRAY5_NV* = 0x00008655
+  GL_VERTEX_ATTRIB_ARRAY6_NV* = 0x00008656
+  GL_VERTEX_ATTRIB_ARRAY7_NV* = 0x00008657
+  GL_VERTEX_ATTRIB_ARRAY8_NV* = 0x00008658
+  GL_VERTEX_ATTRIB_ARRAY9_NV* = 0x00008659
+  GL_VERTEX_ATTRIB_ARRAY10_NV* = 0x0000865A
+  GL_VERTEX_ATTRIB_ARRAY11_NV* = 0x0000865B
+  GL_VERTEX_ATTRIB_ARRAY12_NV* = 0x0000865C
+  GL_VERTEX_ATTRIB_ARRAY13_NV* = 0x0000865D
+  GL_VERTEX_ATTRIB_ARRAY14_NV* = 0x0000865E
+  GL_VERTEX_ATTRIB_ARRAY15_NV* = 0x0000865F
+  GL_MAP1_VERTEX_ATTRIB0_4_NV* = 0x00008660
+  GL_MAP1_VERTEX_ATTRIB1_4_NV* = 0x00008661
+  GL_MAP1_VERTEX_ATTRIB2_4_NV* = 0x00008662
+  GL_MAP1_VERTEX_ATTRIB3_4_NV* = 0x00008663
+  GL_MAP1_VERTEX_ATTRIB4_4_NV* = 0x00008664
+  GL_MAP1_VERTEX_ATTRIB5_4_NV* = 0x00008665
+  GL_MAP1_VERTEX_ATTRIB6_4_NV* = 0x00008666
+  GL_MAP1_VERTEX_ATTRIB7_4_NV* = 0x00008667
+  GL_MAP1_VERTEX_ATTRIB8_4_NV* = 0x00008668
+  GL_MAP1_VERTEX_ATTRIB9_4_NV* = 0x00008669
+  GL_MAP1_VERTEX_ATTRIB10_4_NV* = 0x0000866A
+  GL_MAP1_VERTEX_ATTRIB11_4_NV* = 0x0000866B
+  GL_MAP1_VERTEX_ATTRIB12_4_NV* = 0x0000866C
+  GL_MAP1_VERTEX_ATTRIB13_4_NV* = 0x0000866D
+  GL_MAP1_VERTEX_ATTRIB14_4_NV* = 0x0000866E
+  GL_MAP1_VERTEX_ATTRIB15_4_NV* = 0x0000866F
+  GL_MAP2_VERTEX_ATTRIB0_4_NV* = 0x00008670
+  GL_MAP2_VERTEX_ATTRIB1_4_NV* = 0x00008671
+  GL_MAP2_VERTEX_ATTRIB2_4_NV* = 0x00008672
+  GL_MAP2_VERTEX_ATTRIB3_4_NV* = 0x00008673
+  GL_MAP2_VERTEX_ATTRIB4_4_NV* = 0x00008674
+  GL_MAP2_VERTEX_ATTRIB5_4_NV* = 0x00008675
+  GL_MAP2_VERTEX_ATTRIB6_4_NV* = 0x00008676
+  GL_MAP2_VERTEX_ATTRIB7_4_NV* = 0x00008677
+  GL_MAP2_VERTEX_ATTRIB8_4_NV* = 0x00008678
+  GL_MAP2_VERTEX_ATTRIB9_4_NV* = 0x00008679
+  GL_MAP2_VERTEX_ATTRIB10_4_NV* = 0x0000867A
+  GL_MAP2_VERTEX_ATTRIB11_4_NV* = 0x0000867B
+  GL_MAP2_VERTEX_ATTRIB12_4_NV* = 0x0000867C
+  GL_MAP2_VERTEX_ATTRIB13_4_NV* = 0x0000867D
+  GL_MAP2_VERTEX_ATTRIB14_4_NV* = 0x0000867E
+  GL_MAP2_VERTEX_ATTRIB15_4_NV* = 0x0000867F
+
+proc glBindProgramNV*(target: TGLenum, id: TGLuint){.dynlib: dllname, 
+    importc: "glBindProgramNV".}
+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, 
+    importc: "glGenProgramsNV".}
+proc glAreProgramsResidentNV*(n: TGLsizei, ids: PGLuint, residences: PGLboolean): TGLboolean{.
+    dynlib: dllname, importc: "glAreProgramsResidentNV".}
+proc glRequestResidentProgramsNV*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, 
+    importc: "glRequestResidentProgramsNV".}
+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, 
+    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, 
+    importc: "glGetTrackMatrixivNV".}
+proc glGetVertexAttribdvNV*(index: TGLuint, pname: TGLenum, params: PGLdouble){.
+    dynlib: dllname, importc: "glGetVertexAttribdvNV".}
+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, 
+    importc: "glGetVertexAttribPointervNV".}
+proc glIsProgramNV*(id: TGLuint): TGLboolean{.dynlib: dllname, 
+    importc: "glIsProgramNV".}
+proc glLoadProgramNV*(target: TGLenum, id: TGLuint, length: TGLsizei, 
+                      theProgram: PGLubyte){.dynlib: dllname, 
+    importc: "glLoadProgramNV".}
+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, 
+    importc: "glProgramParameters4dvNV".}
+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, 
+    importc: "glTrackMatrixNV".}
+proc glVertexAttribPointerNV*(index: TGLuint, size: TGLint, thetype: TGLenum, 
+                              stride: TGLsizei, pointer: PGLvoid){.
+    dynlib: dllname, importc: "glVertexAttribPointerNV".}
+proc glVertexAttrib1sNV*(index: TGLuint, x: TGLshort){.dynlib: dllname, 
+    importc: "glVertexAttrib1sNV".}
+proc glVertexAttrib1fNV*(index: TGLuint, x: TGLfloat){.dynlib: dllname, 
+    importc: "glVertexAttrib1fNV".}
+proc glVertexAttrib1dNV*(index: TGLuint, x: TGLdouble){.dynlib: dllname, 
+    importc: "glVertexAttrib1dNV".}
+proc glVertexAttrib2sNV*(index: TGLuint, x: TGLshort, y: TGLshort){.
+    dynlib: dllname, importc: "glVertexAttrib2sNV".}
+proc glVertexAttrib2fNV*(index: TGLuint, x: TGLfloat, y: TGLfloat){.
+    dynlib: dllname, importc: "glVertexAttrib2fNV".}
+proc glVertexAttrib2dNV*(index: TGLuint, x: TGLdouble, y: TGLdouble){.
+    dynlib: dllname, importc: "glVertexAttrib2dNV".}
+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, 
+                                        importc: "glVertexAttrib3dNV".}
+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, 
+                                       importc: "glVertexAttrib4fNV".}
+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, 
+                                        importc: "glVertexAttrib4ubNV".}
+proc glVertexAttrib1svNV*(index: TGLuint, v: PGLshort){.dynlib: dllname, 
+    importc: "glVertexAttrib1svNV".}
+proc glVertexAttrib1fvNV*(index: TGLuint, v: PGLfloat){.dynlib: dllname, 
+    importc: "glVertexAttrib1fvNV".}
+proc glVertexAttrib1dvNV*(index: TGLuint, v: PGLdouble){.dynlib: dllname, 
+    importc: "glVertexAttrib1dvNV".}
+proc glVertexAttrib2svNV*(index: TGLuint, v: PGLshort){.dynlib: dllname, 
+    importc: "glVertexAttrib2svNV".}
+proc glVertexAttrib2fvNV*(index: TGLuint, v: PGLfloat){.dynlib: dllname, 
+    importc: "glVertexAttrib2fvNV".}
+proc glVertexAttrib2dvNV*(index: TGLuint, v: PGLdouble){.dynlib: dllname, 
+    importc: "glVertexAttrib2dvNV".}
+proc glVertexAttrib3svNV*(index: TGLuint, v: PGLshort){.dynlib: dllname, 
+    importc: "glVertexAttrib3svNV".}
+proc glVertexAttrib3fvNV*(index: TGLuint, v: PGLfloat){.dynlib: dllname, 
+    importc: "glVertexAttrib3fvNV".}
+proc glVertexAttrib3dvNV*(index: TGLuint, v: PGLdouble){.dynlib: dllname, 
+    importc: "glVertexAttrib3dvNV".}
+proc glVertexAttrib4svNV*(index: TGLuint, v: PGLshort){.dynlib: dllname, 
+    importc: "glVertexAttrib4svNV".}
+proc glVertexAttrib4fvNV*(index: TGLuint, v: PGLfloat){.dynlib: dllname, 
+    importc: "glVertexAttrib4fvNV".}
+proc glVertexAttrib4dvNV*(index: TGLuint, v: PGLdouble){.dynlib: dllname, 
+    importc: "glVertexAttrib4dvNV".}
+proc glVertexAttrib4ubvNV*(index: TGLuint, v: PGLubyte){.dynlib: dllname, 
+    importc: "glVertexAttrib4ubvNV".}
+proc glVertexAttribs1svNV*(index: TGLuint, n: TGLsizei, v: PGLshort){.
+    dynlib: dllname, importc: "glVertexAttribs1svNV".}
+proc glVertexAttribs1fvNV*(index: TGLuint, n: TGLsizei, v: PGLfloat){.
+    dynlib: dllname, importc: "glVertexAttribs1fvNV".}
+proc glVertexAttribs1dvNV*(index: TGLuint, n: TGLsizei, v: PGLdouble){.
+    dynlib: dllname, importc: "glVertexAttribs1dvNV".}
+proc glVertexAttribs2svNV*(index: TGLuint, n: TGLsizei, v: PGLshort){.
+    dynlib: dllname, importc: "glVertexAttribs2svNV".}
+proc glVertexAttribs2fvNV*(index: TGLuint, n: TGLsizei, v: PGLfloat){.
+    dynlib: dllname, importc: "glVertexAttribs2fvNV".}
+proc glVertexAttribs2dvNV*(index: TGLuint, n: TGLsizei, v: PGLdouble){.
+    dynlib: dllname, importc: "glVertexAttribs2dvNV".}
+proc glVertexAttribs3svNV*(index: TGLuint, n: TGLsizei, v: PGLshort){.
+    dynlib: dllname, importc: "glVertexAttribs3svNV".}
+proc glVertexAttribs3fvNV*(index: TGLuint, n: TGLsizei, v: PGLfloat){.
+    dynlib: dllname, importc: "glVertexAttribs3fvNV".}
+proc glVertexAttribs3dvNV*(index: TGLuint, n: TGLsizei, v: PGLdouble){.
+    dynlib: dllname, importc: "glVertexAttribs3dvNV".}
+proc glVertexAttribs4svNV*(index: TGLuint, n: TGLsizei, v: PGLshort){.
+    dynlib: dllname, importc: "glVertexAttribs4svNV".}
+proc glVertexAttribs4fvNV*(index: TGLuint, n: TGLsizei, v: PGLfloat){.
+    dynlib: dllname, importc: "glVertexAttribs4fvNV".}
+proc glVertexAttribs4dvNV*(index: TGLuint, n: TGLsizei, v: PGLdouble){.
+    dynlib: dllname, importc: "glVertexAttribs4dvNV".}
+proc glVertexAttribs4ubvNV*(index: TGLuint, n: TGLsizei, v: PGLubyte){.
+    dynlib: dllname, importc: "glVertexAttribs4ubvNV".}
+  #***** GL_NV_vertex_program1_1 *****//
+  #***** GL_ATI_element_array *****//
+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, 
+    importc: "glElementPointerATI".}
+proc glDrawElementArrayATI*(mode: TGLenum, count: TGLsizei){.dynlib: dllname, 
+    importc: "glDrawElementArrayATI".}
+proc glDrawRangeElementArrayATI*(mode: TGLenum, start: TGLuint, theend: TGLuint, 
+                                 count: TGLsizei){.dynlib: dllname, 
+    importc: "glDrawRangeElementArrayATI".}
+  #***** GL_ATI_envmap_bumpmap *****//
+const 
+  GL_BUMP_ROT_MATRIX_ATI* = 0x00008775
+  GL_BUMP_ROT_MATRIX_SIZE_ATI* = 0x00008776
+  GL_BUMP_NUM_TEX_UNITS_ATI* = 0x00008777
+  GL_BUMP_TEX_UNITS_ATI* = 0x00008778
+  GL_DUDV_ATI* = 0x00008779
+  GL_DU8DV8_ATI* = 0x0000877A
+  GL_BUMP_ENVMAP_ATI* = 0x0000877B
+  GL_BUMP_TARGET_ATI* = 0x0000877C
+
+proc glTexBumpParameterivATI*(pname: TGLenum, param: PGLint){.dynlib: dllname, 
+    importc: "glTexBumpParameterivATI".}
+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 
+  GL_FRAGMENT_SHADER_ATI* = 0x00008920
+  GL_REG_0_ATI* = 0x00008921
+  GL_REG_1_ATI* = 0x00008922
+  GL_REG_2_ATI* = 0x00008923
+  GL_REG_3_ATI* = 0x00008924
+  GL_REG_4_ATI* = 0x00008925
+  GL_REG_5_ATI* = 0x00008926
+  GL_CON_0_ATI* = 0x00008941
+  GL_CON_1_ATI* = 0x00008942
+  GL_CON_2_ATI* = 0x00008943
+  GL_CON_3_ATI* = 0x00008944
+  GL_CON_4_ATI* = 0x00008945
+  GL_CON_5_ATI* = 0x00008946
+  GL_CON_6_ATI* = 0x00008947
+  GL_CON_7_ATI* = 0x00008948
+  GL_MOV_ATI* = 0x00008961
+  GL_ADD_ATI* = 0x00008963
+  GL_MUL_ATI* = 0x00008964
+  GL_SUB_ATI* = 0x00008965
+  GL_DOT3_ATI* = 0x00008966
+  GL_DOT4_ATI* = 0x00008967
+  GL_MAD_ATI* = 0x00008968
+  GL_LERP_ATI* = 0x00008969
+  GL_CND_ATI* = 0x0000896A
+  GL_CND0_ATI* = 0x0000896B
+  GL_DOT2_ADD_ATI* = 0x0000896C
+  GL_SECONDARY_INTERPOLATOR_ATI* = 0x0000896D
+  GL_SWIZZLE_STR_ATI* = 0x00008976
+  GL_SWIZZLE_STQ_ATI* = 0x00008977
+  GL_SWIZZLE_STR_DR_ATI* = 0x00008978
+  GL_SWIZZLE_STQ_DQ_ATI* = 0x00008979
+  GL_RED_BIT_ATI* = 0x00000001
+  GL_GREEN_BIT_ATI* = 0x00000002
+  GL_BLUE_BIT_ATI* = 0x00000004
+  GL_2X_BIT_ATI* = 0x00000001
+  GL_4X_BIT_ATI* = 0x00000002
+  GL_8X_BIT_ATI* = 0x00000004
+  GL_HALF_BIT_ATI* = 0x00000008
+  GL_QUARTER_BIT_ATI* = 0x00000010
+  GL_EIGHTH_BIT_ATI* = 0x00000020
+  GL_SATURATE_BIT_ATI* = 0x00000040 # GL_2X_BIT_ATI  { already defined }
+  GL_COMP_BIT_ATI* = 0x00000002
+  GL_NEGATE_BIT_ATI* = 0x00000004
+  GL_BIAS_BIT_ATI* = 0x00000008
+
+proc glGenFragmentShadersATI*(range: TGLuint): TGLuint{.dynlib: dllname, 
+    importc: "glGenFragmentShadersATI".}
+proc glBindFragmentShaderATI*(id: TGLuint){.dynlib: dllname, 
+    importc: "glBindFragmentShaderATI".}
+proc glDeleteFragmentShaderATI*(id: TGLuint){.dynlib: dllname, 
+    importc: "glDeleteFragmentShaderATI".}
+proc glBeginFragmentShaderATI*(){.dynlib: dllname, 
+                                  importc: "glBeginFragmentShaderATI".}
+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, 
+    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, 
+    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, 
+    importc: "glColorFragmentOp3ATI".}
+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, 
+                            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, 
+                            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 
+  GL_PN_TRIANGLES_ATI* = 0x000087F0
+  GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI* = 0x000087F1
+  GL_PN_TRIANGLES_POINT_MODE_ATI* = 0x000087F2
+  GL_PN_TRIANGLES_NORMAL_MODE_ATI* = 0x000087F3
+  GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI* = 0x000087F4
+  GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI* = 0x000087F5
+  GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI* = 0x000087F6
+  GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI* = 0x000087F7
+  GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI* = 0x000087F8
+
+proc glPNTrianglesiATI*(pname: TGLenum, param: TGLint){.dynlib: dllname, 
+    importc: "glPNTrianglesiATI".}
+proc glPNTrianglesfATI*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, 
+    importc: "glPNTrianglesfATI".}
+  #***** GL_ATI_texture_mirror_once *****//
+const 
+  GL_MIRROR_CLAMP_ATI* = 0x00008742
+  GL_MIRROR_CLAMP_TO_EDGE_ATI* = 0x00008743
+  #***** GL_ATI_vertex_array_object *****//
+
+const 
+  GL_STATIC_ATI* = 0x00008760
+  GL_DYNAMIC_ATI* = 0x00008761
+  GL_PRESERVE_ATI* = 0x00008762
+  GL_DISCARD_ATI* = 0x00008763
+  GL_OBJECT_BUFFER_SIZE_ATI* = 0x00008764
+  GL_OBJECT_BUFFER_USAGE_ATI* = 0x00008765
+  GL_ARRAY_OBJECT_BUFFER_ATI* = 0x00008766
+  GL_ARRAY_OBJECT_OFFSET_ATI* = 0x00008767
+
+proc glNewObjectBufferATI*(size: TGLsizei, pointer: PGLvoid, usage: TGLenum): TGLuint{.
+    dynlib: dllname, importc: "glNewObjectBufferATI".}
+proc glIsObjectBufferATI*(buffer: TGLuint): TGLboolean{.dynlib: dllname, 
+    importc: "glIsObjectBufferATI".}
+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, 
+    importc: "glDeleteObjectBufferATI".}
+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, 
+                              buffer: TGLuint, offset: TGLuint){.
+    dynlib: dllname, importc: "glVariantArrayObjectATI".}
+proc glGetVariantArrayObjectfvATI*(id: TGLuint, pname: TGLenum, params: PGLfloat){.
+    dynlib: dllname, importc: "glGetVariantArrayObjectfvATI".}
+proc glGetVariantArrayObjectivATI*(id: TGLuint, pname: TGLenum, params: PGLint){.
+    dynlib: dllname, importc: "glGetVariantArrayObjectivATI".}
+  #***** GL_ATI_vertex_streams *****//
+const 
+  GL_MAX_VERTEX_STREAMS_ATI* = 0x0000876B
+  GL_VERTEX_STREAM0_ATI* = 0x0000876C
+  GL_VERTEX_STREAM1_ATI* = 0x0000876D
+  GL_VERTEX_STREAM2_ATI* = 0x0000876E
+  GL_VERTEX_STREAM3_ATI* = 0x0000876F
+  GL_VERTEX_STREAM4_ATI* = 0x00008770
+  GL_VERTEX_STREAM5_ATI* = 0x00008771
+  GL_VERTEX_STREAM6_ATI* = 0x00008772
+  GL_VERTEX_STREAM7_ATI* = 0x00008773
+  GL_VERTEX_SOURCE_ATI* = 0x00008774
+
+proc glVertexStream1s*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, 
+    importc: "glVertexStream1s".}
+proc glVertexStream1i*(stream: TGLenum, coords: TGLint){.dynlib: dllname, 
+    importc: "glVertexStream1i".}
+proc glVertexStream1f*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, 
+    importc: "glVertexStream1f".}
+proc glVertexStream1d*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, 
+    importc: "glVertexStream1d".}
+proc glVertexStream1sv*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, 
+    importc: "glVertexStream1sv".}
+proc glVertexStream1iv*(stream: TGLenum, coords: TGLint){.dynlib: dllname, 
+    importc: "glVertexStream1iv".}
+proc glVertexStream1fv*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, 
+    importc: "glVertexStream1fv".}
+proc glVertexStream1dv*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, 
+    importc: "glVertexStream1dv".}
+proc glVertexStream2s*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, 
+    importc: "glVertexStream2s".}
+proc glVertexStream2i*(stream: TGLenum, coords: TGLint){.dynlib: dllname, 
+    importc: "glVertexStream2i".}
+proc glVertexStream2f*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, 
+    importc: "glVertexStream2f".}
+proc glVertexStream2d*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, 
+    importc: "glVertexStream2d".}
+proc glVertexStream2sv*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, 
+    importc: "glVertexStream2sv".}
+proc glVertexStream2iv*(stream: TGLenum, coords: TGLint){.dynlib: dllname, 
+    importc: "glVertexStream2iv".}
+proc glVertexStream2fv*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, 
+    importc: "glVertexStream2fv".}
+proc glVertexStream2dv*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, 
+    importc: "glVertexStream2dv".}
+proc glVertexStream3s*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, 
+    importc: "glVertexStream3s".}
+proc glVertexStream3i*(stream: TGLenum, coords: TGLint){.dynlib: dllname, 
+    importc: "glVertexStream3i".}
+proc glVertexStream3f*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, 
+    importc: "glVertexStream3f".}
+proc glVertexStream3d*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, 
+    importc: "glVertexStream3d".}
+proc glVertexStream3sv*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, 
+    importc: "glVertexStream3sv".}
+proc glVertexStream3iv*(stream: TGLenum, coords: TGLint){.dynlib: dllname, 
+    importc: "glVertexStream3iv".}
+proc glVertexStream3fv*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, 
+    importc: "glVertexStream3fv".}
+proc glVertexStream3dv*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, 
+    importc: "glVertexStream3dv".}
+proc glVertexStream4s*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, 
+    importc: "glVertexStream4s".}
+proc glVertexStream4i*(stream: TGLenum, coords: TGLint){.dynlib: dllname, 
+    importc: "glVertexStream4i".}
+proc glVertexStream4f*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, 
+    importc: "glVertexStream4f".}
+proc glVertexStream4d*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, 
+    importc: "glVertexStream4d".}
+proc glVertexStream4sv*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, 
+    importc: "glVertexStream4sv".}
+proc glVertexStream4iv*(stream: TGLenum, coords: TGLint){.dynlib: dllname, 
+    importc: "glVertexStream4iv".}
+proc glVertexStream4fv*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, 
+    importc: "glVertexStream4fv".}
+proc glVertexStream4dv*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, 
+    importc: "glVertexStream4dv".}
+proc glNormalStream3b*(stream: TGLenum, coords: TGLByte){.dynlib: dllname, 
+    importc: "glNormalStream3b".}
+proc glNormalStream3s*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, 
+    importc: "glNormalStream3s".}
+proc glNormalStream3i*(stream: TGLenum, coords: TGLint){.dynlib: dllname, 
+    importc: "glNormalStream3i".}
+proc glNormalStream3f*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, 
+    importc: "glNormalStream3f".}
+proc glNormalStream3d*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, 
+    importc: "glNormalStream3d".}
+proc glNormalStream3bv*(stream: TGLenum, coords: TGLByte){.dynlib: dllname, 
+    importc: "glNormalStream3bv".}
+proc glNormalStream3sv*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, 
+    importc: "glNormalStream3sv".}
+proc glNormalStream3iv*(stream: TGLenum, coords: TGLint){.dynlib: dllname, 
+    importc: "glNormalStream3iv".}
+proc glNormalStream3fv*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, 
+    importc: "glNormalStream3fv".}
+proc glNormalStream3dv*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, 
+    importc: "glNormalStream3dv".}
+proc glClientActiveVertexStream*(stream: TGLenum){.dynlib: dllname, 
+    importc: "glClientActiveVertexStream".}
+proc glVertexBlendEnvi*(pname: TGLenum, param: TGLint){.dynlib: dllname, 
+    importc: "glVertexBlendEnvi".}
+proc glVertexBlendEnvf*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, 
+    importc: "glVertexBlendEnvf".}
+  #***** GL_3DFX_texture_compression_FXT1 *****//
+const 
+  GL_COMPRESSED_RGB_FXT1_3DFX* = 0x000086B0
+  GL_COMPRESSED_RGBA_FXT1_3DFX* = 0x000086B1
+  #***** GL_IBM_cull_vertex *****//
+
+const 
+  GL_CULL_VERTEX_IBM* = 0x0001928A
+  #***** GL_IBM_multimode_draw_arrays *****//
+
+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, 
+                                 primcount: TGLsizei, modestride: TGLint){.
+    dynlib: dllname, importc: "glMultiModeDrawElementsIBM".}
+  #***** GL_IBM_raster_pos_clip *****//
+const 
+  GL_RASTER_POSITION_UNCLIPPED_IBM* = 0x00019262
+  #***** GL_IBM_texture_mirrored_repeat *****//
+
+const 
+  GL_MIRRORED_REPEAT_IBM* = 0x00008370
+  #***** GL_IBM_vertex_array_lists *****//
+
+const 
+  GL_VERTEX_ARRAY_LIST_IBM* = 0x0001929E
+  GL_NORMAL_ARRAY_LIST_IBM* = 0x0001929F
+  GL_COLOR_ARRAY_LIST_IBM* = 0x000192A0
+  GL_INDEX_ARRAY_LIST_IBM* = 0x000192A1
+  GL_TEXTURE_COORD_ARRAY_LIST_IBM* = 0x000192A2
+  GL_EDGE_FLAG_ARRAY_LIST_IBM* = 0x000192A3
+  GL_FOG_COORDINATE_ARRAY_LIST_IBM* = 0x000192A4
+  GL_SECONDARY_COLOR_ARRAY_LIST_IBM* = 0x000192A5
+  GL_VERTEX_ARRAY_LIST_STRIDE_IBM* = 0x000192A8
+  GL_NORMAL_ARRAY_LIST_STRIDE_IBM* = 0x000192A9
+  GL_COLOR_ARRAY_LIST_STRIDE_IBM* = 0x000192AA
+  GL_INDEX_ARRAY_LIST_STRIDE_IBM* = 0x000192AB
+  GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM* = 0x000192AC
+  GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM* = 0x000192AD
+  GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM* = 0x000192AE
+  GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM* = 0x000192AF
+
+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, 
+    importc: "glSecondaryColorPointerListIBM".}
+proc glEdgeFlagPointerListIBM*(stride: TGLint, pointer: PGLboolean, 
+                               ptrstride: TGLint){.dynlib: dllname, 
+    importc: "glEdgeFlagPointerListIBM".}
+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, 
+    importc: "glNormalPointerListIBM".}
+proc glTexCoordPointerListIBM*(size: TGLint, thetype: TGLenum, stride: TGLint, 
+                               pointer: PGLvoid, ptrstride: TGLint){.
+    dynlib: dllname, importc: "glTexCoordPointerListIBM".}
+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, 
+    importc: "glWindowPos2dMESA".}
+proc glWindowPos2fMESA*(x: TGLfloat, y: TGLfloat){.dynlib: dllname, 
+    importc: "glWindowPos2fMESA".}
+proc glWindowPos2iMESA*(x: TGLint, y: TGLint){.dynlib: dllname, 
+    importc: "glWindowPos2iMESA".}
+proc glWindowPos2sMESA*(x: TGLshort, y: TGLshort){.dynlib: dllname, 
+    importc: "glWindowPos2sMESA".}
+proc glWindowPos2ivMESA*(p: PGLint){.dynlib: dllname, 
+                                     importc: "glWindowPos2ivMESA".}
+proc glWindowPos2svMESA*(p: PGLshort){.dynlib: dllname, 
+                                       importc: "glWindowPos2svMESA".}
+proc glWindowPos2fvMESA*(p: PGLfloat){.dynlib: dllname, 
+                                       importc: "glWindowPos2fvMESA".}
+proc glWindowPos2dvMESA*(p: PGLdouble){.dynlib: dllname, 
+                                        importc: "glWindowPos2dvMESA".}
+proc glWindowPos3iMESA*(x: TGLint, y: TGLint, z: TGLint){.dynlib: dllname, 
+    importc: "glWindowPos3iMESA".}
+proc glWindowPos3sMESA*(x: TGLshort, y: TGLshort, z: TGLshort){.dynlib: dllname, 
+    importc: "glWindowPos3sMESA".}
+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, 
+                                     importc: "glWindowPos3ivMESA".}
+proc glWindowPos3svMESA*(p: PGLshort){.dynlib: dllname, 
+                                       importc: "glWindowPos3svMESA".}
+proc glWindowPos3fvMESA*(p: PGLfloat){.dynlib: dllname, 
+                                       importc: "glWindowPos3fvMESA".}
+proc glWindowPos3dvMESA*(p: PGLdouble){.dynlib: dllname, 
+                                        importc: "glWindowPos3dvMESA".}
+proc glWindowPos4iMESA*(x: TGLint, y: TGLint, z: TGLint, w: TGLint){.
+    dynlib: dllname, importc: "glWindowPos4iMESA".}
+proc glWindowPos4sMESA*(x: TGLshort, y: TGLshort, z: TGLshort, w: TGLshort){.
+    dynlib: dllname, importc: "glWindowPos4sMESA".}
+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, 
+                                     importc: "glWindowPos4ivMESA".}
+proc glWindowPos4svMESA*(p: PGLshort){.dynlib: dllname, 
+                                       importc: "glWindowPos4svMESA".}
+proc glWindowPos4fvMESA*(p: PGLfloat){.dynlib: dllname, 
+                                       importc: "glWindowPos4fvMESA".}
+proc glWindowPos4dvMESA*(p: PGLdouble){.dynlib: dllname, 
+                                        importc: "glWindowPos4dvMESA".}
+  #***** GL_OML_interlace *****//
+const 
+  GL_INTERLACE_OML* = 0x00008980
+  GL_INTERLACE_READ_OML* = 0x00008981
+  #***** GL_OML_resample *****//
+
+const 
+  GL_PACK_RESAMPLE_OML* = 0x00008984
+  GL_UNPACK_RESAMPLE_OML* = 0x00008985
+  GL_RESAMPLE_REPLICATE_OML* = 0x00008986
+  GL_RESAMPLE_ZERO_FILL_OML* = 0x00008987
+  GL_RESAMPLE_AVERAGE_OML* = 0x00008988
+  GL_RESAMPLE_DECIMATE_OML* = 0x00008989 # GL_RESAMPLE_AVERAGE_OML  { already defined }
+  #***** GL_OML_subsample *****//
+
+const 
+  GL_FORMAT_SUBSAMPLE_24_24_OML* = 0x00008982
+  GL_FORMAT_SUBSAMPLE_244_244_OML* = 0x00008983
+  #***** GL_SGIS_generate_mipmap *****//
+
+const 
+  GL_GENERATE_MIPMAP_SGIS* = 0x00008191
+  GL_GENERATE_MIPMAP_HINT_SGIS* = 0x00008192
+  #***** GL_SGIS_multisample *****//
+
+const 
+  GLX_SAMPLE_BUFFERS_SGIS* = 0x000186A0
+  GLX_SAMPLES_SGIS* = 0x000186A1
+  GL_MULTISAMPLE_SGIS* = 0x0000809D
+  GL_SAMPLE_ALPHA_TO_MASK_SGIS* = 0x0000809E
+  GL_SAMPLE_ALPHA_TO_ONE_SGIS* = 0x0000809F
+  constGL_SAMPLE_MASK_SGIS* = 0x000080A0
+  GL_MULTISAMPLE_BIT_EXT* = 0x20000000
+  GL_1PASS_SGIS* = 0x000080A1
+  GL_2PASS_0_SGIS* = 0x000080A2
+  GL_2PASS_1_SGIS* = 0x000080A3
+  GL_4PASS_0_SGIS* = 0x000080A4
+  GL_4PASS_1_SGIS* = 0x000080A5
+  GL_4PASS_2_SGIS* = 0x000080A6
+  GL_4PASS_3_SGIS* = 0x000080A7
+  GL_SAMPLE_BUFFERS_SGIS* = 0x000080A8
+  GL_SAMPLES_SGIS* = 0x000080A9
+  GL_SAMPLE_MASK_VALUE_SGIS* = 0x000080AA
+  GL_SAMPLE_MASK_INVERT_SGIS* = 0x000080AB
+  constGL_SAMPLE_PATTERN_SGIS* = 0x000080AC
+
+proc glSampleMaskSGIS*(value: TGLclampf, invert: TGLboolean){.dynlib: dllname, 
+    importc: "glSampleMaskSGIS".}
+proc glSamplePatternSGIS*(pattern: TGLenum){.dynlib: dllname, 
+    importc: "glSamplePatternSGIS".}
+  #***** GL_SGIS_pixel_texture *****//
+const 
+  GL_PIXEL_TEXTURE_SGIS* = 0x00008353
+  GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS* = 0x00008354
+  GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS* = 0x00008355
+  GL_PIXEL_GROUP_COLOR_SGIS* = 0x00008356
+
+proc glPixelTexGenParameteriSGIS*(pname: TGLenum, param: TGLint){.
+    dynlib: dllname, importc: "glPixelTexGenParameteriSGIS".}
+proc glPixelTexGenParameterfSGIS*(pname: TGLenum, param: TGLfloat){.
+    dynlib: dllname, importc: "glPixelTexGenParameterfSGIS".}
+proc glGetPixelTexGenParameterivSGIS*(pname: TGLenum, params: TGLint){.
+    dynlib: dllname, importc: "glGetPixelTexGenParameterivSGIS".}
+proc glGetPixelTexGenParameterfvSGIS*(pname: TGLenum, params: TGLfloat){.
+    dynlib: dllname, importc: "glGetPixelTexGenParameterfvSGIS".}
+  #***** GL_SGIS_texture_border_clamp *****//
+  # GL_CLAMP_TO_BORDER_SGIS  { already defined }
+  #***** GL_SGIS_texture_color_mask *****//
+const 
+  GL_TEXTURE_COLOR_WRITEMASK_SGIS* = 0x000081EF
+
+proc glTextureColorMaskSGIS*(r: TGLboolean, g: TGLboolean, b: TGLboolean, 
+                             a: TGLboolean){.dynlib: dllname, 
+    importc: "glTextureColorMaskSGIS".}
+  #***** GL_SGIS_texture_edge_clamp *****//
+const 
+  GL_CLAMP_TO_EDGE_SGIS* = 0x0000812F
+  #***** GL_SGIS_texture_lod *****//
+
+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 
+  GL_DEPTH_COMPONENT16_SGIX* = 0x000081A5
+  GL_DEPTH_COMPONENT24_SGIX* = 0x000081A6
+  GL_DEPTH_COMPONENT32_SGIX* = 0x000081A7
+  #***** GL_SGIX_fog_offset *****//
+
+const 
+  GL_FOG_OFFSET_SGIX* = 0x00008198
+  GL_FOG_OFFSET_VALUE_SGIX* = 0x00008199
+  #***** GL_SGIX_interlace *****//
+
+const 
+  GL_INTERLACE_SGIX* = 0x00008094
+  #***** GL_SGIX_shadow_ambient *****//
+
+const 
+  GL_SHADOW_AMBIENT_SGIX* = 0x000080BF
+  #***** GL_SGI_color_matrix *****//
+
+const 
+  GL_COLOR_MATRIX_SGI* = 0x000080B1
+  GL_COLOR_MATRIX_STACK_DEPTH_SGI* = 0x000080B2
+  GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI* = 0x000080B3
+  GL_POST_COLOR_MATRIX_RED_SCALE_SGI* = 0x000080B4
+  GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI* = 0x000080B5
+  GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI* = 0x000080B6
+  GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI* = 0x000080B7
+  GL_POST_COLOR_MATRIX_RED_BIAS_SGI* = 0x000080B8
+  GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI* = 0x000080B9
+  GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI* = 0x000080BA
+  GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI* = 0x000080BB
+  #***** GL_SGI_color_table *****//
+
+const 
+  constGL_COLOR_TABLE_SGI* = 0x000080D0
+  GL_POST_CONVOLUTION_COLOR_TABLE_SGI* = 0x000080D1
+  GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI* = 0x000080D2
+  GL_PROXY_COLOR_TABLE_SGI* = 0x000080D3
+  GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI* = 0x000080D4
+  GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI* = 0x000080D5
+  GL_COLOR_TABLE_SCALE_SGI* = 0x000080D6
+  GL_COLOR_TABLE_BIAS_SGI* = 0x000080D7
+  GL_COLOR_TABLE_FORMAT_SGI* = 0x000080D8
+  GL_COLOR_TABLE_WIDTH_SGI* = 0x000080D9
+  GL_COLOR_TABLE_RED_SIZE_SGI* = 0x000080DA
+  GL_COLOR_TABLE_GREEN_SIZE_SGI* = 0x000080DB
+  GL_COLOR_TABLE_BLUE_SIZE_SGI* = 0x000080DC
+  GL_COLOR_TABLE_ALPHA_SIZE_SGI* = 0x000080DD
+  GL_COLOR_TABLE_LUMINANCE_SIZE_SGI* = 0x000080DE
+  GL_COLOR_TABLE_INTENSITY_SIZE_SGI* = 0x000080DF
+
+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, 
+    importc: "glCopyColorTableSGI".}
+proc glColorTableParameterivSGI*(target: TGLenum, pname: TGLenum, params: PGLint){.
+    dynlib: dllname, importc: "glColorTableParameterivSGI".}
+proc glColorTableParameterfvSGI*(target: TGLenum, pname: TGLenum, 
+                                 params: PGLfloat){.dynlib: dllname, 
+    importc: "glColorTableParameterfvSGI".}
+proc glGetColorTableSGI*(target: TGLenum, format: TGLenum, thetype: TGLenum, 
+                         table: PGLvoid){.dynlib: dllname, 
+    importc: "glGetColorTableSGI".}
+proc glGetColorTableParameterivSGI*(target: TGLenum, pname: TGLenum, 
+                                    params: PGLint){.dynlib: dllname, 
+    importc: "glGetColorTableParameterivSGI".}
+proc glGetColorTableParameterfvSGI*(target: TGLenum, pname: TGLenum, 
+                                    params: PGLfloat){.dynlib: dllname, 
+    importc: "glGetColorTableParameterfvSGI".}
+  #***** GL_SGI_texture_color_table *****//
+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, 
+    importc: "glColor4ubVertex2fSUN".}
+proc glColor4ubVertex2fvSUN*(c: PGLubyte, v: PGLfloat){.dynlib: dllname, 
+    importc: "glColor4ubVertex2fvSUN".}
+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, 
+    importc: "glColor4ubVertex3fvSUN".}
+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, 
+    importc: "glColor3fVertex3fvSUN".}
+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, 
+    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, 
+    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, 
+    importc: "glTexCoord2fVertex3fSUN".}
+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, 
+    importc: "glTexCoord4fVertex4fSUN".}
+proc glTexCoord4fVertex4fvSUN*(tc: PGLfloat, v: PGLfloat){.dynlib: dllname, 
+    importc: "glTexCoord4fVertex4fvSUN".}
+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, 
+    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, 
+                                      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, 
+    ny: TGLfloat, nz: TGLfloat, x: TGLfloat, y: TGLfloat, z: TGLfloat){.
+    dynlib: dllname, importc: "glTexCoord2fColor4fNormal3fVertex3fSUN".}
+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, 
+    importc: "glTexCoord4fColor4fNormal3fVertex4fSUN".}
+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, 
+    importc: "glReplacementCodeuiVertex3fSUN".}
+proc glReplacementCodeuiVertex3fvSUN*(rc: PGLuint, v: PGLfloat){.
+    dynlib: dllname, importc: "glReplacementCodeuiVertex3fvSUN".}
+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, 
+                  importc: "glReplacementCodeuiColor4ubVertex3fvSUN".}
+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, 
+                  importc: "glReplacementCodeuiColor3fVertex3fvSUN".}
+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, 
+                  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, 
+    importc: "glReplacementCodeuiColor4fNormal3fVertex3fSUN".}
+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, 
+    importc: "glReplacementCodeuiTexCoord2fVertex3fSUN".}
+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, 
+    y: TGLfloat, z: TGLfloat){.dynlib: dllname, importc: "glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN".}
+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, 
+    y: TGLfloat, z: TGLfloat){.dynlib: dllname, importc: "glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN".}
+proc glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN*(rc: PGLuint, 
+    tc: PGLfloat, c: PGLfloat, n: PGLfloat, v: PGLfloat){.dynlib: dllname, 
+    importc: "glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN".}
+  #***** GL_ARB_fragment_program *****//
+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 }
+                                        # GL_PROGRAM_BINDING_ARB  { already defined }
+                                        # GL_PROGRAM_INSTRUCTIONS_ARB  { already defined }
+                                        # GL_MAX_PROGRAM_INSTRUCTIONS_ARB  { already defined }
+                                        # GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB  { already defined }
+                                        # GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB  { already defined }
+                                        # GL_PROGRAM_TEMPORARIES_ARB  { already defined }
+                                        # GL_MAX_PROGRAM_TEMPORARIES_ARB  { already defined }
+                                        # GL_PROGRAM_NATIVE_TEMPORARIES_ARB  { already defined }
+                                        # GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB  { already defined }
+                                        # GL_PROGRAM_PARAMETERS_ARB  { already defined }
+                                        # GL_MAX_PROGRAM_PARAMETERS_ARB  { already defined }
+                                        # GL_PROGRAM_NATIVE_PARAMETERS_ARB  { already defined }
+                                        # GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB  { already defined }
+                                        # GL_PROGRAM_ATTRIBS_ARB  { already defined }
+                                        # GL_MAX_PROGRAM_ATTRIBS_ARB  { already defined }
+                                        # GL_PROGRAM_NATIVE_ATTRIBS_ARB  { already defined }
+                                        # GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB  { already defined }
+                                        # GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB  { already defined }
+                                        # GL_MAX_PROGRAM_ENV_PARAMETERS_ARB  { already defined }
+                                        # GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB  { already defined }
+  GL_PROGRAM_ALU_INSTRUCTIONS_ARB* = 0x00008805
+  GL_PROGRAM_TEX_INSTRUCTIONS_ARB* = 0x00008806
+  GL_PROGRAM_TEX_INDIRECTIONS_ARB* = 0x00008807
+  GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB* = 0x00008808
+  GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB* = 0x00008809
+  GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB* = 0x0000880A
+  GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB* = 0x0000880B
+  GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB* = 0x0000880C
+  GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB* = 0x0000880D
+  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 }
+                                               # GL_MATRIX0_ARB  { already defined }
+                                               # GL_MATRIX1_ARB  { already defined }
+                                               # GL_MATRIX2_ARB  { already defined }
+                                               # GL_MATRIX3_ARB  { already defined }
+                                               # GL_MATRIX4_ARB  { already defined }
+                                               # GL_MATRIX5_ARB  { already defined }
+                                               # GL_MATRIX6_ARB  { already defined }
+                                               # GL_MATRIX7_ARB  { already defined }
+                                               # GL_MATRIX8_ARB  { already defined }
+                                               # GL_MATRIX9_ARB  { already defined }
+                                               # GL_MATRIX10_ARB  { already defined }
+                                               # GL_MATRIX11_ARB  { already defined }
+                                               # GL_MATRIX12_ARB  { already defined }
+                                               # GL_MATRIX13_ARB  { already defined }
+                                               # GL_MATRIX14_ARB  { already defined }
+                                               # GL_MATRIX15_ARB  { already defined }
+                                               # GL_MATRIX16_ARB  { already defined }
+                                               # GL_MATRIX17_ARB  { already defined }
+                                               # GL_MATRIX18_ARB  { already defined }
+                                               # GL_MATRIX19_ARB  { already defined }
+                                               # GL_MATRIX20_ARB  { already defined }
+                                               # GL_MATRIX21_ARB  { already defined }
+                                               # GL_MATRIX22_ARB  { already defined }
+                                               # GL_MATRIX23_ARB  { already defined }
+                                               # GL_MATRIX24_ARB  { already defined }
+                                               # GL_MATRIX25_ARB  { already defined }
+                                               # GL_MATRIX26_ARB  { already defined }
+                                               # GL_MATRIX27_ARB  { already defined }
+                                               # GL_MATRIX28_ARB  { already defined }
+                                               # GL_MATRIX29_ARB  { already defined }
+                                               # GL_MATRIX30_ARB  { already defined }
+                                               # GL_MATRIX31_ARB  { already defined }
+                                               # glProgramStringARB  { already defined }
+                                               # glBindProgramARB  { already defined }
+                                               # glDeleteProgramsARB  { already defined }
+                                               # glGenProgramsARB  { already defined }
+                                               # glProgramEnvParameter4dARB  { already defined }
+                                               # glProgramEnvParameter4dvARB  { already defined }
+                                               # glProgramEnvParameter4fARB  { already defined }
+                                               # glProgramEnvParameter4fvARB  { already defined }
+                                               # glProgramLocalParameter4dARB  { already defined }
+                                               # glProgramLocalParameter4dvARB  { already defined }
+                                               # glProgramLocalParameter4fARB  { already defined }
+                                               # glProgramLocalParameter4fvARB  { already defined }
+                                               # glGetProgramEnvParameterdvARB  { already defined }
+                                               # glGetProgramEnvParameterfvARB  { already defined }
+                                               # glGetProgramLocalParameterdvARB  { already defined }
+                                               # glGetProgramLocalParameterfvARB  { already defined }
+                                               # glGetProgramivARB  { already defined }
+                                               # glGetProgramStringARB  { already defined }
+                                               # glIsProgramARB  { already defined }
+  #***** GL_ATI_text_fragment_shader *****
+
+const 
+  GL_TEXT_FRAGMENT_SHADER_ATI* = 0x00008200 #***** GL_ARB_vertex_buffer_object *****
+
+const 
+  GL_BUFFER_SIZE_ARB* = 0x00008764
+  GL_BUFFER_USAGE_ARB* = 0x00008765
+  GL_ARRAY_BUFFER_ARB* = 0x00008892
+  GL_ELEMENT_ARRAY_BUFFER_ARB* = 0x00008893
+  GL_ARRAY_BUFFER_BINDING_ARB* = 0x00008894
+  GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB* = 0x00008895
+  GL_VERTEX_ARRAY_BUFFER_BINDING_ARB* = 0x00008896
+  GL_NORMAL_ARRAY_BUFFER_BINDING_ARB* = 0x00008897
+  GL_COLOR_ARRAY_BUFFER_BINDING_ARB* = 0x00008898
+  GL_INDEX_ARRAY_BUFFER_BINDING_ARB* = 0x00008899
+  GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB* = 0x0000889A
+  GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB* = 0x0000889B
+  GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB* = 0x0000889C
+  GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB* = 0x0000889D
+  GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB* = 0x0000889E
+  GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB* = 0x0000889F
+  GL_READ_ONLY_ARB* = 0x000088B8
+  GL_WRITE_ONLY_ARB* = 0x000088B9
+  GL_READ_WRITE_ARB* = 0x000088BA
+  GL_BUFFER_ACCESS_ARB* = 0x000088BB
+  GL_BUFFER_MAPPED_ARB* = 0x000088BC
+  GL_BUFFER_MAP_POINTER_ARB* = 0x000088BD
+  GL_STREAM_DRAW_ARB* = 0x000088E0
+  GL_STREAM_READ_ARB* = 0x000088E1
+  GL_STREAM_COPY_ARB* = 0x000088E2
+  GL_STATIC_DRAW_ARB* = 0x000088E4
+  GL_STATIC_READ_ARB* = 0x000088E5
+  GL_STATIC_COPY_ARB* = 0x000088E6
+  GL_DYNAMIC_DRAW_ARB* = 0x000088E8
+  GL_DYNAMIC_READ_ARB* = 0x000088E9
+  GL_DYNAMIC_COPY_ARB* = 0x000088EA
+
+proc glBindBufferARB*(target: TGLenum, buffer: TGLuint){.dynlib: dllname, 
+    importc: "glBindBufferARB".}
+proc glDeleteBuffersARB*(n: TGLsizei, buffers: PGLuint){.dynlib: dllname, 
+    importc: "glDeleteBuffersARB".}
+proc glGenBuffersARB*(n: TGLsizei, buffers: PGLuint){.dynlib: dllname, 
+    importc: "glGenBuffersARB".}
+proc glIsBufferARB*(buffer: TGLuint): TGLboolean{.dynlib: dllname, 
+    importc: "glIsBufferARB".}
+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, 
+    importc: "glBufferSubDataARB".}
+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, 
+    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 
+  GL_UNPACK_CLIENT_STORAGE_APPLE* = 0x000085B2
+  #***** GL_APPLE_element_array *****//
+
+const 
+  GL_ELEMENT_ARRAY_APPLE* = 0x00008768
+  GL_ELEMENT_ARRAY_TYPE_APPLE* = 0x00008769
+  GL_ELEMENT_ARRAY_POINTER_APPLE* = 0x0000876A
+
+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, 
+    importc: "glDrawRangeElementArrayAPPLE".}
+proc glMultiDrawElementArrayAPPLE*(mode: TGLenum, first: PGLint, 
+                                   count: PGLsizei, primcount: TGLsizei){.
+    dynlib: dllname, importc: "glMultiDrawElementArrayAPPLE".}
+proc glMultiDrawRangeElementArrayAPPLE*(mode: TGLenum, start: TGLuint, 
+                                        theend: TGLuint, first: PGLint, 
+                                        count: PGLsizei, primcount: TGLsizei){.
+    dynlib: dllname, importc: "glMultiDrawRangeElementArrayAPPLE".}
+  #***** GL_APPLE_fence *****//
+const 
+  GL_DRAW_PIXELS_APPLE* = 0x00008A0A
+  GL_FENCE_APPLE* = 0x00008A0B
+
+proc glGenFencesAPPLE*(n: TGLsizei, fences: PGLuint){.dynlib: dllname, 
+    importc: "glGenFencesAPPLE".}
+proc glDeleteFencesAPPLE*(n: TGLsizei, fences: PGLuint){.dynlib: dllname, 
+    importc: "glDeleteFencesAPPLE".}
+proc glSetFenceAPPLE*(fence: TGLuint){.dynlib: dllname, 
+                                       importc: "glSetFenceAPPLE".}
+proc glIsFenceAPPLE*(fence: TGLuint): TGLboolean{.dynlib: dllname, 
+    importc: "glIsFenceAPPLE".}
+proc glTestFenceAPPLE*(fence: TGLuint): TGLboolean{.dynlib: dllname, 
+    importc: "glTestFenceAPPLE".}
+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, 
+    importc: "glFinishObjectAPPLE".}
+  #***** GL_APPLE_vertex_array_object *****//
+const 
+  GL_VERTEX_ARRAY_BINDING_APPLE* = 0x000085B5
+
+proc glBindVertexArrayAPPLE*(thearray: TGLuint){.dynlib: dllname, 
+    importc: "glBindVertexArrayAPPLE".}
+proc glDeleteVertexArraysAPPLE*(n: TGLsizei, arrays: PGLuint){.dynlib: dllname, 
+    importc: "glDeleteVertexArraysAPPLE".}
+proc glGenVertexArraysAPPLE*(n: TGLsizei, arrays: PGLuint){.dynlib: dllname, 
+    importc: "glGenVertexArraysAPPLE".}
+proc glIsVertexArrayAPPLE*(thearray: TGLuint): TGLboolean{.dynlib: dllname, 
+    importc: "glIsVertexArrayAPPLE".}
+  #***** GL_APPLE_vertex_array_range *****//
+const 
+  constGL_VERTEX_ARRAY_RANGE_APPLE* = 0x0000851D
+  GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE* = 0x0000851E
+  GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_APPLE* = 0x00008520
+  GL_VERTEX_ARRAY_RANGE_POINTER_APPLE* = 0x00008521
+  GL_VERTEX_ARRAY_STORAGE_HINT_APPLE* = 0x0000851F
+  GL_STORAGE_CACHED_APPLE* = 0x000085BE
+  GL_STORAGE_SHARED_APPLE* = 0x000085BF
+
+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 
+  GL_MATRIX_PALETTE_ARB* = 0x00008840
+  GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB* = 0x00008841
+  GL_MAX_PALETTE_MATRICES_ARB* = 0x00008842
+  constGL_CURRENT_PALETTE_MATRIX_ARB* = 0x00008843
+  GL_MATRIX_INDEX_ARRAY_ARB* = 0x00008844
+  GL_CURRENT_MATRIX_INDEX_ARB* = 0x00008845
+  GL_MATRIX_INDEX_ARRAY_SIZE_ARB* = 0x00008846
+  GL_MATRIX_INDEX_ARRAY_TYPE_ARB* = 0x00008847
+  GL_MATRIX_INDEX_ARRAY_STRIDE_ARB* = 0x00008848
+  GL_MATRIX_INDEX_ARRAY_POINTER_ARB* = 0x00008849
+
+proc glCurrentPaletteMatrixARB*(index: TGLint){.dynlib: dllname, 
+    importc: "glCurrentPaletteMatrixARB".}
+proc glMatrixIndexubvARB*(size: TGLint, indices: PGLubyte){.dynlib: dllname, 
+    importc: "glMatrixIndexubvARB".}
+proc glMatrixIndexusvARB*(size: TGLint, indices: PGLushort){.dynlib: dllname, 
+    importc: "glMatrixIndexusvARB".}
+proc glMatrixIndexuivARB*(size: TGLint, indices: PGLuint){.dynlib: dllname, 
+    importc: "glMatrixIndexuivARB".}
+proc glMatrixIndexPointerARB*(size: TGLint, thetype: TGLenum, stride: TGLsizei, 
+                              pointer: PGLvoid){.dynlib: dllname, 
+    importc: "glMatrixIndexPointerARB".}
+  #***** GL_NV_element_array *****//
+const 
+  GL_ELEMENT_ARRAY_TYPE_NV* = 0x00008769
+  GL_ELEMENT_ARRAY_POINTER_NV* = 0x0000876A
+
+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, 
+                                first: TGLint, count: TGLsizei){.
+    dynlib: dllname, importc: "glDrawRangeElementArrayNV".}
+proc glMultiDrawElementArrayNV*(mode: TGLenum, first: PGLint, count: PGLsizei, 
+                                primcount: TGLsizei){.dynlib: dllname, 
+    importc: "glMultiDrawElementArrayNV".}
+proc glMultiDrawRangeElementArrayNV*(mode: TGLenum, start: TGLuint, 
+                                     theend: TGLuint, first: PGLint, 
+                                     count: PGLsizei, primcount: TGLsizei){.
+    dynlib: dllname, importc: "glMultiDrawRangeElementArrayNV".}
+  #***** GL_NV_float_buffer *****//
+const 
+  GL_FLOAT_R_NV* = 0x00008880
+  GL_FLOAT_RG_NV* = 0x00008881
+  GL_FLOAT_RGB_NV* = 0x00008882
+  GL_FLOAT_RGBA_NV* = 0x00008883
+  GL_FLOAT_R16_NV* = 0x00008884
+  GL_FLOAT_R32_NV* = 0x00008885
+  GL_FLOAT_RG16_NV* = 0x00008886
+  GL_FLOAT_RG32_NV* = 0x00008887
+  GL_FLOAT_RGB16_NV* = 0x00008888
+  GL_FLOAT_RGB32_NV* = 0x00008889
+  GL_FLOAT_RGBA16_NV* = 0x0000888A
+  GL_FLOAT_RGBA32_NV* = 0x0000888B
+  GL_TEXTURE_FLOAT_COMPONENTS_NV* = 0x0000888C
+  GL_FLOAT_CLEAR_COLOR_VALUE_NV* = 0x0000888D
+  GL_FLOAT_RGBA_MODE_NV* = 0x0000888E
+  #***** GL_NV_fragment_program *****//
+
+const 
+  GL_FRAGMENT_PROGRAM_NV* = 0x00008870
+  GL_MAX_TEXTURE_COORDS_NV* = 0x00008871
+  GL_MAX_TEXTURE_IMAGE_UNITS_NV* = 0x00008872
+  GL_FRAGMENT_PROGRAM_BINDING_NV* = 0x00008873
+  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, 
+    importc: "glProgramNamedParameter4fNV".}
+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, 
+                                     name: PGLubyte, params: PGLfloat){.
+    dynlib: dllname, importc: "glGetProgramNamedParameterfvNV".}
+proc glGetProgramNamedParameterdvNV*(id: TGLuint, length: TGLsizei, 
+                                     name: PGLubyte, params: PGLdouble){.
+    dynlib: dllname, importc: "glGetProgramNamedParameterdvNV".}
+  # glProgramLocalParameter4dARB  { already defined }
+  # glProgramLocalParameter4dvARB  { already defined }
+  # glProgramLocalParameter4fARB  { already defined }
+  # glProgramLocalParameter4fvARB  { already defined }
+  # glGetProgramLocalParameterdvARB  { already defined }
+  # glGetProgramLocalParameterfvARB  { already defined }
+  #***** GL_NV_primitive_restart *****//
+const 
+  constGL_PRIMITIVE_RESTART_NV* = 0x00008558
+  constGL_PRIMITIVE_RESTART_INDEX_NV* = 0x00008559
+
+proc glPrimitiveRestartNV*(){.dynlib: dllname, importc: "glPrimitiveRestartNV".}
+proc glPrimitiveRestartIndexNV*(index: TGLuint){.dynlib: dllname, 
+    importc: "glPrimitiveRestartIndexNV".}
+  #***** GL_NV_vertex_program2 *****//
+  #***** GL_NV_pixel_data_range *****//
+const 
+  GL_WRITE_PIXEL_DATA_RANGE_NV* = 0x00008878
+  GL_READ_PIXEL_DATA_RANGE_NV* = 0x00008879
+  GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV* = 0x0000887A
+  GL_READ_PIXEL_DATA_RANGE_LENGTH_NV* = 0x0000887B
+  GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV* = 0x0000887C
+  GL_READ_PIXEL_DATA_RANGE_POINTER_NV* = 0x0000887D
+
+proc glPixelDataRangeNV*(target: TGLenum, len: TGLsizei, pointer: PGLvoid){.
+    dynlib: dllname, importc: "glPixelDataRangeNV".}
+proc glFlushPixelDataRangeNV*(target: TGLenum){.dynlib: dllname, 
+    importc: "glFlushPixelDataRangeNV".}
+  # wglAllocateMemoryNV  { already defined }
+  # wglFreeMemoryNV  { already defined }
+  #***** GL_EXT_texture_rectangle *****//
+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 
+  GL_RGB_S3TC* = 0x000083A0
+  GL_RGB4_S3TC* = 0x000083A1
+  GL_RGBA_S3TC* = 0x000083A2
+  GL_RGBA4_S3TC* = 0x000083A3
+  #***** GL_ATI_draw_buffers *****//
+
+const 
+  GL_MAX_DRAW_BUFFERS_ATI* = 0x00008824
+  GL_DRAW_BUFFER0_ATI* = 0x00008825
+  GL_DRAW_BUFFER1_ATI* = 0x00008826
+  GL_DRAW_BUFFER2_ATI* = 0x00008827
+  GL_DRAW_BUFFER3_ATI* = 0x00008828
+  GL_DRAW_BUFFER4_ATI* = 0x00008829
+  GL_DRAW_BUFFER5_ATI* = 0x0000882A
+  GL_DRAW_BUFFER6_ATI* = 0x0000882B
+  GL_DRAW_BUFFER7_ATI* = 0x0000882C
+  GL_DRAW_BUFFER8_ATI* = 0x0000882D
+  GL_DRAW_BUFFER9_ATI* = 0x0000882E
+  GL_DRAW_BUFFER10_ATI* = 0x0000882F
+  GL_DRAW_BUFFER11_ATI* = 0x00008830
+  GL_DRAW_BUFFER12_ATI* = 0x00008831
+  GL_DRAW_BUFFER13_ATI* = 0x00008832
+  GL_DRAW_BUFFER14_ATI* = 0x00008833
+  GL_DRAW_BUFFER15_ATI* = 0x00008834
+
+proc glDrawBuffersATI*(n: TGLsizei, bufs: PGLenum){.dynlib: dllname, 
+    importc: "glDrawBuffersATI".}
+  #***** GL_ATI_texture_env_combine3 *****//
+const 
+  GL_MODULATE_ADD_ATI* = 0x00008744
+  GL_MODULATE_SIGNED_ADD_ATI* = 0x00008745
+  GL_MODULATE_SUBTRACT_ATI* = 0x00008746
+  #***** GL_ATI_texture_float *****//
+
+const 
+  GL_RGBA_FLOAT32_ATI* = 0x00008814
+  GL_RGB_FLOAT32_ATI* = 0x00008815
+  GL_ALPHA_FLOAT32_ATI* = 0x00008816
+  GL_INTENSITY_FLOAT32_ATI* = 0x00008817
+  GL_LUMINANCE_FLOAT32_ATI* = 0x00008818
+  GL_LUMINANCE_ALPHA_FLOAT32_ATI* = 0x00008819
+  GL_RGBA_FLOAT16_ATI* = 0x0000881A
+  GL_RGB_FLOAT16_ATI* = 0x0000881B
+  GL_ALPHA_FLOAT16_ATI* = 0x0000881C
+  GL_INTENSITY_FLOAT16_ATI* = 0x0000881D
+  GL_LUMINANCE_FLOAT16_ATI* = 0x0000881E
+  GL_LUMINANCE_ALPHA_FLOAT16_ATI* = 0x0000881F
+  #***** GL_NV_texture_expand_normal *****//
+
+const 
+  GL_TEXTURE_UNSIGNED_REMAP_MODE_NV* = 0x0000888F
+  #***** GL_NV_half_float *****//
+
+const 
+  GL_HALF_FLOAT_NV* = 0x0000140B
+
+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, 
+    importc: "glVertex3hNV".}
+proc glVertex3hvNV*(v: PGLushort){.dynlib: dllname, importc: "glVertex3hvNV".}
+proc glVertex4hNV*(x: TGLushort, y: TGLushort, z: TGLushort, w: TGLushort){.
+    dynlib: dllname, importc: "glVertex4hNV".}
+proc glVertex4hvNV*(v: PGLushort){.dynlib: dllname, importc: "glVertex4hvNV".}
+proc glNormal3hNV*(nx: TGLushort, ny: TGLushort, nz: TGLushort){.
+    dynlib: dllname, importc: "glNormal3hNV".}
+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, 
+                  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, 
+    importc: "glTexCoord2hNV".}
+proc glTexCoord2hvNV*(v: PGLushort){.dynlib: dllname, importc: "glTexCoord2hvNV".}
+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, 
+    importc: "glMultiTexCoord1hNV".}
+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, 
+    importc: "glMultiTexCoord2hvNV".}
+proc glMultiTexCoord3hNV*(target: TGLenum, s: TGLushort, t: TGLushort, 
+                          r: TGLushort){.dynlib: dllname, 
+    importc: "glMultiTexCoord3hNV".}
+proc glMultiTexCoord3hvNV*(target: TGLenum, v: PGLushort){.dynlib: dllname, 
+    importc: "glMultiTexCoord3hvNV".}
+proc glMultiTexCoord4hNV*(target: TGLenum, s: TGLushort, t: TGLushort, 
+                          r: TGLushort, q: TGLushort){.dynlib: dllname, 
+    importc: "glMultiTexCoord4hNV".}
+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, 
+    importc: "glSecondaryColor3hvNV".}
+proc glVertexWeighthNV*(weight: TGLushort){.dynlib: dllname, 
+    importc: "glVertexWeighthNV".}
+proc glVertexWeighthvNV*(weight: PGLushort){.dynlib: dllname, 
+    importc: "glVertexWeighthvNV".}
+proc glVertexAttrib1hNV*(index: TGLuint, x: TGLushort){.dynlib: dllname, 
+    importc: "glVertexAttrib1hNV".}
+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, 
+    importc: "glVertexAttrib2hvNV".}
+proc glVertexAttrib3hNV*(index: TGLuint, x: TGLushort, y: TGLushort, 
+                         z: TGLushort){.dynlib: dllname, 
+                                        importc: "glVertexAttrib3hNV".}
+proc glVertexAttrib3hvNV*(index: TGLuint, v: PGLushort){.dynlib: dllname, 
+    importc: "glVertexAttrib3hvNV".}
+proc glVertexAttrib4hNV*(index: TGLuint, x: TGLushort, y: TGLushort, 
+                         z: TGLushort, w: TGLushort){.dynlib: dllname, 
+    importc: "glVertexAttrib4hNV".}
+proc glVertexAttrib4hvNV*(index: TGLuint, v: PGLushort){.dynlib: dllname, 
+    importc: "glVertexAttrib4hvNV".}
+proc glVertexAttribs1hvNV*(index: TGLuint, n: TGLsizei, v: PGLushort){.
+    dynlib: dllname, importc: "glVertexAttribs1hvNV".}
+proc glVertexAttribs2hvNV*(index: TGLuint, n: TGLsizei, v: PGLushort){.
+    dynlib: dllname, importc: "glVertexAttribs2hvNV".}
+proc glVertexAttribs3hvNV*(index: TGLuint, n: TGLsizei, v: PGLushort){.
+    dynlib: dllname, importc: "glVertexAttribs3hvNV".}
+proc glVertexAttribs4hvNV*(index: TGLuint, n: TGLsizei, v: PGLushort){.
+    dynlib: dllname, importc: "glVertexAttribs4hvNV".}
+  #***** GL_ATI_map_object_buffer *****//
+proc glMapObjectBufferATI*(buffer: TGLuint): PGLvoid{.dynlib: dllname, 
+    importc: "glMapObjectBufferATI".}
+proc glUnmapObjectBufferATI*(buffer: TGLuint){.dynlib: dllname, 
+    importc: "glUnmapObjectBufferATI".}
+  #***** GL_ATI_separate_stencil *****//
+const 
+  GL_KEEP* = 0x00001E00
+  GL_ZERO* = 0x00000000
+  GL_REPLACE* = 0x00001E01
+  GL_INCR* = 0x00001E02
+  GL_DECR* = 0x00001E03
+  GL_INVERT* = 0x0000150A
+  GL_NEVER* = 0x00000200
+  GL_LESS* = 0x00000201
+  GL_LEQUAL* = 0x00000203
+  GL_GREATER* = 0x00000204
+  GL_GEQUAL* = 0x00000206
+  GL_EQUAL* = 0x00000202
+  GL_NOTEQUAL* = 0x00000205
+  GL_ALWAYS* = 0x00000207
+  GL_FRONT* = 0x00000404
+  GL_BACK* = 0x00000405
+  GL_FRONT_AND_BACK* = 0x00000408
+  GL_STENCIL_BACK_FUNC_ATI* = 0x00008800
+  GL_STENCIL_BACK_FAIL_ATI* = 0x00008801
+  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, 
+    importc: "glStencilOpSeparateATI".}
+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, 
+    importc: "glVertexAttribArrayObjectATI".}
+proc glGetVertexAttribArrayObjectfvATI*(index: TGLuint, pname: TGLenum, 
+                                        params: PGLfloat){.dynlib: dllname, 
+    importc: "glGetVertexAttribArrayObjectfvATI".}
+proc glGetVertexAttribArrayObjectivATI*(index: TGLuint, pname: TGLenum, 
+                                        params: PGLint){.dynlib: dllname, 
+    importc: "glGetVertexAttribArrayObjectivATI".}
+  #***** GL_ARB_occlusion_query *****//
+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, 
+    importc: "glGenQueriesARB".}
+proc glDeleteQueriesARB*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, 
+    importc: "glDeleteQueriesARB".}
+proc glIsQueryARB*(id: TGLuint): TGLboolean{.dynlib: dllname, 
+    importc: "glIsQueryARB".}
+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){.
+    dynlib: dllname, importc: "glGetQueryivARB".}
+proc glGetQueryObjectivARB*(id: TGLuint, pname: TGLenum, params: PGLint){.
+    dynlib: dllname, importc: "glGetQueryObjectivARB".}
+proc glGetQueryObjectuivARB*(id: TGLuint, pname: TGLenum, params: PGLuint){.
+    dynlib: dllname, importc: "glGetQueryObjectuivARB".}
+  #***** GL_ARB_shader_objects *****//
+const 
+  GL_PROGRAM_OBJECT_ARB* = 0x00008B40
+  GL_OBJECT_TYPE_ARB* = 0x00008B4E
+  GL_OBJECT_SUBTYPE_ARB* = 0x00008B4F
+  GL_OBJECT_DELETE_STATUS_ARB* = 0x00008B80
+  GL_OBJECT_COMPILE_STATUS_ARB* = 0x00008B81
+  GL_OBJECT_LINK_STATUS_ARB* = 0x00008B82
+  GL_OBJECT_VALIDATE_STATUS_ARB* = 0x00008B83
+  GL_OBJECT_INFO_LOG_LENGTH_ARB* = 0x00008B84
+  GL_OBJECT_ATTACHED_OBJECTS_ARB* = 0x00008B85
+  GL_OBJECT_ACTIVE_UNIFORMS_ARB* = 0x00008B86
+  GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB* = 0x00008B87
+  GL_OBJECT_SHADER_SOURCE_LENGTH_ARB* = 0x00008B88
+  GL_SHADER_OBJECT_ARB* = 0x00008B48
+  GL_FLOAT* = 0x00001406
+  GL_FLOAT_VEC2_ARB* = 0x00008B50
+  GL_FLOAT_VEC3_ARB* = 0x00008B51
+  GL_FLOAT_VEC4_ARB* = 0x00008B52
+  GL_INT* = 0x00001404
+  GL_INT_VEC2_ARB* = 0x00008B53
+  GL_INT_VEC3_ARB* = 0x00008B54
+  GL_INT_VEC4_ARB* = 0x00008B55
+  GL_BOOL_ARB* = 0x00008B56
+  GL_BOOL_VEC2_ARB* = 0x00008B57
+  GL_BOOL_VEC3_ARB* = 0x00008B58
+  GL_BOOL_VEC4_ARB* = 0x00008B59
+  GL_FLOAT_MAT2_ARB* = 0x00008B5A
+  GL_FLOAT_MAT3_ARB* = 0x00008B5B
+  GL_FLOAT_MAT4_ARB* = 0x00008B5C
+
+proc glDeleteObjectARB*(obj: GLhandleARB){.dynlib: dllname, 
+    importc: "glDeleteObjectARB".}
+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, 
+                                      importc: "glShaderSourceARB".}
+proc glCompileShaderARB*(shaderObj: GLhandleARB){.dynlib: dllname, 
+    importc: "glCompileShaderARB".}
+proc glCreateProgramObjectARB*(): GLhandleARB{.dynlib: dllname, 
+    importc: "glCreateProgramObjectARB".}
+proc glAttachObjectARB*(containerObj: GLhandleARB, obj: GLhandleARB){.
+    dynlib: dllname, importc: "glAttachObjectARB".}
+proc glLinkProgramARB*(programObj: GLhandleARB){.dynlib: dllname, 
+    importc: "glLinkProgramARB".}
+proc glUseProgramObjectARB*(programObj: GLhandleARB){.dynlib: dllname, 
+    importc: "glUseProgramObjectARB".}
+proc glValidateProgramARB*(programObj: GLhandleARB){.dynlib: dllname, 
+    importc: "glValidateProgramARB".}
+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, 
+                     v3: TGLfloat){.dynlib: dllname, importc: "glUniform4fARB".}
+proc glUniform1iARB*(location: TGLint, v0: TGLint){.dynlib: dllname, 
+    importc: "glUniform1iARB".}
+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, 
+                     v3: TGLint){.dynlib: dllname, importc: "glUniform4iARB".}
+proc glUniform1fvARB*(location: TGLint, count: TGLsizei, value: PGLfloat){.
+    dynlib: dllname, importc: "glUniform1fvARB".}
+proc glUniform2fvARB*(location: TGLint, count: TGLsizei, value: PGLfloat){.
+    dynlib: dllname, importc: "glUniform2fvARB".}
+proc glUniform3fvARB*(location: TGLint, count: TGLsizei, value: PGLfloat){.
+    dynlib: dllname, importc: "glUniform3fvARB".}
+proc glUniform4fvARB*(location: TGLint, count: TGLsizei, value: PGLfloat){.
+    dynlib: dllname, importc: "glUniform4fvARB".}
+proc glUniform1ivARB*(location: TGLint, count: TGLsizei, value: PGLint){.
+    dynlib: dllname, importc: "glUniform1ivARB".}
+proc glUniform2ivARB*(location: TGLint, count: TGLsizei, value: PGLint){.
+    dynlib: dllname, importc: "glUniform2ivARB".}
+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, 
+                            transpose: TGLboolean, value: PGLfloat){.
+    dynlib: dllname, importc: "glUniformMatrix2fvARB".}
+proc glUniformMatrix3fvARB*(location: TGLint, count: TGLsizei, 
+                            transpose: TGLboolean, value: PGLfloat){.
+    dynlib: dllname, importc: "glUniformMatrix3fvARB".}
+proc glUniformMatrix4fvARB*(location: TGLint, count: TGLsizei, 
+                            transpose: TGLboolean, value: PGLfloat){.
+    dynlib: dllname, importc: "glUniformMatrix4fvARB".}
+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, 
+    importc: "glGetInfoLogARB".}
+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, 
+                            thetype: PGLenum, name: PGLcharARB){.
+    dynlib: dllname, importc: "glGetActiveUniformARB".}
+proc glGetUniformfvARB*(programObj: GLhandleARB, location: TGLint, 
+                        params: PGLfloat){.dynlib: dllname, 
+    importc: "glGetUniformfvARB".}
+proc glGetUniformivARB*(programObj: GLhandleARB, location: TGLint, 
+                        params: PGLint){.dynlib: dllname, 
+    importc: "glGetUniformivARB".}
+proc glGetShaderSourceARB*(obj: GLhandleARB, maxLength: TGLsizei, len: PGLsizei, 
+                           source: PGLcharARB){.dynlib: dllname, 
+    importc: "glGetShaderSourceARB".}
+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_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 }
+                                                          # GL_FLOAT_VEC3_ARB  { already defined }
+                                                          # GL_FLOAT_VEC4_ARB  { already defined }
+                                                          # GL_FLOAT_MAT2_ARB  { already defined }
+                                                          # GL_FLOAT_MAT3_ARB  { already defined }
+                                                          # GL_FLOAT_MAT4_ARB  { already defined }
+                                                          # glVertexAttrib1fARB  { already defined }
+                                                          # glVertexAttrib1sARB  { already defined }
+                                                          # glVertexAttrib1dARB  { already defined }
+                                                          # glVertexAttrib2fARB  { already defined }
+                                                          # glVertexAttrib2sARB  { already defined }
+                                                          # glVertexAttrib2dARB  { already defined }
+                                                          # glVertexAttrib3fARB  { already defined }
+                                                          # glVertexAttrib3sARB  { already defined }
+                                                          # glVertexAttrib3dARB  { already defined }
+                                                          # glVertexAttrib4fARB  { already defined }
+                                                          # glVertexAttrib4sARB  { already defined }
+                                                          # glVertexAttrib4dARB  { already defined }
+                                                          # glVertexAttrib4NubARB  { already defined }
+                                                          # glVertexAttrib1fvARB  { already defined }
+                                                          # glVertexAttrib1svARB  { already defined }
+                                                          # glVertexAttrib1dvARB  { already defined }
+                                                          # glVertexAttrib2fvARB  { already defined }
+                                                          # glVertexAttrib2svARB  { already defined }
+                                                          # glVertexAttrib2dvARB  { already defined }
+                                                          # glVertexAttrib3fvARB  { already defined }
+                                                          # glVertexAttrib3svARB  { already defined }
+                                                          # glVertexAttrib3dvARB  { already defined }
+                                                          # glVertexAttrib4fvARB  { already defined }
+                                                          # glVertexAttrib4svARB  { already defined }
+                                                          # glVertexAttrib4dvARB  { already defined }
+                                                          # glVertexAttrib4ivARB  { already defined }
+                                                          # glVertexAttrib4bvARB  { already defined }
+                                                          # glVertexAttrib4ubvARB  { already defined }
+                                                          # glVertexAttrib4usvARB  { already defined }
+                                                          # glVertexAttrib4uivARB  { already defined }
+                                                          # glVertexAttrib4NbvARB  { already defined }
+                                                          # glVertexAttrib4NsvARB  { already defined }
+                                                          # glVertexAttrib4NivARB  { already defined }
+                                                          # 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, 
+    importc: "glBindAttribLocationARB".}
+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".}
+  # glGetVertexAttribdvARB  { already defined }
+  # glGetVertexAttribfvARB  { already defined }
+  # glGetVertexAttribivARB  { already defined }
+  # glGetVertexAttribPointervARB  { already defined }
+  #***** GL_ARB_fragment_shader *****//
+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 }
+                                                       # GL_SHADER_OBJECT_ARB  { already defined }
+  #***** GL_ARB_shading_language_100 *****//
+  #***** GL_ARB_texture_non_power_of_two *****//
+  #***** GL_ARB_point_sprite *****//
+
+const 
+  GL_POINT_SPRITE_ARB* = 0x00008861
+  GL_COORD_REPLACE_ARB* = 0x00008862
+  #***** GL_EXT_depth_bounds_test *****//
+
+const 
+  constGL_DEPTH_BOUNDS_TEST_EXT* = 0x00008890
+  constGL_DEPTH_BOUNDS_EXT* = 0x00008891
+
+proc glDepthBoundsEXT*(zmin: TGLclampd, zmax: TGLclampd){.dynlib: dllname, 
+    importc: "glDepthBoundsEXT".}
+  #***** GL_EXT_texture_mirror_clamp *****//
+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 
+  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 
+  GL_PACK_INVERT_MESA* = 0x00008758
+  #***** GL_MESA_ycbcr_texture *****//
+
+const 
+  GL_YCBCR_MESA* = 0x00008757
+  GL_UNSIGNED_SHORT_8_8_MESA* = 0x000085BA
+  GL_UNSIGNED_SHORT_8_8_REV_MESA* = 0x000085BB
+  #***** GL_ARB_fragment_program_shadow *****//
+  #***** GL_NV_fragment_program_option *****//
+  #***** GL_EXT_pixel_buffer_object *****//
+
+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 
+  GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV* = 0x000088F4
+  GL_MAX_PROGRAM_CALL_DEPTH_NV* = 0x000088F5
+  GL_MAX_PROGRAM_IF_DEPTH_NV* = 0x000088F6
+  GL_MAX_PROGRAM_LOOP_DEPTH_NV* = 0x000088F7
+  GL_MAX_PROGRAM_LOOP_COUNT_NV* = 0x000088F8
+  #***** GL_NV_vertex_program2_option *****//
+  # GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV  { already defined }
+  # GL_MAX_PROGRAM_CALL_DEPTH_NV  { already defined }
+  #***** GL_NV_vertex_program3 *****//
+  # GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB  { already defined }
+  #***** GL_ARB_draw_buffers *****//
+
+const 
+  GL_MAX_DRAW_BUFFERS_ARB* = 0x00008824
+  GL_DRAW_BUFFER0_ARB* = 0x00008825
+  GL_DRAW_BUFFER1_ARB* = 0x00008826
+  GL_DRAW_BUFFER2_ARB* = 0x00008827
+  GL_DRAW_BUFFER3_ARB* = 0x00008828
+  GL_DRAW_BUFFER4_ARB* = 0x00008829
+  GL_DRAW_BUFFER5_ARB* = 0x0000882A
+  GL_DRAW_BUFFER6_ARB* = 0x0000882B
+  GL_DRAW_BUFFER7_ARB* = 0x0000882C
+  GL_DRAW_BUFFER8_ARB* = 0x0000882D
+  GL_DRAW_BUFFER9_ARB* = 0x0000882E
+  GL_DRAW_BUFFER10_ARB* = 0x0000882F
+  GL_DRAW_BUFFER11_ARB* = 0x00008830
+  GL_DRAW_BUFFER12_ARB* = 0x00008831
+  GL_DRAW_BUFFER13_ARB* = 0x00008832
+  GL_DRAW_BUFFER14_ARB* = 0x00008833
+  GL_DRAW_BUFFER15_ARB* = 0x00008834
+
+proc glDrawBuffersARB*(n: TGLsizei, bufs: PGLenum){.dynlib: dllname, 
+    importc: "glDrawBuffersARB".}
+  #***** GL_ARB_texture_rectangle *****//
+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 
+  GL_RGBA_FLOAT_MODE_ARB* = 0x00008820
+  GL_CLAMP_VERTEX_COLOR_ARB* = 0x0000891A
+  GL_CLAMP_FRAGMENT_COLOR_ARB* = 0x0000891B
+  GL_CLAMP_READ_COLOR_ARB* = 0x0000891C
+  GL_FIXED_ONLY_ARB* = 0x0000891D
+  WGL_TYPE_RGBA_FLOAT_ARB* = 0x000021A0
+
+proc glClampColorARB*(target: TGLenum, clamp: TGLenum){.dynlib: dllname, 
+    importc: "glClampColorARB".}
+  #***** GL_ARB_half_float_pixel *****//
+const 
+  GL_HALF_FLOAT_ARB* = 0x0000140B
+  #***** GL_ARB_texture_float *****//
+
+const 
+  GL_TEXTURE_RED_TYPE_ARB* = 0x00008C10
+  GL_TEXTURE_GREEN_TYPE_ARB* = 0x00008C11
+  GL_TEXTURE_BLUE_TYPE_ARB* = 0x00008C12
+  GL_TEXTURE_ALPHA_TYPE_ARB* = 0x00008C13
+  GL_TEXTURE_LUMINANCE_TYPE_ARB* = 0x00008C14
+  GL_TEXTURE_INTENSITY_TYPE_ARB* = 0x00008C15
+  GL_TEXTURE_DEPTH_TYPE_ARB* = 0x00008C16
+  GL_UNSIGNED_NORMALIZED_ARB* = 0x00008C17
+  GL_RGBA32F_ARB* = 0x00008814
+  GL_RGB32F_ARB* = 0x00008815
+  GL_ALPHA32F_ARB* = 0x00008816
+  GL_INTENSITY32F_ARB* = 0x00008817
+  GL_LUMINANCE32F_ARB* = 0x00008818
+  GL_LUMINANCE_ALPHA32F_ARB* = 0x00008819
+  GL_RGBA16F_ARB* = 0x0000881A
+  GL_RGB16F_ARB* = 0x0000881B
+  GL_ALPHA16F_ARB* = 0x0000881C
+  GL_INTENSITY16F_ARB* = 0x0000881D
+  GL_LUMINANCE16F_ARB* = 0x0000881E
+  GL_LUMINANCE_ALPHA16F_ARB* = 0x0000881F
+  #***** GL_EXT_texture_compression_dxt1 *****//
+  # GL_COMPRESSED_RGB_S3TC_DXT1_EXT  { already defined }
+  # GL_COMPRESSED_RGBA_S3TC_DXT1_EXT  { already defined }
+  #***** GL_ARB_pixel_buffer_object *****//
+
+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 
+  GL_FRAMEBUFFER_EXT* = 0x00008D40
+  GL_RENDERBUFFER_EXT* = 0x00008D41
+  GL_STENCIL_INDEX_EXT* = 0x00008D45
+  GL_STENCIL_INDEX1_EXT* = 0x00008D46
+  GL_STENCIL_INDEX4_EXT* = 0x00008D47
+  GL_STENCIL_INDEX8_EXT* = 0x00008D48
+  GL_STENCIL_INDEX16_EXT* = 0x00008D49
+  GL_RENDERBUFFER_WIDTH_EXT* = 0x00008D42
+  GL_RENDERBUFFER_HEIGHT_EXT* = 0x00008D43
+  GL_RENDERBUFFER_INTERNAL_FORMAT_EXT* = 0x00008D44
+  GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT* = 0x00008CD0
+  GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT* = 0x00008CD1
+  GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT* = 0x00008CD2
+  GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT* = 0x00008CD3
+  GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT* = 0x00008CD4
+  GL_COLOR_ATTACHMENT0_EXT* = 0x00008CE0
+  GL_COLOR_ATTACHMENT1_EXT* = 0x00008CE1
+  GL_COLOR_ATTACHMENT2_EXT* = 0x00008CE2
+  GL_COLOR_ATTACHMENT3_EXT* = 0x00008CE3
+  GL_COLOR_ATTACHMENT4_EXT* = 0x00008CE4
+  GL_COLOR_ATTACHMENT5_EXT* = 0x00008CE5
+  GL_COLOR_ATTACHMENT6_EXT* = 0x00008CE6
+  GL_COLOR_ATTACHMENT7_EXT* = 0x00008CE7
+  GL_COLOR_ATTACHMENT8_EXT* = 0x00008CE8
+  GL_COLOR_ATTACHMENT9_EXT* = 0x00008CE9
+  GL_COLOR_ATTACHMENT10_EXT* = 0x00008CEA
+  GL_COLOR_ATTACHMENT11_EXT* = 0x00008CEB
+  GL_COLOR_ATTACHMENT12_EXT* = 0x00008CEC
+  GL_COLOR_ATTACHMENT13_EXT* = 0x00008CED
+  GL_COLOR_ATTACHMENT14_EXT* = 0x00008CEE
+  GL_COLOR_ATTACHMENT15_EXT* = 0x00008CEF
+  GL_DEPTH_ATTACHMENT_EXT* = 0x00008D00
+  GL_STENCIL_ATTACHMENT_EXT* = 0x00008D20
+  GL_FRAMEBUFFER_COMPLETE_EXT* = 0x00008CD5
+  GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT* = 0x00008CD6
+  GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT* = 0x00008CD7
+  GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT* = 0x00008CD8
+  GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT* = 0x00008CD9
+  GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT* = 0x00008CDA
+  GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT* = 0x00008CDB
+  GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT* = 0x00008CDC
+  GL_FRAMEBUFFER_UNSUPPORTED_EXT* = 0x00008CDD
+  GL_FRAMEBUFFER_STATUS_ERROR_EXT* = 0x00008CDE
+  GL_FRAMEBUFFER_BINDING_EXT* = 0x00008CA6
+  GL_RENDERBUFFER_BINDING_EXT* = 0x00008CA7
+  GL_MAX_COLOR_ATTACHMENTS_EXT* = 0x00008CDF
+  GL_MAX_RENDERBUFFER_SIZE_EXT* = 0x000084E8
+  GL_INVALID_FRAMEBUFFER_OPERATION_EXT* = 0x00000506
+
+proc glIsRenderbufferEXT*(renderbuffer: TGLuint): TGLboolean{.dynlib: dllname, 
+    importc: "glIsRenderbufferEXT".}
+proc glBindRenderbufferEXT*(target: TGLenum, renderbuffer: TGLuint){.
+    dynlib: dllname, importc: "glBindRenderbufferEXT".}
+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, 
+                               width: TGLsizei, height: TGLsizei){.
+    dynlib: dllname, importc: "glRenderbufferStorageEXT".}
+proc glGetRenderbufferParameterivEXT*(target: TGLenum, pname: TGLenum, 
+                                      params: PGLint){.dynlib: dllname, 
+    importc: "glGetRenderbufferParameterivEXT".}
+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, 
+    importc: "glGenFramebuffersEXT".}
+proc glCheckFramebufferStatusEXT*(target: TGLenum): TGLenum{.dynlib: dllname, 
+    importc: "glCheckFramebufferStatusEXT".}
+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, 
+    importc: "glFramebufferTexture2DEXT".}
+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, 
+    importc: "glFramebufferRenderbufferEXT".}
+proc glGetFramebufferAttachmentParameterivEXT*(target: TGLenum, 
+    attachment: TGLenum, pname: TGLenum, params: PGLint){.dynlib: dllname, 
+    importc: "glGetFramebufferAttachmentParameterivEXT".}
+proc glGenerateMipmapEXT*(target: TGLenum){.dynlib: dllname, 
+    importc: "glGenerateMipmapEXT".}
+  #***** GL_version_1_4 *****//
+const 
+  GL_BLEND_DST_RGB* = 0x000080C8
+  GL_BLEND_SRC_RGB* = 0x000080C9
+  GL_BLEND_DST_ALPHA* = 0x000080CA
+  GL_BLEND_SRC_ALPHA* = 0x000080CB
+  GL_POINT_SIZE_MIN* = 0x00008126
+  GL_POINT_SIZE_MAX* = 0x00008127
+  GL_POINT_FADE_THRESHOLD_SIZE* = 0x00008128
+  GL_POINT_DISTANCE_ATTENUATION* = 0x00008129
+  GL_GENERATE_MIPMAP* = 0x00008191
+  GL_GENERATE_MIPMAP_HINT* = 0x00008192
+  GL_DEPTH_COMPONENT16* = 0x000081A5
+  GL_DEPTH_COMPONENT24* = 0x000081A6
+  GL_DEPTH_COMPONENT32* = 0x000081A7
+  GL_MIRRORED_REPEAT* = 0x00008370
+  GL_FOG_COORDINATE_SOURCE* = 0x00008450
+  GL_FOG_COORDINATE* = 0x00008451
+  GL_FRAGMENT_DEPTH* = 0x00008452
+  GL_CURRENT_FOG_COORDINATE* = 0x00008453
+  GL_FOG_COORDINATE_ARRAY_TYPE* = 0x00008454
+  GL_FOG_COORDINATE_ARRAY_STRIDE* = 0x00008455
+  GL_FOG_COORDINATE_ARRAY_POINTER* = 0x00008456
+  GL_FOG_COORDINATE_ARRAY* = 0x00008457
+  GL_COLOR_SUM* = 0x00008458
+  GL_CURRENT_SECONDARY_COLOR* = 0x00008459
+  GL_SECONDARY_COLOR_ARRAY_SIZE* = 0x0000845A
+  GL_SECONDARY_COLOR_ARRAY_TYPE* = 0x0000845B
+  GL_SECONDARY_COLOR_ARRAY_STRIDE* = 0x0000845C
+  GL_SECONDARY_COLOR_ARRAY_POINTER* = 0x0000845D
+  GL_SECONDARY_COLOR_ARRAY* = 0x0000845E
+  GL_MAX_TEXTURE_LOD_BIAS* = 0x000084FD
+  GL_TEXTURE_FILTER_CONTROL* = 0x00008500
+  GL_TEXTURE_LOD_BIAS* = 0x00008501
+  GL_INCR_WRAP* = 0x00008507
+  GL_DECR_WRAP* = 0x00008508
+  GL_TEXTURE_DEPTH_SIZE* = 0x0000884A
+  GL_DEPTH_TEXTURE_MODE* = 0x0000884B
+  GL_TEXTURE_COMPARE_MODE* = 0x0000884C
+  GL_TEXTURE_COMPARE_FUNC* = 0x0000884D
+  GL_COMPARE_R_TO_TEXTURE* = 0x0000884E
+
+proc glBlendFuncSeparate*(sfactorRGB: TGLenum, dfactorRGB: TGLenum, 
+                          sfactorAlpha: TGLenum, dfactorAlpha: TGLenum){.
+    dynlib: dllname, importc: "glBlendFuncSeparate".}
+proc glFogCoordf*(coord: TGLfloat){.dynlib: dllname, importc: "glFogCoordf".}
+proc glFogCoordfv*(coord: PGLfloat){.dynlib: dllname, importc: "glFogCoordfv".}
+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, 
+    importc: "glMultiDrawArrays".}
+proc glMultiDrawElements*(mode: TGLenum, count: PGLsizei, thetype: TGLenum, 
+                          indices: PGLvoid, primcount: TGLsizei){.
+    dynlib: dllname, importc: "glMultiDrawElements".}
+proc glPointParameterf*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, 
+    importc: "glPointParameterf".}
+proc glPointParameterfv*(pname: TGLenum, params: PGLfloat){.dynlib: dllname, 
+    importc: "glPointParameterfv".}
+proc glPointParameteri*(pname: TGLenum, param: TGLint){.dynlib: dllname, 
+    importc: "glPointParameteri".}
+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, 
+                                       importc: "glSecondaryColor3bv".}
+proc glSecondaryColor3d*(red: TGLdouble, green: TGLdouble, blue: TGLdouble){.
+    dynlib: dllname, importc: "glSecondaryColor3d".}
+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, 
+                                        importc: "glSecondaryColor3fv".}
+proc glSecondaryColor3i*(red: TGLint, green: TGLint, blue: TGLint){.
+    dynlib: dllname, importc: "glSecondaryColor3i".}
+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, 
+                                        importc: "glSecondaryColor3sv".}
+proc glSecondaryColor3ub*(red: TGLubyte, green: TGLubyte, blue: TGLubyte){.
+    dynlib: dllname, importc: "glSecondaryColor3ub".}
+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, 
+                                        importc: "glSecondaryColor3uiv".}
+proc glSecondaryColor3us*(red: TGLushort, green: TGLushort, blue: TGLushort){.
+    dynlib: dllname, importc: "glSecondaryColor3us".}
+proc glSecondaryColor3usv*(v: PGLushort){.dynlib: dllname, 
+    importc: "glSecondaryColor3usv".}
+proc glSecondaryColorPointer*(size: TGLint, thetype: TGLenum, stride: TGLsizei, 
+                              pointer: PGLvoid){.dynlib: dllname, 
+    importc: "glSecondaryColorPointer".}
+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, 
+    importc: "glWindowPos2f".}
+proc glWindowPos2fv*(v: PGLfloat){.dynlib: dllname, importc: "glWindowPos2fv".}
+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, 
+    importc: "glWindowPos2s".}
+proc glWindowPos2sv*(v: PGLshort){.dynlib: dllname, importc: "glWindowPos2sv".}
+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, 
+    importc: "glWindowPos3f".}
+proc glWindowPos3fv*(v: PGLfloat){.dynlib: dllname, importc: "glWindowPos3fv".}
+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, 
+    importc: "glWindowPos3s".}
+proc glWindowPos3sv*(v: PGLshort){.dynlib: dllname, importc: "glWindowPos3sv".}
+  #***** GL_version_1_5 *****//
+const 
+  GL_BUFFER_SIZE* = 0x00008764
+  GL_BUFFER_USAGE* = 0x00008765
+  GL_QUERY_COUNTER_BITS* = 0x00008864
+  GL_CURRENT_QUERY* = 0x00008865
+  GL_QUERY_RESULT* = 0x00008866
+  GL_QUERY_RESULT_AVAILABLE* = 0x00008867
+  GL_ARRAY_BUFFER* = 0x00008892
+  GL_ELEMENT_ARRAY_BUFFER* = 0x00008893
+  GL_ARRAY_BUFFER_BINDING* = 0x00008894
+  GL_ELEMENT_ARRAY_BUFFER_BINDING* = 0x00008895
+  GL_VERTEX_ARRAY_BUFFER_BINDING* = 0x00008896
+  GL_NORMAL_ARRAY_BUFFER_BINDING* = 0x00008897
+  GL_COLOR_ARRAY_BUFFER_BINDING* = 0x00008898
+  GL_INDEX_ARRAY_BUFFER_BINDING* = 0x00008899
+  GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING* = 0x0000889A
+  GL_EDGE_FLAG_ARRAY_BUFFER_BINDING* = 0x0000889B
+  GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING* = 0x0000889C
+  GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING* = 0x0000889D
+  GL_WEIGHT_ARRAY_BUFFER_BINDING* = 0x0000889E
+  GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING* = 0x0000889F
+  GL_READ_ONLY* = 0x000088B8
+  GL_WRITE_ONLY* = 0x000088B9
+  GL_READ_WRITE* = 0x000088BA
+  GL_BUFFER_ACCESS* = 0x000088BB
+  GL_BUFFER_MAPPED* = 0x000088BC
+  GL_BUFFER_MAP_POINTER* = 0x000088BD
+  GL_STREAM_DRAW* = 0x000088E0
+  GL_STREAM_READ* = 0x000088E1
+  GL_STREAM_COPY* = 0x000088E2
+  GL_STATIC_DRAW* = 0x000088E4
+  GL_STATIC_READ* = 0x000088E5
+  GL_STATIC_COPY* = 0x000088E6
+  GL_DYNAMIC_DRAW* = 0x000088E8
+  GL_DYNAMIC_READ* = 0x000088E9
+  GL_DYNAMIC_COPY* = 0x000088EA
+  GL_SAMPLES_PASSED* = 0x00008914
+  GL_FOG_COORD_SRC* = 0x00008450
+  GL_FOG_COORD* = 0x00008451
+  GL_CURRENT_FOG_COORD* = 0x00008453
+  GL_FOG_COORD_ARRAY_TYPE* = 0x00008454
+  GL_FOG_COORD_ARRAY_STRIDE* = 0x00008455
+  GL_FOG_COORD_ARRAY_POINTER* = 0x00008456
+  GL_FOG_COORD_ARRAY* = 0x00008457
+  GL_FOG_COORD_ARRAY_BUFFER_BINDING* = 0x0000889D
+  GL_SRC0_RGB* = 0x00008580
+  GL_SRC1_RGB* = 0x00008581
+  GL_SRC2_RGB* = 0x00008582
+  GL_SRC0_ALPHA* = 0x00008588
+  GL_SRC1_ALPHA* = 0x00008589
+  GL_SRC2_ALPHA* = 0x0000858A
+
+proc glGenQueries*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, 
+    importc: "glGenQueries".}
+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, 
+    importc: "glBeginQuery".}
+proc glEndQuery*(target: TGLenum){.dynlib: dllname, importc: "glEndQuery".}
+proc glGetQueryiv*(target: TGLenum, pname: TGLenum, params: PGLint){.
+    dynlib: dllname, importc: "glGetQueryiv".}
+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, 
+    importc: "glBindBuffer".}
+proc glDeleteBuffers*(n: TGLsizei, buffers: PGLuint){.dynlib: dllname, 
+    importc: "glDeleteBuffers".}
+proc glGenBuffers*(n: TGLsizei, buffers: PGLuint){.dynlib: dllname, 
+    importc: "glGenBuffers".}
+proc glIsBuffer*(buffer: TGLuint): TGLboolean{.dynlib: dllname, 
+    importc: "glIsBuffer".}
+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, 
+                                      importc: "glBufferSubData".}
+proc glGetBufferSubData*(target: TGLenum, offset: GLintptr, size: GLsizeiptr, 
+                         data: PGLvoid){.dynlib: dllname, 
+    importc: "glGetBufferSubData".}
+proc glMapBuffer*(target: TGLenum, access: TGLenum): PGLvoid{.dynlib: dllname, 
+    importc: "glMapBuffer".}
+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 
+  GL_BLEND_EQUATION_RGB* = 0x00008009
+  GL_VERTEX_ATTRIB_ARRAY_ENABLED* = 0x00008622
+  GL_VERTEX_ATTRIB_ARRAY_SIZE* = 0x00008623
+  GL_VERTEX_ATTRIB_ARRAY_STRIDE* = 0x00008624
+  GL_VERTEX_ATTRIB_ARRAY_TYPE* = 0x00008625
+  GL_CURRENT_VERTEX_ATTRIB* = 0x00008626
+  GL_VERTEX_PROGRAM_POINT_SIZE* = 0x00008642
+  GL_VERTEX_PROGRAM_TWO_SIDE* = 0x00008643
+  GL_VERTEX_ATTRIB_ARRAY_POINTER* = 0x00008645
+  GL_STENCIL_BACK_FUNC* = 0x00008800
+  GL_STENCIL_BACK_FAIL* = 0x00008801
+  GL_STENCIL_BACK_PASS_DEPTH_FAIL* = 0x00008802
+  GL_STENCIL_BACK_PASS_DEPTH_PASS* = 0x00008803
+  GL_MAX_DRAW_BUFFERS* = 0x00008824
+  GL_DRAW_BUFFER0* = 0x00008825
+  GL_DRAW_BUFFER1* = 0x00008826
+  GL_DRAW_BUFFER2* = 0x00008827
+  GL_DRAW_BUFFER3* = 0x00008828
+  GL_DRAW_BUFFER4* = 0x00008829
+  GL_DRAW_BUFFER5* = 0x0000882A
+  GL_DRAW_BUFFER6* = 0x0000882B
+  GL_DRAW_BUFFER7* = 0x0000882C
+  GL_DRAW_BUFFER8* = 0x0000882D
+  GL_DRAW_BUFFER9* = 0x0000882E
+  GL_DRAW_BUFFER10* = 0x0000882F
+  GL_DRAW_BUFFER11* = 0x00008830
+  GL_DRAW_BUFFER12* = 0x00008831
+  GL_DRAW_BUFFER13* = 0x00008832
+  GL_DRAW_BUFFER14* = 0x00008833
+  GL_DRAW_BUFFER15* = 0x00008834
+  GL_BLEND_EQUATION_ALPHA* = 0x0000883D
+  GL_POINT_SPRITE* = 0x00008861
+  GL_COORD_REPLACE* = 0x00008862
+  GL_MAX_VERTEX_ATTRIBS* = 0x00008869
+  GL_VERTEX_ATTRIB_ARRAY_NORMALIZED* = 0x0000886A
+  GL_MAX_TEXTURE_COORDS* = 0x00008871
+  GL_MAX_TEXTURE_IMAGE_UNITS* = 0x00008872
+  GL_FRAGMENT_SHADER* = 0x00008B30
+  GL_VERTEX_SHADER* = 0x00008B31
+  GL_MAX_FRAGMENT_UNIFORM_COMPONENTS* = 0x00008B49
+  GL_MAX_VERTEX_UNIFORM_COMPONENTS* = 0x00008B4A
+  GL_MAX_VARYING_FLOATS* = 0x00008B4B
+  GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS* = 0x00008B4C
+  GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS* = 0x00008B4D
+  GL_SHADER_TYPE* = 0x00008B4F
+  GL_FLOAT_VEC2* = 0x00008B50
+  GL_FLOAT_VEC3* = 0x00008B51
+  GL_FLOAT_VEC4* = 0x00008B52
+  GL_INT_VEC2* = 0x00008B53
+  GL_INT_VEC3* = 0x00008B54
+  GL_INT_VEC4* = 0x00008B55
+  GL_BOOL* = 0x00008B56
+  GL_BOOL_VEC2* = 0x00008B57
+  GL_BOOL_VEC3* = 0x00008B58
+  GL_BOOL_VEC4* = 0x00008B59
+  GL_FLOAT_MAT2* = 0x00008B5A
+  GL_FLOAT_MAT3* = 0x00008B5B
+  GL_FLOAT_MAT4* = 0x00008B5C
+  GL_SAMPLER_1D* = 0x00008B5D
+  GL_SAMPLER_2D* = 0x00008B5E
+  GL_SAMPLER_3D* = 0x00008B5F
+  GL_SAMPLER_CUBE* = 0x00008B60
+  GL_SAMPLER_1D_SHADOW* = 0x00008B61
+  GL_SAMPLER_2D_SHADOW* = 0x00008B62
+  GL_DELETE_STATUS* = 0x00008B80
+  GL_COMPILE_STATUS* = 0x00008B81
+  GL_LINK_STATUS* = 0x00008B82
+  GL_VALIDATE_STATUS* = 0x00008B83
+  GL_INFO_LOG_LENGTH* = 0x00008B84
+  GL_ATTACHED_SHADERS* = 0x00008B85
+  GL_ACTIVE_UNIFORMS* = 0x00008B86
+  GL_ACTIVE_UNIFORM_MAX_LENGTH* = 0x00008B87
+  GL_SHADER_SOURCE_LENGTH* = 0x00008B88
+  GL_ACTIVE_ATTRIBUTES* = 0x00008B89
+  GL_ACTIVE_ATTRIBUTE_MAX_LENGTH* = 0x00008B8A
+  GL_FRAGMENT_SHADER_DERIVATIVE_HINT* = 0x00008B8B
+  GL_SHADING_LANGUAGE_VERSION* = 0x00008B8C
+  GL_CURRENT_PROGRAM* = 0x00008B8D
+  GL_POINT_SPRITE_COORD_ORIGIN* = 0x00008CA0
+  GL_LOWER_LEFT* = 0x00008CA1
+  GL_UPPER_LEFT* = 0x00008CA2
+  GL_STENCIL_BACK_REF* = 0x00008CA3
+  GL_STENCIL_BACK_VALUE_MASK* = 0x00008CA4
+  GL_STENCIL_BACK_WRITEMASK* = 0x00008CA5
+
+{.pop.}
\ No newline at end of file
diff --git a/tests/manyloc/keineschweine/lib/glu.nim b/tests/manyloc/keineschweine/lib/glu.nim
new file mode 100644
index 000000000..e00120d83
--- /dev/null
+++ b/tests/manyloc/keineschweine/lib/glu.nim
@@ -0,0 +1,335 @@
+#
+#
+#  Adaption of the delphi3d.net OpenGL units to FreePascal
+#  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              
+#******************************************************************************
+
+import 
+  GL
+
+when defined(windows): 
+  {.push, callconv: stdcall.}
+else: 
+  {.push, callconv: cdecl.}
+
+when defined(windows): 
+  const 
+    dllname = "glu32.dll"
+elif defined(macosx): 
+  const 
+    dllname = "/System/Library/Frameworks/OpenGL.framework/Libraries/libGLU.dylib"
+else: 
+  const 
+    dllname = "libGLU.so.1"
+type 
+  TViewPortArray* = array[0..3, TGLint]
+  T16dArray* = array[0..15, TGLdouble]
+  TCallBack* = proc ()
+  T3dArray* = array[0..2, TGLdouble]
+  T4pArray* = array[0..3, Pointer]
+  T4fArray* = array[0..3, TGLfloat]
+  PPointer* = ptr Pointer
+
+type 
+  GLUnurbs*{.final.} = object 
+  PGLUnurbs* = ptr GLUnurbs
+  GLUquadric*{.final.} = object 
+  PGLUquadric* = ptr GLUquadric
+  GLUtesselator*{.final.} = object 
+  PGLUtesselator* = ptr GLUtesselator # backwards compatibility:
+  GLUnurbsObj* = GLUnurbs
+  PGLUnurbsObj* = PGLUnurbs
+  GLUquadricObj* = GLUquadric
+  PGLUquadricObj* = PGLUquadric
+  GLUtesselatorObj* = GLUtesselator
+  PGLUtesselatorObj* = PGLUtesselator
+  GLUtriangulatorObj* = GLUtesselator
+  PGLUtriangulatorObj* = PGLUtesselator
+  TGLUnurbs* = GLUnurbs
+  TGLUquadric* = GLUquadric
+  TGLUtesselator* = GLUtesselator
+  TGLUnurbsObj* = GLUnurbsObj
+  TGLUquadricObj* = GLUquadricObj
+  TGLUtesselatorObj* = GLUtesselatorObj
+  TGLUtriangulatorObj* = GLUtriangulatorObj
+
+proc gluErrorString*(errCode: TGLenum): cstring{.dynlib: dllname, 
+    importc: "gluErrorString".}
+proc gluErrorUnicodeStringEXT*(errCode: TGLenum): ptr int16{.dynlib: dllname, 
+    importc: "gluErrorUnicodeStringEXT".}
+proc gluGetString*(name: TGLenum): cstring{.dynlib: dllname, 
+    importc: "gluGetString".}
+proc gluOrtho2D*(left, right, bottom, top: TGLdouble){.dynlib: dllname, 
+    importc: "gluOrtho2D".}
+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, 
+                 viewport: var TViewPortArray, winx, winy, winz: PGLdouble): int{.
+    dynlib: dllname, importc: "gluProject".}
+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, 
+    importc: "gluScaleImage".}
+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, 
+                        format, atype: TGLenum, data: Pointer): int{.
+    dynlib: dllname, importc: "gluBuild2DMipmaps".}
+proc gluNewQuadric*(): PGLUquadric{.dynlib: dllname, importc: "gluNewQuadric".}
+proc gluDeleteQuadric*(state: PGLUquadric){.dynlib: dllname, 
+    importc: "gluDeleteQuadric".}
+proc gluQuadricNormals*(quadObject: PGLUquadric, normals: TGLenum){.
+    dynlib: dllname, importc: "gluQuadricNormals".}
+proc gluQuadricTexture*(quadObject: PGLUquadric, textureCoords: TGLboolean){.
+    dynlib: dllname, importc: "gluQuadricTexture".}
+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, 
+    importc: "gluCylinder".}
+proc gluDisk*(qobj: PGLUquadric, innerRadius, outerRadius: TGLdouble, 
+              slices, loops: TGLint){.dynlib: dllname, importc: "gluDisk".}
+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){.
+    dynlib: dllname, importc: "gluSphere".}
+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, 
+    importc: "gluDeleteTess".}
+proc gluTessBeginPolygon*(tess: PGLUtesselator, polygon_data: Pointer){.
+    dynlib: dllname, importc: "gluTessBeginPolygon".}
+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, 
+    importc: "gluTessEndContour".}
+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, 
+    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, 
+                                        importc: "gluNewNurbsRenderer".}
+proc gluDeleteNurbsRenderer*(nobj: PGLUnurbs){.dynlib: dllname, 
+    importc: "gluDeleteNurbsRenderer".}
+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, 
+    importc: "gluPwlCurve".}
+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, 
+    importc: "gluNurbsSurface".}
+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".}
+proc gluGetNurbsProperty*(nobj: PGLUnurbs, aproperty: TGLenum, value: PGLfloat){.
+    dynlib: dllname, importc: "gluGetNurbsProperty".}
+proc gluNurbsCallback*(nobj: PGLUnurbs, which: TGLenum, fn: TCallBack){.
+    dynlib: dllname, importc: "gluNurbsCallback".}
+  #*** Callback function prototypes ***
+type                          # gluQuadricCallback
+  GLUquadricErrorProc* = proc (p: TGLenum) # gluTessCallback
+  GLUtessBeginProc* = proc (p: TGLenum)
+  GLUtessEdgeFlagProc* = proc (p: TGLboolean)
+  GLUtessVertexProc* = proc (p: Pointer)
+  GLUtessEndProc* = proc ()
+  GLUtessErrorProc* = proc (p: TGLenum)
+  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) # 
+                                                                               # 
+                                                                               # gluNurbsCallback
+  GLUnurbsErrorProc* = proc (p: TGLenum) #***           Generic constants               ****/
+
+const                         # Version
+  GLU_VERSION_1_1* = 1
+  GLU_VERSION_1_2* = 1        # Errors: (return value 0 = no error)
+  GLU_INVALID_ENUM* = 100900
+  GLU_INVALID_VALUE* = 100901
+  GLU_OUT_OF_MEMORY* = 100902
+  GLU_INCOMPATIBLE_GL_VERSION* = 100903 # StringName
+  GLU_VERSION* = 100800
+  GLU_EXTENSIONS* = 100801    # Boolean
+  GLU_TRUE* = GL_TRUE
+  GLU_FALSE* = GL_FALSE #***           Quadric constants               ****/
+                        # QuadricNormal
+  GLU_SMOOTH* = 100000
+  GLU_FLAT* = 100001
+  GLU_NONE* = 100002          # QuadricDrawStyle
+  GLU_POINT* = 100010
+  GLU_LINE* = 100011
+  GLU_FILL* = 100012
+  GLU_SILHOUETTE* = 100013    # QuadricOrientation
+  GLU_OUTSIDE* = 100020
+  GLU_INSIDE* = 100021        # Callback types:
+                              #      GLU_ERROR       = 100103;
+                              #***           Tesselation constants           ****/
+  GLU_TESS_MAX_COORD* = 1.00000e+150 # TessProperty
+  GLU_TESS_WINDING_RULE* = 100140
+  GLU_TESS_BOUNDARY_ONLY* = 100141
+  GLU_TESS_TOLERANCE* = 100142 # TessWinding
+  GLU_TESS_WINDING_ODD* = 100130
+  GLU_TESS_WINDING_NONZERO* = 100131
+  GLU_TESS_WINDING_POSITIVE* = 100132
+  GLU_TESS_WINDING_NEGATIVE* = 100133
+  GLU_TESS_WINDING_ABS_GEQ_TWO* = 100134 # TessCallback
+  GLU_TESS_BEGIN* = 100100    # void (CALLBACK*)(TGLenum    type)
+  constGLU_TESS_VERTEX* = 100101 # void (CALLBACK*)(void      *data)
+  GLU_TESS_END* = 100102      # void (CALLBACK*)(void)
+  GLU_TESS_ERROR* = 100103    # void (CALLBACK*)(TGLenum    errno)
+  GLU_TESS_EDGE_FLAG* = 100104 # void (CALLBACK*)(TGLboolean boundaryEdge)
+  GLU_TESS_COMBINE* = 100105 # void (CALLBACK*)(TGLdouble  coords[3],
+                             #                                                            void      *data[4],
+                             #                                                            TGLfloat   weight[4],
+                             #                                                            void      **dataOut) 
+  GLU_TESS_BEGIN_DATA* = 100106 # void (CALLBACK*)(TGLenum    type,
+                                #                                                            void      *polygon_data) 
+  GLU_TESS_VERTEX_DATA* = 100107 # void (CALLBACK*)(void      *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) 
+  GLU_TESS_EDGE_FLAG_DATA* = 100110 # void (CALLBACK*)(TGLboolean boundaryEdge,
+                                    #                                                            void      *polygon_data) 
+  GLU_TESS_COMBINE_DATA* = 100111 # void (CALLBACK*)(TGLdouble  coords[3],
+                                  #                                                            void      *data[4],
+                                  #                                                            TGLfloat   weight[4],
+                                  #                                                            void      **dataOut,
+                                  #                                                            void      *polygon_data) 
+                                  # TessError
+  GLU_TESS_ERROR1* = 100151
+  GLU_TESS_ERROR2* = 100152
+  GLU_TESS_ERROR3* = 100153
+  GLU_TESS_ERROR4* = 100154
+  GLU_TESS_ERROR5* = 100155
+  GLU_TESS_ERROR6* = 100156
+  GLU_TESS_ERROR7* = 100157
+  GLU_TESS_ERROR8* = 100158
+  GLU_TESS_MISSING_BEGIN_POLYGON* = GLU_TESS_ERROR1
+  GLU_TESS_MISSING_BEGIN_CONTOUR* = GLU_TESS_ERROR2
+  GLU_TESS_MISSING_END_POLYGON* = GLU_TESS_ERROR3
+  GLU_TESS_MISSING_END_CONTOUR* = GLU_TESS_ERROR4
+  GLU_TESS_COORD_TOO_LARGE* = GLU_TESS_ERROR5
+  GLU_TESS_NEED_COMBINE_CALLBACK* = GLU_TESS_ERROR6 #***           NURBS constants                 ****/
+                                                    # NurbsProperty
+  GLU_AUTO_LOAD_MATRIX* = 100200
+  GLU_CULLING* = 100201
+  GLU_SAMPLING_TOLERANCE* = 100203
+  GLU_DISPLAY_MODE* = 100204
+  GLU_PARAMETRIC_TOLERANCE* = 100202
+  GLU_SAMPLING_METHOD* = 100205
+  GLU_U_STEP* = 100206
+  GLU_V_STEP* = 100207        # NurbsSampling
+  GLU_PATH_LENGTH* = 100215
+  GLU_PARAMETRIC_ERROR* = 100216
+  GLU_DOMAIN_DISTANCE* = 100217 # NurbsTrim
+  GLU_MAP1_TRIM_2* = 100210
+  GLU_MAP1_TRIM_3* = 100211   # NurbsDisplay
+                              #      GLU_FILL                = 100012;
+  GLU_OUTLINE_POLYGON* = 100240
+  GLU_OUTLINE_PATCH* = 100241 # NurbsCallback
+                              #      GLU_ERROR               = 100103;
+                              # NurbsErrors
+  GLU_NURBS_ERROR1* = 100251
+  GLU_NURBS_ERROR2* = 100252
+  GLU_NURBS_ERROR3* = 100253
+  GLU_NURBS_ERROR4* = 100254
+  GLU_NURBS_ERROR5* = 100255
+  GLU_NURBS_ERROR6* = 100256
+  GLU_NURBS_ERROR7* = 100257
+  GLU_NURBS_ERROR8* = 100258
+  GLU_NURBS_ERROR9* = 100259
+  GLU_NURBS_ERROR10* = 100260
+  GLU_NURBS_ERROR11* = 100261
+  GLU_NURBS_ERROR12* = 100262
+  GLU_NURBS_ERROR13* = 100263
+  GLU_NURBS_ERROR14* = 100264
+  GLU_NURBS_ERROR15* = 100265
+  GLU_NURBS_ERROR16* = 100266
+  GLU_NURBS_ERROR17* = 100267
+  GLU_NURBS_ERROR18* = 100268
+  GLU_NURBS_ERROR19* = 100269
+  GLU_NURBS_ERROR20* = 100270
+  GLU_NURBS_ERROR21* = 100271
+  GLU_NURBS_ERROR22* = 100272
+  GLU_NURBS_ERROR23* = 100273
+  GLU_NURBS_ERROR24* = 100274
+  GLU_NURBS_ERROR25* = 100275
+  GLU_NURBS_ERROR26* = 100276
+  GLU_NURBS_ERROR27* = 100277
+  GLU_NURBS_ERROR28* = 100278
+  GLU_NURBS_ERROR29* = 100279
+  GLU_NURBS_ERROR30* = 100280
+  GLU_NURBS_ERROR31* = 100281
+  GLU_NURBS_ERROR32* = 100282
+  GLU_NURBS_ERROR33* = 100283
+  GLU_NURBS_ERROR34* = 100284
+  GLU_NURBS_ERROR35* = 100285
+  GLU_NURBS_ERROR36* = 100286
+  GLU_NURBS_ERROR37* = 100287 #***           Backwards compatibility for old tesselator           ****/
+
+proc gluBeginPolygon*(tess: PGLUtesselator){.dynlib: dllname, 
+    importc: "gluBeginPolygon".}
+proc gluNextContour*(tess: PGLUtesselator, atype: TGLenum){.dynlib: dllname, 
+    importc: "gluNextContour".}
+proc gluEndPolygon*(tess: PGLUtesselator){.dynlib: dllname, 
+    importc: "gluEndPolygon".}
+const                         # Contours types -- obsolete!
+  GLU_CW* = 100120
+  GLU_CCW* = 100121
+  GLU_INTERIOR* = 100122
+  GLU_EXTERIOR* = 100123
+  GLU_UNKNOWN* = 100124       # Names without "TESS_" prefix
+  GLU_BEGIN* = GLU_TESS_BEGIN
+  GLU_VERTEX* = constGLU_TESS_VERTEX
+  GLU_END* = GLU_TESS_END
+  GLU_ERROR* = GLU_TESS_ERROR
+  GLU_EDGE_FLAG* = GLU_TESS_EDGE_FLAG
+
+{.pop.}
+# implementation
diff --git a/tests/manyloc/keineschweine/lib/glut.nim b/tests/manyloc/keineschweine/lib/glut.nim
new file mode 100644
index 000000000..ff157c327
--- /dev/null
+++ b/tests/manyloc/keineschweine/lib/glut.nim
@@ -0,0 +1,438 @@
+#
+#
+#  Adaption of the delphi3d.net OpenGL units to FreePascal
+#  Sebastian Guenther (sg@freepascal.org) in 2002
+#  These units are free to use
+#
+
+# Copyright (c) Mark J. Kilgard, 1994, 1995, 1996.
+# This program is freely distributable without licensing fees  and is
+#   provided without guarantee or warrantee expressed or  implied. This
+#   program is -not- in the public domain.
+#******************************************************************************
+# Converted to Delphi by Tom Nuydens (tom@delphi3d.net)
+#   Contributions by Igor Karpov (glygrik@hotbox.ru)
+#   For the latest updates, visit Delphi3D: http://www.delphi3d.net
+#******************************************************************************
+
+import 
+  GL
+
+when defined(windows): 
+  const 
+    dllname = "glut32.dll"
+elif defined(macosx): 
+  const 
+    dllname = "/System/Library/Frameworks/GLUT.framework/GLUT"
+else: 
+  const 
+    dllname = "libglut.so.3"
+type
+  TGlutVoidCallback* = proc (){.cdecl.}
+  TGlut1IntCallback* = proc (value: cint){.cdecl.}
+  TGlut2IntCallback* = proc (v1, v2: cint){.cdecl.}
+  TGlut3IntCallback* = proc (v1, v2, v3: cint){.cdecl.}
+  TGlut4IntCallback* = proc (v1, v2, v3, v4: cint){.cdecl.}
+  TGlut1Char2IntCallback* = proc (c: int8, v1, v2: cint){.cdecl.}
+  TGlut1UInt3IntCallback* = proc (u, v1, v2, v3: cint){.cdecl.}
+
+const 
+  GLUT_API_VERSION* = 3
+  GLUT_XLIB_IMPLEMENTATION* = 12 # Display mode bit masks.
+  GLUT_RGB* = 0
+  GLUT_RGBA* = GLUT_RGB
+  GLUT_INDEX* = 1
+  GLUT_SINGLE* = 0
+  GLUT_DOUBLE* = 2
+  GLUT_ACCUM* = 4
+  GLUT_ALPHA* = 8
+  GLUT_DEPTH* = 16
+  GLUT_STENCIL* = 32
+  GLUT_MULTISAMPLE* = 128
+  GLUT_STEREO* = 256
+  GLUT_LUMINANCE* = 512       # Mouse buttons.
+  GLUT_LEFT_BUTTON* = 0
+  GLUT_MIDDLE_BUTTON* = 1
+  GLUT_RIGHT_BUTTON* = 2      # Mouse button state.
+  GLUT_DOWN* = 0
+  GLUT_UP* = 1                # function keys
+  GLUT_KEY_F1* = 1
+  GLUT_KEY_F2* = 2
+  GLUT_KEY_F3* = 3
+  GLUT_KEY_F4* = 4
+  GLUT_KEY_F5* = 5
+  GLUT_KEY_F6* = 6
+  GLUT_KEY_F7* = 7
+  GLUT_KEY_F8* = 8
+  GLUT_KEY_F9* = 9
+  GLUT_KEY_F10* = 10
+  GLUT_KEY_F11* = 11
+  GLUT_KEY_F12* = 12          # directional keys
+  GLUT_KEY_LEFT* = 100
+  GLUT_KEY_UP* = 101
+  GLUT_KEY_RIGHT* = 102
+  GLUT_KEY_DOWN* = 103
+  GLUT_KEY_PAGE_UP* = 104
+  GLUT_KEY_PAGE_DOWN* = 105
+  GLUT_KEY_HOME* = 106
+  GLUT_KEY_END* = 107
+  GLUT_KEY_INSERT* = 108      # Entry/exit  state.
+  GLUT_LEFT* = 0
+  GLUT_ENTERED* = 1           # Menu usage state.
+  GLUT_MENU_NOT_IN_USE* = 0
+  GLUT_MENU_IN_USE* = 1       # Visibility  state.
+  GLUT_NOT_VISIBLE* = 0
+  GLUT_VISIBLE* = 1           # Window status  state.
+  GLUT_HIDDEN* = 0
+  GLUT_FULLY_RETAINED* = 1
+  GLUT_PARTIALLY_RETAINED* = 2
+  GLUT_FULLY_COVERED* = 3     # Color index component selection values.
+  GLUT_RED* = 0
+  GLUT_GREEN* = 1
+  GLUT_BLUE* = 2              # Layers for use.
+  GLUT_NORMAL* = 0
+  GLUT_OVERLAY* = 1
+
+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).
+    GLUT_BITMAP_9_BY_15* = cast[Pointer](2)
+    GLUT_BITMAP_8_BY_13* = cast[Pointer](3)
+    GLUT_BITMAP_TIMES_ROMAN_10* = cast[Pointer](4)
+    GLUT_BITMAP_TIMES_ROMAN_24* = cast[Pointer](5)
+    GLUT_BITMAP_HELVETICA_10* = cast[Pointer](6)
+    GLUT_BITMAP_HELVETICA_12* = cast[Pointer](7)
+    GLUT_BITMAP_HELVETICA_18* = cast[Pointer](8)
+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).
+    GLUT_BITMAP_9_BY_15*: Pointer
+    GLUT_BITMAP_8_BY_13*: Pointer
+    GLUT_BITMAP_TIMES_ROMAN_10*: Pointer
+    GLUT_BITMAP_TIMES_ROMAN_24*: Pointer
+    GLUT_BITMAP_HELVETICA_10*: Pointer
+    GLUT_BITMAP_HELVETICA_12*: Pointer
+    GLUT_BITMAP_HELVETICA_18*: Pointer
+const                         # glutGet parameters.
+  GLUT_WINDOW_X* = 100
+  GLUT_WINDOW_Y* = 101
+  GLUT_WINDOW_WIDTH* = 102
+  GLUT_WINDOW_HEIGHT* = 103
+  GLUT_WINDOW_BUFFER_SIZE* = 104
+  GLUT_WINDOW_STENCIL_SIZE* = 105
+  GLUT_WINDOW_DEPTH_SIZE* = 106
+  GLUT_WINDOW_RED_SIZE* = 107
+  GLUT_WINDOW_GREEN_SIZE* = 108
+  GLUT_WINDOW_BLUE_SIZE* = 109
+  GLUT_WINDOW_ALPHA_SIZE* = 110
+  GLUT_WINDOW_ACCUM_RED_SIZE* = 111
+  GLUT_WINDOW_ACCUM_GREEN_SIZE* = 112
+  GLUT_WINDOW_ACCUM_BLUE_SIZE* = 113
+  GLUT_WINDOW_ACCUM_ALPHA_SIZE* = 114
+  GLUT_WINDOW_DOUBLEBUFFER* = 115
+  GLUT_WINDOW_RGBA* = 116
+  GLUT_WINDOW_PARENT* = 117
+  GLUT_WINDOW_NUM_CHILDREN* = 118
+  GLUT_WINDOW_COLORMAP_SIZE* = 119
+  GLUT_WINDOW_NUM_SAMPLES* = 120
+  GLUT_WINDOW_STEREO* = 121
+  GLUT_WINDOW_CURSOR* = 122
+  GLUT_SCREEN_WIDTH* = 200
+  GLUT_SCREEN_HEIGHT* = 201
+  GLUT_SCREEN_WIDTH_MM* = 202
+  GLUT_SCREEN_HEIGHT_MM* = 203
+  GLUT_MENU_NUM_ITEMS* = 300
+  GLUT_DISPLAY_MODE_POSSIBLE* = 400
+  GLUT_INIT_WINDOW_X* = 500
+  GLUT_INIT_WINDOW_Y* = 501
+  GLUT_INIT_WINDOW_WIDTH* = 502
+  GLUT_INIT_WINDOW_HEIGHT* = 503
+  constGLUT_INIT_DISPLAY_MODE* = 504
+  GLUT_ELAPSED_TIME* = 700
+  GLUT_WINDOW_FORMAT_ID* = 123 # glutDeviceGet parameters.
+  GLUT_HAS_KEYBOARD* = 600
+  GLUT_HAS_MOUSE* = 601
+  GLUT_HAS_SPACEBALL* = 602
+  GLUT_HAS_DIAL_AND_BUTTON_BOX* = 603
+  GLUT_HAS_TABLET* = 604
+  GLUT_NUM_MOUSE_BUTTONS* = 605
+  GLUT_NUM_SPACEBALL_BUTTONS* = 606
+  GLUT_NUM_BUTTON_BOX_BUTTONS* = 607
+  GLUT_NUM_DIALS* = 608
+  GLUT_NUM_TABLET_BUTTONS* = 609
+  GLUT_DEVICE_IGNORE_KEY_REPEAT* = 610
+  GLUT_DEVICE_KEY_REPEAT* = 611
+  GLUT_HAS_JOYSTICK* = 612
+  GLUT_OWNS_JOYSTICK* = 613
+  GLUT_JOYSTICK_BUTTONS* = 614
+  GLUT_JOYSTICK_AXES* = 615
+  GLUT_JOYSTICK_POLL_RATE* = 616 # glutLayerGet parameters.
+  GLUT_OVERLAY_POSSIBLE* = 800
+  GLUT_LAYER_IN_USE* = 801
+  GLUT_HAS_OVERLAY* = 802
+  GLUT_TRANSPARENT_INDEX* = 803
+  GLUT_NORMAL_DAMAGED* = 804
+  GLUT_OVERLAY_DAMAGED* = 805 # glutVideoResizeGet parameters.
+  GLUT_VIDEO_RESIZE_POSSIBLE* = 900
+  GLUT_VIDEO_RESIZE_IN_USE* = 901
+  GLUT_VIDEO_RESIZE_X_DELTA* = 902
+  GLUT_VIDEO_RESIZE_Y_DELTA* = 903
+  GLUT_VIDEO_RESIZE_WIDTH_DELTA* = 904
+  GLUT_VIDEO_RESIZE_HEIGHT_DELTA* = 905
+  GLUT_VIDEO_RESIZE_X* = 906
+  GLUT_VIDEO_RESIZE_Y* = 907
+  GLUT_VIDEO_RESIZE_WIDTH* = 908
+  GLUT_VIDEO_RESIZE_HEIGHT* = 909 # glutGetModifiers return mask.
+  GLUT_ACTIVE_SHIFT* = 1
+  GLUT_ACTIVE_CTRL* = 2
+  GLUT_ACTIVE_ALT* = 4        # glutSetCursor parameters.
+                              # Basic arrows.
+  GLUT_CURSOR_RIGHT_ARROW* = 0
+  GLUT_CURSOR_LEFT_ARROW* = 1 # Symbolic cursor shapes.
+  GLUT_CURSOR_INFO* = 2
+  GLUT_CURSOR_DESTROY* = 3
+  GLUT_CURSOR_HELP* = 4
+  GLUT_CURSOR_CYCLE* = 5
+  GLUT_CURSOR_SPRAY* = 6
+  GLUT_CURSOR_WAIT* = 7
+  GLUT_CURSOR_TEXT* = 8
+  GLUT_CURSOR_CROSSHAIR* = 9  # Directional cursors.
+  GLUT_CURSOR_UP_DOWN* = 10
+  GLUT_CURSOR_LEFT_RIGHT* = 11 # Sizing cursors.
+  GLUT_CURSOR_TOP_SIDE* = 12
+  GLUT_CURSOR_BOTTOM_SIDE* = 13
+  GLUT_CURSOR_LEFT_SIDE* = 14
+  GLUT_CURSOR_RIGHT_SIDE* = 15
+  GLUT_CURSOR_TOP_LEFT_CORNER* = 16
+  GLUT_CURSOR_TOP_RIGHT_CORNER* = 17
+  GLUT_CURSOR_BOTTOM_RIGHT_CORNER* = 18
+  GLUT_CURSOR_BOTTOM_LEFT_CORNER* = 19 # Inherit from parent window.
+  GLUT_CURSOR_INHERIT* = 100  # Blank cursor.
+  GLUT_CURSOR_NONE* = 101     # Fullscreen crosshair (if available).
+  GLUT_CURSOR_FULL_CROSSHAIR* = 102 # GLUT device control sub-API.
+                                    # glutSetKeyRepeat modes.
+  GLUT_KEY_REPEAT_OFF* = 0
+  GLUT_KEY_REPEAT_ON* = 1
+  GLUT_KEY_REPEAT_DEFAULT* = 2 # Joystick button masks.
+  GLUT_JOYSTICK_BUTTON_A* = 1
+  GLUT_JOYSTICK_BUTTON_B* = 2
+  GLUT_JOYSTICK_BUTTON_C* = 4
+  GLUT_JOYSTICK_BUTTON_D* = 8 # GLUT game mode sub-API.
+                              # glutGameModeGet.
+  GLUT_GAME_MODE_ACTIVE* = 0
+  GLUT_GAME_MODE_POSSIBLE* = 1
+  GLUT_GAME_MODE_WIDTH* = 2
+  GLUT_GAME_MODE_HEIGHT* = 3
+  GLUT_GAME_MODE_PIXEL_DEPTH* = 4
+  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, 
+    importc: "glutInit".}
+
+proc glutInit*() =
+  ## version that passes `argc` and `argc` implicitely.
+  var
+    cmdLine {.importc: "cmdLine".}: array[0..255, cstring]
+    cmdCount {.importc: "cmdCount".}: cint
+  glutInit(addr(cmdCount), addr(cmdLine))
+
+proc glutInitDisplayMode*(mode: int16){.dynlib: dllname, 
+                                        importc: "glutInitDisplayMode".}
+proc glutInitDisplayString*(str: cstring){.dynlib: dllname, 
+    importc: "glutInitDisplayString".}
+proc glutInitWindowPosition*(x, y: int){.dynlib: dllname, 
+    importc: "glutInitWindowPosition".}
+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, 
+    importc: "glutCreateWindow".}
+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, 
+    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, 
+    importc: "glutSetWindowTitle".}
+proc glutSetIconTitle*(title: cstring){.dynlib: dllname, 
+                                        importc: "glutSetIconTitle".}
+proc glutPositionWindow*(x, y: int){.dynlib: dllname, 
+                                     importc: "glutPositionWindow".}
+proc glutReshapeWindow*(width, height: int){.dynlib: dllname, 
+    importc: "glutReshapeWindow".}
+proc glutPopWindow*(){.dynlib: dllname, importc: "glutPopWindow".}
+proc glutPushWindow*(){.dynlib: dllname, importc: "glutPushWindow".}
+proc glutIconifyWindow*(){.dynlib: dllname, importc: "glutIconifyWindow".}
+proc glutShowWindow*(){.dynlib: dllname, importc: "glutShowWindow".}
+proc glutHideWindow*(){.dynlib: dllname, importc: "glutHideWindow".}
+proc glutFullScreen*(){.dynlib: dllname, importc: "glutFullScreen".}
+proc glutSetCursor*(cursor: int){.dynlib: dllname, importc: "glutSetCursor".}
+proc glutWarpPointer*(x, y: int){.dynlib: dllname, importc: "glutWarpPointer".}
+  # GLUT overlay sub-API.
+proc glutEstablishOverlay*(){.dynlib: dllname, importc: "glutEstablishOverlay".}
+proc glutRemoveOverlay*(){.dynlib: dllname, importc: "glutRemoveOverlay".}
+proc glutUseLayer*(layer: TGLenum){.dynlib: dllname, importc: "glutUseLayer".}
+proc glutPostOverlayRedisplay*(){.dynlib: dllname, 
+                                  importc: "glutPostOverlayRedisplay".}
+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, 
+    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, 
+    importc: "glutAddMenuEntry".}
+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, 
+                                     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, 
+    importc: "glutDisplayFunc".}
+proc glutReshapeFunc*(f: TGlut2IntCallback){.dynlib: dllname, 
+    importc: "glutReshapeFunc".}
+proc glutKeyboardFunc*(f: TGlut1Char2IntCallback){.dynlib: dllname, 
+    importc: "glutKeyboardFunc".}
+proc glutMouseFunc*(f: TGlut4IntCallback){.dynlib: dllname, 
+    importc: "glutMouseFunc".}
+proc glutMotionFunc*(f: TGlut2IntCallback){.dynlib: dllname, 
+    importc: "glutMotionFunc".}
+proc glutPassiveMotionFunc*(f: TGlut2IntCallback){.dynlib: dllname, 
+    importc: "glutPassiveMotionFunc".}
+proc glutEntryFunc*(f: TGlut1IntCallback){.dynlib: dllname, 
+    importc: "glutEntryFunc".}
+proc glutVisibilityFunc*(f: TGlut1IntCallback){.dynlib: dllname, 
+    importc: "glutVisibilityFunc".}
+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, 
+    importc: "glutMenuStateFunc".}
+proc glutSpecialFunc*(f: TGlut3IntCallback){.dynlib: dllname, 
+    importc: "glutSpecialFunc".}
+proc glutSpaceballMotionFunc*(f: TGlut3IntCallback){.dynlib: dllname, 
+    importc: "glutSpaceballMotionFunc".}
+proc glutSpaceballRotateFunc*(f: TGlut3IntCallback){.dynlib: dllname, 
+    importc: "glutSpaceballRotateFunc".}
+proc glutSpaceballButtonFunc*(f: TGlut2IntCallback){.dynlib: dllname, 
+    importc: "glutSpaceballButtonFunc".}
+proc glutButtonBoxFunc*(f: TGlut2IntCallback){.dynlib: dllname, 
+    importc: "glutButtonBoxFunc".}
+proc glutDialsFunc*(f: TGlut2IntCallback){.dynlib: dllname, 
+    importc: "glutDialsFunc".}
+proc glutTabletMotionFunc*(f: TGlut2IntCallback){.dynlib: dllname, 
+    importc: "glutTabletMotionFunc".}
+proc glutTabletButtonFunc*(f: TGlut4IntCallback){.dynlib: dllname, 
+    importc: "glutTabletButtonFunc".}
+proc glutMenuStatusFunc*(f: TGlut3IntCallback){.dynlib: dllname, 
+    importc: "glutMenuStatusFunc".}
+proc glutOverlayDisplayFunc*(f: TGlutVoidCallback){.dynlib: dllname, 
+    importc: "glutOverlayDisplayFunc".}
+proc glutWindowStatusFunc*(f: TGlut1IntCallback){.dynlib: dllname, 
+    importc: "glutWindowStatusFunc".}
+proc glutKeyboardUpFunc*(f: TGlut1Char2IntCallback){.dynlib: dllname, 
+    importc: "glutKeyboardUpFunc".}
+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, 
+    importc: "glutSetColor".}
+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, 
+    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, 
+    importc: "glutBitmapCharacter".}
+proc glutBitmapWidth*(font: pointer, character: int): int{.dynlib: dllname, 
+    importc: "glutBitmapWidth".}
+proc glutStrokeCharacter*(font: pointer, character: int){.dynlib: dllname, 
+    importc: "glutStrokeCharacter".}
+proc glutStrokeWidth*(font: pointer, character: int): int{.dynlib: dllname, 
+    importc: "glutStrokeWidth".}
+proc glutBitmapLength*(font: pointer, str: cstring): int{.dynlib: dllname, 
+    importc: "glutBitmapLength".}
+proc glutStrokeLength*(font: pointer, str: cstring): int{.dynlib: dllname, 
+    importc: "glutStrokeLength".}
+  # GLUT pre-built models sub-API
+proc glutWireSphere*(radius: TGLdouble, slices, stacks: TGLint){.
+    dynlib: dllname, importc: "glutWireSphere".}
+proc glutSolidSphere*(radius: TGLdouble, slices, stacks: TGLint){.
+    dynlib: dllname, importc: "glutSolidSphere".}
+proc glutWireCone*(base, height: TGLdouble, slices, stacks: TGLint){.
+    dynlib: dllname, importc: "glutWireCone".}
+proc glutSolidCone*(base, height: TGLdouble, slices, stacks: TGLint){.
+    dynlib: dllname, importc: "glutSolidCone".}
+proc glutWireCube*(size: TGLdouble){.dynlib: dllname, importc: "glutWireCube".}
+proc glutSolidCube*(size: TGLdouble){.dynlib: dllname, importc: "glutSolidCube".}
+proc glutWireTorus*(innerRadius, outerRadius: TGLdouble, sides, rings: TGLint){.
+    dynlib: dllname, importc: "glutWireTorus".}
+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, 
+                                       importc: "glutWireTeapot".}
+proc glutSolidTeapot*(size: TGLdouble){.dynlib: dllname, 
+                                        importc: "glutSolidTeapot".}
+proc glutWireOctahedron*(){.dynlib: dllname, importc: "glutWireOctahedron".}
+proc glutSolidOctahedron*(){.dynlib: dllname, importc: "glutSolidOctahedron".}
+proc glutWireTetrahedron*(){.dynlib: dllname, importc: "glutWireTetrahedron".}
+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, 
+    importc: "glutVideoResizeGet".}
+proc glutSetupVideoResizing*(){.dynlib: dllname, 
+                                importc: "glutSetupVideoResizing".}
+proc glutStopVideoResizing*(){.dynlib: dllname, importc: "glutStopVideoResizing".}
+proc glutVideoResize*(x, y, width, height: int){.dynlib: dllname, 
+    importc: "glutVideoResize".}
+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, 
+                                        importc: "glutIgnoreKeyRepeat".}
+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, 
+    importc: "glutGameModeString".}
+proc glutEnterGameMode*(): int{.dynlib: dllname, importc: "glutEnterGameMode".}
+proc glutLeaveGameMode*(){.dynlib: dllname, importc: "glutLeaveGameMode".}
+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
new file mode 100644
index 000000000..76c052d70
--- /dev/null
+++ b/tests/manyloc/keineschweine/lib/glx.nim
@@ -0,0 +1,153 @@
+#
+#
+#  Translation of the Mesa GLX headers for FreePascal
+#  Copyright (C) 1999 Sebastian Guenther
+#
+#
+#  Mesa 3-D graphics library
+#  Version:  3.0
+#  Copyright (C) 1995-1998  Brian Paul
+#
+#  This library is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU Library General Public
+#  License as published by the Free Software Foundation; either
+#  version 2 of the License, or (at your option) any later version.
+#
+#  This library is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+#  Library General Public License for more details.
+#
+#  You should have received a copy of the GNU Library General Public
+#  License along with this library; if not, write to the Free
+#  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+
+import 
+  X, XLib, XUtil, gl
+
+when defined(windows): 
+  const 
+    dllname = "GL.dll"
+elif defined(macosx): 
+  const 
+    dllname = "/usr/X11R6/lib/libGL.dylib"
+else: 
+  const 
+    dllname = "libGL.so"
+const 
+  GLX_USE_GL* = 1
+  GLX_BUFFER_SIZE* = 2
+  GLX_LEVEL* = 3
+  GLX_RGBA* = 4
+  GLX_DOUBLEBUFFER* = 5
+  GLX_STEREO* = 6
+  GLX_AUX_BUFFERS* = 7
+  GLX_RED_SIZE* = 8
+  GLX_GREEN_SIZE* = 9
+  GLX_BLUE_SIZE* = 10
+  GLX_ALPHA_SIZE* = 11
+  GLX_DEPTH_SIZE* = 12
+  GLX_STENCIL_SIZE* = 13
+  GLX_ACCUM_RED_SIZE* = 14
+  GLX_ACCUM_GREEN_SIZE* = 15
+  GLX_ACCUM_BLUE_SIZE* = 16
+  GLX_ACCUM_ALPHA_SIZE* = 17  # GLX_EXT_visual_info extension
+  GLX_X_VISUAL_TYPE_EXT* = 0x00000022
+  GLX_TRANSPARENT_TYPE_EXT* = 0x00000023
+  GLX_TRANSPARENT_INDEX_VALUE_EXT* = 0x00000024
+  GLX_TRANSPARENT_RED_VALUE_EXT* = 0x00000025
+  GLX_TRANSPARENT_GREEN_VALUE_EXT* = 0x00000026
+  GLX_TRANSPARENT_BLUE_VALUE_EXT* = 0x00000027
+  GLX_TRANSPARENT_ALPHA_VALUE_EXT* = 0x00000028 # Error codes returned by glXGetConfig:
+  GLX_BAD_SCREEN* = 1
+  GLX_BAD_ATTRIBUTE* = 2
+  GLX_NO_EXTENSION* = 3
+  GLX_BAD_VISUAL* = 4
+  GLX_BAD_CONTEXT* = 5
+  GLX_BAD_VALUE* = 6
+  GLX_BAD_ENUM* = 7           # GLX 1.1 and later:
+  GLX_VENDOR* = 1
+  GLX_VERSION* = 2
+  GLX_EXTENSIONS* = 3         # GLX_visual_info extension
+  GLX_TRUE_COLOR_EXT* = 0x00008002
+  GLX_DIRECT_COLOR_EXT* = 0x00008003
+  GLX_PSEUDO_COLOR_EXT* = 0x00008004
+  GLX_STATIC_COLOR_EXT* = 0x00008005
+  GLX_GRAY_SCALE_EXT* = 0x00008006
+  GLX_STATIC_GRAY_EXT* = 0x00008007
+  GLX_NONE_EXT* = 0x00008000
+  GLX_TRANSPARENT_RGB_EXT* = 0x00008008
+  GLX_TRANSPARENT_INDEX_EXT* = 0x00008009
+
+type                          # From XLib:
+  XPixmap* = TXID
+  XFont* = TXID
+  XColormap* = TXID
+  GLXContext* = Pointer
+  GLXPixmap* = TXID
+  GLXDrawable* = TXID
+  GLXContextID* = TXID
+  TXPixmap* = XPixmap
+  TXFont* = XFont
+  TXColormap* = XColormap
+  TGLXContext* = GLXContext
+  TGLXPixmap* = GLXPixmap
+  TGLXDrawable* = GLXDrawable
+  TGLXContextID* = GLXContextID
+
+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, 
+    importc: "glXCreateContext".}
+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, 
+    dynlib: dllname, importc: "glXCopyContext".}
+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, 
+    dynlib: dllname, importc: "glXDestroyGLXPixmap".}
+proc glXQueryExtension*(dpy: PDisplay, errorb, event: var int): bool{.cdecl, 
+    dynlib: dllname, importc: "glXQueryExtension".}
+proc glXQueryVersion*(dpy: PDisplay, maj, min: var int): bool{.cdecl, 
+    dynlib: dllname, importc: "glXQueryVersion".}
+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, 
+    importc: "glXGetConfig".}
+proc glXGetCurrentContext*(): GLXContext{.cdecl, dynlib: dllname, 
+    importc: "glXGetCurrentContext".}
+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, 
+    importc: "glXUseXFont".}
+  # GLX 1.1 and later
+proc glXQueryExtensionsString*(dpy: PDisplay, screen: int): cstring{.cdecl, 
+    dynlib: dllname, importc: "glXQueryExtensionsString".}
+proc glXQueryServerString*(dpy: PDisplay, screen, name: int): cstring{.cdecl, 
+    dynlib: dllname, importc: "glXQueryServerString".}
+proc glXGetClientString*(dpy: PDisplay, name: int): cstring{.cdecl, 
+    dynlib: dllname, importc: "glXGetClientString".}
+  # Mesa GLX Extensions
+proc glXCreateGLXPixmapMESA*(dpy: PDisplay, visual: PXVisualInfo, 
+                             pixmap: XPixmap, cmap: XColormap): GLXPixmap{.
+    cdecl, dynlib: dllname, importc: "glXCreateGLXPixmapMESA".}
+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, 
+    importc: "glXCopySubBufferMESA".}
+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".}
+# implementation
diff --git a/tests/manyloc/keineschweine/lib/wingl.nim b/tests/manyloc/keineschweine/lib/wingl.nim
new file mode 100644
index 000000000..7ed78f970
--- /dev/null
+++ b/tests/manyloc/keineschweine/lib/wingl.nim
@@ -0,0 +1,368 @@
+import 
+  gl, windows
+
+proc wglGetExtensionsStringARB*(hdc: HDC): cstring{.dynlib: dllname, 
+    importc: "wglGetExtensionsStringARB".}
+const 
+  WGL_FRONT_COLOR_BUFFER_BIT_ARB* = 0x00000001
+  WGL_BACK_COLOR_BUFFER_BIT_ARB* = 0x00000002
+  WGL_DEPTH_BUFFER_BIT_ARB* = 0x00000004
+  WGL_STENCIL_BUFFER_BIT_ARB* = 0x00000008
+
+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, 
+    importc: "wglDeleteBufferRegionARB".}
+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, 
+    importc: "wglRestoreBufferRegionARB".}
+proc wglAllocateMemoryNV*(size: TGLsizei, readFrequency: TGLfloat, 
+                          writeFrequency: TGLfloat, priority: TGLfloat): PGLvoid{.
+    dynlib: dllname, importc: "wglAllocateMemoryNV".}
+proc wglFreeMemoryNV*(pointer: PGLvoid){.dynlib: dllname, 
+    importc: "wglFreeMemoryNV".}
+const 
+  WGL_IMAGE_BUFFER_MIN_ACCESS_I3D* = 0x00000001
+  WGL_IMAGE_BUFFER_LOCK_I3D* = 0x00000002
+
+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, 
+    importc: "wglAssociateImageBufferEventsI3D".}
+proc wglReleaseImageBufferEventsI3D*(hdc: HDC, pAddress: PGLvoid, count: UINT): BOOL{.
+    dynlib: dllname, importc: "wglReleaseImageBufferEventsI3D".}
+proc wglEnableFrameLockI3D*(): BOOL{.dynlib: dllname, 
+                                     importc: "wglEnableFrameLockI3D".}
+proc wglDisableFrameLockI3D*(): BOOL{.dynlib: dllname, 
+                                      importc: "wglDisableFrameLockI3D".}
+proc wglIsEnabledFrameLockI3D*(pFlag: PBOOL): BOOL{.dynlib: dllname, 
+    importc: "wglIsEnabledFrameLockI3D".}
+proc wglQueryFrameLockMasterI3D*(pFlag: PBOOL): BOOL{.dynlib: dllname, 
+    importc: "wglQueryFrameLockMasterI3D".}
+proc wglGetFrameUsageI3D*(pUsage: PGLfloat): BOOL{.dynlib: dllname, 
+    importc: "wglGetFrameUsageI3D".}
+proc wglBeginFrameTrackingI3D*(): BOOL{.dynlib: dllname, 
+                                        importc: "wglBeginFrameTrackingI3D".}
+proc wglEndFrameTrackingI3D*(): BOOL{.dynlib: dllname, 
+                                      importc: "wglEndFrameTrackingI3D".}
+proc wglQueryFrameTrackingI3D*(pFrameCount: PDWORD, pMissedFrames: PDWORD, 
+                               pLastMissedUsage: PGLfloat): BOOL{.
+    dynlib: dllname, importc: "wglQueryFrameTrackingI3D".}
+const 
+  WGL_NUMBER_PIXEL_FORMATS_ARB* = 0x00002000
+  WGL_DRAW_TO_WINDOW_ARB* = 0x00002001
+  WGL_DRAW_TO_BITMAP_ARB* = 0x00002002
+  WGL_ACCELERATION_ARB* = 0x00002003
+  WGL_NEED_PALETTE_ARB* = 0x00002004
+  WGL_NEED_SYSTEM_PALETTE_ARB* = 0x00002005
+  WGL_SWAP_LAYER_BUFFERS_ARB* = 0x00002006
+  WGL_SWAP_METHOD_ARB* = 0x00002007
+  WGL_NUMBER_OVERLAYS_ARB* = 0x00002008
+  WGL_NUMBER_UNDERLAYS_ARB* = 0x00002009
+  WGL_TRANSPARENT_ARB* = 0x0000200A
+  WGL_TRANSPARENT_RED_VALUE_ARB* = 0x00002037
+  WGL_TRANSPARENT_GREEN_VALUE_ARB* = 0x00002038
+  WGL_TRANSPARENT_BLUE_VALUE_ARB* = 0x00002039
+  WGL_TRANSPARENT_ALPHA_VALUE_ARB* = 0x0000203A
+  WGL_TRANSPARENT_INDEX_VALUE_ARB* = 0x0000203B
+  WGL_SHARE_DEPTH_ARB* = 0x0000200C
+  WGL_SHARE_STENCIL_ARB* = 0x0000200D
+  WGL_SHARE_ACCUM_ARB* = 0x0000200E
+  WGL_SUPPORT_GDI_ARB* = 0x0000200F
+  WGL_SUPPORT_OPENGL_ARB* = 0x00002010
+  WGL_DOUBLE_BUFFER_ARB* = 0x00002011
+  WGL_STEREO_ARB* = 0x00002012
+  WGL_PIXEL_TYPE_ARB* = 0x00002013
+  WGL_COLOR_BITS_ARB* = 0x00002014
+  WGL_RED_BITS_ARB* = 0x00002015
+  WGL_RED_SHIFT_ARB* = 0x00002016
+  WGL_GREEN_BITS_ARB* = 0x00002017
+  WGL_GREEN_SHIFT_ARB* = 0x00002018
+  WGL_BLUE_BITS_ARB* = 0x00002019
+  WGL_BLUE_SHIFT_ARB* = 0x0000201A
+  WGL_ALPHA_BITS_ARB* = 0x0000201B
+  WGL_ALPHA_SHIFT_ARB* = 0x0000201C
+  WGL_ACCUM_BITS_ARB* = 0x0000201D
+  WGL_ACCUM_RED_BITS_ARB* = 0x0000201E
+  WGL_ACCUM_GREEN_BITS_ARB* = 0x0000201F
+  WGL_ACCUM_BLUE_BITS_ARB* = 0x00002020
+  WGL_ACCUM_ALPHA_BITS_ARB* = 0x00002021
+  WGL_DEPTH_BITS_ARB* = 0x00002022
+  WGL_STENCIL_BITS_ARB* = 0x00002023
+  WGL_AUX_BUFFERS_ARB* = 0x00002024
+  WGL_NO_ACCELERATION_ARB* = 0x00002025
+  WGL_GENERIC_ACCELERATION_ARB* = 0x00002026
+  WGL_FULL_ACCELERATION_ARB* = 0x00002027
+  WGL_SWAP_EXCHANGE_ARB* = 0x00002028
+  WGL_SWAP_COPY_ARB* = 0x00002029
+  WGL_SWAP_UNDEFINED_ARB* = 0x0000202A
+  WGL_TYPE_RGBA_ARB* = 0x0000202B
+  WGL_TYPE_COLORINDEX_ARB* = 0x0000202C
+
+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, 
+                                   piAttributes: PGLint, pfValues: PGLfloat): BOOL{.
+    dynlib: dllname, importc: "wglGetPixelFormatAttribfvARB".}
+proc wglChoosePixelFormatARB*(hdc: HDC, piAttribIList: PGLint, 
+                              pfAttribFList: PGLfloat, nMaxFormats: TGLuint, 
+                              piFormats: PGLint, nNumFormats: PGLuint): BOOL{.
+    dynlib: dllname, importc: "wglChoosePixelFormatARB".}
+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, 
+                                     importc: "wglGetCurrentReadDCARB".}
+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
+  WGL_MAX_PBUFFER_HEIGHT_ARB* = 0x00002030
+  WGL_PBUFFER_LARGEST_ARB* = 0x00002033
+  WGL_PBUFFER_WIDTH_ARB* = 0x00002034
+  WGL_PBUFFER_HEIGHT_ARB* = 0x00002035
+  WGL_PBUFFER_LOST_ARB* = 0x00002036
+
+proc wglCreatePbufferARB*(hDC: HDC, iPixelFormat: TGLint, iWidth: TGLint, 
+                          iHeight: TGLint, piAttribList: PGLint): THandle{.
+    dynlib: dllname, importc: "wglCreatePbufferARB".}
+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, 
+    importc: "wglDestroyPbufferARB".}
+proc wglQueryPbufferARB*(hPbuffer: THandle, iAttribute: TGLint, piValue: PGLint): BOOL{.
+    dynlib: dllname, importc: "wglQueryPbufferARB".}
+proc wglSwapIntervalEXT*(interval: TGLint): BOOL{.dynlib: dllname, 
+    importc: "wglSwapIntervalEXT".}
+proc wglGetSwapIntervalEXT*(): TGLint{.dynlib: dllname, 
+                                       importc: "wglGetSwapIntervalEXT".}
+const 
+  WGL_BIND_TO_TEXTURE_RGB_ARB* = 0x00002070
+  WGL_BIND_TO_TEXTURE_RGBA_ARB* = 0x00002071
+  WGL_TEXTURE_FORMAT_ARB* = 0x00002072
+  WGL_TEXTURE_TARGET_ARB* = 0x00002073
+  WGL_MIPMAP_TEXTURE_ARB* = 0x00002074
+  WGL_TEXTURE_RGB_ARB* = 0x00002075
+  WGL_TEXTURE_RGBA_ARB* = 0x00002076
+  WGL_NO_TEXTURE_ARB* = 0x00002077
+  WGL_TEXTURE_CUBE_MAP_ARB* = 0x00002078
+  WGL_TEXTURE_1D_ARB* = 0x00002079
+  WGL_TEXTURE_2D_ARB* = 0x0000207A # WGL_NO_TEXTURE_ARB  { already defined }
+  WGL_MIPMAP_LEVEL_ARB* = 0x0000207B
+  WGL_CUBE_MAP_FACE_ARB* = 0x0000207C
+  WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB* = 0x0000207D
+  WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB* = 0x0000207E
+  WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB* = 0x0000207F
+  WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB* = 0x00002080
+  WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB* = 0x00002081
+  WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB* = 0x00002082
+  WGL_FRONT_LEFT_ARB* = 0x00002083
+  WGL_FRONT_RIGHT_ARB* = 0x00002084
+  WGL_BACK_LEFT_ARB* = 0x00002085
+  WGL_BACK_RIGHT_ARB* = 0x00002086
+  WGL_AUX0_ARB* = 0x00002087
+  WGL_AUX1_ARB* = 0x00002088
+  WGL_AUX2_ARB* = 0x00002089
+  WGL_AUX3_ARB* = 0x0000208A
+  WGL_AUX4_ARB* = 0x0000208B
+  WGL_AUX5_ARB* = 0x0000208C
+  WGL_AUX6_ARB* = 0x0000208D
+  WGL_AUX7_ARB* = 0x0000208E
+  WGL_AUX8_ARB* = 0x0000208F
+  WGL_AUX9_ARB* = 0x00002090
+
+proc wglBindTexImageARB*(hPbuffer: THandle, iBuffer: TGLint): BOOL{.
+    dynlib: dllname, importc: "wglBindTexImageARB".}
+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, 
+    importc: "wglGetExtensionsStringEXT".}
+proc wglMakeContextCurrentEXT*(hDrawDC: HDC, hReadDC: HDC, hglrc: HGLRC): BOOL{.
+    dynlib: dllname, importc: "wglMakeContextCurrentEXT".}
+proc wglGetCurrentReadDCEXT*(): HDC{.dynlib: dllname, 
+                                     importc: "wglGetCurrentReadDCEXT".}
+const 
+  WGL_DRAW_TO_PBUFFER_EXT* = 0x0000202D
+  WGL_MAX_PBUFFER_PIXELS_EXT* = 0x0000202E
+  WGL_MAX_PBUFFER_WIDTH_EXT* = 0x0000202F
+  WGL_MAX_PBUFFER_HEIGHT_EXT* = 0x00002030
+  WGL_OPTIMAL_PBUFFER_WIDTH_EXT* = 0x00002031
+  WGL_OPTIMAL_PBUFFER_HEIGHT_EXT* = 0x00002032
+  WGL_PBUFFER_LARGEST_EXT* = 0x00002033
+  WGL_PBUFFER_WIDTH_EXT* = 0x00002034
+  WGL_PBUFFER_HEIGHT_EXT* = 0x00002035
+
+proc wglCreatePbufferEXT*(hDC: HDC, iPixelFormat: TGLint, iWidth: TGLint, 
+                          iHeight: TGLint, piAttribList: PGLint): THandle{.
+    dynlib: dllname, importc: "wglCreatePbufferEXT".}
+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, 
+    importc: "wglDestroyPbufferEXT".}
+proc wglQueryPbufferEXT*(hPbuffer: THandle, iAttribute: TGLint, piValue: PGLint): BOOL{.
+    dynlib: dllname, importc: "wglQueryPbufferEXT".}
+const 
+  WGL_NUMBER_PIXEL_FORMATS_EXT* = 0x00002000
+  WGL_DRAW_TO_WINDOW_EXT* = 0x00002001
+  WGL_DRAW_TO_BITMAP_EXT* = 0x00002002
+  WGL_ACCELERATION_EXT* = 0x00002003
+  WGL_NEED_PALETTE_EXT* = 0x00002004
+  WGL_NEED_SYSTEM_PALETTE_EXT* = 0x00002005
+  WGL_SWAP_LAYER_BUFFERS_EXT* = 0x00002006
+  WGL_SWAP_METHOD_EXT* = 0x00002007
+  WGL_NUMBER_OVERLAYS_EXT* = 0x00002008
+  WGL_NUMBER_UNDERLAYS_EXT* = 0x00002009
+  WGL_TRANSPARENT_EXT* = 0x0000200A
+  WGL_TRANSPARENT_VALUE_EXT* = 0x0000200B
+  WGL_SHARE_DEPTH_EXT* = 0x0000200C
+  WGL_SHARE_STENCIL_EXT* = 0x0000200D
+  WGL_SHARE_ACCUM_EXT* = 0x0000200E
+  WGL_SUPPORT_GDI_EXT* = 0x0000200F
+  WGL_SUPPORT_OPENGL_EXT* = 0x00002010
+  WGL_DOUBLE_BUFFER_EXT* = 0x00002011
+  WGL_STEREO_EXT* = 0x00002012
+  WGL_PIXEL_TYPE_EXT* = 0x00002013
+  WGL_COLOR_BITS_EXT* = 0x00002014
+  WGL_RED_BITS_EXT* = 0x00002015
+  WGL_RED_SHIFT_EXT* = 0x00002016
+  WGL_GREEN_BITS_EXT* = 0x00002017
+  WGL_GREEN_SHIFT_EXT* = 0x00002018
+  WGL_BLUE_BITS_EXT* = 0x00002019
+  WGL_BLUE_SHIFT_EXT* = 0x0000201A
+  WGL_ALPHA_BITS_EXT* = 0x0000201B
+  WGL_ALPHA_SHIFT_EXT* = 0x0000201C
+  WGL_ACCUM_BITS_EXT* = 0x0000201D
+  WGL_ACCUM_RED_BITS_EXT* = 0x0000201E
+  WGL_ACCUM_GREEN_BITS_EXT* = 0x0000201F
+  WGL_ACCUM_BLUE_BITS_EXT* = 0x00002020
+  WGL_ACCUM_ALPHA_BITS_EXT* = 0x00002021
+  WGL_DEPTH_BITS_EXT* = 0x00002022
+  WGL_STENCIL_BITS_EXT* = 0x00002023
+  WGL_AUX_BUFFERS_EXT* = 0x00002024
+  WGL_NO_ACCELERATION_EXT* = 0x00002025
+  WGL_GENERIC_ACCELERATION_EXT* = 0x00002026
+  WGL_FULL_ACCELERATION_EXT* = 0x00002027
+  WGL_SWAP_EXCHANGE_EXT* = 0x00002028
+  WGL_SWAP_COPY_EXT* = 0x00002029
+  WGL_SWAP_UNDEFINED_EXT* = 0x0000202A
+  WGL_TYPE_RGBA_EXT* = 0x0000202B
+  WGL_TYPE_COLORINDEX_EXT* = 0x0000202C
+
+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, 
+                                   piAttributes: PGLint, pfValues: PGLfloat): BOOL{.
+    dynlib: dllname, importc: "wglGetPixelFormatAttribfvEXT".}
+proc wglChoosePixelFormatEXT*(hdc: HDC, piAttribIList: PGLint, 
+                              pfAttribFList: PGLfloat, nMaxFormats: TGLuint, 
+                              piFormats: PGLint, nNumFormats: PGLuint): BOOL{.
+    dynlib: dllname, importc: "wglChoosePixelFormatEXT".}
+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, 
+    importc: "wglGetDigitalVideoParametersI3D".}
+proc wglSetDigitalVideoParametersI3D*(hDC: HDC, iAttribute: TGLint, 
+                                      piValue: PGLint): BOOL{.dynlib: dllname, 
+    importc: "wglSetDigitalVideoParametersI3D".}
+const 
+  WGL_GAMMA_TABLE_SIZE_I3D* = 0x0000204E
+  WGL_GAMMA_EXCLUDE_DESKTOP_I3D* = 0x0000204F
+
+proc wglGetGammaTableParametersI3D*(hDC: HDC, iAttribute: TGLint, 
+                                    piValue: PGLint): BOOL{.dynlib: dllname, 
+    importc: "wglGetGammaTableParametersI3D".}
+proc wglSetGammaTableParametersI3D*(hDC: HDC, iAttribute: TGLint, 
+                                    piValue: PGLint): BOOL{.dynlib: dllname, 
+    importc: "wglSetGammaTableParametersI3D".}
+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, 
+                          puGreen: PGLUSHORT, puBlue: PGLUSHORT): BOOL{.
+    dynlib: dllname, importc: "wglSetGammaTableI3D".}
+const 
+  WGL_GENLOCK_SOURCE_MULTIVIEW_I3D* = 0x00002044
+  WGL_GENLOCK_SOURCE_EXTERNAL_SYNC_I3D* = 0x00002045
+  WGL_GENLOCK_SOURCE_EXTERNAL_FIELD_I3D* = 0x00002046
+  WGL_GENLOCK_SOURCE_EXTERNAL_TTL_I3D* = 0x00002047
+  WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D* = 0x00002048
+  WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D* = 0x00002049
+  WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D* = 0x0000204A
+  WGL_GENLOCK_SOURCE_EDGE_RISING_I3D* = 0x0000204B
+  WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D* = 0x0000204C
+  WGL_FLOAT_COMPONENTS_NV* = 0x000020B0
+  WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV* = 0x000020B1
+  WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV* = 0x000020B2
+  WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV* = 0x000020B3
+  WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV* = 0x000020B4
+  WGL_TEXTURE_FLOAT_R_NV* = 0x000020B5
+  WGL_TEXTURE_FLOAT_RG_NV* = 0x000020B6
+  WGL_TEXTURE_FLOAT_RGB_NV* = 0x000020B7
+  WGL_TEXTURE_FLOAT_RGBA_NV* = 0x000020B8
+
+proc wglEnableGenlockI3D*(hDC: HDC): BOOL{.dynlib: dllname, 
+    importc: "wglEnableGenlockI3D".}
+proc wglDisableGenlockI3D*(hDC: HDC): BOOL{.dynlib: dllname, 
+    importc: "wglDisableGenlockI3D".}
+proc wglIsEnabledGenlockI3D*(hDC: HDC, pFlag: PBOOL): BOOL{.dynlib: dllname, 
+    importc: "wglIsEnabledGenlockI3D".}
+proc wglGenlockSourceI3D*(hDC: HDC, uSource: TGLuint): BOOL{.dynlib: dllname, 
+    importc: "wglGenlockSourceI3D".}
+proc wglGetGenlockSourceI3D*(hDC: HDC, uSource: PGLUINT): BOOL{.dynlib: dllname, 
+    importc: "wglGetGenlockSourceI3D".}
+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, 
+    importc: "wglGenlockSampleRateI3D".}
+proc wglGetGenlockSampleRateI3D*(hDC: HDC, uRate: PGLUINT): BOOL{.
+    dynlib: dllname, importc: "wglGetGenlockSampleRateI3D".}
+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, 
+                                       uMaxPixelDelay: PGLUINT): BOOL{.
+    dynlib: dllname, importc: "wglQueryGenlockMaxSourceDelayI3D".}
+const 
+  WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV* = 0x000020A0
+  WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV* = 0x000020A1
+  WGL_TEXTURE_RECTANGLE_NV* = 0x000020A2
+
+const 
+  WGL_RGBA_FLOAT_MODE_ATI* = 0x00008820
+  WGL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI* = 0x00008835
+  WGL_TYPE_RGBA_FLOAT_ATI* = 0x000021A0
+
+# implementation
diff --git a/tests/manyloc/packages/package1/p1.babel b/tests/manyloc/packages/package1/p1.babel
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/manyloc/packages/package1/p1.babel
diff --git a/tests/manyloc/packages/package2/p2.babel b/tests/manyloc/packages/package2/p2.babel
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/manyloc/packages/package2/p2.babel
diff --git a/tests/metatype/tautoproc.nim b/tests/metatype/tautoproc.nim
new file mode 100644
index 000000000..9e8ff0bcb
--- /dev/null
+++ b/tests/metatype/tautoproc.nim
@@ -0,0 +1,16 @@
+# bug #898
+
+proc measureTime(e: auto) =
+  discard
+
+proc generate(a: int): void =
+  discard
+
+proc runExample =
+  var builder: int = 0
+
+  measureTime:
+    builder.generate()
+
+measureTime:
+  discard
diff --git a/tests/misc/tbug1217bracketquotes.nim b/tests/misc/tbug1217bracketquotes.nim
new file mode 100644
index 000000000..90e67d45b
--- /dev/null
+++ b/tests/misc/tbug1217bracketquotes.nim
@@ -0,0 +1,14 @@
+discard """
+  output: "13{(.{}}{*4&*$**()&*@1235"
+"""
+
+type
+  Test = enum
+    `1`, `3`, `{`, `(.`, `{}}{`, `*4&*$**()&*@`
+
+let `.}` = 1
+let `(}` = 2
+let `[` = 3
+let `]` = 5
+
+echo `1`, `3`, `{`, `(.`, `{}}{`, `*4&*$**()&*@`, `.}`, `(}`, `[`, `]`
diff --git a/tests/notnil/tnotnil4.nim b/tests/notnil/tnotnil4.nim
new file mode 100644
index 000000000..23968ee48
--- /dev/null
+++ b/tests/notnil/tnotnil4.nim
@@ -0,0 +1,14 @@
+discard ""
+type
+   TObj = ref object
+
+proc check(a: TObj not nil) =
+  echo repr(a)
+
+proc doit() =
+   var x : array[0..1, TObj]
+
+   if x[0] != nil:
+      check(x[0])
+
+doit()
\ No newline at end of file
diff --git a/tests/objects/tobjconstr2.nim b/tests/objects/tobjconstr2.nim
index cb47e146d..8ef7004e4 100644
--- a/tests/objects/tobjconstr2.nim
+++ b/tests/objects/tobjconstr2.nim
@@ -20,3 +20,15 @@ type
 
 var a = Bar(y: 100, x: 200) # works
 var b = Bar(x: 100, y: 200) # used to fail
+
+# bug 1275
+
+type
+  Graphic = object of TObject
+    case kind: range[0..1]
+    of 0:
+      radius: float
+    of 1:
+      size: tuple[w, h: float]
+
+var d = Graphic(kind: 1, size: (12.9, 6.9))
diff --git a/tests/osproc/ta.nim b/tests/osproc/ta.nim
new file mode 100644
index 000000000..6c1495590
--- /dev/null
+++ b/tests/osproc/ta.nim
@@ -0,0 +1,3 @@
+import strutils
+let x = stdin.readLine()
+echo x.parseInt + 5
\ No newline at end of file
diff --git a/tests/osproc/tstdin.nim b/tests/osproc/tstdin.nim
new file mode 100644
index 000000000..2ea939992
--- /dev/null
+++ b/tests/osproc/tstdin.nim
@@ -0,0 +1,16 @@
+discard """
+  file: "tstdin.nim"
+  output: "10"
+"""
+import osproc, os, streams
+
+doAssert fileExists(getCurrentDir() / "tests" / "osproc" / "ta.exe")
+
+var p = startProcess("ta.exe", getCurrentDir() / "tests" / "osproc")
+p.inputStream.write("5\n")
+while true:
+  let line = p.outputStream.readLine()
+  if line != "":
+    echo line
+  else:
+    break
\ No newline at end of file
diff --git a/tests/parallel/nimrod.cfg b/tests/parallel/nimrod.cfg
new file mode 100644
index 000000000..b81c89721
--- /dev/null
+++ b/tests/parallel/nimrod.cfg
@@ -0,0 +1 @@
+threads:on
diff --git a/tests/parallel/tdisjoint_slice1.nim b/tests/parallel/tdisjoint_slice1.nim
new file mode 100644
index 000000000..c1d0e52f8
--- /dev/null
+++ b/tests/parallel/tdisjoint_slice1.nim
@@ -0,0 +1,21 @@
+discard """
+  outputsub: "EVEN 28"
+"""
+
+import threadpool
+
+proc odd(a: int) =  echo "ODD  ", a
+proc even(a: int) = echo "EVEN ", a
+
+proc main() =
+  var a: array[0..30, int]
+  for i in low(a)..high(a): a[i] = i
+  parallel:
+    var i = 0
+    while i <= 29:
+      spawn even(a[i])
+      spawn odd(a[i+1])
+      inc i, 2
+      # is correct here
+
+main()
diff --git a/tests/parallel/tdisjoint_slice2.nim b/tests/parallel/tdisjoint_slice2.nim
new file mode 100644
index 000000000..1e86ea644
--- /dev/null
+++ b/tests/parallel/tdisjoint_slice2.nim
@@ -0,0 +1,33 @@
+discard """
+  output: '''0
+1
+2
+3
+4
+5
+6
+7
+8'''
+  sortoutput: true
+"""
+
+import threadpool
+
+proc f(a: openArray[int]) =
+  for x in a: echo x
+
+proc f(a: int) = echo a
+
+proc main() =
+  var a: array[0..9, int] = [0,1,2,3,4,5,6,7,8,9]
+  parallel:
+    spawn f(a[0..2])
+    #spawn f(a[16..30])
+    var i = 3
+    while i <= 8:
+      spawn f(a[i])
+      spawn f(a[i+1])
+      inc i, 2
+      # is correct here
+
+main()
diff --git a/tests/parallel/tflowvar.nim b/tests/parallel/tflowvar.nim
new file mode 100644
index 000000000..77fab14b5
--- /dev/null
+++ b/tests/parallel/tflowvar.nim
@@ -0,0 +1,17 @@
+discard """
+  output: '''foobarfoobarbazbearbazbear'''
+  cmd: "nimrod $target --threads:on $options $file"
+"""
+
+import threadpool
+
+proc computeSomething(a, b: string): string = a & b & a & b
+
+proc main =
+  let fvA = spawn computeSomething("foo", "bar")
+  let fvB = spawn computeSomething("baz", "bear")
+
+  echo(^fvA, ^fvB)
+
+main()
+sync()
diff --git a/tests/parallel/tforstmt.nim b/tests/parallel/tforstmt.nim
new file mode 100644
index 000000000..58de833f3
--- /dev/null
+++ b/tests/parallel/tforstmt.nim
@@ -0,0 +1,25 @@
+discard """
+  output: '''3
+4
+5
+6
+7'''
+  sortoutput: true
+"""
+
+import threadpool, os
+
+proc p(x: int) =
+  os.sleep(100 - x*10)
+  echo x
+
+proc testFor(a, b: int; foo: var openArray[int]) =
+  parallel:
+    for i in max(a, 0) .. min(b, foo.high):
+      spawn p(foo[i])
+
+var arr = [0, 1, 2, 3, 4, 5, 6, 7]
+
+testFor(3, 10, arr)
+
+
diff --git a/tests/parallel/tinvalid_array_bounds.nim b/tests/parallel/tinvalid_array_bounds.nim
new file mode 100644
index 000000000..4c6065fd6
--- /dev/null
+++ b/tests/parallel/tinvalid_array_bounds.nim
@@ -0,0 +1,25 @@
+discard """
+  errormsg: "can prove: i + 1 > 30"
+  line: 21
+"""
+
+import threadpool
+
+proc f(a: openArray[int]) =
+  for x in a: echo x
+
+proc f(a: int) = echo a
+
+proc main() =
+  var a: array[0..30, int]
+  parallel:
+    spawn f(a[0..15])
+    spawn f(a[16..30])
+    var i = 0
+    while i <= 30:
+      spawn f(a[i])
+      spawn f(a[i+1])
+      inc i
+      #inc i  # inc i, 2  would be correct here
+
+main()
diff --git a/tests/parallel/tinvalid_counter_usage.nim b/tests/parallel/tinvalid_counter_usage.nim
new file mode 100644
index 000000000..c6303c651
--- /dev/null
+++ b/tests/parallel/tinvalid_counter_usage.nim
@@ -0,0 +1,26 @@
+discard """
+  errormsg: "invalid usage of counter after increment"
+  line: 21
+"""
+
+import threadpool
+
+proc f(a: openArray[int]) =
+  for x in a: echo x
+
+proc f(a: int) = echo a
+
+proc main() =
+  var a: array[0..30, int]
+  parallel:
+    spawn f(a[0..15])
+    spawn f(a[16..30])
+    var i = 0
+    while i <= 30:
+      inc i
+      spawn f(a[i])
+      inc i
+      #spawn f(a[i+1])
+      #inc i  # inc i, 2  would be correct here
+
+main()
diff --git a/tests/parallel/tnon_disjoint_slice1.nim b/tests/parallel/tnon_disjoint_slice1.nim
new file mode 100644
index 000000000..72d008bbd
--- /dev/null
+++ b/tests/parallel/tnon_disjoint_slice1.nim
@@ -0,0 +1,25 @@
+discard """
+  errormsg: "cannot prove (i)..(i) disjoint from (i + 1)..(i + 1)"
+  line: 20
+"""
+
+import threadpool
+
+proc f(a: openArray[int]) =
+  for x in a: echo x
+
+proc f(a: int) = echo a
+
+proc main() =
+  var a: array[0..30, int]
+  parallel:
+    #spawn f(a[0..15])
+    #spawn f(a[16..30])
+    var i = 0
+    while i <= 29:
+      spawn f(a[i])
+      spawn f(a[i+1])
+      inc i
+      #inc i  # inc i, 2  would be correct here
+
+main()
diff --git a/tests/parallel/tpi.nim b/tests/parallel/tpi.nim
new file mode 100644
index 000000000..dcb9b8fc5
--- /dev/null
+++ b/tests/parallel/tpi.nim
@@ -0,0 +1,26 @@
+discard """
+  output: '''3.141792613595791
+3.141792613595791'''
+"""
+
+import strutils, math, threadpool
+
+proc term(k: float): float = 4 * math.pow(-1, k) / (2*k + 1)
+
+proc piU(n: int): float =
+  var ch = newSeq[FlowVar[float]](n+1)
+  for k in 0..n:
+    ch[k] = spawn term(float(k))
+  for k in 0..n:
+    result += ^ch[k]
+
+proc piS(n: int): float =
+  var ch = newSeq[float](n+1)
+  parallel:
+    for k in 0..ch.high:
+      ch[k] = spawn term(float(k))
+  for k in 0..ch.high:
+    result += ch[k]
+
+echo formatFloat(piU(5000))
+echo formatFloat(piS(5000))
diff --git a/tests/system/tsysspawn.nim b/tests/parallel/tsysspawn.nim
index 0388918aa..fc7921b0e 100644
--- a/tests/system/tsysspawn.nim
+++ b/tests/parallel/tsysspawn.nim
@@ -4,20 +4,22 @@ discard """
   cmd: "nimrod $target --threads:on $options $file"
 """
 
+import threadpool
+
 var
   x, y = 0
 
 proc p1 =
-  for i in 0 .. 1_000_000:
+  for i in 0 .. 10_000:
     discard
 
-  inc x
+  atomicInc x
 
 proc p2 =
-  for i in 0 .. 1_000_000:
+  for i in 0 .. 10_000:
     discard
 
-  inc y, 2
+  atomicInc y, 2
 
 for i in 0.. 3:
   spawn(p1())
diff --git a/tests/parallel/tsysspawnbadarg.nim b/tests/parallel/tsysspawnbadarg.nim
new file mode 100644
index 000000000..ad798a7d3
--- /dev/null
+++ b/tests/parallel/tsysspawnbadarg.nim
@@ -0,0 +1,9 @@
+discard """
+  line: 9
+  errormsg: "'spawn' takes a call expression"
+  cmd: "nimrod $target --threads:on $options $file"
+"""
+
+import threadpool
+
+let foo = spawn(1)
diff --git a/tests/seq/tsequtils.nim b/tests/seq/tsequtils.nim
index 7bc15ef9c..3a7eeeffa 100644
--- a/tests/seq/tsequtils.nim
+++ b/tests/seq/tsequtils.nim
@@ -50,6 +50,6 @@ var concatseq = concat(seq1,seq2)
 echo "Concat: ", $$(concatseq)
 
 var seq3 = @[1,2,3,4,5,5,5,7]
-var discntseq = distnct(seq3)
-echo "Distnct: ", $$(discntseq)
+var dedupseq = deduplicate(seq3)
+echo "Deduplicate: ", $$(dedupseq)
 
diff --git a/tests/sets/tsets3.nim b/tests/sets/tsets3.nim
new file mode 100644
index 000000000..f599f8e7d
--- /dev/null
+++ b/tests/sets/tsets3.nim
@@ -0,0 +1,100 @@
+include sets
+
+let
+  s1: TSet[int] = toSet([1, 2, 4, 8, 16])
+  s2: TSet[int] = toSet([1, 2, 3, 5, 8])
+  s3: TSet[int] = toSet([3, 5, 7])
+
+block union:
+  let
+    s1_s2 = union(s1, s2)
+    s1_s3 = s1 + s3
+    s2_s3 = s2 + s3
+
+  assert s1_s2.len == 7
+  assert s1_s3.len == 8
+  assert s2_s3.len == 6
+
+  for i in s1:
+    assert i in s1_s2
+    assert i in s1_s3
+  for i in s2:
+    assert i in s1_s2
+    assert i in s2_s3
+  for i in s3:
+    assert i in s1_s3
+    assert i in s2_s3
+
+  assert((s1 + s1) == s1)
+  assert((s2 + s1) == s1_s2)
+
+block intersection:
+  let
+    s1_s2 = intersection(s1, s2)
+    s1_s3 = intersection(s1, s3)
+    s2_s3 = s2 * s3
+
+  assert s1_s2.len == 3
+  assert s1_s3.len == 0
+  assert s2_s3.len == 2
+
+  for i in s1_s2:
+    assert i in s1
+    assert i in s2
+  for i in s1_s3:
+    assert i in s1
+    assert i in s3
+  for i in s2_s3:
+    assert i in s2
+    assert i in s3
+
+  assert((s2 * s2) == s2)
+  assert((s3 * s2) == s2_s3)
+
+block symmetricDifference:
+  let
+    s1_s2 = symmetricDifference(s1, s2)
+    s1_s3 = s1 -+- s3
+    s2_s3 = s2 -+- s3
+
+  assert s1_s2.len == 4
+  assert s1_s3.len == 8
+  assert s2_s3.len == 4
+
+  for i in s1:
+    assert i in s1_s2 xor i in s2
+    assert i in s1_s3 xor i in s3
+  for i in s2:
+    assert i in s1_s2 xor i in s1
+    assert i in s2_s3 xor i in s3
+  for i in s3:
+    assert i in s1_s3 xor i in s1
+    assert i in s2_s3 xor i in s2
+
+  assert((s3 -+- s3) == initSet[int]())
+  assert((s3 -+- s1) == s1_s3)
+
+block difference:
+  let
+    s1_s2 = difference(s1, s2)
+    s1_s3 = difference(s1, s3)
+    s2_s3 = s2 - s3
+
+  assert s1_s2.len == 2
+  assert s1_s3.len == 5
+  assert s2_s3.len == 3
+
+  for i in s1:
+    assert i in s1_s2 xor i in s2
+    assert i in s1_s3 xor i in s3
+  for i in s2:
+    assert i in s2_s3 xor i in s3
+
+  assert((s2 - s2) == initSet[int]())
+  assert((s1 - s3 - s1) == s1 -+- s3)
+
+block disjoint:
+  assert(not disjoint(s1, s2))
+  assert disjoint(s1, s3)
+  assert(not disjoint(s2, s3))
+  assert(not disjoint(s2, s2))
diff --git a/tests/system/tsysspawnbadarg.nim b/tests/system/tsysspawnbadarg.nim
deleted file mode 100644
index ace074602..000000000
--- a/tests/system/tsysspawnbadarg.nim
+++ /dev/null
@@ -1,7 +0,0 @@
-discard """
-  line: 7
-  errormsg: "'spawn' takes a call expression of type void"
-  cmd: "nimrod $target --threads:on $options $file"
-"""
-
-spawn(1)
diff --git a/tests/template/annotate.nim b/tests/template/annotate.nim
new file mode 100644
index 000000000..fa58030dc
--- /dev/null
+++ b/tests/template/annotate.nim
@@ -0,0 +1,113 @@
+import macros, parseutils
+
+# Generate tags
+macro make(names: openarray[expr]): stmt {.immediate.} =
+    result = newStmtList()
+
+    for i in 0 .. names.len-1:
+        result.add newProc(
+            name   = ident($names[i]).postfix("*"),
+            params = [
+                ident("string"),
+                newIdentDefs(
+                    ident("content"),
+                    ident("string")
+                )
+            ],
+            body = newStmtList(
+                parseStmt("reindent(content)")
+            )
+        )
+
+
+iterator lines(value: string): string =
+    var i = 0
+    while i < value.len:
+        var line: string
+        inc(i, value.parseUntil(line, 0x0A.char, i) + 1)
+        yield line
+
+
+proc reindent*(value: string, preset_indent = 0): string =
+    var indent = -1
+
+    # Detect indentation!
+    for ln in lines(value):
+        var read = ln.skipWhitespace()
+
+        # If the line is empty, ignore it for indentation
+        if read == ln.len: continue
+
+        indent = if indent < 0: read
+                 else: min(indent, read)
+
+    # Create a precursor indent as-needed
+    var precursor = newString(0)
+    for i in 1 .. preset_indent:
+        precursor.add(' ')
+
+    # Re-indent
+    result = newString(0)
+
+    for ln in lines(value):
+        var value = ln.substr(indent)
+
+        result.add(precursor)
+
+        if value.len > 0:
+            result.add(value)
+            result.add(0x0A.char)
+
+    return result
+
+
+#Define tags
+make([ html, xml, glsl, js, css, rst ])
+
+
+when isMainModule:
+    ## Test tags
+
+    const script = js"""
+        var x = 5;
+        console.log(x.toString());
+    """
+
+    const styles = css"""
+        .someRule {
+            width: 500px;
+        }
+    """
+
+    const body = html"""
+        <ul>
+            <li>1</li>
+            <li>2</li>
+            <li>
+                <a hef="#google">google</a>
+            </li>
+        </ul>
+    """
+
+    const info = xml"""
+        <item>
+            <i>1</i>
+            <i>2</i>
+        </item>
+    """
+
+    const shader = glsl"""
+        void main()
+        {
+            gl_Position = gl_ProjectionMatrix
+                        * gl_ModelViewMatrix
+                        * gl_Vertex;
+        }
+    """
+
+
+    echo script
+    echo styles
+    echo body
+    echo info
+    echo shader
\ No newline at end of file
diff --git a/tests/template/otests.nim b/tests/template/otests.nim
new file mode 100644
index 000000000..c885e23df
--- /dev/null
+++ b/tests/template/otests.nim
@@ -0,0 +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"""

+            <p>Test!</p>

+        """

+        const expected = html"""

+            <p>Test!</p>

+        """

+        doAssert actual() == expected

+

+    block: #basic

+        proc actual: string = tmpli html"""

+            <p>Test $$x</p>

+            $x

+        """

+        const expected = html"""

+            <p>Test $x</p>

+            5

+        """

+        doAssert actual() == expected

+

+    block: #expression

+        proc actual: string = tmpli html"""

+            <p>Test $$(x * 5)</p>

+            $(x * 5)

+        """

+        const expected = html"""

+            <p>Test $(x * 5)</p>

+            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"""

+            <p>Test for</p>

+            <ul>

+                $for y in 0..2 {

+                    <li>$y</li>

+                }

+            </ul>

+        """

+        const expected = html"""

+            <p>Test for</p>

+            <ul>

+                <li>0</li>

+                <li>1</li>

+                <li>2</li>

+            </ul>

+        """

+        doAssert actual() == expected

+

+    block: #while

+        proc actual: string = tmpli html"""

+            <p>Test while/stmt</p>

+            <ul>

+                ${ var y = 0 }

+                $while y < 4 {

+                    <li>$y</li>

+                    ${ inc(y) }

+                }

+            </ul>

+        """

+        const expected = html"""

+            <p>Test while/stmt</p>

+            <ul>

+                <li>0</li>

+                <li>1</li>

+                <li>2</li>

+                <li>3</li>

+            </ul>

+        """

+        doAssert actual() == expected

+

+    block: #ifElifElse

+        proc actual: string = tmpli html"""

+            <p>Test if/elif/else</p>

+            $if x == 8 {

+                <div>x is 8!</div>

+            }

+            $elif x == 7 {

+                <div>x is 7!</div>

+            }

+            $else {

+                <div>x is neither!</div>

+            }

+        """

+        const expected = html"""

+            <p>Test if/elif/else</p>

+            <div>x is neither!</div>

+        """

+        doAssert actual() == expected

+

+    block: #multiLineStatements

+        proc actual: string = tmpli html"""

+            <p>Test multiline statements</p>

+            ${

+                var x = 5

+                var y = 7

+            }

+            <span>$x</span><span>$y</span>

+        """

+        const expected = html"""

+            <p>Test multiline statements</p>

+            <span>5</span><span>7</span>

+        """

+        doAssert actual() == expected

+

+    block: #caseOfElse

+        proc actual: string = tmpli html"""

+            <p>Test case</p>

+            $case x

+            $of 5 {

+                <div>x == 5</div>

+            }

+            $of 6 {

+                <div>x == 6</div>

+            }

+            $else {}

+        """

+        const expected = html"""

+            <p>Test case</p>

+            <div>x == 5</div>

+        """

+        doAssert actual() == expected

+

+

+

+when true: #embeddingTest

+    proc no_substitution: string = tmpli html"""

+        <h1>Template test!</h1>

+    """

+

+    # # Single variable substitution

+    proc substitution(who = "nobody"): string = tmpli html"""

+        <div id="greeting">hello $who!</div>

+    """

+

+    # Expression template

+    proc test_expression(nums: openarray[int] = []): string =

+        var i = 2

+        tmpli html"""

+            $(no_substitution())

+            $(substitution("Billy"))

+            <div id="age">Age: $($nums[i] & "!!")</div>

+        """

+

+    proc test_statements(nums: openarray[int] = []): string =

+        tmpli html"""

+            $(test_expression(nums))

+            $if true {

+                <ul>

+                    $for i in nums {

+                        <li>$(i * 2)</li>

+                    }

+                </ul>

+            }

+        """

+

+    var actual = test_statements([0,1,2])

+    const expected = html"""

+        <h1>Template test!</h1>

+        <div id="greeting">hello Billy!</div>

+        <div id="age">Age: 2!!</div>

+        <ul>

+            <li>0</li>

+            <li>2</li>

+            <li>4</li>

+        </ul>

+    """

+    doAssert actual == expected

+

+

+when defined(future):

+    block: #tryCatch

+        proc actual: string = tmpli html"""

+            <p>Test try/catch</p>

+            <div>

+                $try {

+                    <div>Lets try this!</div>

+                }

+                $except {

+                    <div>Uh oh!</div>

+                }

+            </div>

+        """

+        const expected = html"""

+            <p>Test try/catch</p>

+            <div>

+                    <div>Lets try this!</div>

+            </div>

+        """

+        doAssert actual() == expected
\ No newline at end of file
diff --git a/tests/template/t_otemplates.nim b/tests/template/t_otemplates.nim
new file mode 100644
index 000000000..7de728ab2
--- /dev/null
+++ b/tests/template/t_otemplates.nim
@@ -0,0 +1,345 @@
+discard """
+  output: "Success"
+"""
+
+# Ref:

+# http://nimrod-lang.org/macros.html

+# http://nimrod-lang.org/parseutils.html

+

+

+# Imports

+import tables, parseutils, macros, strutils

+import annotate

+export annotate

+

+

+# Fields

+const identChars = {'a'..'z', 'A'..'Z', '0'..'9', '_'}

+

+

+# Procedure Declarations

+proc parse_template(node: PNimrodNode, value: string) {.compiletime.}

+

+

+# Procedure Definitions

+proc substring(value: string, index: int, length = -1): string {.compiletime.} =

+    ## Returns a string at most `length` characters long, starting at `index`.

+    return if length < 0:    value.substr(index)

+           elif length == 0: ""

+           else:             value.substr(index, index + length-1)

+

+

+proc parse_thru_eol(value: string, index: int): int {.compiletime.} =

+    ## Reads until and past the end of the current line, unless

+    ## a non-whitespace character is encountered first

+    var remainder: string

+    var read = value.parseUntil(remainder, {0x0A.char}, index)

+    if remainder.skipWhitespace() == read:

+        return read + 1

+

+

+proc trim_after_eol(value: var string) {.compiletime.} =

+    ## Trims any whitespace at end after \n

+    var toTrim = 0

+    for i in countdown(value.len-1, 0):

+        # If \n, return

+        if value[i] in [' ', '\t']: inc(toTrim)

+        else: break

+

+    if toTrim > 0:

+        value = value.substring(0, value.len - toTrim)

+

+

+proc trim_eol(value: var string) {.compiletime.} =

+    ## Removes everything after the last line if it contains nothing but whitespace

+    for i in countdown(value.len - 1, 0):

+        # If \n, trim and return

+        if value[i] == 0x0A.char:

+            value = value.substr(0, i)

+            break

+

+        # This is the first character

+        if i == 0:

+            value = ""

+            break

+

+        # Skip change

+        if not (value[i] in [' ', '\t']): break

+

+

+proc detect_indent(value: string, index: int): int {.compiletime.} =

+    ## Detects how indented the line at `index` is.

+    # Seek to the beginning of the line.

+    var lastChar = index

+    for i in countdown(index, 0):

+        if value[i] == 0x0A.char:

+            # if \n, return the indentation level

+            return lastChar - i

+        elif not (value[i] in [' ', '\t']):

+            # if non-whitespace char, decrement lastChar

+            dec(lastChar)

+

+

+proc parse_thru_string(value: string, i: var int, strType = '"') {.compiletime.} =

+    ## Parses until ending " or ' is reached.

+    inc(i)

+    if i < value.len-1:

+        inc(i, value.skipUntil({'\\', strType}, i))

+

+

+proc parse_to_close(value: string, index: int, open='(', close=')', opened=0): int {.compiletime.} =

+    ## Reads until all opened braces are closed

+    ## ignoring any strings "" or ''

+    var remainder   = value.substring(index)

+    var open_braces = opened

+    result = 0

+

+    while result < remainder.len:

+        var c = remainder[result]

+

+        if   c == open:  inc(open_braces)

+        elif c == close: dec(open_braces)

+        elif c == '"':   remainder.parse_thru_string(result)

+        elif c == '\'':  remainder.parse_thru_string(result, '\'')

+

+        if open_braces == 0: break

+        else: inc(result)

+

+

+iterator parse_stmt_list(value: string, index: var int): string =

+    ## Parses unguided ${..} block

+    var read        = value.parse_to_close(index, open='{', close='}')

+    var expressions = value.substring(index + 1, read - 1).split({ ';', 0x0A.char })

+

+    for expression in expressions:

+        let value = expression.strip

+        if value.len > 0:

+            yield value

+

+    #Increment index & parse thru EOL

+    inc(index, read + 1)

+    inc(index, value.parse_thru_eol(index))

+

+

+iterator parse_compound_statements(value, identifier: string, index: int): string =

+    ## Parses through several statements, i.e. if {} elif {} else {}

+    ## and returns the initialization of each as an empty statement

+    ## i.e. if x == 5 { ... } becomes if x == 5: nil.

+

+    template get_next_ident(expected): stmt =

+        var nextIdent: string

+        discard value.parseWhile(nextIdent, {'$'} + identChars, i)

+

+        var next: string

+        var read: int

+

+        if nextIdent == "case":

+            # We have to handle case a bit differently

+            read = value.parseUntil(next, '$', i)

+            inc(i, read)

+            yield next.strip(leading=false) & "\n"

+

+        else:

+            read = value.parseUntil(next, '{', i)

+

+            if nextIdent in expected:

+                inc(i, read)

+                # Parse until closing }, then skip whitespace afterwards

+                read = value.parse_to_close(i, open='{', close='}')

+                inc(i, read + 1)

+                inc(i, value.skipWhitespace(i))

+                yield next & ": nil\n"

+

+            else: break

+

+

+    var i = index

+    while true:

+        # Check if next statement would be valid, given the identifier

+        if identifier in ["if", "when"]:

+            get_next_ident([identifier, "$elif", "$else"])

+

+        elif identifier == "case":

+            get_next_ident(["case", "$of", "$elif", "$else"])

+

+        elif identifier == "try":

+            get_next_ident(["try", "$except", "$finally"])

+

+

+proc parse_complex_stmt(value, identifier: string, index: var int): PNimrodNode {.compiletime.} =

+    ## Parses if/when/try /elif /else /except /finally statements

+

+    # Build up complex statement string

+    var stmtString = newString(0)

+    var numStatements = 0

+    for statement in value.parse_compound_statements(identifier, index):

+        if statement[0] == '$': stmtString.add(statement.substr(1))

+        else:                   stmtString.add(statement)

+        inc(numStatements)

+

+    # Parse stmt string

+    result = parseExpr(stmtString)

+

+    var resultIndex = 0

+

+    # Fast forward a bit if this is a case statement

+    if identifier == "case":

+        inc(resultIndex)

+

+    while resultIndex < numStatements:

+

+        # Detect indentation

+        let indent = detect_indent(value, index)

+

+        # Parse until an open brace `{`

+        var read = value.skipUntil('{', index)

+        inc(index, read + 1)

+

+        # Parse through EOL

+        inc(index, value.parse_thru_eol(index))

+

+        # Parse through { .. }

+        read = value.parse_to_close(index, open='{', close='}', opened=1)

+

+        # Add parsed sub-expression into body

+        var body       = newStmtList()

+        var stmtString = value.substring(index, read)

+        trim_after_eol(stmtString)

+        stmtString = reindent(stmtString, indent)

+        parse_template(body, stmtString)

+        inc(index, read + 1)

+

+        # Insert body into result

+        var stmtIndex = macros.high(result[resultIndex])

+        result[resultIndex][stmtIndex] = body

+

+        # Parse through EOL again & increment result index

+        inc(index, value.parse_thru_eol(index))

+        inc(resultIndex)

+

+

+proc parse_simple_statement(value: string, index: var int): PNimrodNode {.compiletime.} =

+    ## Parses for/while

+

+    # Detect indentation

+    let indent = detect_indent(value, index)

+

+    # Parse until an open brace `{`

+    var splitValue: string

+    var read = value.parseUntil(splitValue, '{', index)

+    result   = parseExpr(splitValue & ":nil")

+    inc(index, read + 1)

+

+    # Parse through EOL

+    inc(index, value.parse_thru_eol(index))

+

+    # Parse through { .. }

+    read = value.parse_to_close(index, open='{', close='}', opened=1)

+

+    # Add parsed sub-expression into body

+    var body       = newStmtList()

+    var stmtString = value.substring(index, read)

+    trim_after_eol(stmtString)

+    stmtString = reindent(stmtString, indent)

+    parse_template(body, stmtString)

+    inc(index, read + 1)

+

+    # Insert body into result

+    var stmtIndex = macros.high(result)

+    result[stmtIndex] = body

+

+    # Parse through EOL again

+    inc(index, value.parse_thru_eol(index))

+

+

+proc parse_until_symbol(node: PNimrodNode, value: string, index: var int): bool {.compiletime.} =

+    ## Parses a string until a $ symbol is encountered, if

+    ## two $$'s are encountered in a row, a split will happen

+    ## removing one of the $'s from the resulting output

+    var splitValue: string

+    var read = value.parseUntil(splitValue, '$', index)

+    var insertionPoint = node.len

+

+    inc(index, read + 1)

+    if index < value.len:

+

+        case value[index]

+        of '$':

+            # Check for duplicate `$`, meaning this is an escaped $

+            node.add newCall("add", ident("result"), newStrLitNode("$"))

+            inc(index)

+

+        of '(':

+            # Check for open `(`, which means parse as simple single-line expression.

+            trim_eol(splitValue)

+            read = value.parse_to_close(index) + 1

+            node.add newCall("add", ident("result"),

+                newCall(bindSym"strip", parseExpr("$" & value.substring(index, read)))

+            )

+            inc(index, read)

+

+        of '{':

+            # Check for open `{`, which means open statement list

+            trim_eol(splitValue)

+            for s in value.parse_stmt_list(index):

+                node.add parseExpr(s)

+

+        else:

+            # Otherwise parse while valid `identChars` and make expression w/ $

+            var identifier: string

+            read = value.parseWhile(identifier, identChars, index)

+

+            if identifier in ["for", "while"]:

+                ## for/while means open simple statement

+                trim_eol(splitValue)

+                node.add value.parse_simple_statement(index)

+

+            elif identifier in ["if", "when", "case", "try"]:

+                ## if/when/case/try means complex statement

+                trim_eol(splitValue)

+                node.add value.parse_complex_stmt(identifier, index)

+

+            elif identifier.len > 0:

+                ## Treat as simple variable

+                node.add newCall("add", ident("result"), newCall("$", ident(identifier)))

+                inc(index, read)

+

+        result = true

+

+    # Insert

+    if splitValue.len > 0:

+        node.insert insertionPoint, newCall("add", ident("result"), newStrLitNode(splitValue))

+

+

+proc parse_template(node: PNimrodNode, value: string) =

+    ## Parses through entire template, outputing valid

+    ## Nimrod code into the input `node` AST.

+    var index = 0

+    while index < value.len and

+          parse_until_symbol(node, value, index): nil

+

+

+macro tmpli*(body: expr): stmt =

+    result = newStmtList()

+

+    result.add parseExpr("result = \"\"")

+

+    var value = if body.kind in nnkStrLit..nnkTripleStrLit: body.strVal

+                else: body[1].strVal

+

+    parse_template(result, reindent(value))

+

+

+macro tmpl*(body: expr): stmt =

+    result = newStmtList()

+

+    var value = if body.kind in nnkStrLit..nnkTripleStrLit: body.strVal

+                else: body[1].strVal

+

+    parse_template(result, reindent(value))

+

+

+# Run tests

+when isMainModule:

+    include otests
+    echo "Success"
diff --git a/tests/testament/caasdriver.nim b/tests/testament/caasdriver.nim
index 22c5ed6fa..ddfe88273 100644
--- a/tests/testament/caasdriver.nim
+++ b/tests/testament/caasdriver.nim
@@ -86,6 +86,10 @@ proc doProcCommand(session: var TNimrodSession, command: string): string =
 
 proc doCommand(session: var TNimrodSession, command: string) =
   if session.mode == CaasRun:
+    if not session.nim.running:
+      session.lastOutput = "FAILED TO EXECUTE: " & command & "\n" &
+          "Exit code " & $session.nim.peekExitCode
+      return
     session.lastOutput = doCaasCommand(session,
                                        command & " " & session.filename)
   else:
@@ -102,7 +106,7 @@ proc close(session: var TNimrodSession) {.destructor.} =
   if session.mode == CaasRun:
     session.nim.close
 
-proc doScenario(script: string, output: PStream, mode: TRunMode): bool =
+proc doScenario(script: string, output: PStream, mode: TRunMode, verbose: bool): bool =
   result = true
 
   var f = open(script)
@@ -134,7 +138,7 @@ proc doScenario(script: string, output: PStream, mode: TRunMode): bool =
         continue
       elif line.startsWith(">"):
         s.doCommand(line.substr(1).strip)
-        output.writeln line, "\n", s.lastOutput
+        output.writeln line, "\n", if verbose: s.lastOutput else: ""
       else:
         var expectMatch = true
         var pattern = s.replaceVars(line)
@@ -151,13 +155,14 @@ proc doScenario(script: string, output: PStream, mode: TRunMode): bool =
           output.writeln "FAILURE ", line
           result = false
 
-iterator caasTestsRunner*(filter = ""): tuple[test, output: string,
-                                              status: bool, mode: TRunMode] =
+iterator caasTestsRunner*(filter = "", verbose = false): tuple[test,
+                                              output: string, status: bool,
+                                              mode: TRunMode] =
   for scenario in os.walkFiles(TesterDir / "caas/*.txt"):
     if filter.len > 0 and find(scenario, filter) == -1: continue
     for mode in modes:
       var outStream = newStringStream()
-      let r = doScenario(scenario, outStream, mode)
+      let r = doScenario(scenario, outStream, mode, verbose)
       yield (scenario, outStream.data, r, mode)
 
 when isMainModule:
@@ -175,9 +180,12 @@ when isMainModule:
   if verbose and len(filter) > 0:
     echo "Running only test cases matching filter '$1'" % [filter]
 
-  for test, output, result, mode in caasTestsRunner(filter):
+  for test, output, result, mode in caasTestsRunner(filter, verbose):
     if not result or verbose:
-      echo test, "\n", output, "-> ", $mode, ":", $result, "\n-----"
+      echo "Mode ", $mode, " (", if result: "succeeded)" else: "failed)"
+      echo test
+      echo output
+      echo "---------\n"
     if not result:
       failures += 1
 
diff --git a/tests/testament/categories.nim b/tests/testament/categories.nim
index bb9c90d2a..841eb8159 100644
--- a/tests/testament/categories.nim
+++ b/tests/testament/categories.nim
@@ -282,26 +282,33 @@ proc testBabelPackages(r: var TResults, cat: Category, filter: PackageFilter) =
     echo("[Warning] - Cannot run babel tests: Babel update failed.")
     return
 
-  for name, url in listPackages(filter):
-    var test = makeTest(name, "", cat)
-    echo(url)
-    let
-      installProcess = startProcess(babelExe, "", ["install", "-y", name])
-      installStatus = waitForExitEx(installProcess)
-    installProcess.close
-    if installStatus != quitSuccess:
-      r.addResult(test, "", "", reInstallFailed)
-      continue
+  let packageFileTest = makeTest("PackageFileParsed", "", cat)
+  try:
+    for name, url in listPackages(filter):
+      var test = makeTest(name, "", cat)
+      echo(url)
+      let
+        installProcess = startProcess(babelExe, "", ["install", "-y", name])
+        installStatus = waitForExitEx(installProcess)
+      installProcess.close
+      if installStatus != quitSuccess:
+        r.addResult(test, "", "", reInstallFailed)
+        continue
+
+      let
+        buildPath = getPackageDir(name)[0.. -3]
+      let
+        buildProcess = startProcess(babelExe, buildPath, ["build"])
+        buildStatus = waitForExitEx(buildProcess)
+      buildProcess.close
+      if buildStatus != quitSuccess:
+        r.addResult(test, "", "", reBuildFailed)
+      r.addResult(test, "", "", reSuccess)
+    r.addResult(packageFileTest, "", "", reSuccess)
+  except EJsonParsingError:
+    echo("[Warning] - Cannot run babel tests: Invalid package file.")
+    r.addResult(packageFileTest, "", "", reBuildFailed)
 
-    let
-      buildPath = getPackageDir(name)[0.. -3]
-    let
-      buildProcess = startProcess(babelExe, buildPath, ["build"])
-      buildStatus = waitForExitEx(buildProcess)
-    buildProcess.close
-    if buildStatus != quitSuccess:
-      r.addResult(test, "", "", reBuildFailed)
-    r.addResult(test, "", "", reSuccess)
 
 # ----------------------------------------------------------------------------
 
diff --git a/tests/testament/specs.nim b/tests/testament/specs.nim
index 225ea1891..6e72f4b5e 100644
--- a/tests/testament/specs.nim
+++ b/tests/testament/specs.nim
@@ -46,7 +46,7 @@ type
     msg*: string
     ccodeCheck*: string
     err*: TResultEnum
-    substr*: bool
+    substr*, sortoutput*: bool
     targets*: set[TTarget]
 
 const
@@ -113,6 +113,8 @@ proc parseSpec*(filename: string): TSpec =
       result.action = actionRun
       result.outp = e.value
       result.substr = true
+    of "sortoutput":
+      result.sortoutput = parseCfgBool(e.value)
     of "exitcode": 
       discard parseInt(e.value, result.exitCode)
     of "msg":
diff --git a/tests/testament/tester.nim b/tests/testament/tester.nim
index 50d0e6eac..fc6b4ff95 100644
--- a/tests/testament/tester.nim
+++ b/tests/testament/tester.nim
@@ -11,7 +11,8 @@
 
 import
   parseutils, strutils, pegs, os, osproc, streams, parsecfg, json,
-  marshal, backend, parseopt, specs, htmlgen, browsers, terminal
+  marshal, backend, parseopt, specs, htmlgen, browsers, terminal,
+  algorithm
 
 const
   resultsFile = "testresults.html"
@@ -150,6 +151,11 @@ proc codegenCheck(test: TTest, check: string, given: var TSpec) =
     except EIO:
       given.err = reCodeNotFound
 
+proc makeDeterministic(s: string): string =
+  var x = splitLines(s)
+  sort(x, system.cmp)
+  result = join(x, "\n")
+
 proc testSpec(r: var TResults, test: TTest) =
   # major entry point for a single test
   let tname = test.name.addFileExt(".nim")
@@ -191,8 +197,10 @@ proc testSpec(r: var TResults, test: TTest) =
             r.addResult(test, "exitcode: " & $expected.exitCode,
                               "exitcode: " & $exitCode, reExitCodesDiffer)
           else:
-            if strip(buf.string) != strip(expected.outp):
-              if not (expected.substr and expected.outp in buf.string):
+            var bufB = strip(buf.string)
+            if expected.sortoutput: bufB = makeDeterministic(bufB)
+            if bufB != strip(expected.outp):
+              if not (expected.substr and expected.outp in bufB):
                 given.err = reOutputsDiffer
             if given.err == reSuccess:
               codeGenCheck(test, expected.ccodeCheck, given)
diff --git a/tests/vm/tarrayboundeval.nim b/tests/vm/tarrayboundeval.nim
index 9b33a2415..07aac4c4e 100644
--- a/tests/vm/tarrayboundeval.nim
+++ b/tests/vm/tarrayboundeval.nim
@@ -1,6 +1,7 @@
 discard """
   output: '''7
-8 8'''
+8 8
+-2'''
 """
 
 #bug 1063
@@ -21,3 +22,10 @@ type
     internal: array[int((KeyMax + 31)/32), cuint]
     
 echo myconst, " ", int((KeyMax + 31) / 32)
+
+#bug 1304 or something:
+
+const constArray: array [-3..2, int] = [-3, -2, -1, 0, 1, 2]
+
+echo constArray[-2]
+
diff --git a/tests/vm/teval1.nim b/tests/vm/teval1.nim
index a02f26592..cdb4ad8e2 100644
--- a/tests/vm/teval1.nim
+++ b/tests/vm/teval1.nim
@@ -16,4 +16,9 @@ const
   
 echo "##", x, "##"
 
+# bug #1310
+static:
+    var i, j: set[int8] = {}
+    var k = i + j
+
 
diff --git a/tinyc/tests/gcctestsuite.sh b/tinyc/tests/gcctestsuite.sh
index bd9204b2b..bd9204b2b 100755..100644
--- a/tinyc/tests/gcctestsuite.sh
+++ b/tinyc/tests/gcctestsuite.sh
diff --git a/tinyc/texi2pod.pl b/tinyc/texi2pod.pl
index d86e176f1..d86e176f1 100755..100644
--- a/tinyc/texi2pod.pl
+++ b/tinyc/texi2pod.pl
diff --git a/todo.txt b/todo.txt
index 996067175..16c05186a 100644
--- a/todo.txt
+++ b/todo.txt
@@ -1,6 +1,28 @@
 version 0.9.6
 =============
 
+- scopes are still broken for generic instantiation!
+- integrate the new LL into the devel branch
+- start experimental branch
+- overloading of '='; general lift mechanism
+
+Concurrency
+-----------
+
+- 'gcsafe' inferrence needs to be fixed
+- the disjoint checker needs to deal with 'a = spawn f(); g = spawn f()'
+- implement 'deepCopy' builtin
+- implement 'foo[1..4] = spawn(f[4..7])'
+- support for exception propagation
+- Minor: The copying of the 'ref Promise' into the thead local storage only
+  happens to work due to the write barrier's implementation
+- implement lock levels --> first without the more complex race avoidance
+- document the new 'spawn' and 'parallel' statements
+
+
+Misc
+----
+
 - fix the bug that keeps 'defer' template from working
 - make '--implicitStatic:on' the default
 - fix the tuple unpacking in lambda bug
@@ -12,6 +34,7 @@ version 0.9.6
 - type API for macros; make 'spawn' a macro
 - markAndSweepGC should expose an API for fibers
 - prevent 'alloc(TypeWithGCedMemory)'
+- some table related tests are wrong (memory usage checks)
 
 
 Bugs
@@ -138,7 +161,6 @@ Not essential for 1.0.0
 - implement the "snoopResult" pragma; no, make a strutils with string append
   semantics instead ...
 - implement "closure tuple consists of a single 'ref'" optimization
-- optimize method dispatchers
 - new feature: ``distinct T with operations``
 - arglist as a type (iterator chaining); variable length type lists for generics
 - implement marker procs for message passing
diff --git a/web/assets/style.css b/web/assets/style.css
index 5cee279fc..91bb4bd8a 100644
--- a/web/assets/style.css
+++ b/web/assets/style.css
@@ -93,7 +93,7 @@ html, body {
         border-left:10px solid #8f9698;
         background:#f3f6f8;
         font-size:15px;
-        font-family:courier;
+        font-family:courier, monospace;
         letter-spacing:0;
         line-height:17px;
       }
diff --git a/web/babelpkglist.nim b/web/babelpkglist.nim
index 378d4ce30..8745c9f99 100644
--- a/web/babelpkglist.nim
+++ b/web/babelpkglist.nim
@@ -28,13 +28,19 @@ proc processContent(content: string) =
     officialCount = 0
     unofficialList = ""
     unofficialCount = 0
+  let
+    endings = {'.', '!'}
 
   for pkg in jsonArr:
     assert pkg.kind == JObject
     let pkgWeb =
       if pkg.hasKey("web"): pkg["web"].str
       else: pkg["url"].str
-    let listItem = li(a(href=pkgWeb, pkg["name"].str), " ", pkg["description"].str)
+    let
+      desc = pkg["description"].str
+      # Review array index access when #1291 is solved.
+      dot = if desc.high > 0 and desc[<desc.high] in endings: "" else: "."
+      listItem = li(a(href=pkgWeb, pkg["name"].str), " ", desc & dot)
     if pkg["url"].str.startsWith("git://github.com/nimrod-code") or
        "official" in pkg["tags"].elems:
       officialCount.inc
diff --git a/web/news.txt b/web/news.txt
index 0bbae7b7b..a8d525443 100644
--- a/web/news.txt
+++ b/web/news.txt
@@ -2,6 +2,29 @@
 News
 ====
 
+..
+  2014-06-29 Version 0.9.6 released
+  =================================
+
+  Changes affecting backwards compatibility
+  -----------------------------------------
+
+  - ``spawn`` now uses an elaborate self-adapting thread pool and as such
+    has been moved into its own module. So to use it, you now have to import
+    ``threadpool``.
+  - The symbol binding rules in generics changed: ``bar`` in ``foo.bar`` is
+    now considered for implicit early binding.
+  - ``c2nim`` moved into its own repository and is now a Babel package.
+  - ``pas2nim`` moved into its own repository and is now a Babel package.
+
+
+  Library Additions
+  -----------------
+
+  - Added module ``cpuinfo``.
+  - Added module ``threadpool``.
+  - ``sequtils.distnct`` has been renamed to ``sequtils.deduplicate``.
+  - Added ``algorithm.reversed``
 
 
 2014-04-21 Version 0.9.4 released
diff --git a/web/nimrod.ini b/web/nimrod.ini
index 14701ecea..7b0a91c19 100644
--- a/web/nimrod.ini
+++ b/web/nimrod.ini
@@ -36,9 +36,9 @@ UNIX. We don't believe this to be a coincidence. - Jeremy S. Anderson."""
 
 
 [Documentation]
-doc: "endb;intern;apis;lib;manual;tut1;tut2;nimrodc;overview;filters;trmacros"
-doc: "tools;c2nim;niminst;nimgrep;gc;estp;idetools;docgen"
-pdf: "manual;lib;tut1;tut2;nimrodc;c2nim;niminst;gc"
+doc: "endb;intern;apis;lib;manual;tut1;tut2;nimrodc;overview;filters"
+doc: "tools;c2nim;niminst;nimgrep;gc;estp;idetools;docgen;koch;backends.txt"
+pdf: "manual;lib;tut1;tut2;nimrodc;niminst;gc"
 srcdoc2: "system.nim;impure/graphics;wrappers/sdl"
 srcdoc2: "core/macros;pure/marshal;core/typeinfo;core/unsigned"
 srcdoc2: "impure/re;pure/sockets"
@@ -64,6 +64,15 @@ srcdoc2: "pure/nimprof;pure/unittest;packages/docutils/highlite"
 srcdoc2: "packages/docutils/rst;packages/docutils/rstast"
 srcdoc2: "packages/docutils/rstgen;pure/logging;pure/asyncdispatch;pure/asyncnet"
 srcdoc2: "pure/rawsockets;pure/asynchttpserver;pure/net;pure/selectors;pure/future"
+srcdoc2: "wrappers/expat;wrappers/readline/history"
+srcdoc2: "wrappers/libsvm.nim;wrappers/libuv"
+srcdoc2: "wrappers/zip/zlib;wrappers/zip/libzip"
+srcdoc2: "wrappers/libcurl;pure/md5;wrappers/mysql;wrappers/iup"
+srcdoc2: "posix/posix;wrappers/odbcsql"
+srcdoc2: "wrappers/tre;wrappers/openssl;wrappers/pcre"
+srcdoc2: "wrappers/sqlite3;wrappers/postgres;wrappers/tinyc"
+srcdoc2: "wrappers/readline/readline;wrappers/readline/rltypedefs"
+srcdoc2: "wrappers/joyent_http_parser"
 
 webdoc: "wrappers/libcurl;pure/md5;wrappers/mysql;wrappers/iup"
 webdoc: "wrappers/sqlite3;wrappers/postgres;wrappers/tinyc"